Răsfoiți Sursa

零售的申请开店基本ok

shish 5 ani în urmă
părinte
comite
956d3646f3

+ 1 - 1
app/ghs/controllers/ApplyController.php

@@ -65,7 +65,7 @@ class ApplyController extends BaseController
         $post['from'] = ApplyClass::FROM_GHS;
         $post['certType'] = ApplyClass::CERT_TYPE_LICENSE;
         //增加或更新申请
-        ApplyService::replaceGhsApply($post);
+        ApplyService::addGhsApply($post);
         util::complete();
     }
 

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

@@ -47,10 +47,20 @@ class ApplyController extends BaseController
         if ($apply['status'] != 0) {
             util::fail('已经审过了');
         }
-        if ($status == 1) {
-            ApplyService::pass($id);
+
+        $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('操作失败');
         }
-        ApplyService::updateById($id, ['status' => $status, 'remark' => $remark]);
+
         util::success('操作成功');
     }
 
@@ -62,12 +72,6 @@ class ApplyController extends BaseController
         $post['long'] = isset($post['longitude']) ? $post['longitude'] : '';
         $post['lat'] = isset($post['latitude']) ? $post['latitude'] : '';
         $post['from'] = ApplyClass::FROM_RETAIL;
-        if (isset($post['mobile']) == false) {
-            util::fail('请填写手机号');
-        }
-        if (stringUtil::isMobile($post['mobile']) == false) {
-            util::fail('请填写正确手机号');
-        }
         //增加或更新申请
         ApplyService::replaceRetailApply($post);
         util::complete();

+ 29 - 127
biz-ty/sj/classes/MerchantClass.php

@@ -6,14 +6,9 @@ use biz\ad\classes\AdClass;
 use biz\admin\classes\AdminClass;
 use biz\coupon\classes\CouponAssetClass;
 use biz\goods\classes\CategoryClass;
-use biz\goods\classes\GoodsSettingClass;
-use biz\saas\classes\ApplyClass;
-use bizTy\shop\classes\ShopClass;
 use common\components\business;
 use common\components\httpUtil;
 use common\components\qrCodeUtil;
-use common\components\stringUtil;
-use common\components\util;
 use Yii;
 use biz\base\classes\BaseClass;
 
@@ -34,6 +29,35 @@ class MerchantClass extends BaseClass
     //供货商
     const STYLE_SUPPLIER = 2;
 
+    //开店初始化更多信息,有提供营业执照才初始化的信息 shish 2021.2.27
+    public static function initMore($applyData, $sjId, $shopId)
+    {
+        if ($applyData['style'] == MerchantClass::STYLE_RETAIL) {
+            self::initRetailMore($applyData, $sjId, $shopId);
+        }
+        if ($applyData['style'] == MerchantClass::STYLE_SUPPLIER) {
+            self::initGhsMore($applyData, $sjId, $shopId);
+        }
+    }
+
+    public static function initRetailMore($applyData, $sjId, $shopId)
+    {
+        //初始化员工和角色
+        AdminClass::initAdmin($applyData, $sjId, $shopId);
+        //商品和分类初始化
+        CategoryClass::initCategoryGoods($sjId);
+        //商城和门店广告初始化
+        AdClass::initAdd($sjId);
+        //优惠券资产与配置信息初始化
+        CouponAssetClass::add(['merchantId' => $sjId, 'switch' => 1]);
+    }
+
+    public static function initGhsMore($applyData, $sjId, $shopId)
+    {
+        //初始化员工和角色
+        \bizGhs\admin\classes\AdminClass::initAdmin($applyData, $sjId, $shopId);
+    }
+
     //商家信息组合 shish 2019.12.20
     public static function groupMerchantBaseInfo($list)
     {
@@ -64,128 +88,6 @@ class MerchantClass extends BaseClass
         return $list;
     }
 
