Merge branch 'feature/juhe_sms' of wmtx/sdk into master

添加身份认证与新的短信接口
master
郑永星 5 years ago committed by Gogs
commit fd11837e34

@ -1180,7 +1180,11 @@ function think_psw_md5($str, $key = 'ThinkUCenter')
function age_verify($cardno, $name, $user_id = '')
{
$info = '';
$date = age($cardno, $name, $info);
if (C('tool_age.status')==1) {
$date = age($cardno, $name, $info);
} else if(C('juhe_age.status')==1){
$date = juhedataAge($cardno, $name, C('juhe_age.appkey'));
}
$arr['name'] = $name;
$arr['id_card'] = $cardno;
@ -1206,6 +1210,26 @@ function age_verify($cardno, $name, $user_id = '')
$arr['status'] = 0;
M('idcard_log', 'tab_')->data($arr)->add();
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'] == 210304){
$arr['status'] = 0;
M('idcard_log', 'tab_')->data($arr)->add();
return 3;
} else {
$arr['status'] = -1;
M('idcard_log', 'tab_')->data($arr)->add();
@ -1251,6 +1275,20 @@ function age($cardno, $name, &$info)
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) {
$host = "https://idcardcert.market.alicloudapi.com";
$path = "/idCardCert";
@ -1433,3 +1471,56 @@ function curl_post($url = '', $post_data = array()) {
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']];
}
} 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'=>'没有配置短信发送'];

@ -384,4 +384,24 @@ function getIpForbitWhiteList($user_id) {
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}&#m#=10");
$post['tpl_value'] = $tpl_value;
$post['key'] = $key;
$return = json_decode(curl_post(C("JUHE_SMSURL"),$post),true);
return $return;
}

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

@ -9,7 +9,13 @@ use Org\YeepaySDK\Yeepay;
use Sdk\Model\PayLimitConfModel;
use Sdk\Model\PayChannelIntentionModel;
class ShortcutController extends BaseController{
// public function test() {
//
// dump(juheSmsCode('13067381027',C('juhedata.tpl_id'),C('juhedata.key'),'123456'));
//
// }
// 签约处理
public function sign_contract() {

@ -2438,7 +2438,7 @@ class UserController extends BaseController
$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'])) {
$data['age_status'] = 2; // 成年
} else {
@ -2448,7 +2448,7 @@ class UserController extends BaseController
$model = M('idcard_log', 'tab_')->where(['name' => $data['real_name'],'id_card' => $data['idcard']])->order('id DESC')->find();
if(!empty($model) && $model['status'] != '-1') {
$arr['num'] = $model['num']+1;
M('idcard_log', 'tab_')->where(['id' => $model['id']])->save($arr);
if($model['status'] == 1) {
$data['age_status'] = is_adult($data['idcard']) ? 2 : 3;
@ -2492,6 +2492,11 @@ class UserController extends BaseController
case 2://未成年
$data['age_status'] = 3;
break;
case 3:
$log['remarks'] = '请求过于频繁,请稍后重试';
log_action($log);
$this -> set_message(1070, "fail", "请求过于频繁,请稍后重试");
break;
default:

Loading…
Cancel
Save