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),实现工作台、接单大厅、资质认证、工单协同与钱包提现完整闭环。
这个提交包含在:
2026-11-23 15:10:30 +08:00
父节点 d3cd6ba342
当前提交 14533eadb7
共有 270 个文件被更改,包括 9757 次插入 和 1392 次删除

查看文件

@@ -0,0 +1,40 @@
<?php
namespace app\admin\command;
use app\common\library\OrderAutoCloseService;
use think\console\Command;
use think\console\Input;
use think\console\Output;
/**
* 超时未接单订单自动关闭、原路退款及消息提醒守护任务
* 运行方式:php think order:autoclose
*/
class OrderAutoclose extends Command
{
protected function configure()
{
$this->setName('order:autoclose')
->setDescription('自动关闭下单超过后台配置天数仍无师傅接单的订单并退款提醒');
}
protected function execute(Input $input, Output $output)
{
$res = OrderAutoCloseService::closeExpiredOrders(100);
if ($res['days'] <= 0) {
$output->writeln('[OrderAutoclose] 后台配置超时自动关闭天数为 0,功能已关闭');
return;
}
$output->writeln("[OrderAutoclose] 配置天数={$res['days']}天,扫描到 {$res['scanned']} 笔超时未接单订单");
foreach ($res['details'] as $item) {
if ($item['status'] === 'closed') {
$output->writeln(" [OK] 订单 #{$item['order_id']} ({$item['order_no']}) 已自动关闭,退款状态={$item['refund_state']}");
} elseif ($item['status'] === 'error') {
$output->writeln(" [FAIL] 订单 #{$item['order_id']} 处理失败: {$item['error']}");
}
}
$output->writeln("[OrderAutoclose] 执行结束:关闭 {$res['closed']} 笔,退款成功 {$res['refunded']} 笔,退款待重试 {$res['refund_failed']} 笔");
}
}

查看文件

@@ -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();

查看文件

@@ -1,9 +1,13 @@
<?php
return [
'User_id' => '关联用户账号',
'Nickname' => '师傅昵称',
'Realname' => '真实姓名',
'Mobile' => '联系电话',
'Mobile' => '登录手机号',
'Password' => '登录密码',
'Status' => '账号状态',
'Normal' => '正常',
'Disabled' => '已停用',
'Idcard_no' => '身份证号',
'Idcard_front' => '身份证人像面',
'Idcard_back' => '身份证国徽面',
@@ -25,6 +29,7 @@ return [
'Frozen_money' => '履约冻结金额',
'Off' => '已暂停接单',
'On' => '接单中',
'Draft' => '待完善资料',
'Pending' => '待审核',
'Pass' => '已通过',
'Reject' => '未通过',

查看文件

@@ -10,8 +10,8 @@ return [
'Is_read' => '消息已读标记',
'Read_yes' => '已读',
'Read_no' => '未读',
'User' => '普通雇主用户',
'Master' => '入驻签约师傅',
'User' => '用户端会员',
'Master' => '师傅端师傅',
'System' => '系统通知',
'Audit' => '资格审核提醒',
'Remind' => '履约工单提醒',

查看文件

@@ -26,11 +26,15 @@ class Master extends Model
// 追加属性
protected $append = [
'work_status_text',
'verify_status_text'
'verify_status_text',
'status_text'
];
public function getStatusList()
{
return ['normal' => __('Normal'), 'disabled' => __('Disabled')];
}
public function getWorkStatusList()
{
return ['off' => __('Off'), 'on' => __('On')];
@@ -38,7 +42,19 @@ class Master extends Model
public function getVerifyStatusList()
{
return ['pending' => __('Pending'), 'pass' => __('Pass'), 'reject' => __('Reject')];
return [
'draft' => __('Draft'),
'pending' => __('Pending'),
'pass' => __('Pass'),
'reject' => __('Reject'),
];
}
public function getStatusTextAttr($value, $data)
{
$value = $value ?: ($data['status'] ?? 'normal');
$list = $this->getStatusList();
return $list[$value] ?? '';
}
@@ -56,13 +72,4 @@ class Master extends Model
$list = $this->getVerifyStatusList();
return $list[$value] ?? '';
}
public function user()
{
return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}

查看文件

@@ -319,7 +319,7 @@
<!-- 平台在册师傅 -->
<div class="col-xs-12 col-sm-6 col-md-3">
<div class="kpi-deck-card">
<div class="kpi-label">平台认证专业师傅</div>
<div class="kpi-label">平台认证专业师傅(总注册 {$totalMasterAccount})</div>
<div class="kpi-value" style="color: #d97706;">
{$totalMaster} <small style="font-size: 14px; font-weight: normal; color: #64748b;">位</small>
</div>
@@ -328,7 +328,7 @@
</div>
<div class="kpi-meta">
<span>在线可接单: <strong style="color:#16a34a;">{$onlineMaster} 人</strong></span>
<span>待审申请: <strong style="color:#ff6a00;">{$pendingMaster} 位</strong></span>
<span>待审 / 待填资料: <strong style="color:#ff6a00;">{$pendingMaster} / {$draftMaster}</strong></span>
</div>
</div>
</div>

查看文件

@@ -6,22 +6,38 @@
<h4 class="panel-title"><i class="fa fa-user-circle"></i> 账号与基础资料</h4>
</div>
<div class="panel-body">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-user_id" data-rule="required" min="0" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="" placeholder="请选择或搜索关联的用户账号">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Realname')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-realname" data-rule="required" class="form-control" name="row[realname]" type="text" value="" placeholder="请输入师傅真实姓名">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Nickname')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-nickname" class="form-control" name="row[nickname]" type="text" value="" placeholder="选填,默认同步真实姓名">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Mobile')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-mobile" data-rule="required;mobile" class="form-control" name="row[mobile]" type="text" value="" placeholder="请输入师傅联系手机号">
<input id="c-mobile" data-rule="required;mobile" class="form-control" name="row[mobile]" type="text" value="" placeholder="请输入师傅独立登录手机号">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Password')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-password" class="form-control" name="row[password]" type="password" value="" autocomplete="new-password" placeholder="选填,至少6位;留空则仅支持微信/验证码登录">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="statusList" item="vo"}
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="normal"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
</div>
</div>
<div class="form-group">

查看文件

@@ -63,10 +63,15 @@
<div class="row">
<div class="col-xs-12 col-sm-6">
<div class="form-group" style="margin-bottom: 8px;">
<label class="control-label col-xs-4 text-muted">关联平台账号:</label>
<label class="control-label col-xs-4 text-muted">师傅编号与绑定:</label>
<div class="col-xs-8">
<p class="form-control-static">
{$row.user.nickname|default=$row.user.username|default='-'|htmlentities} (UID: {$row.user_id})
<code>#M{$row.id}</code>
{if !empty($wechatBind.openid)}
<span class="label label-success" style="margin-left:6px;"><i class="fa fa-wechat"></i> 已绑定微信</span>
{else/}
<span class="label label-default" style="margin-left:6px;">未绑定微信</span>
{/if}
</p>
</div>
</div>

查看文件

@@ -69,12 +69,19 @@
<img class="md-avatar" src="{$masterAvatarUrl|default='/assets/img/avatar.png'|htmlentities}" onerror="this.src='/assets/img/avatar.png'" />
<div>
<div class="md-info-name">
<span class="name-txt">{$row.realname|htmlentities}</span>
<span class="name-txt">{$row.realname|default=$row.nickname|htmlentities}</span>
{if ($row.status ?? 'normal') == 'normal'}
<span class="label label-success">账号正常</span>
{else/}
<span class="label label-danger">账号已停用</span>
{/if}
{if $row.verify_status == 'pass'}
<span class="label label-success"><i class="fa fa-shield"></i> 实名认证通过</span>
{elseif $row.verify_status == 'pending'/}
<span class="label label-warning"><i class="fa fa-clock-o"></i> 认证待审核</span>
<a href="master/audit?ids={$row.id}" class="btn btn-xs btn-warning btn-dialog" data-area='["920px", "88%"]' title="师傅资质审核 - {$row.realname|htmlentities}" style="color:#fff; margin-left:6px;"><i class="fa fa-check-square-o"></i> 立即审核</a>
{elseif $row.verify_status == 'draft'/}
<span class="label label-default"><i class="fa fa-edit"></i> 待完善资料</span>
{else/}
<span class="label label-danger"><i class="fa fa-times"></i> 认证已驳回</span>
{/if}
@@ -122,12 +129,25 @@
</div>
<div class="md-card-body">
<div class="md-grid-list" style="margin-bottom: 14px;">
<div class="md-item"><span class="md-item-k">真实姓名:</span><span class="md-item-v">{$row.realname|htmlentities}</span></div>
<div class="md-item"><span class="md-item-k">真实姓名:</span><span class="md-item-v">{$row.realname|default='未填写'|htmlentities}</span></div>
<div class="md-item"><span class="md-item-k">身份证号:</span><span class="md-item-v"><code>{$row.idcard_no|default='未登记'|htmlentities}</code></span></div>
<div class="md-item"><span class="md-item-k">关联账号:</span><span class="md-item-v">{$row.user.nickname|default=$row.user.username|default='-'|htmlentities} (ID:{$row.user_id})</span></div>
<div class="md-item"><span class="md-item-k">师傅编号:</span><span class="md-item-v"><code>#M{$row.id}</code> · 昵称: {$row.nickname|default=$row.realname|default='-'|htmlentities}</span></div>
<div class="md-item"><span class="md-item-k">师傅等级:</span><span class="md-item-v">LV.{$row.level}</span></div>
<div class="md-item"><span class="md-item-k">微信绑定:</span><span class="md-item-v">{if !empty($wechatBind.openid)}<span class="label label-success">已绑定</span> <code>{:mb_substr($wechatBind.openid, 0, 6)}****{:mb_substr($wechatBind.openid, -4)}</code>{else/}<span class="label label-default">未绑定微信</span>{/if}</span></div>
<div class="md-item"><span class="md-item-k">安全与会话:</span><span class="md-item-v">{if !empty($securityInfo.payment_password_hash)}<span class="label label-info">已设支付密码</span>{else/}<span class="label label-default">未设支付密码</span>{/if} {if $isLoginLocked || $isPayLocked}<span class="label label-danger">已锁定</span>{/if} · 活跃会话 {$activeTokens}</span></div>
<div class="md-item" style="grid-column: span 2;"><span class="md-item-k">审核批注:</span><span class="md-item-v">{$row.audit_msg|default='资质核验正常'|htmlentities}</span></div>
</div>
<div style="display:flex; gap:8px; flex-wrap:wrap; margin-bottom:14px;">
{if !empty($wechatBind.openid)}
<button type="button" class="btn btn-xs btn-warning btn-master-unbind-wx" data-id="{$row.id}"><i class="fa fa-unlink"></i> 解绑微信授权</button>
{/if}
{if $isLoginLocked || $isPayLocked || ($row.loginfailure ?? 0) > 0 || ($securityInfo.failed_attempts ?? 0) > 0 || ($securityInfo.payment_failed_attempts ?? 0) > 0}
<button type="button" class="btn btn-xs btn-info btn-master-unlock-sec" data-id="{$row.id}"><i class="fa fa-unlock"></i> 解除安全锁定</button>
{/if}
<button type="button" class="btn btn-xs {if ($row.status ?? 'normal') == 'normal'}btn-danger{else/}btn-success{/if} btn-master-toggle-status" data-id="{$row.id}" data-status="{$row.status|default='normal'}">
<i class="fa fa-power-off"></i> {if ($row.status ?? 'normal') == 'normal'}停用师傅账号{else/}恢复启用账号{/if}
</button>
</div>
<div style="font-size: 12px; font-weight: 600; color: #475569; margin-bottom: 8px;">身份证正反面照片:</div>
<div class="idcard-preview-box">

查看文件

@@ -6,22 +6,38 @@
<h4 class="panel-title"><i class="fa fa-user-circle"></i> 账号与基础资料</h4>
</div>
<div class="panel-body">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-user_id" data-rule="required" min="0" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}" placeholder="请选择或搜索关联的用户账号">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Realname')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-realname" data-rule="required" class="form-control" name="row[realname]" type="text" value="{$row.realname|htmlentities}" placeholder="请输入师傅真实姓名">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Nickname')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-nickname" class="form-control" name="row[nickname]" type="text" value="{$row.nickname|default=''|htmlentities}" placeholder="展示昵称">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Mobile')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-mobile" data-rule="required;mobile" class="form-control" name="row[mobile]" type="text" value="{$row.mobile|htmlentities}" placeholder="请输入师傅联系手机号">
<input id="c-mobile" data-rule="required;mobile" class="form-control" name="row[mobile]" type="text" value="{$row.mobile|htmlentities}" placeholder="请输入师傅独立登录手机号">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">重置密码:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-password" class="form-control" name="row[password]" type="password" value="" autocomplete="new-password" placeholder="留空表示不修改;填写至少6位将重置并强制下线">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="statusList" item="vo"}
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
</div>
</div>
<div class="form-group">

查看文件

@@ -3,6 +3,7 @@
{:build_heading(null,FALSE)}
<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 === 'draft' ? 'active' : ''}"><a href="#t-draft" data-value="draft" data-toggle="tab"><i class="fa fa-edit text-muted"></i> 待完善资料</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>

查看文件

@@ -39,9 +39,6 @@
<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}

查看文件

@@ -68,6 +68,7 @@
<div class="col-sm-6 wd-kv"><span class="k">当前提现冻结:</span><strong class="text-warning">¥{$master.frozen_money|default='0.00'|htmlentities}</strong></div>
<div class="col-sm-6 wd-kv"><span class="k">常驻城市:</span>{$master.city|default='-'|htmlentities}</div>
<div class="col-sm-6 wd-kv"><span class="k">履约数据:</span>累计完单 {$master.order_count|default=0} 笔 · <i class="fa fa-star text-warning"></i> {$master.score|default='5.0'}</div>
<div class="col-sm-12 wd-kv" style="margin-bottom:0;"><span class="k">师傅端微信:</span>{if !empty($wechatBind.openid)}<span class="label label-success">已绑定</span> <code>{:mb_substr($wechatBind.openid, 0, 6)}****{:mb_substr($wechatBind.openid, -4)}</code>{else/}<span class="label label-warning">未绑定(无法发起商家转账,需师傅登录师傅端小程序)</span>{/if}</div>
</div>
{else/}
<p class="text-muted" style="margin-bottom:0;">未查询到师傅档案。</p>

查看文件

