Browse Source

绑定流程

shish 4 years ago
parent
commit
0b83df36ec

+ 0 - 2
app-ghs/controllers/ShopController.php

@@ -30,8 +30,6 @@ class ShopController extends BaseController
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {
-            $custom = CustomClass::getById($id, true);
-            CustomClass::valid($custom, $this->shopId);
             $shop = $this->shop ?? [];
             $lsShopId = $shop->lsShopId ?? 0;
             if (!empty($lsShopId)) {

+ 19 - 14
biz-ghs/merchant/classes/ShopClass.php

@@ -118,15 +118,6 @@ class ShopClass extends BaseClass
     public static function bindLsShopByCustomId($ghsShop, $id)
     {
         $ghsShopId = $ghsShop->id ?? 0;
-        $custom = CustomClass::getById($id, true);
-        if (empty($custom)) {
-            util::fail('门店信息没有找到');
-        }
-        $customShopId = $custom->shopId ?? 0;
-        $customShop = self::getById($customShopId, true);
-        if (isset($customShop->pfShopId) && !empty($customShop->pfShopId)) {
-            util::fail('这个零售店已经绑定了一个批发店');
-        }
         $ghsMainId = $ghsShop->mainId ?? 0;
         if (empty($ghsMainId)) {
             util::fail('没有找到你的main信息');
@@ -135,16 +126,30 @@ class ShopClass extends BaseClass
         if (empty($ghsMain)) {
             util::fail('没有找到main信息');
         }
-        $customMobile = $customShop->mobile ?? 0;
         $ghsMobile = $ghsShop->mobile ?? 0;
-        if (empty($ghsShop)) {
+        if (empty($ghsMobile)) {
             util::fail('手机号有问题?');
         }
+        $customMobile = 0;
+        $customShop = null;
+        $customShopId = 0;
+        if (!empty($id)) {
+            $custom = CustomClass::getById($id, true);
+            if (empty($custom)) {
+                util::fail('门店信息没有找到');
+            }
+            $customShopId = $custom->shopId ?? 0;
+            $customShop = self::getById($customShopId, true);
+            if (isset($customShop->pfShopId) && !empty($customShop->pfShopId)) {
+                util::fail('这个零售店已经绑定了一个批发店');
+            }
+            $customMobile = $customShop->mobile ?? 0;
+        }
         if ($ghsMobile != $customMobile) {
             //如果绑定的零售店跟批发店手机号不一样,则先查批发店这个手机号有没创建过零售店,没有则自动给创建,有则提醒选的零售店不对
-            $has = ShopClass::getByCondition(['mobile' => $customMobile, 'ptStyle' => dict::getDict('ptStyle', 'hd')], true);
-            if (!empty($has)) {
-                util::fail('请确认此零售店开通时用的手机号要与本批发店一致?');
+            $has = ShopClass::getByCondition(['mobile' => $ghsMobile, 'ptStyle' => dict::getDict('ptStyle', 'hd')], true);
+            if (!empty($has) && !empty($id)) {
+                util::fail('请确认此零售店开通时用的手机号与本批发店一致?');
             } else {
                 //创建零售店
                 $apply = ApplyClass::getByCondition(['mobile' => $ghsMobile]);

+ 6 - 7
biz/ghs/classes/GhsClass.php

@@ -54,17 +54,20 @@ class GhsClass extends BaseClass
         }
         $ghsShop = ShopClass::getShopInfo($ghsShopId);
         $ghsSjId = $ghsShop['sjId'] ?? 0;
+        $ghsMainId = $ghsShop['mainId'] ?? 0;
         $ghsDefault = $ghsShop['default'] ?? 0;
         $name = $ghsDefault == 1 ? $ghsShop['merchantName'] : $ghsShop['merchantName'] . ' ' . $ghsShop['shopName'];
         $py = stringUtil::py($name);
-        $ghShop = ShopClass::getShopInfo($hdShopId);
-        $hdSjId = $ghShop['sjId'] ?? 0;
+        $hdShopInfo = ShopClass::getShopInfo($hdShopId);
+        $hdSjId = $hdShopInfo['sjId'] ?? 0;
+        $hdMainId = $hdShopInfo['mainId'] ?? 0;
 
         $data = [
             'sjId' => $ghsSjId,
             'shopId' => $ghsShopId,
             'ownSjId' => $hdSjId,
             'ownShopId' => $hdShopId,
+            'ownMainId' => $hdMainId,
             'name' => $name,
             'py' => $py,
             'mobile' => $ghsShop['mobile'] ?? '',
@@ -91,6 +94,7 @@ class GhsClass extends BaseClass
             'shopId' => $hdShopId,
             'ownSjId' => $ghsSjId,
             'ownShopId' => $ghsShopId,
+            'ownMainId' => $ghsMainId,
             'name' => $name,
             'py' => $py,
             'mobile' => $mobile,
@@ -114,24 +118,19 @@ class GhsClass extends BaseClass
         if (!empty($parentShopId)) {
             $introduce = CustomClass::getByCondition(['ownShopId' => $ghsShopId, 'shopId' => $parentShopId], true);
         }
-
         //有新客户提醒供货商
         WxMessageClass::newGhsCustomInform($ghsShop, $custom, $introduce);
         //新客户加入app通知
         NoticeClass::newCustomNotice($ghsShop, $custom);
-
         if ($type == 1) {
             return $ghs;
         }
-
         return $custom;
     }
 
     //增加供应商 ssh 2021.3.29
     public static function addGhs($data)
     {
-        //供应商客户+1
-        ShopService::totalUserPlus($data['shopId']);
         return self::add($data);
     }
 

+ 0 - 13
biz/shop/services/ShopService.php

@@ -122,19 +122,6 @@ class ShopService extends BaseService
         }
     }
 
-    //更新客户数 +1
-    public static function totalUserPlus($shopId)
-    {
-        $shop = ShopClass::getById($shopId);
-        if($shop){
-            $data = [
-                'totalUser'=>$shop['totalUser'] + 1
-            ];
-            ShopClass::updateById($shopId,$data);
-        }
-
-    }
-
     //更新总访问数 +1
     public static function totalViewPlus($shopId)
     {