shish 5 ani în urmă
părinte
comite
9e9f4e5b24

+ 4 - 1
biz-ghs/order/classes/OrderClearClass.php

@@ -126,8 +126,11 @@ class OrderClearClass extends BaseClass
         $shop = ShopClass::getLockById($shopId);
         $currentGathering = bcsub($shop->mayGathering, $amount, 2);
         $shop->mayGathering = $currentGathering;
+        if ($custom->debtNum == 0) {
+            $shop->mayGatheringNum -= 1;
+            $shop->save();
+        }
         $shop->save();
-
     }
 
 }

+ 11 - 5
biz-ghs/order/services/OrderService.php

@@ -393,6 +393,13 @@ class OrderService extends BaseService
         if (isset($order->debt) == false) {
             util::fail('订单有问题,没有欠款项');
         }
+
+        $customId = $order->customId;
+        $custom = CustomClass::getLockById($customId);
+        if (empty($custom)) {
+            util::fail('没有找到客户信息');
+        }
+
         /**门店资产变化**/
         $amount = $order->actPrice ?? 0.00;
         $currentShopId = $order->shopId ?? 0;
@@ -410,6 +417,10 @@ class OrderService extends BaseService
             //客户欠款支付会增加【应收客户款】
             $currentGathering = bcadd($shop->mayGathering, $amount, 2);
             $shop->mayGathering = $currentGathering;
+            //客户第一次欠款的增加一个欠款客户
+            if ($custom->debtNum == 0) {
+                $shop->mayGatheringNum += 1;
+            }
         }
         $shop->save();
 
@@ -465,11 +476,6 @@ class OrderService extends BaseService
         StatYjClass::addYj($order);
 
         /**客户资产变化**/
-        $customId = $order->customId;
-        $custom = CustomClass::getLockById($customId);
-        if (empty($custom)) {
-            util::fail('没有找到客户信息');
-        }
         if ($payWay == dict::getDict('payWay', 'debtPay')) {
             //欠款支付
             $custom->isDebt = CustomClass::IS_DEBT_YES;

+ 4 - 0
biz-hd/purchase/classes/PurchaseClearClass.php

@@ -173,6 +173,10 @@ class PurchaseClearClass extends BaseClass
         $custom->debtNum -= count($arr);
         $custom->isDebt = $remain > 0 ? 1 : 0;
         $custom->save();
+        if ($custom->debtNum == 0) {
+            $shop->mayGatheringNum -= 1;
+            $shop->save();
+        }
 
         //客户门店应付供货商款减少
         $customShopId = $custom->shopId;