Selaa lähdekoodia

展示所有门店申请

shish 5 vuotta sitten
vanhempi
commit
987ad21f72

+ 13 - 3
app/ghs/controllers/ApplyController.php

@@ -39,13 +39,23 @@ class ApplyController extends BaseController
     public function actionRegister()
     {
         $post = Yii::$app->request->post();
+        $admin = $this->admin;
         $post['adminId'] = $this->adminId;
+        $post['adminName'] = $admin['adminName'] ?? '';
         $post['long'] = isset($post['longitude']) ? $post['longitude'] : '';
         $post['lat'] = isset($post['latitude']) ? $post['latitude'] : '';
         $post['from'] = ApplyClass::FROM_GHS;
-        $post['certType'] = ApplyClass::CERT_TYPE_LICENSE;
-        //增加或更新申请
-        ApplyService::addGhsApply($post);
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+            //新申请
+            ApplyService::replaceGhs($post);
+            $transaction->commit();
+        } catch (\Exception $exception) {
+            $transaction->rollBack();
+            Yii::info("申请报错:" . $exception->getMessage());
+            util::fail('提交失败');
+        }
         util::complete();
     }
 

+ 0 - 2
app/saas/controllers/ApplyController.php

@@ -16,13 +16,11 @@ class ApplyController extends BaseController
     public function actionList()
     {
         $get = Yii::$app->request->get();
-        $style = $get['style'] ?? MerchantClass::STYLE_RETAIL;
         $status = $get['status'] ?? 0;
         $where = [];
         if (!empty($status)) {
             $where['status'] = $status;
         }
-        $where['style'] = $style;
         $list = ApplyService::getApplyList($where);
         util::success($list);
     }

+ 1 - 0
app/shop/controllers/ApplyController.php

@@ -44,6 +44,7 @@ class ApplyController extends BaseController
         $post['long'] = isset($post['longitude']) ? $post['longitude'] : '';
         $post['lat'] = isset($post['latitude']) ? $post['latitude'] : '';
         $post['from'] = ApplyClass::FROM_RETAIL;
+        $post['style'] = MerchantClass::STYLE_RETAIL;
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {

+ 0 - 5
biz-ty/sj/services/MerchantService.php

@@ -2,17 +2,12 @@
 
 namespace bizTy\sj\services;
 
-use biz\ad\classes\AdClass;
-use biz\admin\classes\AdminRoleClass;
 use biz\agent\classes\AgentAssetClass;
 use biz\auth\services\AuthService;
-use biz\coupon\classes\CouponAssetClass;
-use biz\goods\classes\CategoryClass;
 use biz\goods\classes\GoodsSettingClass;
 use biz\saas\classes\ApplyClass;
 use bizGhs\custom\classes\CustomClass;
 use bizTy\base\services\BaseService;
-use biz\merchant\classes\AdminClass;
 use bizTy\sj\classes\MerchantAssetClass;
 use bizTy\sj\classes\MerchantClass;
 use bizTy\sj\classes\MerchantExtendClass;

+ 21 - 1
biz/saas/classes/ApplyClass.php

@@ -99,7 +99,27 @@ class ApplyClass extends BaseClass
         $data['style'] = MerchantClass::STYLE_RETAIL;
         $respond = self::addApply($data);
         $mobile = $data['mobile'];
-        $text = "有零售商资料提交,客户({$mobile})已提交资料,";
+        $text = "零售商 {$mobile} 已提交资料,";
+        if (isset($data['introSjName']) && !empty($data['introSjName'])) {
+            $text .= "介绍人:{$data['introSjName']},";
+        }
+        $text .= "请及时跟进";
+        noticeUtil::push($text, '15280215347');
+        return $respond;
+    }
+
+    //新增申请开店 shish 2021.2.27
+    public static function addGhs($data)
+    {
+        $prefix = $data['province'] == $data['city'] ? $data['province'] : $data['province'] . $data['city'];
+        $dist = $data['dist'] ?? '';
+        $floor = $data['floor'] ?? '';
+        $address = $data['address'] ?? '';
+        $data['fullAddress'] = $prefix . $dist . $address . $floor;
+        $data['style'] = MerchantClass::STYLE_SUPPLIER;
+        $respond = self::addApply($data);
+        $mobile = $data['mobile'];
+        $text = "供货商 {$mobile} 已提交资料,";
         if (isset($data['introSjName']) && !empty($data['introSjName'])) {
             $text .= "介绍人:{$data['introSjName']},";
         }

+ 22 - 30
biz/saas/services/ApplyService.php

@@ -79,7 +79,7 @@ class ApplyService extends BaseService
         return $respond;
     }
 
