Tokumeikoi 4 ani în urmă
părinte
comite
dae5d2a2a3
1 a modificat fișierele cu 3 adăugiri și 3 ștergeri
  1. 3 3
      app/Services/OrderService.php

+ 3 - 3
app/Services/OrderService.php

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