refactor(zy): 修改消息通知的类型和功能

This commit is contained in:
2025-06-09 10:52:18 +08:00
parent c9a8b9d5e8
commit 70baaa2fd5
5 changed files with 127 additions and 109 deletions

View File

@@ -9,6 +9,7 @@ use app\admin\model\zy\Menber;
use app\admin\model\zy\Stadium;
use think\exception\PDOException;
use app\admin\model\zy\link\Message;
use app\admin\model\zy\game\Activity;
use app\admin\model\zy\game\GameJoin;
use app\admin\model\zy\game\GameMatch;
use think\exception\ValidateException;
@@ -30,9 +31,10 @@ class Game extends Base
$params = $this->request->param();
$query = $this->model->alias('g')
->join([Participant::$tableName => 'p'], 'p.game_id=g.id', 'LEFT')
->join([Activity::$tableName => 'a'], 'a.id=g.act_id', 'LEFT')
->join([Stadium::$tableName => 's'], 's.id = g.gym_id', 'LEFT')
->join([Club::$tableName => 'c'], 'c.id = g.club_id', 'LEFT')
->field('g.*, s.name as gym_name, c.name as club_name,JSON_ARRAYAGG(p.avatar) as avatar,count(p.id) as join_num');
->field('g.*,a.type,s.name as gym_name,c.name as club_name,JSON_ARRAYAGG(p.avatar) as avatar,count(p.id) as join_num');
if (isset($params['name'])) {
$query->where('g.name', 'like', '%' . $params['name'] . '%');
}
@@ -43,14 +45,14 @@ class Game extends Base
$query->where('g.week', $params['week']);
}
if (isset($params['pid'])) {
$query->where('pid', $params['pid']);
$query->where('g.pid', $params['pid']);
} else {
$query->where('pid', 0);
$query->where('g.pid', 0);
}
if (isset($params['public_time'])) {
$query->where('public_time', $params['public_time']);
$query->where('g.public_time', $params['public_time']);
} else {
$query->where('public_time', '<=', date('Y-m-d H:i:s'));
$query->where('g.public_time', '<=', date('Y-m-d H:i:s'));
}
if (isset($params['page'])) {
$pageSize = intval($params['pageSize'] ?? 10);
@@ -113,18 +115,18 @@ class Game extends Base
'remark' => '用户自行退出活动'
]);
}
(new Message())->save([
'type' => 1,
'name' => '系统消息',
'avatar' => '',
'from_id' => 0,
'user_id' => $join->user_id,
'content' => json_encode([
'topic' => '退出',
'content' => '已退出 ' . $model['name'] . ' 活动',
'game_id' => $model->id
])
]);
// (new Message())->save([
// 'type' => 1,
// 'name' => '系统消息',
// 'avatar' => '',
// 'from_id' => 0,
// 'user_id' => $join->user_id,
// 'content' => json_encode([
// 'topic' => '退出',
// 'content' => '已退出 ' . $model['name'] . ' 活动',
// 'game_id' => $model->id
// ])
// ]);
Db::commit();
} catch (ValidateException | PDOException | Exception $e) {
@@ -175,21 +177,21 @@ class Game extends Base
'remark' => '活动取消,全额退款'
]);
}
$msgs[] = [
'type' => 1,
'name' => '系统消息',
'avatar' => '',
'from_id' => 0,
'user_id' => $j->user_id,
'content' => json_encode([
'topic' => '评论',
'content' => $model['name'] . ' 活动已取消',
'game_id' => $model->id
])
];
// $msgs[] = [
// 'type' => 1,
// 'name' => '系统消息',
// 'avatar' => '',
// 'from_id' => 0,
// 'user_id' => $j->user_id,
// 'content' => json_encode([
// 'topic' => '评论',
// 'content' => $model['name'] . ' 活动已取消',
// 'game_id' => $model->id
// ])
// ];
}
(new Message())->insertAll($msgs);;
// (new Message())->insertAll($msgs);;
Db::commit();
} catch (ValidateException | PDOException | Exception $e) {
Db::rollback();