diff --git a/application/common/library/LotteryGiftLua.php b/application/common/library/LotteryGiftLua.php index 9bf9b1fc..f18714a0 100644 --- a/application/common/library/LotteryGiftLua.php +++ b/application/common/library/LotteryGiftLua.php @@ -11,14 +11,14 @@ class LotteryGiftLua -- 接收参数:send_uid, gift_gold, small_trigger_times, big_threshold, small_round, big_round, big_total_gold local send_uid = ARGV[1] local gift_gold = tonumber(ARGV[2]) -local small_trigger_times = ARGV[3] -- 小奖池触发次数 +local small_trigger_times = tonumber(ARGV[3]) or 115 -- 小奖池触发次数 local small_round = tonumber(ARGV[4]) -- 小奖池当前轮次 local lucky_rate = tonumber(ARGV[5]) -- 收益率 local lottery_rate = tonumber(ARGV[6]) -- 爆币率 -- 1. 基础金额拆分 -local recv_gold = gift_gold * lucky_rate -local small_pool_add = gift_gold * (1-lucky_rate) +local recv_gold = gift_gold * (lucky_rate / 100) +local small_pool_add = gift_gold * (1-(lucky_rate / 100)) -- 2. Redis键定义 local small_round_key = "lottery:small_pool:round" @@ -62,7 +62,6 @@ if small_total_times >= small_trigger_times then small_round = small_round + 1 redis.call('set', small_round_key, small_round) result.small_round = small_round - end -- 返回结果 diff --git a/application/common/service/LotteryService.php b/application/common/service/LotteryService.php index 8a8feea6..07df25e8 100644 --- a/application/common/service/LotteryService.php +++ b/application/common/service/LotteryService.php @@ -107,8 +107,11 @@ class LotteryService // 读取配置+独立轮次 $small_trigger_times = intval($this->config['small_pool_trigger_times'] ?? 200);//触发抽奖次数 $small_round = intval($this->redis->get('lottery:small_pool:round') ?: 1);//小奖轮次 - $lucky_rate = db::name('bb_lottery_config')->where(['key' => 'lucky_rate'])->value('value');//收益率 - $lottery_rate = db::name('bb_lottery_config')->where(['key' => 'lottery_rate'])->value('value');//爆币率 + $lucky_rate = intval($this->config['lucky_rate'] ?? 1);//收益率 + $lottery_rate = intval($this->config['lottery_rate'] ?? 115);//爆币率 + if($lottery_rate <= 2){ + throw new Exception('配置错误'); + } // 加载Lua脚本