新需求-活动需求-盲盒转盘调通盘

This commit is contained in:
2025-10-13 11:26:30 +08:00
parent 212c4faaf3
commit 9c0cd48425
4 changed files with 42 additions and 23 deletions

View File

@@ -623,12 +623,14 @@ class Guild extends adminApi
$search_status_time = input('search_status_time', ''); $search_status_time = input('search_status_time', '');
$search_end_time = input('search_end_time', ''); $search_end_time = input('search_end_time', '');
$search_status = input('search_status', ''); $search_status = input('search_status', '');
$where = ['b.delete_time'=>0]; // $where = ['b.delete_time'=>0];
$where = [];
if($search_user_id){ if($search_user_id){
$where['b.user_id'] = $search_user_id; $where['b.user_id'] = $search_user_id;
} }
if($search_guild_id){ if($search_guild_id){
$where['a.guild_id'] = $search_guild_id; //$where['a.guild_id'] = $search_guild_id;
$where['b.guild_special_id'] = $search_guild_id;
} }
if($search_status_time){ if($search_status_time){
$where['a.start_time'] = ['>=', $search_status_time]; $where['a.start_time'] = ['>=', $search_status_time];

View File

@@ -40,7 +40,7 @@ class BlindBoxTurntable extends BaseCom
$num = input('num',1); $num = input('num',1);
$heart_id = input('heart_id',0); $heart_id = input('heart_id',0);
$auction_id = input('auction_id',0); $auction_id = input('auction_id',0);
$reslut = model('BlindBoxTurntableGiftDraw')->draw_gift($gift_bag_id, $user_id, $gift_user_ids,$num,$room_id,$heart_id,$auction_id); $reslut = model('BlindBoxTurntableGiftDrawWorld')->draw_gift($gift_bag_id, $user_id, $gift_user_ids,$num,$room_id,$heart_id,$auction_id);
return v($reslut['code'], $reslut['msg'], $reslut['data']); return v($reslut['code'], $reslut['msg'], $reslut['data']);
} }
/* /*
@@ -93,7 +93,7 @@ class BlindBoxTurntable extends BaseCom
$user_id = $this->uid; $user_id = $this->uid;
$room_id = input('room_id',0); $room_id = input('room_id',0);
$num = input('num',1); $num = input('num',1);
$reslut = model('BlindBoxTurntableGiftDraw')->xlh_draw_gift($user_id,$num,$room_id); $reslut = model('BlindBoxTurntableGiftDrawWorld')->xlh_draw_gift($user_id,$num,$room_id);
return v($reslut['code'], $reslut['msg'], $reslut['data']); return v($reslut['code'], $reslut['msg'], $reslut['data']);
} }
/* /*

View File

@@ -1110,7 +1110,7 @@ class BlindBoxTurntableGift extends Model
$where['a.gift_bag_id'] = 13; $where['a.gift_bag_id'] = 13;
$where['a.user_id'] = $user_id; $where['a.user_id'] = $user_id;
$where['a.room_id'] = $room_id; $where['a.room_id'] = $room_id;
$list = db('vs_gift_bag_receive_log') $list = db('vs_gift_bag_receive_pan_log')
->alias('a') ->alias('a')
->join('vs_room_pan_xlh b','b.id = a.parent_id','left') ->join('vs_room_pan_xlh b','b.id = a.parent_id','left')
->join('vs_gift c','c.gid = a.gift_id','left') ->join('vs_gift c','c.gid = a.gift_id','left')
@@ -1133,7 +1133,7 @@ class BlindBoxTurntableGift extends Model
$where['a.gift_bag_id'] = 13; $where['a.gift_bag_id'] = 13;
$where['a.room_id'] = $room_id; $where['a.room_id'] = $room_id;
$where['e.is_world_show'] = 1; $where['e.is_world_show'] = 1;
$list = db('vs_gift_bag_receive_log') $list = db('vs_gift_bag_receive_pan_log')
->alias('a') ->alias('a')
->join('vs_room_pan_xlh b','b.id = a.parent_id','left') ->join('vs_room_pan_xlh b','b.id = a.parent_id','left')
->join('vs_gift c','c.gid = a.gift_id','left') ->join('vs_gift c','c.gid = a.gift_id','left')

View File

@@ -52,10 +52,8 @@ class BlindBoxTurntableGiftDrawWorld extends Model
// 3. 预计算抽奖结果 // 3. 预计算抽奖结果
$precomputeResult = $this->precomputeDrawResults( $precomputeResult = $this->precomputeDrawResults(
$bag_data, $bag_data,
$room,
$gift_user_ids, $gift_user_ids,
$num, $num
$room_id
); );
if ($precomputeResult['code'] !== 1) { if ($precomputeResult['code'] !== 1) {
return $precomputeResult; return $precomputeResult;
@@ -104,7 +102,18 @@ class BlindBoxTurntableGiftDrawWorld extends Model
} catch (\Exception $e) { } catch (\Exception $e) {
$key = 'blind_box_draw_errors_' . date('Y-m-d-H-i-s'); $key = 'blind_box_draw_errors_' . date('Y-m-d-H-i-s');
$this->redis->setex($key, 86400 * 7, $e->getMessage()); $errorData = [
'error_message' => $e->getMessage(),
'gift_bag_id' => $gift_bag_id,
'user_id' => $user_id,
'gift_user_ids' => $gift_user_ids,
'num' => $num,
'room_id' => $room_id,
'heart_id' => $heart_id,
'auction_id' => $auction_id,
];
$this->redis->setex($key, 86400 * 7, json_encode($errorData));
return ['code' => 0, 'msg' => "网络加载失败,请重试!", 'data' => null]; return ['code' => 0, 'msg' => "网络加载失败,请重试!", 'data' => null];
} }
@@ -182,20 +191,17 @@ class BlindBoxTurntableGiftDrawWorld extends Model
/** /**
* 预计算抽奖结果 * 预计算抽奖结果
*/ */
private function precomputeDrawResults($bag_data, $room, $gift_user_ids, $num, $room_id) private function precomputeDrawResults($bag_data, $gift_user_ids, $num)
{ {
$toarray = explode(',', $gift_user_ids); $toarray = explode(',', $gift_user_ids);
$ext = json_decode($bag_data['ext'], true);
$xlh_ext = $this->getCachedXlhConfig();
$xlh_is_piao_ping = 0; $xlh_is_piao_ping = 0;
$current_xlh_periods_num = $room['xlh_periods_num']; $current_xlh_periods_num = $this->getCachedXlhPeriodsNum("get");
// 1. 计算奖池信息 // 1. 计算奖池信息
$poolInfo = $this->calculatePoolInfo($bag_data['id']); $poolInfo = $this->calculatePoolInfo($bag_data['id']);
if ($poolInfo['code'] !== 1) { if ($poolInfo['code'] !== 1) {
return $poolInfo; return $poolInfo;
} }
$totalQuantity = $poolInfo['data']['total_quantity'];
$totalRemaining = $poolInfo['data']['total_remaining']; $totalRemaining = $poolInfo['data']['total_remaining'];
$periods = $poolInfo['data']['periods']; $periods = $poolInfo['data']['periods'];
$totalDrawTimes = $poolInfo['data']['total_draw_times']; $totalDrawTimes = $poolInfo['data']['total_draw_times'];
@@ -543,7 +549,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
} }
if (!empty($batchInsertData)) { if (!empty($batchInsertData)) {
$insertResult = db::name("vs_gift_bag_receive_log")->insertAll($batchInsertData); $insertResult = db::name("vs_gift_bag_receive_pan_log")->insertAll($batchInsertData);
if (!$insertResult) { if (!$insertResult) {
throw new \Exception('插入礼包发放记录失败'); throw new \Exception('插入礼包发放记录失败');
} }
@@ -700,17 +706,15 @@ class BlindBoxTurntableGiftDrawWorld extends Model
*/ */
private function handleXlhOperations($room_id, $xlh_ext, $xlhIsPiaoPing, $currentXlhPeriodsNum,$room) private function handleXlhOperations($room_id, $xlh_ext, $xlhIsPiaoPing, $currentXlhPeriodsNum,$room)
{ {
if($room['xlh_periods_num'] < $xlh_ext['open_condition']['waiting_start_num'] && $currentXlhPeriodsNum >= $xlh_ext['open_condition']['waiting_start_num']){ $xlhPeriodsNum = $this->getCachedXlhPeriodsNum("get");
if($xlhPeriodsNum < $xlh_ext['open_condition']['waiting_start_num'] && $currentXlhPeriodsNum >= $xlh_ext['open_condition']['waiting_start_num']){
$xlhIsPiaoPing = 1; $xlhIsPiaoPing = 1;
} }
if($room['xlh_periods_num'] < $xlh_ext['open_condition']['start_num'] && $currentXlhPeriodsNum >= $xlh_ext['open_condition']['start_num']){ if($xlhPeriodsNum < $xlh_ext['open_condition']['start_num'] && $currentXlhPeriodsNum >= $xlh_ext['open_condition']['start_num']){
$xlhIsPiaoPing = 2; $xlhIsPiaoPing = 2;
} }
// 更新房间巡乐会次数 // 更新房间巡乐会次数
db::name("vs_room")->where('id', $room_id)->update([ $this->getCachedXlhPeriodsNum("set",$currentXlhPeriodsNum);
'xlh_periods_num' => $currentXlhPeriodsNum
]);
// 处理飘屏 // 处理飘屏
if ($xlhIsPiaoPing == 1 || $xlhIsPiaoPing == 2) { if ($xlhIsPiaoPing == 1 || $xlhIsPiaoPing == 2) {
@@ -918,6 +922,18 @@ class BlindBoxTurntableGiftDrawWorld extends Model
} }
return $ext; return $ext;
} }
/**
* 获取缓存的巡乐会开启次数
*/
private function getCachedXlhPeriodsNum($type="get",$num=1) {
$cacheKey = "xlh_periods_num";
$xlh_periods_num = Cache::get($cacheKey) ?? 0;
if($type=="set"){
$xlh_periods_num = $xlh_periods_num+$num;
Cache::set($cacheKey, $xlh_periods_num, 0);
}
return $xlh_periods_num;
}
/** /**
* 重置奖池 * 重置奖池
@@ -1190,7 +1206,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
} }
if (!empty($gift_records)) { if (!empty($gift_records)) {
db::name("vs_gift_bag_receive_log")->insertAll($gift_records); db::name("vs_gift_bag_receive_pan_log")->insertAll($gift_records);
} }
// 批量处理用户礼物包 // 批量处理用户礼物包
@@ -1418,4 +1434,5 @@ class BlindBoxTurntableGiftDrawWorld extends Model
Log::record('Redis操作失败: ' . $e->getMessage(), 'error'); Log::record('Redis操作失败: ' . $e->getMessage(), 'error');
} }
} }
} }