之前做项目用到了事务回滚这个机制。我把代码贴出来多多交流给点意见,我用的是laravel 5.1bane版本的,
public static function createDeal($to_status, $params, $new_balance, $update = true)
{
\DB::beginTransaction();
try {
$update_order_status = \DB::table('wallet_order')
->where('order_id', $params['order_id'])
->update(['to_status' => $to_status, 'update_time' => $params['pay_time']]);
if (!$update_order_status) {
throw new \Exception("update order error");
}
&n