From 9429cf17c1e49248a40f67252b566579c1d83c44 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 15:16:27 +0800 Subject: [PATCH 1/7] =?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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/api/model/Lottery.php b/application/api/model/Lottery.php index 39f10150..93d96116 100644 --- a/application/api/model/Lottery.php +++ b/application/api/model/Lottery.php @@ -81,7 +81,7 @@ class Lottery extends Model return ['code' => 0, 'msg' => '送礼失败', 'data' => null]; } //计算收礼人得益 - $receiver_earnings = $gift_price /2/100; + $receiver_earnings = $gift_price /2/get_system_config_value('rmb_coin_ratio'); //增加收益并记录日志 $receiver = model('api/GiveGift') -> change_user_cion_or_earnings_log($to_id,$receiver_earnings,$room_id,2,11,'收礼增加收益'); From 5e66113357da8f97a04fb2f32d334e787f65b6a8 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 15:35:09 +0800 Subject: [PATCH 2/7] =?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 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/application/api/model/Lottery.php b/application/api/model/Lottery.php index 93d96116..36c9ae39 100644 --- a/application/api/model/Lottery.php +++ b/application/api/model/Lottery.php @@ -75,7 +75,7 @@ class Lottery extends Model $giftId = Db::name('bb_lottery_gift_record')->insertGetId($giftRecord); //收礼记录行为日志 - $give_gift = model('api/GiveGift')->change_user_give_gift_log($send_uid,$gift_id,$gift_price,$num,$to_id,2,1,$room_id,0); + $give_gift = model('api/GiveGift')->change_user_give_gift_log($send_uid,$gift_id,$gift_price,$num,$to_id,2,1,0,0); if(!$give_gift){ Db::rollback(); return ['code' => 0, 'msg' => '送礼失败', 'data' => null]; @@ -85,12 +85,12 @@ class Lottery extends Model //增加收益并记录日志 $receiver = model('api/GiveGift') -> change_user_cion_or_earnings_log($to_id,$receiver_earnings,$room_id,2,11,'收礼增加收益'); - //用户魅力等级更新 - $user_level = model('api/Level')->user_level_data_update($to_id,$gift_price,2,$room_id); - if(!$user_level){ - Db::rollback(); - return ['code' => 0, 'msg' => '用户等级更新失败', 'data' => null]; - } +// //用户魅力等级更新 +// $user_level = model('api/Level')->user_level_data_update($to_id,$gift_price,2,$room_id); +// if(!$user_level){ +// Db::rollback(); +// return ['code' => 0, 'msg' => '用户等级更新失败', 'data' => null]; +// } //增加房间幸运值 db::name('vs_room')->where(['id' => $room_id])->setInc('luck_value',$gift_price); db::name('vs_room_luck_value')->insert( [ From 9bfcc77d1cde1b07e3a066d4b498c32df3e88ece 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 16:09:09 +0800 Subject: [PATCH 3/7] =?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 | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/application/common/service/LotteryService.php b/application/common/service/LotteryService.php index 6ac676f7..1e1bf602 100644 --- a/application/common/service/LotteryService.php +++ b/application/common/service/LotteryService.php @@ -147,21 +147,21 @@ class LotteryService ); } else { $winnerUid = $send_uid; // 奖默认给当前送礼用户 - // 1. 只要开小奖,小奖剩余划入大奖池流水 - $this->addPoolFlow( - 2, // 大奖池 - 3, // 划转 - $result['small_remain_amount'],//小奖剩余金额 - $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) { + //开小奖,小奖剩余划入大奖池流水 + $this->addPoolFlow( + 2, // 大奖池 + 3, // 划转 + $result['small_remain_amount'],//小奖剩余金额 + $result['big_total_gold'] - $result['small_remain_amount'], + $result['big_total_gold'], + $giftId, + $result['big_round'] - ($result['is_big_prize'] ? 1 : 0), + "小奖剩余划转大奖池:{$result['small_remain_amount']}金币" + ); + //2.1 大奖中奖记录 $this->addWinnerRecord( $winnerUid, @@ -217,7 +217,17 @@ class LotteryService $result['small_round'] - 1, // 开奖轮次为当前轮次-1(已结束的轮次) "小奖池开奖:轮次" . ($result['small_round'] - 1).",中奖金额:{$result['small_prize_amount']}金币" ); - + //开小奖,小奖剩余划入大奖池流水 + $this->addPoolFlow( + 2, // 大奖池 + 3, // 划转 + $result['small_remain_amount'],//小奖剩余金额 + $result['big_total_gold'] - $result['small_remain_amount'], + $result['big_total_gold'], + $giftId, + $result['big_round'] - ($result['is_big_prize'] ? 1 : 0), + "小奖剩余划转大奖池:{$result['small_remain_amount']}金币" + ); } } From fe83b67ef4b72dfdb60f8e563dcd98fef172e0d5 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 16:58:31 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=B9=B8=E8=BF=90=E5=B8=81=20=E4=B8=8D?= =?UTF-8?q?=E5=8F=82=E4=B8=8E=E5=90=84=E7=A7=8D=E7=A4=BC=E7=89=A9=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/RoomAuction.php | 14 +++++++++++++- application/api/controller/RoomPit.php | 4 ++++ application/api/controller/SingerSong.php | 8 ++++++++ application/api/controller/UserZone.php | 4 ++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/application/api/controller/RoomAuction.php b/application/api/controller/RoomAuction.php index 36180fa8..9e576ace 100644 --- a/application/api/controller/RoomAuction.php +++ b/application/api/controller/RoomAuction.php @@ -3,6 +3,7 @@ namespace app\api\controller; use app\common\controller\BaseCom; +use think\Db; class RoomAuction extends BaseCom { @@ -18,6 +19,10 @@ class RoomAuction extends BaseCom public function room_auction_time() { $gift_id = input('gift_id'); + $pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value'); + if($gift_id == $pool_gift_id){ + return V(0, '此礼物不能进行此操作'); + } $reslut = model('RoomAuction')->room_auction_time($gift_id); return V($reslut['code'], $reslut['msg'], $reslut['data']); } @@ -34,6 +39,10 @@ class RoomAuction extends BaseCom if (in_array($gift_id, $cp_gift_ids)) { return V( 0, '礼物不能是CP礼物,请重新选择'); } + $pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value'); + if($gift_id == $pool_gift_id){ + return V(0, '此礼物不能进行此操作'); + } $relation_id = input('relation_id',''); $auction_type = input('auction_type',1);//1真爱拍 2 亲密拍 $time_day = input('time_day', 0);//小时 @@ -59,7 +68,10 @@ class RoomAuction extends BaseCom $gift_id = input('gift_id'); $num = input('num'); $type = input('type',1);//1金币购买 2送背包礼物 - + $pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value'); + if($gift_id == $pool_gift_id){ + return V(0, '此礼物不能进行此操作'); + } $reslut = model('RoomAuction')->room_auction_join($auction_id,$user_id,$gift_id,$num,$type); return V($reslut['code'], $reslut['msg'], $reslut['data']); } diff --git a/application/api/controller/RoomPit.php b/application/api/controller/RoomPit.php index f10c6f5d..3271a2fe 100644 --- a/application/api/controller/RoomPit.php +++ b/application/api/controller/RoomPit.php @@ -89,6 +89,10 @@ class RoomPit extends BaseCom $room_id = input('room_id', 0); $gift_id = input('gift_id', 0); $gift_price = input('gift_price', 0); + $pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value'); + if($gift_id == $pool_gift_id){ + return V(0, '此礼物不能进行此操作'); + } $reslut = model('RoomPit')->set_room_pit_apply_help_gift($this->uid, $room_id, $gift_id, $gift_price); return V($reslut['code'], $reslut['msg'], $reslut['data']); } diff --git a/application/api/controller/SingerSong.php b/application/api/controller/SingerSong.php index 68d06a52..6d9a4c6c 100644 --- a/application/api/controller/SingerSong.php +++ b/application/api/controller/SingerSong.php @@ -33,6 +33,10 @@ class SingerSong extends BaseCom if (!$gift_id) { return V(0, '请选择礼物'); } + $pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value'); + if($gift_id == $pool_gift_id){ + return V(0, '此礼物不能进行此操作'); + } $gift_num = input('gift_num', 1); $reslut = model('SingerSong')->singerAddSong($this->uid, $song_name, $gift_id, $gift_num); return V($reslut['code'], $reslut['msg'], $reslut['data']); @@ -71,6 +75,10 @@ class SingerSong extends BaseCom if (!$gift_id) { return V(0, '请选择礼物'); } + $pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value'); + if($gift_id == $pool_gift_id){ + return V(0, '此礼物不能进行此操作'); + } $gift_num = input('gift_num', 1); $reslut = db::name('vs_singer_song')->insert([ 'user_id' => $this->uid, diff --git a/application/api/controller/UserZone.php b/application/api/controller/UserZone.php index f48b51a5..c05c16b4 100644 --- a/application/api/controller/UserZone.php +++ b/application/api/controller/UserZone.php @@ -185,6 +185,10 @@ class UserZone extends BaseCom $gift_id = input('gift_id', 0); $num = input('num', 1); $is_pack = input('is_pack', 1);//2背包 1金币 + $pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value'); + if($gift_id == $pool_gift_id){ + return V(0, '此礼物不能进行此操作'); + } $reslut = model('GiveGift')->reward_zone($this->uid, $zid, $gift_id, $num, $is_pack); return V($reslut['code'], $reslut['msg'], $reslut['data']); } From 7c002eab1d582c1a7e03c42631bdaa85555f3e00 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 17:16:20 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E6=8A=A2=E7=BA=A2=E5=8C=85=20=E9=BA=A6?= =?UTF-8?q?=E4=B8=8A=E7=94=A8=E6=88=B7=20=E5=8F=AF=E6=8A=A2?= 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 7a6043f7..f497f155 100644 --- a/application/common/service/RedpacketService.php +++ b/application/common/service/RedpacketService.php @@ -610,7 +610,7 @@ class RedpacketService { $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){ + if($room_type['type_id'] == 1 || $room_type['type_id'] == 7 || $room_type['type_id'] == 8 || $room_type['type_id'] == 9 || $room_type['type_id'] == 10){ $onPit = Db::name('vs_room_pit')->where(['user_id' => $userId,'room_id' => $roomId])->value('pit_number'); if ($onPit <= 0){ return false; From 702f09d0de0b2fee9a7aeda22658745f76df291b 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 17:43:32 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=8A=A2=E7=BA=A2?= =?UTF-8?q?=E5=8C=85=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/library/RedpacketLua.php | 30 ++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/application/common/library/RedpacketLua.php b/application/common/library/RedpacketLua.php index e5359ae6..952f24b2 100644 --- a/application/common/library/RedpacketLua.php +++ b/application/common/library/RedpacketLua.php @@ -69,29 +69,35 @@ if leftCount <= 0 or leftAmount <= 0 then return {0, "红包已抢完", 0} end --- 计算红包金额 +-- 计算红包金额(核心修改:适配整数金币,避免0) local amount = 0 local isFinished = 0 if leftCount == 1 then - -- 最后一个红包,获得剩余所有金额 + -- 最后一个红包,获得剩余所有金额(确保至少1) amount = leftAmount isFinished = 1 else - -- 随机算法:二倍均值法,保证公平性 - local maxAmount = leftAmount / leftCount * 2 - amount = math.random(1, math.floor(maxAmount)) - -- 确保金额不会超过剩余金额 - if amount > leftAmount then - amount = leftAmount - end - -- 检查是否是最后一个(由于浮点数计算可能有误差) - if leftCount == 1 or (leftAmount - amount) < 0.01 then + -- 随机算法:二倍均值法(适配整数,保证最低1) + -- 1. 计算二倍均值(整数处理,向下取整) + local avg = leftAmount / leftCount + local maxAmount = math.floor(avg * 2) + -- 2. 确保最大金额至少为1,且不超过剩余金额-(剩余个数-1)(避免后续红包无金额可分) + -- 剩余金额-(剩余个数-1):保证剩下的每个红包至少能分1个金币 + local safeMax = leftAmount - (leftCount - 1) + maxAmount = math.min(maxAmount, safeMax) + maxAmount = math.max(maxAmount, 1) -- 确保最小可随机值为1 + + -- 3. 随机生成1到maxAmount之间的整数(避免0) + amount = math.random(1, maxAmount) + + -- 4. 检查是否抢完(整数判断,无需浮点数误差处理) + if leftCount - 1 == 1 or (leftAmount - amount) <= 0 then isFinished = 1 end end --- 更新红包数据 +-- 更新红包数据(整数处理,无小数) local newLeftAmount = leftAmount - amount local newLeftCount = leftCount - 1 From 7664fd812de1bc82c6f8e9afa9c77985d72ab8b8 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 17:52:31 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=8A=A2=E7=BA=A2?= =?UTF-8?q?=E5=8C=85=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/library/RedpacketLua.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/application/common/library/RedpacketLua.php b/application/common/library/RedpacketLua.php index 952f24b2..8ab7fa82 100644 --- a/application/common/library/RedpacketLua.php +++ b/application/common/library/RedpacketLua.php @@ -69,7 +69,7 @@ if leftCount <= 0 or leftAmount <= 0 then return {0, "红包已抢完", 0} end --- 计算红包金额(核心修改:适配整数金币,避免0) +-- 计算红包金额(核心修复:解决3金币2红包场景第二个红包为0的问题) local amount = 0 local isFinished = 0 @@ -78,21 +78,24 @@ if leftCount == 1 then amount = leftAmount isFinished = 1 else - -- 随机算法:二倍均值法(适配整数,保证最低1) - -- 1. 计算二倍均值(整数处理,向下取整) + -- 随机算法:二倍均值法(适配整数+保底逻辑,彻底避免0) + -- 1. 基础二倍均值(整数处理) local avg = leftAmount / leftCount local maxAmount = math.floor(avg * 2) - -- 2. 确保最大金额至少为1,且不超过剩余金额-(剩余个数-1)(避免后续红包无金额可分) - -- 剩余金额-(剩余个数-1):保证剩下的每个红包至少能分1个金币 + + -- 2. 核心修复:保底限制 - 最大金额不能超过「剩余金额 - (剩余个数 - 1)」 + -- 确保剩下的每个红包至少能分到1个金币(比如3金币2红包:3 - (2-1) = 2,第一个红包最多抢2) local safeMax = leftAmount - (leftCount - 1) maxAmount = math.min(maxAmount, safeMax) - maxAmount = math.max(maxAmount, 1) -- 确保最小可随机值为1 - -- 3. 随机生成1到maxAmount之间的整数(避免0) + -- 3. 强制保证最小金额为1,最大金额不小于1 + maxAmount = math.max(maxAmount, 1) + + -- 4. 随机生成1到maxAmount之间的整数(绝对不会出现0) amount = math.random(1, maxAmount) - -- 4. 检查是否抢完(整数判断,无需浮点数误差处理) - if leftCount - 1 == 1 or (leftAmount - amount) <= 0 then + -- 5. 整数场景下的抢完判断(无需浮点数误差处理) + if (leftCount - 1) == 1 and (leftAmount - amount) == 0 then isFinished = 1 end end