-    //初始化商家信息 shish 2020.2.11
-    public static function initSjInfo($applyData)
-    {
-        $applyId = $applyData['id'];
-        unset($applyData['id']);
-
-        //生成商家
-        $applyData['accountStyle'] = 0;
-        $applyData['status'] = 1;
-        $applyData['shopLat'] = isset($applyData['lat']) ? $applyData['lat'] : (string)0;
-        $applyData['shopLong'] = isset($applyData['long']) ? $applyData['long'] : (string)0;
-        $applyData['shopPrecision'] = (string)0;
-        $applyData['wxToken'] = stringUtil::buildWxToken(0);
-        $applyData['shopPhotoList'] = isset($applyData['shopPhotoList']) ? $applyData['shopPhotoList'] : '';
-        $applyData['merchantName'] = isset($applyData['merchantName']) ? $applyData['merchantName'] : '';
-        $applyData['shopProvince'] = isset($applyData['province']) ? $applyData['province'] : '';
-        $applyData['shopCity'] = isset($applyData['city']) ? $applyData['city'] : '';
-        $applyData['shopDist'] = isset($applyData['dist']) ? $applyData['dist'] : '';
-        $applyData['shopAddress'] = isset($applyData['address']) ? $applyData['address'] : '';
-        $applyData['alipayAccount'] = isset($applyData['alipayAccount']) ? $applyData['alipayAccount'] : '';
-        $applyData['alipayAccountName'] = isset($applyData['alipayAccountName']) ? $applyData['alipayAccountName'] : '';
-        $applyData['agentLevel'] = 1;
-        $applyData['parentId'] = $applyData['introSjId'] ?? 0;
-        $sj = self::add($applyData);
-
-        $sjId = $sj['id'];
-        $mobile = $applyData['mobile'];
-
-        ApplyClass::updateById($applyId, ['sjId' => $sjId]);
-
-        //生成资产
-        $assetData = [
-            'balance' => 0,
-            'totalVisit' => 0,
-            'totalUser' => 0,
-            'totalMember' => 0,
-            'totalFans' => 0,
-            'totalWeixinFans' => 0,
-            'totalIntegral' => 0,
-            'totalPoint' => 0,
-            'totalGoods' => 0,
-            'totalRecharge' => 0,
-            'totalOrder' => 0,
-            'totalDeal' => 0,
-            'merchantId' => $sjId,
-            'totalIncome' => 0,
-            'totalExpend' => 0,
-        ];
-        MerchantAssetClass::add($assetData);
-
-        //生成商家拓展信息
-        $extendData = [
-            'merchantId' => $sjId,
-            'wxAppId' => isset($applyData['wxAppId']) ? $applyData['wxAppId'] : '',
-            'webTitle' => isset($applyData['merchantName']) ? $applyData['merchantName'] : '',
-            'webKeyword' => isset($applyData['merchantName']) ? $applyData['merchantName'] : '',
-            'webDescription' => isset($applyData['merchantName']) ? $applyData['merchantName'] : '',
-            'wxMenuInit' => 0,
-            'wxTMessageInit' => 0,
-            'payment' => 0,//支付功能关闭
-            'recharge' => 0,//充值功能关闭
-            'giveCoupon' => 1,//默认赠送代金劵
-            'giveCouponPrice' => 5,//代金劵金额5元
-            'couponMeetPrice' => 180,//满足金额
-            'couponValidity' => 30,//代金劵有效期30天
-            'alipayAccount' => isset($applyData['alipayAccount']) ? $applyData['alipayAccount'] : '',//提现的支付宝帐号
-            'alipayAccountName' => isset($applyData['alipayAccountName']) ? $applyData['alipayAccountName'] : '',//提现支付宝帐号姓名
-            'gradeList' => '1_2000_0.9I2_5000_0.88I3_10000_0.85I4_20000_0.8',//1 级会员需要满 2000 积分 购物享9折;2 级会员需要满 5000 积分 购物享88折
-        ];
-        MerchantExtendClass::add($extendData);
-
-        MerchantInitClass::add(['merchantId' => $sjId]);
-
-        //商家商品配置信息
-        $setData = [
-            'merchantId' => $sjId,
-            'riseType' => 0,
-            'riseAmount' => 0,
-        ];
-        GoodsSettingClass::add($setData);
-        //创建门店
-        $shopData = [
-            'shopName' => $sj['merchantName'],
-            'merchantId' => $sjId,
-            'openTime' => '8:00 - 23:00',
-            'telephone' => $mobile,
-            'introduction' => '欢迎光临',
-            'province' => isset($applyData['province']) ? $applyData['province'] : '',
-            'city' => isset($applyData['city']) ? $applyData['city'] : '',
-            'dist' => isset($applyData['dist']) ? $applyData['dist'] : '',
-            'default' => 1,
-            'address' => isset($applyData['address']) ? $applyData['address'] : '',
-            'fullAddress' => isset($applyData['fullAddress']) ? $applyData['fullAddress'] : '',
-        ];
-        $shopRespond = ShopClass::addShop($shopData);
-        $shopId = $shopRespond['id'];
-        //设置商家默认门店
-        MerchantClass::updateById($sjId, ['defaultShopId' => $shopId]);
-
-        if ($applyData['style'] == MerchantClass::STYLE_RETAIL) {
-
-            //初始化员工和角色
-            AdminClass::initAdmin($applyData, $sjId, $shopId);
-
-            //商品和分类初始化
-            CategoryClass::initCategoryGoods($sjId);
-            //商城和门店广告初始化
-            AdClass::initAdd($sjId);
-            //优惠券资产与配置信息初始化
-            CouponAssetClass::add(['merchantId' => $sjId, 'switch' => 1]);
-
-        } elseif ($applyData['style'] == MerchantClass::STYLE_SUPPLIER) {
-
-            //初始化员工和角色
-            \bizGhs\admin\classes\AdminClass::initAdmin($applyData, $sjId, $shopId);
-
-        } else {
-            util::fail('商家类型有问题');
-        }
-        return $sj;
-    }
-
     //h5商城链接二维码 shish 2020.4.30
     public static function getH5MallQrCode($id)
     {

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

@@ -2,9 +2,13 @@
 
 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 bizTy\base\services\BaseService;
 use biz\merchant\classes\AdminClass;
@@ -18,7 +22,9 @@ use biz\saas\services\SetMealService;
 use biz\user\services\UserService;
 use biz\wx\classes\WxOpenClass;
 use biz\wx\services\WxMenuService;
+use bizTy\sj\classes\MerchantInitClass;
 use common\components\business;
+use common\components\stringUtil;
 use common\components\util;
 use common\services\xhTMessageService;
 use common\services\xhWxMenuService;
@@ -29,6 +35,117 @@ class MerchantService extends BaseService
 
     public static $baseFile = '\bizTy\sj\classes\MerchantClass';
 
+    //初始化商家信息 shish 2020.2.11
+    public static function initSjInfo($applyData)
+    {
+        $applyId = $applyData['id'];
+        unset($applyData['id']);
+
+        //生成商家
+        $applyData['accountStyle'] = 0;
+        $applyData['status'] = 1;
+        $applyData['shopLat'] = isset($applyData['lat']) ? $applyData['lat'] : (string)0;
+        $applyData['shopLong'] = isset($applyData['long']) ? $applyData['long'] : (string)0;
+        $applyData['shopPrecision'] = (string)0;
+        $applyData['wxToken'] = stringUtil::buildWxToken(0);
+        $applyData['shopPhotoList'] = isset($applyData['shopPhotoList']) ? $applyData['shopPhotoList'] : '';
+        $applyData['merchantName'] = isset($applyData['merchantName']) ? $applyData['merchantName'] : '';
+        $applyData['shopProvince'] = isset($applyData['province']) ? $applyData['province'] : '';
+        $applyData['shopCity'] = isset($applyData['city']) ? $applyData['city'] : '';
+        $applyData['shopDist'] = isset($applyData['dist']) ? $applyData['dist'] : '';
+        $applyData['shopAddress'] = isset($applyData['address']) ? $applyData['address'] : '';
+        $applyData['alipayAccount'] = isset($applyData['alipayAccount']) ? $applyData['alipayAccount'] : '';
+        $applyData['alipayAccountName'] = isset($applyData['alipayAccountName']) ? $applyData['alipayAccountName'] : '';
+        $applyData['agentLevel'] = 1;
+        $applyData['parentId'] = $applyData['introSjId'] ?? 0;
+        $sj = self::add($applyData);
+
+        $sjId = $sj['id'];
+        $mobile = $applyData['mobile'];
+
+        ApplyClass::updateById($applyId, ['sjId' => $sjId]);
+
+        //生成资产
+        $assetData = [
+            'balance' => 0,
+            'totalVisit' => 0,
+            'totalUser' => 0,
+            'totalMember' => 0,
+            'totalFans' => 0,
+            'totalWeixinFans' => 0,
+            'totalIntegral' => 0,
+            'totalPoint' => 0,
+            'totalGoods' => 0,
+            'totalRecharge' => 0,
+            'totalOrder' => 0,
+            'totalDeal' => 0,
+            'merchantId' => $sjId,
+            'totalIncome' => 0,
+            'totalExpend' => 0,
+        ];
+        MerchantAssetClass::add($assetData);
+
+        //生成商家拓展信息
+        $extendData = [
+            'merchantId' => $sjId,
+            'wxAppId' => isset($applyData['wxAppId']) ? $applyData['wxAppId'] : '',
+            'webTitle' => isset($applyData['merchantName']) ? $applyData['merchantName'] : '',
+            'webKeyword' => isset($applyData['merchantName']) ? $applyData['merchantName'] : '',
+            'webDescription' => isset($applyData['merchantName']) ? $applyData['merchantName'] : '',
+            'wxMenuInit' => 0,
+            'wxTMessageInit' => 0,
+            'payment' => 0,//支付功能关闭
+            'recharge' => 0,//充值功能关闭
+            'giveCoupon' => 1,//默认赠送代金劵
+            'giveCouponPrice' => 5,//代金劵金额5元
+            'couponMeetPrice' => 180,//满足金额
+            'couponValidity' => 30,//代金劵有效期30天
+            'alipayAccount' => isset($applyData['alipayAccount']) ? $applyData['alipayAccount'] : '',//提现的支付宝帐号
+            'alipayAccountName' => isset($applyData['alipayAccountName']) ? $applyData['alipayAccountName'] : '',//提现支付宝帐号姓名
+            'gradeList' => '1_2000_0.9I2_5000_0.88I3_10000_0.85I4_20000_0.8',//1 级会员需要满 2000 积分 购物享9折;2 级会员需要满 5000 积分 购物享88折
+        ];
+        MerchantExtendClass::add($extendData);
+
+        MerchantInitClass::add(['merchantId' => $sjId]);
+
+        //商家商品配置信息
+        $setData = [
+            'merchantId' => $sjId,
+            'riseType' => 0,
+            'riseAmount' => 0,
+        ];
+        GoodsSettingClass::add($setData);
+
+        //创建门店
+        $shopData = [
+            'shopName' => $sj['merchantName'],
+            'merchantId' => $sjId,
+            'openTime' => '8:00 - 23:00',
+            'telephone' => $mobile,
+            'introduction' => '欢迎光临',
+            'province' => isset($applyData['province']) ? $applyData['province'] : '',
+            'city' => isset($applyData['city']) ? $applyData['city'] : '',
+            'dist' => isset($applyData['dist']) ? $applyData['dist'] : '',
+            'default' => 1,
+            'address' => isset($applyData['address']) ? $applyData['address'] : '',
+            'fullAddress' => isset($applyData['fullAddress']) ? $applyData['fullAddress'] : '',
+        ];
+        $shopRespond = ShopClass::addShop($shopData);
+        $shopId = $shopRespond['id'];
+
+        //设置商家默认门店
+        MerchantClass::updateById($sjId, ['defaultShopId' => $shopId]);
+
+        //有营业执照时才初始化的信息
+        if (isset($applyData['licenseNo']) && !empty($applyData['licenseNo'])) {
+            //员工角色、商品、分类等等初始化
+            MerchantClass::initMore($applyData, $sjId, $shopId);
+        }
+
+        return $sj;
+    }
+
+
     //生成商家 shish 2021.2.23
     public static function generateSj($apply)
     {

+ 15 - 11
biz/admin/classes/AdminClass.php

@@ -23,6 +23,12 @@ class AdminClass extends BaseClass
         'wx84d95afcb7b594eb' => ['oTFbYvsjwgVwXggwtlM2ESAKwuN8', 'oTFbYvqP6qwdCCkdFB9GYnlzDIUg'],
     ];
 
+    //补充营业执照时初始化员工
+    public static function supplementAdmin()
+    {
+
+    }
+
     //开店时初始化员工和角色
     public static function initAdmin($applyData, $sjId, $shopId)
     {
@@ -55,17 +61,15 @@ class AdminClass extends BaseClass
         }
         //新增客户
         if (isset($applyData['introSjId']) && $applyData['introStyle'] == MerchantClass::STYLE_SUPPLIER) {
-            if ($applyData['style'] == MerchantClass::STYLE_RETAIL) {
-                $customData = [
-                    'customSjId' => $sjId,
-                    'customShopId' => $shopId,
-                    'sjId' => $applyData['introSjId'],
-                    'name' => $applyData['name'],
-                    'mobile' => $applyData['mobile'],
-                    'isOpen' => 1,
-                ];
-                CustomClass::addCustom($customData);
-            }
+            $customData = [
+                'customSjId' => $sjId,
+                'customShopId' => $shopId,
+                'sjId' => $applyData['introSjId'],
+                'name' => $applyData['name'],
+                'mobile' => $applyData['mobile'],
+                'isOpen' => 1,
+            ];
+            CustomClass::addCustom($customData);
         }
     }
 

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

