mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-03 18:40:52 +08:00
fix: 规范数据库事物的使用,解决在swoole环境下可能会出现事物一直不被提交的问题
This commit is contained in:
@@ -64,17 +64,22 @@ class CheckCommission extends Command
|
||||
->where('invite_user_id', '!=', NULL)
|
||||
->get();
|
||||
foreach ($orders as $order) {
|
||||
DB::beginTransaction();
|
||||
if (!$this->payHandle($order->invite_user_id, $order)) {
|
||||
try{
|
||||
DB::beginTransaction();
|
||||
if (!$this->payHandle($order->invite_user_id, $order)) {
|
||||
DB::rollBack();
|
||||
continue;
|
||||
}
|
||||
$order->commission_status = 2;
|
||||
if (!$order->save()) {
|
||||
DB::rollBack();
|
||||
continue;
|
||||
}
|
||||
DB::commit();
|
||||
} catch (\Exception $e){
|
||||
DB::rollBack();
|
||||
continue;
|
||||
throw $e;
|
||||
}
|
||||
$order->commission_status = 2;
|
||||
if (!$order->save()) {
|
||||
DB::rollBack();
|
||||
continue;
|
||||
}
|
||||
DB::commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user