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),实现工作台、接单大厅、资质认证、工单协同与钱包提现完整闭环。
81 行
2.3 KiB
PHP
81 行
2.3 KiB
PHP
<?php
|
||
|
||
namespace app\api\controller;
|
||
|
||
use think\Db;
|
||
|
||
/**
|
||
* 用户端消息中心(仅限 user 身份,师傅端使用 MasterMessage)
|
||
*/
|
||
class Message extends Base
|
||
{
|
||
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)));
|
||
|
||
$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);
|
||
}
|
||
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($uid),
|
||
'page' => $page,
|
||
]);
|
||
}
|
||
|
||
public function read()
|
||
{
|
||
$id = (int)$this->request->post('id');
|
||
$uid = $this->uid();
|
||
|
||
$row = Db::name('message')->where('id', $id)->where('receive_type', 'user')->where('receive_id', $uid)->find();
|
||
if (!$row) {
|
||
$this->error('消息不存在');
|
||
}
|
||
Db::name('message')->where('id', $id)->update(['is_read' => 1]);
|
||
$this->success('已读');
|
||
}
|
||
|
||
public function readAll()
|
||
{
|
||
$uid = $this->uid();
|
||
$affected = Db::name('message')
|
||
->where('receive_type', 'user')->where('receive_id', $uid)->where('is_read', 0)
|
||
->update(['is_read' => 1]);
|
||
$this->success('已全部标记为已读', ['count' => (int)$affected]);
|
||
}
|
||
|
||
public function unread()
|
||
{
|
||
$this->success('', ['unread' => $this->unreadCount($this->uid())]);
|
||
}
|
||
|
||
protected function unreadCount($uid)
|
||
{
|
||
if (!$uid) {
|
||
return 0;
|
||
}
|
||
return (int)Db::name('message')
|
||
->where('receive_type', 'user')->where('receive_id', $uid)->where('is_read', 0)
|
||
->count();
|
||
}
|
||
}
|