From c9a8b9d5e8cb0e2966f82ad605a3a4266e344f45 Mon Sep 17 00:00:00 2001 From: xiadc <251308692@qq.com> Date: Fri, 6 Jun 2025 12:00:13 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B6=88=E6=81=AF=E6=A8=A1=E5=9D=97):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B6=88=E6=81=AF=E6=9F=A5=E8=AF=A2=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E6=94=AF=E6=8C=81=E4=BF=B1=E4=B9=90=E9=83=A8?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改了 User、Activity、Circle、Club 和 Game 控制器中的消息查询逻辑 - 增加了对俱乐部成员的判断,使得俱乐部消息能够展示给相关用户 - 调整了消息表中的字段名称,统一使用 user_id 替代 target_id - 优化了订单创建流程,只在需要时创建订单 - 更新了活动模型中的 costKey 属性,以适应新的费用结构 - 添加了新的费用类型翻译,以支持多退少补等功能 --- addons/shopro/controller/user/User.php | 39 +++++++++++++++---- addons/shopro/controller/zy/Activity.php | 29 +++++++------- addons/shopro/controller/zy/Circle.php | 2 +- addons/shopro/controller/zy/Club.php | 6 +-- addons/shopro/controller/zy/Game.php | 4 +- addons/shopro/controller/zy/Sys.php | 4 +- .../admin/lang/zh-cn/zy/game/activity.php | 1 - .../admin/lang/zh-cn/zy/game/game_join.php | 8 ++++ application/admin/model/zy/game/Activity.php | 2 +- 9 files changed, 63 insertions(+), 32 deletions(-) diff --git a/addons/shopro/controller/user/User.php b/addons/shopro/controller/user/User.php index 82561c4..b47fce4 100644 --- a/addons/shopro/controller/user/User.php +++ b/addons/shopro/controller/user/User.php @@ -363,7 +363,7 @@ class User extends Common 'name' => $user['nickname'], 'avatar' => $user['avatar'], 'from_id' => $user['id'], - 'target_id' => $params['user_id'], + 'user_id' => $params['user_id'], 'content' => json_encode([ 'topic' => '好友消息', 'time' => date('Y-m-d H:i:s'), @@ -386,17 +386,31 @@ class User extends Common public function msgGroup() { $params = $this->request->param(); - - $query1 = Message::field('*,count(*) as num')->where('user_id', $this->auth->id); - $query2 = Message::field('*,count(*) as num')->where('user_id', $this->auth->id); + $member = Menber::where('user_id', $this->auth->id)->where('role', '>', 1)->column('club_id'); + if (!empty($member)) { + $query1 = Message::field('*,count(*) as num')->where(function ($q1) use ($member) { + $q1->where('user_id', $this->auth->id) + ->whereOr(function ($q2) use ($member) { + $q2->where('type', 3)->whereIn('from_id', $member); + }); + }); + $query2 = Message::field('*,count(*) as num')->where(function ($q1) use ($member) { + $q1->where('user_id', $this->auth->id) + ->whereOr(function ($q2) use ($member) { + $q2->where('type', 3)->whereIn('from_id', $member); + }); + }); + } else { + $query1 = Message::field('*,count(*) as num')->where('user_id', $this->auth->id); + $query2 = Message::field('*,count(*) as num')->where('user_id', $this->auth->id); + } if (isset($params['type'])) { $query1->where('type', $params['type']); $query2->where('type', $params['type']); } $query1->group('from_id')->order('update_time', 'desc'); $query2->group('from_id')->order('update_time', 'desc'); - $num = $query2->where('status', 0)->column('count(*) as num', 'from_id'); // ->column('count(*) as num', 'gender'); - // dd($num); + $num = $query2->where('status', 0)->column('count(*) as num', 'from_id'); $res = $query1->paginate($params['pageSize'] ?? 10); $list = $res->items(); foreach ($list as &$r) { @@ -410,8 +424,17 @@ class User extends Common public function msg() { $params = $this->request->param(); - - $query = Message::where('user_id', $this->auth->id); + $member = Menber::where('user_id', $this->auth->id)->where('role', '>', 1)->column('club_id'); + if (!empty($member)) { + $query = Message::where(function ($q1) use ($member) { + $q1->where('user_id', $this->auth->id) //用户消息 + ->whereOr(function ($q2) use ($member) { //俱乐部消息 + $q2->where('type', 3)->whereIn('from_id', $member); + }); + }); + } else { + $query = Message::where('user_id', $this->auth->id); + } if (isset($params['type'])) { $query->where('type', $params['type']); } diff --git a/addons/shopro/controller/zy/Activity.php b/addons/shopro/controller/zy/Activity.php index 9af9faf..c1c81cb 100644 --- a/addons/shopro/controller/zy/Activity.php +++ b/addons/shopro/controller/zy/Activity.php @@ -235,18 +235,21 @@ class Activity extends Base $this->error('报名人数错误'); } } - $orderCreate = new OrderCreate($params); - $result = $orderCreate->calc('create'); - $order = $orderCreate->create($result); - $join = new GameJoin; - $join->allowField(true)->save([ - 'act_id' => $game['act_id'], - 'game_id' => $game['id'], - 'user_id' => $this->auth->id, - 'order_id' => $order['id'], - 'status' => 0, //待支付 - 'users' => json_encode($params['users'] ?? []) - ]); + $cost = json_decode($game['cost'], true); + if (!empty($cost['type']) && ($cost['type'] == 10 || $cost['type'] == 30)) { + $orderCreate = new OrderCreate($params); + $result = $orderCreate->calc('create'); + $order = $orderCreate->create($result); + $join = new GameJoin; + $join->allowField(true)->save([ + 'act_id' => $game['act_id'], + 'game_id' => $game['id'], + 'user_id' => $this->auth->id, + 'order_id' => $order['id'], + 'status' => 0, //待支付 + 'users' => json_encode($params['users'] ?? []) + ]); + } foreach ($participant as &$p) { $p['game_join_id'] = $join->id; } @@ -258,6 +261,6 @@ class Activity extends Base $this->error($e->getMessage(), $e); } - $this->success('Success', $order); + $this->success('Success', $order ?? []); } } diff --git a/addons/shopro/controller/zy/Circle.php b/addons/shopro/controller/zy/Circle.php index 39d241e..5075229 100644 --- a/addons/shopro/controller/zy/Circle.php +++ b/addons/shopro/controller/zy/Circle.php @@ -236,7 +236,7 @@ class Circle extends Base 'name' => '通知消息', 'avatar' => '', 'from_id' => 1, - 'target_id' => $model->user_id, + 'user_id' => $model->user_id, 'content' => json_encode([ 'topic' => '影圈审核', 'result' => ($params['status'] == 1) ? '通过' : '不通过', diff --git a/addons/shopro/controller/zy/Club.php b/addons/shopro/controller/zy/Club.php index 3fe2f0c..62c5e44 100644 --- a/addons/shopro/controller/zy/Club.php +++ b/addons/shopro/controller/zy/Club.php @@ -227,8 +227,7 @@ class Club extends Base 'type' => 3, 'name' => $club->name, 'avatar' => $club->logo, - 'from_id' => $this->auth->id, - 'target_id' => $club->id, + 'from_id' => $club->id, 'content' => json_encode([ 'topic' => '俱乐部加入申请', '俱乐部名称' => $club->name, @@ -301,8 +300,7 @@ class Club extends Base 'type' => 3, 'name' => $club->name, 'avatar' => $club->logo, - 'from_id' => $this->auth->id, - 'target_id' => $params['club_id'], + 'from_id' => $club->id, 'content' => json_encode([ 'topic' => '俱乐部加入申请', '俱乐部名称' => $club->name, diff --git a/addons/shopro/controller/zy/Game.php b/addons/shopro/controller/zy/Game.php index 29ea5f4..f96f18b 100644 --- a/addons/shopro/controller/zy/Game.php +++ b/addons/shopro/controller/zy/Game.php @@ -118,7 +118,7 @@ class Game extends Base 'name' => '系统消息', 'avatar' => '', 'from_id' => 0, - 'target_id' => $join->user_id, + 'user_id' => $join->user_id, 'content' => json_encode([ 'topic' => '退出', 'content' => '已退出 ' . $model['name'] . ' 活动', @@ -180,7 +180,7 @@ class Game extends Base 'name' => '系统消息', 'avatar' => '', 'from_id' => 0, - 'target_id' => $j->user_id, + 'user_id' => $j->user_id, 'content' => json_encode([ 'topic' => '评论', 'content' => $model['name'] . ' 活动已取消', diff --git a/addons/shopro/controller/zy/Sys.php b/addons/shopro/controller/zy/Sys.php index 67495bf..6ea619c 100644 --- a/addons/shopro/controller/zy/Sys.php +++ b/addons/shopro/controller/zy/Sys.php @@ -2,12 +2,12 @@ namespace addons\shopro\controller\zy; -use app\admin\model\zy\link\Visitor; + use think\Db; use think\Exception; use app\admin\model\zy\Tags; use think\exception\PDOException; -use app\admin\model\zy\link\Message; +use app\admin\model\zy\link\Visitor; use app\admin\model\shopro\user\User; use app\admin\model\zy\circle\Circle; use app\admin\model\zy\link\Complaint; diff --git a/application/admin/lang/zh-cn/zy/game/activity.php b/application/admin/lang/zh-cn/zy/game/activity.php index 737219f..87092db 100644 --- a/application/admin/lang/zh-cn/zy/game/activity.php +++ b/application/admin/lang/zh-cn/zy/game/activity.php @@ -79,5 +79,4 @@ return [ 'Week5' => '周五', 'Week6' => '周六', - ]; diff --git a/application/admin/lang/zh-cn/zy/game/game_join.php b/application/admin/lang/zh-cn/zy/game/game_join.php index 5d9bb80..ec6abcd 100644 --- a/application/admin/lang/zh-cn/zy/game/game_join.php +++ b/application/admin/lang/zh-cn/zy/game/game_join.php @@ -17,4 +17,12 @@ return [ 'Status-1' => '取消', 'Status0' => '待支付', 'Status1' => '已支付', + + 'Cost10' => '报名时收取', + 'Cost21' => '活动后收取:固定', + 'Cost22' => '活动后收取:AA', + 'Cost23' => '活动后收取:女固定男AA', + 'Cost24' => '活动后收取:AA,男比女高X元', + 'Cost25' => '活动后收取:AA,男比女高X%', + 'Cost30' => '多退少补', ]; diff --git a/application/admin/model/zy/game/Activity.php b/application/admin/model/zy/game/Activity.php index fbe497d..68f4517 100644 --- a/application/admin/model/zy/game/Activity.php +++ b/application/admin/model/zy/game/Activity.php @@ -29,7 +29,7 @@ class Activity extends Model - public $costKey = ['man' => '男报名费', 'woman' => '女报名费', 'extra' => '附加费', 'server' => '服务费']; + public $costKey = ['pay_type' => '支付方式', 'male' => '男费用', 'woman' => '女费用', 'extra' => '附加费', 'server' => '服务费'];