Browse Source

注册账号

shish 10 months ago
parent
commit
5b1fd5c804
1 changed files with 44 additions and 41 deletions
  1. 44 41
      app-hd/controllers/ApplyController.php

+ 44 - 41
app-hd/controllers/ApplyController.php

@@ -124,48 +124,49 @@ class ApplyController extends BaseController
     {
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
-        try {
 
-            $post = Yii::$app->request->post();
+        $post = Yii::$app->request->post();
 
-            //前期限制只有批发店邀请了才能注册
-            $ghsShopAdminId = $post['ghsShopAdminId'] ?? 0;
-            $hdShopAdminId = $post['hdShopAdminId'] ?? 0;
-            if (empty($ghsShopAdminId) && empty($hdShopAdminId)) {
-                //util::fail('批发店推荐才能注册,编号:' . $ghsShopAdminId . ' ' . $hdShopAdminId);
-            }
+        //前期限制只有批发店邀请了才能注册
+        $ghsShopAdminId = $post['ghsShopAdminId'] ?? 0;
+        $hdShopAdminId = $post['hdShopAdminId'] ?? 0;
+        if (empty($ghsShopAdminId) && empty($hdShopAdminId)) {
+            //util::fail('批发店推荐才能注册,编号:' . $ghsShopAdminId . ' ' . $hdShopAdminId);
+        }
 
-            $shopName = $post['name'] ?? '';
-            if (empty($shopName)) {
-                util::fail('名称不能为空');
-            }
-            $mobile = $post['mobile'] ?? '';
-            if (stringUtil::isMobile($mobile) == false) {
-                util::fail('请填写正确手机号');
-            }
-            if (stringUtil::getWordNum($shopName) > 8) {
-                util::fail('名称不能超过8个汉字');
-            }
-            $arr = ['斗南鲜花', '惠雅鲜花', '纯彩花艺', '泉城鲜花', '杭州斗南', '惠雅', '国恋', '花悠星', '勇记', '丰行', '昱成', '问境', '珑松'];
-            foreach ($arr as $it) {
-                if (strstr($shopName, $it) != null) {
-                    util::fail('花店名称已经存在,请换个名称');
-                }
-            }
-            $has = SjClass::getByCondition(['name' => $shopName]);
-            if (!empty($has)) {
-                //util::fail('名称已经被别人使用,请换个名字,或者名字后面加个2');
-            }
-            $has = ApplyClass::getByCondition(['mobile' => $mobile]);
-            if (!empty($has)) {
-                //手机号开了零售店不能再开批发店,开了批发店不能再开零售店!!
-                util::fail('手机号已经申请过了');
-            }
-            $hasShop = ShopClass::getByCondition(['mobile' => $mobile]);
-            if (!empty($hasShop)) {
-                //手机号开了零售店不能再开批发店,开了批发店不能再开零售店!!
-                util::fail('手机号已经被使用');
+        $shopName = $post['name'] ?? '';
+        if (empty($shopName)) {
+            util::fail('名称不能为空');
+        }
+        $mobile = $post['mobile'] ?? '';
+        if (stringUtil::isMobile($mobile) == false) {
+            util::fail('请填写正确手机号');
+        }
+        if (stringUtil::getWordNum($shopName) > 8) {
+            util::fail('名称不能超过8个汉字');
+        }
+        $arr = ['斗南鲜花', '惠雅鲜花', '纯彩花艺', '泉城鲜花', '杭州斗南', '惠雅', '国恋', '花悠星', '勇记', '丰行', '昱成', '问境', '珑松'];
+        foreach ($arr as $it) {
+            if (strstr($shopName, $it) != null) {
+                util::fail('花店名称已经存在,请换个名称');
             }
+        }
+        $has = SjClass::getByCondition(['name' => $shopName]);
+        if (!empty($has)) {
+            //util::fail('名称已经被别人使用,请换个名字,或者名字后面加个2');
+        }
+        $has = ApplyClass::getByCondition(['mobile' => $mobile]);
+        if (!empty($has)) {
+            //手机号开了零售店不能再开批发店,开了批发店不能再开零售店!!
+            util::fail('手机号已经申请过了');
+        }
+        $hasShop = ShopClass::getByCondition(['mobile' => $mobile]);
+        if (!empty($hasShop)) {
+            //手机号开了零售店不能再开批发店,开了批发店不能再开零售店!!
+            util::fail('手机号已经被使用');
+        }
+
+        try {
 
             $post['adminId'] = $this->adminId;
             $authCode = $post['authCode'] ?? '';
@@ -234,10 +235,10 @@ class ApplyController extends BaseController
             $newMainId = $newShop->mainId ?? 0;
             $newShopId = $newShop->id ?? 0;
             $pfShopId = $newShop->pfShopId ?? 0;
-            $onlyCg = isset($newShop->onlyCg) ? $newShop->onlyCg : 1;
+            $onlyCg = $newShop->onlyCg ?? 1;
 
             $shareLogo = imgUtil::groupImg('buy_logo.jpg');
-            if (isset($newShop->shareLogo) && !empty($newShop->shareLogo)) {
+            if (!empty($newShop->shareLogo)) {
                 $shareLogo = imgUtil::groupImg($newShop->shareLogo);
             }
 
@@ -290,7 +291,9 @@ class ApplyController extends BaseController
 
         } catch (\Exception $exception) {
             $transaction->rollBack();
-            Yii::info("申请报错:" . $exception->getMessage());
+            $message = $exception->getMessage() ?? '';
+            Yii::info("申请报错:" . $message);
+            noticeUtil::push("花店注册失败,手机号{$mobile},原因:" . $message, '15280215347');
             util::fail('提交失败');
         }
     }