lizhen_gitee hace 1 año
padre
commit
c7acc9d5d9

+ 54 - 3
application/api/controller/Userauth.php

@@ -16,13 +16,13 @@ class Userauth extends Api
 
 
     //实名认证信息
-    public function idcard_info(){
+    public function userauth_info(){
         $check = Db::name('user_auth')->where('user_id',$this->auth->id)->order('id desc')->find();
         $this->success('success',$check);
     }
 
     //申请实名认证
-    public function apply_idcard_confirm(){
+    public function apply_userauth(){
         $truename = input('truename','');
         $idcard   = input('idcard'  ,'');
 
@@ -72,7 +72,7 @@ class Userauth extends Api
         }
 
         //阿里云身份证三要素认证
-        $auth_restult = $this->userauth_aliyun_three($idcard, $truename,$this->auth->mobile);
+        $auth_restult = $this->userauth_aliyun_two($idcard, $truename);
         if($auth_restult == false){
             $this->error('身份证信息与姓名或注册手机号不符');
         }
@@ -114,6 +114,57 @@ class Userauth extends Api
 
     }
 
+    //产品链接:https://market.aliyun.com/products/57000002/cmapi026109.html#sku=yuncode20109000025
+    //阿里云-数脉api
+    //姓名+身份证号
+    private function userauth_aliyun_two($cardNo = '',$realname = ''){
+        if(!$cardNo || !$realname){
+            return false;
+        }
+
+        $config = config('aliyun_auth_shumai_two');
+
+        $host = "https://eid.shumaidata.com";
+        $path = "/eid/check";
+        $method = "POST";
+        $appcode = $config['app_code'];
+        $headers = array();
+        array_push($headers, "Authorization:APPCODE " . $appcode);
+
+        $querys = "idcard=".$cardNo."&name=".urlencode($realname);
+        $bodys  = '';
+        $url = $host . $path . "?" . $querys;
+
+        $curl = curl_init();
+        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
+        curl_setopt($curl, CURLOPT_URL, $url);
+        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
+        curl_setopt($curl, CURLOPT_FAILONERROR, false);
+        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+        //设定返回信息中是否包含响应信息头,启用时会将头文件的信息作为数据流输出,true 表示输出信息头, false表示不输出信息头
+        //如果需要将字符串转成json,请将 CURLOPT_HEADER 设置成 false
+        curl_setopt($curl, CURLOPT_HEADER, false);
+        if (1 == strpos("$".$host, "https://"))
+        {
+            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
+            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
+        }
+        $returnRes = curl_exec($curl);
+        //var_dump($returnRes);
+        curl_close($curl);
+        $result = json_decode($returnRes,true);
+        //dump($result);
+
+        if(is_array($result) && isset($result['code']) && $result['code'] == 0){
+            if(isset($result['result']) && isset($result['result']['res'])){
+                if($result['result']['res'] == 1){
+                    //实名过了
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
     //产品链接:https://market.aliyun.com/products/57000002/cmapi026100.html?spm=5176.730005.result.8.1dbc123e8ArY19&innerSource=search#sku=yuncode2010000006
     //阿里云-数脉api
     //姓名+手机号+身份证号

+ 5 - 2
application/common/model/Message.php

@@ -19,7 +19,7 @@ class Message extends Model
     /**
      * 添加系统消息
      */
-    public static function addMessage($user_id,$title,$content) {
+    public static function addMessage($user_id,$title,$content,$infotype = '',$infotype_id = 0) {
         if(!$user_id || !$title || !$content) {
             return false;
         }
@@ -28,7 +28,10 @@ class Message extends Model
         $data["title"] = $title;
         $data["content"] = $content;
         $data["createtime"] = time();
-        return self::insert($data);
+        $data["status"] = 0;
+        $data["infotype"] = $infotype;
+        $data["infotype_id"] = $infotype_id;
+        return self::insertGetId($data);
     }
 
 }

+ 5 - 5
application/config.php

@@ -389,11 +389,11 @@ return [
     ],
     'pay_test' => 0,//支付测试:0=正常,1=支付0.01
 
-    //阿里云实名认证要素,正式数脉
-    'aliyun_auth_shumai' => [
-        'app_key'    => '204165018',
-        'app_secret' => 'owfeQdhvhzq988fC4iOz2YjnSGOk7sFX',
-        'app_code'   => '70754381570645739ce7bfb56268a483',
+    //阿里云实名认证要素,正式数脉
+    'aliyun_auth_shumai_two' => [
+        'app_key'    => '204475388',
+        'app_secret' => 'cpcuFvHRRqeI9sCnTwjYMwUi9Iv5aHhE',
+        'app_code'   => 'f198eb0d295b4849b1946d3619c25ede',
     ],
 
     //app接口加密