From 051d6589e904dc8ab43517d40c71e1e87603f217 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 16:39:53 +0800 Subject: [PATCH] =?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 | 13 ++++++++++++- application/common/service/LotteryService.php | 12 ++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/application/api/model/Lottery.php b/application/api/model/Lottery.php index 84dcd9e9..2ac3ccff 100644 --- a/application/api/model/Lottery.php +++ b/application/api/model/Lottery.php @@ -80,7 +80,7 @@ class Lottery extends Model return ['code' => 0, 'msg' => '送礼失败', 'data' => null]; } //计算收礼人得益 - $receiver_earnings = model('GiveGift')->receiver_earnings($to_id,$gift_price,2); + $receiver_earnings = $gift_price /2/100; //增加收益并记录日志 $receiver = $this -> change_user_cion_or_earnings_log($to_id,$receiver_earnings,$room_id,2,11,'收礼增加收益'); @@ -90,6 +90,17 @@ class Lottery extends Model 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( [ + 'room_id' => $room_id, + 'send_uid' => $send_uid, + 'recv_uid' => $to_id, + 'gift_id' => $gift_id, + 'num' => $num, + 'luck_value' => $gift_price, + 'createtime' => time() + ]); $ToUserInfo = Db::name('user')->where(['id' => $to_id])->field('id as user_id,nickname,avatar,sex')->find(); $ToUserInfo['icon'][0] = model('UserData')->user_wealth_icon($to_id);//财富图标 diff --git a/application/common/service/LotteryService.php b/application/common/service/LotteryService.php index 5643708f..ff270e29 100644 --- a/application/common/service/LotteryService.php +++ b/application/common/service/LotteryService.php @@ -29,13 +29,13 @@ class LotteryService private function initRedisFromDb() { // 1. 恢复小奖池轮次(取pool_type=1的最大times) - $maxSmallRound = Db::name('lottery_pool_flow')->where('pool_type', 1)->max('times') ?: 1; + $maxSmallRound = Db::name('bb_lottery_pool_flow')->where('pool_type', 1)->max('times') ?: 1; if (!$this->redis->get('lottery:small_pool:round')) { $this->redis->set('lottery:small_pool:round', $maxSmallRound); } // 2. 恢复大奖池轮次(取pool_type=2的最大times) - $maxBigRound = Db::name('lottery_pool_flow')->where('pool_type', 2)->max('times') ?: 1; + $maxBigRound = Db::name('bb_lottery_pool_flow')->where('pool_type', 2)->max('times') ?: 1; if (!$this->redis->get('lottery:big_pool:round')) { $this->redis->set('lottery:big_pool:round', $maxBigRound); } @@ -43,13 +43,13 @@ class LotteryService // 3. 恢复小奖池当前轮次的次数/金额 $small_round = intval($this->redis->get('lottery:small_pool:round')); if (!$this->redis->get('lottery:small_pool:total_times')) { - $smallTotalTimes = Db::name('lottery_pool_flow') + $smallTotalTimes = Db::name('bb_lottery_pool_flow') ->where(['pool_type' => 1, 'type' => 1, 'times' => $small_round]) ->count(); $this->redis->set('lottery:small_pool:total_times', $smallTotalTimes); } if (!$this->redis->get('lottery:small_pool:total_gold')) { - $smallTotalGold = Db::name('lottery_pool_flow') + $smallTotalGold = Db::name('bb_lottery_pool_flow') ->where(['pool_type' => 1, 'type' => 1, 'times' => $small_round]) ->sum('amount') ?: 0; $this->redis->set('lottery:small_pool:total_gold', $smallTotalGold); @@ -58,10 +58,10 @@ class LotteryService // 4. 恢复大奖池当前轮次的金额 $big_round = intval($this->redis->get('lottery:big_pool:round')); if (!$this->redis->get('lottery:big_pool:total_gold')) { - $bigAddGold = Db::name('lottery_pool_flow') + $bigAddGold = Db::name('bb_lottery_pool_flow') ->where(['pool_type' => 2, 'type' => 3, 'times' => $big_round]) ->sum('amount') ?: 0; - $bigReduceGold = Db::name('lottery_pool_flow') + $bigReduceGold = Db::name('bb_lottery_pool_flow') ->where(['pool_type' => 2, 'type' => [2,4], 'times' => $big_round]) ->sum('amount') ?: 0; $this->redis->set('lottery:big_pool:total_gold', $bigAddGold + $bigReduceGold);