shish 5 лет назад
Родитель
Сommit
7ae3571dab
1 измененных файлов с 20 добавлено и 0 удалено
  1. 20 0
      biz-ghs/order/classes/OrderClearClass.php

+ 20 - 0
biz-ghs/order/classes/OrderClearClass.php

@@ -3,6 +3,7 @@
 namespace bizGhs\order\classes;
 
 use biz\ghs\classes\GhsClass;
+use biz\shop\classes\ShopClass;
 use bizGhs\custom\classes\CustomClass;
 use common\components\orderSn;
 use common\components\util;
@@ -71,6 +72,17 @@ class OrderClearClass extends BaseClass
         $custom->debtNum = $num;
         $custom->save();
 
+        //客户门店应付供货商款减少
+        $customShopId = $custom->shopId;
+        $customShop = ShopClass::getLockById($customShopId);
+        if (empty($customShop)) {
+            util::fail('没有找到客户门店');
+        }
+        $currentMayPay = bcsub($customShop->mayPay, $amount, 2);
+        $customShop->mayPay = $currentMayPay;
+        $customShop->save();
+
+
         $orderSn = orderSn::getPurchaseClearSn();
         $clearData = [
             'prePrice' => $amount,
@@ -106,6 +118,14 @@ class OrderClearClass extends BaseClass
         $ghs->debtNum = $num;
         $ghs->debt = $remainAmount > 0 ? 2 : 1;
         $ghs->save();
+
+        //供货商的门店应收客户款减少
+        $shopId = $ghs->shopId;
+        $shop = ShopClass::getLockById($shopId);
+        $currentGathering = bcsub($shop->mayGathering, $amount, 2);
+        $shop->mayGathering = $currentGathering;
+        $shop->save();
+
     }
 
 }