shish 5 лет назад
Родитель
Сommit
bd39b1fa15

+ 9 - 0
app-hd/controllers/ShopController.php

@@ -4,6 +4,7 @@ namespace hd\controllers;
 
 use biz\shop\classes\ShopClass;
 use biz\sj\services\MerchantExtendService;
+use bizGhs\admin\classes\AdminClass;
 use bizHd\merchant\services\ShopService;
 use common\components\dirUtil;
 use common\components\util;
@@ -46,6 +47,14 @@ class ShopController extends BaseController
         util::complete();
     }
 
+    //切换门店 linqh 2021.1.31
+    public function actionToggleShop()
+    {
+        $shopId = Yii::$app->request->post('shopId', 0);
+        $res = AdminClass::toggleShop($this->admin, $shopId, $this->sjId, $this->shopAdmin);
+        util::success($res);
+    }
+
     //下载微信和支付宝收款码 ssh 2020.2.29
     public function actionGatheringCode()
     {

+ 7 - 2
app-pt/controllers/TestController.php

@@ -4,8 +4,10 @@ namespace pt\controllers;
 
 use biz\sj\services\MerchantExtendService;
 use biz\sj\services\MerchantService;
+use bizGhs\custom\classes\CustomClass;
 use bizHd\message\services\InformAdminService;
 use bizHd\order\services\OrderService;
+use bizHd\saas\classes\ApplyClass;
 use bizHd\user\services\UserService;
 use bizHd\wx\classes\WxOpenClass;
 use bizHd\wx\services\WxOpenService;
@@ -19,10 +21,13 @@ use common\components\miniUtil;
 class TestController extends PublicController
 {
 
+
     public function actionPy()
     {
-        $pinyin = new Pinyin(); // 默认
-        echo $pinyin->abbr('带着希望去旅行圳未石耒');
+        $applyData = ApplyClass::getById(86);
+        $sjId = 12449;
+        $shopId = 35903;
+        CustomClass::buildCustom($applyData, $sjId, $shopId);
     }
 
     //即时配送

+ 1 - 1
biz-ghs/admin/classes/AdminClass.php

@@ -428,7 +428,7 @@ class AdminClass extends BaseClass
     //切换门店 linqh 2021.1.31
     public static function toggleShop($admin, $toggleShopId, $sjId, $originShopAdmin)
     {
-        if ($admin['super'] != 1) {
+        if (isset($originShopAdmin['super']) == false || $originShopAdmin['super'] != 1) {
             util::fail("您没有权限");
         }
         $adminId = $admin['id'];

+ 21 - 13
biz-ghs/custom/classes/CustomClass.php

@@ -18,6 +18,7 @@ class CustomClass extends BaseClass
     public static $baseFile = '\bizGhs\custom\models\Custom';
 
     //申请开店建立客户关系 ssh 2021.2.28
+    //GhsClass::build()也有相似流程
     public static function buildCustom($applyData, $sjId, $shopId)
     {
         if ($applyData['style'] == SjClass::STYLE_RETAIL) {
@@ -39,11 +40,16 @@ class CustomClass extends BaseClass
                         'lat' => $applyData['lat'],
                     ];
                     CustomClass::addCustom($customData);
-                    $introShopId = $applyData['introShopId'] ?? 0;
-                    $ghsShop = ShopClass::getShopInfo($introShopId);
-                    if (empty($ghsShop)) {
-                        util::fail('没有找到门店');
-                    }
+                }
+
+                $introShopId = $applyData['introShopId'] ?? 0;
+                $ghsShop = ShopClass::getShopInfo($introShopId);
+                if (empty($ghsShop)) {
+                    util::fail('没有找到门店');
+                }
+
+                $ghs = GhsClass::getByCondition(['ownSjId' => $sjId, 'sjId' => $ghsShop['merchantId'], 'shopId' => $ghsShop['id']]);
+                if (empty($ghs)) {
                     $ghsData = [
                         'sjId' => $ghsShop['merchantId'],
                         'shopId' => $ghsShop['id'],
@@ -66,9 +72,9 @@ class CustomClass extends BaseClass
         if ($applyData['style'] == SjClass::STYLE_SUPPLIER) {
             if ($applyData['introStyle'] == SjClass::STYLE_RETAIL) {
                 $has = CustomClass::getByCondition(['ownSjId' => $sjId, 'sjId' => $applyData['introSjId'], 'shopId' => $applyData['introShopId']]);
+                $introSjId = $applyData['introSjId'] ?? 0;
+                $introShopId = $applyData['introShopId'] ?? 0;
                 if (empty($has)) {
-                    $introSjId = $applyData['introSjId'] ?? 0;
-                    $introShopId = $applyData['introShopId'] ?? 0;
                     $shop = ShopClass::getShopInfo($introShopId);
                     $name = $shop['shopName'] ?? '';
                     $super = ShopClass::getSuper($introShopId);
@@ -89,12 +95,14 @@ class CustomClass extends BaseClass
                         'lat' => $applyData['lat'],
                     ];
                     CustomClass::addCustom($customData);
-
-                    $ghsShop = ShopClass::getShopInfo($shopId);
-                    if (empty($ghsShop)) {
-                        util::fail('没有找到门店');
-                    }
-
+                }
+                $ghsShop = ShopClass::getShopInfo($shopId);
+                if (empty($ghsShop)) {
+                    util::fail('没有找到门店');
+                }
+                $ghs = GhsClass::getByCondition(['ownSjId' => $introSjId, 'sjId' => $sjId, 'shopId' => $shopId]);
+                dd($ghs);
+                if (empty($ghs)) {
                     $ghsData = [
                         'sjId' => $sjId,
                         'shopId' => $shopId,

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

@@ -17,6 +17,7 @@ class GhsClass extends BaseClass
     public static $baseFile = '\biz\ghs\models\Ghs';
 
     //新增供货商 shish 2021.4.13
+    //CustomClass::buildCustom()也有相似流程
     public static function build($thisShopId, $shopId, $sjId)
     {
         $ghsShop = ShopClass::getShopInfo($thisShopId);

+ 2 - 7
biz/shop/classes/ShopClass.php

@@ -48,13 +48,8 @@ class ShopClass extends BaseClass
         if (empty($list)) {
             return $list;
         }
-        $sjIds = array_column($list, 'merchantId');
-        $sjList = MerchantClass::getMerchantByIds($sjIds);
-        $prefix = imgUtil::getPrefix();
         foreach ($list as $key => $val) {
-            $sjId = $val['merchantId'];
-            $avatar = isset($sjList[$sjId]['logoUrl']) ? $sjList[$sjId]['logoUrl'] : $prefix . '/retail/default-img.png';
-            $list[$key]['avatar'] = $avatar;
+            $list[$key]['avatar'] = imgUtil::groupImg($val['avatar']);
         }
         return $list;
     }
@@ -96,7 +91,7 @@ class ShopClass extends BaseClass
     //取商家所有门店 ssh 2020.2.29
     public static function getAllShop($merchantId)
     {
-        return self::getAllByCondition(['merchantId' => $merchantId],null,"*");
+        return self::getAllByCondition(['merchantId' => $merchantId], null, "*");
     }
 
     //验证所属权限 ssh 2020.2.29