Răsfoiți Sursa

main信息优化

shish 4 ani în urmă
părinte
comite
deda165a2b

+ 6 - 6
app-ghs/controllers/CustomController.php

@@ -136,9 +136,9 @@ class CustomController extends BaseController
             }
         }
         $list = CustomService::getCustomSortList($where, $sort);
-        $shop = $this->shop;
-        $list['totalUser'] = $shop->totalUser ?? 0;
-        $list['mayGatheringNum'] = $shop->mayGatheringNum ?? 0;
+        $main = $this->main;
+        $list['totalUser'] = $main->totalUser ?? 0;
+        $list['mayGatheringNum'] = $main->mayGatheringNum ?? 0;
         util::success($list);
     }
 
@@ -219,9 +219,9 @@ class CustomController extends BaseController
         }
         $list = CustomService::getDebtList($where);
         //共X个客户,合计欠款XXX元
-        $shop = $this->shop;
-        $list['customNum'] = $shop->mayGatheringNum ?? 0;
-        $list['debtAmount'] = $shop->mayGathering ?? 0.00;
+        $main = $this->main;
+        $list['customNum'] = $main->mayGatheringNum ?? 0;
+        $list['debtAmount'] = $main->mayGathering ?? 0.00;
         util::success($list);
     }
 

+ 20 - 9
biz-ghs/clear/classes/ClearClass.php

@@ -9,6 +9,7 @@ use bizGhs\cg\classes\CgClass;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\order\classes\OrderClass;
 use bizGhs\order\classes\PurchaseOrderClass;
+use bizGhs\shop\classes\MainClass;
 use bizHd\purchase\classes\PurchaseClass;
 use common\components\dict;
 use common\components\orderSn;
@@ -140,10 +141,15 @@ class ClearClass extends BaseClass
         if (empty($shop)) {
             util::fail('没有找到供应商门店');
         }
+        $mainId = $shop->mainId ?? 0;
+        $main = MainClass::getLockById($mainId);
+        if (empty($main)) {
+            util::fail('没有main信息');
+        }
         //门店应收客户款减少
-        $currentGathering = bcsub($shop->mayGathering, $order->actPrice, 2);
-        $shop->mayGathering = $currentGathering;
-        $shop->save();
+        $currentGathering = bcsub($main->mayGathering, $order->actPrice, 2);
+        $main->mayGathering = $currentGathering;
+        $main->save();
 
         //采购单状态变更
         foreach ($list as $purchase) {
@@ -165,8 +171,8 @@ class ClearClass extends BaseClass
         $custom->isDebt = $remain > 0 ? 1 : 0;
         $custom->save();
         if ($custom->debtNum == 0) {
-            $shop->mayGatheringNum -= 1;
-            $shop->save();
+            $main->mayGatheringNum -= 1;
+            $main->save();
         }
 
         //应付供应商款减少
@@ -175,12 +181,17 @@ class ClearClass extends BaseClass
         if (empty($customShop)) {
             util::fail('没有找到客户门店');
         }
-        $currentMayPay = bcsub($customShop->mayPay, $order->actPrice, 2);
-        $customShop->mayPay = $currentMayPay;
+        $customMainId = $customShop->mainId ?? 0;
+        $customMain = MainClass::getLockById($customMainId);
+        if (empty($customMain)) {
+            util::fail('没有main信息');
+        }
+        $currentMayPay = bcsub($customMain->mayPay, $order->actPrice, 2);
+        $customMain->mayPay = $currentMayPay;
         if ($ghs->debtNum == 0) {
-            $customShop->mayPayNum -= 1;
+            $customMain->mayPayNum -= 1;
         }
-        $customShop->save();
+        $customMain->save();
     }
 
     //供应商的采购信息 ssh 20210625

+ 18 - 10
biz-ghs/order/classes/PurchaseOrderClass.php

@@ -260,11 +260,11 @@ class PurchaseOrderClass extends BaseClass
             $main->save();
 
             //采购增加
-            $shop->cgFinish += 1;
-            $shop->totalPurchaseOrder += 1;
-            $currentTotalPurchase = bcadd($shop->totalPurchase, $currentPrice, 2);
-            $shop->totalPurchase = $currentTotalPurchase;
-            $shop->save();
+            $main->cgFinish += 1;
+            $main->totalPurchaseOrder += 1;
+            $currentTotalPurchase = bcadd($main->totalPurchase, $currentPrice, 2);
+            $main->totalPurchase = $currentTotalPurchase;
+            $main->save();
 
             //供应商资产增加
             $ghsId = $data['ghsId'] ?? 0;
