shish 4 年之前
父節點
當前提交
52cfc79002

+ 4 - 5
biz-ghs/product/classes/ProductClass.php

@@ -774,19 +774,18 @@ class ProductClass extends BaseClass
             }
             $upData['discountPrice'] = $discountPrice;
         }
-
         //加价
-        $skAddPrice = $data['skAddPrice'] ?? 0;
+        $skAddPrice = isset($data['skAddPrice']) && $data['skAddPrice'] > 0 ? $data['skAddPrice'] : 0;
         $upData['skAddPrice'] = $skAddPrice;
         $addPrice = $data['addPrice'] ?? 0;
         $upData['addPrice'] = $addPrice;
         if ($addPrice > $skAddPrice) {
-            util::fail('店加价不能大于散客加价');
+            util::fail('店加价不能大于散客加价');
         }
-        $hjAddPrice = $data['hjAddPrice'] ?? 0;
+        $hjAddPrice = isset($data['hjAddPrice']) && $data['hjAddPrice'] > 0 ? $data['hjAddPrice'] : 0;
         $upData['hjAddPrice'] = $hjAddPrice;
         if ($hjAddPrice > $addPrice) {
-            util::fail('银店加价不能大于普店加价');
+            util::fail('同行加价不能大于花店加价');
         }
         //价格
         $price = $data['price'] ?? 0;

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

@@ -21,6 +21,7 @@ use bizGhs\stock\classes\StockRecordClass;
 use bizGhs\stock\services\StockRecordService;
 use bizHd\cg\classes\CgRefundClass;
 use bizHd\cg\classes\CgXjClass;
+use bizHd\shop\classes\MainClass;
 use bizHd\stat\classes\StatIncomeClass;
 use bizHd\wx\classes\WxOpenClass;
 use common\components\dict;
@@ -507,9 +508,14 @@ class PurchaseClass extends BaseClass
         if (empty($shop)) {
             util::fail('没有找到门店');
         }
-        $shop->totalPurchaseOrder += 1;
-        $shop->cgUnPay += 1;
-        $shop->save();
+        $mainId = $shop->mainId ?? 0;
+        $main = MainClass::getLockById($mainId);
+        if (empty($main)) {
+            util::fail('没有main信息');
+        }
+        $main->totalPurchaseOrder += 1;
+        $main->cgUnPay += 1;
+        $main->save();
 
         return $respond;
     }

+ 18 - 12
biz-hd/purchase/services/PurchaseService.php

@@ -22,6 +22,7 @@ use bizHd\admin\classes\ShopAdminClass;
 use bizHd\base\services\BaseService;
 use bizHd\purchase\classes\PurchaseClass;
 use bizHd\purchase\classes\PurchaseItemClass;
+use bizHd\shop\classes\MainClass;
 use common\components\dict;
 use common\components\imgUtil;
 use common\components\noticeUtil;
@@ -337,20 +338,25 @@ class PurchaseService extends BaseService
         if (empty($shop)) {
             util::fail('没有找到门店');
         }
+        $mainId = $shop->mainId ?? 0;
+        $main = MainClass::getLockById($mainId);
+        if (empty($main)) {
+            util::fail('没有main信息');
+        }
         $realPrice = $info->realPrice;
         $actPrice = $info->actPrice;
         //余额支付引起余额减少
         if ($payWay == dict::getDict('payWay', 'balancePay')) {
-            ShopClass::purchaseReduceBalance($shop, $realPrice, $info);
+            ShopClass::purchaseReduceBalance($shop, $realPrice, $info);//////////////////////////////////////////////////////////
         }
-        $shop->totalPurchase = bcadd($shop->totalPurchase, $actPrice, 2);
-        $currentExpend = bcadd($shop->totalExpend, $actPrice, 2);
-        $shop->totalExpend = $currentExpend;
-        $shop->cgUnPay -= 1;
+        $main->totalPurchase = bcadd($main->totalPurchase, $actPrice, 2);
+        $currentExpend = bcadd($main->totalExpend, $actPrice, 2);
+        $main->totalExpend = $currentExpend;
+        $main->cgUnPay -= 1;
         if ($book == 1) {
-            $shop->cgUnSend += 1;
+            $main->cgUnSend += 1;
         } else {
-            $shop->cgFinish += 1;
+            $main->cgFinish += 1;
 
             //加库存 lqh 2021-05-10
             $orderSn = $info->orderSn;
@@ -380,10 +386,10 @@ class PurchaseService extends BaseService
             $currentMayPay = bcadd($shop->mayPay, $realPrice, 2);
             $shop->mayPay = $currentMayPay;
         }
-        $shop->save();
+        $main->save();
 
         //支出统计
-        StatOutClass::updateOrInsert($shop, $info->orderPrice);
+        StatOutClass::updateOrInsert($shop, $info->orderPrice);///////////////////////////////////////////////////
         //支出流水
         $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
         $sjId = $info->sjId ?? 0;
@@ -403,11 +409,11 @@ class PurchaseService extends BaseService
 
         //采购总量统计
         $cgNum = $info->bigNum ?? 0;
-        StatCgClass::replace($shop, $info->orderPrice, $cgNum);
+        StatCgClass::replace($shop, $info->orderPrice, $cgNum);//////////////////////////////////////////////////////
         //按供货商分别统计采购量
         $num = $info->bigNum ?? 0;
         $amount = $info->orderPrice ?? 0;
