错误屏蔽
This commit is contained in:
@@ -628,83 +628,88 @@ class BlindBoxTurntableGift extends Model
|
||||
* 礼物特效播放
|
||||
*/
|
||||
public function gift_send($send_id){
|
||||
$blind_box_turntable = db('vs_blind_box_turntable_log')->where(['id'=>$send_id,'is_sued'=>0])->find();
|
||||
if(!$blind_box_turntable){
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
}
|
||||
$room_id = $blind_box_turntable['room_id'];
|
||||
$blind_box_turntable_log = db('vs_blind_box_turntable_results_log')->where(['tid'=>$send_id])->select();
|
||||
if(!$blind_box_turntable_log){
|
||||
return ['code' => 0, 'msg' => '数据不存在','data' => null];
|
||||
}
|
||||
$room_name = Db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->value('room_name');
|
||||
$FromUserInfo = Db::name('user')->where(['id'=>$blind_box_turntable['user_id']])->find();
|
||||
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($blind_box_turntable['user_id']);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($blind_box_turntable['user_id']);//魅力图标
|
||||
$user_nickname = $FromUserInfo['nickname'];
|
||||
$textMessage = $user_nickname;
|
||||
$text_message = [];
|
||||
foreach ($blind_box_turntable_log as $key => $value) {
|
||||
$ToUserInfo = Db::name('user')->where(['id' => $value['gift_user_id']])->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$draw_gift = Db::name('vs_gift')->where(['gid'=>$value['gift_id']])->find();
|
||||
$textMessage = $textMessage . ' 送给 ' . $ToUserInfo['nickname']. ' 盲盒转盘礼物 ' . $draw_gift['gift_name'].' x ' .$value['count']."\n";
|
||||
$play_image[] = $draw_gift['play_image'];
|
||||
$gift_names[] = $draw_gift['gift_name'];
|
||||
|
||||
$text_message = $user_nickname . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $draw_gift['gift_name'] . 'X' . $value['count']."\n";
|
||||
if($draw_gift['is_public_server'] == 1) {
|
||||
$text_list_new[] = [
|
||||
'text' => $text_message,
|
||||
'gift_picture' => $draw_gift['base_image'],
|
||||
'room_id' => $room_id,
|
||||
'fromUserName' => $FromUserInfo['nickname'],
|
||||
'toUserName' => $ToUserInfo['nickname'],
|
||||
'giftName' => $draw_gift['gift_name'],
|
||||
'roomId' => $room_id,
|
||||
'number' => $value['count'],
|
||||
];
|
||||
try{
|
||||
$blind_box_turntable = db('vs_blind_box_turntable_log')->where(['id'=>$send_id,'is_sued'=>0])->find();
|
||||
if(!$blind_box_turntable){
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
}
|
||||
$ToUserInfosList[$value['gift_user_id']] = $ToUserInfo;
|
||||
$room_id = $blind_box_turntable['room_id'];
|
||||
$blind_box_turntable_log = db('vs_blind_box_turntable_results_log')->where(['tid'=>$send_id])->select();
|
||||
if(!$blind_box_turntable_log){
|
||||
return ['code' => 0, 'msg' => '数据不存在','data' => null];
|
||||
}
|
||||
$room_name = Db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->value('room_name');
|
||||
$FromUserInfo = Db::name('user')->where(['id'=>$blind_box_turntable['user_id']])->find();
|
||||
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($blind_box_turntable['user_id']);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($blind_box_turntable['user_id']);//魅力图标
|
||||
$user_nickname = $FromUserInfo['nickname'];
|
||||
$textMessage = $user_nickname;
|
||||
$text_message = [];
|
||||
foreach ($blind_box_turntable_log as $key => $value) {
|
||||
$ToUserInfo = Db::name('user')->where(['id' => $value['gift_user_id']])->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$draw_gift = Db::name('vs_gift')->where(['gid'=>$value['gift_id']])->find();
|
||||
$textMessage = $textMessage . ' 送给 ' . $ToUserInfo['nickname']. ' 盲盒转盘礼物 ' . $draw_gift['gift_name'].' x ' .$value['count']."\n";
|
||||
$play_image[] = $draw_gift['play_image'];
|
||||
$gift_names[] = $draw_gift['gift_name'];
|
||||
|
||||
}
|
||||
foreach($ToUserInfosList as &$userInfo) {
|
||||
$userInfo['icon'][0] = model('UserData')->user_wealth_icon($userInfo['user_id']);//财富图标
|
||||
$userInfo['icon'][1] = model('UserData')->user_charm_icon($userInfo['user_id']);//魅力图标
|
||||
$userInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $userInfo['user_id'],'room_id' => $room_id])->value('charm');//魅力
|
||||
$ToUserInfos[] = $userInfo;
|
||||
}
|
||||
$text = [
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'ToUserInfos' => $ToUserInfos,
|
||||
'GiftInfo' => [
|
||||
'play_image' => implode(',',$play_image),
|
||||
'gift_name' => implode(',',$gift_names),
|
||||
],
|
||||
'text' => rtrim($textMessage, "\n")
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1005,$room_id,$text);
|
||||
$roomtype = Db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
if($roomtype == 6){
|
||||
//推送消息
|
||||
$hot_value = db::name('vs_give_gift')->where('from_id', $room_id)->where('from',6)
|
||||
->sum('total_price');
|
||||
$text1 = [
|
||||
'room_id' => $room_id,
|
||||
'hot_value' => $hot_value * 10,
|
||||
'text' => '房间心动值变化'
|
||||
$text_message = $user_nickname . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $draw_gift['gift_name'] . 'X' . $value['count']."\n";
|
||||
if($draw_gift['is_public_server'] == 1) {
|
||||
$text_list_new[] = [
|
||||
'text' => $text_message,
|
||||
'gift_picture' => $draw_gift['base_image'],
|
||||
'room_id' => $room_id,
|
||||
'fromUserName' => $FromUserInfo['nickname'],
|
||||
'toUserName' => $ToUserInfo['nickname'],
|
||||
'giftName' => $draw_gift['gift_name'],
|
||||
'roomId' => $room_id,
|
||||
'number' => $value['count'],
|
||||
];
|
||||
}
|
||||
$ToUserInfosList[$value['gift_user_id']] = $ToUserInfo;
|
||||
|
||||
}
|
||||
foreach($ToUserInfosList as &$userInfo) {
|
||||
$userInfo['icon'][0] = model('UserData')->user_wealth_icon($userInfo['user_id']);//财富图标
|
||||
$userInfo['icon'][1] = model('UserData')->user_charm_icon($userInfo['user_id']);//魅力图标
|
||||
$userInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $userInfo['user_id'],'room_id' => $room_id])->value('charm');//魅力
|
||||
$ToUserInfos[] = $userInfo;
|
||||
}
|
||||
$text = [
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'ToUserInfos' => $ToUserInfos,
|
||||
'GiftInfo' => [
|
||||
'play_image' => implode(',',$play_image),
|
||||
'gift_name' => implode(',',$gift_names),
|
||||
],
|
||||
'text' => rtrim($textMessage, "\n")
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1028,$room_id,$text1);
|
||||
}else{
|
||||
if(!empty($text_list_new)){
|
||||
//推送礼物横幅
|
||||
$push = new Push($blind_box_turntable['user_id'], $room_id);
|
||||
$push->giftBanner($text_list_new);
|
||||
model('Chat')->sendMsg(1005,$room_id,$text);
|
||||
$roomtype = Db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
if($roomtype == 6){
|
||||
//推送消息
|
||||
$hot_value = db::name('vs_give_gift')->where('from_id', $room_id)->where('from',6)
|
||||
->sum('total_price');
|
||||
$text1 = [
|
||||
'room_id' => $room_id,
|
||||
'hot_value' => $hot_value * 10,
|
||||
'text' => '房间心动值变化'
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1028,$room_id,$text1);
|
||||
}else{
|
||||
if(!empty($text_list_new)){
|
||||
//推送礼物横幅
|
||||
$push = new Push($blind_box_turntable['user_id'], $room_id);
|
||||
$push->giftBanner($text_list_new);
|
||||
}
|
||||
}
|
||||
db::name('vs_blind_box_turntable_log')->where('id', $send_id)->update(['is_sued' => 1, 'updatetime' => time()]);
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
return ['code' => 0, 'msg' => "网络请求错误,请重试!", 'data' => null];
|
||||
}
|
||||
db::name('vs_blind_box_turntable_log')->where('id', $send_id)->update(['is_sued' => 1, 'updatetime' => time()]);
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1161,7 +1166,7 @@ class BlindBoxTurntableGift extends Model
|
||||
}
|
||||
return [
|
||||
'activities_name' => $xlh_box['name'],
|
||||
'ico' => null,
|
||||
'icon' => null,
|
||||
'xlh_status'=>$xlh_status,
|
||||
'end_time'=>$xlh_data['end_time'] ?? 0,
|
||||
];
|
||||
|
||||
@@ -18,64 +18,70 @@ class BlindBoxTurntableGiftDraw extends Model
|
||||
*/
|
||||
public function draw_gift($gift_bag_id, $user_id, $gift_user_ids, $num = 1, $room_id = 0, $heart_id = 0)
|
||||
{
|
||||
// 1. 验证参数并提前处理错误
|
||||
$validationResult = $this->validateDrawParameters($gift_bag_id, $user_id, $gift_user_ids, $room_id);
|
||||
if ($validationResult !== true) {
|
||||
return $validationResult;
|
||||
try {
|
||||
// 1. 验证参数并提前处理错误
|
||||
$validationResult = $this->validateDrawParameters($gift_bag_id, $user_id, $gift_user_ids, $room_id);
|
||||
if ($validationResult !== true) {
|
||||
return $validationResult;
|
||||
}
|
||||
|
||||
// 2. 预加载必要数据
|
||||
$loadResult = $this->loadDrawData($gift_bag_id, $user_id, $room_id);
|
||||
if ($loadResult['code'] !== 1) {
|
||||
return $loadResult;
|
||||
}
|
||||
['bag_data' => $bag_data, 'room' => $room, 'xlh_ext' => $xlh_ext] = $loadResult['data'];
|
||||
|
||||
// 3. 预计算抽奖结果
|
||||
$precomputeResult = $this->precomputeDrawResults(
|
||||
$bag_data,
|
||||
$room,
|
||||
$gift_user_ids,
|
||||
$num,
|
||||
$room_id
|
||||
);
|
||||
if ($precomputeResult['code'] !== 1) {
|
||||
return $precomputeResult;
|
||||
}
|
||||
$precomputedResults = $precomputeResult['data']['results'];
|
||||
$availableGiftss = $precomputeResult['data']['availableGifts'];
|
||||
$currentXlhPeriodsNum = $precomputeResult['data']['current_xlh_periods_num'];
|
||||
$xlhIsPiaoPing = $precomputeResult['data']['xlh_is_piao_ping'];
|
||||
|
||||
// 4. 执行抽奖事务(核心操作)
|
||||
$transactionResult = $this->executeDrawTransaction(
|
||||
$bag_data,
|
||||
$user_id,
|
||||
$room_id,
|
||||
$num,
|
||||
$precomputedResults,
|
||||
$availableGiftss
|
||||
);
|
||||
if ($transactionResult['code'] !== 1) {
|
||||
return $transactionResult;
|
||||
}
|
||||
$boxTurntableLog = $transactionResult['data']['log_id'];
|
||||
$giftCounts = $transactionResult['data']['gift_counts'];
|
||||
|
||||
// 5. 处理后续操作(非事务性操作)
|
||||
$this->handlePostDrawOperations(
|
||||
$precomputedResults,
|
||||
$boxTurntableLog,
|
||||
$room_id,
|
||||
$xlh_ext,
|
||||
$xlhIsPiaoPing,
|
||||
$currentXlhPeriodsNum,
|
||||
$room,
|
||||
$user_id
|
||||
);
|
||||
|
||||
// 6. 构建并返回结果
|
||||
return $this->buildDrawResult($boxTurntableLog, $giftCounts);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return ['code' => 0, 'msg' => "网络请求错误,请重试!", 'data' => null];
|
||||
}
|
||||
|
||||
// 2. 预加载必要数据
|
||||
$loadResult = $this->loadDrawData($gift_bag_id, $user_id, $room_id);
|
||||
if ($loadResult['code'] !== 1) {
|
||||
return $loadResult;
|
||||
}
|
||||
['bag_data' => $bag_data, 'room' => $room, 'xlh_ext' => $xlh_ext] = $loadResult['data'];
|
||||
|
||||
// 3. 预计算抽奖结果
|
||||
$precomputeResult = $this->precomputeDrawResults(
|
||||
$bag_data,
|
||||
$room,
|
||||
$gift_user_ids,
|
||||
$num,
|
||||
$room_id
|
||||
);
|
||||
if ($precomputeResult['code'] !== 1) {
|
||||
return $precomputeResult;
|
||||
}
|
||||
$precomputedResults = $precomputeResult['data']['results'];
|
||||
$availableGiftss = $precomputeResult['data']['availableGifts'];
|
||||
$currentXlhPeriodsNum = $precomputeResult['data']['current_xlh_periods_num'];
|
||||
$xlhIsPiaoPing = $precomputeResult['data']['xlh_is_piao_ping'];
|
||||
|
||||
// 4. 执行抽奖事务(核心操作)
|
||||
$transactionResult = $this->executeDrawTransaction(
|
||||
$bag_data,
|
||||
$user_id,
|
||||
$room_id,
|
||||
$num,
|
||||
$precomputedResults,
|
||||
$availableGiftss
|
||||
);
|
||||
if ($transactionResult['code'] !== 1) {
|
||||
return $transactionResult;
|
||||
}
|
||||
$boxTurntableLog = $transactionResult['data']['log_id'];
|
||||
$giftCounts = $transactionResult['data']['gift_counts'];
|
||||
|
||||
// 5. 处理后续操作(非事务性操作)
|
||||
$this->handlePostDrawOperations(
|
||||
$precomputedResults,
|
||||
$boxTurntableLog,
|
||||
$room_id,
|
||||
$xlh_ext,
|
||||
$xlhIsPiaoPing,
|
||||
$currentXlhPeriodsNum,
|
||||
$room,
|
||||
$user_id
|
||||
);
|
||||
|
||||
// 6. 构建并返回结果
|
||||
return $this->buildDrawResult($boxTurntableLog, $giftCounts);
|
||||
}
|
||||
/**
|
||||
* 验证抽奖参数
|
||||
@@ -755,11 +761,16 @@ class BlindBoxTurntableGiftDraw extends Model
|
||||
$xlh['start_num'] = $xlh_ext['open_condition']['start_num'];//开始开奖次数
|
||||
// 当前抽奖次数
|
||||
$xlh['current_num'] = $currentXlhPeriodsNum;
|
||||
$xlh['end_time'] = 0;
|
||||
// 状态
|
||||
if($xlh['current_num'] >= $xlh_ext['open_condition']['start_num']){
|
||||
$xlh['status'] = 1;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始
|
||||
//查询巡乐会信息
|
||||
$pan_xlh = db::name('vs_room_pan_xlh')->where('room_id',$room_id)->order('id desc')->find();
|
||||
$xlh['end_time'] = $pan_xlh['end_time'] ?? 0;
|
||||
} elseif($xlh['current_num'] >= $xlh_ext['open_condition']['waiting_start_num'] && $xlh['current_num'] < $xlh_ext['open_condition']['start_num']){
|
||||
$xlh['status'] = 2;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始
|
||||
|
||||
}else{
|
||||
$xlh['status'] = 0;
|
||||
}
|
||||
|
||||
@@ -926,7 +926,7 @@ class Tencent extends Model
|
||||
if($quit_room) {
|
||||
foreach ($quit_room as $v){
|
||||
$room_type = db::name('vs_room')->where(['id' => $v['room_id'],'room_status' => 1])->field('step,type_id')->find();
|
||||
if(($room_type['type_id'] == 7 && ($room_type['step'] == 2 ||$room_type['step'] == 3)) || $room_type == 2){
|
||||
if(isset($room_type) && ($room_type['type_id'] == 7 && ($room_type['step'] == 2 ||$room_type['step'] == 3)) || $room_type == 2){
|
||||
$text['text'] = '掉线!';
|
||||
$text['user_id'] = $uid;
|
||||
$text['type'] = 2;
|
||||
|
||||
Reference in New Issue
Block a user