@@ -2,8 +2,12 @@
 
 namespace biz\saas\classes;
 
+use biz\admin\classes\AdminClass;
 use biz\admin\classes\ShopAdminClass;
 use biz\agent\classes\AgentAssetClass;
+use bizGhs\custom\classes\CustomClass;
+use bizTy\sj\classes\MerchantClass;
+use common\components\noticeUtil;
 use common\components\sms;
 use common\components\stringUtil;
 use common\components\util;
@@ -51,9 +55,79 @@ class ApplyClass extends BaseClass
     }
 
     //更新申请 shish 2021.2.27
-    public static function updateApply()
+    public static function updateRetailApply($data)
     {
+        $customId = $data['customId'] ?? 0;
+        $custom = CustomClass::getById($customId);
+        $customSjId = $custom['customSjId'] ?? 0;
+        $customShopId = $custom['customShopId'];
+        $currentApply = ApplyClass::getByCondition(['sjId' => $customSjId]);
+        if (empty($currentApply)) {
+            util::fail('此客户没有申请开店记录,请排查');
+        }
+        $currentApplyId = $currentApply['id'] ?? 0;
+        $licenseNo = $currentApply['licenseNo'] ?? '';
+        if (!empty($licenseNo)) {
+            util::fail('您已经申请过了');
+        }
+        $applyMobile = $currentApply['mobile'] ?? '';
+        $mobile = $data['mobile'] ?? '';
+        if ($mobile != $applyMobile) {
+            noticeUtil::push("供货商的客户补充开店材料出错 customId:{$customId}", '15280215347');
+            util::fail('手机号错误,请联系管理员', '15280215347');
+        }
+
+        ApplyClass::updateById($currentApplyId, $data);
+        ApplyExtendClass::updateByCondition(['applyId' => $currentApplyId], $data);
+
+        $newApply = ApplyClass::getById($currentApplyId);
+
+        MerchantClass::initRetailMore($newApply, $customSjId, $customShopId);
+
+        return true;
+    }
 
