feat: 新增师傅入驻审核与接单状态联动功能
- 新增师傅资质审核模块及权限 - 未审核通过的师傅默认禁用接单状态 - 新增售后退款申诉功能与相关界面 - 新增用户钱包管理及充值功能 - 更新服务定价矩阵相关数据库结构 - 修复微信支付证书验证问题
这个提交包含在:
@@ -170,8 +170,15 @@ class Master extends Backend
|
||||
unset($params['city']);
|
||||
}
|
||||
|
||||
if (isset($params['verify_status']) && $params['verify_status'] === 'reject' && empty(trim((string)($params['audit_msg'] ?? '')))) {
|
||||
$this->error('驳回实名认证时请填写审核意见说明');
|
||||
if (isset($params['verify_status']) && $params['verify_status'] === 'reject') {
|
||||
if (empty(trim((string)($params['audit_msg'] ?? '')))) {
|
||||
$this->error('驳回实名认证时请填写审核意见说明');
|
||||
}
|
||||
$params['work_status'] = 'off';
|
||||
}
|
||||
if (isset($params['verify_status']) && in_array($params['verify_status'], ['pass', 'reject'], true)) {
|
||||
$params['audittime'] = time();
|
||||
$params['audit_admin_id'] = (int)$this->auth->id;
|
||||
}
|
||||
$result = false;
|
||||
Db::startTrans();
|
||||
@@ -454,4 +461,201 @@ class Master extends Backend
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 师傅入驻资质审核
|
||||
*/
|
||||
public function audit($ids = null)
|
||||
{
|
||||
$id = (int)($ids ?: $this->request->param('ids'));
|
||||
$row = $this->model->with(['user'])->where('master.id', $id)->find();
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
|
||||
if (false === $this->request->isPost()) {
|
||||
// 查询关联服务技能
|
||||
$skills = Db::name('master_skill')
|
||||
->alias('s')
|
||||
->join('service_cat c', 'c.id = s.cat_id', 'LEFT')
|
||||
->where('s.master_id', $row['id'])
|
||||
->field('s.*, c.name as cat_name')
|
||||
->select();
|
||||
|
||||
// 查询技能证书
|
||||
$certs = Db::name('master_cert')
|
||||
->field('id,cert_name,is_custom,cert_image,expire_date,is_long_term,status,audit_msg')
|
||||
->where('master_id', $row['id'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
|
||||
// 证件防伪水印处理
|
||||
if (!empty($row['idcard_front'])) {
|
||||
$row['idcard_front_watermark'] = \app\common\library\TencentVerifyService::getWatermarkUrl($row['idcard_front']);
|
||||
}
|
||||
if (!empty($row['idcard_back'])) {
|
||||
$row['idcard_back_watermark'] = \app\common\library\TencentVerifyService::getWatermarkUrl($row['idcard_back']);
|
||||
}
|
||||
|
||||
$this->view->assign([
|
||||
'row' => $row,
|
||||
'skills' => $skills,
|
||||
'certs' => $certs,
|
||||
]);
|
||||
return $this->view->fetch('audit');
|
||||
}
|
||||
|
||||
$params = $this->request->post('row/a', []);
|
||||
if (empty($params)) {
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
|
||||
$verifyStatus = trim((string)($params['verify_status'] ?? ''));
|
||||
$auditMsg = trim((string)($params['audit_msg'] ?? ''));
|
||||
$level = max(1, (int)($params['level'] ?? $row['level'] ?? 1));
|
||||
|
||||
if (!in_array($verifyStatus, ['pass', 'reject'], true)) {
|
||||
$this->error('请选择有效的审核结果(通过或驳回)');
|
||||
}
|
||||
|
||||
if ($verifyStatus === 'reject' && $auditMsg === '') {
|
||||
$this->error('驳回入驻申请时,必须填写驳回原因说明');
|
||||
}
|
||||
|
||||
$now = time();
|
||||
$adminId = (int)$this->auth->id;
|
||||
|
||||
$updateData = [
|
||||
'verify_status' => $verifyStatus,
|
||||
'audit_msg' => $auditMsg,
|
||||
'level' => $level,
|
||||
'audittime' => $now,
|
||||
'audit_admin_id' => $adminId,
|
||||
'updatetime' => $now,
|
||||
];
|
||||
|
||||
// 若驳回,出工状态必须设为 off
|
||||
if ($verifyStatus === 'reject') {
|
||||
$updateData['work_status'] = 'off';
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
Db::name('master')->where('id', $row['id'])->update($updateData);
|
||||
|
||||
// 发送审核结果通知给师傅和用户
|
||||
$title = $verifyStatus === 'pass' ? '师傅入驻审核通过' : '师傅入驻审核未通过';
|
||||
$content = $verifyStatus === 'pass'
|
||||
? '恭喜您!您的师傅入驻与实名认证已审核通过,已获得接单资格,现在可开启听单承接同城订单。'
|
||||
: ('您的师傅入驻认证申请未通过,原因:' . ($auditMsg ?: '证件材料不符合规范,请重新核对后提交。'));
|
||||
|
||||
Db::name('message')->insert([
|
||||
'receive_type' => 'master',
|
||||
'receive_id' => (int)$row['id'],
|
||||
'type' => 'audit',
|
||||
'title' => $title,
|
||||
'content' => $content,
|
||||
'order_id' => 0,
|
||||
'is_read' => 0,
|
||||
'createtime' => $now,
|
||||
]);
|
||||
|
||||
if ((int)$row['user_id'] > 0) {
|
||||
Db::name('message')->insert([
|
||||
'receive_type' => 'user',
|
||||
'receive_id' => (int)$row['user_id'],
|
||||
'type' => 'audit',
|
||||
'title' => $title,
|
||||
'content' => $content,
|
||||
'order_id' => 0,
|
||||
'is_read' => 0,
|
||||
'createtime' => $now,
|
||||
]);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
|
||||
$this->success('入驻审核处理成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量快捷审核通过
|
||||
*/
|
||||
public function batch_pass()
|
||||
{
|
||||
if (false === $this->request->isPost()) {
|
||||
$this->error(__('Invalid parameters'));
|
||||
}
|
||||
$ids = $this->request->post('ids');
|
||||
$idArr = array_values(array_filter(array_map('intval', explode(',', (string)$ids))));
|
||||
if (!$idArr) {
|
||||
$this->error(__('Parameter %s can not be empty', 'ids'));
|
||||
}
|
||||
|
||||
$pendingMasters = Db::name('master')
|
||||
->where('id', 'in', $idArr)
|
||||
->where('verify_status', 'pending')
|
||||
->select();
|
||||
|
||||
if (empty($pendingMasters)) {
|
||||
$this->error('所选记录中没有待审核的师傅档案');
|
||||
}
|
||||
|
||||
$now = time();
|
||||
$adminId = (int)$this->auth->id;
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$targetIds = array_column($pendingMasters, 'id');
|
||||
Db::name('master')->where('id', 'in', $targetIds)->update([
|
||||
'verify_status' => 'pass',
|
||||
'audit_msg' => '管理员批量审核通过',
|
||||
'audittime' => $now,
|
||||
'audit_admin_id' => $adminId,
|
||||
'updatetime' => $now,
|
||||
]);
|
||||
|
||||
foreach ($pendingMasters as $m) {
|
||||
$mId = (int)$m['id'];
|
||||
$uId = (int)$m['user_id'];
|
||||
$title = '师傅入驻审核通过';
|
||||
$content = '恭喜您!您的师傅入驻与实名认证已审核通过,已获得接单资格,现在可开启听单承接同城订单。';
|
||||
|
||||
Db::name('message')->insert([
|
||||
'receive_type' => 'master',
|
||||
'receive_id' => $mId,
|
||||
'type' => 'audit',
|
||||
'title' => $title,
|
||||
'content' => $content,
|
||||
'order_id' => 0,
|
||||
'is_read' => 0,
|
||||
'createtime' => $now,
|
||||
]);
|
||||
|
||||
if ($uId > 0) {
|
||||
Db::name('message')->insert([
|
||||
'receive_type' => 'user',
|
||||
'receive_id' => $uId,
|
||||
'type' => 'audit',
|
||||
'title' => $title,
|
||||
'content' => $content,
|
||||
'order_id' => 0,
|
||||
'is_read' => 0,
|
||||
'createtime' => $now,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
|
||||
$this->success('已成功批量审核通过 ' . count($pendingMasters) . ' 位师傅');
|
||||
}
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户