-    //新或修改申请开店 shish 2021.2.27
+    //新或修改申请开店 shish 2021.2.27
     public static function replaceRetail($data, $import = false)
     {
         $mobile = $data['mobile'] ?? 0;
@@ -109,7 +109,6 @@ class ApplyService extends BaseService
         if (in_array($from, [ApplyClass::FROM_GHS, ApplyClass::FROM_RETAIL]) == false) {
             util::fail('请填写来源');
         }
-
         if ($import == false) {
             //查询客户提交的证件
             $has = ApplyClass::getByCondition(['licenseNo' => $licenseNo]);
@@ -142,12 +141,8 @@ class ApplyService extends BaseService
     }
 
     //供货商申请开店 shish 2021.01.28
-    public static function addGhsApply($data)
+    public static function replaceGhs($data)
     {
-        $style = $data['style'] ?? 0;
-        if (in_array($style, [MerchantClass::STYLE_RETAIL, MerchantClass::STYLE_SUPPLIER]) == false) {
-            util::fail('请确认商家类型');
-        }
         $mobile = $data['mobile'] ?? 0;
         if (empty($mobile)) {
             util::fail('请填写手机号');
@@ -155,37 +150,34 @@ class ApplyService extends BaseService
         if (stringUtil::isMobile($mobile) == false) {
             util::fail('请填写正确手机号');
         }
-        //查询客户提交的证件
-        $certType = $data['certType'] ?? ApplyClass::CERT_TYPE_LICENSE;
-        $extend = ApplyClass::getByCondition(['certType' => $certType, 'mobile' => $mobile]);
-        if (!empty($extend)) {
-            util::fail('已申请过了');
-        }
         $from = $data['from'] ?? 0;
         if (in_array($from, [ApplyClass::FROM_GHS, ApplyClass::FROM_RETAIL]) == false) {
-            util::fail('申请没有填写来源');
+            util::fail('请填写来源');
+        }
+        $licenseNo = $data['licenseNo'] ?? '';
+        $has = ApplyClass::getByCondition(['licenseNo' => $licenseNo]);
+        if (!empty($has)) {
+            util::fail('您已申请');
+        }
+        //引荐的员工
+        $shopAdminId = $data['shopAdminId'] ?? 0;
+        if (!empty($shopAdminId)) {
+            $shopAdmin = ShopAdminClass::getById($shopAdminId);
+            if (!empty($shopAdmin)) {
+                $sjId = $shopAdmin['merchantId'] ?? 0;
+                $sj = MerchantClass::getMerchantById($sjId);
+                $data['introSjId'] = $sjId;
+                $data['introStyle'] = $sj['style'] ?? MerchantClass::STYLE_SUPPLIER;
+                $data['introSjName'] = $sj['merchantName'] ?? '';
+                $data['introShopId'] = $shopAdmin['shopId'] ?? 0;
+            }
         }
         $prefix = $data['province'] == $data['city'] ? $data['province'] : $data['province'] . $data['city'];
         $dist = $data['dist'] ?? '';
         $floor = $data['floor'] ?? '';
         $address = $data['address'] ?? '';
         $data['fullAddress'] = $prefix . $dist . $address . $floor;
-        $respond = ApplyClass::addApply($data);
-        $mobile = $data['mobile'];
-        if ($style == MerchantClass::STYLE_RETAIL) {
-            $text = "有零售商资料提交,";
-        } else {
-            $text = "供货商申请开店,";
-        }
-        $text .= '客户(' . $mobile . ')已提交资料,';
-        $introSjId = $data['introSjId'] ?? 0;
-        if (!empty($introSjId)) {
-            $merchant = MerchantClass::getMerchantById($introSjId);
-            $name = $merchant['merchantName'] ?? '';
-            $text .= "介绍人:{$name},";
-        }
-        $text .= "请及时跟进";
-        noticeUtil::push($text, '15280215347');
+        $respond = ApplyClass::addGhs($data);
         return $respond;
     }