shish пре 5 година
родитељ
комит
d077ba804c

+ 0 - 20
app/ghs/controllers/ApplyController.php

@@ -35,26 +35,6 @@ class ApplyController extends BaseController
         util::success($data);
     }
 
-    //审核
-    public function actionCheck()
-    {
-        $id = Yii::$app->request->post('id');
-        $status = Yii::$app->request->post('status', 0);
-        $remark = Yii::$app->request->post('remark', '');
-        $apply = ApplyService::getById($id);
-        if (empty($apply)) {
-            util::fail('找不到申请记录');
-        }
-        if ($apply['status'] != 0) {
-            util::fail('已经审过了');
-        }
-        if ($status == 1) {
-            ApplyService::pass($id);
-        }
-        ApplyService::updateById($id, ['status' => $status, 'remark' => $remark]);
-        util::success('操作成功');
-    }
-
     //申请试用,花店添加新客户 shish 2021.1.8
     public function actionRegister()
     {

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

@@ -50,10 +50,10 @@ class ApplyController extends BaseController
             $transaction->commit();
         } catch (\Exception $exception) {
             $transaction->rollBack();
-            Yii::info("商家审核操作失败,报错:" . $exception->getMessage());
+            Yii::info("审核操作报错:" . $exception->getMessage());
             util::fail('操作失败');
         }
-        util::success('操作成功');
+        util::complete();
     }
 
     //申请试用登记 shish 2020.1.11

+ 13 - 32
app/shop/controllers/ApplyController.php

@@ -34,46 +34,27 @@ class ApplyController extends BaseController
         util::success($data);
     }
 
-    //审核
-    public function actionCheck()
-    {
-        $id = Yii::$app->request->post('id');
-        $status = Yii::$app->request->post('status', 0);
-        $remark = Yii::$app->request->post('remark', '');
-        $apply = ApplyService::getById($id);
-        if (empty($apply)) {
-            util::fail('找不到申请记录');
-        }
-        if ($apply['status'] != 0) {
-            util::fail('已经审过了');
-        }
-
-        $connection = Yii::$app->db;//事务处理
-        $transaction = $connection->beginTransaction();
-        try {
-            if ($status == 1) {
-                ApplyService::pass($id);
-            } else {
-                ApplyClass::updateById($id, ['status' => $status, 'remark' => $remark]);
-            }
-        } catch (\Exception $e) {
-            $transaction->rollBack();
-            util::fail('操作失败');
-        }
-
-        util::success('操作成功');
-    }
-
     //申请试用 shish 2020.1.11
     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_RETAIL;
-        //增加或更新申请
-        ApplyService::replaceRetailApply($post);
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+            //增加或更新申请
+            ApplyService::replaceRetail($post);
+            $transaction->commit();
+        } catch (\Exception $exception) {
+            $transaction->rollBack();
+            Yii::info("申请报错:" . $exception->getMessage());
+            util::fail('提交失败');
+        }
         util::complete();
     }
 

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

@@ -49,7 +49,6 @@ class MerchantService extends BaseService
         $customSjId = $custom['customSjId'] ?? 0;
         $customShopId = $custom['customShopId'] ?? 0;
         MerchantClass::initRetailMore($apply, $customSjId, $customShopId);
-
         //标识有客户关系的开店状态
         CustomClass::updateByCondition(['customSjId' => $customSjId], ['isOpen' => 1]);
     }

+ 12 - 29
biz/saas/classes/ApplyClass.php

@@ -55,7 +55,7 @@ class ApplyClass extends BaseClass
     }
 
     //更新申请 shish 2021.2.27
-    public static function updateRetailApply($data)
+    public static function updateRetail($data)
     {
         $customId = $data['customId'] ?? 0;
         $custom = CustomClass::getById($customId);
@@ -72,42 +72,25 @@ class ApplyClass extends BaseClass
         $applyMobile = $currentApply['mobile'] ?? '';
         $mobile = $data['mobile'] ?? '';
         if ($mobile != $applyMobile) {
-            noticeUtil::push("供货商的客户补充开店材料出错 customId:{$customId}", '15280215347');
+            noticeUtil::push("二次申请开店使用的手机号不一样 customId:{$customId}", '15280215347');
             util::fail('手机号错误,请联系管理员', '15280215347');
         }
-
+        $data['status'] = ApplyClass::STATUS_CHECKING;
         ApplyClass::updateById($currentApplyId, $data);
-        ApplyExtendClass::updateByCondition(['applyId' => $currentApplyId], $data);
 
+        $licenseNo = $data['licenseNo'] ?? '';
+        $mobile = $data['mobile'] ?? '';
+        $extData = [
+            'licenseNo' => $licenseNo,
+            'mobile' => $mobile,
+        ];
+        ApplyExtendClass::updateByCondition(['applyId' => $currentApplyId], $extData);
         return true;
     }
 
     //新增申请开店 shish 2021.2.27
