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,
|
||||
|
||||
在新工单中引用
屏蔽一个用户