src/Leevel/Database/Ddd/UnitOfWork.php
public function transaction(Closure $action)
    {
        $this->beginTransaction();

        try {
            $result = $action($this);

            $this->flush();
            $this->commit();

            return $result;
        } catch (Throwable $e) {
            $this->rollBack();
            $this->close();

            throw $e;
        }
    }
public function transaction(Closure $action)
    {
        $this->beginTransaction();

        try {
            $result = $action($this);

            $this->flush();
            $this->commit();

            return $result;
        } catch (Throwable $e) {
            $this->rollBack();
            $this->close();

            throw $e;
        }
    }
执行数据库事务.

@param \Closure $action

@return mixed