feat: 新增账号安全模块及资质校验功能
- 新增账号安全页面及支付密码验证组件 - 新增用户类型选择流程及商家资质管理 - 新增订单资质校验逻辑,师傅需满足订单证书要求 - 新增企业资质认证相关数据库表及接口 - 优化用户列表展示,区分个人与商家用户类型
这个提交包含在:
@@ -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();
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户