feat: 微信授权登录 + 我的中心角色切换 + 师傅工作台全模块 + 图标美化
登录与角色: - Auth::wxlogin 微信 code → jscode2session → 落库发 token(appid/secret 走 .env) - 新增 fa_user_wechat 表,openid 幂等建号(CLI 已验证 is_new 1→0 不重复建号) - Auth::switchRole 角色切换(未入驻 2001 / 审核中 2002 / 未通过 2003) - pages/login 改为微信一键授权;pages/mine 我的中心(师傅入口 + 切换师傅端) 师傅工作台(对齐需求文档): - pages/master/workbench 工作台:接单开关 / 待处理待验收 / 可提现 / 六宫格入口 / 信用四指标 / 技能标签 - pages/master/hall 订单大厅:类型筛选(一口价/报价) + 4 种排序 + 抢单倒计时 + 报价入口 - pages/master/quote 报价竞标:金额/说明/有效期 + 报价记录 - pages/master/wallet 钱包:可提现/今日/累计 + 账单明细 + 提现校验 - pages/master/credit 信用与申诉:五项指标 + 规则 + 申诉提交/记录 - 新增 fa_appeal 表 视觉: - 15 个类目图标重画为双色扁平 SVG,用无头 Chrome 渲染为 192px 透明 PNG - 首页改用 <image src=static/icons/*.png>,移除 200 行 CSS 图标数据 验证:page_flow 47 + e2e_flow 65 + phase2_verify 27 = 139 项断言全通过
这个提交包含在:
@@ -144,7 +144,7 @@ class Master extends Base
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单大厅:待接单订单(按技能过滤,急单优先)
|
||||
* 订单大厅:支持排序与单类型筛选(一口价 / 报价 / 悬赏)
|
||||
*/
|
||||
public function hall()
|
||||
{
|
||||
@@ -154,19 +154,36 @@ class Master extends Base
|
||||
$catIds = Db::name('master_skill')->where('master_id', $master['id'])->column('cat_id');
|
||||
$page = max(1, (int)$this->request->param('page', 1));
|
||||
$limit = min(30, max(1, (int)$this->request->param('limit', 10)));
|
||||
$sort = $this->request->param('sort', 'new'); // new 最新 / amount 报酬 / urgent 急单 / time 时效
|
||||
$type = $this->request->param('type', 'all'); // all / fixed 一口价 / quote 报价
|
||||
|
||||
// TP5 中 count() 会重置查询条件,故用闭包重建
|
||||
$build = function () use ($catIds) {
|
||||
$build = function () use ($catIds, $type) {
|
||||
$q = Db::name('order')->where('status', OrderStatus::PENDING_ACCEPT)->where('master_id', 0);
|
||||
if (!empty($catIds)) {
|
||||
$q->where('cat_id', 'in', $catIds);
|
||||
}
|
||||
if ($type === 'fixed') {
|
||||
$q->where('price_type', 'fixed');
|
||||
} elseif ($type === 'quote') {
|
||||
$q->where('price_type', 'quote');
|
||||
}
|
||||
return $q;
|
||||
};
|
||||
|
||||
$total = $build()->count();
|
||||
$list = $build()->order('urgent desc, id desc')->page($page, $limit)->select();
|
||||
if ($sort === 'amount') {
|
||||
$order = 'pay_amount desc, id desc';
|
||||
} elseif ($sort === 'urgent') {
|
||||
$order = 'urgent desc, id desc';
|
||||
} elseif ($sort === 'time') {
|
||||
$order = 'appoint_time asc, id desc';
|
||||
} else {
|
||||
$order = 'id desc';
|
||||
}
|
||||
|
||||
$total = $build()->count();
|
||||
$list = $build()->order($order)->page($page, $limit)->select();
|
||||
|
||||
$now = time();
|
||||
foreach ($list as &$row) {
|
||||
$row['appoint_text'] = $row['appoint_time'] ? date('m-d H:i', (int)$row['appoint_time']) : '尽快上门';
|
||||
$row['pay_amount'] = (float)$row['pay_amount'];
|
||||
@@ -174,10 +191,15 @@ class Master extends Base
|
||||
$row['mobile'] = substr_replace($row['mobile'], '****', 3, 4);
|
||||
$row['address'] = $row['city'] . $row['district'] . $row['address'];
|
||||
$row['status_text'] = OrderStatus::label($row['status']);
|
||||
$row['left_seconds'] = max(0, (int)$row['createtime'] + 3600 - $now);
|
||||
$row['quote_count'] = (int)Db::name('order_quote')->where('order_id', $row['id'])->count();
|
||||
}
|
||||
unset($row);
|
||||
|
||||
$this->success('', ['list' => $list, 'total' => (int)$total, 'page' => $page]);
|
||||
$this->success('', [
|
||||
'list' => $list, 'total' => (int)$total,
|
||||
'page' => $page, 'sort' => $sort, 'type' => $type,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,5 +527,112 @@ class Master extends Base
|
||||
$this->addLog($row['id'], OrderStatus::PENDING_ACCEPT, '超 2 小时未联系客户,订单自动回流大厅', 'system', 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 信用体系:综合评分 / 接单率 / 准时率 / 好评率 / 投诉率
|
||||
*/
|
||||
public function credit()
|
||||
{
|
||||
$master = $this->requireMaster();
|
||||
$mid = (int)$master['id'];
|
||||
|
||||
$reviewTotal = (int)Db::name('review')->where('master_id', $mid)->where('status', 'normal')->count();
|
||||
$reviewGood = (int)Db::name('review')->where('master_id', $mid)->where('status', 'normal')->where('score', '>=', 4)->count();
|
||||
$appealCount = (int)Db::name('appeal')->where('master_id', $mid)->count();
|
||||
$orderCount = max(1, (int)$master['order_count']);
|
||||
|
||||
$this->success('', [
|
||||
'score' => (float)$master['score'],
|
||||
'level' => (int)$master['level'],
|
||||
'accept_rate' => (float)$master['accept_rate'],
|
||||
'ontime_rate' => (float)$master['ontime_rate'],
|
||||
'good_rate' => $reviewTotal ? round($reviewGood * 100 / $reviewTotal, 1) : 100,
|
||||
'complaint_rate' => round($appealCount * 100 / $orderCount, 1),
|
||||
'order_count' => (int)$master['order_count'],
|
||||
'review_total' => $reviewTotal,
|
||||
'appeal_total' => $appealCount,
|
||||
'rules' => [
|
||||
'综合评分 = 客户评价星级平均值(5 分制)',
|
||||
'接单率 = 已联系客户订单 / 接单总数',
|
||||
'准时率 = 按预约时间到达 / 上门总数',
|
||||
'好评率 = 4 星及以上评价占比',
|
||||
'投诉率 = 申诉工单数 / 完成订单数',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 申诉中心:列表
|
||||
*/
|
||||
public function appeals()
|
||||
{
|
||||
$master = $this->requireMaster();
|
||||
$list = Db::name('appeal')->where('master_id', $master['id'])->order('id desc')->limit(30)->select();
|
||||
$typeText = ['misjudge' => '误判申诉', 'review' => '恶意评价', 'deduct' => '扣款申诉', 'other' => '其他'];
|
||||
$statusText = ['wait' => '待处理', 'handling' => '处理中', 'done' => '已处理', 'reject' => '已驳回'];
|
||||
foreach ($list as &$row) {
|
||||
$row['type_text'] = isset($typeText[$row['type']]) ? $typeText[$row['type']] : '其他';
|
||||
$row['status_text'] = isset($statusText[$row['status']]) ? $statusText[$row['status']] : $row['status'];
|
||||
$row['time_text'] = date('Y-m-d H:i', (int)$row['createtime']);
|
||||
}
|
||||
unset($row);
|
||||
$this->success('', ['list' => $list]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 申诉中心:提交
|
||||
* @ApiMethod (POST)
|
||||
*/
|
||||
public function appeal()
|
||||
{
|
||||
$master = $this->requireMaster();
|
||||
$type = $this->request->post('type', 'other');
|
||||
$orderId = (int)$this->request->post('order_id', 0);
|
||||
$content = trim((string)$this->request->post('content'));
|
||||
if (!in_array($type, ['misjudge', 'review', 'deduct', 'other'], true)) {
|
||||
$this->error('申诉类型错误');
|
||||
}
|
||||
if (mb_strlen($content) < 5) {
|
||||
$this->error('请填写至少 5 个字的申诉说明');
|
||||
}
|
||||
if (Db::name('appeal')->where('master_id', $master['id'])->where('status', 'wait')->count() >= 5) {
|
||||
$this->error('您有多个待处理申诉,请等待处理完成');
|
||||
}
|
||||
Db::name('appeal')->insert([
|
||||
'master_id' => $master['id'],
|
||||
'order_id' => $orderId,
|
||||
'type' => $type,
|
||||
'content' => mb_substr($content, 0, 500),
|
||||
'images' => (string)$this->request->post('images', ''),
|
||||
'status' => 'wait',
|
||||
'createtime' => time(),
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
$this->success('申诉已提交,平台将在 24 小时内处理');
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的报价记录
|
||||
*/
|
||||
public function quotes()
|
||||
{
|
||||
$master = $this->requireMaster();
|
||||
$list = Db::name('order_quote')->alias('q')
|
||||
->join('order o', 'o.id = q.order_id', 'LEFT')
|
||||
->field('q.*, o.order_no, o.service_name, o.pay_amount as order_amount, o.status as order_status')
|
||||
->where('q.master_id', $master['id'])
|
||||
->order('q.id desc')
|
||||
->limit(30)
|
||||
->select();
|
||||
$statusText = ['wait' => '等待客户选择', 'accept' => '已被选中', 'reject' => '未被选中', 'expired' => '已过期'];
|
||||
foreach ($list as &$row) {
|
||||
$row['status_text'] = isset($statusText[$row['status']]) ? $statusText[$row['status']] : $row['status'];
|
||||
$row['amount'] = (float)$row['amount'];
|
||||
$row['time_text'] = date('m-d H:i', (int)$row['createtime']);
|
||||
$row['expire_text'] = date('m-d H:i', (int)$row['expire_time']);
|
||||
}
|
||||
unset($row);
|
||||
$this->success('', ['list' => $list]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
在新工单中引用
屏蔽一个用户