From 12caada8dd18b557ecb21f40e4bc15e660624f9b Mon Sep 17 00:00:00 2001 From: tokumeikoi Date: Sat, 30 Apr 2022 02:38:22 +0800 Subject: [PATCH] update: surplus by onetime --- app/Services/OrderService.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Services/OrderService.php b/app/Services/OrderService.php index 9cb26bf2..792a01ec 100644 --- a/app/Services/OrderService.php +++ b/app/Services/OrderService.php @@ -171,7 +171,10 @@ class OrderService ->first(); if (!$lastOneTimeOrder) return; $nowUserTraffic = $user->transfer_enable / 1073741824; - $trafficUnitPrice = ($lastOneTimeOrder->total_amount + $lastOneTimeOrder->balance_amount) / $nowUserTraffic; + if (!$nowUserTraffic) return; + $paidTotalAmount = ($lastOneTimeOrder->total_amount + $lastOneTimeOrder->balance_amount); + if (!$paidTotalAmount) return; + $trafficUnitPrice = $paidTotalAmount / $nowUserTraffic; $notUsedTraffic = $nowUserTraffic - (($user->u + $user->d) / 1073741824); $result = $trafficUnitPrice * $notUsedTraffic; $orderModel = Order::where('user_id', $user->id)->where('period', '!=', 'reset_price')->where('status', 3);