From ed5488699f469427e098da5987d646cde6bcd83c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Wed, 15 Oct 2025 19:16:23 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=8A=A2=E7=BA=A2=E5=8C=85=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E9=AA=8C=E8=AF=81=E6=8F=90=E7=A4=BA=E8=AF=AD=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/RedpacketService.php | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/application/common/service/RedpacketService.php b/application/common/service/RedpacketService.php index db1aa65..568f3a9 100644 --- a/application/common/service/RedpacketService.php +++ b/application/common/service/RedpacketService.php @@ -595,10 +595,37 @@ class RedpacketService */ private function checkUserOnMic($userId,$roomId) { - $onPit = Db::name('vs_room_pit')->where(['user_id' => $userId,'room_id' => $roomId])->value('pit_number'); - if ($onPit <= 0){ - return false; + $room_type = Db::name('vs_room')->where('id',$roomId)->field('type_id,label_id'); + //实际麦位 + if($room_type['type_id'] == 1 || $room_type['type_id'] == 7 || $room_type['type_id'] == 8){ + $onPit = Db::name('vs_room_pit')->where(['user_id' => $userId,'room_id' => $roomId])->value('pit_number'); + if ($onPit <= 0){ + return false; + } + }elseif($room_type['type_id'] ==2){//拍卖 + //获取房间的当前拍卖ID + $auctionId = Db::name('vs_room_auction')->where(['room_id' => $roomId,'status' => 2])->value('auction_id'); + $onPit = []; + if($auctionId){ + $onPits = model('api/RoomAuction')->room_auction_list_on($auctionId); + //提取数组里面的user_id的值 来判断用户是否在里面 + $onPit = array_column($onPits,'user_id'); + //拍卖位 从缓存中取 Cache::get('auction_user_'.$room_id) + $onpitNumber_10 = Cache::get('auction_user_'.$roomId); + if($onpitNumber_10){ + $onPit[] = $onpitNumber_10; + } + } + $onpitNumber_9 = Db::name('vs_room_pit')->where(['pit_number' => 9,'room_id' => $roomId])->value('user_id'); + if($onpitNumber_9){ + $onPit[] = $onpitNumber_9; + } + + if (!in_array($userId,$onPit)){ + return false; + } } + return true; } From 754bc120ca53edbea4478cff373efd7ca8ec1587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Wed, 15 Oct 2025 19:22:00 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=8A=A2=E7=BA=A2=E5=8C=85=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E9=AA=8C=E8=AF=81=E6=8F=90=E7=A4=BA=E8=AF=AD=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/service/RedpacketService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/common/service/RedpacketService.php b/application/common/service/RedpacketService.php index 568f3a9..7023e20 100644 --- a/application/common/service/RedpacketService.php +++ b/application/common/service/RedpacketService.php @@ -595,7 +595,7 @@ class RedpacketService */ private function checkUserOnMic($userId,$roomId) { - $room_type = Db::name('vs_room')->where('id',$roomId)->field('type_id,label_id'); + $room_type = Db::name('vs_room')->where('id',$roomId)->field('type_id,label_id')->find(); //实际麦位 if($room_type['type_id'] == 1 || $room_type['type_id'] == 7 || $room_type['type_id'] == 8){ $onPit = Db::name('vs_room_pit')->where(['user_id' => $userId,'room_id' => $roomId])->value('pit_number'); From beb87cf3fde7fa1232ba2d7a00b11ccbd25969a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Thu, 16 Oct 2025 09:18:16 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=B0=8F=E6=97=B6=E6=A6=9C=E7=BA=A2?= =?UTF-8?q?=E5=8C=85=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/model/RoomHourRanking.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/application/api/model/RoomHourRanking.php b/application/api/model/RoomHourRanking.php index f7acd49..25869cd 100644 --- a/application/api/model/RoomHourRanking.php +++ b/application/api/model/RoomHourRanking.php @@ -32,17 +32,6 @@ class RoomHourRanking extends Model // $is_open_red_pack = db::name('vs_hour_ranking_config')->where('id', 1)->value('is_open_red_pack'); $is_open_red_pack = 0 ; -// $profit = db::name('vs_room')->alias('a') -// ->join('vs_give_gift b', 'a.id = b.from_id AND b.from = 2 AND b.createtime BETWEEN '.$start_time.' AND '.$end_time, 'left') -// ->join('vs_room_label c', 'a.label_id = c.id','left') -// ->field('a.id as room_id,a.user_id,a.room_name,a.label_id,a.room_cover,IFNULL(sum(b.total_price), 0) as total_price,c.label_icon') -// ->where('a.room_status', 1) // 只统计正常状态的房间 -// ->where('a.apply_status', 2) // 只统计审核通过的房间 -// ->where('a.type_id', '<>', 6) -// ->group('a.id') -// ->order('total_price', 'desc') -// ->page($page, $page_limit) -// ->select(); // 更进一步的优化版本: $subQuery = Db::name('vs_give_gift') ->where('from', 2) @@ -70,6 +59,13 @@ class RoomHourRanking extends Model }else{ $v['xlh_status'] = 0; } + //查询房间是否有红包 + if($v['room_id'] > 0){ + $red_pack_status = Db::name('redpacket')->where(['room_id' => $v['room_id'], 'status' => ['<=',1]])->count(); + $v['redpacket_status'] = $red_pack_status; + }else{ + $v['redpacket_status'] = 0; + } } } //当前小时开始时间 和结束时间 00:00-00:59 这样的格式 From 774107e28f4c2da5ab73a051f9e562ab9247eff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Thu, 16 Oct 2025 10:16:20 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E7=BA=A2=E5=8C=85=20=E6=8A=A2=E5=AE=8C?= =?UTF-8?q?=E9=94=80=E6=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/model/Chat.php | 2 ++ application/common/service/RedpacketService.php | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/application/api/model/Chat.php b/application/api/model/Chat.php index 7ee1a97..8e66e36 100644 --- a/application/api/model/Chat.php +++ b/application/api/model/Chat.php @@ -121,6 +121,8 @@ class Chat extends Model // ClearUserCharm = 1059, //发红包 // RedPacket = 1060, + //红包领完推送 + // RedPacketComplete = 1061, diff --git a/application/common/service/RedpacketService.php b/application/common/service/RedpacketService.php index 7023e20..b05ef77 100644 --- a/application/common/service/RedpacketService.php +++ b/application/common/service/RedpacketService.php @@ -111,6 +111,18 @@ class RedpacketService $amount = floatval($result[1]); $isFinished = $result[2] == 1; // Lua脚本返回是否抢完 + //给前端推送销毁这个红包 + // redis 记录该红包是否已经推送过了 只推送一次 + $redisKey = "redpacket:{$redpacketId}:is_finished"; + if (!$redis->get($redisKey)) { + $redis->set($redisKey, 1); + $text = [ + 'redpacket_id' => $redpacketId, + 'text' => '抢完了,请销毁该红包' + ]; + model('api/Chat')->sendMsg(1061,$redpacket['room_id'],$text); + } + // Lua脚本执行成功,记录到数据库 Db::startTrans(); From 2308ea8b64a76bdbd5c728791047b254968b00bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Thu, 16 Oct 2025 10:23:58 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E7=BA=A2=E5=8C=85=20=E6=8A=A2=E5=AE=8C?= =?UTF-8?q?=E9=94=80=E6=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/service/RedpacketService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/common/service/RedpacketService.php b/application/common/service/RedpacketService.php index b05ef77..44bc17e 100644 --- a/application/common/service/RedpacketService.php +++ b/application/common/service/RedpacketService.php @@ -114,8 +114,8 @@ class RedpacketService //给前端推送销毁这个红包 // redis 记录该红包是否已经推送过了 只推送一次 $redisKey = "redpacket:{$redpacketId}:is_finished"; - if (!$redis->get($redisKey)) { - $redis->set($redisKey, 1); + if (!Cache::get($redisKey)) { + Cache::set($redisKey, 1, $redpacket['countdown']+get_system_config_value('red_packet_time')+60); $text = [ 'redpacket_id' => $redpacketId, 'text' => '抢完了,请销毁该红包' From fd535f969bc21eb2a37dbd9a432640a8d36ae88c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Thu, 16 Oct 2025 10:42:04 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E7=BA=A2=E5=8C=85=20=E6=8A=A2=E5=AE=8C?= =?UTF-8?q?=E9=94=80=E6=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/RedpacketService.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/application/common/service/RedpacketService.php b/application/common/service/RedpacketService.php index 44bc17e..7a6043f 100644 --- a/application/common/service/RedpacketService.php +++ b/application/common/service/RedpacketService.php @@ -113,17 +113,18 @@ class RedpacketService $isFinished = $result[2] == 1; // Lua脚本返回是否抢完 //给前端推送销毁这个红包 // redis 记录该红包是否已经推送过了 只推送一次 - $redisKey = "redpacket:{$redpacketId}:is_finished"; - if (!Cache::get($redisKey)) { - Cache::set($redisKey, 1, $redpacket['countdown']+get_system_config_value('red_packet_time')+60); - $text = [ - 'redpacket_id' => $redpacketId, - 'text' => '抢完了,请销毁该红包' - ]; - model('api/Chat')->sendMsg(1061,$redpacket['room_id'],$text); + if($isFinished){ + $redisKey = "redpacket:{$redpacketId}:is_finished"; + if (!Cache::get($redisKey)) { + Cache::set($redisKey, 1, $redpacket['countdown']+get_system_config_value('red_packet_time')+60); + $text = [ + 'redpacket_id' => $redpacketId, + 'text' => '抢完了,请销毁该红包' + ]; + model('api/Chat')->sendMsg(1061,$redpacket['room_id'],$text); + } } - // Lua脚本执行成功,记录到数据库 Db::startTrans(); try {