Przeglądaj źródła

客户和供应商的中央化

shish 4 lat temu
rodzic
commit
bad5c014b4

+ 2 - 5
app-hd/controllers/OrderController.php

@@ -312,12 +312,9 @@ class OrderController extends BaseController
         //商城
         $post['fromType'] = 1;
         //客户
-        $customId = $post['customId'] ?? 0;
+        $customId = isset($post['customId']) && $post['customId'] > 0 ? $post['customId'] : 0;
         if (empty($customId)) {
-            $customId = isset($this->shop->skCustomId) ? $this->shop->skCustomId : 0;
-        }
-        if (empty($customId)) {
-            util::fail('没有找到客户');
+            $customId = $this->shop->defaultCustomId ?? 0;
         }
         $custom = CustomClass::getById($customId);
         if (empty($custom)) {

+ 41 - 0
console/controllers/InitController.php

@@ -280,6 +280,47 @@ class InitController extends Controller
 
         self::migrationDel();
 
+        //客户和供应商的中央化
+        self::ghsCustomMain();
+
+    }
+
+    //客户和供应商的中央化 ssh 20220506
+    public static function ghsCustomMain()
+    {
+        $map = [];
+        $allShop = ShopClass::getAllByCondition(['id>' => 0], null, '*', null, true);
+        if (!empty($allShop)) {
+            foreach ($allShop as $single) {
+                $mainId = $single->mainId ?? 0;
+                $shopId = $single->id ?? 0;
+                $map[$shopId] = $mainId;
+            }
+        }
+
+        $customList = CustomClass::getAllByCondition(['id>' => 0], null, '*', null, true);
+        if (!empty($customList)) {
+            foreach ($customList as $custom) {
+                $shopId = $custom->shopId ?? 0;
+                $mainId = $map[$shopId] ?? 0;
+                $custom->mainId = $mainId;
+                $ownShopId = $custom->ownShopId ?? 0;
+                $ownMainId = $map[$ownShopId] ?? 0;
+                $custom->ownMainId = $ownMainId;
+                $custom->save();
+            }
+        }
+
+        $ghsList = GhsClass::getByCondition(['id>' => 0], null, '*', null, true);
+        foreach ($ghsList as $ghs) {
+            $shopId = $ghs->shopId ?? 0;
+            $mainId = $map[$shopId] ?? 0;
+            $ghs->mainId = $mainId;
+            $ownShopId = $ghs->ownShopId ?? 0;
+            $ownMainId = $map[$ownShopId] ?? 0;
+            $ghs->ownMainId = $ownMainId;
+            $ghs->save();
+        }
     }
 
 

+ 3 - 1
sql.sql

@@ -1006,4 +1006,6 @@ CREATE TABLE `xhGoodsSn` (
 ) ENGINE=INNODB AUTO_INCREMENT=520 COMMENT='有效的自增商品编号';
 ALTER TABLE xhGoodsCategory ADD `sn` CHAR(30) NOT NULL DEFAULT '' COMMENT '有效的商品编号' AFTER `sjId`;
 ALTER TABLE xhWork ADD `goodsSn` CHAR(30) NOT NULL DEFAULT '' COMMENT '有效的商品编号,对应xhGoods sn' AFTER `workSn`;
-ALTER TABLE xhShop ADD defaultCustomId INT NOT NULL DEFAULT 0 COMMENT '门店默认客户,没有选客户时使用' AFTER `skCustomId`;
+ALTER TABLE xhShop ADD defaultCustomId INT NOT NULL DEFAULT 0 COMMENT '门店默认客户,没有选客户时使用' AFTER `skCustomId`;
+ALTER TABLE xhGhsCustom ADD mainId INT NOT NULL DEFAULT 0 COMMENT '' AFTER `shopId`;
+ALTER TABLE xhGhs ADD mainId INT NOT NULL DEFAULT 0 COMMENT '中央id' AFTER `shopId`;