|
|
@@ -2,9 +2,11 @@
|
|
|
|
|
|
namespace shop\controllers;
|
|
|
|
|
|
+use biz\admin\services\AdminShopService;
|
|
|
use biz\saas\services\ApplyService;
|
|
|
use biz\wx\services\WxBaseService;
|
|
|
use biz\wx\services\WxOpenService;
|
|
|
+use common\components\stringUtil;
|
|
|
use Yii;
|
|
|
use common\components\util;
|
|
|
use biz\admin\services\AdminService;
|
|
|
@@ -51,49 +53,32 @@ class ApplyController extends BaseController
|
|
|
//申请试用 shish 2020.1.11
|
|
|
public function actionRegister()
|
|
|
{
|
|
|
-
|
|
|
- $rand = rand(0, 1);
|
|
|
- $wxBase = WxBaseService::getWxBase();
|
|
|
- $wxAliasName = isset($wxBase['wxAliasName']) && !empty($wxBase['wxAliasName']) ? $wxBase['wxAliasName'] : 'ihuahuibao';
|
|
|
- $data = ['focus' => 1, 'wxAliasName' => $wxAliasName];
|
|
|
- if ($rand == 0) {
|
|
|
- $data = ['focus' => 0, 'wxAliasName' => $wxAliasName];
|
|
|
- }
|
|
|
- util::success($data);
|
|
|
-
|
|
|
$get = Yii::$app->request->get();
|
|
|
- if (isset($get['oldId']) && !empty($get['oldId'])) {
|
|
|
- $get['introMerchantId'] = $get['oldId'];
|
|
|
- }
|
|
|
- $get['userId'] = $this->userId;
|
|
|
+ $get['adminId'] = $this->adminId;
|
|
|
$get['long'] = isset($get['longitude']) ? $get['longitude'] : '';
|
|
|
$get['lat'] = isset($get['latitude']) ? $get['latitude'] : '';
|
|
|
-
|
|
|
- $cacheKey = 'OPEN_SHOP_APPLY_' . $this->userId;
|
|
|
- $cacheCode = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
|
|
|
- if (isset($cacheCode) == false || empty($cacheCode)) {
|
|
|
- util::fail('没有验证码');
|
|
|
+ $introMerchantId = isset($get['introMerchantId']) && !empty($get['introMerchantId']) ? $get['introMerchantId'] : 0;
|
|
|
+ if (empty($introMerchantId)) {
|
|
|
+ util::fail('目前仅开放邀请注册');
|
|
|
}
|
|
|
- if ($get['code'] != $cacheCode) {
|
|
|
- util::fail('验证码错误');
|
|
|
+ $mobile = isset($get['mobile']) && !empty($get['mobile']) && stringUtil::isMobile($get['mobile']) ? $get['mobile'] : 0;
|
|
|
+ if (empty($mobile)) {
|
|
|
+ util::fail('请填写正确手机号');
|
|
|
}
|
|
|
-
|
|
|
- $apply = ApplyClass::getByCondition(['userId' => $this->userId]);
|
|
|
+ $apply = ApplyClass::getByCondition(['mobile' => $mobile]);
|
|
|
if (!empty($apply)) {
|
|
|
- util::fail('您已经申请过了');
|
|
|
+ util::fail('手机号已被使用');
|
|
|
}
|
|
|
- $admin = AdminService::getByCondition(['platUserId' => $this->userId]);
|
|
|
- if (!empty($admin)) {
|
|
|
- util::fail('您已经开店了');
|
|
|
+ $apply = ApplyClass::getByCondition(['adminId' => $this->adminId]);
|
|
|
+ if (!empty($apply)) {
|
|
|
+ util::fail('您已经申请过了');
|
|
|
}
|
|
|
+ $admin = AdminService::getById($this->adminId);
|
|
|
ApplyService::addApply($get);
|
|
|
- $rand = rand(0, 1);
|
|
|
$wxBase = WxBaseService::getWxBase();
|
|
|
$wxAliasName = isset($wxBase['wxAliasName']) && !empty($wxBase['wxAliasName']) ? $wxBase['wxAliasName'] : 'ihuahuibao';
|
|
|
- $data = ['focus' => 1, 'wxAliasName' => $wxAliasName];
|
|
|
- if ($rand == 0) {
|
|
|
- $data = ['focus' => 0, 'wxAliasName' => $wxAliasName];
|
|
|
- }
|
|
|
+ $focus = isset($admin['subscribe']) ? $admin['subscribe'] : 0;
|
|
|
+ $data = ['focus' => $focus, 'wxAliasName' => $wxAliasName];
|
|
|
util::success($data);
|
|
|
}
|
|
|
|