chore: 重写初始提交(清空历史,整理后全量提交)
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2026-2036 http://ywxapp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: ywxapp<admin@ywxapp.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace addon\wxchat\controller\member;
|
||||
|
||||
use addon\wxchat\model\WxchatRealnameAuth;
|
||||
use think\facade\Request;
|
||||
use ywxapp\controller\FrontendBase;
|
||||
|
||||
/**
|
||||
* 真人认证:多重认证 + AI 智能审核 + 人工复审
|
||||
*/
|
||||
class Auth extends FrontendBase
|
||||
{
|
||||
/**
|
||||
* 提交认证资料
|
||||
*/
|
||||
public function submit()
|
||||
{
|
||||
$uid = $this->auth->uid;
|
||||
$realName = trim((string) Request::post('real_name', ''));
|
||||
$idCard = trim((string) Request::post('id_card', ''));
|
||||
$frontImg = trim((string) Request::post('front_img', ''));
|
||||
$backImg = trim((string) Request::post('back_img', ''));
|
||||
$holdImg = trim((string) Request::post('hold_img', ''));
|
||||
$faceImg = trim((string) Request::post('face_img', ''));
|
||||
|
||||
if (! $realName || strlen($idCard) < 15) {
|
||||
$this->error('请填写真实姓名与证件号');
|
||||
}
|
||||
|
||||
// 证件号脱敏存储(保留前4后4)
|
||||
$masked = substr($idCard, 0, 4) . str_repeat('*', max(0, strlen($idCard) - 8)) . substr($idCard, -4);
|
||||
|
||||
$data = [
|
||||
'uid' => $uid,
|
||||
'real_name' => $realName,
|
||||
'id_card' => $masked,
|
||||
'front_img' => $frontImg,
|
||||
'back_img' => $backImg,
|
||||
'hold_img' => $holdImg,
|
||||
'face_img' => $faceImg,
|
||||
'status' => 0,
|
||||
'ai_result' => 0,
|
||||
'ai_score' => 0,
|
||||
'reject_reason' => '',
|
||||
'update_at' => time(),
|
||||
];
|
||||
|
||||
$exist = WxchatRealnameAuth::where('uid', $uid)->find();
|
||||
if ($exist) {
|
||||
$exist->save($data);
|
||||
} else {
|
||||
$data['create_at'] = time();
|
||||
(new WxchatRealnameAuth())->save($data);
|
||||
}
|
||||
|
||||
// 触发 AI 智能审核
|
||||
$this->aiCheck($uid);
|
||||
|
||||
$this->success([], '已提交,审核中');
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的认证状态(补充 AI 审核详情)
|
||||
*/
|
||||
public function status()
|
||||
{
|
||||
$uid = $this->auth->uid;
|
||||
$auth = WxchatRealnameAuth::where('uid', $uid)->find();
|
||||
$this->success([
|
||||
'status' => $auth ? (int) $auth->status : -1,
|
||||
'ai_result' => $auth ? (int) $auth->ai_result : 0,
|
||||
'ai_score' => $auth ? (float) $auth->ai_score : 0,
|
||||
'ai_detail' => $auth ? ($auth->ai_detail ?? '') : '',
|
||||
'reject_reason' => $auth ? $auth->reject_reason : '',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* AI 智能审核(接入 AiAuditService:本地启发式 / 真实 HTTP 服务,可配置切换)
|
||||
*/
|
||||
private function aiCheck($uid)
|
||||
{
|
||||
$auth = WxchatRealnameAuth::where('uid', $uid)->find();
|
||||
if (! $auth) {
|
||||
return;
|
||||
}
|
||||
$result = \addon\wxchat\service\AiAuditService::audit([
|
||||
'uid' => $uid,
|
||||
'real_name' => $auth->real_name,
|
||||
'id_card' => $auth->id_card,
|
||||
'front_img' => $auth->front_img,
|
||||
'back_img' => $auth->back_img,
|
||||
'hold_img' => $auth->hold_img,
|
||||
'face_img' => $auth->face_img,
|
||||
]);
|
||||
$auth->ai_score = $result['score'];
|
||||
$auth->ai_result = $result['result']; // 1-通过初筛 2-不通过
|
||||
$auth->ai_detail = $result['detail'] ?? '';
|
||||
$auth->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* 人工复审(后台调用,建议加管理员鉴权)
|
||||
*/
|
||||
public function review()
|
||||
{
|
||||
$id = (int) Request::post('id', 0);
|
||||
$pass = (int) Request::post('pass', 0);
|
||||
$reason = trim((string) Request::post('reason', ''));
|
||||
$auth = WxchatRealnameAuth::find($id);
|
||||
if (! $auth) {
|
||||
$this->error('记录不存在');
|
||||
}
|
||||
$auth->status = $pass ? 1 : 2;
|
||||
$auth->reject_reason = $pass ? '' : $reason;
|
||||
$auth->reviewer_id = $this->auth->uid ?? 0;
|
||||
$auth->review_at = time();
|
||||
$auth->save();
|
||||
|
||||
// 审核通过 -> 标记资料真人认证
|
||||
if ($pass) {
|
||||
\ywxapp\model\MemberProfile::where('uid', $auth->uid)
|
||||
->update(['is_realname' => 1]);
|
||||
}
|
||||
$this->success([], $pass ? '已通过' : '已驳回');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user