Merge remote-tracking branch 'origin/my_yuliao' into my_yuliao
This commit is contained in:
@@ -1068,9 +1068,14 @@ class Room extends Model
|
|||||||
db::name('vs_room_visitor')->where(['room_id' => $room_id, 'user_id' => $user_id])->delete();
|
db::name('vs_room_visitor')->where(['room_id' => $room_id, 'user_id' => $user_id])->delete();
|
||||||
//房间的模式
|
//房间的模式
|
||||||
$res = model('api/Room')->get_room_label($room_id);
|
$res = model('api/Room')->get_room_label($room_id);
|
||||||
|
if($res['code'] != 1){
|
||||||
|
$room_label = 1;
|
||||||
|
$room_type = 1;
|
||||||
|
}else{
|
||||||
$room_label = $res['data']['label_id'];
|
$room_label = $res['data']['label_id'];
|
||||||
$room_type = $res['data']['type_id'];
|
$room_type = $res['data']['type_id'];
|
||||||
|
}
|
||||||
|
|
||||||
$apply_type = 0;
|
$apply_type = 0;
|
||||||
if($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8)){
|
if($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8)){
|
||||||
$apply_type = 1;
|
$apply_type = 1;
|
||||||
|
|||||||
@@ -313,47 +313,56 @@ class UserData extends Model
|
|||||||
];
|
];
|
||||||
db::name('user_auth')->insert($auth);
|
db::name('user_auth')->insert($auth);
|
||||||
|
|
||||||
$config = get_system_config();
|
$res = $this->real_name_verify($real_name,$id_card);
|
||||||
//获取Access Token
|
if($res['code'] == 200){
|
||||||
$access_token = $this->redis->get('access_token_'.$config['tencent_app_id']);
|
//修改状态
|
||||||
//判断是否过期
|
db::name('user_auth')->where(['real_name' => $real_name,'card_id' => $id_card])->update(['is_real' => 1]);
|
||||||
if(empty($access_token)){
|
return ['code' => 1, 'msg' => '验证通过!','data' =>null];
|
||||||
$access_token = model('Tencent')->getAccessToken($config['tencent_app_id'],$config['tencent_app_secret']);
|
}else{
|
||||||
$this->redis->set('access_token_'.$config['tencent_app_id'],$access_token,1000);
|
return ['code' => 0, 'msg' => $res['msg'],'data' =>null];
|
||||||
sleep(1);
|
|
||||||
//获取SignTicket
|
|
||||||
$sign_ticket = model('Tencent')->getSignTicket($access_token,$config['tencent_app_id']);
|
|
||||||
$this->redis->set('sign_ticket_'.$config['tencent_app_id'],$sign_ticket,1100);
|
|
||||||
}
|
|
||||||
$sign_ticket = $this->redis->get('sign_ticket_'.$config['tencent_app_id']);
|
|
||||||
|
|
||||||
//获取NONCE Ticket
|
|
||||||
$nonce_ticket = model('Tencent')->getNonceTicket($access_token,$user_id,$config['tencent_app_id']);
|
|
||||||
//获取随机字符串
|
|
||||||
$nonceStr = generateRandom(32);
|
|
||||||
//生成一个订单号 并保存在redis
|
|
||||||
$orderNo = generateRandom(12);
|
|
||||||
//保存在redis
|
|
||||||
$this->redis->set('order_no_tencent_'.$user_id,$orderNo,3600);
|
|
||||||
//生成签名
|
|
||||||
$sign = model('Tencent')->getSign($user_id,$nonceStr,$sign_ticket,$config['tencent_app_id']);
|
|
||||||
//生成faceId
|
|
||||||
$faceId = model('Tencent')->getFaceId($orderNo,$real_name,$id_card,$sign,$user_id,$config['tencent_app_id'],$nonceStr);
|
|
||||||
if(isset($faceId['code'])){
|
|
||||||
return ['code' => 0, 'msg' => $faceId['msg'],'data' =>null];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
// $config = get_system_config();
|
||||||
'userid' => 'u'.$user_id,
|
// //获取Access Token
|
||||||
'nonce' => $nonceStr,
|
// $access_token = $this->redis->get('access_token_'.$config['tencent_app_id']);
|
||||||
'sign' => $sign,
|
// //判断是否过期
|
||||||
'appid' => $config['tencent_app_id'],
|
// if(empty($access_token)){
|
||||||
'orderNo' => $orderNo,
|
// $access_token = model('Tencent')->getAccessToken($config['tencent_app_id'],$config['tencent_app_secret']);
|
||||||
'apiVersion'=>'1.0.0',
|
// $this->redis->set('access_token_'.$config['tencent_app_id'],$access_token,1000);
|
||||||
'licence'=>$config['tencent_licence'],
|
// sleep(1);
|
||||||
'faceId' => $faceId
|
// //获取SignTicket
|
||||||
];
|
// $sign_ticket = model('Tencent')->getSignTicket($access_token,$config['tencent_app_id']);
|
||||||
return ['code' => 1, 'msg' => '获取成功','data' =>$data];
|
// $this->redis->set('sign_ticket_'.$config['tencent_app_id'],$sign_ticket,1100);
|
||||||
|
// }
|
||||||
|
// $sign_ticket = $this->redis->get('sign_ticket_'.$config['tencent_app_id']);
|
||||||
|
//
|
||||||
|
// //获取NONCE Ticket
|
||||||
|
// $nonce_ticket = model('Tencent')->getNonceTicket($access_token,$user_id,$config['tencent_app_id']);
|
||||||
|
// //获取随机字符串
|
||||||
|
// $nonceStr = generateRandom(32);
|
||||||
|
// //生成一个订单号 并保存在redis
|
||||||
|
// $orderNo = generateRandom(12);
|
||||||
|
// //保存在redis
|
||||||
|
// $this->redis->set('order_no_tencent_'.$user_id,$orderNo,3600);
|
||||||
|
// //生成签名
|
||||||
|
// $sign = model('Tencent')->getSign($user_id,$nonceStr,$sign_ticket,$config['tencent_app_id']);
|
||||||
|
// //生成faceId
|
||||||
|
// $faceId = model('Tencent')->getFaceId($orderNo,$real_name,$id_card,$sign,$user_id,$config['tencent_app_id'],$nonceStr);
|
||||||
|
// if(isset($faceId['code'])){
|
||||||
|
// return ['code' => 0, 'msg' => $faceId['msg'],'data' =>null];
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// $data = [
|
||||||
|
// 'userid' => 'u'.$user_id,
|
||||||
|
// 'nonce' => $nonceStr,
|
||||||
|
// 'sign' => $sign,
|
||||||
|
// 'appid' => $config['tencent_app_id'],
|
||||||
|
// 'orderNo' => $orderNo,
|
||||||
|
// 'apiVersion'=>'1.0.0',
|
||||||
|
// 'licence'=>$config['tencent_licence'],
|
||||||
|
// 'faceId' => $faceId
|
||||||
|
// ];
|
||||||
|
// return ['code' => 1, 'msg' => '获取成功','data' =>$data];
|
||||||
}
|
}
|
||||||
|
|
||||||
//实名认证结果
|
//实名认证结果
|
||||||
@@ -596,4 +605,71 @@ class UserData extends Model
|
|||||||
}
|
}
|
||||||
return ['code' => 1, 'msg' => '获取成功','data' =>$data];
|
return ['code' => 1, 'msg' => '获取成功','data' =>$data];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//身份证二要素认证
|
||||||
|
public function real_name_verify($real_name, $card_id)
|
||||||
|
{
|
||||||
|
// 云市场分配的密钥Id
|
||||||
|
$secretId = '1QMATmzeRHC7Auz8';
|
||||||
|
// 云市场分配的密钥Key
|
||||||
|
$secretKey = 'FKeTuxiKC76DrdPMAu4nhsppLZ1mI93l';
|
||||||
|
|
||||||
|
// 签名
|
||||||
|
$datetime = gmdate('D, d M Y H:i:s T');
|
||||||
|
$signStr = sprintf("x-date: %s", $datetime);
|
||||||
|
$sign = base64_encode(hash_hmac('sha1', $signStr, $secretKey, true));
|
||||||
|
$auth = sprintf('{"id": "%s", "x-date": "%s" , "signature": "%s"}', $secretId, $datetime, $sign);
|
||||||
|
|
||||||
|
// 请求方法
|
||||||
|
$method = 'GET';
|
||||||
|
// 请求头
|
||||||
|
$headers = array(
|
||||||
|
'Authorization' => $auth,
|
||||||
|
);
|
||||||
|
// 查询参数
|
||||||
|
$queryParams = array (
|
||||||
|
'cardNo' => $card_id,
|
||||||
|
'realName' => $real_name,
|
||||||
|
);
|
||||||
|
// body参数(POST方法下)
|
||||||
|
$bodyParams = array (
|
||||||
|
|
||||||
|
);
|
||||||
|
$sendData = http_build_query($bodyParams);
|
||||||
|
// url参数拼接
|
||||||
|
$url = 'https://ap-beijing.cloudmarket-apigw.com/service-hcgajsa5/idcard/VerifyIdcardv2';
|
||||||
|
if (count($queryParams) > 0) {
|
||||||
|
$url .= '?' . http_build_query($queryParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
|
||||||
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
|
||||||
|
if (in_array($method, array('POST', 'PUT', 'PATCH'), true)) {
|
||||||
|
$headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $sendData);
|
||||||
|
}
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array_map(function ($v, $k) {
|
||||||
|
return $k . ': ' . $v;
|
||||||
|
}, array_values($headers), array_keys($headers)));
|
||||||
|
|
||||||
|
// $data = json_decode(curl_exec($ch), true);
|
||||||
|
$result = curl_exec($ch);
|
||||||
|
if($result) {
|
||||||
|
$data = json_decode($result, true);
|
||||||
|
// var_dump($data);exit;
|
||||||
|
if ($data['error_code'] == 0) {
|
||||||
|
if ($data['result']['isok']) {
|
||||||
|
return ['code' => 200, 'msg' => '验证成功', 'data' => null];
|
||||||
|
} else {
|
||||||
|
return ['code' => 201, 'msg' => '信息有误' . json_encode($data), 'data' => null];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ['code' => 201, 'msg' => '信息有误' . json_encode($data), 'data' => null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ['code' => 201, 'msg' => '信息有误', 'data' => null];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user