refactor(zy): 修改消息通知的类型和功能
This commit is contained in:
@@ -486,20 +486,20 @@ class User extends Common
|
||||
'reason' => $params['reason'] ?? '',
|
||||
'status' => 1
|
||||
]);
|
||||
(new Message())->allowField(true)->save([ // 消息通知
|
||||
'type' => 2,
|
||||
'name' => $fromUser->nickname,
|
||||
'avatar' => $fromUser->avatar,
|
||||
'from_id' => $fromUser->id,
|
||||
'user_id' => $user->id,
|
||||
'content' => json_encode([
|
||||
'topic' => '申请联系信息',
|
||||
'申请人' => $fromUser->nickname,
|
||||
'申请时间' => date('Y-m-d H:i:s'),
|
||||
'reason' => $params['reason'] ?? '',
|
||||
'apply_id' => $apply->id
|
||||
])
|
||||
]);
|
||||
// (new Message())->allowField(true)->save([ // 消息通知
|
||||
// 'type' => 2,
|
||||
// 'name' => $fromUser->nickname,
|
||||
// 'avatar' => $fromUser->avatar,
|
||||
// 'from_id' => $fromUser->id,
|
||||
// 'user_id' => $user->id,
|
||||
// 'content' => json_encode([
|
||||
// 'topic' => '申请联系信息',
|
||||
// '申请人' => $fromUser->nickname,
|
||||
// '申请时间' => date('Y-m-d H:i:s'),
|
||||
// 'reason' => $params['reason'] ?? '',
|
||||
// 'apply_id' => $apply->id
|
||||
// ])
|
||||
// ]);
|
||||
Db::commit();
|
||||
} catch (ValidateException | PDOException | Exception $e) {
|
||||
Db::rollback();
|
||||
|
||||
@@ -9,6 +9,7 @@ use app\admin\model\zy\Stadium;
|
||||
use app\admin\model\zy\game\Game;
|
||||
use think\exception\PDOException;
|
||||
use app\admin\model\shopro\Category;
|
||||
use app\admin\model\zy\link\Message;
|
||||
use app\admin\model\zy\game\GameJoin;
|
||||
use think\exception\ValidateException;
|
||||
use app\admin\model\shopro\goods\Goods;
|
||||
@@ -211,7 +212,8 @@ class Activity extends Base
|
||||
}
|
||||
$order = GameJoin::where('game_id', $game['id'])->count();
|
||||
$gender = ['man' => 0, 'woman' => 0];
|
||||
$participant = [];
|
||||
$user = auth_user();
|
||||
$participant = $msgs = [];
|
||||
foreach ($params['users'] as $u) {
|
||||
$order++;
|
||||
$participant[] = [
|
||||
@@ -229,6 +231,19 @@ class Activity extends Base
|
||||
} else {
|
||||
$gender['man'] += 1;
|
||||
}
|
||||
$msgs[] = [
|
||||
'type' => 1,
|
||||
'name' => '系统消息',
|
||||
'avatar' => '',
|
||||
'from_id' => 0,
|
||||
'user_id' => $u['user_id'],
|
||||
'content' => json_encode([
|
||||
'msgType' => 1,
|
||||
'content' => $user['nickname'] . ' 帮你报名了组球',
|
||||
'game_id' => $game['id'],
|
||||
'act_id' => $game['act_id'],
|
||||
])
|
||||
];
|
||||
}
|
||||
foreach ($gender as $k => $v) {
|
||||
if ($params['goods_list'][$k]['goods_num'] != $v) {
|
||||
@@ -254,6 +269,7 @@ class Activity extends Base
|
||||
$p['game_join_id'] = $join->id;
|
||||
}
|
||||
(new Participant)->insertAll($participant);
|
||||
(new Message())->insertAll($msgs);
|
||||
|
||||
Db::commit();
|
||||
} catch (ValidateException | PDOException | Exception $e) {
|
||||
|
||||
@@ -134,18 +134,18 @@ class Circle extends Base
|
||||
'avatar' => $user['avatar'],
|
||||
'gender' => $user['gender'],
|
||||
]);
|
||||
(new Message())->allowField(true)->save([ // 消息通知
|
||||
'type' => 1,
|
||||
'name' => '互动消息',
|
||||
'avatar' => '',
|
||||
'from_id' => 0,
|
||||
'user_id' => $circle->user_id,
|
||||
'content' => json_encode([
|
||||
'topic' => '点赞',
|
||||
'content' => $user['nickname'] . '点赞了你的帖子',
|
||||
'circle_id' => $circle->id
|
||||
])
|
||||
]);
|
||||
// (new Message())->allowField(true)->save([ // 消息通知
|
||||
// 'type' => 1,
|
||||
// 'name' => '互动消息',
|
||||
// 'avatar' => '',
|
||||
// 'from_id' => 0,
|
||||
// 'user_id' => $circle->user_id,
|
||||
// 'content' => json_encode([
|
||||
// 'topic' => '点赞',
|
||||
// 'content' => $user['nickname'] . '点赞了你的帖子',
|
||||
// 'circle_id' => $circle->id
|
||||
// ])
|
||||
// ]);
|
||||
} else { // 取消点赞
|
||||
$like->delete();
|
||||
}
|
||||
@@ -186,18 +186,18 @@ class Circle extends Base
|
||||
'gender' => $user['gender'],
|
||||
'content' => $params['content'],
|
||||
]);
|
||||
(new Message())->allowField(true)->save([ // 消息通知
|
||||
'type' => 1,
|
||||
'name' => '互动消息',
|
||||
'avatar' => '',
|
||||
'from_id' => 0,
|
||||
'target_id' => $circle->user_id,
|
||||
'content' => json_encode([
|
||||
'topic' => '评论',
|
||||
'content' => $user['nickname'] . '评论了你的帖子',
|
||||
'circle_id' => $circle->id
|
||||
])
|
||||
]);
|
||||
// (new Message())->allowField(true)->save([ // 消息通知
|
||||
// 'type' => 1,
|
||||
// 'name' => '互动消息',
|
||||
// 'avatar' => '',
|
||||
// 'from_id' => 0,
|
||||
// 'target_id' => $circle->user_id,
|
||||
// 'content' => json_encode([
|
||||
// 'topic' => '评论',
|
||||
// 'content' => $user['nickname'] . '评论了你的帖子',
|
||||
// 'circle_id' => $circle->id
|
||||
// ])
|
||||
// ]);
|
||||
Db::commit();
|
||||
} catch (ValidateException | PDOException | Exception $e) {
|
||||
Db::rollback();
|
||||
@@ -231,18 +231,18 @@ class Circle extends Base
|
||||
throw new Exception($model->id . ' 此记录不在待审核状态');
|
||||
}
|
||||
$model->save(['status' => $params['status']]);
|
||||
(new Message())->allowField(true)->save([ // 消息通知
|
||||
'type' => 3,
|
||||
'name' => '通知消息',
|
||||
'avatar' => '',
|
||||
'from_id' => 1,
|
||||
'user_id' => $model->user_id,
|
||||
'content' => json_encode([
|
||||
'topic' => '影圈审核',
|
||||
'result' => ($params['status'] == 1) ? '通过' : '不通过',
|
||||
'circle_id' => $model->id
|
||||
])
|
||||
]);
|
||||
// (new Message())->allowField(true)->save([ // 消息通知
|
||||
// 'type' => 3,
|
||||
// 'name' => '通知消息',
|
||||
// 'avatar' => '',
|
||||
// 'from_id' => 1,
|
||||
// 'user_id' => $model->user_id,
|
||||
// 'content' => json_encode([
|
||||
// 'topic' => '影圈审核',
|
||||
// 'result' => ($params['status'] == 1) ? '通过' : '不通过',
|
||||
// 'circle_id' => $model->id
|
||||
// ])
|
||||
// ]);
|
||||
}
|
||||
Db::commit();
|
||||
} catch (ValidateException | PDOException | Exception $e) {
|
||||
|
||||
@@ -223,20 +223,20 @@ class Club extends Base
|
||||
'reason' => $params['reason'],
|
||||
'status' => 1
|
||||
]);
|
||||
(new Message())->allowField(true)->save([ // 消息通知
|
||||
'type' => 3,
|
||||
'name' => $club->name,
|
||||
'avatar' => $club->logo,
|
||||
'from_id' => $club->id,
|
||||
'content' => json_encode([
|
||||
'topic' => '俱乐部加入申请',
|
||||
'俱乐部名称' => $club->name,
|
||||
'申请人' => $this->user->nickname,
|
||||
'申请时间' => date('Y-m-d H:i:s'),
|
||||
'reason' => $params['reason'] ?? '',
|
||||
'apply_id' => $apply->id
|
||||
])
|
||||
]);
|
||||
// (new Message())->allowField(true)->save([ // 消息通知
|
||||
// 'type' => 3,
|
||||
// 'name' => $club->name,
|
||||
// 'avatar' => $club->logo,
|
||||
// 'from_id' => $club->id,
|
||||
// 'content' => json_encode([
|
||||
// 'topic' => '俱乐部加入申请',
|
||||
// '俱乐部名称' => $club->name,
|
||||
// '申请人' => $this->user->nickname,
|
||||
// '申请时间' => date('Y-m-d H:i:s'),
|
||||
// 'reason' => $params['reason'] ?? '',
|
||||
// 'apply_id' => $apply->id
|
||||
// ])
|
||||
// ]);
|
||||
}
|
||||
Db::commit();
|
||||
} catch (ValidateException | PDOException | Exception $e) {
|
||||
@@ -296,20 +296,20 @@ class Club extends Base
|
||||
'reason' => $params['reason'],
|
||||
'status' => 1
|
||||
]);
|
||||
(new Message())->allowField(true)->save([ // 消息通知
|
||||
'type' => 3,
|
||||
'name' => $club->name,
|
||||
'avatar' => $club->logo,
|
||||
'from_id' => $club->id,
|
||||
'content' => json_encode([
|
||||
'topic' => '俱乐部加入申请',
|
||||
'俱乐部名称' => $club->name,
|
||||
'申请人' => $user->nickname,
|
||||
'申请时间' => date('Y-m-d H:i:s'),
|
||||
'reason' => $params['reason'] ?? '',
|
||||
'apply_id' => $apply->id,
|
||||
])
|
||||
]);
|
||||
// (new Message())->allowField(true)->save([ // 消息通知
|
||||
// 'type' => 3,
|
||||
// 'name' => $club->name,
|
||||
// 'avatar' => $club->logo,
|
||||
// 'from_id' => $club->id,
|
||||
// 'content' => json_encode([
|
||||
// 'topic' => '俱乐部加入申请',
|
||||
// '俱乐部名称' => $club->name,
|
||||
// '申请人' => $user->nickname,
|
||||
// '申请时间' => date('Y-m-d H:i:s'),
|
||||
// 'reason' => $params['reason'] ?? '',
|
||||
// 'apply_id' => $apply->id,
|
||||
// ])
|
||||
// ]);
|
||||
}
|
||||
Db::commit();
|
||||
} catch (ValidateException | PDOException | Exception $e) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user