shish před 4 roky
rodič
revize
7f70155643

+ 3 - 6
biz-ghs/merchant/classes/ShopClass.php

@@ -175,12 +175,9 @@ class ShopClass extends BaseClass
                 util::fail('请确认此零售店开通时用的手机号与本批发店一致?');
             } else {
                 //创建零售店
-                $apply = ApplyClass::getByCondition(['mobile' => $ghsMobile]);
-                if (empty($apply)) {
-                    util::fail('没有找到申请信息');
-                }
-                $apply['adminId'] = $adminId;
-                $respond = SjService::initHdBaseInfo($apply, $ghsMain, true);
+                $hdInitData = $ghsShop->attributes ?? [];
+                $hdInitData['adminId'] = $adminId;
+                $respond = SjService::initHdBaseInfo($hdInitData, $ghsMain, true);
                 $customShop = $respond['shop'] ?? [];
                 if (empty($customShop)) {
                     util::fail('没有生成门店');

+ 8 - 8
biz-hd/merchant/services/SjService.php

@@ -21,8 +21,7 @@ class SjService extends BaseService
 
     public static $baseFile = '\bizHd\merchant\classes\SjClass';
 
-
-    public static function initHdBaseInfo($applyData, $main, $applyThis = false)
+    public static function initHdBaseInfo($applyData, $main, $applyOpen = false)
     {
         $applyId = $applyData['id'] ?? 0;
         $adminId = $applyData['adminId'] ?? 0;
@@ -43,20 +42,21 @@ class SjService extends BaseService
         $applyData['dist'] = $applyData['dist'] ?? '';
         $applyData['address'] = $applyData['address'] ?? '';
         $applyData['agentLevel'] = 1;
-        $applyData['parentId'] = $applyData['introSjId'] ?? 0;
         $deadline = time() + 365 * 86400;
         $applyData['deadline'] = date("Y-m-d H:i:s", $deadline);
-        $applyData['parentId'] = $applyData['introSjId'] ?? 0;
-        $applyData['parentShopId'] = $applyData['introShopId'] ?? 0;
+        if ($applyOpen) {
+            $applyData['parentId'] = $applyData['introSjId'] ?? 0;
+            $applyData['parentShopId'] = $applyData['introShopId'] ?? 0;
+        }
 
         $jsData = $applyData;
-        $sjData['style'] = dict::getDict('ptStyle', 'hd');
+        $sjData['style'] = $ptStyle;
         $sj = self::add($jsData, true);
         $sjId = $sj->id;
         $sjName = $sj->name ?? 0;
         $mobile = $applyData['mobile'] ?? '';
 
-        if (!empty($applyId) && $applyThis == true) {
+        if (!empty($applyId) && $applyOpen == true) {
             ApplyClass::updateById($applyId, ['sjId' => $sjId]);
         }
 
@@ -138,7 +138,7 @@ class SjService extends BaseService
         SjClass::updateById($sjId, $sjData);
 
         //建立供应商和客户关系
-        if ($applyThis) {
+        if ($applyOpen) {
             CustomService::shareBuildTrade($applyData, $shopInfo);
         }