新需求-活动需求-盲盒转盘调通盘-调试-后台接口调整

This commit is contained in:
2025-10-14 10:21:22 +08:00
parent 9c957165ff
commit 2ebc3bdd5a
2 changed files with 39 additions and 33 deletions

View File

@@ -137,7 +137,7 @@ class Activities extends BaseCom
//规则 //规则
$data['rule'] = get_system_config_value('web_site')."/api/Page/page_show?id=13"; $data['rule'] = get_system_config_value('web_site')."/api/Page/page_show?id=13";
$ext = json_decode($gift_bag['ext'],true); $ext = json_decode($gift_bag['ext'],true);
$data['money'] = $ext['money']; $data['money'] = $gift_bag['money'];
$data['counter'] = $ext['counter']; $data['counter'] = $ext['counter'];
$data['money'] = $ext['money_str']; $data['money'] = $ext['money_str'];
$data['diamond'] = $ext['diamond']; $data['diamond'] = $ext['diamond'];

View File

@@ -103,7 +103,6 @@ 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');
$errorData = [ $errorData = [
'error_message' => $e->getMessage(),
'gift_bag_id' => $gift_bag_id, 'gift_bag_id' => $gift_bag_id,
'user_id' => $user_id, 'user_id' => $user_id,
'gift_user_ids' => $gift_user_ids, 'gift_user_ids' => $gift_user_ids,
@@ -112,8 +111,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
'heart_id' => $heart_id, 'heart_id' => $heart_id,
'auction_id' => $auction_id, 'auction_id' => $auction_id,
]; ];
$this->redis->setex($key, 86400 * 7, json_encode($errorData)); $this->redis->setex($key, 86400 * 7, $e->getMessage(). ' ' .json_encode($errorData));
return ['code' => 0, 'msg' => "网络加载失败,请重试!", 'data' => null]; return ['code' => 0, 'msg' => "网络加载失败,请重试!", 'data' => null];
} }
@@ -219,11 +217,11 @@ class BlindBoxTurntableGiftDrawWorld extends Model
$giftInfoMap = $this->preloadGiftInfo($availableGifts); $giftInfoMap = $this->preloadGiftInfo($availableGifts);
// 4. 处理奖池重置逻辑 // 4. 处理奖池重置逻辑
$needGiftNum = count($toarray) * $num; $needGiftNum = count($toarray) * $num; //总需要的礼物数
$remaining_available_gifts=[]; $remaining_available_gifts=[];
if ($totalRemaining - $needGiftNum <= 0) { if ($totalRemaining - $needGiftNum <= 0) {//奖池剩余数量-需要的礼物数小于0
$remaining_available_gifts = $availableGifts; $remaining_available_gifts = $availableGifts; //剩余可用礼物
$availableGifts = $this->resetPoolAndReload($bag_data['id']); $availableGifts = $this->resetPoolAndReload($bag_data['id']); //重置奖池并重新加载
if (empty($availableGifts)) { if (empty($availableGifts)) {
throw new \Exception('重置奖池后仍无可用礼物'); throw new \Exception('重置奖池后仍无可用礼物');
} }
@@ -727,7 +725,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
private function handleXlhPiaoPing($room_id, $xlh_ext, $xlhIsPiaoPing,$room){ private function handleXlhPiaoPing($room_id, $xlh_ext, $xlhIsPiaoPing,$room){
if($xlhIsPiaoPing == 1){ if($xlhIsPiaoPing == 1){
// 即将开始推送飘屏 // 即将开始推送飘屏
$text = $room['room_name']."巡乐会即将开始..."; $text = "巡乐会即将开始...";
// 推送礼物横幅 // 推送礼物横幅
$push = new Push(UID, $room_id); $push = new Push(UID, $room_id);
$text_list_new = [ $text_list_new = [
@@ -739,7 +737,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
} }
if($xlhIsPiaoPing == 2){ if($xlhIsPiaoPing == 2){
// 正式开始推送飘屏 // 正式开始推送飘屏
$text = $room['room_name']."已正式开启巡乐会游戏..."; $text = "巡乐会游戏已正式开启...";
// 推送礼物横幅 // 推送礼物横幅
$push = new Push(UID, $room_id); $push = new Push(UID, $room_id);
$text_list_new = [ $text_list_new = [
@@ -783,13 +781,22 @@ class BlindBoxTurntableGiftDrawWorld extends Model
}else{ }else{
$xlh['status'] = 0; $xlh['status'] = 0;
} }
// 推送 // 推送进度条
$text = [ $push = new Push(UID, $room_id);
$text_list_new = [
'xlh_data' => $xlh, 'xlh_data' => $xlh,
'text' => "" 'text' => "",
'from_type' => 0
]; ];
$push->xunlehui($text_list_new);
// 聊天室推送系统消息 // 聊天室推送系统消息
model('Chat')->sendMsg(1056,$room_id,$text); // 推送
// $text = [
// 'xlh_data' => $xlh,
// 'text' => ""
// ];
// model('Chat')->sendMsg(1056,$room_id,$text);
} }
/** /**
* 统计礼物数量 * 统计礼物数量
@@ -979,27 +986,14 @@ class BlindBoxTurntableGiftDrawWorld extends Model
public function xlh_draw_gift($user_id, $num, $room_id) public function xlh_draw_gift($user_id, $num, $room_id)
{ {
$gift_bag_id = 13; $gift_bag_id = 13;
// 1. 获取并缓存盲盒配置 // 1. 获取并缓存盲盒配置
$cacheKey = "xlh_config_{$gift_bag_id}";
$ext = $this->getCachedXlhConfig(); $ext = $this->getCachedXlhConfig();
// 2. 检查用户金币和房间状态 // 2. 检查用户金币和房间状态
$bag_gift_price = $ext['xlh_box_price'] * $num; $bag_gift_price = $ext['xlh_box_price'] * $num;
$user_waller = db::name('user_wallet')->where(['user_id' => $user_id])->find(); $user_waller = db::name('user_wallet')->where(['user_id' => $user_id])->find();
if (!$user_waller || $user_waller['coin'] < $bag_gift_price) { if (!$user_waller || $user_waller['coin'] < $bag_gift_price) {
return ['code' => 0, 'msg' => '用户金币不足', 'data' => null]; return ['code' => 0, 'msg' => '用户金币不足', 'data' => null];
} }
$room = db::name('vs_room')
->field('id,room_name,is_open_blind_box_turntable,xlh_periods')
->where(['id' => $room_id])
->find();
$bag_data = db::name("vs_gift_bag")
->field('id,name,ext,periods')
->where('id', $gift_bag_id)
->find();
// 3. 检查巡乐会状态 // 3. 检查巡乐会状态
$pan_xlh = db::name('vs_room_pan_xlh') $pan_xlh = db::name('vs_room_pan_xlh')
->order('id', 'desc') ->order('id', 'desc')
@@ -1189,7 +1183,13 @@ class BlindBoxTurntableGiftDrawWorld extends Model
$total_processed += $current_batch; $total_processed += $current_batch;
} catch (\Exception $e) { } catch (\Exception $e) {
db::rollback(); db::rollback();
Log::record('巡乐会抽奖失败: ' . $e->getMessage(),"infos"); $key = 'xlh_draw_gift_errors_' . date('Y-m-d-H-i-s');
$errorData = [
'user_id' => $user_id,
'gift_bag_id' => $gift_bag_id,
'room_id' => $room_id,
];
$this->redis->setex($key, 86400 * 7, $e->getMessage(). ' ' .json_encode($errorData));
return ['code' => 0, 'msg' => "抽奖中,请稍等...", 'data' => null]; return ['code' => 0, 'msg' => "抽奖中,请稍等...", 'data' => null];
} }
} }
@@ -1254,7 +1254,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
// 8. 处理推送消息 // 8. 处理推送消息
if ($is_zhong_jiang == 1) { if ($is_zhong_jiang == 1) {
$this->handlePrizeNotification($user_id,$gift_id, $room_id, $pan_xlh_num, $end_time, $room['room_name'],$ext['locking_condition']['locking_gift_id']); $this->handlePrizeNotification($user_id,$gift_id, $room_id, $pan_xlh_num, $end_time,$ext['locking_condition']['locking_gift_id']);
} }
// 9. 构建返回结果 // 9. 构建返回结果
@@ -1353,29 +1353,35 @@ class BlindBoxTurntableGiftDrawWorld extends Model
/** /**
* 巡乐会抽奖-处理中奖通知 * 巡乐会抽奖-处理中奖通知
*/ */
private function handlePrizeNotification($user_id,$gift_id, $room_id, $pan_xlh_num, $end_time, $room_name,$locking_gift_id) private function handlePrizeNotification($user_id,$gift_id, $room_id, $pan_xlh_num, $end_time,$locking_gift_id)
{ {
$FromUserInfo = db::name('user')->field('nickname,avatar')->where(['id' => $user_id])->find(); $FromUserInfo = db::name('user')->field('nickname,avatar')->where(['id' => $user_id])->find();
$gift_info = db::name('vs_gift')->field('gift_name')->where(['gid' => $gift_id])->find(); $gift_info = db::name('vs_gift')->field('gift_name')->where(['gid' => $gift_id])->find();
$locking_gift = db::name('vs_gift')->field('gift_name')->where(['gid' => $locking_gift_id])->find(); $locking_gift = db::name('vs_gift')->field('gift_name')->where(['gid' => $locking_gift_id])->find();
$room_data = db::name('vs_room')->field('room_name,user_id')->where(['id' => $room_id])->find();
$room_user = db::name('user')->where('id',$room_data['user_id'])->field('nickname,avatar')->find();
//锁定礼物 //锁定礼物
$text = [ $text = [
'gift_num' => $pan_xlh_num, 'gift_num' => $pan_xlh_num,
'FromUserInfo' => $FromUserInfo, 'FromUserInfo' => $FromUserInfo,
'end_time' => $end_time, 'end_time' => $end_time,
'text' => $FromUserInfo['nickname'] . ' 在 ' . $room_name . ' 房间巡乐会中 获得' . $gift_info['gift_name'] . '礼物 x 1' 'text' => $FromUserInfo['nickname'] . ' 在 ' . ' 巡乐会活动中 获得' . $gift_info['gift_name'] . '礼物 x 1'
]; ];
model('Chat')->sendMsg(1057, $room_id, $text); model('Chat')->sendMsg(1057, $room_id, $text);
//推送礼物横幅 //推送礼物横幅
$text = $FromUserInfo['nickname'] . ' 在 ' . $room_name.' 房间巡乐会锁定礼物'.$locking_gift['gift_name'].' x ' .$pan_xlh_num ; $text = $FromUserInfo['nickname'] .' 巡乐会活动中锁定礼物'.$locking_gift['gift_name'].' x ' .$pan_xlh_num ;
$push = new Push(0, $room_id); $push = new Push(0, $room_id);
$text_list_new = [ $text_list_new = [
'text' => $text, 'text' => $text,
'room_id' => $room_id, 'room_id' => $room_id,
'from_type' => 1 'from_type' => 4,
'gift_num' => $pan_xlh_num,
'FromUserInfo' => $FromUserInfo,
'end_time' => $end_time,
'room_user' => $room_user
]; ];
$push->xunlehui($text_list_new); $push->xunlehui($text_list_new);
} }