-    public static function addRetailApply($data, $system = false)
+    public static function addRetail($data)
     {
-        $licenseNo = $data['licenseNo'] ?? '';
-        $mobile = $data['mobile'] ?? '';
-
-        $certType = $data['certType'] ?? ApplyClass::CERT_TYPE_LICENSE;
-        if ($system == false) {
-            //查询客户提交的证件
-            $has = ApplyClass::getByCondition(['certType' => $certType, 'licenseNo' => $licenseNo]);
-            if (!empty($has)) {
-                util::fail('您已申请过了');
-            }
-        } else {
-            //导入纯彩花艺已有客户判断
-            $has = ApplyClass::getByCondition(['certType' => $certType, 'licenseNo' => $licenseNo, 'mobile' => $mobile]);
-            if (!empty($has)) {
-                noticeUtil::push("客户 $mobile 已经申请", '15280215347');
-                return false;
-            }
-        }
-
-        $from = $data['from'] ?? 0;
-        if (in_array($from, [ApplyClass::FROM_GHS, ApplyClass::FROM_RETAIL]) == false) {
-            util::fail('申请没有填写来源');
-        }
         $prefix = $data['province'] == $data['city'] ? $data['province'] : $data['province'] . $data['city'];
         $dist = $data['dist'] ?? '';
         $floor = $data['floor'] ?? '';
@@ -116,7 +99,7 @@ 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']},";
         }

+ 34 - 3
biz/saas/services/ApplyService.php

@@ -4,6 +4,7 @@ namespace biz\saas\services;
 
 use biz\admin\classes\AdminClass;
 use biz\base\services\BaseService;
+use biz\saas\models\Apply;
 use bizGhs\custom\classes\CustomClass;
 use bizTy\shop\classes\ShopAdminClass;
 use bizTy\sj\classes\MerchantClass;
@@ -79,7 +80,7 @@ class ApplyService extends BaseService
     }
 
     //新样或修改申请开店 shish 2021.2.27
-    public static function replaceRetailApply($data, $system = false)
+    public static function replaceRetail($data, $import = false)
     {
         $mobile = $data['mobile'] ?? 0;
         if (empty($mobile)) {
@@ -101,12 +102,42 @@ class ApplyService extends BaseService
                 $data['introShopId'] = $shopAdmin['shopId'] ?? 0;
             }
         }
+        $licenseNo = $data['licenseNo'] ?? '';
+        $mobile = $data['mobile'] ?? '';
+
+        $from = $data['from'] ?? 0;
+        if (in_array($from, [ApplyClass::FROM_GHS, ApplyClass::FROM_RETAIL]) == false) {
+            util::fail('请填写来源');
+        }
+
+        if ($import == false) {
+            //查询客户提交的证件
+            $has = ApplyClass::getByCondition(['licenseNo' => $licenseNo]);
+            if (!empty($has)) {
+                util::fail('您已申请');
+            }
+            $has = ApplyClass::getByCondition(['mobile' => $mobile]);
+            if (!empty($has)) {
+                $currentSjId = $has['sjId'] ?? 0;
+                $currentCustom = CustomClass::getByCondition(['customSjId' => $currentSjId]);
+                if (!empty($currentCustom)) {
+                    $data['customId'] = $currentCustom['id'] ?? 0;
+                }
+            }
+        } else {
+            //导入纯彩花艺已有客户判断
+            $has = ApplyClass::getByCondition(['mobile' => $mobile]);
+            if (!empty($has)) {
+                noticeUtil::push("客户 $mobile 已经申请", '15280215347');
+                return false;
+            }
+        }
         $customId = $data['customId'] ?? 0;
         if (!empty($customId)) {
             //纯彩花艺客户已经开店但没有提供营业执照,需要重新走申请流程
-            return ApplyClass::updateRetailApply($data);
+            return ApplyClass::updateRetail($data);
         } else {
-            return ApplyClass::addRetailApply($data, $system);
+            return ApplyClass::addRetail($data);
         }
     }
 

+ 1 - 1
console/controllers/SjInitController.php

@@ -45,7 +45,7 @@ class SjInitController extends Controller
             $val['name'] = $val['sjName'];
             $val['fullAddress'] = $val['address'];
             $val['nickName'] = $val['adminName'];
-            $respond = ApplyService::replaceRetailApply($val, true);
+            $respond = ApplyService::replaceRetail($val, true);
             if (!empty($respond)) {
                 $id = $respond['id'] ?? 0;
                 ApplyService::pass($id);