From 88948eb8eeab9d81cf9e8cc3818f16a9fd68e517 Mon Sep 17 00:00:00 2001 From: tokumeikoi Date: Sun, 11 Jul 2021 01:13:09 +0900 Subject: [PATCH] fix: change plan refund surplus amount --- app/Services/OrderService.php | 2 +- app/Services/UserService.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Services/OrderService.php b/app/Services/OrderService.php index 6d4ed099..2a4182c2 100644 --- a/app/Services/OrderService.php +++ b/app/Services/OrderService.php @@ -202,7 +202,7 @@ class OrderService if ($item->cycle === 'onetime_price') continue; if ($this->orderIsUsed($item)) continue; $orderSurplusMonth = $orderSurplusMonth + self::STR_TO_TIME[$item->cycle]; - $orderSurplusAmount = $orderSurplusAmount + ($item['total_amount'] + $item['balance_amount']); + $orderSurplusAmount = $orderSurplusAmount + ($item['total_amount'] + $item['balance_amount'] + $item['surplus_amount']); } if (!$orderSurplusMonth || !$orderSurplusAmount) return; $monthUnitPrice = $orderSurplusAmount / $orderSurplusMonth; diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 5d3f2f0f..98ba804d 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -55,7 +55,7 @@ class UserService public function addBalance(int $userId, int $balance):bool { - $user = User::find($userId); + $user = User::lockForUpdate()->find($userId); if (!$user) { return false; }