shish 5 жил өмнө
parent
commit
1b72b15c7e

+ 2 - 2
app-ghs/controllers/MainController.php

@@ -77,8 +77,8 @@ class MainController extends BaseController
         $latestThirty = StatIncomeClass::getAmountThirty($this->shopId);
         $base = [
             'balance' => $shopInfo['balance'],
-            'mayGathering' => $shopInfo['mayGathering'],
-            'mayPay' => 0,
+            'mayGathering' => $shopInfo['mayGathering'] ?? 0.00,
+            'mayPay' => $shopInfo['mayPay'] ?? 0.00,
             'stockCost' => $stockInfo['stockCost'],
             'stockNum' => 0,
             'stockBigNum' => $stockInfo['stockBigNum'],

+ 2 - 2
app-hd/controllers/MainController.php

@@ -126,8 +126,8 @@ class MainController extends BaseController
 
         $base = [
             'balance' => $shopInfo['balance'],
-            'mayGathering' => $shopInfo['mayGathering'],
-            'mayPay' => 0,
+            'mayGathering' => $shopInfo['mayGathering'] ?? 0.00,
+            'mayPay' => $shopInfo['mayPay'] ?? 0.00,
             'stockCost' => $stockInfo['stockCost'],
             'stockNum' => 0,
             'stockBigNum' => $stockInfo['stockBigNum'],

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

@@ -416,6 +416,11 @@ class OrderService extends BaseService
         $shop->totalOrderNum += 1;
         $currentTotalIncome = bcadd($shop->totalIncome, $amount, 2);
         $shop->totalIncome = $currentTotalIncome;
+        if ($payWay == dict::getDict('payWay', 'debtPay')) {
+            //客户欠款支付会增加【应收客户款】
+            $currentGathering = bcadd($shop->mayGathering, $amount, 2);
+            $shop->mayGathering = $currentGathering;
+        }
         $shop->save();
 
         $orderId = $order->id;

+ 19 - 5
biz-hd/purchase/classes/PurchaseClearClass.php

@@ -104,13 +104,13 @@ class PurchaseClearClass extends BaseClass
         $ghs->debt = $currentAmount > 0 ? 2 : 1;
         $ghs->save();
 
+        $shopId = $ghs->shopId;
+        $shop = ShopClass::getLockById($shopId);
+        if (empty($shop)) {
+            util::fail('没有找到供货商门店');
+        }
         //供货商的门店余额增加
         if ($payWay == dict::getDict('payWay', 'wxPay')) {
-            $shopId = $ghs->shopId;
-            $shop = ShopClass::getLockById($shopId);
-            if (empty($shop)) {
-                util::fail('没有找到门店');
-            }
             $balance = bcadd($shop->balance, $order->actPrice, 2);
             $txBalance = bcadd($shop->txBalance, $order->actPrice, 2);
             $shop->balance = $balance;
@@ -134,6 +134,10 @@ class PurchaseClearClass extends BaseClass
             ];
             ShopYeChangeClass::addChange($change, true);
         }
+        //供货商的门店应收客户款减少
+        $currentGathering = bcsub($shop->mayGathering, $order->actPrice, 2);
+        $shop->mayGathering = $currentGathering;
+        $shop->save();
 
         if (empty($arr)) {
             $msg = "结算订单 orderSn:{$orderSn} 支付成功,回调处理,没有找到采购订单";
@@ -168,6 +172,16 @@ class PurchaseClearClass extends BaseClass
         $custom->debtNum -= count($arr);
         $custom->isDebt = $remain > 0 ? 1 : 0;
         $custom->save();
+
+        //客户门店应付供货商款减少
+        $customShopId = $custom->shopId;
+        $customShop = ShopClass::getLockById($customShopId);
+        if (empty($customShop)) {
+            util::fail('没有找到客户门店');
+        }
+        $currentMayPay = bcsub($customShop->mayPay, $order->actPrice, 2);
+        $customShop->mayPay = $currentMayPay;
+        $customShop->save();
     }
 
 }

+ 6 - 1
biz-hd/purchase/services/PurchaseService.php

@@ -247,6 +247,11 @@ class PurchaseService extends BaseService
         $shop->totalExpend = $currentExpend;
         $shop->cgUnPay -= 1;
         $shop->cgUnSend += 1;
+        if ($payWay == dict::getDict('payWay', 'debtPay')) {
+            //欠款支付会增加【应付供货商款】
+            $currentMayPay = bcadd($shop->mayPay, $actPrice, 2);
+            $shop->mayPay = $currentMayPay;
+        }
         $shop->save();
 
         //当天和当月支出统计
@@ -277,7 +282,7 @@ class PurchaseService extends BaseService
         $ghs->save();
 
         //自取采购单直接完成
-        if($info->getType == PurchaseClass::GET_TYPE_SELF_GET){
+        if ($info->getType == PurchaseClass::GET_TYPE_SELF_GET) {
             $shop->cgUnSend -= 1;
             $shop->cgSending += 1;
             $shop->save();

+ 0 - 1
common/components/payUtil.php

@@ -52,7 +52,6 @@ class payUtil
             $transaction->rollBack();
             util::fail("支付回调处理失败 orderSn:{$orderSn} capitalType:{$capitalType}");
         }
-
     }
 
 }