@@ -289,8 +289,16 @@ class PurchaseOrderClass extends BaseClass
             //门店应收客户款增加
             $ghsShopId = $ghs->shopId;
             $ghsShop = ShopClass::getLockById($ghsShopId);
-            $currentMayGathering = bcadd($ghsShop->mayGathering, $currentPrice, 2);
-            $ghsShop->mayGathering = $currentMayGathering;
+            if (empty($ghsShop)) {
+                util::fail('没有找到门店');
+            }
+            $ghsMainId = $ghsShop->mainId ?? 0;
+            $ghsMain = \bizGhs\shop\classes\MainClass::getLockById($ghsMainId);
+            if (empty($ghsMain)) {
+                util::fail('没有main信息');
+            }
+            $currentMayGathering = bcadd($ghsMain->mayGathering, $currentPrice, 2);
+            $ghsMain->mayGathering = $currentMayGathering;
 
             //客户资产增加
             $customId = $ghs->customId;
@@ -301,16 +309,16 @@ class PurchaseOrderClass extends BaseClass
             $custom->isDebt = CustomClass::IS_DEBT_YES;
             $custom->debtAmount = bcadd($custom->debtAmount, $currentPrice, 2);
             if ($custom->debtNum == 0) {
-                $ghsShop->mayGatheringNum += 1;
+                $ghsMain->mayGatheringNum += 1;
             }
-            $ghsShop->save();
+            $ghsMain->save();
             $custom->debtNum += 1;
             $custom->buyNum += 1;
             $custom->buyAmount = bcadd($custom->buyAmount, $currentPrice, 2);
             $custom->save();
 
             //当天和当月支出统计
-            StatOutClass::updateOrInsert($shop, $currentPrice);
+            StatOutClass::updateOrInsert($main, $shop, $currentPrice);
             //支出流水
             $payWay = dict::getDict('payWay', 'unknown');
             $capitalType = dict::getDict('capitalType', 'ghsPurchase', 'id');

+ 9 - 3
biz-hd/purchase/classes/PurchaseClearClass.php

@@ -9,6 +9,7 @@ use biz\wx\classes\WxMessageClass;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\order\classes\OrderClass;
 use bizHd\base\classes\BaseClass;
+use bizHd\shop\classes\MainClass;
 use common\components\dict;
 use common\components\orderSn;
 use common\components\util;
@@ -144,14 +145,19 @@ class PurchaseClearClass extends BaseClass
         if (empty($shop)) {
             util::fail('没有找到供应商门店');
         }
+        $mainId = $shop->mainId ?? 0;
+        $main = MainClass::getLockById($mainId);
+        if (empty($main)) {
+            util::fail('没有main信息');
+        }
         if ($payWay == dict::getDict('payWay', 'wxPay')) {
             //供应商门店余额增加
             ShopClass::customClearAddBalance($shop, $order);
         }
         //供应商的门店应收客户款减少
-        $currentGathering = bcsub($shop->mayGathering, $order->actPrice, 2);
-        $shop->mayGathering = $currentGathering;
-        $shop->save();
+        $currentGathering = bcsub($main->mayGathering, $order->actPrice, 2);
+        $main->mayGathering = $currentGathering;
+        $main->save();
 
         if (empty($arr)) {
             $msg = "结算订单 orderSn:{$orderSn} 支付成功,回调处理,没有找到采购订单";

+ 1 - 5
biz/shop/classes/ShopClass.php

@@ -162,13 +162,9 @@ class ShopClass extends BaseClass
     }
 
     //客户结帐增加余额 ssh 20210729
-    public static function customClearAddBalance($shop, $order)
+    public static function customClearAddBalance($main, $shop, $order)
     {
         $mainId = $shop->mainId ?? 0;
-        $main = MainClass::getLockById($mainId);
-        if (empty($main)) {
-            util::fail('没有找到资产信息');
-        }
         $balance = bcadd($main->balance, $order->actPrice, 2);
         $txBalance = bcadd($main->txBalance, $order->actPrice, 2);
         $main->balance = $balance;