shish 4 năm trước cách đây
mục cha
commit
4062149ad1
1 tập tin đã thay đổi với 14 bổ sung9 xóa
  1. 14 9
      console/controllers/CustomController.php

+ 14 - 9
console/controllers/CustomController.php

@@ -48,15 +48,15 @@ class CustomController extends Controller
                     $customId = $custom['id'] ?? 0;
                     $where = ['customId' => $customId, 'debt' => 1];
                     $orderList = OrderClass::getAllByCondition($where, 'addTime DESC', '*');
-                    if (empty($orderList)) {
-                        continue;
-                    }
                     $ghsOrderDebtAmount = 0;
-                    foreach ($orderList as $order) {
-                        $actPrice = $order['actPrice'] ?? 0;
-                        $ghsOrderDebtAmount = bcadd($ghsOrderDebtAmount, $actPrice, 2);
+                    if (!empty($orderList)) {
+                        foreach ($orderList as $order) {
+                            $actPrice = $order['actPrice'] ?? 0;
+                            $ghsOrderDebtAmount = bcadd($ghsOrderDebtAmount, $actPrice, 2);
+                        }
                     }
 
+
                     $ghsId = $custom['ghsId'] ?? 0;
 
                     $ghs = \bizHd\ghs\classes\GhsClass::getById($ghsId);
@@ -64,9 +64,14 @@ class CustomController extends Controller
                     $where = ['ghsId' => $ghsId, 'debt' => PurchaseClass::DEBT_YES];
                     $cgList = PurchaseClass::getAllByCondition($where, 'addTime DESC', '*');
                     $hdCgOrderDebtAmount = 0;
-                    foreach ($cgList as $cg) {
-                        $actPrice = $cg['actPrice'] ?? 0;
-                        $hdCgOrderDebtAmount = bcadd($hdCgOrderDebtAmount, $actPrice, 2);
+                    if (!empty($cgList)) {
+                        foreach ($cgList as $cg) {
+                            $actPrice = $cg['actPrice'] ?? 0;
+                            $hdCgOrderDebtAmount = bcadd($hdCgOrderDebtAmount, $actPrice, 2);
+                        }
+                    }
+                    if($ghsOrderDebtAmount < 0 || $hdCgOrderDebtAmount < 0 ){
+                        noticeUtil::push("!!!!!!!供应商 {$ghsId}  客户id {$customId} 出现负数 $ghsOrderDebtAmount $hdCgOrderDebtAmount", '15280215347');
                     }
                     $ghsOrderDebtAmount = floatval($ghsOrderDebtAmount);
                     $hdCgOrderDebtAmount = floatval($hdCgOrderDebtAmount);