+    //新增申请开店 shish 2021.2.27
+    public static function addRetailApply($data, $system = false)
+    {
+        $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'] ?? '';
+        $address = $data['address'] ?? '';
+        $data['fullAddress'] = $prefix . $dist . $address . $floor;
+        $data['style'] = MerchantClass::STYLE_RETAIL;
+        $respond = self::addApply($data);
+        $mobile = $data['mobile'];
+        $text = "有零售商资料提交,客户(' . $mobile . ')已提交资料,";
+        if (isset($data['introSjName']) && !empty($data['introSjName'])) {
+            $text .= "介绍人:{$data['introSjName']},";
+        }
+        $text .= "请及时跟进";
+        noticeUtil::push($text, '15280215347');
+        return $respond;
     }
 
 }

+ 25 - 68
biz/saas/services/ApplyService.php

@@ -5,9 +5,11 @@ namespace biz\saas\services;
 use biz\admin\classes\AdminClass;
 use biz\base\services\BaseService;
 use bizGhs\custom\classes\CustomClass;
+use bizTy\shop\classes\ShopAdminClass;
 use bizTy\sj\classes\MerchantClass;
 use biz\saas\classes\ApplyClass;
 use biz\saas\classes\ApplyExtendClass;
+use bizTy\sj\services\MerchantService;
 use common\components\noticeUtil;
 use common\components\stringUtil;
 use common\components\util;
