From 694483f52695b21dfc5de24df31332fa88f3f4ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Sun, 21 Dec 2025 20:10:18 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E7=88=86=E5=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/service/LotteryService.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/application/common/service/LotteryService.php b/application/common/service/LotteryService.php index d00f5b77..520ae515 100644 --- a/application/common/service/LotteryService.php +++ b/application/common/service/LotteryService.php @@ -210,12 +210,12 @@ class LotteryService $this->addPoolFlow( 1, // 小奖池 2, // 开奖扣除 + $result['small_prize_amount'], $result['small_total_gold'], - $result['small_total_gold'], - 0, + $result['small_total_gold'] - $result['small_prize_amount'], $giftId, $result['small_round'] - 1, // 开奖轮次为当前轮次-1(已结束的轮次) - "小奖池开奖:轮次" . ($result['small_round'] - 1).",累计{$result['small_total_gold']}金币" + "小奖池开奖:轮次" . ($result['small_round'] - 1).",中奖金额:{$result['small_prize_amount']}金币" ); } From 0624562ddadaee149a3e6988f7f896bf96f078e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Sun, 21 Dec 2025 20:54:12 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E7=88=86=E5=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/model/Lottery.php | 14 ++++++++------ application/common/library/LotteryGiftLua.php | 4 ++-- application/common/service/LotteryService.php | 8 ++++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/application/api/model/Lottery.php b/application/api/model/Lottery.php index 785f0f44..39f10150 100644 --- a/application/api/model/Lottery.php +++ b/application/api/model/Lottery.php @@ -43,12 +43,6 @@ class Lottery extends Model $FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($send_uid);//魅力图标 $FromUserInfo['chat_bubble'] = model('Decorate')->user_decorate_detail($send_uid,9);//聊天气泡 - $nums = $num * count($toarray); - $ress = $this->lottery($send_uid,$gift_info['gift_price'],$nums,$room_id,$gift_id,$FromUserInfo,$gift_info); - if($ress['code'] == 0){ - return ['code' => 0, 'msg' => $ress['msg'], 'data' => null]; - } - //送礼 开启事务 Db::startTrans(); //扣除用户金币并记录日志 @@ -125,6 +119,14 @@ class Lottery extends Model model('api/Chat')->sendMsg(1005,$room_id,$text); } Db::commit(); + + //计算爆币 + $nums = $num * count($toarray); + $ress = $this->lottery($send_uid,$gift_info['gift_price'],$nums,$room_id,$gift_id,$FromUserInfo,$gift_info); + if($ress['code'] == 0){ + return ['code' => 0, 'msg' => $ress['msg'], 'data' => null]; + } + return ['code' => 1, 'msg' => '送礼成功', 'data' => null]; } diff --git a/application/common/library/LotteryGiftLua.php b/application/common/library/LotteryGiftLua.php index 6ad47631..b705f0c4 100644 --- a/application/common/library/LotteryGiftLua.php +++ b/application/common/library/LotteryGiftLua.php @@ -245,8 +245,8 @@ if small_total_times >= small_trigger_times then result.big_ratio = big_ratio -- 大奖金额计算(基于开奖前的总金额) - result.big_prize_amount = math.floor(result.big_pool_total_before_open * big_ratio / 100 * 100) / 100 - result.big_release_amount = math.floor((result.big_pool_total_before_open - result.big_prize_amount) * 100) / 100 + result.big_prize_amount = math.floor(big_threshold * big_ratio / 100) + result.big_release_amount = math.floor(big_total_gold - result.big_prize_amount) -- 重置大奖池,大轮次+1 redis.call('set', big_total_gold_key, 0) diff --git a/application/common/service/LotteryService.php b/application/common/service/LotteryService.php index 520ae515..6ac676f7 100644 --- a/application/common/service/LotteryService.php +++ b/application/common/service/LotteryService.php @@ -152,17 +152,17 @@ class LotteryService 2, // 大奖池 3, // 划转 $result['small_remain_amount'],//小奖剩余金额 - $result['big_total_gold'] - $result['small_remain_amount'], - $result['big_total_gold'], + $result['big_pool_total_before_open'] - $result['small_remain_amount'], + $result['big_pool_total_before_open'], $giftId, $result['big_round'] - ($result['is_big_prize'] ? 1 : 0), "小奖剩余划转大奖池:{$result['small_remain_amount']}金币" ); - //2.开小奖剩余划入大奖后 大奖够开奖 + //开大奖 if ($result['is_big_prize'] == 1) { - // 大奖中奖记录 + //2.1 大奖中奖记录 $this->addWinnerRecord( $winnerUid, 2, // 大奖 From b9d876437a899d0b06ddbb21c62426b199eeb05f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Sun, 21 Dec 2025 20:57:14 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E7=88=86=E5=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/service/LotteryService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/common/service/LotteryService.php b/application/common/service/LotteryService.php index 6ac676f7..f94300e6 100644 --- a/application/common/service/LotteryService.php +++ b/application/common/service/LotteryService.php @@ -124,7 +124,7 @@ class LotteryService $this->bigPrizeWeights['80'], $this->bigPrizeWeights['total'] ], 0); -// var_dump($result);die; + var_dump($result);die; $result = json_decode($result, true); if (json_last_error() !== JSON_ERROR_NONE) { throw new Exception('Lua脚本执行失败'); From 81912377753405e2ef2ec4650801fdd90c01f1c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Sun, 21 Dec 2025 20:59:41 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E7=88=86=E5=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/library/LotteryGiftLua.php | 2 +- application/common/service/LotteryService.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/common/library/LotteryGiftLua.php b/application/common/library/LotteryGiftLua.php index b705f0c4..d39bcf59 100644 --- a/application/common/library/LotteryGiftLua.php +++ b/application/common/library/LotteryGiftLua.php @@ -246,7 +246,7 @@ if small_total_times >= small_trigger_times then -- 大奖金额计算(基于开奖前的总金额) result.big_prize_amount = math.floor(big_threshold * big_ratio / 100) - result.big_release_amount = math.floor(big_total_gold - result.big_prize_amount) + result.big_release_amount = math.floor(big_total_gold - result.big_prize_amount) -- 重置大奖池,大轮次+1 redis.call('set', big_total_gold_key, 0) diff --git a/application/common/service/LotteryService.php b/application/common/service/LotteryService.php index f94300e6..6ac676f7 100644 --- a/application/common/service/LotteryService.php +++ b/application/common/service/LotteryService.php @@ -124,7 +124,7 @@ class LotteryService $this->bigPrizeWeights['80'], $this->bigPrizeWeights['total'] ], 0); - var_dump($result);die; +// var_dump($result);die; $result = json_decode($result, true); if (json_last_error() !== JSON_ERROR_NONE) { throw new Exception('Lua脚本执行失败'); From 6f32ca2b08fd4722641d59c08d94c6b8943f2b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Mon, 22 Dec 2025 09:13:52 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E7=88=86=E5=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Room.php | 10 ++++++++++ application/api/model/Room.php | 24 +++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/application/api/controller/Room.php b/application/api/controller/Room.php index 162f5d37..c032a886 100644 --- a/application/api/controller/Room.php +++ b/application/api/controller/Room.php @@ -128,6 +128,16 @@ class Room extends BaseCom return V($reslut['code'], $reslut['msg'], $reslut['data']); } + + //进入房间前的判断 + public function before_join_room_check() + { + $room_id = input('room_id', 0); + $reslut = model('Room')->before_join_room_check($this->uid, $room_id); + return V($reslut['code'], $reslut['msg'], $reslut['data']); + } + + /* * 进入房间 */ diff --git a/application/api/model/Room.php b/application/api/model/Room.php index f63e90cd..cb53b258 100644 --- a/application/api/model/Room.php +++ b/application/api/model/Room.php @@ -555,8 +555,8 @@ class Room extends Model return ['code' => 1, 'msg' => '成功', 'data' => ['total_amount' => $total_amount, 'total_earning' => $total_earning,'list' => $list_data_array]]; } - //进入房间 - public function join_room($user_id, $room_id, $password) { + //进入房间前的判断 + public function before_join_room_check($user_id, $room_id) { $room = db::name('vs_room')->where(['id' => $room_id,'apply_status' => ['in',[1,2]]])->find(); if (!isset($room)) { return ['code' => 0, 'msg' => '房间不存在', 'data' => '']; @@ -564,11 +564,6 @@ class Room extends Model if($room['apply_status'] == 1){ return ['code' => 0, 'msg' => '房间正在审核中……', 'data' => '']; } - if(isset($room['password']) && $user_id != $room['user_id']){ - if (empty($password) || $room['password'] != md5($password)) { - return ['code' => 0, 'msg' => '密码错误', 'data' => '']; - } - } if ($room['room_status'] == 2) {//1正常2封禁3关闭 $minutes = floor(($room['seal_time'] - time()) % 86400 / 60); @@ -646,7 +641,22 @@ class Room extends Model $this->quit_room($user_id, $room_user,$user_id); } } + return ['code' => 1, + 'msg' => '成功', + 'data' => null + ]; + } + //进入房间 + public function join_room($user_id, $room_id, $password) { + $room = db::name('vs_room')->where(['id' => $room_id,'apply_status' => ['in',[1,2]]])->find(); + if(isset($room['password']) && $user_id != $room['user_id']){ + if (empty($password) || $room['password'] != md5($password)) { + return ['code' => 0, 'msg' => '密码错误', 'data' => '']; + } + } + + $room = db::name('vs_room')->where(['id' => $room_id,'apply_status' => ['in',[1,2]]])->find(); //K歌模式下获取歌曲信息 $song_pit_list = null; $song_list = null;