-        StatCgGhsClass::hdCgGhsReplace(true,$info, $amount, $num);
+        StatCgGhsClass::hdCgGhsReplace(true, $info, $amount, $num);
 
         //供应商资产变化
         $ghsId = $info->ghsId ?? 0;
@@ -426,7 +432,7 @@ class PurchaseService extends BaseService
         if (isset($info->ghsShopAdminId) && !empty($info->ghsShopAdminId)) {
             $noNeedWxNotice = isset(Yii::$app->params['noNeedWxNotice']) ? Yii::$app->params['noNeedWxNotice'] : 0;
             if ($noNeedWxNotice == 0) {
-                WxMessageClass::generateCgOrder($shop, $info);
+                WxMessageClass::generateCgOrder($shop, $info);///////////////////////////////////////////////////////////////
             }
         }
 

+ 31 - 0
console/controllers/InitController.php

@@ -368,6 +368,17 @@ class InitController extends Controller
         $main->cashName = $shop->cashName ?? '';
         $main->cashAccount = $shop->cashAccount ?? '';
         $main->cashBank = $shop->cashBank ?? '';
+
+        $main->cgUnPay = $shop->cgUnPay ?? 0;
+        $main->cgUnSend = $shop->cgUnSend ?? 0;
+        $main->cgSending = $shop->cgSending ?? 0;
+        $main->cgFinish = $shop->cgFinish ?? 0;
+        $main->cgCancel = $shop->cgCancel ?? 0;
+        $main->mayGatheringNum = $shop->mayGatheringNum ?? 0;
+        $main->mayGathering = $shop->mayGathering ?? 0;
+        $main->mayPay = $shop->mayPay ?? 0;
+        $main->mayPayNum = $shop->mayPayNum ?? 0;
+
         $main->save();
     }
 
@@ -419,7 +430,27 @@ class InitController extends Controller
         $sql = "ALTER TABLE `xhShop` DROP COLUMN `cashAccount`;";
         Yii::$app->db->createCommand($sql)->execute();
         $sql = "ALTER TABLE `xhShop` DROP COLUMN `cashBank`;";
+
+        Yii::$app->db->createCommand($sql)->execute();
+        $sql = "ALTER TABLE `xhShop` DROP COLUMN `cgUnPay`;";
+        Yii::$app->db->createCommand($sql)->execute();
+        $sql = "ALTER TABLE `xhShop` DROP COLUMN `cgUnSend`;";
+        Yii::$app->db->createCommand($sql)->execute();
+        $sql = "ALTER TABLE `xhShop` DROP COLUMN `cgSending`;";
+        Yii::$app->db->createCommand($sql)->execute();
+        $sql = "ALTER TABLE `xhShop` DROP COLUMN `cgFinish`;";
         Yii::$app->db->createCommand($sql)->execute();
+        $sql = "ALTER TABLE `xhShop` DROP COLUMN `cgCancel`;";
+        Yii::$app->db->createCommand($sql)->execute();
+        $sql = "ALTER TABLE `xhShop` DROP COLUMN `mayGathering`;";
+        Yii::$app->db->createCommand($sql)->execute();
+        $sql = "ALTER TABLE `xhShop` DROP COLUMN `mayGatheringNum`;";
+        Yii::$app->db->createCommand($sql)->execute();
+        $sql = "ALTER TABLE `xhShop` DROP COLUMN `mayPay`;";
+        Yii::$app->db->createCommand($sql)->execute();
+        $sql = "ALTER TABLE `xhShop` DROP COLUMN `mayPayNum`;";
+        Yii::$app->db->createCommand($sql)->execute();
+
     }
 
 }

+ 9 - 0
sql.sql

@@ -982,4 +982,13 @@ ALTER TABLE xhStatPdSub ADD mainId INT NOT NULL DEFAULT 0 COMMENT '中央id' AFT
 ALTER TABLE xhStatPdSubMonth ADD mainId INT NOT NULL DEFAULT 0 COMMENT '中央id' AFTER `shopId`;
 ALTER TABLE xhStatPdSub DROP INDEX `shop`;
 ALTER TABLE xhStatPdSubMonth DROP INDEX `shop`;
+ALTER TABLE xhMain ADD `cgUnPay` INT(11) NOT NULL DEFAULT '0' COMMENT '采购待付款订单数' AFTER `cashBank`;
+ALTER TABLE xhMain ADD `cgUnSend` INT(11) NOT NULL DEFAULT '0' COMMENT '采购待配送订单数' AFTER `cgUnPay`;
+ALTER TABLE xhMain ADD `cgSending` INT(11) NOT NULL DEFAULT '0' COMMENT '采购配送中订单数' AFTER `cgUnSend`;
+ALTER TABLE xhMain ADD `cgFinish` INT(11) NOT NULL DEFAULT '0' COMMENT '采购完成订单数' AFTER `cgSending`;
+ALTER TABLE xhMain ADD `cgCancel` INT(11) NOT NULL DEFAULT '0' COMMENT '采购取消订单数' AFTER`cgFinish`;
+ALTER TABLE xhMain ADD `mayGathering` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '应收款' AFTER `cgCancel`;
+ALTER TABLE xhMain ADD `mayGatheringNum` INT(11) NOT NULL DEFAULT '0' COMMENT '应收款客户数' AFTER `mayGathering`;
+ALTER TABLE xhMain ADD `mayPay` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '应付供货商款' AFTER `mayGatheringNum`;
+ALTER TABLE xhMain ADD `mayPayNum` INT(11) NOT NULL DEFAULT '0' COMMENT '应付供货商数' AFTER `mayPay`;
 -- ssh 20220424