增加了实名认证的日志记录、暂时去除了网易易盾环境的区分
This commit is contained in:
parent
43876a9d57
commit
3f9d065d7e
83
app/Model/LogIdCard.php
Normal file
83
app/Model/LogIdCard.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $log_id 主键id
|
||||
* @property string $name 姓名
|
||||
* @property string $card_no 身份证号
|
||||
* @property int $status 认证结果,1-通过 2-不通过(原因见reasonType) 0-待定
|
||||
* @property string $data_id 用户侧唯一标识
|
||||
* @property string $task_id 服务侧唯一标识
|
||||
* @property string $content 返回内容,json格式
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class LogIdCard extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'log_id_card';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['log_id', 'name', 'card_no', 'status', 'data_id', 'task_id', 'content', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "log_id";
|
||||
|
||||
/**
|
||||
* 获取数据-单
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据-多
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params = [], array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param array $params
|
||||
* @param array $data
|
||||
* @return int
|
||||
*/
|
||||
public static function edit(array $params = [], array $data = []): int
|
||||
{
|
||||
return self::where($params)->update($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return LogIdCard|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addLogIdCard(array $data): LogIdCard|\Hyperf\Database\Model\Model
|
||||
{
|
||||
return self::create($data);
|
||||
}
|
||||
|
||||
}
|
||||
@ -122,12 +122,13 @@ class DoctorAuthService extends BaseService
|
||||
// 网易易盾认证
|
||||
// 实人认证-生产环境开启
|
||||
$app_env = config('app_env','dev');
|
||||
if ($app_env != "dev"){
|
||||
if ($app_env == "dev"){
|
||||
$IdCard = new IdCard();
|
||||
|
||||
$params = array();
|
||||
$params['name'] = $card_name;
|
||||
$params['cardNo'] = $card_num;
|
||||
$params['dataId'] = $doctor['user_id'];
|
||||
$res = $IdCard->checkIdCard($params);
|
||||
if (!empty($res)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, $res);
|
||||
|
||||
@ -174,15 +174,14 @@ class PatientFamilyService extends BaseService
|
||||
}
|
||||
|
||||
// 实人认证-生产环境开启
|
||||
|
||||
|
||||
$app_env = config('app_env', 'dev');
|
||||
if ($app_env != "dev") {
|
||||
if ($app_env == "dev") {
|
||||
$IdCard = new IdCard();
|
||||
|
||||
$params = array();
|
||||
$params['name'] = $request_params['card_name'];
|
||||
$params['cardNo'] = $request_params['id_number'];
|
||||
$params['dataId'] = $user_info['user_id'];
|
||||
$res = $IdCard->checkIdCard($params);
|
||||
if (!empty($res)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, $res);
|
||||
|
||||
@ -4,6 +4,7 @@ namespace Extend\VerifyDun;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\LogIdCard;
|
||||
use App\Utils\HttpRequest;
|
||||
use App\Utils\Log;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
@ -35,6 +36,10 @@ class IdCard extends Base
|
||||
$this->options["form_params"] = $this->params;
|
||||
|
||||
$result = $this->httpRuest->postRequest($api_url,$this->options);
|
||||
|
||||
// 记录日志,ca认证要求
|
||||
Log::getInstance("VerifyDun-IdCard-checkIdCard")->info(json_encode($result,JSON_UNESCAPED_UNICODE));
|
||||
|
||||
if (empty($result)){
|
||||
return "身份证认证失败";
|
||||
}
|
||||
@ -50,22 +55,21 @@ class IdCard extends Base
|
||||
return "身份证认证失败";
|
||||
}
|
||||
|
||||
// 记录日志
|
||||
$this->recordLog($params['dataId'],$params['name'],$params['cardNo'],$result);
|
||||
|
||||
// 处理不通过情况
|
||||
if ($result['result']['status'] == 2){
|
||||
switch ($result['result']['reasonType']) {
|
||||
case 2:
|
||||
return "输入姓名和身份证号不一致";
|
||||
break;
|
||||
case 3:
|
||||
return "查无此身份证";
|
||||
break;
|
||||
case 4:
|
||||
return "身份证照片信息与输入信息不一致";
|
||||
break;
|
||||
|
||||
default:
|
||||
return "身份证认证失败";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,4 +83,28 @@ class IdCard extends Base
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录日志
|
||||
* @param string $data_id
|
||||
* @param string $name
|
||||
* @param string $card_no
|
||||
* @param array $result
|
||||
* @return void
|
||||
*/
|
||||
public function recordLog(string $data_id,string $name,string $card_no,array $result): void
|
||||
{
|
||||
try {
|
||||
$data = array();
|
||||
$data['name'] = $name;
|
||||
$data['card_no'] = $card_no;
|
||||
$data['status'] = $result['result']['status'];
|
||||
$data['data_id'] = $data_id;
|
||||
$data['task_id'] = $result['result']['taskId'];
|
||||
$data['content'] = json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
LogIdCard::addLogIdCard($data);
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("VerifyDun-IdCard-checkIdCard")->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user