fix: change plan refund surplus amount

This commit is contained in:
tokumeikoi 2021-07-11 01:13:09 +09:00
parent 4d38ce3968
commit 88948eb8ee
2 changed files with 2 additions and 2 deletions

View File

@ -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;

View File

@ -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;
}