feat: 用户端与师傅端双小程序架构解耦,新增师傅独立认证及超时自动关单机制
1. 账号体系与数据库解耦: - 师傅表 fa_master 解除对 fa_user.id 的外键依赖,升级为独立认证账号主表; - 新增师傅端独立支撑表:fa_master_security、fa_master_token、fa_master_wechat、fa_master_agreement_read; - 新增工单超时未接单自动关闭与原路退款配置(order_unaccepted_close_days)。 2. 服务端(Server): - 新增师傅端独立 API 控制器与认证库(MasterAuth, MasterBase, MasterMessage, MasterSecurity, MasterToken); - WxLogin 支持双小程序端(user/master)独立换取 session_key、openid 与 access_token; - 新增控制台调度命令 php think order:autoclose,支持订单超时自动关闭与售后退款闭环; - 修复 PHP 8.5 兼容性问题(Request.php 的 (bool) 强制转换); - 系统业务配置全面收敛至数据库 fa_config 及 site.php。 3. 小程序端: - yjyf-app(用户端):彻底剥离师傅端路由、组件及静态资源,增加隐私授权弹窗与评价模块; - yjyf-master-app(师傅端):全新独立微信小程序工程(wx140d90ceda786107),实现工作台、接单大厅、资质认证、工单协同与钱包提现完整闭环。
这个提交包含在:
@@ -52,14 +52,14 @@ class Home extends Backend
|
||||
->whereRaw('IF(pay_time > 0, pay_time, createtime) BETWEEN ' . (int)$monthStart . ' AND ' . (int)$todayEnd)
|
||||
->sum('pay_amount') ?: 0);
|
||||
|
||||
// 运力与商户统计
|
||||
// 运力与双端独立账号统计
|
||||
$totalMaster = Master::where('verify_status', 'pass')->count();
|
||||
$totalMasterAccount = Master::count();
|
||||
$draftMaster = Master::where('verify_status', 'draft')->count();
|
||||
$onlineMaster = Master::where('verify_status', 'pass')->where('work_status', 'on')->count();
|
||||
$totalMerchant = Merchant::where('verify_status', 'pass')->count();
|
||||
$totalUser = Db::name('user')->alias('u')
|
||||
->join('master ma', 'ma.user_id = u.id', 'LEFT')
|
||||
->join('merchant me', 'me.user_id = u.id', 'LEFT')
|
||||
->whereNull('ma.id')
|
||||
->whereNull('me.id')
|
||||
->count();
|
||||
|
||||
@@ -155,8 +155,10 @@ class Home extends Backend
|
||||
'todayGmv' => number_format($todayGmv, 2, '.', ','),
|
||||
'monthGmv' => number_format($monthGmv, 2, '.', ','),
|
||||
|
||||
'totalMaster' => $totalMaster,
|
||||
'onlineMaster' => $onlineMaster,
|
||||
'totalMaster' => $totalMaster,
|
||||
'totalMasterAccount' => $totalMasterAccount,
|
||||
'draftMaster' => $draftMaster,
|
||||
'onlineMaster' => $onlineMaster,
|
||||
'totalMerchant' => $totalMerchant,
|
||||
'totalUser' => $totalUser,
|
||||
|
||||
|
||||
@@ -18,13 +18,14 @@ class Master extends Backend
|
||||
* @var \app\admin\model\Master
|
||||
*/
|
||||
protected $model = null;
|
||||
protected $relationSearch = true;
|
||||
protected $searchFields = 'id,realname,mobile,city';
|
||||
protected $relationSearch = false;
|
||||
protected $searchFields = 'id,realname,nickname,mobile,city';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\Master;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
$this->view->assign("workStatusList", $this->model->getWorkStatusList());
|
||||
$this->view->assign("verifyStatusList", $this->model->getVerifyStatusList());
|
||||
}
|
||||
@@ -40,7 +41,6 @@ class Master extends Backend
|
||||
}
|
||||
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
||||
$list = $this->model
|
||||
->with(['user'])
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
@@ -48,6 +48,8 @@ class Master extends Backend
|
||||
$items = $list->items();
|
||||
$masterIds = array_column($items, 'id');
|
||||
$skillsGroup = [];
|
||||
$wechatMap = [];
|
||||
$securityMap = [];
|
||||
if (!empty($masterIds)) {
|
||||
$allSkills = Db::name('master_skill')
|
||||
->where('master_id', 'in', $masterIds)
|
||||
@@ -59,9 +61,37 @@ class Master extends Backend
|
||||
$skillsGroup[$sk['master_id']][] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
$wechatRows = Db::name('master_wechat')
|
||||
->where('master_id', 'in', $masterIds)
|
||||
->field('master_id,openid,createtime')
|
||||
->select();
|
||||
foreach ($wechatRows as $wc) {
|
||||
$wechatMap[(int)$wc['master_id']] = $wc;
|
||||
}
|
||||
|
||||
$secRows = Db::name('master_security')
|
||||
->where('master_id', 'in', $masterIds)
|
||||
->field('master_id,payment_password_hash,failed_attempts,locked_until,payment_failed_attempts,payment_locked_until')
|
||||
->select();
|
||||
foreach ($secRows as $sr) {
|
||||
$securityMap[(int)$sr['master_id']] = $sr;
|
||||
}
|
||||
}
|
||||
$now = time();
|
||||
foreach ($items as &$it) {
|
||||
$it['skills_list'] = $skillsGroup[$it['id']] ?? [];
|
||||
$mid = (int)$it['id'];
|
||||
unset($it['password'], $it['salt']);
|
||||
$it['skills_list'] = $skillsGroup[$mid] ?? [];
|
||||
$wc = $wechatMap[$mid] ?? null;
|
||||
$it['wechat_bound'] = !empty($wc['openid']);
|
||||
$it['wechat_openid_mask'] = !empty($wc['openid'])
|
||||
? (mb_substr($wc['openid'], 0, 6) . '****' . mb_substr($wc['openid'], -4))
|
||||
: '';
|
||||
$sec = $securityMap[$mid] ?? null;
|
||||
$it['has_pay_password'] = !empty($sec['payment_password_hash']);
|
||||
$it['is_locked'] = ((int)($sec['locked_until'] ?? 0) > $now)
|
||||
|| ((int)($sec['payment_locked_until'] ?? 0) > $now);
|
||||
}
|
||||
unset($it);
|
||||
|
||||
@@ -69,7 +99,7 @@ class Master extends Backend
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增认证师傅档案(校验用户唯一绑定,强制初始化资金与履约统计为 0)
|
||||
* 新增独立师傅账号与档案(不再绑定 fa_user)
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
@@ -81,13 +111,38 @@ class Master extends Backend
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$params = $this->preExcludeFields($params);
|
||||
$uid = (int)($params['user_id'] ?? 0);
|
||||
if ($uid <= 0) {
|
||||
$this->error('请选择关联的平台注册用户账号');
|
||||
unset($params['user_id']);
|
||||
|
||||
$mobile = trim((string)($params['mobile'] ?? ''));
|
||||
if (!preg_match('/^1[3-9]\d{9}$/', $mobile)) {
|
||||
$this->error('请输入有效的11位手机号码');
|
||||
}
|
||||
if (Db::name('master')->where('user_id', $uid)->count() > 0) {
|
||||
$this->error('该用户已绑定过师傅档案,请勿重复创建');
|
||||
if (Db::name('master')->where('mobile', $mobile)->count() > 0) {
|
||||
$this->error('该手机号已注册过师傅端账号,请勿重复创建');
|
||||
}
|
||||
|
||||
$realname = trim((string)($params['realname'] ?? ''));
|
||||
if ($realname === '') {
|
||||
$this->error('请填写师傅真实姓名');
|
||||
}
|
||||
|
||||
$plainPassword = trim((string)($params['password'] ?? ''));
|
||||
if ($plainPassword !== '' && mb_strlen($plainPassword) < 6) {
|
||||
$this->error('登录密码长度不能少于6位');
|
||||
}
|
||||
$salt = \fast\Random::alnum();
|
||||
if ($plainPassword === '') {
|
||||
// 若管理员未指定初始密码,生成高强度随机盐与不可逆占位密码,师傅可通过微信或手机验证码登录
|
||||
$plainPassword = \fast\Random::alnum(16);
|
||||
}
|
||||
$params['salt'] = $salt;
|
||||
$params['password'] = \app\common\library\MasterAuth::instance()->getEncryptPassword($plainPassword, $salt);
|
||||
|
||||
if (empty($params['nickname'])) {
|
||||
$params['nickname'] = $realname;
|
||||
}
|
||||
$params['mobile'] = $mobile;
|
||||
$params['status'] = in_array($params['status'] ?? 'normal', ['normal', 'disabled'], true) ? $params['status'] : 'normal';
|
||||
$params['money'] = 0.00;
|
||||
$params['frozen_money'] = 0.00;
|
||||
$params['order_count'] = 0;
|
||||
@@ -95,6 +150,9 @@ class Master extends Backend
|
||||
$params['score'] = 5.00;
|
||||
$params['accept_rate'] = 100.00;
|
||||
$params['ontime_rate'] = 100.00;
|
||||
if ($params['status'] !== 'normal') {
|
||||
$params['work_status'] = 'off';
|
||||
}
|
||||
|
||||
$result = $this->model->allowField(true)->save($params);
|
||||
if ($result !== false) {
|
||||
@@ -104,7 +162,7 @@ class Master extends Backend
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除保护:已产生承接工单、钱包余额或结算流水的师傅禁止物理删除
|
||||
* 删除保护:已产生承接工单、提现、申诉、评价、钱包余额或结算流水的师傅禁止物理删除
|
||||
*/
|
||||
public function del($ids = null)
|
||||
{
|
||||
@@ -119,12 +177,19 @@ class Master extends Backend
|
||||
$hasOrder = Db::name('order')->where('master_id', 'in', $idArr)->count();
|
||||
$hasFund = Db::name('master')->where('id', 'in', $idArr)->where('money > 0 OR frozen_money > 0')->count();
|
||||
$hasSettle = Db::name('settle')->where('master_id', 'in', $idArr)->count();
|
||||
if ($hasOrder > 0 || $hasFund > 0 || $hasSettle > 0) {
|
||||
$this->error('所选师傅已关联历史工单、结算记录或存在钱包资金,禁止物理删除;如需停用请关闭听单状态');
|
||||
$hasWithdraw = Db::name('withdraw')->where('master_id', 'in', $idArr)->count();
|
||||
$hasAppeal = Db::name('appeal')->where('master_id', 'in', $idArr)->count();
|
||||
if ($hasOrder > 0 || $hasFund > 0 || $hasSettle > 0 || $hasWithdraw > 0 || $hasAppeal > 0) {
|
||||
$this->error('所选师傅已关联历史工单、提现、申诉、结算记录或存在钱包资金,禁止物理删除;如需停用请将账号状态设为已停用');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
Db::name('master_skill')->where('master_id', 'in', $idArr)->delete();
|
||||
Db::name('master_cert')->where('master_id', 'in', $idArr)->delete();
|
||||
Db::name('master_token')->where('master_id', 'in', $idArr)->delete();
|
||||
Db::name('master_wechat')->where('master_id', 'in', $idArr)->delete();
|
||||
Db::name('master_security')->where('master_id', 'in', $idArr)->delete();
|
||||
Db::name('master_agreement_read')->where('master_id', 'in', $idArr)->delete();
|
||||
$deleted = Db::name('master')->where('id', 'in', $idArr)->delete();
|
||||
Db::commit();
|
||||
} catch (Exception $e) {
|
||||
@@ -138,7 +203,7 @@ class Master extends Backend
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑师傅资料与入驻资质审核(状态变更自动触发通知)
|
||||
* 编辑师傅资料、独立账号状态与入驻资质审核
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
@@ -153,7 +218,45 @@ class Master extends Backend
|
||||
if ($params) {
|
||||
$params = $this->preExcludeFields($params);
|
||||
// 禁止在师傅档案编辑中直接篡改钱包可用余额、冻结资金与累计完单数
|
||||
unset($params['money'], $params['frozen_money'], $params['order_count']);
|
||||
unset($params['user_id'], $params['money'], $params['frozen_money'], $params['order_count'], $params['salt']);
|
||||
|
||||
if (isset($params['mobile'])) {
|
||||
$mobile = trim((string)$params['mobile']);
|
||||
if (!preg_match('/^1[3-9]\d{9}$/', $mobile)) {
|
||||
$this->error('请输入有效的11位手机号码');
|
||||
}
|
||||
$dup = Db::name('master')->where('mobile', $mobile)->where('id', '<>', (int)$row['id'])->count();
|
||||
if ($dup > 0) {
|
||||
$this->error('该手机号已被其他师傅账号占用');
|
||||
}
|
||||
$params['mobile'] = $mobile;
|
||||
}
|
||||
|
||||
// 登录密码留空表示不修改,填写则重置盐值与加密密码并清理登录会话
|
||||
$resetPassword = false;
|
||||
if (array_key_exists('password', $params)) {
|
||||
$plainPassword = trim((string)$params['password']);
|
||||
if ($plainPassword === '') {
|
||||
unset($params['password']);
|
||||
} else {
|
||||
if (mb_strlen($plainPassword) < 6) {
|
||||
$this->error('重置的登录密码长度不能少于6位');
|
||||
}
|
||||
$salt = \fast\Random::alnum();
|
||||
$params['salt'] = $salt;
|
||||
$params['password'] = \app\common\library\MasterAuth::instance()->getEncryptPassword($plainPassword, $salt);
|
||||
$resetPassword = true;
|
||||
}
|
||||
}
|
||||
|
||||
$kickToken = $resetPassword;
|
||||
if (isset($params['status'])) {
|
||||
$params['status'] = in_array($params['status'], ['normal', 'disabled'], true) ? $params['status'] : $row['status'];
|
||||
if ($params['status'] === 'disabled') {
|
||||
$params['work_status'] = 'off';
|
||||
$kickToken = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 若提交的身份证号包含脱敏星号 *,保留原数据库记录不覆盖;若为新填写明文则做合法性校验
|
||||
if (isset($params['idcard_no'])) {
|
||||
@@ -184,6 +287,9 @@ class Master extends Backend
|
||||
Db::startTrans();
|
||||
try {
|
||||
$result = $row->allowField(true)->save($params);
|
||||
if ($kickToken) {
|
||||
\app\common\library\MasterToken::clear((int)$row['id']);
|
||||
}
|
||||
$newVerify = isset($params['verify_status']) ? (string)$params['verify_status'] : $oldVerify;
|
||||
if ($newVerify !== $oldVerify && in_array($newVerify, ['pass', 'reject'], true)) {
|
||||
$now = time();
|
||||
@@ -201,18 +307,6 @@ class Master extends Backend
|
||||
'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) {
|
||||
@@ -370,7 +464,7 @@ class Master extends Backend
|
||||
*/
|
||||
public function detail($ids = null)
|
||||
{
|
||||
$row = $this->model->with(['user'])->where('master.id', (int)$ids)->find();
|
||||
$row = $this->model->where('id', (int)$ids)->find();
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
@@ -448,8 +542,26 @@ class Master extends Backend
|
||||
$row['idcard_back_watermark'] = \app\common\library\TencentVerifyService::getWatermarkUrl($row['idcard_back']);
|
||||
}
|
||||
|
||||
// 8. 独立账号安全、微信绑定与活跃会话状态
|
||||
$wechatBind = Db::name('master_wechat')->where('master_id', $row['id'])->find();
|
||||
$securityInfo = Db::name('master_security')->where('master_id', $row['id'])->find();
|
||||
$activeTokens = Db::name('master_token')
|
||||
->where('master_id', $row['id'])
|
||||
->where(function ($q) {
|
||||
$q->where('expiretime', 0)->whereOr('expiretime', '>', time());
|
||||
})
|
||||
->count();
|
||||
$now = time();
|
||||
$isLoginLocked = (int)($securityInfo['locked_until'] ?? 0) > $now;
|
||||
$isPayLocked = (int)($securityInfo['payment_locked_until'] ?? 0) > $now;
|
||||
|
||||
$this->view->assign([
|
||||
'row' => $row,
|
||||
'wechatBind' => $wechatBind ?: [],
|
||||
'securityInfo' => $securityInfo ?: [],
|
||||
'activeTokens' => (int)$activeTokens,
|
||||
'isLoginLocked' => $isLoginLocked,
|
||||
'isPayLocked' => $isPayLocked,
|
||||
'recentOrders' => $recentOrders,
|
||||
'recentWithdraws' => $recentWithdraws,
|
||||
'recentSettles' => $recentSettles,
|
||||
@@ -468,7 +580,7 @@ class Master extends Backend
|
||||
public function audit($ids = null)
|
||||
{
|
||||
$id = (int)($ids ?: $this->request->param('ids'));
|
||||
$row = $this->model->with(['user'])->where('master.id', $id)->find();
|
||||
$row = $this->model->where('id', $id)->find();
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
@@ -489,6 +601,8 @@ class Master extends Backend
|
||||
->order('id desc')
|
||||
->select();
|
||||
|
||||
$wechatBind = Db::name('master_wechat')->where('master_id', $row['id'])->find();
|
||||
|
||||
// 证件防伪水印处理
|
||||
if (!empty($row['idcard_front'])) {
|
||||
$row['idcard_front_watermark'] = \app\common\library\TencentVerifyService::getWatermarkUrl($row['idcard_front']);
|
||||
@@ -498,9 +612,10 @@ class Master extends Backend
|
||||
}
|
||||
|
||||
$this->view->assign([
|
||||
'row' => $row,
|
||||
'skills' => $skills,
|
||||
'certs' => $certs,
|
||||
'row' => $row,
|
||||
'wechatBind' => $wechatBind ?: [],
|
||||
'skills' => $skills,
|
||||
'certs' => $certs,
|
||||
]);
|
||||
return $this->view->fetch('audit');
|
||||
}
|
||||
@@ -543,7 +658,7 @@ class Master extends Backend
|
||||
try {
|
||||
Db::name('master')->where('id', $row['id'])->update($updateData);
|
||||
|
||||
// 发送审核结果通知给师傅和用户
|
||||
// 发送审核结果通知给独立师傅端
|
||||
$title = $verifyStatus === 'pass' ? '师傅入驻审核通过' : '师傅入驻审核未通过';
|
||||
$content = $verifyStatus === 'pass'
|
||||
? '恭喜您!您的师傅入驻与实名认证已审核通过,已获得接单资格,现在可开启听单承接同城订单。'
|
||||
@@ -560,19 +675,6 @@ class Master extends Backend
|
||||
'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();
|
||||
@@ -621,7 +723,6 @@ class Master extends Backend
|
||||
|
||||
foreach ($pendingMasters as $m) {
|
||||
$mId = (int)$m['id'];
|
||||
$uId = (int)$m['user_id'];
|
||||
$title = '师傅入驻审核通过';
|
||||
$content = '恭喜您!您的师傅入驻与实名认证已审核通过,已获得接单资格,现在可开启听单承接同城订单。';
|
||||
|
||||
@@ -635,19 +736,6 @@ class Master extends Backend
|
||||
'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();
|
||||
@@ -658,4 +746,99 @@ class Master extends Backend
|
||||
|
||||
$this->success('已成功批量审核通过 ' . count($pendingMasters) . ' 位师傅');
|
||||
}
|
||||
|
||||
/**
|
||||
* 解绑师傅端微信账号(清空 fa_master_wechat 并踢掉会话)
|
||||
*/
|
||||
public function unbind_wechat($ids = null)
|
||||
{
|
||||
if (false === $this->request->isPost()) {
|
||||
$this->error(__('Invalid parameters'));
|
||||
}
|
||||
$masterId = (int)($ids ?: $this->request->post('ids'));
|
||||
$row = $this->model->find($masterId);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
Db::name('master_wechat')->where('master_id', $masterId)->delete();
|
||||
\app\common\library\MasterToken::clear($masterId);
|
||||
Db::commit();
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
$this->success('已解绑该师傅的微信授权绑定');
|
||||
}
|
||||
|
||||
/**
|
||||
* 解除师傅登录/支付密码防爆破锁定
|
||||
*/
|
||||
public function unlock_security($ids = null)
|
||||
{
|
||||
if (false === $this->request->isPost()) {
|
||||
$this->error(__('Invalid parameters'));
|
||||
}
|
||||
$masterId = (int)($ids ?: $this->request->post('ids'));
|
||||
$row = $this->model->find($masterId);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$now = time();
|
||||
Db::startTrans();
|
||||
try {
|
||||
Db::name('master')->where('id', $masterId)->update([
|
||||
'loginfailure' => 0,
|
||||
'loginfailuretime' => 0,
|
||||
'updatetime' => $now,
|
||||
]);
|
||||
Db::name('master_security')->where('master_id', $masterId)->update([
|
||||
'failed_attempts' => 0,
|
||||
'locked_until' => 0,
|
||||
'payment_failed_attempts' => 0,
|
||||
'payment_locked_until' => 0,
|
||||
]);
|
||||
Db::commit();
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
$this->success('已解除登录与支付防爆破锁定');
|
||||
}
|
||||
|
||||
/**
|
||||
* 停用 / 启用独立师傅账号(停用自动关闭听单并下线会话)
|
||||
*/
|
||||
public function toggle_status($ids = null)
|
||||
{
|
||||
if (false === $this->request->isPost()) {
|
||||
$this->error(__('Invalid parameters'));
|
||||
}
|
||||
$masterId = (int)($ids ?: $this->request->post('ids'));
|
||||
$row = $this->model->find($masterId);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$target = ($row['status'] ?? 'normal') === 'normal' ? 'disabled' : 'normal';
|
||||
$update = [
|
||||
'status' => $target,
|
||||
'updatetime' => time(),
|
||||
];
|
||||
if ($target === 'disabled') {
|
||||
$update['work_status'] = 'off';
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
Db::name('master')->where('id', $masterId)->update($update);
|
||||
if ($target === 'disabled') {
|
||||
\app\common\library\MasterToken::clear($masterId);
|
||||
}
|
||||
Db::commit();
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
$this->success($target === 'disabled' ? '已停用该师傅账号并强制下线' : '已恢复启用该师傅账号');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,20 +157,6 @@ class MasterCert extends Backend
|
||||
'is_read' => 0,
|
||||
'createtime' => $now,
|
||||
]);
|
||||
|
||||
$userId = (int)Db::name('master')->where('id', $masterId)->value('user_id');
|
||||
if ($userId > 0) {
|
||||
Db::name('message')->insert([
|
||||
'receive_type' => 'user',
|
||||
'receive_id' => $userId,
|
||||
'type' => 'audit',
|
||||
'title' => $msgTitle,
|
||||
'content' => $msgContent,
|
||||
'order_id' => 0,
|
||||
'is_read' => 0,
|
||||
'createtime' => $now,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
@@ -168,8 +168,8 @@ class Order extends Backend
|
||||
$targetMaster = null;
|
||||
if ($newMasterId > 0 && $newMasterId !== $oldMasterId && $newStatus !== 9) {
|
||||
$targetMaster = Db::name('master')->where('id', $newMasterId)->find();
|
||||
if (!$targetMaster || $targetMaster['verify_status'] !== 'pass') {
|
||||
$this->error('所选承接师傅不存在或尚未通过实名认证');
|
||||
if (!$targetMaster || $targetMaster['verify_status'] !== 'pass' || (isset($targetMaster['status']) && $targetMaster['status'] !== 'normal')) {
|
||||
$this->error('所选承接师傅不存在、未通过实名认证或账号已被停用');
|
||||
}
|
||||
if (in_array($newStatus, [1, 2], true)) {
|
||||
$newStatus = 3;
|
||||
@@ -444,8 +444,8 @@ class Order extends Backend
|
||||
}
|
||||
|
||||
$targetMaster = Db::name('master')->where('id', $masterId)->find();
|
||||
if (!$targetMaster || $targetMaster['verify_status'] !== 'pass') {
|
||||
$this->error('所选师傅不存在或未通过实名认证');
|
||||
if (!$targetMaster || $targetMaster['verify_status'] !== 'pass' || (isset($targetMaster['status']) && $targetMaster['status'] !== 'normal')) {
|
||||
$this->error('所选师傅不存在、未通过实名认证或账号已被停用');
|
||||
}
|
||||
if (!\app\common\library\OrderQualification::forMaster($row['qual_req'] ?? '', $masterId)) {
|
||||
$this->error('所选师傅未持有符合订单要求的有效认证证书:' . $row['qual_req']);
|
||||
@@ -540,6 +540,7 @@ class Order extends Backend
|
||||
|
||||
$candidateMasters = Db::name('master')
|
||||
->where('verify_status', 'pass')
|
||||
->where('status', 'normal')
|
||||
->orderRaw("work_status = 'on' DESC, score DESC, order_count DESC")
|
||||
->limit(12)
|
||||
->select();
|
||||
|
||||
@@ -79,6 +79,7 @@ class Withdraw extends Backend
|
||||
}
|
||||
$masterId = (int)$row['master_id'];
|
||||
$master = $masterId > 0 ? Db::name('master')->where('id', $masterId)->find() : null;
|
||||
$wechatBind = $masterId > 0 ? Db::name('master_wechat')->where('master_id', $masterId)->find() : null;
|
||||
$recentSettles = $masterId > 0
|
||||
? Db::name('settle')->alias('s')
|
||||
->join('__ORDER__ o', 'o.id = s.order_id', 'LEFT')
|
||||
@@ -98,12 +99,13 @@ class Withdraw extends Backend
|
||||
: [];
|
||||
|
||||
$this->view->assign([
|
||||
'row' => $row,
|
||||
'master' => $master ?: [],
|
||||
'recentSettles' => $recentSettles,
|
||||
'walletLogs' => $walletLogs,
|
||||
'verifyStatusList' => ['pending' => '审核中', 'pass' => '已认证', 'reject' => '审核未通过'],
|
||||
'walletTypeList' => (new \app\admin\model\WalletLog)->getTypeList(),
|
||||
'row' => $row,
|
||||
'master' => $master ?: [],
|
||||
'wechatBind' => $wechatBind ?: [],
|
||||
'recentSettles' => $recentSettles,
|
||||
'walletLogs' => $walletLogs,
|
||||
'verifyStatusList' => ['draft' => '待完善资料', 'pending' => '审核中', 'pass' => '已认证', 'reject' => '审核未通过'],
|
||||
'walletTypeList' => (new \app\admin\model\WalletLog)->getTypeList(),
|
||||
]);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
@@ -154,9 +156,11 @@ class Withdraw extends Backend
|
||||
}
|
||||
|
||||
if (false === $this->request->isPost()) {
|
||||
$master = Db::name('master')->where('id', (int)$row['master_id'])->field('id,realname,mobile,user_id,money,frozen_money')->find();
|
||||
$master = Db::name('master')->where('id', (int)$row['master_id'])->field('id,realname,mobile,money,frozen_money')->find();
|
||||
$wechatBind = Db::name('master_wechat')->where('master_id', (int)$row['master_id'])->find();
|
||||
$this->view->assign('row', $row);
|
||||
$this->view->assign('master', $master ?: []);
|
||||
$this->view->assign('wechatBind', $wechatBind ?: []);
|
||||
$this->view->assign('flowOptions', $flowOptions);
|
||||
$this->view->assign('useWxApi', $useWxApi);
|
||||
$this->view->assign('transferStateLabel', PaymentService::transferStateLabel($row['transfer_state'] ?? ''));
|
||||
@@ -229,7 +233,7 @@ class Withdraw extends Backend
|
||||
}
|
||||
|
||||
if ($status === 'pass') {
|
||||
$this->sendMasterMessage($masterId, (int)$master['user_id'], '提现审核通过', '您的提现申请 ¥' . $amount . ' 已通过审核,财务将尽快安排打款到银行卡');
|
||||
$this->sendMasterMessage($masterId, '提现审核通过', '您的提现申请 ¥' . $amount . ' 已通过审核,财务将尽快安排打款到银行卡');
|
||||
} elseif ($status === 'done') {
|
||||
Db::name('master')->where('id', $masterId)->update([
|
||||
'frozen_money' => max(0, round((float)$master['frozen_money'] - $amount, 2)),
|
||||
@@ -245,7 +249,7 @@ class Withdraw extends Backend
|
||||
'remark' => '提现打款完成,冻结资金 ¥' . $amount . ' 划出(' . ($row['channel'] === 'bank' ? '银行储蓄卡' : '微信钱包') . ' ' . $row['account'] . ')',
|
||||
'createtime' => time(),
|
||||
]);
|
||||
$this->sendMasterMessage($masterId, (int)$master['user_id'], '提现打款完成', '您的提现 ¥' . $amount . ' 已打款成功,请留意到账通知');
|
||||
$this->sendMasterMessage($masterId, '提现打款完成', '您的提现 ¥' . $amount . ' 已打款成功,请留意到账通知');
|
||||
}
|
||||
Db::commit();
|
||||
} catch (PDOException|\Exception $e) {
|
||||
@@ -301,18 +305,16 @@ class Withdraw extends Backend
|
||||
}
|
||||
|
||||
/**
|
||||
* 向师傅端工作台及所属用户发送站内消息
|
||||
* @param int $masterId 师傅ID
|
||||
* @param int $userId 用户ID
|
||||
* @param string $title 消息标题
|
||||
* @param string $content 消息内容
|
||||
* 向独立师傅端工作台发送站内消息
|
||||
* @param int $masterId 师傅ID
|
||||
* @param string $title 消息标题
|
||||
* @param string $content 消息内容
|
||||
*/
|
||||
protected function sendMasterMessage($masterId, $userId, $title, $content)
|
||||
protected function sendMasterMessage($masterId, $title, $content)
|
||||
{
|
||||
$now = time();
|
||||
$rows = [];
|
||||
if ($masterId > 0) {
|
||||
$rows[] = [
|
||||
if ((int)$masterId > 0) {
|
||||
Db::name('message')->insert([
|
||||
'receive_type' => 'master',
|
||||
'receive_id' => (int)$masterId,
|
||||
'type' => 'audit',
|
||||
@@ -321,22 +323,7 @@ class Withdraw extends Backend
|
||||
'order_id' => 0,
|
||||
'is_read' => 0,
|
||||
'createtime' => $now,
|
||||
];
|
||||
}
|
||||
if ($userId > 0) {
|
||||
$rows[] = [
|
||||
'receive_type' => 'user',
|
||||
'receive_id' => (int)$userId,
|
||||
'type' => 'system',
|
||||
'title' => mb_substr((string)$title, 0, 100),
|
||||
'content' => mb_substr((string)$content, 0, 500),
|
||||
'order_id' => 0,
|
||||
'is_read' => 0,
|
||||
'createtime' => $now,
|
||||
];
|
||||
}
|
||||
if ($rows) {
|
||||
Db::name('message')->insertAll($rows);
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +138,19 @@ class Config extends Backend
|
||||
$this->token();
|
||||
$row = $this->request->post("row/a", [], 'trim');
|
||||
if ($row) {
|
||||
if (isset($row['order_unaccepted_close_switch'])) {
|
||||
$closeSwitch = (int)$row['order_unaccepted_close_switch'] ? 1 : 0;
|
||||
$row['order_unaccepted_close_switch'] = (string)$closeSwitch;
|
||||
if ($closeSwitch === 0) {
|
||||
$row['order_unaccepted_close_days'] = '0';
|
||||
} else {
|
||||
$closeDaysRaw = isset($row['order_unaccepted_close_days']) ? trim((string)$row['order_unaccepted_close_days']) : '';
|
||||
if ($closeDaysRaw === '' || !ctype_digit($closeDaysRaw) || (int)$closeDaysRaw < 1) {
|
||||
$this->error('开启超时未接单自动关闭时,请填写大于 0 的整数天数');
|
||||
}
|
||||
$row['order_unaccepted_close_days'] = (string)((int)$closeDaysRaw);
|
||||
}
|
||||
}
|
||||
$configList = [];
|
||||
foreach ($this->model->all() as $v) {
|
||||
if (isset($row[$v['name']])) {
|
||||
@@ -158,6 +171,8 @@ class Config extends Backend
|
||||
}
|
||||
try {
|
||||
ConfigModel::refreshFile();
|
||||
Cache::rm('wechat_access_token_user');
|
||||
Cache::rm('wechat_access_token_master');
|
||||
} catch (Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
|
||||
@@ -50,18 +50,12 @@ class User extends Backend
|
||||
$rows = $list->items();
|
||||
$uids = array_column($rows, 'id');
|
||||
|
||||
$masterMap = [];
|
||||
$merchantMap = [];
|
||||
$memberMap = [];
|
||||
$orderStatMap = [];
|
||||
$couponCntMap = [];
|
||||
|
||||
if (!empty($uids)) {
|
||||
$masters = Db::name('master')->field('id,user_id,realname,verify_status')->where('user_id', 'in', $uids)->select();
|
||||
foreach ($masters as $m) {
|
||||
$masterMap[(int)$m['user_id']] = $m;
|
||||
}
|
||||
|
||||
$merchants = Db::name('merchant')->field('id,user_id,name,verify_status')->where('user_id', 'in', $uids)->select();
|
||||
foreach ($merchants as $mc) {
|
||||
$merchantMap[(int)$mc['user_id']] = $mc;
|
||||
@@ -112,9 +106,6 @@ class User extends Backend
|
||||
} else {
|
||||
$roles[] = ['type' => 'owner', 'label' => '个人用户'];
|
||||
}
|
||||
if (isset($masterMap[$uid]) && $masterMap[$uid]['verify_status'] === 'pass') {
|
||||
$roles[] = ['type' => 'master', 'label' => '认证师傅 (' . $masterMap[$uid]['realname'] . ')'];
|
||||
}
|
||||
if (isset($merchantMap[$uid]) && $merchantMap[$uid]['verify_status'] === 'pass') {
|
||||
$roles[] = ['type' => 'merchant', 'label' => '签约企业 (' . $merchantMap[$uid]['name'] . ')'];
|
||||
} elseif (isset($memberMap[$uid]) && !empty($memberMap[$uid])) {
|
||||
@@ -143,7 +134,6 @@ class User extends Backend
|
||||
$row->avatar = $row->avatar ? (strpos($row->avatar, '/assets/') === 0 ? $row->avatar : cdnurl($row->avatar, true)) : letter_avatar($row->nickname);
|
||||
$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) {
|
||||
@@ -205,7 +195,6 @@ class User extends Backend
|
||||
|
||||
$this->view->assign([
|
||||
'row' => $row,
|
||||
'masterProfile' => $masterProfile,
|
||||
'merchantProfile' => $merchantProfile,
|
||||
'enterpriseCert' => $enterpriseCert,
|
||||
'addressList' => $addressList,
|
||||
@@ -365,9 +354,8 @@ class User extends Backend
|
||||
}
|
||||
$uid = (int)$row['id'];
|
||||
if (Db::name('order')->where('user_id', $uid)->count() > 0
|
||||
|| Db::name('master')->where('user_id', $uid)->count() > 0
|
||||
|| Db::name('merchant')->where('user_id', $uid)->count() > 0) {
|
||||
$this->error('该会员已关联历史订单、师傅或商家档案,禁止物理删除;如需停用请将状态设为隐藏');
|
||||
$this->error('该会员已关联历史订单或商家档案,禁止物理删除;如需停用请将状态设为隐藏');
|
||||
}
|
||||
Auth::instance()->delete($uid);
|
||||
$this->success();
|
||||
|
||||
在新工单中引用
屏蔽一个用户