123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- <?php
- /**
- * IdentifyController.php UTF-8
- * 实名认证
- *
- * @date : 2018/4/27 16:38
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : wuyonghong <wyh@huosdk.com>
- * @version : HUOSDK 8.0
- */
- namespace api\float\controller;
- use api\common\controller\V2ApiBaseController;
- use huo\controller\member\Bind;
- use huo\controller\member\Member;
- use huo\controller\member\MemCache;
- use huo\model\member\MemberModel;
- use huoIdentify\controller\Identify;
- use huoIdentify\controller\Online;
- use huoIdentify\controller\UnderageLimitMsg;
- use huolib\constant\CommonConst;
- use huolib\constant\GameConst;
- use huolib\constant\IdentifyConst;
- use huolib\sms\SmsType;
- use huolib\status\CommonStatus;
- use huolib\status\MemberStatus;
- class IdentifyController extends V2ApiBaseController {
- public function _initialize() {
- parent::_initialize();
- }
- /**
- * WAP-实名认证页
- * http://doc.1tsdk.com/138?page_id=3112
- * 【域名】/wap/identify/index
- */
- public function index() {
- $this->checkLogin();
- $_device_id = get_val($this->rq_data, 'device_id', '');
- $_mem_data = (new MemCache())->getInfoById($this->mem_id);
- $_app_id = $this->request->param('app_id', CommonConst::CONST_ZERO);
- $_rdata['username'] = $_mem_data['username'];
- $_id_types = IdentifyConst::getTypes();
- $_list = [];
- foreach ($_id_types as $_k => $_v) {
- $_list[] = [
- 'type_id' => $_k,
- 'type_name' => $_v,
- ];
- }
- $_type_arr['count'] = count($_id_types);
- $_type_arr['list'] = $_list;
- $_rdata['type'] = $_type_arr;
- $_rdata['game_auth'] = (new \huoIdentify\controller\Identify())->getGameAuthByAppId($_app_id);
- $this->assign($_rdata);
- $this->assign('app_id', $_app_id);
- $this->assign('device_id', $_device_id);
- return $this->fetch('identify/index');
- }
- /**
- * API-实名认证-设置
- * http://doc.1tsdk.com/138?page_id=3117
- * 【域名】/wap/identify/set
- */
- public function save() {
- $this->checkLogin();
- $_type = $this->request->param('type/d', IdentifyConst::ITYPE_MAINLAND);
- $_idcard = $this->request->param('idcard/s', '');
- $_idcard = $this->request->param('id_card/s', $_idcard); //兼容旧字段
- $_realname = $this->request->param('realname/s', '');
- $_realname = $this->request->param('real_name/s', $_realname); //兼容旧字段
- if (empty($_idcard) || empty($_realname)) {
- $_code = CommonStatus::INVALID_PARAMS;
- $this->error(CommonStatus::getMsg($_code), [], $_code);
- }
- $_rdata = (new Identify())->updateIdentify($this->mem_id, $_type, $_realname, $_idcard);
- $this->returnData($_rdata);
- }
- /**
- * WAP-实名认证提示信息页
- * http://doc.huosdk.com/web/#/138?page_id=10976
- * 【域名】/wap/identify/msg
- */
- public function getMsg() {
- $_type = $this->request->param('type', CommonConst::CONST_ZERO);
- $_rdata = UnderageLimitMsg::getMsg($_type);
- $this->assign('msg', $_rdata['msg']);
- $this->assign('close_type', $_rdata['close_type']);
- return $this->fetch('identify/msg');
- }
- /**
- * 绑定手机页面
- * http://doc.huosdk.com/web/#/138?page_id=10989
- * 【域名】/wap/identify/bind/mobile
- */
- public function bindMobile() {
- $_app_id = get_val($this->rq_data, 'app_id', CommonConst::CONST_ZERO);
- $_device_id = get_val($this->rq_data, 'device_id', '');
- $this->assign('app_id', $_app_id);
- $this->assign('device_id', $_device_id);
- $_game_auth = GameConst::GAME_IDENTIFY_IS_YES; // 类型 1 实名认证:不需认证 2 实名认证:强制认证 3 实名认证:需认证
- $_mem_id = $this->mem_id;
- $_online_class = (new Online($_app_id, $_mem_id, $_device_id));
- $_time_left = $_online_class->getTimeLeft();
- if (empty($_time_left['time_left']) && !empty($_time_left['bind_url'])) {
- // $_game_auth = (new \huoIdentify\controller\Identify())->getGameAuthByAppId($_app_id);
- $_game_auth = GameConst::GAME_IDENTIFY_IS_MUST; // 类型 1 实名认证:不需认证 2 实名认证:强制认证 3 实名认证:需认证
- }
- $_identify_url = $_online_class->getIdentifyUrl();
- $this->assign('identify_url', $_identify_url);
- $this->assign('game_auth', $_game_auth);
- return $this->fetch('identify/bind_mobile');
- }
- /**
- * 发送短信
- * http://doc.huosdk.com/web/#/138?page_id=10990
- * 【域名】/wap/identify/sms/send
- */
- public function smsSend() {
- $_param = $this->rq_data;
- $_sms_data = get_val($_param, 'sms', []);
- $_mobile = get_val($_sms_data, 'mobile', '');
- if (empty($_mobile)) {
- $_mem_id = $this->mem_id;
- $_rdata = (new Bind())->getBindInfo($_mem_id);
- if (CommonStatus::NO_ERROR != $_rdata['code']) {
- return $this->returnData($_rdata);
- }
- $_mobile = get_val($_rdata['data'], 'real_mobile', '');
- }
- $_type = get_val($_sms_data, 'type', SmsType::SMS_ID_VERIFY);
- $_bind_class = new Bind();
- $_rdata = $_bind_class->smsSend($_mobile, $_type);
- return $this->returnData($_rdata);
- }
- /**
- * 绑定手机
- * http://doc.huosdk.com/web/#/138?page_id=10991
- * 【域名】/wap/identify/bind/post
- */
- public function bindPost() {
- $_sms_data = get_val($this->rq_data, 'sms', []);
- $_mobile = get_val($_sms_data, 'mobile', '');
- $_type = get_val($_sms_data, 'type', SmsType::SMS_ID_VERIFY);
- $_code = get_val($_sms_data, 'code', '');
- $_app_id = get_val($this->rq_data, 'app_id', CommonConst::CONST_ZERO);
- $_device_id = get_val($this->rq_data, 'device_id', '');
- $_password = get_val($this->rq_data, 'password', '');
- if (empty($_password)) {
- $_code = MemberStatus::PASSWORD_EMPTY;
- $this->error(MemberStatus::getMsg($_code));
- }
- if (empty($_app_id) || empty($_device_id)) {
- $_code = CommonStatus::INVALID_PARAMS;
- $this->error(CommonStatus::getMsg($_code));
- }
- $_member_count = (new MemberModel()) ->getMemNumber($_mobile);
- if ($_member_count > 8){
- $_code = MemberStatus::PHONE_BIND_TOOMUCH;
- $this->error(MemberStatus::getMsg($_code));
- }
- $_mem_rq = $this->setMemData();
- $_bind_class = new Bind();
- $_rdata = $_bind_class->bindPost($this->mem_id, $_mobile, $_code, $_type, $_mem_rq->getPassword());
- if (CommonStatus::NO_ERROR != $_rdata['code']) {
- return $this->returnData($_rdata);
- }
- $_auth_info = (new Identify())->getMemIdentifyInfo($_app_id, $this->mem_id, $_device_id);
- $_rdata['data']['url'] = get_val($_auth_info, 'url', '');
- $_rdata['data']['auth_info'] = get_val($_auth_info, 'auth_info', []);
- $_rs = (new Member())->updatePassword($this->mem_id, $_password);
- if (CommonStatus::NO_ERROR != $_rs['code']) {
- return $this->returnData($_rs);
- }
- //Log::error(['绑定手机号', $this->rq_data, $_rdata]);
- return $this->returnData($_rdata);
- }
- }
|