shish 6 лет назад
Родитель
Сommit
404a32576f

+ 11 - 1
app/www/controllers/ApplyController.php

@@ -60,8 +60,18 @@ class ApplyController extends BaseController
 		}
 		$admin = AdminService::getByCondition(['platUserId' => $this->userId]);
 		if (!empty($admin)) {
-			util::fail('您已经开店了');
+			util::fail('您已经开店了,不能重复申请');
 		}
+		
+		$cacheKey = 'OPEN_SHOP_APPLY_' . $userId;
+		$cacheCode = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+		if (isset($cacheCode) == false || empty($cacheCode)) {
+			util::fail('没有验证码');
+		}
+		if ($get['code'] != $cacheCode) {
+			util::fail('验证码错误');
+		}
+
 		ApplyService::addApply($get);
 		if ($rand == 0) {
 			$data = ['focus' => 0, 'qrCode' => 'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=3602624501,870193918&fm=26&gp=0.jpg'];

+ 5 - 8
app/www/controllers/InformUserController.php

@@ -13,8 +13,8 @@ use yii\helpers\Json;
 
 class InformUserController extends BaseController
 {
-	
-	//发送短信
+
+	//申请开店提交资料时发送验证码 shish 2020.3.8
 	public function actionSendSms()
 	{
 		$get = Yii::$app->request->get();
@@ -23,16 +23,13 @@ class InformUserController extends BaseController
 		if (stringUtil::isMobile($mobile) == false) {
 			util::fail('请填写手机号');
 		}
-
 		$code = stringUtil::getRandNum(4);
 		$msg = "您的验证码:" . $code . "。为了您的帐号安全,验证码不要告诉别人哦";
 		$userId = $this->userId;
+		
+		$cacheKey = 'OPEN_SHOP_APPLY_' . $userId;
+		Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 120, $code]);
 
-		if ($type == 1) {
-
-		} else {
-			util::fail('发送失败');
-		}
 		sms::send($mobile, $msg);
 		util::ok('已发送');
 	}