add balance payment

This commit is contained in:
Tokumeikoi
2020-03-17 20:16:55 +08:00
parent 3075f0d411
commit 6fba0b6dab
3 changed files with 20 additions and 5 deletions

View File

@ -14,20 +14,23 @@ class OrderService
$this->order = $order;
}
public function cancel():void
public function cancel():bool
{
$order = $this->order;
DB::beginTransaction();
$order->status = 2;
if (!$order->save()) {
DB::rollBack();
return false;
}
if ($order->balance_amount) {
$userService = new UserService();
if (!$userService->addBalance($order->user_id, $order->balance_amount)) {
DB::rollBack();
return false;
}
}
DB::commit();
return true;
}
}