fix: 修复多处可能出现的事务安全问题

This commit is contained in:
xboard 2023-12-14 13:07:57 +08:00
parent b8009142ed
commit 7bac88d593
4 changed files with 4 additions and 1 deletions

View File

@ -172,6 +172,7 @@ class OrderController extends Controller
$orderService->setInvite($user);
if (!$order->save()) {
DB::rollBack();
return $this->fail([500 ,'订单创建失败']);
}
DB::commit();

View File

@ -49,12 +49,12 @@ class PlanController extends Controller
}
$plan->update($params);
DB::commit();
return $this->success(true);
} catch (\Exception $e) {
DB::rollBack();
\Log::error($e);
return $this->fail([500 ,'保存失败']);
}
return $this->success(true);
}
if (!Plan::create($params)) {
return $this->fail([500 ,'创建失败']);

View File

@ -144,6 +144,7 @@ class OrderController extends Controller
}
if (!$order->save()) {
DB::rollBack();
return $this->fail([400, __('Failed to create order')]);
}
DB::commit();

View File

@ -169,6 +169,7 @@ class TicketController extends Controller
'message' => $message
]);
if (!$ticketMessage) {
DB::rollBack();
return $this->fail([400, __('Failed to open ticket')]);
}
DB::commit();