身份认证及新短信接入

master
zhengyongxing 5 years ago
parent 7f396e24d6
commit f273f58c90

@ -1180,7 +1180,11 @@ function think_psw_md5($str, $key = 'ThinkUCenter')
function age_verify($cardno, $name, $user_id = '') function age_verify($cardno, $name, $user_id = '')
{ {
$info = ''; $info = '';
if (C('tool_age.status')==1) {
$date = age($cardno, $name, $info); $date = age($cardno, $name, $info);
} else if(C('juhe_age.status')==1){
$date = juhedataAge($cardno, $name, C('juhe_age.appkey'));
}
$arr['name'] = $name; $arr['name'] = $name;
$arr['id_card'] = $cardno; $arr['id_card'] = $cardno;
@ -1206,6 +1210,26 @@ function age_verify($cardno, $name, $user_id = '')
$arr['status'] = 0; $arr['status'] = 0;
M('idcard_log', 'tab_')->data($arr)->add(); M('idcard_log', 'tab_')->data($arr)->add();
return 0; return 0;
} elseif(isset($date['error_code']) && $date['error_code'] == 0 && $date['result']['res'] == 1){
$arr['status'] = 1;
M('idcard_log', 'tab_')->data($arr)->add();
$birthday = getIDCardInfo($cardno);
if ($birthday['isAdult'] == 1) {
return 2;
} else {
return 1;
}
} elseif(isset($date['error_code']) && $date['error_code'] == 0 && $date['result']['res'] == 2){
$arr['status'] = 0;
M('idcard_log', 'tab_')->data($arr)->add();
return 0;
} elseif(isset($date['error_code']) && $date['error_code'] != 0){
$arr['status'] = 0;
M('idcard_log', 'tab_')->data($arr)->add();
return 3;
} else { } else {
$arr['status'] = -1; $arr['status'] = -1;
M('idcard_log', 'tab_')->data($arr)->add(); M('idcard_log', 'tab_')->data($arr)->add();
@ -1251,6 +1275,20 @@ function age($cardno, $name, &$info)
return $r; return $r;
} }
function juhedataAge($cardno, $name, $key) {
$url = "http://op.juhe.cn/idcard/query";
$post['idcard'] = $cardno;
$post['realname'] = $name;
$post['orderid'] = 1;
$post['key'] = $key;
$return = json_decode(curl_post($url,$post),true);
return $return;
}
function age2($cardno, $name) { function age2($cardno, $name) {
$host = "https://idcardcert.market.alicloudapi.com"; $host = "https://idcardcert.market.alicloudapi.com";
$path = "/idCardCert"; $path = "/idCardCert";
@ -1433,3 +1471,56 @@ function curl_post($url = '', $post_data = array()) {
return $data; return $data;
} }
function getIDCardInfo($IDCard){
$result['error']=0;//0未知错误1身份证格式错误2无错误
$result['flag']='';//0标示成年1标示未成年
$result['tdate']='';//生日格式如2012-11-15<br>     
if(!preg_match("/^[1-9]([0-9a-zA-Z]{17}|[0-9a-zA-Z]{14})$/i",$IDCard)){
//5.3以下
//if(!eregi("^[1-9]([0-9a-zA-Z]{17}|[0-9a-zA-Z]{14})$",$IDCard)){
$result['error']=1;
return $result;
}else{
if(strlen($IDCard)==18){
$tyear=intval(substr($IDCard,6,4));
$tmonth=intval(substr($IDCard,10,2));
$tday=intval(substr($IDCard,12,2));
if($tyear>date("Y")||$tyear<(date("Y")-100)){
$flag=0;
}elseif($tmonth<0||$tmonth>12){
$flag=0;
}elseif($tday<0||$tday>31){
$flag=0;
}else{
$tdate=$tyear."-".$tmonth."-".$tday." 00:00:00";
if((time()-mktime(0,0,0,$tmonth,$tday,$tyear))>18*365*24*60*60){
$flag=0;
}else{
$flag=1;
}
}
}elseif(strlen($IDCard)==15){
$tyear=intval("19".substr($IDCard,6,2));
$tmonth=intval(substr($IDCard,8,2));
$tday=intval(substr($IDCard,10,2));
if($tyear>date("Y")||$tyear<(date("Y")-100)){
$flag=0;
}elseif($tmonth<0||$tmonth>12){
$flag=0;
}elseif($tday<0||$tday>31){
$flag=0;
}else{
$tdate=$tyear."-".$tmonth."-".$tday." 00:00:00";
if((time()-mktime(0,0,0,$tmonth,$tday,$tyear))>18*365*24*60*60){
$flag=0;
}else{
$flag=1;
}
}
}
}
$result['error']=2;//0未知错误1身份证格式错误2无错误
$result['isAdult']=$flag;//0标示成年1标示未成年
$result['birthday']=$tdate;//生日日期
return $result;
}

@ -220,7 +220,15 @@ class SmsController extends Controller {
$sms_return = ['code'=>1010,'msg'=>$re['message']]; $sms_return = ['code'=>1010,'msg'=>$re['message']];
} }
} else { } elseif(get_tool_status('juhedata')) {
$this->check_sms($phone,C('juhedata.limit'),true,$pid);
$re = juheSmsCode($phone,C('juhedata.tpl_id'),C('juhedata.key'),$rand);
if (!$re['error_code']) {
$sms_return = ['code'=>1010,'msg'=>$re['reason']];
}
}else {
$sms_return = ['code'=>1008,'msg'=>'没有配置短信发送']; $sms_return = ['code'=>1008,'msg'=>'没有配置短信发送'];

@ -385,3 +385,23 @@ function getIpForbitWhiteList($user_id) {
return $is_white_list?true:false; return $is_white_list?true:false;
} }
/**
* 聚合数据短信接口
* @param $phone 电话号码
* @param $tpl_id 模板id
* @param $key 模板密钥
* @param $code 验证码
* @return array
*/
function juheSmsCode($phone,$tpl_id,$key,$code) {
$post['mobile'] = $phone;
$post['tpl_id'] = $tpl_id;
$tpl_value=urlencode("#code#={$code}");
$post['tpl_value'] = $tpl_value;
$post['key'] = $key;
$return = json_decode(curl_post(C("JUHE_SMSURL"),$post));
return $return;
}

