This commit is contained in:
2025-12-21 16:39:53 +08:00
parent f9f0d01948
commit 051d6589e9
2 changed files with 18 additions and 7 deletions

View File

@@ -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);//财富图标

View File

@@ -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);