core/DB.php
public static function transaction($func)
    {
        try {
            DB::beginTransaction();
            $func();
            DB::commit();
        } catch (\Exception $exception) {
            DB::rollBack();
            throw $exception;
        }
    }
public static function transaction($func)
    {
        try {
            DB::beginTransaction();
            $func();
            DB::commit();
        } catch (\Exception $exception) {
            DB::rollBack();
            throw $exception;
        }
    }
事务闭包
@param $func
@throws \Exception