@@ -52,102 +54,57 @@ class ApplyService extends BaseService
     }
 
     //审核通过,商家初始化 shish 2021.2.23
-    public static function pass($id)
+    public static function pass($id, $remark = '')
     {
         $apply = ApplyClass::getById($id);
         if (empty($apply)) {
             util::fail('没有找到申请记录');
         }
         $applyId = $apply['id'];
-        ApplyClass::updateById($applyId, ['status' => ApplyClass::STATUS_PASS]);
+        ApplyClass::updateById($applyId, ['status' => ApplyClass::STATUS_PASS, 'remark' => $remark]);
         $adminId = $apply['adminId'];
         $admin = AdminClass::getById($adminId);
         $apply['merchantName'] = isset($apply['name']) ? $apply['name'] : '';
         $apply['adminName'] = $admin['adminName'] ?? '';
-        $respond = MerchantClass::initSjInfo($apply);
+        //初始化商家信息
+        $respond = MerchantService::initSjInfo($apply);
         return $respond;
     }
 
-    //零售商的申请开店 shish 2021.2.27
+    //新样或修改申请开店 shish 2021.2.27
     public static function replaceRetailApply($data, $system = false)
     {
-        $style = MerchantClass::STYLE_RETAIL;
         $mobile = $data['mobile'] ?? 0;
-        $licenseNo = $data['licenseNo'] ?? '';
         if (empty($mobile)) {
             util::fail('请填写手机号');
         }
         if (stringUtil::isMobile($mobile) == false) {
             util::fail('请填写正确手机号');
         }
-
-        //这里的客户id是在供货商的客户详情邀请开店传过来的
-        //客户已经开店但没有提供营业执照,需要重新走申请流程
-        $customId = $data['customId'] ?? 0;
-        $introSjId = 0;
-        if (!empty($customId)) {
-            $custom = CustomClass::getById($customId);
-            $customSjId = $custom['customSjId'] ?? 0;
-            $currentApply = ApplyClass::getByCondition(['sjId' => $customSjId]);
-            $licenseNo = $currentApply['licenseNo'] ?? '';
-            if (empty($licenseNo)) {
-                util::fail('您已经申请过了');
-            }
-            $introSjId = $customSjId;
-            $data['introSjId'] = $introSjId;
-        }
-
-        //非系统申请需要验证
-        $certType = $data['certType'] ?? ApplyClass::CERT_TYPE_LICENSE;
-        if ($system == false) {
-            //查询客户提交的证件
-            $has = ApplyClass::getByCondition(['certType' => $certType, '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;
             }
-        } 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'] ?? '';
-        $address = $data['address'] ?? '';
-        $data['fullAddress'] = $prefix . $dist . $address . $floor;
-        $respond = ApplyClass::addApply($data);
-        $mobile = $data['mobile'];
-        if ($style == MerchantClass::STYLE_RETAIL) {
-            $text = "有零售商资料提交,";
+        $customId = $data['customId'] ?? 0;
+        if (!empty($customId)) {
+            //纯彩花艺客户已经开店但没有提供营业执照,需要重新走申请流程
+            return ApplyClass::updateRetailApply($data);
         } else {
-            $text = "供货商申请开店,";
+            return ApplyClass::addRetailApply($data, $system);
         }
-        $text .= '客户(' . $mobile . ')已提交资料,';
-        if (!empty($introSjId)) {
-            $merchant = MerchantClass::getMerchantById($introSjId);
-            $name = $merchant['merchantName'] ?? '';
-            $text .= "介绍人:{$name},";
-        }
-        $text .= "请及时跟进";
-        noticeUtil::push($text, '15280215347');
-        return $respond;
-    }
-
-    //供货商的申请开店 shish 2021.2.27
-    public static function replaceGhsApply()
-    {
-
     }
 
-    //申请开店 shish 2021.01.28
-    public static function replaceApply($data)
+    //供货商申请开店 shish 2021.01.28
+    public static function addGhsApply($data)
     {
         $style = $data['style'] ?? 0;
         if (in_array($style, [MerchantClass::STYLE_RETAIL, MerchantClass::STYLE_SUPPLIER]) == false) {

+ 2 - 0
console/controllers/SjInitController.php

@@ -4,6 +4,7 @@ namespace console\controllers;
 
 use biz\saas\classes\ApplyClass;
 use biz\saas\services\ApplyService;
+use bizTy\sj\classes\MerchantClass;
 use Yii;
 use yii\console\Controller;
 
@@ -40,6 +41,7 @@ class SjInitController extends Controller
         foreach ($data as $key => $val) {
             $val['from'] = ApplyClass::FROM_GHS;
             $val['introSjId'] = $sjId;
+            $val['introStyle'] = MerchantClass::STYLE_SUPPLIER;
             $val['name'] = $val['sjName'];
             $val['fullAddress'] = $val['address'];
             $val['nickName'] = $val['adminName'];

+ 4 - 1
sql.sql

@@ -1274,4 +1274,7 @@ ALTER TABLE xhGhsAdmin ADD recentShop VARCHAR(500) NOT NULL DEFAULT '' COMMENT '
 ALTER TABLE xhApply MODIFY `certType` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '证件类型 1营业执照 2身份证号';
 ALTER TABLE xhApply MODIFY `licenseNo` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '营业执照号,身份证号';
 ALTER TABLE xhApplyExtend MODIFY `licenseNo` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '营业执照号,身份证号';
-ALTER TABLE xhApplyExtend MODIFY `license` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '营业执照,身份证照';
+ALTER TABLE xhApplyExtend MODIFY `license` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '营业执照,身份证照';
+ALTER TABLE xhApply MODIFY `introStyle` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '商家类型 同 xhSj的style字段';
+ALTER TABLE xhApply ADD introSjName VARCHAR(100) NOT NULL DEFAULT '' COMMENT '商家名称' AFTER `introStyle`;
+ALTER TABLE xhApply ADD introShopId INT NOT NULL DEFAULT 0 COMMENT '引荐商家的门店' AFTER `introSjName`;