Browse Source

添加供货商优化

shish 3 years ago
parent
commit
e48e4e807f
2 changed files with 31 additions and 36 deletions
  1. 30 35
      app-ghs/controllers/GhsController.php
  2. 1 1
      biz/ghs/classes/GhsClass.php

+ 30 - 35
app-ghs/controllers/GhsController.php

@@ -8,6 +8,7 @@ use bizHd\saas\classes\ApplyClass;
 use bizHd\saas\services\ApplyService;
 use common\components\dict;
 use common\components\imgUtil;
+use common\components\orderSn;
 use common\components\stringUtil;
 use Yii;
 use common\components\util;
@@ -19,14 +20,6 @@ class GhsController extends BaseController
     public function actionAdd()
     {
         $post = Yii::$app->request->post();
-        $mobile = $post['mobile'] ?? '';
-        $confirmMobile = $post['confirmMobile'];
-        if (stringUtil::isMobile($mobile) == false) {
-            util::fail(' 请填写正确的手机号');
-        }
-        if ($mobile != $confirmMobile) {
-            util::fail('二次号码填写不一致');
-        }
         $name = $post['name'] ?? '';
         if (empty($name)) {
             util::fail('名称不能为空');
@@ -34,37 +27,39 @@ class GhsController extends BaseController
         if (stringUtil::getWordNum($name) > 8) {
             util::fail('名称不能超过8个汉字');
         }
-        $has = ApplyClass::getByCondition(['mobile' => $mobile, 'style' => SjClass::STYLE_KM_SUPPLIER]);
-        if (!empty($has)) {
-
-            $connection = Yii::$app->db;
-            $transaction = $connection->beginTransaction();
-            try {
-                $shopId = $this->shopId;
-                $currentShopId = $has['shopId'] ?? 0;
-                if (empty($currentShopId)) {
-                    util::fail('添加失败');
-                }
-                $hasGhs = GhsClass::getByCondition(['ownShopId' => $this->shopId, 'shopId' => $currentShopId], true);
-                if (!empty($hasGhs)) {
-                    $name = $hasGhs->name ?? '';
-                    util::fail("手机已添加过了,供货商名称:【{$name}】");
-                }
-                $ghs = \biz\ghs\classes\GhsClass::build($currentShopId, $shopId, 1);
-                $ghs['avatar'] = imgUtil::groupImg($ghs['avatar']);
-                $transaction->commit();
-                util::success($ghs);
-            } catch (\Exception $exception) {
-                $transaction->rollBack();
-                Yii::info("添加供货商没有成功:" . $exception->getMessage());
-                util::fail('添加供货商没有成功');
-            }
-            util::fail('添加失败,请联系管理员');
-        }
+//        $has = ApplyClass::getByCondition(['mobile' => $mobile, 'style' => SjClass::STYLE_KM_SUPPLIER]);
+//        if (!empty($has)) {
+//
+//            $connection = Yii::$app->db;
+//            $transaction = $connection->beginTransaction();
+//            try {
+//                $shopId = $this->shopId;
+//                $currentShopId = $has['shopId'] ?? 0;
+//                if (empty($currentShopId)) {
+//                    util::fail('添加失败');
+//                }
+//                $hasGhs = GhsClass::getByCondition(['ownShopId' => $this->shopId, 'shopId' => $currentShopId], true);
+//                if (!empty($hasGhs)) {
+//                    $name = $hasGhs->name ?? '';
+//                    util::fail("手机已添加过了,供货商名称:【{$name}】");
+//                }
+//                $ghs = \biz\ghs\classes\GhsClass::build($currentShopId, $shopId, 1);
+//                $ghs['avatar'] = imgUtil::groupImg($ghs['avatar']);
+//                $transaction->commit();
+//                util::success($ghs);
+//            } catch (\Exception $exception) {
+//                $transaction->rollBack();
+//                Yii::info("添加供货商没有成功:" . $exception->getMessage());
+//                util::fail('添加供货商没有成功');
+//            }
+//            util::fail('添加失败,请联系管理员');
+//        }
 
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {
+            //获取虚拟手机号
+            $mobile = orderSn::getMobileSn();
             $sjId = $this->sjId;
             $shopId = $this->shopId;
             $sjName = $this->sj->name ?? '';

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

@@ -155,7 +155,7 @@ class GhsClass extends BaseClass
         $customObj = CustomClass::getById($customId, true);
         WxMessageClass::newGhsCustomInform($ghsShopObj, $customObj, $introduce);
         //新客户加入app通知
-        NoticeClass::newCustomNotice($ghsShop, $custom);
+        //NoticeClass::newCustomNotice($ghsShop, $custom);
         if ($type == 1) {
             return $ghs;
         }