Commit 9028c0d6 authored by clone's avatar clone

手机号注册

parent b42a149d
<?php <?php
namespace app\api\controller; namespace app\api\controller;
use app\api\extend\Basic; use app\api\extend\Basic;
use app\api\untils\MessageUntils;
use think\Request; use think\Request;
/** /**
...@@ -10,21 +13,51 @@ use think\Request; ...@@ -10,21 +13,51 @@ use think\Request;
* Time : 18:38 * Time : 18:38
* Intro: * Intro:
*/ */
class Register extends Basic
class Register extends Basic{ {
function __construct($request = null) function __construct($request = null)
{ {
parent::__construct($request); parent::__construct($request);
} }
public function registerVerify(){
/**
* 发送验证码
* @return \think\Response
*/
public function registerSendCode()
{
$params = $this->params;
/* $params = array(
"phone" => "16617616471",
"device_id" => "1111"
);*/
$checkResult = $this->validate($params, "RegisterValidate.verify");
if (true !== $checkResult) {
return $this->response("101", $checkResult);
}
$message = new MessageUntils();
$result = $message->sendCheckCodeV2($params['device_id'], $params['phone']);
if ($result == 'true') {
return $this->response("200", "request success", $result);
} else {
return $this->response("101", $result);
}
}
public function registerVerify()
{
$params = $this->params; $params = $this->params;
$params = array( $params = array(
"phone" => "13817616471" "phone" => "16617616471",
"device_id" => "1111",
"code" => 1231,
"union_id" =>
); );
$checkResult = $this->validate($params, "04.verify"); $checkResult = $this->validate($params, "RegisterValidate.register");
if (true !== $checkResult) { if (true !== $checkResult) {
return $this->response("101", $checkResult); return $this->response("101", $checkResult);
} }
//^((13[0-9])|(14[5,7,9])|(15[^4])|(18[0-9])|(17[0,1,3,5,6,7,8]))\\d{8}$
} }
} }
\ No newline at end of file
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
namespace app\api\untils; namespace app\api\untils;
use app\extra\RedisExt;
use app\model\NoteLog; use app\model\NoteLog;
class MessageUntils { class MessageUntils {
...@@ -122,4 +123,53 @@ class MessageUntils { ...@@ -122,4 +123,53 @@ class MessageUntils {
$noteLog->save(); $noteLog->save();
return $result_data; return $result_data;
} }
/**
* @param $device_id
* @param $phone
* @return mixed
*/
public function sendCheckCodeV2($device_id,$phone) {
$noteLog = new NoteLog();
$send_time = $noteLog->field('send_time')->where('phone', $phone)
->where('is_success',1)
->where('send_time','between time',[date('Y-m-d').' 00:00:00',date('Y-m-d').' 23:59:59'])
->select();
$num = count($send_time); //发送数量
if (!empty($send_time[$num-1]) && (time() - strtotime($send_time[$num-1]->send_time) < 58) && $num != 0) {
return '1分钟内不能再次获取验证码';
}
if ($num > 7){
return '短信发送超过上限';
}
$message = new MessageUntils();
$_code = mt_rand(1000, 9999) . '';
$result = $message->sendCCPSMS($phone, array($_code, '5分钟'), 214759);
$noteLog->phone = $phone;
$noteLog->template_msg = '【同联商业】您的验证码为'.$_code.',请于5分钟内正确输入,如非本人操作,请忽略此短信。';
$noteLog->code = $_code;
$noteLog->send_time = date('Y-m-d H:i:s');
$result['statusCode'] = 0;
if ($result['statusCode'] == "000000") {
$noteLog->is_success = 1;
$noteLog->save();
//todo 存code
$redis_ = RedisExt::getRedis();
if($redis_){
$redis_->set($device_id,$_code,300);
}else{
session($device_id,$_code);
}
return "true";
} else {
$noteLog->is_success = 2;
$noteLog->save();
return '发送异常,请联系管理员';
}
}
} }
...@@ -14,25 +14,20 @@ use think\Validate; ...@@ -14,25 +14,20 @@ use think\Validate;
class RegisterValidate extends Validate class RegisterValidate extends Validate
{ {
protected $rule = [ protected $rule = [
'phone' => 'require|length:11|number',
'code' => 'require|number', 'code' => 'require|number',
'device_id' => 'require',
'phone' => [ 'regex' => '/^((13[0-9])|(14[0-9])|(15[0-9])|(18[0-9])|(16[0-9])|(17[0-9])|(19[0-9]))\\d{8}$/i' ],
]; ];
protected $message = [ protected $message = [
'wx_open_id.require' => '微信open_id不能为空', 'phone.regex' => '手机号格式不正确',
'wx_open_id.length:10,50' => '微信open_id错误', 'device_id.require' => '设备id不能为空',
'sex.require' => '性别为必须字段', 'code.require' => 'code为必填字段',
'sex.number' => '性别必须是数字', 'code.number' => 'code只能为数字',
'source.require' => '来源为必须字段',
'source.number' => '来源必须是数字',
'user_id.require' => 'user_id为必须字段',
'user_id.number' => 'user_id必须是数字',
'user_id.gt' => 'user_id必须大于0',
]; ];
protected $scene = [ protected $scene = [
'verify' => [ 'phone'], 'verify' => [ 'phone,device_id' ],
'select' => [ 'wx_open_id' ], 'register' => [ 'phone,device_id,code' ],
'bind' => [ 'wx_open_id', 'user_id' ],
]; ];
} }
\ No newline at end of file
...@@ -232,12 +232,12 @@ Route::group('index', [ ...@@ -232,12 +232,12 @@ Route::group('index', [
'addRealMoney' => [ 'index/Collection/addRealMoney', [ 'method' => 'post' ] ],//新增实收 'addRealMoney' => [ 'index/Collection/addRealMoney', [ 'method' => 'post' ] ],//新增实收
'visitShop' => [ 'index/Supervise/visitShop', [ 'method' => 'get' ] ],//门店拜访 'visitShop' => [ 'index/Supervise/visitShop', [ 'method' => 'get' ] ],//门店拜访
'carryOut' => [ 'index/Supervise/carryOut', [ 'method' => 'get' ] ],//监督执行 'carryOut' => [ 'index/Supervise/carryOut', [ 'method' => 'get' ] ],//监督执行
'toReportListOne' => ['index/Finance/toReportListOne', [ 'method' => 'POST' ] ], //回到一级审核 'toReportListOne' => [ 'index/Finance/toReportListOne', [ 'method' => 'POST' ] ], //回到一级审核
'checkOver' => ['index/Finance/checkOver', [ 'method' => 'POST' ] ], //财务结单 'checkOver' => [ 'index/Finance/checkOver', [ 'method' => 'POST' ] ], //财务结单
'getTaxesById' => ['index/Finance/getTaxesById', [ 'method' => 'POST|GET' ] ], //财务结单 'getTaxesById' => [ 'index/Finance/getTaxesById', [ 'method' => 'POST|GET' ] ], //财务结单
'financeUpdateLog' => ['index/Finance/financeUpdateLog', [ 'method' => 'POST|GET' ] ], //财务结单 'financeUpdateLog' => [ 'index/Finance/financeUpdateLog', [ 'method' => 'POST|GET' ] ], //财务结单
'noticeIndex' => ['index/notice/index', [ 'method' => 'GET' ] ], //财务结单 'noticeIndex' => [ 'index/notice/index', [ 'method' => 'GET' ] ], //财务结单
...@@ -312,24 +312,15 @@ Route::group('api', [ ...@@ -312,24 +312,15 @@ Route::group('api', [
//Version //Version
'getVersionNo' => [ 'api/Version/getVersionNo', [ 'method' => 'post|get' ] ], 'getVersionNo' => [ 'api/Version/getVersionNo', [ 'method' => 'post|get' ] ],
// 'agentUserTb' => [ 'api_broker/Client/agentUserTb', [ 'method' => 'get' ] ],//客户列表
// 'agentUserFollow' => [ 'api_broker/Client/agentUserFollow', [ 'method' => 'get' ] ],//客户列表
// 'agentSearch' => [ 'api_broker/Client/agentSearch', [ 'method' => 'get' ] ],//经纪人搜索 'saveWxInfo' => [ 'api/WxSdk/saveWxInfo', [ 'method' => 'POST|GET' ] ], //wx
// 'getULabelsListApp' => [ 'api_broker/Client/getULabelsListApp', [ 'method' => 'get' ] ],//客户标签 'bindUserId' => [ 'api/WxSdk/bindUserId', [ 'method' => 'POST|GET' ] ], //wx
// 'all_user' => [ 'api_broker/Client/all_user', [ 'method' => 'post|get' ] ],//全部客户 朱伟
'sendCode' => [ 'api/Register/registerSendCode', [ 'method' => 'POST' ] ],
'userVerify' => [ 'api/Register/registerVerify', [ 'method' => 'POST|get' ] ],
'convertOrderByTime' => [ 'api/ConvertOrder/convertOrderByTime', [ 'method' => 'post|get' ] ],
'convertMarchIn' => [ 'api/ConvertOrder/convertMarchIn', [ 'method' => 'post|get' ] ],
'convertCollectingBill' => [ 'api/ConvertOrder/convertCollectingBill', [ 'method' => 'post|get' ] ],
'houseTable' => [ 'api/TransferHouseInfo/table', [ 'method' => 'post|get' ] ], //转商铺表
'houseImgTable' => [ 'api/TransferHouseInfo/houseImg', [ 'method' => 'post|get' ] ], //转楼盘表
'agentHouse' => [ 'api/TransferHouseInfo/agentHouse', [ 'method' => 'post|get' ] ], //转楼盘表
'saveWxInfo' => ['api/WxSdk/saveWxInfo', [ 'method' => 'POST|GET' ] ], //wx
'bindUserId' => ['api/WxSdk/bindUserId', [ 'method' => 'POST|GET' ] ], //wx 'userNickToUserName' => [ 'api/TransferHouseInfo/userNickToUserName', [ 'method' => 'post|get' ] ], //user_nick同步到user_name
'landlordPhoneToJson' => [ 'api/TransferHouseInfo/landlordPhoneToJson', [ 'method' => 'post|get' ] ], //房东手机号转json
'landlordPhoneStar' => [ 'api/TransferHouseInfo/landlordPhoneStar', [ 'method' => 'post|get' ] ], //房东手机号转json
]); ]);
Route::group('chat', [ Route::group('chat', [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment