Commit 9028c0d6 authored by clone's avatar clone

手机号注册

parent b42a149d
<?php
namespace app\api\controller;
use app\api\extend\Basic;
use app\api\untils\MessageUntils;
use think\Request;
/**
......@@ -10,21 +13,51 @@ use think\Request;
* Time : 18:38
* Intro:
*/
class Register extends Basic{
class Register extends Basic
{
function __construct($request = null)
{
parent::__construct($request);
}
public function registerVerify(){
/**
* 发送验证码
* @return \think\Response
*/
public function registerSendCode()
{
$params = $this->params;
$params = array(
"phone" => "13817616471"
/* $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 = array(
"phone" => "16617616471",
"device_id" => "1111",
"code" => 1231,
"union_id" =>
);
$checkResult = $this->validate($params, "04.verify");
$checkResult = $this->validate($params, "RegisterValidate.register");
if (true !== $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 @@
namespace app\api\untils;
use app\extra\RedisExt;
use app\model\NoteLog;
class MessageUntils {
......@@ -122,4 +123,53 @@ class MessageUntils {
$noteLog->save();
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;
class RegisterValidate extends Validate
{
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 = [
'wx_open_id.require' => '微信open_id不能为空',
'wx_open_id.length:10,50' => '微信open_id错误',
'sex.require' => '性别为必须字段',
'sex.number' => '性别必须是数字',
'source.require' => '来源为必须字段',
'source.number' => '来源必须是数字',
'user_id.require' => 'user_id为必须字段',
'user_id.number' => 'user_id必须是数字',
'user_id.gt' => 'user_id必须大于0',
'phone.regex' => '手机号格式不正确',
'device_id.require' => '设备id不能为空',
'code.require' => 'code为必填字段',
'code.number' => 'code只能为数字',
];
protected $scene = [
'verify' => [ 'phone'],
'select' => [ 'wx_open_id' ],
'bind' => [ 'wx_open_id', 'user_id' ],
'verify' => [ 'phone,device_id' ],
'register' => [ 'phone,device_id,code' ],
];
}
\ No newline at end of file
......@@ -21,7 +21,7 @@ Route::group('app', [
'share_register' => [ 'app/index/share_register', [ 'method' => 'get' ] ],
'agreement' => [ 'app/index/agreement', [ 'method' => 'get' ] ],
'agreement_app' => [ 'app/index/agreement_app', [ 'method' => 'get' ] ],
'download_c' => [ 'app/index/download_c', [ 'method' => 'get' ] ],
'download_c' => [ 'app/index/download_c', [ 'method' => 'get' ] ],
'getShopDetails' => [ 'app/index/getShopDetail', [ 'method' => 'get | post' ] ],
'getVersionNo' => [ 'app/index/getVersionNo', [ 'method' => 'get | post' ] ],
'feed' => [ 'app/index/feed', [ 'method' => 'get' ] ]
......@@ -48,7 +48,7 @@ Route::group('app_broker', [
'bargaininfo_detail_pc' => [ 'app_broker/index/bargaininfo_detail_pc', [ 'method' => 'get' ] ],
'customerinfo_customer_add' => [ 'app_broker/index/customerinfo_customer_add', [ 'method' => 'get' ] ],
'customerinfo_details_new' => [ 'app_broker/index/customerinfo_details_new', [ 'method' => 'get' ] ],
'download_b' => [ 'app_broker/index/download_b', [ 'method' => 'get' ] ],
'download_b' => [ 'app_broker/index/download_b', [ 'method' => 'get' ] ],
'imagebody' => [ 'app_broker/index/imagebody', [ 'method' => 'get' ] ],
]);
......@@ -162,7 +162,7 @@ Route::group('index', [
'editExclusive' => [ 'index/houses/editExclusive', [ 'method' => 'post' ] ], //添加和编辑楼盘独家
'getExclusive' => [ 'index/houses/getExclusive', [ 'method' => 'get' ] ], //获取楼盘独家
'getRecords' => [ 'index/houses/getRecords', [ 'method' => 'get' ] ], //操作记录
'delHouseFile' => [ 'index/houses/delHouseFile', [ 'method' => 'post' ] ], //操作记录
'delHouseFile' => [ 'index/houses/delHouseFile', [ 'method' => 'post' ] ], //操作记录
'getDistrictList' => [ 'index/district/getDistrictList', [ 'method' => 'get' ] ], //总监列表
'adddistrict' => [ 'index/district/addDistrict', [ 'method' => 'get|post' ] ], //添加部门,绑定总监关系
'getDistrictListByName' => [ 'index/district/getDistrictListByName', [ 'method' => 'get' ] ], //查询部门
......@@ -229,15 +229,15 @@ Route::group('index', [
'agent_zhuan_aagent' => [ 'index/agent/agent_zhuan_aagent', [ 'method' => 'post|get' ] ],//经纪人
'shop_a_store' => [ 'index/agent/shop_a_store', [ 'method' => 'post|get' ] ],//经纪人
'getCollection' => [ 'index/Collection/getCollection', [ 'method' => 'post|get' ] ],//收款记录
'addRealMoney' => [ 'index/Collection/addRealMoney', [ 'method' => 'post' ] ],//新增实收
'addRealMoney' => [ 'index/Collection/addRealMoney', [ 'method' => 'post' ] ],//新增实收
'visitShop' => [ 'index/Supervise/visitShop', [ 'method' => 'get' ] ],//门店拜访
'carryOut' => [ 'index/Supervise/carryOut', [ 'method' => 'get' ] ],//监督执行
'toReportListOne' => ['index/Finance/toReportListOne', [ 'method' => 'POST' ] ], //回到一级审核
'checkOver' => ['index/Finance/checkOver', [ 'method' => 'POST' ] ], //财务结单
'toReportListOne' => [ 'index/Finance/toReportListOne', [ 'method' => 'POST' ] ], //回到一级审核
'checkOver' => [ 'index/Finance/checkOver', [ 'method' => 'POST' ] ], //财务结单
'getTaxesById' => ['index/Finance/getTaxesById', [ 'method' => 'POST|GET' ] ], //财务结单
'financeUpdateLog' => ['index/Finance/financeUpdateLog', [ 'method' => 'POST|GET' ] ], //财务结单
'noticeIndex' => ['index/notice/index', [ 'method' => 'GET' ] ], //财务结单
'getTaxesById' => [ 'index/Finance/getTaxesById', [ 'method' => 'POST|GET' ] ], //财务结单
'financeUpdateLog' => [ 'index/Finance/financeUpdateLog', [ 'method' => 'POST|GET' ] ], //财务结单
'noticeIndex' => [ 'index/notice/index', [ 'method' => 'GET' ] ], //财务结单
......@@ -312,24 +312,15 @@ Route::group('api', [
//Version
'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' ] ],//经纪人搜索
// 'getULabelsListApp' => [ 'api_broker/Client/getULabelsListApp', [ 'method' => 'get' ] ],//客户标签
// 'all_user' => [ 'api_broker/Client/all_user', [ '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
'saveWxInfo' => [ 'api/WxSdk/saveWxInfo', [ 'method' => 'POST|GET' ] ], //wx
'bindUserId' => [ 'api/WxSdk/bindUserId', [ 'method' => 'POST|GET' ] ], //wx
'sendCode' => [ 'api/Register/registerSendCode', [ 'method' => 'POST' ] ],
'userVerify' => [ 'api/Register/registerVerify', [ 'method' => 'POST|get' ] ],
]);
Route::group('chat', [
......@@ -472,8 +463,8 @@ Route::group('broker', [
//user
'returnSearchCondition' => [ 'api_broker/User/returnSearchCondition', [ 'method' => 'get' ] ], //客户搜索条件
'searchUser' => [ 'api_broker/User/searchUser', [ 'method' => 'get|post' ] ], //客户搜索
'returnSearchCondition' => [ 'api_broker/User/returnSearchCondition', [ 'method' => 'get' ] ], //客户搜索条件
'searchUser' => [ 'api_broker/User/searchUser', [ 'method' => 'get|post' ] ], //客户搜索
]);
......
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