diff --git a/app/Http/Controllers/Api/VerificationController.php b/app/Http/Controllers/Api/VerificationController.php index 709eb3b..4ca94d0 100644 --- a/app/Http/Controllers/Api/VerificationController.php +++ b/app/Http/Controllers/Api/VerificationController.php @@ -87,13 +87,22 @@ class VerificationController extends Controller return $this->error('对不起,你没有该订单的核销权限'); } + DB::beginTransaction(); try { //改变订单状态为已完成 $order->status = OrderStatus::SUCCESS; $order->save(); - return $this->success(); + //扣除供应商冻结的交易金 + $supplier = Supplier::find($order->supplier_id); + $supplier->deposit_used = $supplier->deposit_used + $order->deposit; + $supplier->deposit_frozen = $supplier->deposit_frozen - $order->deposit; + $supplier->save(); //需要用save才能执行模型事件记录日志 + + DB::commit(); + return $this->success('核销成功'); } catch (\Exception $e) { + DB::rollBack(); return $this->error($e->getMessage()); } }