@@ -88,27 +88,10 @@ class Auth extends Base
{
$uid = $this->uid();
$user = Db::name('user')->field('id,nickname,mobile,email,avatar,money,score,user_type,identity_selected,company_name,company_legal_person,company_legal_mobile,company_tech_mobile,contact_address,createtime')->where('id', $uid)->find();
$master = Db::name('master')->where('user_id', $uid)->find();
$couponCount = Db::name('user_coupon')->where('user_id', $uid)->where('status', 'unused')->count();
$unread = Db::name('message')->where('receive_type', 'user')->where('receive_id', $uid)->where('is_read', 0)->count();
$masterInfo = null;
if ($master) {
$masterInfo = [
'id' => (int)$master['id'],
'realname' => $master['realname'],
'verify_status' => $master['verify_status'],
'audit_msg' => $master['audit_msg'],
'work_status' => $master['work_status'],
'level' => (int)$master['level'],
'score' => (float)$master['score'],
'order_count' => (int)$master['order_count'],
'money' => (float)$master['money'],
'can_take' => $master['verify_status'] === 'pass',
];
}
$merchantRel = $this->merchantOf($uid);
$merchant = $merchantRel ? $merchantRel['merchant'] : null;
$merchantRole = $merchantRel ? $merchantRel['role'] : null;
@@ -175,8 +158,6 @@ class Auth extends Base
'coupon_count' => (int)$couponCount,
'unread_count' => (int)$unread,
'order_counts' => $orderCounts,
'is_master' => $master ? true : false,
'master' => $masterInfo,
'is_merchant' => $merchant ? true : false,
'merchant' => $merchantInfo,
];
@@ -382,44 +363,6 @@ class Auth extends Base
]);
}
public function switchRole()
{
$role = $this->request->post('role', 'user');
if (!in_array($role, ['user', 'master', 'merchant'], true)) {
$this->error('角色参数错误');
}
if ($role === 'master') {
$master = $this->masterInfo();
if (!$master) {
$this->error('请先完成师傅入驻', ['need_apply' => 1], 2001);
}
}
if ($role === 'merchant') {
$merchantRel = $this->merchantOf($this->uid());
$merchant = $merchantRel ? $merchantRel['merchant'] : null;
if (!$merchant) {
$this->error('请先完成商家入驻', ['need_apply' => 1], 2001);
}
if ($merchant['verify_status'] === 'pending') {
$this->error('商家资质审核中,请耐心等待', ['verify_status' => 'pending'], 2002);
}
if ($merchant['verify_status'] === 'reject') {
$this->error('资质未通过:' . $merchant['audit_msg'], ['verify_status' => 'reject'], 2003);
}
}
$redirect = '/pages/index/index';
if ($role === 'master') {
$redirect = '/pages/master/workbench';
} elseif ($role === 'merchant') {
$redirect = '/pages/mine/mine';
}
$this->success('切换成功', ['role' => $role, 'redirect' => $redirect]);
}
/**
* 当前用户的商家归属:主账号 / 关联账号
* 返回 ['merchant' => 商家行, 'role' => owner|member]

查看文件

@@ -7,8 +7,8 @@ use app\common\library\OrderStatus;
use think\Db;
/**
* 业务接口基类
* 统一处理:登录用户注入 / 师傅档案 / 订单归属校验 / 状态流转 / 通知
* 用户端业务接口基类
* 统一处理:登录用户注入 / 订单归属校验 / 状态流转 / 通知
*/
class Base extends Api
{
@@ -18,9 +18,6 @@ class Base extends Api
/** @var mixed 当前登录用户 */
protected $user = null;
/** @var array|false|null 师傅档案:null未查询 / false未入驻 / array已入驻 */
protected $master = null;
protected function _initialize()
{
parent::_initialize();
@@ -56,53 +53,10 @@ class Base extends Api
}
}
/**
* 师傅档案
*/
protected function masterInfo($reload = false)
{
if ($this->uid() <= 0) {
return false;
}
if ($this->master === null || $reload) {
$row = Db::name('master')->where('user_id', $this->uid())->find();
$this->master = $row ? $row : false;
}
return $this->master;
}
/**
* 要求拥有师傅档案,允许查看师傅端。
*/
protected function requireMasterProfile()
{
$master = $this->masterInfo();
if (!$master) {
$this->error('请先完成师傅入驻', ['need_apply' => 1], 2001);
}
return $master;
}
/** 要求师傅通过审核,供接单及敏感操作使用。 */
protected function requireMaster()
{
$master = $this->requireMasterProfile();
if ($master['verify_status'] === 'pending') {
$this->error('师傅资质审核中,请耐心等待', ['verify_status' => 'pending'], 2002);
}
if ($master['verify_status'] === 'reject') {
$this->error('资质未通过:' . $master['audit_msg'], ['verify_status' => 'reject'], 2003);
}
if ($master['verify_status'] !== 'pass') {
$this->error('师傅资质尚未审核通过,无法接单');
}
return $master;
}
/**
* 取本人订单(越权拦截)
* @param int $orderId
* @param string $side user|master
* @param string $side user
*/
protected function ownOrder($orderId, $side = 'user')
{
@@ -114,18 +68,12 @@ class Base extends Api
if (!$order) {
$this->error('订单不存在');
}
if ($side === 'user' && (int)$order['user_id'] !== $this->uid()) {
if ((int)$order['user_id'] !== $this->uid()) {
$team = $this->currentMerchantTeam();
if (!$team || !in_array((int)$order['user_id'], $team['user_ids'], true)) {
$this->error('无权操作该订单', null, 403);
}
}
if ($side === 'master') {
$master = $this->requireMaster();
if ((int)$order['master_id'] !== (int)$master['id']) {
$this->error('无权操作该订单', null, 403);
}
}
return $order;
}

查看文件

@@ -18,7 +18,7 @@ use think\Hook;
*/
class Common extends Api
{
protected $noNeedLogin = ['init', 'captcha', 'areas', 'expressCompanies', 'dicts'];
protected $noNeedLogin = ['init', 'captcha', 'areas', 'expressCompanies', 'dicts', 'upload'];
protected $noNeedRight = '*';
public function _initialize()
@@ -68,6 +68,13 @@ class Common extends Api
*/
public function upload()
{
if (!$this->auth->isLogin()) {
$token = $this->request->server('HTTP_TOKEN', $this->request->request('token', ''));
$masterAuth = \app\common\library\MasterAuth::instance();
if (!$token || !$masterAuth->init($token)) {
$this->error(__('Please login first'), null, 401);
}
}
Config::set('default_return_type', 'json');
//必须设定cdnurl为空,否则cdnurl函数计算错误
Config::set('upload.cdnurl', '');

查看文件

@@ -1622,7 +1622,8 @@ class Home extends Base
public function agreement()
{
$type = trim((string)$this->request->param('type', 'user_service'));
$item = \app\common\library\AgreementService::getByType($type, $this->uid());
list($subjectId, $side) = $this->resolveAgreementSubject();
$item = \app\common\library\AgreementService::getByType($type, $subjectId, $side);
if (!$item) {
$this->error('协议内容暂未配置或已下线');
}
@@ -1631,7 +1632,7 @@ class Home extends Base
}
/**
* 记录用户已首次查看指定修订版本的协议(后续打开不再标背景色)
* 记录用户或师傅已首次查看指定修订版本的协议(后续打开不再标背景色)
*/
public function agreementRead()
{
@@ -1640,10 +1641,27 @@ class Home extends Base
}
$type = trim((string)$this->request->post('type', 'privacy'));
$revision = (int)$this->request->post('revision', 0);
$res = \app\common\library\AgreementService::markUserRead($this->uid(), $type, $revision);
list($subjectId, $side) = $this->resolveAgreementSubject();
$res = \app\common\library\AgreementService::markUserRead($subjectId, $type, $revision, $side);
$this->success('', $res);
}
protected function resolveAgreementSubject()
{
if ($this->uid() > 0) {
return [$this->uid(), 'user'];
}
$token = $this->request->server('HTTP_TOKEN', $this->request->request('token', ''));
if ($token) {
$masterAuth = \app\common\library\MasterAuth::instance();
if ($masterAuth->init($token)) {
return [(int)$masterAuth->id(), 'master'];
}
}
$reqSide = trim((string)$this->request->param('side', ''));
return [0, $reqSide === 'master' ? 'master' : 'user'];
}
/**
* 官方系统图库(受下单所选类目控制,仅展示对应类目下的商品及参考图片;同源聚合系统图库表 + 细分规格图 + 商品主缩略图)
*/
@@ -1841,11 +1859,15 @@ class Home extends Base
*/
public function serviceConfig()
{
$userMini = \app\common\library\WxLogin::getMiniAppConfig('user');
$masterMini = \app\common\library\WxLogin::getMiniAppConfig('master');
$this->success('', [
'service_phone' => trim((string)(\think\Config::get('site.service_phone') ?: '')),
'service_work_time' => trim((string)(\think\Config::get('site.service_work_time') ?: '')),
'service_corp_id' => trim((string)(\think\Config::get('site.service_corp_id') ?: '')),
'service_kf_url' => trim((string)(\think\Config::get('site.service_kf_url') ?: '')),
'user_appid' => $userMini['appid'],
'master_appid' => $masterMini['appid'],
]);
}
}

查看文件

@@ -14,11 +14,11 @@ use app\common\library\WxPayV3Service;
use think\Db;
/**
* 师傅端:入驻 / 订单大厅 / 抢单 / 履约流转 / 收入
* 师傅端:入驻 / 订单大厅 / 抢单 / 履约流转 / 收入(继承独立 MasterBase,完全脱离 fa_user)
*/
class Master extends Base
class Master extends MasterBase
{
protected $noNeedLogin = [];
protected $noNeedLogin = ['hall', 'orderDetail', 'resolveLocation'];
/**
* 师傅入驻申请
@@ -94,10 +94,20 @@ class Master extends Base
$this->error('请至少选择一个服务类目');
}
$exist = Db::name('master')->where('user_id', $this->uid())->find();
if ($exist && $exist['verify_status'] === 'pass') {
$mid = $this->masterId();
$exist = Db::name('master')->where('id', $mid)->find();
if (!$exist) {
$this->error('师傅账号不存在,请重新登录');
}
if ($exist['verify_status'] === 'pass') {
$this->error('您已是认证师傅,无需重复入驻');
}
if ($mobile !== (string)($exist['mobile'] ?? '')) {
$conflict = Db::name('master')->where('mobile', $mobile)->where('id', '<>', $mid)->find();
if ($conflict) {
$this->error('该手机号已被其他师傅账号绑定,请更换手机号');
}
}
// 若是驳回后重提且未修改脱敏展示号,沿用原存储的完整身份证号;否则校验完整身份证号并真实入库
if (strpos($rawIdcard, '*') !== false) {
@@ -134,32 +144,27 @@ class Master extends Base
$catNameMap = Db::name('service_cat')->where('id', 'in', $skillCatIds)->column('name', 'id');
$save = [
'realname' => mb_substr($realname, 0, 50),
'mobile' => $mobile,
'idcard_no' => $finalIdcard,
'idcard_front' => $idcardFront,
'idcard_back' => $idcardBack,
'cert_images' => $certImages,
'city' => $normalizedCity,
'work_status' => 'off',
'verify_status' => 'pending',
'audit_msg' => '',
'audittime' => null,
'realname' => mb_substr($realname, 0, 50),
'nickname' => !empty($exist['nickname']) && strpos((string)$exist['nickname'], '师傅') !== 0 ? (string)$exist['nickname'] : mb_substr($realname, 0, 50),
'mobile' => $mobile,
'idcard_no' => $finalIdcard,
'idcard_front' => $idcardFront,
'idcard_back' => $idcardBack,
'cert_images' => $certImages,
'city' => $normalizedCity,
'work_status' => 'off',
'verify_status' => 'pending',
'audit_msg' => '',
'audittime' => null,
'audit_admin_id' => 0,
'updatetime' => time(),
'updatetime' => time(),
];
Db::startTrans();
try {
if ($exist) {
$masterId = (int)$exist['id'];
Db::name('master')->where('id', $masterId)->update($save);
Db::name('master_skill')->where('master_id', $masterId)->delete();
} else {
$save['user_id'] = $this->uid();
$save['createtime'] = time();
$masterId = Db::name('master')->insertGetId($save);
}
$masterId = $mid;
Db::name('master')->where('id', $masterId)->update($save);
Db::name('master_skill')->where('master_id', $masterId)->delete();
foreach ($skillCatIds as $catId) {
$cName = isset($catNameMap[$catId]) ? (string)$catNameMap[$catId] : '';
Db::name('master_skill')->insert([
@@ -217,8 +222,17 @@ class Master extends Base
public function info()
{
$master = $this->masterInfo();
if (!$master) {
$this->success('未入驻', ['applied' => false]);
if (!$master || ($master['verify_status'] ?? 'draft') === 'draft') {
$this->success('未入驻', [
'applied' => false,
'master' => $master ? [
'id' => (int)$master['id'],
'nickname' => (string)($master['nickname'] ?? ''),
'mobile' => (string)($master['mobile'] ?? ''),
'avatar' => !empty($master['avatar']) ? \app\common\library\MasterAvatar::url($master['avatar']) : '',
'verify_status' => 'draft',
] : null,
]);
}
$skillsRaw = Db::name('master_skill')->alias('s')
->join('service_cat c', 'c.id = s.cat_id', 'LEFT')
@@ -298,13 +312,19 @@ class Master extends Base
if (!preg_match('/^1\d{10}$/', $mobile)) {
$this->error('请输入正确的接单手机号');
}
if ($mobile !== (string)($master['mobile'] ?? '')) {
$conflict = Db::name('master')->where('mobile', $mobile)->where('id', '<>', (int)$master['id'])->find();
if ($conflict) {
$this->error('该手机号已被其他师傅账号绑定');
}
}
$update = ['mobile' => $mobile, 'updatetime' => time()];
$avatar = trim((string)$this->request->post('avatar', ''));
if ($avatar !== '') {
$this->validateAvatar($avatar);
$update['avatar'] = $avatar;
}
Db::name('master')->where('id', (int)$master['id'])->where('user_id', $this->uid())->update($update);
Db::name('master')->where('id', (int)$master['id'])->update($update);
$this->success('保存成功');
}
@@ -403,6 +423,41 @@ class Master extends Base
]);
}
/**
* 免登录只读位置逆解析(供未登录游客进大厅自动定位显示省市区与地标,不写库)
* @ApiMethod (GET)
*/
public function resolveLocation()
{
$rawLat = $this->request->param('lat', '');
$rawLng = $this->request->param('lng', '');
if (!$this->isValidCoord($rawLat, $rawLng)) {
$this->error('定位坐标无效');
}
$lat = round((float)$rawLat, 6);
$lng = round((float)$rawLng, 6);
$resolvedCity = '';
$resolvedDistrict = '';
$resolvedPoi = '';
$geo = TiandituService::regeocoder($lat, $lng);
if (is_array($geo)) {
$resolvedCity = trim((string)($geo['city'] ?: ($geo['province'] ?? '')));
$resolvedDistrict = trim((string)($geo['district'] ?? ''));
$resolvedPoi = trim((string)($geo['poi'] ?? ''));
}
$locationLabel = trim($resolvedCity . $resolvedDistrict . ($resolvedPoi !== '' ? ('·' . $resolvedPoi) : ''));
$this->success('', [
'lat' => $lat,
'lng' => $lng,
'location_city' => $resolvedCity,
'location_district' => $resolvedDistrict,
'location_label' => $locationLabel,
]);
}
/**
* 地点关键词检索(供定位受限或手动切换听单区域使用)
* @ApiMethod (GET)
@@ -545,14 +600,14 @@ class Master extends Base
}
/**
* 订单大厅:支持基于定位的智能推荐、离我最近与多种排序及单类型筛选
* 订单大厅:支持已认证师傅接单筛选,及未登录游客免登录公开脱敏浏览
*/
public function hall()
{
$master = $this->requireMasterProfile();
$master = $this->masterInfo();
$this->recycleExpired();
$catIds = $this->getMasterSkillCatIds((int)$master['id']);
$catIds = $master ? $this->getMasterSkillCatIds((int)$master['id']) : [];
$page = max(1, (int)$this->request->param('page', 1));
$limit = min(30, max(1, (int)$this->request->param('limit', 10)));
$sort = trim((string)$this->request->param('sort', 'recommend')); // recommend 智能推荐 / distance 离我最近 / new 最新 / amount 报酬 / urgent 急单 / time 时效
@@ -751,10 +806,12 @@ class Master extends Base
}
$now = time();
$qualificationCerts = OrderQualification::certificates((int)$master['id']);
$qualificationCerts = $master ? OrderQualification::certificates((int)$master['id']) : [];
$qualificationToday = date('Y-m-d');
foreach ($list as &$row) {
$row['qualification_allowed'] = OrderQualification::allows($row['qual_req'], $qualificationCerts, $qualificationToday);
$row['qualification_allowed'] = $master
? OrderQualification::allows($row['qual_req'], $qualificationCerts, $qualificationToday)
: true;
unset($row['verify_code'], $row['_has_coord'], $row['_dist_km'], $row['_same_city']);
$row['appoint_text'] = $row['appoint_time'] ? date('Y-m-d H:i', (int)$row['appoint_time']) : '接单后与业主预约';
$row['pay_amount'] = (float)$row['pay_amount'];
@@ -764,7 +821,15 @@ class Master extends Base
$row['commission'] = $hallSettleCalc['commission'];
$row['master_fee'] = $hallSettleCalc['settle_amount'];
$row['urgent'] = (int)$row['urgent'];
$row['mobile'] = substr_replace($row['mobile'], '****', 3, 4);
if (!$master) {
// 未登录浏览仅展示脱敏区域信息与项目,严禁下发客户手机与姓名全称
$row['user_id'] = 0;
$row['mobile'] = '';
$rawContact = trim((string)($row['contact'] ?? ''));
$row['contact'] = $rawContact !== '' ? (mb_substr($rawContact, 0, 1) . '**') : '业主';
} else {
$row['mobile'] = substr_replace($row['mobile'], '****', 3, 4);
}
$rawAddr = (string)$row['address'];
$maskedAddr = preg_replace('/\d+栋|\d+单元|\d+室|\d+号楼/', '**', $rawAddr);
@@ -873,6 +938,7 @@ class Master extends Base
'location_source' => $reqHasValidCoord ? 'realtime' : ($dbHasValidCoord ? 'saved' : 'none'),
'location_city' => $locationCity,
'serve_radius' => $serveRadius,
'guest_mode' => !$master,
'filter_options' => ['categories' => $filterCategories, 'service_types' => $filterTypes],
]);
}
@@ -892,9 +958,6 @@ class Master extends Base
if (!$order) {
$this->error('订单不存在');
}
if ((int)$order['user_id'] === (int)$this->uid()) {
$this->error('不能承接或报价自己发布的订单');
}
if ($order['price_type'] === 'quote') {
$this->error('该订单为师傅报价订单,请提交报价');
}
@@ -935,7 +998,7 @@ class Master extends Base
*/
public function contact()
{
$order = $this->ownOrder((int)$this->request->post('order_id'), 'master');
$order = $this->ownOrder((int)$this->request->post('order_id'));
if ((int)$order['contact_time'] > 0) {
$this->success('已记录');
}
@@ -950,7 +1013,7 @@ class Master extends Base
*/
public function schedule()
{
$order = $this->ownOrder((int)$this->request->post('order_id'), 'master');
$order = $this->ownOrder((int)$this->request->post('order_id'));
if (!in_array((int)$order['status'], [OrderStatus::ACCEPTED, OrderStatus::APPOINTED], true)) {
$this->error('当前状态(' . OrderStatus::label((int)$order['status']) . ')不可修改预约时间');
}
@@ -977,7 +1040,7 @@ class Master extends Base
*/
public function arrive()
{
$order = $this->ownOrder((int)$this->request->post('order_id'), 'master');
$order = $this->ownOrder((int)$this->request->post('order_id'));
$lng = trim((string)$this->request->post('lng', ''));
$lat = trim((string)$this->request->post('lat', ''));
$extra = ['arrive_time' => time()];
@@ -1002,7 +1065,7 @@ class Master extends Base
*/
public function startJob()
{
$order = $this->ownOrder((int)$this->request->post('order_id'), 'master');
$order = $this->ownOrder((int)$this->request->post('order_id'));
$this->transit($order, OrderStatus::WORKING, '师傅开始施工', ['start_time' => time()], 'master', (int)$order['master_id']);
$this->notify('user', (int)$order['user_id'], '师傅已开工', '师傅已开始服务,请留意进度', 'order', (int)$order['id']);
$this->success('已开工');
@@ -1014,7 +1077,7 @@ class Master extends Base
*/
public function finish()
{
$order = $this->ownOrder((int)$this->request->post('order_id'), 'master');
$order = $this->ownOrder((int)$this->request->post('order_id'));
$images = FinishImageUrls::normalize((array)$this->request->post('images/a', []));
$damage = trim((string)$this->request->post('damage_remark', ''));
@@ -1315,9 +1378,6 @@ class Master extends Base
if (!$order) {
$this->error('订单不存在');
}
if ((int)$order['user_id'] === (int)$this->uid()) {
$this->error('不能承接或报价自己发布的订单');
}
if ($order['price_type'] !== 'quote') {
$this->error('该订单不是报价竞价订单');
}
@@ -1393,7 +1453,7 @@ class Master extends Base
$openid = '';
if ($channel === 'wechat' && $wdCfg['transfer_mode'] === 'wx_mch_transfer') {
try {
$openid = PaymentService::resolveUserOpenid($this->uid(), $wxCode);
$openid = PaymentService::resolveMasterOpenid($this->masterId(), $wxCode);
} catch (\Throwable $oe) {
$this->error($oe->getMessage());
return;
@@ -1542,7 +1602,7 @@ class Master extends Base
$this->error('当前提现单状态(' . PaymentService::transferStateLabel($wd['transfer_state']) . ')暂不可拉起确认收款,请稍后重试');
}
$wxSvc = new WxPayV3Service();
$wxSvc = new WxPayV3Service(['side' => 'master']);
$this->success('', [
'already_done' => false,
'withdraw_id' => (int)$wd['id'],
@@ -2029,8 +2089,8 @@ class Master extends Base
public function orderDetail()
{
$master = $this->requireMasterProfile();
$masterId = (int)$master['id'];
$master = $this->masterInfo();
$masterId = $master ? (int)$master['id'] : 0;
$orderId = (int)$this->request->param('id') ?: (int)$this->request->param('order_id');
if ($orderId <= 0) {
$this->error('参数错误');
@@ -2061,7 +2121,9 @@ class Master extends Base
$mobile = (string)$order['mobile'];
$address = (string)$order['address'];
if (!$isMyOrder) {
$mobile = strlen($mobile) >= 7 ? substr_replace($mobile, '****', 3, 4) : $mobile;
$mobile = $masterId > 0
? (strlen($mobile) >= 7 ? substr_replace($mobile, '****', 3, 4) : $mobile)
: '';
$address = preg_replace('/\d+号|\d+栋|\d+单元|\d+室/', '***', $address);
if (mb_strlen($address) > 10) {
$address = mb_substr($address, 0, 8) . '****号';
@@ -2347,7 +2409,9 @@ class Master extends Base
$estCommission = $estCalc['commission'];
$estMasterFee = $estCalc['settle_amount'];
$qualificationAllowed = OrderQualification::forMaster($order['qual_req'] ?? '', $masterId);
$qualificationAllowed = $masterId > 0
? OrderQualification::forMaster($order['qual_req'] ?? '', $masterId)
: true;
$data = [
'id' => (int)$order['id'],
'order_no' => $order['order_no'],
@@ -2410,8 +2474,8 @@ class Master extends Base
'description' => $myQuote['description'],
'status' => $myQuote['status'],
] : null,
'can_grab' => ($qualificationAllowed && $order['price_type'] !== 'quote' && (int)$order['status'] === OrderStatus::PENDING_ACCEPT && (int)$order['master_id'] === 0 && (int)$order['user_id'] !== $this->uid()),
'can_quote' => ($qualificationAllowed && $order['price_type'] === 'quote' && in_array((int)$order['status'], [OrderStatus::PENDING_ACCEPT, OrderStatus::QUOTING], true) && (int)$order['master_id'] === 0 && !$myQuote && (int)$order['user_id'] !== $this->uid()),
'can_grab' => ($qualificationAllowed && $order['price_type'] !== 'quote' && (int)$order['status'] === OrderStatus::PENDING_ACCEPT && (int)$order['master_id'] === 0),
'can_quote' => ($qualificationAllowed && $order['price_type'] === 'quote' && in_array((int)$order['status'], [OrderStatus::PENDING_ACCEPT, OrderStatus::QUOTING], true) && (int)$order['master_id'] === 0 && !$myQuote),
];
// 本人已接工单:附带完整履约节点、增项补差、完工取证、结算入账与操作轨迹
@@ -3365,5 +3429,41 @@ class Master extends Base
];
}
}
/**
* 师傅端我的评价列表
*/
public function reviews()
{
$master = $this->requireMasterProfile();
$masterId = (int)$master['id'];
$list = Db::name('review')
->alias('r')
->join('user u', 'u.id = r.user_id', 'LEFT')
->field('r.id,r.score,r.tags,r.content,r.images,r.is_anonymous,r.reply,r.createtime,u.nickname,u.avatar')
->where('r.master_id', $masterId)
->where('r.status', 'normal')
->order('r.id desc')
->limit(50)
->select();
foreach ($list as &$row) {
if ((int)$row['is_anonymous'] === 1) {
$row['nickname'] = '匿名用户';
$row['avatar'] = '';
}
$row['time_text'] = date('Y-m-d H:i', (int)$row['createtime']);
}
unset($row);
$stat = Db::name('review')->where('master_id', $masterId)->where('status', 'normal')
->field('count(*) as total, avg(score) as avg_score')->find();
$this->success('', [
'list' => $list,
'total' => (int)$stat['total'],
'avg_score' => round((float)$stat['avg_score'], 2),
]);
}
}

查看文件

@@ -0,0 +1,334 @@
<?php
namespace app\api\controller;
use app\common\library\MasterSecurity;
use app\common\library\MasterToken;
use app\common\library\WxLogin;
use think\Db;
/**
* 师傅端独立登录 / 安全凭证 / 个人信息接口(完全独立于 fa_user)
*/
class MasterAuth extends MasterBase
{
protected $noNeedLogin = ['login', 'wxlogin', 'wxPhoneLogin'];
/**
* 师傅手机号 + 密码登录(H5调试/账号密码通道)
* @ApiMethod (POST)
*/
public function login()
{
$mobile = trim((string)$this->request->post('mobile', $this->request->post('account', '')));
$mobile = preg_replace('/[^\d]/', '', $mobile);
$password = (string)$this->request->post('password', '');
$code = trim((string)$this->request->post('code', ''));
if ($password === '' && $code !== '') {
$this->error('短信验证码通道已移除,请使用手机号密码或微信一键登录', null, 2010);
}
if ($mobile === '') {
$this->error('请填写手机号');
}
if (!preg_match('/^1[3-9]\d{9}$/', $mobile)) {
$this->error('手机号格式不正确');
}
if ($password === '') {
$this->error('请填写登录密码');
}
$master = Db::name('master')->where('mobile', $mobile)->find();
if (!$master) {
if (!preg_match('/^\S{6,30}$/', $password)) {
$this->error('登录密码须为6至30位非空字符');
}
if (!$this->masterAuth->register($mobile, $password)) {
$this->error($this->masterAuth->getError() ?: '注册登录失败');
}
} else {
if (isset($master['status']) && $master['status'] !== 'normal') {
$this->error('师傅账号已被禁用');
}
if (empty($master['password'])) {
$this->error('该师傅账号尚未设置登录密码,请使用微信一键登录后在账号安全中设置密码');
}
try {
MasterSecurity::verify((int)$master['id'], 'login', $password);
} catch (\Throwable $e) {
$this->error($e->getMessage() === '密码不正确' ? '手机号或密码不正确' : $e->getMessage());
}
if (!$this->masterAuth->direct((int)$master['id'])) {
$this->error($this->masterAuth->getError() ?: '登录失败');
}
}
$this->success('登录成功', [
'token' => $this->masterAuth->getToken(),
'expires' => 2592000,
'masterinfo' => $this->profileData(),
]);
}
/**
* 师傅端微信小程序 OpenID 静默/授权登录
* @ApiMethod (POST)
*/
public function wxlogin()
{
$code = trim((string)$this->request->post('code'));
$nickname = trim((string)$this->request->post('nickname'));
$avatar = trim((string)$this->request->post('avatar'));
if ($code === '') {
$this->error('缺少微信登录凭证 code');
}
$wx = WxLogin::jscode2session($code, 'master');
if (isset($wx['error'])) {
$this->error($wx['error'], ['wx_errcode' => isset($wx['errcode']) ? (int)$wx['errcode'] : 0]);
}
$ret = WxLogin::provisionMaster(
$wx['openid'],
isset($wx['unionid']) ? $wx['unionid'] : '',
isset($wx['session_key']) ? $wx['session_key'] : '',
$nickname,
$avatar
);
if (!$this->masterAuth->direct($ret['master_id'])) {
$this->error($this->masterAuth->getError() ?: '登录失败');
}
$this->success('登录成功', [
'token' => $this->masterAuth->getToken(),
'expires' => 2592000,
'masterinfo' => $this->profileData(),
'is_new' => $ret['is_new'],
]);
}
/**
* 师傅端微信手机号授权快捷登录
* @ApiMethod (POST)
*/
public function wxPhoneLogin()
{
$phoneCode = trim((string)$this->request->post('phone_code'));
$loginCode = trim((string)$this->request->post('login_code'));
if ($phoneCode === '') {
$this->error('缺少微信手机号授权凭证');
}
$phoneInfo = WxLogin::getPhoneNumber($phoneCode, 'master');
if (isset($phoneInfo['error'])) {
$this->error('获取微信手机号失败:' . $phoneInfo['error'], ['wx_errcode' => isset($phoneInfo['errcode']) ? (int)$phoneInfo['errcode'] : 0]);
}
$mobile = isset($phoneInfo['purePhoneNumber']) ? (string)$phoneInfo['purePhoneNumber'] : (string)($phoneInfo['phoneNumber'] ?? '');
if ($mobile === '') {
$this->error('解析手机号失败');
}
$openid = '';
$sessionKey = '';
$unionid = '';
if ($loginCode !== '') {
$wx = WxLogin::jscode2session($loginCode, 'master');
if (isset($wx['error']) || empty($wx['openid'])) {
$errMsg = isset($wx['error']) && $wx['error'] !== '' ? (string)$wx['error'] : '微信登录凭证换取 OpenID 失败,请重进小程序再试';
\think\Log::error('[MasterAuth::wxPhoneLogin] jscode2session 失败: ' . $errMsg);
$this->error($errMsg, ['wx_errcode' => isset($wx['errcode']) ? (int)$wx['errcode'] : 0]);
}
$openid = $wx['openid'];
$sessionKey = isset($wx['session_key']) ? $wx['session_key'] : '';
$unionid = isset($wx['unionid']) ? $wx['unionid'] : '';
}
$ret = WxLogin::provisionMasterWithMobile($mobile, $openid, $unionid, $sessionKey);
if (!$this->masterAuth->direct($ret['master_id'])) {
$this->error($this->masterAuth->getError() ?: '登录失败');
}
$this->success('登录成功', [
'token' => $this->masterAuth->getToken(),
'expires' => 2592000,
'masterinfo' => $this->profileData(),
'is_new' => $ret['is_new'],
'mobile' => $mobile,
]);
}
/**
* 当前登录师傅基础信息
*/
public function profile()
{
$this->success('', $this->profileData());
}
/**
* 退出登录
* @ApiMethod (POST)
*/
public function logout()
{
$this->masterAuth->logout();
$this->success('已退出登录');
}
/**
* 安全状态查询(登录密码 / 支付密码)
*/
public function securityStatus()
{
$mid = $this->masterId();
$master = Db::name('master')->field('password,mobile')->where('id', $mid)->find();
$security = Db::name('master_security')->where('master_id', $mid)->find();
$this->success('', [
'has_login_password' => !empty($master['password']),
'has_payment_password' => $security && $security['payment_password_hash'] !== '',
]);
}
/**
* 设置或修改师傅登录密码
* @ApiMethod (POST)
*/
public function changeLoginPassword()
{
$mid = $this->masterId();
$new = (string)$this->request->post('new_password', '');
$old = (string)$this->request->post('old_password', '');
if (!preg_match('/^\S{6,30}$/', $new)) {
$this->error('登录密码须为6至30位非空字符');
}
$master = Db::name('master')->field('password,mobile')->where('id', $mid)->find();
if (!empty($master['password'])) {
try {
MasterSecurity::verify($mid, 'login', $old);
} catch (\Throwable $e) {
$this->error($e->getMessage());
}
$ignoreOld = false;
} else {
$this->verifyBoundPhone($this->request->post('phone_code', ''), (string)$master['mobile']);
$ignoreOld = true;
}
if (!$this->masterAuth->changepwd($new, $old, $ignoreOld)) {
$this->error($this->masterAuth->getError() ?: '设置失败');
}
MasterToken::clear($mid);
$this->success('登录密码已更新,请重新登录');
}
/**
* 首次设置师傅支付密码(支持已设登录密码走登录密码验证,或未设登录密码走绑定微信手机号验证)
* @ApiMethod (POST)
*/
public function setPaymentPassword()
{
$mid = $this->masterId();
$new = (string)$this->request->post('new_password', '');
if (!preg_match('/^\d{6}$/', $new)) {
$this->error('支付密码须为6位数字');
}
$master = Db::name('master')->field('password,mobile')->where('id', $mid)->find();
$phoneCode = trim((string)$this->request->post('phone_code', ''));
if ($phoneCode !== '') {
$this->verifyBoundPhone($phoneCode, (string)($master['mobile'] ?? ''));
} elseif (!empty($master['password'])) {
try {
MasterSecurity::verify($mid, 'login', (string)$this->request->post('login_password', ''));
} catch (\Throwable $e) {
$this->error($e->getMessage());
}
} else {
$this->error('请先验证绑定手机号或设置登录密码');
}
MasterSecurity::ensure($mid);
$updated = Db::name('master_security')
->where('master_id', $mid)
->where('payment_password_hash', '')
->update(['payment_password_hash' => password_hash($new, PASSWORD_DEFAULT)]);
if (!$updated) {
$this->error('支付密码已设置,请使用修改功能');
}
$this->success('支付密码设置成功');
}
/**
* 修改师傅支付密码
* @ApiMethod (POST)
*/
public function changePaymentPassword()
{
$mid = $this->masterId();
$new = (string)$this->request->post('new_password', '');
if (!preg_match('/^\d{6}$/', $new)) {
$this->error('支付密码须为6位数字');
}
$oldHash = (string)Db::name('master_security')->where('master_id', $mid)->value('payment_password_hash');
try {
MasterSecurity::verify($mid, 'payment', (string)$this->request->post('old_password', ''));
} catch (\Throwable $e) {
$this->error($e->getMessage());
}
$updated = Db::name('master_security')
->where('master_id', $mid)
->where('payment_password_hash', $oldHash)
->update(['payment_password_hash' => password_hash($new, PASSWORD_DEFAULT)]);
if (!$updated) {
$this->error('支付密码已变更,请重新操作');
}
$this->success('支付密码修改成功');
}
protected function verifyBoundPhone($code, $mobile)
{
if (trim((string)$code) === '') {
$this->error('请先验证绑定的微信手机号');
}
$phone = WxLogin::getPhoneNumber((string)$code, 'master');
$verified = isset($phone['purePhoneNumber']) ? (string)$phone['purePhoneNumber'] : (string)($phone['phoneNumber'] ?? '');
if (isset($phone['error']) || $verified === '' || !hash_equals((string)$mobile, $verified)) {
$this->error('手机号验证失败,请使用绑定手机号重新验证');
}
}
protected function profileData()
{
$mid = $this->masterId();
$master = Db::name('master')->where('id', $mid)->find();
if (!$master) {
return null;
}
$unread = (int)Db::name('message')
->where('receive_type', 'master')
->where('receive_id', $mid)
->where('is_read', 0)
->count();
return [
'id' => (int)$master['id'],
'nickname' => !empty($master['nickname']) ? (string)$master['nickname'] : (!empty($master['realname']) ? (string)$master['realname'] : ('师傅' . substr((string)$master['mobile'], -4))),
'realname' => (string)$master['realname'],
'mobile' => (string)$master['mobile'],
'avatar' => !empty($master['avatar']) ? \app\common\library\MasterAvatar::url($master['avatar']) : '',
'city' => (string)$master['city'],
'verify_status' => (string)$master['verify_status'],
'audit_msg' => (string)$master['audit_msg'],
'work_status' => (string)$master['work_status'],
'level' => (int)$master['level'],
'score' => (float)$master['score'],
'order_count' => (int)$master['order_count'],
'money' => (float)$master['money'],
'frozen_money' => (float)$master['frozen_money'],
'can_take' => $master['verify_status'] === 'pass',
'needs_apply' => ($master['verify_status'] === 'draft'),
'unread_count' => $unread,
];
}
}

查看文件

@@ -0,0 +1,216 @@
<?php
namespace app\api\controller;
use app\common\controller\Api;
use app\common\library\MasterAuth;
use app\common\library\MasterSecurity;
use app\common\library\OrderStatus;
use think\Config;
use think\Db;
use think\Loader;
/**
* 师傅端 API 基类(完全独立于 fa_user,仅校验 fa_master_token -> fa_master)
*/
class MasterBase extends Api
{
protected $noNeedLogin = [];
protected $noNeedRight = '*';
/** @var MasterAuth */
protected $masterAuth = null;
/** @var array|null 当前登录师傅行记录 */
protected $master = null;
protected function _initialize()
{
check_cors_request();
check_ip_allowed();
$this->request->filter('trim,strip_tags,htmlspecialchars');
$this->masterAuth = MasterAuth::instance();
$controllername = Loader::parseName($this->request->controller());
$actionname = strtolower($this->request->action());
$token = $this->request->server('HTTP_TOKEN', $this->request->request('token', \think\Cookie::get('master_token')));
$needLogin = true;
$arr = array_map('strtolower', (array)$this->noNeedLogin);
if (in_array('*', $arr, true) || in_array($actionname, $arr, true)) {
$needLogin = false;
}
if ($needLogin) {
$this->masterAuth->init($token);
if (!$this->masterAuth->isLogin()) {
$this->error(__('Please login first'), null, 401);
}
} elseif ($token) {
$this->masterAuth->init($token);
}
$this->master = $this->masterAuth->getMaster();
$upload = \app\common\model\Config::upload();
\think\Hook::listen('upload_config_init', $upload);
Config::set('upload', array_merge(Config::get('upload'), $upload));
$this->loadlang($controllername);
}
/**
* 当前登录师傅 ID
*/
protected function masterId()
{
return (int)$this->masterAuth->id();
}
/**
* 获取当前登录师傅完整档案
*/
protected function masterInfo($reload = false)
{
if ($this->masterId() <= 0) {
return false;
}
if ($this->master === null || $reload) {
$this->master = $this->masterAuth->reload();
}
return $this->master ?: false;
}
/**
* 要求师傅已提交过实名入驻资料(非 draft 草稿态)
*/
protected function requireMasterProfile()
{
$master = $this->masterInfo();
if (!$master || ($master['verify_status'] ?? 'draft') === 'draft') {
$this->error('请先完成师傅入驻', ['need_apply' => 1], 2001);
}
return $master;
}
/**
* 要求师傅已通过实名认证,供接单/报价/提现等敏感操作使用
*/
protected function requireMaster()
{
$master = $this->requireMasterProfile();
if ($master['verify_status'] === 'pending') {
$this->error('师傅资质审核中,请耐心等待', ['verify_status' => 'pending'], 2002);
}
if ($master['verify_status'] === 'reject') {
$this->error('资质未通过:' . $master['audit_msg'], ['verify_status' => 'reject'], 2003);
}
if ($master['verify_status'] !== 'pass') {
$this->error('师傅资质尚未审核通过,无法接单');
}
return $master;
}
/**
* 校验支付密码(用于提现)
*/
protected function requirePaymentPassword()
{
try {
MasterSecurity::verify($this->masterId(), 'payment', (string)$this->request->post('payment_password', ''));
} catch (\Throwable $e) {
$this->error($e->getMessage());
}
}
/**
* 验证新头像属于当前师傅账号,且符合大小与格式要求
*/
protected function validateAvatar($url)
{
$attachment = Db::name('attachment')
->where('master_id', $this->masterId())
->where('category', 'avatar')
->where('url', $url)
->find();
if (
!$attachment
|| (int)$attachment['filesize'] > 10 * 1024 * 1024
|| !in_array(strtolower((string)$attachment['mimetype']), ['image/jpeg', 'image/png', 'image/gif', 'image/webp', 'image/bmp'], true)
) {
$this->error('头像无效,请重新上传不超过10MB的图片');
}
}
/**
* 取本师傅订单(越权拦截)
*/
protected function ownOrder($orderId)
{
$orderId = (int)$orderId;
if ($orderId <= 0) {
$this->error('订单参数错误');
}
$order = Db::name('order')->where('id', $orderId)->find();
if (!$order) {
$this->error('订单不存在');
}
$master = $this->requireMaster();
if ((int)$order['master_id'] !== (int)$master['id']) {
$this->error('无权操作该订单', null, 403);
}
return $order;
}
/**
* 订单状态流转:校验 -> 乐观锁更新 -> 写流水
*/
protected function transit(array $order, $to, $remark = '', $extra = [], $operatorType = 'master', $operatorId = 0)
{
$from = (int)$order['status'];
if (!OrderStatus::can($from, $to)) {
$this->error('订单状态「' . OrderStatus::label($from) . '」不允许变更为「' . OrderStatus::label($to) . '」');
}
$data = array_merge($extra, [
'status' => (int)$to,
'updatetime' => time(),
]);
$updated = Db::name('order')->where('id', (int)$order['id'])->where('status', $from)->update($data);
if (!$updated) {
$this->error('订单状态已变更,请刷新后重试');
}
$this->addLog((int)$order['id'], (int)$to, $remark, $operatorType, $operatorId ?: $this->masterId());
return array_merge($order, $data);
}
protected function addLog($orderId, $status, $remark = '', $operatorType = 'master', $operatorId = 0)
{
Db::name('order_log')->insert([
'order_id' => (int)$orderId,
'status' => (int)$status,
'remark' => mb_substr((string)$remark, 0, 255),
'operator_type' => $operatorType,
'operator_id' => (int)$operatorId,
'createtime' => time(),
]);
}
protected function notify($receiveType, $receiveId, $title, $content, $type = 'order', $orderId = 0)
{
if (!$receiveId) {
return;
}
Db::name('message')->insert([
'receive_type' => $receiveType,
'receive_id' => (int)$receiveId,
'type' => $type,
'title' => mb_substr((string)$title, 0, 100),
'content' => mb_substr((string)$content, 0, 500),
'order_id' => (int)$orderId,
'is_read' => 0,
'createtime' => time(),
]);
}
}

查看文件

@@ -0,0 +1,82 @@
<?php
namespace app\api\controller;
use think\Db;
/**
* 师傅端独立消息中心(严格隔离仅操作 receive_type = 'master' 且 receive_id = master_id)
*/
class MasterMessage extends MasterBase
{
public function index()
{
$category = $this->request->param('category', 'all');
$page = max(1, (int)$this->request->param('page', 1));
$limit = min(50, max(1, (int)$this->request->param('limit', 20)));
$mid = $this->masterId();
$build = function () use ($mid, $category) {
$q = Db::name('message')->where('receive_type', 'master')->where('receive_id', $mid);
if ($category !== 'all' && $category !== '') {
$q->where('type', $category);
}
return $q;
};
$total = $build()->count();
$list = $build()->order('id desc')->page($page, $limit)->select();
foreach ($list as &$row) {
$row['time_text'] = date('m-d H:i', (int)$row['createtime']);
$row['is_read'] = (int)$row['is_read'];
}
unset($row);
$this->success('', [
'list' => $list,
'total' => (int)$total,
'unread' => $this->unreadCount($mid),
'page' => $page,
]);
}
public function read()
{
$id = (int)$this->request->post('id');
$mid = $this->masterId();
$row = Db::name('message')->where('id', $id)->where('receive_type', 'master')->where('receive_id', $mid)->find();
if (!$row) {
$this->error('消息不存在');
}
Db::name('message')->where('id', $id)->update(['is_read' => 1]);
$this->success('已读');
}
public function readAll()
{
$mid = $this->masterId();
$affected = Db::name('message')
->where('receive_type', 'master')
->where('receive_id', $mid)
->where('is_read', 0)
->update(['is_read' => 1]);
$this->success('已全部标记为已读', ['count' => (int)$affected]);
}
public function unread()
{
$this->success('', ['unread' => $this->unreadCount($this->masterId())]);
}
protected function unreadCount($mid)
{
if ($mid <= 0) {
return 0;
}
return (int)Db::name('message')
->where('receive_type', 'master')
->where('receive_id', $mid)
->where('is_read', 0)
->count();
}
}

查看文件

@@ -5,27 +5,19 @@ namespace app\api\controller;
use think\Db;
/**
* 消息中心(用户 / 师傅共用)
* 用户端消息中心(仅限 user 身份,师傅端使用 MasterMessage)
*/
class Message extends Base
{
/**
* 消息列表
* @ApiParams (name="type", type="string", required=false, description="user|master,默认 user")
* @ApiParams (name="category", type="string", required=false, description="all|order|system|audit|remind")
*/
public function index()
{
$type = $this->request->param('type', 'user');
$type = $type === 'master' ? 'master' : 'user';
$category = $this->request->param('category', 'all');
$page = max(1, (int)$this->request->param('page', 1));
$limit = min(50, max(1, (int)$this->request->param('limit', 20)));
$receiveId = $this->receiveId($type);
$build = function () use ($type, $receiveId, $category) {
$q = Db::name('message')->where('receive_type', $type)->where('receive_id', $receiveId);
$uid = $this->uid();
$build = function () use ($uid, $category) {
$q = Db::name('message')->where('receive_type', 'user')->where('receive_id', $uid);
if ($category !== 'all' && $category !== '') {
$q->where('type', $category);
}
@@ -42,24 +34,19 @@ class Message extends Base
unset($row);
$this->success('', [
'list' => $list,
'total' => (int)$total,
'unread' => $this->unreadCount($type, $receiveId),
'page' => $page,
'list' => $list,
'total' => (int)$total,
'unread' => $this->unreadCount($uid),
'page' => $page,
]);
}
/**
* 标记单条已读
* @ApiMethod (POST)
*/
public function read()
{
$id = (int)$this->request->post('id');
$type = $this->request->post('type', 'user') === 'master' ? 'master' : 'user';
$receiveId = $this->receiveId($type);
$uid = $this->uid();
$row = Db::name('message')->where('id', $id)->where('receive_type', $type)->where('receive_id', $receiveId)->find();
$row = Db::name('message')->where('id', $id)->where('receive_type', 'user')->where('receive_id', $uid)->find();
if (!$row) {
$this->error('消息不存在');
}
@@ -67,48 +54,27 @@ class Message extends Base
$this->success('已读');
}
/**
* 全部标记已读
* @ApiMethod (POST)
*/
public function readAll()
{
$type = $this->request->post('type', 'user') === 'master' ? 'master' : 'user';
$receiveId = $this->receiveId($type);
$uid = $this->uid();
$affected = Db::name('message')
->where('receive_type', $type)->where('receive_id', $receiveId)->where('is_read', 0)
->where('receive_type', 'user')->where('receive_id', $uid)->where('is_read', 0)
->update(['is_read' => 1]);
$this->success('已全部标记为已读', ['count' => (int)$affected]);
}
/**
* 未读数(供 Tab 角标)
*/
public function unread()
{
$type = $this->request->param('type', 'user') === 'master' ? 'master' : 'user';
$this->success('', ['unread' => $this->unreadCount($type, $this->receiveId($type))]);
$this->success('', ['unread' => $this->unreadCount($this->uid())]);
}
/**
* 消息归属ID:用户=uid,师傅=master.id
*/
protected function receiveId($type)
protected function unreadCount($uid)
{
if ($type === 'master') {
$master = $this->masterInfo();
return $master ? (int)$master['id'] : 0;
}
return $this->uid();
}
protected function unreadCount($type, $receiveId)
{
if (!$receiveId) {
if (!$uid) {
return 0;
}
return (int)Db::name('message')
->where('receive_type', $type)->where('receive_id', $receiveId)->where('is_read', 0)
->where('receive_type', 'user')->where('receive_id', $uid)->where('is_read', 0)
->count();
}
}

查看文件

@@ -88,11 +88,14 @@ class Review extends Base
{
$masterId = (int)$this->request->param('master_id');
if ($masterId <= 0) {
$master = $this->masterInfo();
if (!$master) {
$token = $this->request->server('HTTP_TOKEN', $this->request->request('token', ''));
$masterAuth = \app\common\library\MasterAuth::instance();
if ($token && $masterAuth->init($token)) {
$masterId = (int)$masterAuth->id();
}
if ($masterId <= 0) {
$this->error('师傅不存在');
}
$masterId = (int)$master['id'];
}
$list = Db::name('review')
->alias('r')

查看文件

@@ -19,6 +19,7 @@ return [
'app\admin\command\Api',
'app\admin\command\AttachmentScan',
'app\admin\command\OrderAutoverify',
'app\admin\command\OrderAutoclose',
'app\admin\command\OrderRecycle',
'app\admin\command\OrderRefundRetry',
];

查看文件

@@ -178,7 +178,7 @@ class AgreementService
/**
* 按前端请求的 type 读取单条启用协议(API 使用,含变更首看高亮判断)
*/
public static function getByType(string $type, int $userId = 0): ?array
public static function getByType(string $type, int $subjectId = 0, string $side = 'user'): ?array
{
$rawType = trim($type);
$code = self::canonicalCode($rawType);
@@ -217,8 +217,8 @@ class AgreementService
$hasDiff = ($revision > 1 && trim($diffContent) !== '');
$showDiff = false;
if ($hasDiff) {
if ($userId > 0) {
$readRevision = self::getUserReadRevision($userId, $code);
if ($subjectId > 0) {
$readRevision = self::getUserReadRevision($subjectId, $code, $side);
$showDiff = ($readRevision < $revision);
} else {
// 未登录游客由前端结合本机已阅修订版本进行首看门控
@@ -270,18 +270,25 @@ class AgreementService
}
/**
* 查询登录用户已查看过的协议最高修订序号
* 查询登录用户或师傅已查看过的协议最高修订序号
*/
public static function getUserReadRevision(int $userId, string $code): int
public static function getUserReadRevision(int $subjectId, string $code, string $side = 'user'): int
{
if ($userId <= 0 || $code === '') {
if ($subjectId <= 0 || $code === '') {
return 0;
}
try {
$rev = Db::name('agreement_read')
->where('user_id', $userId)
->where('agreement_code', $code)
->value('read_revision');
if ($side === 'master') {
$rev = Db::name('master_agreement_read')
->where('master_id', $subjectId)
->where('agreement_code', $code)
->value('read_revision');
} else {
$rev = Db::name('agreement_read')
->where('user_id', $subjectId)
->where('agreement_code', $code)
->value('read_revision');
}
return $rev ? (int)$rev : 0;
} catch (\Throwable $e) {
return 0;
@@ -289,9 +296,9 @@ class AgreementService
}
/**
* 标记登录用户已首次查看当前变更版协议,防止后续打开重复高亮
* 标记登录用户或师傅已首次查看当前变更版协议,防止后续打开重复高亮
*/
public static function markUserRead(int $userId, string $type, int $revision = 0): array
public static function markUserRead(int $subjectId, string $type, int $revision = 0, string $side = 'user'): array
{
$code = self::canonicalCode($type);
$currentRev = 1;
@@ -305,7 +312,7 @@ class AgreementService
}
$targetRevision = ($revision > 0 && $revision <= $currentRev) ? $revision : $currentRev;
if ($userId <= 0) {
if ($subjectId <= 0) {
return [
'recorded' => false,
'code' => $code,
@@ -315,14 +322,16 @@ class AgreementService
$now = time();
$prefix = (string)Config::get('database.prefix');
$table = $prefix . 'agreement_read';
$isMaster = ($side === 'master');
$table = $prefix . ($isMaster ? 'master_agreement_read' : 'agreement_read');
$idCol = $isMaster ? 'master_id' : 'user_id';
Db::execute(
"INSERT INTO `{$table}` (`user_id`, `agreement_code`, `read_revision`, `read_time`, `createtime`, `updatetime`) "
. "VALUES (:uid, :code, :rev, :rtime, :ctime, :utime) "
"INSERT INTO `{$table}` (`{$idCol}`, `agreement_code`, `read_revision`, `read_time`, `createtime`, `updatetime`) "
. "VALUES (:sid, :code, :rev, :rtime, :ctime, :utime) "
. "ON DUPLICATE KEY UPDATE `read_revision` = GREATEST(`read_revision`, VALUES(`read_revision`)), "
. "`read_time` = VALUES(`read_time`), `updatetime` = VALUES(`updatetime`)",
[
'uid' => $userId,
'sid' => $subjectId,
'code' => $code,
'rev' => $targetRevision,
'rtime' => $now,
@@ -334,7 +343,7 @@ class AgreementService
return [
'recorded' => true,
'code' => $code,
'read_revision' => self::getUserReadRevision($userId, $code),
'read_revision' => self::getUserReadRevision($subjectId, $code, $side),
];
}

查看文件

@@ -0,0 +1,267 @@
<?php
namespace app\common\library;
use fast\Random;
use think\Db;
use think\Exception;
/**
* 师傅端独立认证服务(基于 fa_master 与 fa_master_token,完全不依赖 fa_user)
*/
class MasterAuth
{
protected static $instance = null;
protected $_error = '';
protected $_logined = false;
protected $_master = null;
protected $_token = '';
protected $keeptime = 2592000;
public static function instance()
{
if (is_null(self::$instance)) {
self::$instance = new static();
}
return self::$instance;
}
public function id()
{
return $this->_master ? (int)$this->_master['id'] : 0;
}
public function getMaster()
{
return $this->_master;
}
public function isLogin()
{
return $this->_logined;
}
public function getToken()
{
return $this->_token;
}
public function getError()
{
return $this->_error;
}
public function setError($error)
{
$this->_error = (string)$error;
return $this;
}
public function getEncryptPassword($password, $salt = '')
{
return md5(md5((string)$password) . (string)$salt);
}
/**
* 根据 Token 初始化师傅登录态
*/
public function init($token)
{
if ($this->_logined) {
return true;
}
if ($this->_error) {
return false;
}
$data = MasterToken::get($token);
if (!$data) {
return false;
}
$masterId = (int)$data['master_id'];
if ($masterId <= 0) {
$this->setError('请先登录师傅账号');
return false;
}
$master = Db::name('master')->where('id', $masterId)->find();
if (!$master) {
$this->setError('师傅账号不存在');
return false;
}
if (isset($master['status']) && $master['status'] !== 'normal') {
$this->setError('师傅账号已被禁用');
return false;
}
$this->_master = $master;
$this->_logined = true;
$this->_token = $token;
return true;
}
/**
* 直接登录指定师傅账号(签发独立师傅 Token)
*/
public function direct($masterId)
{
$master = Db::name('master')->where('id', (int)$masterId)->find();
if (!$master) {
$this->setError('师傅账号不存在');
return false;
}
if (isset($master['status']) && $master['status'] !== 'normal') {
$this->setError('师傅账号已被禁用');
return false;
}
Db::startTrans();
try {
$now = time();
$ip = request()->ip();
$update = [
'prevtime' => $master['logintime'] ?: $now,
'logintime' => $now,
'loginip' => $ip,
'loginfailure' => 0,
'updatetime' => $now,
];
Db::name('master')->where('id', (int)$master['id'])->update($update);
$master = array_merge($master, $update);
$this->_master = $master;
$this->_token = $this->generateToken((int)$master['id']);
$this->_logined = true;
MasterSecurity::ensure((int)$master['id']);
Db::commit();
} catch (\Throwable $e) {
Db::rollback();
$this->setError($e->getMessage());
return false;
}
return true;
}
/**
* 手机号 + 密码注册并登录独立师傅账号(默认 verify_status=draft)
*/
public function register($mobile, $password)
{
$mobile = trim((string)$mobile);
if (Db::name('master')->where('mobile', $mobile)->find()) {
$this->setError('该手机号已注册师傅账号');
return false;
}
$now = time();
$ip = request()->ip();
$salt = Random::alnum();
$encrypt = $this->getEncryptPassword($password, $salt);
Db::startTrans();
try {
$masterId = (int)Db::name('master')->insertGetId([
'mobile' => $mobile,
'nickname' => '师傅' . substr($mobile, -4),
'realname' => '',
'password' => $encrypt,
'salt' => $salt,
'verify_status' => 'draft',
'work_status' => 'off',
'status' => 'normal',
'level' => 1,
'score' => 5.00,
'accept_rate' => 100.00,
'ontime_rate' => 100.00,
'serve_radius' => 10,
'money' => 0.00,
'frozen_money' => 0.00,
'prevtime' => $now,
'logintime' => $now,
'loginip' => $ip,
'createtime' => $now,
'updatetime' => $now,
]);
MasterSecurity::ensure($masterId);
$this->_master = Db::name('master')->where('id', $masterId)->find();
$this->_token = $this->generateToken($masterId);
$this->_logined = true;
Db::commit();
} catch (\Throwable $e) {
Db::rollback();
$this->setError($e->getMessage());
return false;
}
return true;
}
/**
* 退出登录
*/
public function logout()
{
if (!$this->_logined) {
$this->setError('尚未登录');
return false;
}
$this->_logined = false;
MasterToken::delete($this->_token);
$this->_master = null;
$this->_token = '';
return true;
}
/**
* 修改登录密码
*/
public function changepwd($newpassword, $oldpassword = '', $ignoreOld = false)
{
if (!$this->_logined || !$this->_master) {
$this->setError('请先登录');
return false;
}
$masterId = (int)$this->_master['id'];
if (!$ignoreOld) {
if ($this->_master['password'] !== $this->getEncryptPassword($oldpassword, $this->_master['salt'])) {
$this->setError('原登录密码不正确');
return false;
}
}
Db::startTrans();
try {
$salt = Random::alnum();
$encrypted = $this->getEncryptPassword($newpassword, $salt);
Db::name('master')->where('id', $masterId)->update([
'loginfailure' => 0,
'password' => $encrypted,
'salt' => $salt,
'updatetime' => time(),
]);
MasterToken::clear($masterId);
Db::commit();
} catch (\Throwable $e) {
Db::rollback();
$this->setError($e->getMessage());
return false;
}
return true;
}
/**
* 刷新当前内存缓存的师傅行
*/
public function reload()
{
if ($this->id() > 0) {
$this->_master = Db::name('master')->where('id', $this->id())->find();
}
return $this->_master;
}
private function generateToken($masterId)
{
$maxAttempts = 5;
for ($i = 0; $i < $maxAttempts; $i++) {
$token = Random::uuid();
if (MasterToken::set($token, $masterId, $this->keeptime)) {
return $token;
}
}
throw new Exception('生成师傅登录令牌失败');
}
}

查看文件

@@ -0,0 +1,61 @@
<?php
namespace app\common\library;
use think\Db;
/**
* 师傅端独立安全凭证校验与防暴力破解锁定(读写 fa_master_security 与 fa_master)
*/
class MasterSecurity
{
public static function ensure($masterId)
{
$prefix = config('database.prefix');
if (!preg_match('/^[A-Za-z0-9_]+$/', $prefix)) {
throw new \RuntimeException('数据库配置错误');
}
Db::execute("INSERT IGNORE INTO `{$prefix}master_security` (`master_id`) VALUES (?)", [(int)$masterId]);
}
public static function verify($masterId, $kind, $password)
{
if (!in_array($kind, ['login', 'payment'], true)) {
throw new \InvalidArgumentException('验证类型错误');
}
$masterId = (int)$masterId;
$attemptsField = $kind === 'payment' ? 'payment_failed_attempts' : 'failed_attempts';
$lockedField = $kind === 'payment' ? 'payment_locked_until' : 'locked_until';
self::ensure($masterId);
Db::startTrans();
try {
$row = Db::name('master_security')->where('master_id', $masterId)->lock(true)->find();
if ((int)$row[$lockedField] > time()) {
throw new \RuntimeException('密码错误次数过多,请15分钟后重试');
}
if ($kind === 'login') {
$master = Db::name('master')->field('password,salt')->where('id', $masterId)->find();
$correct = $master && $master['password'] !== '' && hash_equals((string)$master['password'], md5(md5($password) . $master['salt']));
} else {
if ($row['payment_password_hash'] === '') {
throw new \RuntimeException('请先在账号安全中设置支付密码');
}
$correct = password_verify($password, $row['payment_password_hash']);
}
$failures = $correct ? 0 : (int)$row[$attemptsField] + 1;
Db::name('master_security')->where('master_id', $masterId)->update([
$attemptsField => $failures >= 5 ? 0 : $failures,
$lockedField => $failures >= 5 ? time() + 900 : 0,
]);
Db::commit();
} catch (\Throwable $e) {
Db::rollback();
throw $e;
}
if (!$correct) {
throw new \RuntimeException($failures >= 5 ? '密码错误次数过多,请15分钟后重试' : '密码不正确');
}
return true;
}
}

查看文件

@@ -0,0 +1,111 @@
<?php
namespace app\common\library;
use think\Config;
use think\Db;
/**
* 师傅端独立 Token 操作类(物理隔离于用户端 fa_user_token,读写 fa_master_token)
*/
class MasterToken
{
/**
* 计算加密后的 Token
*/
protected static function encrypt($token)
{
$config = Config::get('token');
$algo = !empty($config['hashalgo']) ? $config['hashalgo'] : 'ripemd160';
$key = isset($config['key']) ? (string)$config['key'] : '';
return hash_hmac($algo, (string)$token, $key);
}
/**
* 清理过期 Token(每天至多清理一次)
*/
protected static function gc()
{
$time = time();
$lastGc = cache('master_tokentime');
if (!$lastGc || $lastGc < $time - 86400) {
cache('master_tokentime', $time);
Db::name('master_token')->where('expiretime', '<', $time)->where('expiretime', '>', 0)->delete();
}
}
/**
* 写入师傅 Token
*/
public static function set($token, $masterId, $expire = 2592000)
{
self::gc();
$encrypted = self::encrypt($token);
$exists = Db::name('master_token')->where('token', $encrypted)->count();
if ($exists) {
return false;
}
$expiretime = !is_null($expire) && (int)$expire !== 0 ? time() + (int)$expire : 0;
Db::name('master_token')->insert([
'token' => $encrypted,
'master_id' => (int)$masterId,
'createtime' => time(),
'expiretime' => $expiretime,
]);
return true;
}
/**
* 读取师傅 Token 数据
*/
public static function get($token)
{
if (!$token) {
return [];
}
$data = Db::name('master_token')->where('token', self::encrypt($token))->find();
if (!$data) {
return [];
}
if (!$data['expiretime'] || (int)$data['expiretime'] > time()) {
$data['token'] = $token;
$data['expires_in'] = $data['expiretime'] ? max(0, (int)$data['expiretime'] - time()) : 365 * 86400;
return $data;
}
self::delete($token);
return [];
}
/**
* 校验 Token 是否属于指定师傅
*/
public static function check($token, $masterId)
{
$data = self::get($token);
return $data && (int)$data['master_id'] === (int)$masterId;
}
/**
* 删除单个 Token
*/
public static function delete($token)
{
if (!$token) {
return false;
}
Db::name('master_token')->where('token', self::encrypt($token))->delete();
return true;
}
/**
* 清除指定师傅全部 Token
*/
public static function clear($masterId)
{
if ((int)$masterId <= 0) {
return false;
}
Db::name('master_token')->where('master_id', (int)$masterId)->delete();
return true;
}
}

查看文件

@@ -0,0 +1,263 @@
<?php
namespace app\common\library;
use think\Db;
use think\Log;
/**
* 超时未接单订单自动关闭服务
*/
class OrderAutoCloseService
{
/** 允许自动关闭的未接单状态集合 */
const CLOSEABLE_STATUSES = [
OrderStatus::PENDING_PAY,
OrderStatus::PENDING_ACCEPT,
OrderStatus::QUOTING,
];
/**
* 读取后台配置的超时未接单自动关闭天数(开关关闭或天数为 0 表示关闭该功能)
*
* @return int
*/
public static function getCloseDays()
{
$switchVal = Db::name('config')->where('name', 'order_unaccepted_close_switch')->value('value');
if ($switchVal === null || $switchVal === '') {
$switchVal = config('site.order_unaccepted_close_switch');
}
if ($switchVal !== null && $switchVal !== '' && (int)$switchVal === 0) {
return 0;
}
$val = Db::name('config')->where('name', 'order_unaccepted_close_days')->value('value');
if ($val === null || $val === '') {
$val = config('site.order_unaccepted_close_days');
}
return max(0, (int)$val);
}
/**
* 扫描并自动关闭超时未接单订单
*
* @param int $limit 单次最大处理条数
* @param int|null $overrideDays 覆盖配置天数(主要用于测试或手动指定)
* @return array
*/
public static function closeExpiredOrders($limit = 100, $overrideDays = null)
{
$days = $overrideDays !== null ? max(0, (int)$overrideDays) : self::getCloseDays();
$result = [
'days' => $days,
'scanned' => 0,
'closed' => 0,
'refunded' => 0,
'refund_failed' => 0,
'details' => [],
];
if ($days <= 0) {
return $result;
}
$now = time();
$threshold = $now - ($days * 86400);
$limit = max(1, (int)$limit);
$orders = Db::name('order')
->whereIn('status', self::CLOSEABLE_STATUSES)
->where('master_id', 0)
->where('createtime', '>', 0)
->where('createtime', '<=', $threshold)
->field('id')
->order('id asc')
->limit($limit)
->select();
$result['scanned'] = count($orders);
foreach ($orders as $row) {
$itemResult = self::closeSingleOrder((int)$row['id'], $days, $threshold, $now);
if ($itemResult['status'] === 'closed') {
$result['closed']++;
if ($itemResult['refund_state'] === 'success') {
$result['refunded']++;
} elseif ($itemResult['refund_state'] === 'failed') {
$result['refund_failed']++;
}
}
$result['details'][] = $itemResult;
}
return $result;
}
/**
* 关闭单笔超时未接单订单:事务内仅做状态流转与本地数据回滚,事务外执行退款与消息通知
*
* @param int $orderId
* @param int $days
* @param int $threshold
* @param int $now
* @return array
*/
public static function closeSingleOrder($orderId, $days, $threshold, $now)
{
$orderId = (int)$orderId;
$reason = "下单超过{$days}天未有师傅接单,系统自动关闭";
$lockedOrder = null;
$needRefund = false;
Db::startTrans();
try {
$lockedOrder = Db::name('order')->where('id', $orderId)->lock(true)->find();
if (
!$lockedOrder
|| (int)$lockedOrder['master_id'] !== 0
|| !in_array((int)$lockedOrder['status'], self::CLOSEABLE_STATUSES, true)
|| !OrderStatus::can((int)$lockedOrder['status'], OrderStatus::CANCELLED)
|| (int)$lockedOrder['createtime'] <= 0
|| (int)$lockedOrder['createtime'] > $threshold
) {
Db::rollback();
return ['order_id' => $orderId, 'status' => 'skipped', 'refund_state' => 'none'];
}
if (isset($lockedOrder['invoice_status']) && in_array($lockedOrder['invoice_status'], ['wait', 'issued'], true)) {
Db::rollback();
Log::warning("[OrderAutoCloseService] 订单 #{$orderId} 处于开票流程中,跳过自动关闭");
return ['order_id' => $orderId, 'status' => 'skipped', 'refund_state' => 'none'];
}
$fromStatus = (int)$lockedOrder['status'];
$updated = Db::name('order')
->where('id', $orderId)
->where('status', $fromStatus)
->where('master_id', 0)
->update([
'status' => OrderStatus::CANCELLED,
'cancel_reason' => mb_substr($reason, 0, 255),
'updatetime' => $now,
]);
if (!$updated) {
Db::rollback();
return ['order_id' => $orderId, 'status' => 'skipped', 'refund_state' => 'none'];
}
// 退还已占用的优惠券
if ((int)$lockedOrder['coupon_id'] > 0) {
Db::name('user_coupon')
->where('id', (int)$lockedOrder['coupon_id'])
->where('user_id', (int)$lockedOrder['user_id'])
->where('order_id', $orderId)
->where('status', 'used')
->update([
'status' => 'unused',
'use_time' => 0,
'order_id' => 0,
]);
}
// 竞价单将等待中的报价标记为已过期
if ($lockedOrder['price_type'] === 'quote') {
Db::name('order_quote')
->where('order_id', $orderId)
->where('status', 'wait')
->update(['status' => 'expired']);
}
Db::name('order_log')->insert([
'order_id' => $orderId,
'status' => OrderStatus::CANCELLED,
'remark' => $reason,
'operator_type' => 'system',
'operator_id' => 0,
'createtime' => $now,
]);
$needRefund = ((int)$lockedOrder['pay_status'] === 1 && (float)$lockedOrder['pay_amount'] > 0);
Db::commit();
} catch (\Throwable $e) {
Db::rollback();
Log::error("[OrderAutoCloseService] 关闭订单 #{$orderId} 异常:" . $e->getMessage());
return [
'order_id' => $orderId,
'status' => 'error',
'refund_state' => 'none',
'error' => $e->getMessage(),
];
}
// 事务外执行原路退款与消息提醒
$refundState = 'none';
$userId = (int)$lockedOrder['user_id'];
$orderNo = (string)$lockedOrder['order_no'];
$payAmount = number_format((float)$lockedOrder['pay_amount'], 2, '.', '');
if ($needRefund) {
try {
PaymentService::refundOrder($orderId, $reason);
PaymentService::syncCancelledOrderRefund($orderId);
$refundState = 'success';
self::notifyUser(
$userId,
$orderId,
'订单超时自动关闭及退款通知',
"您的订单 {$orderNo} 因下单超过 {$days} 天未有师傅接单已自动关闭,实付金额 ¥{$payAmount} 已发起原路退款,请注意查收。",
$now
);
} catch (\Throwable $re) {
$refundState = 'failed';
Log::error("[OrderAutoCloseService] 订单 #{$orderId} 自动退款异常:" . $re->getMessage());
try {
PaymentService::syncCancelledOrderRefund($orderId);
} catch (\Throwable $se) {
Log::error("[OrderAutoCloseService] 订单 #{$orderId} 同步退款状态异常:" . $se->getMessage());
}
self::notifyUser(
$userId,
$orderId,
'订单超时自动关闭通知',
"您的订单 {$orderNo} 因下单超过 {$days} 天未有师傅接单已自动关闭,退款正在系统重试处理中,如有疑问请联系客服。",
$now
);
}
} else {
self::notifyUser(
$userId,
$orderId,
'订单超时自动关闭通知',
"您的订单 {$orderNo} 因下单超过 {$days} 天未有师傅接单已自动关闭。",
$now
);
}
return [
'order_id' => $orderId,
'order_no' => $orderNo,
'status' => 'closed',
'refund_state' => $refundState,
];
}
/**
* 发送用户站内信提醒
*/
protected static function notifyUser($userId, $orderId, $title, $content, $now)
{
if ((int)$userId <= 0) {
return;
}
Db::name('message')->insert([
'receive_type' => 'user',
'receive_id' => (int)$userId,
'type' => 'order',
'title' => mb_substr((string)$title, 0, 100),
'content' => mb_substr((string)$content, 0, 500),
'order_id' => (int)$orderId,
'is_read' => 0,
'createtime' => $now,
]);
}
}

查看文件

@@ -108,6 +108,74 @@ class PaymentService
throw new \InvalidArgumentException('未获取到当前微信授权信息(OpenID 缺失),请在微信小程序内打开并登录后再操作');
}
/**
* 解析并严格校验当前操作师傅的师傅端小程序 OpenID(操作 fa_master_wechat,与用户端完全隔离)
*
* @param int $masterId 当前登录师傅 ID
* @param string $wxCode 师傅端小程序实时获取的 wx.login code
* @return string
*/
public static function resolveMasterOpenid($masterId, $wxCode = '')
{
$masterId = (int)$masterId;
$wxCode = trim((string)$wxCode);
if ($wxCode !== '') {
$wx = WxLogin::jscode2session($wxCode, 'master');
if (!is_array($wx) || !empty($wx['error']) || empty($wx['openid'])) {
$errMsg = (is_array($wx) && !empty($wx['error']))
? (string)$wx['error']
: '获取师傅端微信身份标识(OpenID)失败,请在师傅端小程序内重新登录后再试';
Log::error("[PaymentService::resolveMasterOpenid] jscode2session 失败 master_id={$masterId}: {$errMsg}");
throw new \RuntimeException($errMsg);
}
$liveOpenid = trim((string)$wx['openid']);
$unionid = isset($wx['unionid']) ? trim((string)$wx['unionid']) : '';
$sessionKey = isset($wx['session_key']) ? trim((string)$wx['session_key']) : '';
$now = time();
$existByOpenid = Db::name('master_wechat')->where('openid', $liveOpenid)->find();
if ($existByOpenid) {
$boundMid = (int)$existByOpenid['master_id'];
if ($boundMid > 0 && $boundMid !== $masterId) {
Log::error("[PaymentService::resolveMasterOpenid] OpenID归属冲突 current_mid={$masterId}, bound_mid={$boundMid}");
throw new \InvalidArgumentException('当前微信号已绑定其他师傅账号(师傅ID:' . $boundMid . '),请确认登录账号与微信号一致后再操作');
}
Db::name('master_wechat')->where('id', (int)$existByOpenid['id'])->update([
'master_id' => $masterId,
'unionid' => $unionid !== '' ? $unionid : (string)$existByOpenid['unionid'],
'session_key' => $sessionKey !== '' ? $sessionKey : (string)$existByOpenid['session_key'],
'updatetime' => $now,
]);
} else {
Db::name('master_wechat')->insert([
'master_id' => $masterId,
'openid' => $liveOpenid,
'unionid' => $unionid,
'session_key' => $sessionKey,
'createtime' => $now,
'updatetime' => $now,
]);
}
return $liveOpenid;
}
if ($masterId > 0) {
$bind = Db::name('master_wechat')
->where('master_id', $masterId)
->where('openid', '<>', '')
->order('updatetime desc, id desc')
->find();
if ($bind && !empty($bind['openid'])) {
return trim((string)$bind['openid']);
}
}
throw new \InvalidArgumentException('未获取到师傅端微信授权信息(OpenID 缺失),请在师傅端微信小程序内打开并登录后再操作');
}
/**
* 用户端统一发起微信 JSAPI 支付(覆盖 order 首单支付 / quote 选师傅报价支付 / diff 施工增项补差价支付)
*
@@ -1219,11 +1287,11 @@ class PaymentService
throw new \InvalidArgumentException('提现师傅档案不存在');
}
// 解析收款师傅微信 OpenID(优先读提现单快照,其次查微信绑定表)
// 解析收款师傅微信 OpenID(优先读提现单快照,其次查师傅端独立绑定表 fa_master_wechat)
$openid = trim((string)($wd['openid'] ?? ''));
if ($openid === '' && (int)$master['user_id'] > 0) {
$bind = Db::name('user_wechat')
->where('user_id', (int)$master['user_id'])
if ($openid === '') {
$bind = Db::name('master_wechat')
->where('master_id', (int)$master['id'])
->where('openid', '<>', '')
->order('updatetime desc, id desc')
->find();
@@ -1232,7 +1300,7 @@ class PaymentService
}
}
if ($openid === '') {
$msg = '该师傅尚未绑定微信小程序授权(缺少收款 OpenID),请提醒师傅在微信小程序内登录打开「我的钱包」后再试';
$msg = '该师傅尚未绑定师傅端微信小程序授权(缺少收款 OpenID),请提醒师傅在师傅端小程序内登录打开「我的钱包」后再试';
self::recordWithdrawFailure($withdrawId, 'OPENID_MISSING', $msg);
throw new \InvalidArgumentException($msg);
}
@@ -1269,9 +1337,9 @@ class PaymentService
]);
}
// 事务外调用微信支付 APIv3 发起商家转账(动态读取独立配置中心报备参数)
// 事务外调用微信支付 APIv3 发起商家转账(使用师傅端 AppID 与配置)
$wdCfg = FinanceConfigService::getWithdrawConfig();
$wxSvc = new WxPayV3Service();
$wxSvc = new WxPayV3Service(['side' => 'master']);
try {
$resp = $wxSvc->createTransferBill([
'out_bill_no' => $outBillNo,
@@ -1385,9 +1453,9 @@ class PaymentService
$arrStr = number_format((float)$lockedWd['arrive_amount'], 2, '.', '');
self::sendMasterAndUserMessage(
(int)$master['id'],
(int)$master['user_id'],
0,
'提现已汇出,请确认收款',
"您的提现申请 ¥{$amtStr}(实际到账 ¥{$arrStr})已通过审核并发起微信转账,请在 24 小时内打开小程序「我的钱包」点击「确认收款」入账微信零钱。"
"您的提现申请 ¥{$amtStr}(实际到账 ¥{$arrStr})已通过审核并发起微信转账,请在 24 小时内打开师傅端小程序「我的钱包」点击「确认收款」入账微信零钱。"
);
Db::commit();
@@ -1424,7 +1492,7 @@ class PaymentService
}
if ($wxBillData === null) {
$wxSvc = new WxPayV3Service();
$wxSvc = new WxPayV3Service(['side' => 'master']);
try {
$wxBillData = $wxSvc->queryTransferBill($outBillNo);
} catch (\Throwable $qe) {
@@ -1512,7 +1580,7 @@ class PaymentService
]);
self::sendMasterAndUserMessage(
$masterId,
(int)$master['user_id'],
0,
'提现已到账微信零钱',
'您的提现 ¥' . $amount . '(实到 ¥' . $lockedWd['arrive_amount'] . ')已成功确认收款并入账微信零钱。'
);
@@ -1565,7 +1633,7 @@ class PaymentService
]);
self::sendMasterAndUserMessage(
$masterId,
(int)$master['user_id'],
0,
'提现未完成退回余额通知',
'您的提现申请 ¥' . $amount . ' 未完成入账(原因:' . $reasonText . '),资金已自动解冻退回您的钱包可用余额,可随时重新发起提现。'
);
@@ -1685,7 +1753,7 @@ class PaymentService
]);
self::sendMasterAndUserMessage(
$masterId,
(int)$master['user_id'],
0,
'提现申请已驳回',
'您的提现申请 ¥' . $amount . ' 未通过财务审核:' . $auditMsg . ',申请金额已退回钱包余额。'
);
@@ -1699,7 +1767,7 @@ class PaymentService
// 2. 已存在商户转账单号时:先实时向微信查单,确认为已失败/已撤销/微信侧不存在后,方可解冻退款(严防双重资损)
$outBillNo = (string)$wd['out_bill_no'];
$wxSvc = new WxPayV3Service();
$wxSvc = new WxPayV3Service(['side' => 'master']);
try {
$wxBill = $wxSvc->queryTransferBill($outBillNo);
} catch (\Throwable $qe) {
@@ -1818,7 +1886,7 @@ class PaymentService
]);
self::sendMasterAndUserMessage(
$masterId,
(int)$master['user_id'],
0,
'提现申请已退回余额',
'您的提现申请 ¥' . $amount . ' 已驳回退回(批注:' . $auditMsg . '),申请金额已全额退回钱包可用余额。'
);
@@ -2146,12 +2214,27 @@ class PaymentService
protected static function broadcastNewOrderToMasters(array $order)
{
try {
$masters = Db::name('master')
$excludeMobiles = [];
$orderMobile = trim((string)($order['mobile'] ?? ''));
if ($orderMobile !== '') {
$excludeMobiles[] = $orderMobile;
}
if ((int)($order['user_id'] ?? 0) > 0) {
$posterMobile = trim((string)Db::name('user')->where('id', (int)$order['user_id'])->value('mobile'));
if ($posterMobile !== '') {
$excludeMobiles[] = $posterMobile;
}
}
$q = Db::name('master')
->where('verify_status', 'pass')
->where('work_status', 'on')
->where('user_id', '<>', (int)$order['user_id'])
->limit(20)
->select();
->where('status', 'normal');
if (!empty($excludeMobiles)) {
$q->where(function ($sub) use ($excludeMobiles) {
$sub->whereNull('mobile')->whereOr('mobile', 'not in', array_values(array_unique($excludeMobiles)));
});
}
$masters = $q->limit(20)->select();
foreach ($masters as $m) {
self::sendNotify('master', (int)$m['id'], '新工单就绪通知', '同城有新工单【' . $order['order_no'] . '】进入接单大厅,请尽快前往抢单!', 'order', (int)$order['id']);
}
@@ -2205,18 +2288,6 @@ class PaymentService
'createtime' => $now,
];
}
if ((int)$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);
}

查看文件

@@ -14,26 +14,20 @@ class TencentVerifyService
const DEFAULT_REGION = 'ap-guangzhou';
/**
* 获取腾讯云 SecretId(严格读取站点配置或 .env,不在源码内硬编码密钥)
* 获取腾讯云 SecretId(严格读取后台系统配置,不在源码或 .env 内配置)
*/
public static function getSecretId()
{
$id = class_exists('\\think\\Config') ? \think\Config::get('site.tencent_secret_id') : null;
if (empty($id) && class_exists('\\think\\Env')) {
$id = \think\Env::get('tencent.secret_id', '');
}
return trim((string)$id);
}
/**
* 获取腾讯云 SecretKey(严格读取站点配置或 .env,不在源码内硬编码密钥)
* 获取腾讯云 SecretKey(严格读取后台系统配置,不在源码或 .env 内配置)
*/
public static function getSecretKey()
{
$key = class_exists('\\think\\Config') ? \think\Config::get('site.tencent_secret_key') : null;
if (empty($key) && class_exists('\\think\\Env')) {
$key = \think\Env::get('tencent.secret_key', '');
}
return trim((string)$key);
}

查看文件

@@ -12,16 +12,12 @@ use think\Log;
class TiandituService
{
/**
* 获取天地图 Key(严格读取站点配置或 .env,不在源码内硬编码密钥)
* 获取天地图 Key(严格读取后台系统配置,不在源码或 .env 内配置)
* @return string
*/
public static function getKey()
{
$key = Config::get('site.tianditu_key');
if (empty($key) && class_exists('\\think\\Env')) {
$key = \think\Env::get('tianditu.key', '');
}
return trim((string)$key);
return trim((string)Config::get('site.tianditu_key'));
}
/**

查看文件

@@ -213,6 +213,7 @@ class Upload
// user 维度分类:从请求 token 解析 user_id,路径插入 u{userid} 层级;common 维度或未登录不插入(后台会话无API token,自动落公共目录)
$categoryMap = isset($this->config['category_map']) && is_array($this->config['category_map']) ? $this->config['category_map'] : [];
$userId = 0;
$masterId = 0;
if (($categoryMap[$category] ?? 'common') === 'user' && request()->module() !== 'admin') {
// 后台请求固定走公共目录:避免同域部署时管理员浏览器残留前台 token cookie 导致误插用户层
$token = request()->server('HTTP_TOKEN', request()->request('token', \think\Cookie::get('token')));
@@ -220,9 +221,15 @@ class Upload
$tokenInfo = Token::get($token);
if (!empty($tokenInfo['user_id'])) {
$userId = (int)$tokenInfo['user_id'];
} else {
$masterTokenInfo = MasterToken::get($token);
if (!empty($masterTokenInfo['master_id'])) {
$masterId = (int)$masterTokenInfo['master_id'];
}
}
}
}
$ownerSegment = $userId > 0 ? '/u' . $userId : ($masterId > 0 ? '/m' . $masterId : '');
$replaceArr = [
'{year}' => date("Y"),
'{mon}' => date("m"),
@@ -232,7 +239,7 @@ class Upload
'{sec}' => date("s"),
'{random}' => Random::alnum(16),
'{random32}' => Random::alnum(32),
'{category}' => $category . ($userId > 0 ? '/u' . $userId : ''),
'{category}' => $category . $ownerSegment,
'{filename}' => substr($filename, 0, 100),
'{fileprefix}' => substr($fileprefix, 0, 100),
'{suffix}' => $suffix,
@@ -433,9 +440,11 @@ class Upload
// 附件记录分类与存储路径共用同一注册表(normalizeCategory),不再依赖 site.attachmentcategory 字典校验
$category = $this->normalizeCategory(request()->post('category'));
$auth = Auth::instance();
$masterAuth = MasterAuth::instance();
$params = array(
'admin_id' => (int)session('admin.id'),
'user_id' => (int)$auth->id,
'master_id' => (int)$masterAuth->id(),
'filename' => mb_substr(htmlspecialchars(strip_tags($this->fileInfo['name'])), 0, 100),
'category' => $category,
'filesize' => $this->fileInfo['size'],

查看文件

@@ -15,12 +15,30 @@ class WxLogin
* 小程序 code 换取 session
* @return array|false 成功返回 ['openid'=>..,'session_key'=>..,'unionid'=>..]
*/
public static function jscode2session($code)
public static function getMiniAppConfig($side = 'user')
{
$appid = trim((string)\think\Env::get('wechat.appid', ''));
$secret = trim((string)\think\Env::get('wechat.secret', ''));
$side = $side === 'master' ? 'master' : 'user';
if ($side === 'master') {
return [
'appid' => trim((string)\think\Config::get('site.wechat_master_appid')),
'secret' => trim((string)\think\Config::get('site.wechat_master_secret')),
];
}
return [
'appid' => trim((string)\think\Config::get('site.wechat_user_appid')),
'secret' => trim((string)\think\Config::get('site.wechat_user_secret')),
];
}
public static function jscode2session($code, $side = 'user')
{
$side = $side === 'master' ? 'master' : 'user';
$cfg = self::getMiniAppConfig($side);
$appid = $cfg['appid'];
$secret = $cfg['secret'];
if ($appid === '' || $secret === '') {
return ['error' => '微信登录参数未配置完整(请检查 server/.env 的 wechat.appid 与 wechat.secret)', 'errcode' => -1001];
$label = $side === 'master' ? '师傅端' : '用户端';
return ['error' => "{$label}微信登录参数未配置完整(请在后台「常规管理 -> 系统配置 -> 小程序与支付配置」填写 AppID 与 Secret)", 'errcode' => -1001];
}
$code = trim((string)$code);
if ($code === '') {
@@ -133,19 +151,23 @@ class WxLogin
}
/**
* 获取微信 access_token (带缓存)
* 获取微信 access_token (按端独立缓存,防止双小程序互相覆盖)
* @param string $side user|master
*/
public static function getAccessToken()
public static function getAccessToken($side = 'user')
{
$cached = \think\Cache::get('wechat_access_token');
$side = $side === 'master' ? 'master' : 'user';
$cacheKey = 'wechat_access_token_' . $side;
$cached = \think\Cache::get($cacheKey);
if ($cached) {
return $cached;
}
$appid = \think\Env::get('wechat.appid');
$secret = \think\Env::get('wechat.secret');
$cfg = self::getMiniAppConfig($side);
$appid = $cfg['appid'];
$secret = $cfg['secret'];
if (!$appid || !$secret) {
return ['error' => '微信配置缺失'];
return ['error' => ($side === 'master' ? '师傅端' : '用户端') . '微信配置缺失'];
}
$url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $appid . '&secret=' . $secret;
@@ -156,21 +178,27 @@ class WxLogin
}
$data = json_decode($resp, true);
if (empty($data['access_token'])) {
return ['error' => isset($data['errmsg']) ? $data['errmsg'] : '获取 access_token 失败', 'errcode' => isset($data['errcode']) ? $data['errcode'] : 0];
$ec = isset($data['errcode']) ? (int)$data['errcode'] : 0;
$em = isset($data['errmsg']) ? (string)$data['errmsg'] : '获取 access_token 失败';
\think\Log::error("[WxLogin::getAccessToken] side={$side}, errcode={$ec}, errmsg={$em}");
return ['error' => '微信服务授权异常,请稍后重试', 'errcode' => $ec];
}
$token = $data['access_token'];
$expire = isset($data['expires_in']) ? max(60, (int)$data['expires_in'] - 200) : 6000;
\think\Cache::set('wechat_access_token', $token, $expire);
\think\Cache::set($cacheKey, $token, $expire);
return $token;
}
/**
* 通过手机号快速验证 code 换取用户真实手机号
* 通过手机号快速验证 code 换取真实手机号
* @param string $code
* @param string $side user|master
*/
public static function getPhoneNumber($code)
public static function getPhoneNumber($code, $side = 'user')
{
$token = self::getAccessToken();
$side = $side === 'master' ? 'master' : 'user';
$token = self::getAccessToken($side);
if (is_array($token) && isset($token['error'])) {
return $token;
}
@@ -193,11 +221,19 @@ class WxLogin
$data = json_decode($resp, true);
if (empty($data) || !isset($data['errcode']) || (int)$data['errcode'] !== 0 || empty($data['phone_info'])) {
$ec = isset($data['errcode']) ? (int)$data['errcode'] : -1;
$em = isset($data['errmsg']) ? $data['errmsg'] : '换取手机号失败';
$em = isset($data['errmsg']) ? (string)$data['errmsg'] : '换取手机号失败';
if ($ec === 40001 || $ec === 42001) {
\think\Cache::rm('wechat_access_token');
\think\Cache::rm('wechat_access_token_' . $side);
}
return ['error' => $em, 'errcode' => $ec];
\think\Log::error("[WxLogin::getPhoneNumber] side={$side}, errcode={$ec}, errmsg={$em}");
$hint = [
40029 => '手机号授权凭证已失效,请重新点击登录',
40163 => '手机号授权凭证已被使用,请重新点击登录',
40001 => '微信登录凭证已刷新,请重试',
42001 => '微信登录凭证已刷新,请重试',
45011 => '操作过于频繁,请稍后再试',
];
return ['error' => isset($hint[$ec]) ? $hint[$ec] : '获取微信手机号失败,请重试', 'errcode' => $ec];
}
return $data['phone_info'];
}
@@ -264,4 +300,149 @@ class WxLogin
return ['user_id' => $userId, 'is_new' => $isNew];
}
/**
* 师傅端:按 openid 落库(fa_master + fa_master_wechat),幂等
* @return array ['master_id' => int, 'is_new' => 0|1]
*/
public static function provisionMaster($openid, $unionid = '', $sessionKey = '', $nickname = '', $avatar = '')
{
$openid = (string)$openid;
$bind = Db::name('master_wechat')->where('openid', $openid)->find();
$masterId = $bind ? (int)$bind['master_id'] : 0;
if ($masterId > 0 && !Db::name('master')->where('id', $masterId)->find()) {
$masterId = 0;
}
$now = time();
$isNew = 0;
if ($masterId === 0) {
$isNew = 1;
$masterId = (int)Db::name('master')->insertGetId([
'mobile' => null,
'nickname' => $nickname !== '' ? mb_substr($nickname, 0, 20) : ('师傅' . substr($openid, -4)),
'realname' => '',
'avatar' => $avatar,
'verify_status' => 'draft',
'work_status' => 'off',
'status' => 'normal',
'level' => 1,
'score' => 5.00,
'accept_rate' => 100.00,
'ontime_rate' => 100.00,
'serve_radius' => 10,
'money' => 0.00,
'frozen_money' => 0.00,
'createtime' => $now,
'updatetime' => $now,
]);
MasterSecurity::ensure($masterId);
}
$data = [
'master_id' => $masterId,
'openid' => $openid,
'unionid' => (string)$unionid,
'session_key' => (string)$sessionKey,
'updatetime' => $now,
];
if ($nickname !== '') {
$data['nickname'] = mb_substr($nickname, 0, 64);
}
if ($avatar !== '') {
$data['avatar'] = $avatar;
}
if ($bind) {
Db::name('master_wechat')->where('id', $bind['id'])->update($data);
} else {
$data['createtime'] = $now;
Db::name('master_wechat')->insert($data);
}
$masterUpdate = ['updatetime' => $now];
if ($nickname !== '') {
$masterUpdate['nickname'] = mb_substr($nickname, 0, 20);
}
if ($avatar !== '') {
$masterUpdate['avatar'] = $avatar;
}
Db::name('master')->where('id', $masterId)->update($masterUpdate);
return ['master_id' => $masterId, 'is_new' => $isNew];
}
/**
* 师傅端:按手机号结合 openid 注册或登录独立师傅账号(fa_master + fa_master_wechat,幂等合并)
* @return array ['master_id' => int, 'is_new' => 0|1]
*/
public static function provisionMasterWithMobile($mobile, $openid = '', $unionid = '', $sessionKey = '')
{
$mobile = trim((string)$mobile);
$openid = trim((string)$openid);
$masterId = 0;
$isNew = 0;
$now = time();
// 1. 优先按手机号匹配已存在师傅账号
$existMaster = Db::name('master')->where('mobile', $mobile)->find();
if ($existMaster) {
$masterId = (int)$existMaster['id'];
}
// 2. 若手机号未查到,但有 openid,检查 fa_master_wechat 是否已绑定师傅
if ($masterId === 0 && $openid !== '') {
$bind = Db::name('master_wechat')->where('openid', $openid)->find();
if ($bind && Db::name('master')->where('id', $bind['master_id'])->find()) {
$masterId = (int)$bind['master_id'];
Db::name('master')->where('id', $masterId)->update(['mobile' => $mobile, 'updatetime' => $now]);
}
}
// 3. 师傅账号完全不存在,新建独立师傅账号(状态 draft,需提交实名入驻审核)
if ($masterId === 0) {
$isNew = 1;
$masterId = (int)Db::name('master')->insertGetId([
'mobile' => $mobile,
'nickname' => '师傅' . substr($mobile, -4),
'realname' => '',
'avatar' => '',
'verify_status' => 'draft',
'work_status' => 'off',
'status' => 'normal',
'level' => 1,
'score' => 5.00,
'accept_rate' => 100.00,
'ontime_rate' => 100.00,
'serve_radius' => 10,
'money' => 0.00,
'frozen_money' => 0.00,
'createtime' => $now,
'updatetime' => $now,
]);
}
MasterSecurity::ensure($masterId);
// 4. 若有 openid,建立或更新 fa_master_wechat 关联
if ($openid !== '') {
$bind = Db::name('master_wechat')->where('openid', $openid)->find();
$bindData = [
'master_id' => $masterId,
'openid' => $openid,
'unionid' => (string)$unionid,
'session_key' => (string)$sessionKey,
'updatetime' => $now,
];
if ($bind) {
Db::name('master_wechat')->where('id', $bind['id'])->update($bindData);
} else {
$bindData['createtime'] = $now;
Db::name('master_wechat')->insert($bindData);
}
}
return ['master_id' => $masterId, 'is_new' => $isNew];
}
}

查看文件

@@ -2,7 +2,7 @@
namespace app\common\library;
use think\Env;
use think\Config;
use think\Log;
/**
@@ -50,21 +50,27 @@ class WxPayV3Service
public function __construct(array $overrideConfig = [])
{
$this->appId = trim((string)($overrideConfig['appid'] ?? Env::get('wechat.appid', '')));
$this->mchId = trim((string)($overrideConfig['mch_id'] ?? Env::get('wechat.mch_id', '')));
$this->keyV3 = trim((string)($overrideConfig['key_v3'] ?? Env::get('wechat.key_v3', '')));
$this->publicKeyId = trim((string)($overrideConfig['public_key_id'] ?? Env::get('wechat.public_key_id', '')));
$side = isset($overrideConfig['side']) && $overrideConfig['side'] === 'master' ? 'master' : 'user';
if (isset($overrideConfig['appid'])) {
$this->appId = trim((string)$overrideConfig['appid']);
} else {
$miniCfg = WxLogin::getMiniAppConfig($side);
$this->appId = $miniCfg['appid'];
}
$this->mchId = trim((string)($overrideConfig['mch_id'] ?? Config::get('site.wechat_mch_id')));
$this->keyV3 = trim((string)($overrideConfig['key_v3'] ?? Config::get('site.wechat_key_v3')));
$this->publicKeyId = trim((string)($overrideConfig['public_key_id'] ?? Config::get('site.wechat_public_key_id')));
$certRel = trim((string)($overrideConfig['cert_client'] ?? (Env::get('wechat.cert_client', '') ?: '/addons/epay/certs/apiclient_cert.pem')));
$keyRel = trim((string)($overrideConfig['cert_key'] ?? (Env::get('wechat.cert_key', '') ?: '/addons/epay/certs/apiclient_key.pem')));
$pubRel = trim((string)($overrideConfig['public_key'] ?? (Env::get('wechat.public_key', '') ?: '/addons/epay/certs/public_key.pem')));
$certRel = trim((string)($overrideConfig['cert_client'] ?? '/addons/epay/certs/apiclient_cert.pem'));
$keyRel = trim((string)($overrideConfig['cert_key'] ?? '/addons/epay/certs/apiclient_key.pem'));
$pubRel = trim((string)($overrideConfig['public_key'] ?? '/addons/epay/certs/public_key.pem'));
$this->certClientPath = $this->resolveCertPath($certRel);
$this->certKeyPath = $this->resolveCertPath($keyRel);
$this->publicKeyPath = $this->resolveCertPath($pubRel);
$this->notifyDomain = rtrim(trim((string)($overrideConfig['notify_domain'] ?? Env::get('wechat.notify_domain', ''))), '/');
$this->transferSceneId = trim((string)($overrideConfig['transfer_scene_id'] ?? (Env::get('wechat.transfer_scene_id', '') ?: '1005')));
$this->notifyDomain = rtrim(trim((string)($overrideConfig['notify_domain'] ?? Config::get('site.wechat_notify_domain'))), '/');
$this->transferSceneId = trim((string)($overrideConfig['transfer_scene_id'] ?? (Config::get('site.wechat_transfer_scene_id') ?: '1005')));
}
/**

查看文件

@@ -4,7 +4,7 @@ return array (
'name' => '优匠优服',
'beian' => '',
'cdnurl' => '',
'version' => '1.0.96',
'version' => '1.0.97',
'timezone' => 'Asia/Shanghai',
'forbiddenip' => '',
'languages' =>
@@ -22,9 +22,10 @@ return array (
),
'configgroup' =>
array (
'basic' => '基础配置',
'user' => '会员配置',
'basic' => '基础配置',
'email' => '邮箱配置',
'wechat' => '小程序与支付配置',
'dictionary' => '字典配置',
),
'mail_type' => '1',
@@ -52,6 +53,8 @@ return array (
'order_source_options' => '淘宝/天猫,京东,拼多多,抖音电商,线下门店,其他渠道',
'home_price_ranges' => '[{"label":"80元以下","value":"under_80"},{"label":"80-120元","value":"80_120"},{"label":"120元以上","value":"120_up"}]',
'auto_quote_hours_options' => '6,12,24,48',
'order_unaccepted_close_switch' => '1',
'order_unaccepted_close_days' => '3',
'login_background' => '/assets/img/login_bg_modern.png',
'tianditu_key' => '55aee666be14cd0100874d6faf3c963c',
'tencent_secret_id' => 'AKIDPjrlKq8C2e2CBzax97tRlqiS0SqFRXcX',
@@ -60,4 +63,13 @@ return array (
'service_work_time' => '',
'service_corp_id' => '',
'service_kf_url' => '',
'wechat_user_appid' => 'wx40ca4b02d4d1cb58',
'wechat_user_secret' => 'f661146ce627e2c57770b7d80164dd65',
'wechat_master_appid' => 'wx140d90ceda786107',
'wechat_master_secret' => '18ee42db1b8c4c2a6ce15138de5803fd',
'wechat_mch_id' => '1119105317',
'wechat_key_v3' => 'ffyqcyyszhdhi398672363efnwvikxlv',
'wechat_public_key_id' => 'PUB_KEY_ID_0111191053172026102200381630000600',
'wechat_notify_domain' => 'https://yjyf.gzyakj.com.cn',
'wechat_transfer_scene_id' => '1005',
);