收银台短信验证码
This commit is contained in:
parent
087181aabd
commit
777c3e8e56
@ -35,6 +35,7 @@ class UserValidate extends BaseValidate
|
|||||||
'brigade' => 'require',
|
'brigade' => 'require',
|
||||||
'user_ship' => 'require',
|
'user_ship' => 'require',
|
||||||
'type' => 'require|number',
|
'type' => 'require|number',
|
||||||
|
'code' => 'require|number',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@ -59,8 +60,8 @@ class UserValidate extends BaseValidate
|
|||||||
'brigade' => ' 队',
|
'brigade' => ' 队',
|
||||||
'user_ship' => ' 会员类型',
|
'user_ship' => ' 会员类型',
|
||||||
'type' => '查询类型',
|
'type' => '查询类型',
|
||||||
|
'code' => '验证码',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function sceneFund()
|
public function sceneFund()
|
||||||
{
|
{
|
||||||
return $this->only(['type','id']);
|
return $this->only(['type','id']);
|
||||||
|
@ -211,13 +211,13 @@ class UserLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function dealReportingSms($phone)
|
public function dealReportingSms($phone,$string = '_reporting')
|
||||||
{
|
{
|
||||||
$code = generateRandomCode();
|
$code = generateRandomCode();
|
||||||
$template = getenv('SMS_LOGIN_TEMPLATE');
|
$template = getenv('SMS_LOGIN_TEMPLATE');
|
||||||
$check =(new SmsService())->client($phone,$template,$code);
|
$check =(new SmsService())->client($phone,$template,$code);
|
||||||
if($check){
|
if($check){
|
||||||
$remark = $phone.'_reporting';
|
$remark = $phone.$string;
|
||||||
Cache::set($remark,$code,5*60);
|
Cache::set($remark,$code,5*60);
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
|
@ -4,11 +4,13 @@
|
|||||||
namespace app\store\controller\user;
|
namespace app\store\controller\user;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\service\SmsService;
|
||||||
use app\store\controller\BaseAdminController;
|
use app\store\controller\BaseAdminController;
|
||||||
use app\store\lists\user\UserLists;
|
use app\store\lists\user\UserLists;
|
||||||
use app\admin\logic\user\UserLogic;
|
use app\admin\logic\user\UserLogic;
|
||||||
use app\admin\validate\user\UserValidate;
|
use app\admin\validate\user\UserValidate;
|
||||||
use app\common\model\user\User;
|
use app\common\model\user\User;
|
||||||
|
use support\Cache;
|
||||||
|
|
||||||
class UserController extends BaseAdminController
|
class UserController extends BaseAdminController
|
||||||
{
|
{
|
||||||
@ -18,10 +20,36 @@ class UserController extends BaseAdminController
|
|||||||
return $this->dataLists(new UserLists());
|
return $this->dataLists(new UserLists());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户档案短信
|
||||||
|
* @return \support\Response
|
||||||
|
*/
|
||||||
|
public function archives_sms()
|
||||||
|
{
|
||||||
|
$mobile = $this->request->post('mobile','');
|
||||||
|
if (empty($mobile))
|
||||||
|
return $this->fail('手机号缺失');
|
||||||
|
$res = (new \app\api\logic\user\UserLogic())->dealReportingSms($mobile,'_userArchives');
|
||||||
|
if ($res){
|
||||||
|
return $this->success('发送成功');
|
||||||
|
}
|
||||||
|
return $this->fail('发送失败');
|
||||||
|
|
||||||
|
}
|
||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
$params = (new UserValidate())->post()->goCheck('storeAdd');
|
$params = (new UserValidate())->post()->goCheck('storeAdd');
|
||||||
|
$code = $params['code'];
|
||||||
|
if($code && $params['mobile']){
|
||||||
|
$remark = $params['mobile'].'_userArchives';
|
||||||
|
$codeCache = Cache::get($remark);
|
||||||
|
if(empty($codeCache)){
|
||||||
|
return $this->fail('验证码不存在');
|
||||||
|
}
|
||||||
|
if ($codeCache != $code) {
|
||||||
|
return $this->fail('验证码错误');
|
||||||
|
}
|
||||||
|
}
|
||||||
UserLogic::StoreAdd($params);
|
UserLogic::StoreAdd($params);
|
||||||
if (UserLogic::hasError() ) {
|
if (UserLogic::hasError() ) {
|
||||||
return $this->fail(UserLogic::getError());
|
return $this->fail(UserLogic::getError());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user