This commit is contained in:
Tokumeikoi 2020-05-02 14:29:04 +08:00
parent c7a45c9d3d
commit dae5d2a2a3

View File

@ -128,13 +128,13 @@ class OrderService
->where('status', 3); ->where('status', 3);
$totalValue = $orderModel->sum('total_amount') + $orderModel->sum('balance_amount'); $totalValue = $orderModel->sum('total_amount') + $orderModel->sum('balance_amount');
if ($totalValue <= 0) {
return;
}
$totalMonth = 0; $totalMonth = 0;
foreach ($orderModel->get() as $item) { foreach ($orderModel->get() as $item) {
$totalMonth = $totalMonth + $strToMonth[$item->cycle]; $totalMonth = $totalMonth + $strToMonth[$item->cycle];
} }
if (!$totalValue || !$totalMonth) {
return;
}
$unitPrice = $totalValue / $totalMonth; $unitPrice = $totalValue / $totalMonth;
$remainingMonth = ($user->expired_at - time()) / 2678400; $remainingMonth = ($user->expired_at - time()) / 2678400;
$result = $unitPrice * $remainingMonth; $result = $unitPrice * $remainingMonth;