|
@@ -7,6 +7,7 @@ use app\common\library\Ems;
|
|
use app\common\library\Sms;
|
|
use app\common\library\Sms;
|
|
use app\common\service\UserService;
|
|
use app\common\service\UserService;
|
|
use fast\Random;
|
|
use fast\Random;
|
|
|
|
+use think\Exception;
|
|
use think\Validate;
|
|
use think\Validate;
|
|
use miniprogram\wxBizDataCrypt;
|
|
use miniprogram\wxBizDataCrypt;
|
|
use onlogin\onlogin;
|
|
use onlogin\onlogin;
|
|
@@ -916,8 +917,8 @@ class User extends Api
|
|
public function realauth()
|
|
public function realauth()
|
|
{
|
|
{
|
|
try {
|
|
try {
|
|
- $realName = $this->request->param('real_name',0);
|
|
|
|
- $idCard = $this->request->param('id_card',0);
|
|
|
|
|
|
+ $realName = $this->request->param('real_name','');
|
|
|
|
+ $idCard = $this->request->param('id_card','');
|
|
if ($this->auth->is_auth == 2) {
|
|
if ($this->auth->is_auth == 2) {
|
|
$this->error('您已经真人认证过了~');
|
|
$this->error('您已经真人认证过了~');
|
|
}
|
|
}
|
|
@@ -927,16 +928,17 @@ class User extends Api
|
|
if (empty($idCard)) {
|
|
if (empty($idCard)) {
|
|
throw new Exception('请输入身份证号');
|
|
throw new Exception('请输入身份证号');
|
|
}
|
|
}
|
|
- $userService = new UserService();
|
|
|
|
|
|
+ /*$userService = new UserService();
|
|
$faceParams = [
|
|
$faceParams = [
|
|
'real_name' => $realName,
|
|
'real_name' => $realName,
|
|
'id_card' => $idCard,
|
|
'id_card' => $idCard,
|
|
|
|
+ 'user_id' => $this->auth->id,
|
|
];
|
|
];
|
|
- $res = $userService->faceAuth($faceParams);echo '<pre>';var_dump($res);exit;
|
|
|
|
|
|
+ $res = $userService->faceAuth($faceParams);
|
|
if (!$res['status']) {
|
|
if (!$res['status']) {
|
|
$this->error('您的网络开小差啦5~');
|
|
$this->error('您的网络开小差啦5~');
|
|
}
|
|
}
|
|
- $rs = json_decode($res['data'], true);
|
|
|
|
|
|
+ $rs = $res['data'];
|
|
if (!$rs || $rs['code'] != 0) {
|
|
if (!$rs || $rs['code'] != 0) {
|
|
$this->error('您的网络开小差啦6~');
|
|
$this->error('您的网络开小差啦6~');
|
|
}
|
|
}
|
|
@@ -945,13 +947,31 @@ class User extends Api
|
|
'user_id' => $this->auth->id,
|
|
'user_id' => $this->auth->id,
|
|
'realname' => $realName,
|
|
'realname' => $realName,
|
|
'idcard' => $idCard,
|
|
'idcard' => $idCard,
|
|
- 'certify_id' => $rs['result']['faceId'],
|
|
|
|
- 'out_trade_no' => $data['orderNo'],
|
|
|
|
|
|
+ 'certify_id' => isset($rs['result']['faceId']) ? $rs['result']['faceId'] : '',
|
|
|
|
+ 'out_trade_no' => isset($rs['result']['orderNo']) ? $rs['result']['orderNo'] : '',
|
|
|
|
+ 'status' => 0,
|
|
|
|
+ 'createtime' => time(),
|
|
|
|
+ 'updatetime' => time()
|
|
|
|
+ ];*/
|
|
|
|
+ $userService = new UserService();
|
|
|
|
+ $aliParams = [
|
|
|
|
+ 'id_card' => $idCard,
|
|
|
|
+ 'real_name' => $realName,
|
|
|
|
+ ];
|
|
|
|
+ $aliCheckRes = $userService->aliCheck($aliParams);
|
|
|
|
+ if (!$aliCheckRes['status']) {
|
|
|
|
+ throw new Exception($aliCheckRes['msg']);
|
|
|
|
+ }
|
|
|
|
+ $user_auth = [
|
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
|
+ 'realname' => $realName,
|
|
|
|
+ 'idcard' => $idCard,
|
|
|
|
+ 'certify_id' => '',
|
|
|
|
+ 'out_trade_no' => '',
|
|
'status' => 0,
|
|
'status' => 0,
|
|
'createtime' => time(),
|
|
'createtime' => time(),
|
|
'updatetime' => time()
|
|
'updatetime' => time()
|
|
];
|
|
];
|
|
-
|
|
|
|
//开启事务
|
|
//开启事务
|
|
Db::startTrans();
|
|
Db::startTrans();
|
|
//查询是否认证过
|
|
//查询是否认证过
|
|
@@ -966,22 +986,21 @@ class User extends Api
|
|
$this->error('您的网络开小差啦7~');
|
|
$this->error('您的网络开小差啦7~');
|
|
}
|
|
}
|
|
//修改用户表认证状态
|
|
//修改用户表认证状态
|
|
- $user_rs = Db::name('user')->where(['id' => $this->auth->id])->setField('real_status', 0);
|
|
|
|
|
|
+ $user_rs = Db::name('user')->where(['id' => $this->auth->id])->setField('is_auth', 2);
|
|
if ($user_rs === false) {
|
|
if ($user_rs === false) {
|
|
Db::rollback();
|
|
Db::rollback();
|
|
$this->error('您的网络开小差啦8~');
|
|
$this->error('您的网络开小差啦8~');
|
|
}
|
|
}
|
|
|
|
|
|
Db::commit();
|
|
Db::commit();
|
|
-
|
|
|
|
- $return_data = [
|
|
|
|
|
|
+ /*$return_data = [
|
|
'face_id' => $user_auth['certify_id'],
|
|
'face_id' => $user_auth['certify_id'],
|
|
'order_no' => $user_auth['out_trade_no'],
|
|
'order_no' => $user_auth['out_trade_no'],
|
|
'user_id' => (string)$this->auth->id,
|
|
'user_id' => (string)$this->auth->id,
|
|
- 'nonce' => $sign_data['nonce'],
|
|
|
|
- 'sign' => $sign
|
|
|
|
- ];
|
|
|
|
- $this->success('success', $return_data);
|
|
|
|
|
|
+ 'nonce' => $rs['nonce'],
|
|
|
|
+ 'sign' => $rs['sign'],
|
|
|
|
+ ];*/
|
|
|
|
+ $this->success('验证成功');
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
$this->error($e->getMessage());
|
|
$this->error($e->getMessage());
|
|
}
|
|
}
|
|
@@ -999,9 +1018,11 @@ class User extends Api
|
|
if (!$user_auth['certify_id']) {
|
|
if (!$user_auth['certify_id']) {
|
|
$this->success('请先进行真人认证');
|
|
$this->success('请先进行真人认证');
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ $tencentConfig = config('tencent_yun');
|
|
|
|
+ $sercrtId = isset($tencentConfig['SecretId']) ? $tencentConfig['SecretId'] : '';
|
|
|
|
+ $sercrtKey = isset($tencentConfig['SecretKey']) ? $tencentConfig['SecretKey'] : '';
|
|
//获取token
|
|
//获取token
|
|
- $token_url = 'https://miniprogram-kyc.tencentcloudapi.com/api/oauth2/access_token?app_id='.config('tencent_yun')['secret_id'].'&secret='.config('tencent_yun')['secret_key'].'&grant_type=client_credential&version=1.0.0';
|
|
|
|
|
|
+ $token_url = 'https://miniprogram-kyc.tencentcloudapi.com/api/oauth2/access_token?app_id='.$sercrtId.'&secret='.$sercrtKey.'&grant_type=client_credential&version=1.0.0';
|
|
$token_result = file_get_contents($token_url);
|
|
$token_result = file_get_contents($token_url);
|
|
if (!$token_result) {
|
|
if (!$token_result) {
|
|
$this->error('您的网络开小差啦1~');
|
|
$this->error('您的网络开小差啦1~');
|
|
@@ -1013,7 +1034,7 @@ class User extends Api
|
|
$token = $token_result['access_token'];
|
|
$token = $token_result['access_token'];
|
|
|
|
|
|
//获取签名鉴权参数ticket
|
|
//获取签名鉴权参数ticket
|
|
- $ticket_url = 'https://miniprogram-kyc.tencentcloudapi.com/api/oauth2/api_ticket?app_id='.config('tencent_yun')['secret_id'].'&access_token='.$token.'&type=SIGN&version=1.0.0';
|
|
|
|
|
|
+ $ticket_url = 'https://miniprogram-kyc.tencentcloudapi.com/api/oauth2/api_ticket?app_id='.$sercrtId.'&access_token='.$token.'&type=SIGN&version=1.0.0';
|
|
$ticket_result = file_get_contents($ticket_url);
|
|
$ticket_result = file_get_contents($ticket_url);
|
|
if (!$ticket_result) {
|
|
if (!$ticket_result) {
|
|
$this->error('您的网络开小差啦3~');
|
|
$this->error('您的网络开小差啦3~');
|
|
@@ -1026,7 +1047,7 @@ class User extends Api
|
|
|
|
|
|
//获取签名
|
|
//获取签名
|
|
$sign_data = [
|
|
$sign_data = [
|
|
- 'wbappid' => config('tencent_yun')['secret_id'],
|
|
|
|
|
|
+ 'wbappid' => $sercrtId,
|
|
'orderNo' => $user_auth['out_trade_no'],
|
|
'orderNo' => $user_auth['out_trade_no'],
|
|
'version' => '1.0.0',
|
|
'version' => '1.0.0',
|
|
'ticket' => $ticket,
|
|
'ticket' => $ticket,
|
|
@@ -1039,7 +1060,7 @@ class User extends Api
|
|
//人脸核身结果查询
|
|
//人脸核身结果查询
|
|
$url = 'https://miniprogram-kyc.tencentcloudapi.com/api/v2/base/queryfacerecord?orderNo=' . $user_auth['out_trade_no'];
|
|
$url = 'https://miniprogram-kyc.tencentcloudapi.com/api/v2/base/queryfacerecord?orderNo=' . $user_auth['out_trade_no'];
|
|
$data = [
|
|
$data = [
|
|
- 'appId' => config('tencent_yun')['secret_id'],
|
|
|
|
|
|
+ 'appId' => $sercrtId,
|
|
'version' => '1.0.0',
|
|
'version' => '1.0.0',
|
|
'nonce' => $sign_data['nonce'],
|
|
'nonce' => $sign_data['nonce'],
|
|
'orderNo' => $user_auth['out_trade_no'],
|
|
'orderNo' => $user_auth['out_trade_no'],
|
|
@@ -1055,10 +1076,10 @@ class User extends Api
|
|
$this->error($rs['msg']);
|
|
$this->error($rs['msg']);
|
|
}
|
|
}
|
|
if ($rs['result']['liveRate'] >= 90 && $rs['result']['similarity'] >= 90) {
|
|
if ($rs['result']['liveRate'] >= 90 && $rs['result']['similarity'] >= 90) {
|
|
- $edit_data['status'] = 1;
|
|
|
|
|
|
+ $edit_data['status'] = 2;
|
|
$msg = '真人认证成功';
|
|
$msg = '真人认证成功';
|
|
} else {
|
|
} else {
|
|
- $edit_data['status'] = 2;
|
|
|
|
|
|
+ $edit_data['status'] = -1;
|
|
$edit_data['certify_id'] = '';
|
|
$edit_data['certify_id'] = '';
|
|
$edit_data['out_trade_no'] = '';
|
|
$edit_data['out_trade_no'] = '';
|
|
$msg = '真人认证失败';
|
|
$msg = '真人认证失败';
|
|
@@ -1074,19 +1095,19 @@ class User extends Api
|
|
$this->error('查询认证结果失败2');
|
|
$this->error('查询认证结果失败2');
|
|
}
|
|
}
|
|
//修改用户信息
|
|
//修改用户信息
|
|
- $rs = Db::name('user')->where(['id' => $this->auth->id])->setField('real_status', $edit_data['status']);
|
|
|
|
|
|
+ $rs = Db::name('user')->where(['id' => $this->auth->id])->setField('is_auth', $edit_data['status']);
|
|
if (!$rs) {
|
|
if (!$rs) {
|
|
Db::rollback();
|
|
Db::rollback();
|
|
$this->error('查询认证结果失败3');
|
|
$this->error('查询认证结果失败3');
|
|
}
|
|
}
|
|
- if ($edit_data['status'] == 1) { //通过
|
|
|
|
|
|
+ if ($edit_data['status'] == 2) { //通过
|
|
//tag任务赠送金币
|
|
//tag任务赠送金币
|
|
//真人认证奖励
|
|
//真人认证奖励
|
|
- $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,20);
|
|
|
|
|
|
+ /*$task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,20);
|
|
if($task_rs === false){
|
|
if($task_rs === false){
|
|
Db::rollback();
|
|
Db::rollback();
|
|
$this->error('完成任务赠送奖励失败');
|
|
$this->error('完成任务赠送奖励失败');
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
//系统消息
|
|
//系统消息
|
|
$msg_id = \app\common\model\Message::addMessage($this->auth->id,'真人认证','真人认证已经审核通过');
|
|
$msg_id = \app\common\model\Message::addMessage($this->auth->id,'真人认证','真人认证已经审核通过');
|
|
} else {
|
|
} else {
|