From f273f58c906a4e0c65551c12da5b01c5a7a24cd0 Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Thu, 14 May 2020 14:59:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BA=AB=E4=BB=BD=E8=AE=A4=E8=AF=81=E5=8F=8A?= =?UTF-8?q?=E6=96=B0=E7=9F=AD=E4=BF=A1=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Common/Common/function.php | 93 ++++++++++++++++++- .../Common/Controller/SmsController.class.php | 10 +- Application/Sdk/Common/function.php | 20 ++++ Application/Sdk/Conf/config.php | 1 + .../Sdk/Controller/UserController.class.php | 9 +- 5 files changed, 129 insertions(+), 4 deletions(-) diff --git a/Application/Common/Common/function.php b/Application/Common/Common/function.php index 34dbacc4..f048b9ed 100644 --- a/Application/Common/Common/function.php +++ b/Application/Common/Common/function.php @@ -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'] != 0){ + $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
      + 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; +} \ No newline at end of file diff --git a/Application/Common/Controller/SmsController.class.php b/Application/Common/Controller/SmsController.class.php index d6cb38bd..7c31bda4 100644 --- a/Application/Common/Controller/SmsController.class.php +++ b/Application/Common/Controller/SmsController.class.php @@ -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'=>'没有配置短信发送']; diff --git a/Application/Sdk/Common/function.php b/Application/Sdk/Common/function.php index b8a89ff7..89263c2d 100644 --- a/Application/Sdk/Common/function.php +++ b/Application/Sdk/Common/function.php @@ -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}"); + $post['tpl_value'] = $tpl_value; + $post['key'] = $key; + + $return = json_decode(curl_post(C("JUHE_SMSURL"),$post)); + + return $return; } \ No newline at end of file diff --git a/Application/Sdk/Conf/config.php b/Application/Sdk/Conf/config.php index aefa3ae7..6ed72831 100644 --- a/Application/Sdk/Conf/config.php +++ b/Application/Sdk/Conf/config.php @@ -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"); diff --git a/Application/Sdk/Controller/UserController.class.php b/Application/Sdk/Controller/UserController.class.php index abfa7e54..a3ad8ea9 100644 --- a/Application/Sdk/Controller/UserController.class.php +++ b/Application/Sdk/Controller/UserController.class.php @@ -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: