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, // 大奖