@ -121,6 +121,7 @@ $config = array(
'PAY_DOMAIN' => 'https://api.wmtxkj.com/', 'PAY_DOMAIN' => 'https://api.wmtxkj.com/',
'H5_DOMAIN' => 'https://api.wmtxkj.com/', 'H5_DOMAIN' => 'https://api.wmtxkj.com/',
'DL_DOMAIN' => 'https://dl.wmtxkj.com/', 'DL_DOMAIN' => 'https://dl.wmtxkj.com/',
'JUHE_SMSURL' => 'http://v.juhe.cn/sms/send',
); );
return $config; return $config;
/* $pay = include(APP_PATH . "/Sdk/Conf/pay.php"); /* $pay = include(APP_PATH . "/Sdk/Conf/pay.php");

@ -2438,7 +2438,7 @@ class UserController extends BaseController
$this -> set_message(1086, "fail", "您的账户已经是成年账户,不能再修改成为未成年账户"); $this -> set_message(1086, "fail", "您的账户已经是成年账户,不能再修改成为未成年账户");
} }
//身份证认证 //身份证认证
if (C('tool_age.status') == 0) { if (C('tool_age.status') == 0&&C('juhe_age.status') == 0) {
if (is_adult($data['idcard'])) { if (is_adult($data['idcard'])) {
$data['age_status'] = 2; // 成年 $data['age_status'] = 2; // 成年
} else { } else {
@ -2492,6 +2492,11 @@ class UserController extends BaseController
case 2://未成年 case 2://未成年
$data['age_status'] = 3; $data['age_status'] = 3;
break; break;
case 3:
$log['remarks'] = '请求过于频繁,请稍后重试';
log_action($log);
$this -> set_message(1070, "fail", "请求过于频繁,请稍后重试");
break;
default: default:

Loading…
Cancel
Save