Преглед изворни кода

申请开店载入全部供货商

shish пре 4 година
родитељ
комит
6885e3b1c4

+ 1 - 10
app-hd/controllers/GhsController.php

@@ -141,16 +141,7 @@ class GhsController extends BaseController
     //补充缺失的供货商 shish 20211027
     public function actionBcGhs()
     {
-        if (getenv('YII_ENV') == 'production') {
-            //纯彩花艺、莱漫花行、长安花行、宣言花行
-            $ids = [10, 214, 203, 418];
-        } else {
-            $ids = [36225, 36295];
-        }
-        $hdShopId = $this->shopId ?? 0;
-        foreach ($ids as $ghsShopId) {
-            CustomClass::build($ghsShopId, $hdShopId);
-        }
+        GhsClass::bcGhs($this->shopId);
         util::complete('载入成功');
     }
 

+ 24 - 19
biz-ghs/custom/services/CustomService.php

@@ -17,30 +17,35 @@ class CustomService extends BaseService
     {
         $shopId = $newShop->id ?? 0;
         $introShopId = $applyData['introShopId'] ?? 0;
-        //申请人是花店,介绍人是供应商
-        if ($applyData['style'] == SjClass::STYLE_RETAIL) {
-            if ($applyData['introStyle'] == SjClass::STYLE_SUPPLIER) {
-                CustomClass::build($introShopId, $shopId);
+        if (!empty($introShopId)) {
+            //申请人是花店,介绍人是供应商
+            if ($applyData['style'] == SjClass::STYLE_RETAIL) {
+                if ($applyData['introStyle'] == SjClass::STYLE_SUPPLIER) {
+                    CustomClass::build($introShopId, $shopId);
+                }
             }
-        }
-        //申请人是供应商,介绍人是花店
-        if ($applyData['style'] == SjClass::STYLE_SUPPLIER) {
-            if ($applyData['introStyle'] == SjClass::STYLE_RETAIL) {
-                CustomClass::build($shopId, $introShopId);
+            //申请人是供应商,介绍人是花店
+            if ($applyData['style'] == SjClass::STYLE_SUPPLIER) {
+                if ($applyData['introStyle'] == SjClass::STYLE_RETAIL) {
+                    CustomClass::build($shopId, $introShopId);
+                }
             }
-        }
-        //申请人和介绍人都是花店,但是从供货商采购页邀请也建立关系
-        if ($applyData['style'] == SjClass::STYLE_RETAIL) {
-            if ($applyData['introStyle'] == SjClass::STYLE_RETAIL) {
-                $fromGhsId = $applyData['fromGhsId'] ?? 0;
-                if (!empty($fromGhsId)) {
-                    $fromGhs = GhsClass::getById($fromGhsId, true);
-                    $ghsShopId = $fromGhs->shopId ?? 0;
-                    if(!empty($ghsShopId)){
-                        CustomClass::build($ghsShopId, $shopId);
+            //申请人和介绍人都是花店,但是从供货商采购页邀请也建立关系
+            if ($applyData['style'] == SjClass::STYLE_RETAIL) {
+                if ($applyData['introStyle'] == SjClass::STYLE_RETAIL) {
+                    $fromGhsId = $applyData['fromGhsId'] ?? 0;
+                    if (!empty($fromGhsId)) {
+                        $fromGhs = GhsClass::getById($fromGhsId, true);
+                        $ghsShopId = $fromGhs->shopId ?? 0;
+                        if (!empty($ghsShopId)) {
+                            CustomClass::build($ghsShopId, $shopId);
+                        }
                     }
                 }
             }
+        } else {
+            //载入全部的供货商
+            GhsClass::bcGhs($shopId);
         }
     }
 

+ 14 - 0
biz/ghs/classes/GhsClass.php

@@ -21,6 +21,20 @@ class GhsClass extends BaseClass
 
     public static $baseFile = '\biz\ghs\models\Ghs';
 
+    //补充供货商 shish 20211028
+    public static function bcGhs($hdShopId)
+    {
+        if (getenv('YII_ENV') == 'production') {
+            //纯彩花艺、莱漫花行、长安花行、宣言花行
+            $ids = [10, 214, 203, 418];
+        } else {
+            $ids = [36225, 36295];
+        }
+        foreach ($ids as $ghsShopId) {
+            CustomClass::build($ghsShopId, $hdShopId);
+        }
+    }
+
     //新增客户和供应商关系 shish 2021.4.13
     public static function build($ghsShopId, $hdShopId, $type = 1)
     {