feat: 新增账号安全模块及资质校验功能
- 新增账号安全页面及支付密码验证组件 - 新增用户类型选择流程及商家资质管理 - 新增订单资质校验逻辑,师傅需满足订单证书要求 - 新增企业资质认证相关数据库表及接口 - 优化用户列表展示,区分个人与商家用户类型
这个提交包含在:
@@ -80,7 +80,7 @@ class Home extends Backend
|
||||
|
||||
// 4. 实时待办预警与风控中心(6大核心运营待办)
|
||||
$pendingMaster = Master::where('verify_status', 'pending')->count();
|
||||
$pendingMerchant = Merchant::where('verify_status', 'pending')->count();
|
||||
$pendingMerchant = Db::name('user_enterprise_cert')->where('verify_status', 'pending')->count();
|
||||
$waitingAppeal = Appeal::where('status', 'wait')->count();
|
||||
$waitingWithdraw = Withdraw::where('status', 'wait')->count();
|
||||
$waitingInvoice = Db::name('invoice')->where('status', 'wait')->count();
|
||||
|
||||
@@ -144,7 +144,7 @@ class MasterCert extends Backend
|
||||
? "技能证书审核通过({$certName})"
|
||||
: "技能证书审核未通过({$certName})";
|
||||
$msgContent = $status === 'pass'
|
||||
? "您上传的「{$certName}」已通过平台审核,可正常承接对应资质要求的工单。"
|
||||
? "您上传的「{$certName}」已通过平台审核,有效期内可向相关订单用户展示。"
|
||||
: ("您上传的「{$certName}」未通过审核,原因:" . ($auditMsg !== '' ? $auditMsg : '照片不清晰或证件不符合要求,请重新上传。'));
|
||||
|
||||
Db::name('message')->insert([
|
||||
|
||||
@@ -30,12 +30,68 @@ class Merchant extends Backend
|
||||
$this->view->assign("verifyStatusList", $this->model->getVerifyStatusList());
|
||||
}
|
||||
|
||||
/** 独立展示用户提交的企业资质;审核接口沿用原权限。 */
|
||||
public function certificates()
|
||||
{
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->request->filter(['strip_tags', 'trim']);
|
||||
if (false === $this->request->isAjax()) {
|
||||
return $this->view->fetch();
|
||||
}
|
||||
if ($this->request->isPost() && $this->request->post('view') === 'audit_cert') {
|
||||
if (!$this->auth->check('merchant/edit')) $this->error('无权审核企业资质');
|
||||
$this->token();
|
||||
$id = (int)$this->request->post('id');
|
||||
$decision = (string)$this->request->post('decision', '');
|
||||
$reason = trim((string)$this->request->post('audit_msg', ''));
|
||||
if (!in_array($decision, ['pass', 'reject'], true)) $this->error('审核状态无效');
|
||||
if ($decision === 'reject' && $reason === '') $this->error('请输入驳回原因');
|
||||
if (mb_strlen($reason) > 500) $this->error('驳回原因过长');
|
||||
$updated = Db::name('user_enterprise_cert')->where('id', $id)->where('verify_status', 'pending')->update([
|
||||
'verify_status' => $decision, 'audit_msg' => $decision === 'reject' ? $reason : '', 'updatetime' => time(),
|
||||
]);
|
||||
if (!$updated) $this->error('申请不存在或已处理,请刷新');
|
||||
$this->success('审核完成');
|
||||
}
|
||||
if ($this->request->get('view') === 'certs') {
|
||||
$offset = max(0, (int)$this->request->get('offset', 0));
|
||||
$limit = min(100, max(1, (int)$this->request->get('limit', 20)));
|
||||
$search = trim((string)$this->request->get('search', ''));
|
||||
$makeQuery = function () use ($search) {
|
||||
$query = Db::name('user_enterprise_cert')->alias('c')->join('user u', 'u.id = c.user_id', 'LEFT');
|
||||
if ($search !== '') $query->where(function ($q) use ($search) {
|
||||
$q->where('c.company_name', 'like', '%' . $search . '%')->whereOr('c.license_no', 'like', '%' . $search . '%')->whereOr('u.mobile', 'like', '%' . $search . '%');
|
||||
});
|
||||
return $query;
|
||||
};
|
||||
$total = $makeQuery()->count();
|
||||
$rows = $makeQuery()->field('c.*,u.nickname,u.mobile,u.user_type')->order('c.id', 'desc')->limit($offset, $limit)->select();
|
||||
foreach ($rows as &$row) $row['license_url'] = cdnurl($row['license_image'], true);
|
||||
unset($row);
|
||||
return json(['total' => $total, 'rows' => $rows]);
|
||||
}
|
||||
if ($this->request->get('view') === 'accounts') {
|
||||
$offset = max(0, (int)$this->request->get('offset', 0));
|
||||
$limit = min(100, max(1, (int)$this->request->get('limit', 20)));
|
||||
$search = trim((string)$this->request->get('search', ''));
|
||||
$makeQuery = function () use ($search) {
|
||||
$query = Db::name('user')->where('user_type', 'merchant')->where('identity_selected', 1);
|
||||
if ($search !== '') $query->where(function ($q) use ($search) {
|
||||
$q->where('nickname', 'like', '%' . $search . '%')
|
||||
->whereOr('mobile', 'like', '%' . $search . '%')
|
||||
->whereOr('company_name', 'like', '%' . $search . '%');
|
||||
});
|
||||
return $query;
|
||||
};
|
||||
$total = $makeQuery()->count();
|
||||
$rows = $makeQuery()->field('id,nickname,mobile,company_name,company_legal_person,company_legal_mobile,company_tech_mobile,createtime')
|
||||
->order('id', 'desc')->limit($offset, $limit)->select();
|
||||
return json(['total' => $total, 'rows' => $rows]);
|
||||
}
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
|
||||
@@ -445,6 +445,9 @@ class Order extends Backend
|
||||
if (!$targetMaster || $targetMaster['verify_status'] !== 'pass') {
|
||||
$this->error('所选师傅不存在或未通过实名认证');
|
||||
}
|
||||
if (!\app\common\library\OrderQualification::forMaster($row['qual_req'] ?? '', $masterId)) {
|
||||
$this->error('所选师傅未持有符合订单要求的有效认证证书:' . $row['qual_req']);
|
||||
}
|
||||
$oldMasterId = (int)$row['master_id'];
|
||||
if ($oldMasterId === $masterId && (int)$row['status'] >= 3) {
|
||||
$this->error('当前工单已由该师傅承接,无需重复指派');
|
||||
|
||||
@@ -39,11 +39,13 @@ class User extends Backend
|
||||
return $this->selectpage();
|
||||
}
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$list = $this->model
|
||||
->with('group')
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
$filters = json_decode((string)$this->request->get('filter', '{}'), true);
|
||||
$selectedType = is_array($filters) ? ($filters['user_type'] ?? null) : null;
|
||||
$query = $this->model->with('group')->where($where);
|
||||
if (in_array($selectedType, ['personal', 'merchant'], true)) {
|
||||
$query->where('user.identity_selected', 1);
|
||||
}
|
||||
$list = $query->order($sort, $order)->paginate($limit);
|
||||
|
||||
$rows = $list->items();
|
||||
$uids = array_column($rows, 'id');
|
||||
@@ -103,6 +105,13 @@ class User extends Backend
|
||||
$v->hidden(['password', 'salt']);
|
||||
|
||||
$roles = [];
|
||||
if (!(int)$v['identity_selected']) {
|
||||
$roles[] = ['type' => 'unselected', 'label' => '待选择用户类型'];
|
||||
} elseif ($v['user_type'] === 'merchant') {
|
||||
$roles[] = ['type' => 'merchant_user', 'label' => '商家用户'];
|
||||
} else {
|
||||
$roles[] = ['type' => 'owner', 'label' => '个人用户'];
|
||||
}
|
||||
if (isset($masterMap[$uid]) && $masterMap[$uid]['verify_status'] === 'pass') {
|
||||
$roles[] = ['type' => 'master', 'label' => '认证师傅 (' . $masterMap[$uid]['realname'] . ')'];
|
||||
}
|
||||
@@ -111,10 +120,6 @@ class User extends Backend
|
||||
} elseif (isset($memberMap[$uid]) && !empty($memberMap[$uid])) {
|
||||
$roles[] = ['type' => 'member', 'label' => '企业子账号 (' . $memberMap[$uid] . ')'];
|
||||
}
|
||||
if (empty($roles)) {
|
||||
$roles[] = ['type' => 'owner', 'label' => '个人业主'];
|
||||
}
|
||||
|
||||
$v['role_badges'] = $roles;
|
||||
$v['order_count'] = $orderStatMap[$uid]['cnt'] ?? 0;
|
||||
$v['total_spent'] = $orderStatMap[$uid]['spent'] ?? '0.00';
|
||||
@@ -139,6 +144,7 @@ class User extends Backend
|
||||
$uid = (int)$row['id'];
|
||||
|
||||
$masterProfile = Db::name('master')->where('user_id', $uid)->find();
|
||||
$enterpriseCert = Db::name('user_enterprise_cert')->where('user_id', $uid)->find();
|
||||
$merchantProfile = Db::name('merchant')->where('user_id', $uid)->find();
|
||||
if (!$merchantProfile) {
|
||||
$memberBind = Db::name('merchant_member')->alias('mm')
|
||||
@@ -201,6 +207,7 @@ class User extends Backend
|
||||
'row' => $row,
|
||||
'masterProfile' => $masterProfile,
|
||||
'merchantProfile' => $merchantProfile,
|
||||
'enterpriseCert' => $enterpriseCert,
|
||||
'addressList' => $addressList,
|
||||
'recentOrders' => $recentOrders,
|
||||
'coupons' => $coupons,
|
||||
|
||||
@@ -61,4 +61,7 @@
|
||||
config: {$config|json_encode}
|
||||
};
|
||||
require.config.site.version += "-admin-list-20261119";
|
||||
if (require.config.controllername === 'merchant' || require.config.controllername === 'user.user') {
|
||||
require.config.site.version += "-identity-security-20261121";
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -448,13 +448,13 @@
|
||||
</a>
|
||||
|
||||
<!-- 商家待审 -->
|
||||
<a href="{:url('merchant/index', ['verify_status' => 'pending'])}" class="action-card addtabsit" title="企业商家">
|
||||
<a href="{:url('merchant/certificates')}" class="action-card addtabsit" title="企业资质认证">
|
||||
<div class="action-info">
|
||||
<div class="action-icon" style="background: #f0fdf4; color: #16a34a;">
|
||||
<i class="fa fa-building-o"></i>
|
||||
</div>
|
||||
<div class="action-text">
|
||||
<div class="name">商家待审核</div>
|
||||
<div class="name">企业资质待审核</div>
|
||||
<div class="sub">企业资质核验</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<div class="panel panel-default panel-intro">
|
||||
<div class="panel-heading"><strong>企业资质认证</strong><p class="text-muted">个人用户和商家用户均可提交企业资质认证;认证不会改变用户类型。</p></div>
|
||||
<div class="panel-body">
|
||||
<form id="cert-audit-token">{:token()}</form>
|
||||
<div id="certs-toolbar" class="toolbar"><a href="javascript:;" class="btn btn-primary" id="certs-refresh" title="刷新"><i class="fa fa-refresh"></i></a></div>
|
||||
<table id="certs-table" class="table table-striped table-bordered table-hover table-nowrap" data-operate-audit="{:$auth->check('merchant/edit')}" width="100%"></table>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,8 +1,8 @@
|
||||
<div class="panel panel-default panel-intro">
|
||||
<div class="panel-heading">
|
||||
{:build_heading(null,FALSE)}
|
||||
<span>企业业务档案及旧资质记录</span>
|
||||
<ul class="nav nav-tabs" data-field="verify_status">
|
||||
<li class="{:$Think.get.verify_status === null ? 'active' : ''}"><a href="#t-all" data-value="" data-toggle="tab">全部商家</a></li>
|
||||
<li class="{:$Think.get.verify_status === null ? 'active' : ''}"><a href="#t-all" data-value="" data-toggle="tab">全部档案</a></li>
|
||||
<li class="{:$Think.get.verify_status === 'pending' ? 'active' : ''}"><a href="#t-pending" data-value="pending" data-toggle="tab"><i class="fa fa-clock-o text-warning"></i> 企业资质待审</a></li>
|
||||
<li class="{:$Think.get.verify_status === 'pass' ? 'active' : ''}"><a href="#t-pass" data-value="pass" data-toggle="tab"><i class="fa fa-check-circle text-success"></i> 认证通过</a></li>
|
||||
<li class="{:$Think.get.verify_status === 'reject' ? 'active' : ''}"><a href="#t-reject" data-value="reject" data-toggle="tab"><i class="fa fa-times-circle text-danger"></i> 已驳回</a></li>
|
||||
@@ -30,3 +30,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -35,12 +35,16 @@
|
||||
<div class="ud-name">
|
||||
<span>{$row.nickname|default=$row.username|htmlentities}</span>
|
||||
<span class="label {if $row.status=='normal'}label-success{else/}label-default{/if}">{if $row.status=='normal'}正常{else/}已停用{/if}</span>
|
||||
<span class="label {if $row.user_type=='merchant' && $row.identity_selected}label-primary{else/}label-default{/if}">{if !$row.identity_selected}待选择用户类型{elseif $row.user_type=='merchant'/}商家用户{else/}个人用户{/if}</span>
|
||||
{if !empty($masterProfile) && $masterProfile.verify_status=='pass'}
|
||||
<span class="label label-warning"><i class="fa fa-wrench"></i> 认证师傅:{$masterProfile.realname|htmlentities}</span>
|
||||
{/if}
|
||||
{if !empty($merchantProfile) && $merchantProfile.verify_status=='pass'}
|
||||
<span class="label label-primary"><i class="fa fa-building-o"></i> 关联企业:{$merchantProfile.name|htmlentities}</span>
|
||||
{/if}
|
||||
{if !empty($enterpriseCert)}
|
||||
<span class="label label-info">企业资质:{if $enterpriseCert.verify_status=='pass'}已认证{elseif $enterpriseCert.verify_status=='pending'/}审核中{else/}未通过{/if}</span>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="ud-sub">
|
||||
账号: {$row.username|htmlentities} |
|
||||
@@ -66,6 +70,32 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if !empty($enterpriseCert)}
|
||||
<div class="ud-card">
|
||||
<div class="ud-card-hd"><i class="fa fa-certificate"></i> 企业资质认证</div>
|
||||
<div class="ud-card-bd">
|
||||
<table class="table table-bordered table-condensed" style="margin-bottom:0;"><tbody>
|
||||
<tr><th>企业名称</th><td>{$enterpriseCert.company_name|htmlentities}</td><th>营业执照号码</th><td>{$enterpriseCert.license_no|htmlentities}</td></tr>
|
||||
<tr><th>法人姓名</th><td>{$enterpriseCert.legal_person|default='未填写'|htmlentities}</td><th>审核结果</th><td>{if $enterpriseCert.verify_status=='pass'}已通过{elseif $enterpriseCert.verify_status=='pending'/}待审核{else/}已驳回:{$enterpriseCert.audit_msg|htmlentities}{/if}</td></tr>
|
||||
</tbody></table>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{if $row.identity_selected && $row.user_type=='merchant'}
|
||||
<div class="ud-card">
|
||||
<div class="ud-card-hd"><i class="fa fa-building-o"></i> 商家用户资料</div>
|
||||
<div class="ud-card-bd">
|
||||
<table class="table table-bordered table-condensed" style="margin-bottom:0;">
|
||||
<tbody>
|
||||
<tr><th>公司名称</th><td>{$row.company_name|default='未填写'|htmlentities}</td><th>法人姓名</th><td>{$row.company_legal_person|default='未填写'|htmlentities}</td></tr>
|
||||
<tr><th>法人手机号</th><td>{$row.company_legal_mobile|default='未填写'|htmlentities}</td><th>技术手机号</th><td>{$row.company_tech_mobile|default='未填写'|htmlentities}</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="row">
|
||||
<!-- 常用上门服务地址簿 -->
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
<div class="panel panel-default panel-intro">
|
||||
{:build_heading()}
|
||||
<div class="panel-heading"><strong>用户列表</strong><p class="text-muted">查看个人用户、商家用户及其独立的师傅身份。</p>
|
||||
<ul class="nav nav-tabs" data-field="user_type">
|
||||
<li class="active"><a href="#users-all" data-value="" data-toggle="tab">全部用户</a></li>
|
||||
<li><a href="#users-personal" data-value="personal" data-toggle="tab">个人用户</a></li>
|
||||
<li><a href="#users-merchant" data-value="merchant" data-toggle="tab">商家用户</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div id="myTabContent" class="tab-content">
|
||||
|
||||
在新工单中引用
屏蔽一个用户