盘修改 礼物推送

This commit is contained in:
2025-09-16 16:37:25 +08:00
parent 98de5e02ad
commit e6f5689a94
2 changed files with 119 additions and 113 deletions

View File

@@ -382,6 +382,19 @@ class BlindBoxTurntableGift extends Model
db::rollback(); db::rollback();
return ['code' => 0, 'msg' => '添加盲盒转盘结果记录失败', 'data' => null]; return ['code' => 0, 'msg' => '添加盲盒转盘结果记录失败', 'data' => null];
} }
//给接收礼物的人送礼物
$give_gift_ext['gift_id'] = $user_gift['gift_id'];
$give_gift_ext['count'] = $user_gift['count'];
$give_gift_ext['gift_price'] = $user_gift['gift_price'];
$give_gift_ext['all_gift_price'] = $user_gift['gift_price'] * $user_gift['count'];
$give_gift_ext['is_draw_gift'] = 1;
$res = model('Room')->room_gift($user_id, $user_gift['gift_user_id'], $user_gift['gift_id'], $user_gift['count'], 1, $room_id, 0,$heart_id,$give_gift_ext);
if (isset($res) && $res['code'] != 1) {
db::rollback();
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
}
} }
// 扣除抽奖消耗的金币 // 扣除抽奖消耗的金币
@@ -602,35 +615,72 @@ class BlindBoxTurntableGift extends Model
} }
/* /*
* 礼物 * 礼物特效播
*/ */
public function gift_send($send_id){ public function gift_send($send_id){
$blind_box_turntable = db('vs_blind_box_turntable_log')->where('id',$send_id)->find(); $blind_box_turntable = db('vs_blind_box_turntable_log')->where(['id'=>$send_id,'is_sued'=>0])->find();
if(!$blind_box_turntable){ if(!$blind_box_turntable){
return ['code' => 0, 'msg' => '数据不存在','data' => null];
}
$blind_box_turntable_log = db('vs_blind_box_turntable_results_log')->where(['tid'=>$send_id,'is_sued'=>0])->select();
if(!$blind_box_turntable_log){
return ['code' => 1, 'msg' => '成功', 'data' => null]; 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();
$user_nickname = $FromUserInfo['nickname'];
$textMessage = $user_nickname;
$text_message = [];
foreach ($blind_box_turntable_log as $key => $value) { foreach ($blind_box_turntable_log as $key => $value) {
if($value['is_sued'] == 1){ //礼物已发放就不再重复发放 $ToUserInfo = Db::name('user')->where(['id'=>$value['gift_user_id']])->find();
continue; $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'];
$text_message = $user_nickname . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $draw_gift['gift_name'] . 'X' . $value['count']."\n";
$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'],
];
} }
$give_gift_ext['gift_id'] = $value['gift_id']; $text = [
$give_gift_ext['count'] = $value['count']; 'FromUserInfo' => $FromUserInfo,
$give_gift_ext['gift_price'] = $value['gift_price']; 'GiftInfo' => [
$give_gift_ext['all_gift_price'] = $value['all_gift_price']; 'play_image' => implode(',',$play_image),
$give_gift_ext['is_draw_gift'] = 1; ],
// $res = model('GiveGift')->give_gift($blind_box_turntable['user_id'], $value['gift_user_id'], $value['gift_id'], $value['count'],2,1, $blind_box_turntable['room_id'],0,0,$give_gift_ext); 'text' => $textMessage
$res = model('Room')->room_gift($blind_box_turntable['user_id'], $value['gift_user_id'], $value['gift_id'], $value['count'], 1, $blind_box_turntable['room_id'], 0,$value['heart_id'],$give_gift_ext); ];
if (isset($res) && $res['code'] != 1) { //聊天室推送系统消息
// return V(0, $res['msg']); model('Chat')->sendMsg(1005,$room_id,$text);
continue; $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($draw_gift['is_public_server'] == 1){
//推送礼物横幅
$push = new Push($blind_box_turntable['user_id'], $room_id);
$push->giftBanner($text_list_new);
} }
db('vs_blind_box_turntable_results_log')->where('id', $value['id'])->update(['is_sued' => 1, 'updatetime' => time()]);
} }
db::name('vs_blind_box_turntable_log')->where('id', $send_id)->update(['is_sued' => 1, 'updatetime' => time()]);
return ['code' => 1, 'msg' => '成功', 'data' => null]; return ['code' => 1, 'msg' => '成功', 'data' => null];
} }

View File

@@ -383,52 +383,8 @@ class GiveGift extends Model
} }
} }
//推送礼物特效 //推送礼物特效
if(!isset($ext['is_draw_gift']) || $ext['is_draw_gift'] != 1){// 非盲盒转盘 推送
if($gift_info['label'] == 2){ if($gift_info['label'] == 2){
if(isset($ext['is_draw_gift']) && $ext['is_draw_gift'] == 1){
$draw_gift = Db::name('vs_gift')->where(['gid'=>$ext['gift_id']])->find();
$textMessage = $FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 盲盒转盘礼物 ' . $draw_gift['gift_name'].' x ' .$ext['count'];
$text = [
'FromUserInfo' => $FromUserInfo,
'ToUserInfo' => $ToUserInfo,
'GiftInfo' => $draw_gift,
'GiftNum' => $draw_gift['gift_name'],
'text' => $textMessage
];
//聊天室推送系统消息
model('Chat')->sendMsg(1005,$from_id,$text);
$roomtype = Db::name('vs_room')->where(['id' => $from_id])->value('type_id');
if($roomtype == 6){
//推送消息
$hot_value = db::name('vs_give_gift')->where('from_id', $from_id)->where('from',6)
->sum('total_price');
$text1 = [
'room_id' => $from_id,
'hot_value' => $hot_value * 10,
'text' => '房间心动值变化'
];
//聊天室推送系统消息
model('Chat')->sendMsg(1028,$from_id,$text1);
}else{
if($draw_gift['is_public_server'] == 1){
//推送礼物横幅
$push = new Push(UID, $from_id);
$room_name = Db::name('vs_room')->where(['id' => $from_id, 'apply_status' => 2])->value('room_name');
$text = $FromUserInfo['nickname'] . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $draw_gift['gift_name'] . 'X' . $num;
$text_list_new = [
'text' => $text,
'gift_picture' => $draw_gift['base_image'],
'room_id' => $from_id,
'fromUserName' => $FromUserInfo['nickname'],
'toUserName' => $ToUserInfo['nickname'],
'giftName' => $draw_gift['gift_name'],
'roomId' => $from_id,
'number' => $num,
];
$push->giftBanner($text_list_new);
}
}
}else{
//循环开出来的盲盒,相同的礼物只推送一次,消息推送为$FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 趣味礼物 ' .$gift_inf['gift_name'].' x 多少'; //循环开出来的盲盒,相同的礼物只推送一次,消息推送为$FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 趣味礼物 ' .$gift_inf['gift_name'].' x 多少';
if($gift_box){ if($gift_box){
// 统计相同礼物的数量 // 统计相同礼物的数量
@@ -457,9 +413,9 @@ class GiveGift extends Model
$textMessage = $FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 趣味礼物 ' . implode('', $giftTextList); $textMessage = $FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 趣味礼物 ' . implode('', $giftTextList);
$textData = [ $textData = [
'FromUserInfo' => $FromUserInfo, 'FromUserInfo' => $FromUserInfo,
// 'ToUserInfo' => $ToUserInfo, // 'ToUserInfo' => $ToUserInfo,
// 'GiftInfo' => $gift_info, // 'GiftInfo' => $gift_info,
// 'GiftNum' => $num, // 'GiftNum' => $num,
'text' => $textMessage 'text' => $textMessage
]; ];
// 聊天室推送文字消息 // 聊天室推送文字消息
@@ -508,7 +464,7 @@ class GiveGift extends Model
$push = new Push(UID, $from_id); $push = new Push(UID, $from_id);
$room_name = Db::name('vs_room')->where(['id' => $from_id, 'apply_status' => 2])->value('room_name'); $room_name = Db::name('vs_room')->where(['id' => $from_id, 'apply_status' => 2])->value('room_name');
$bannerText = $FromUserInfo['nickname'] . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $gift_inf['gift_name'] . 'X' . $count; $bannerText = $FromUserInfo['nickname'] . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $gift_inf['gift_name'] . 'X' . $count;
$text_list_new = [ $text_list_new[] = [
'text' => $bannerText, 'text' => $bannerText,
'gift_picture' => $gift_inf['base_image'], 'gift_picture' => $gift_inf['base_image'],
'room_id' => $from_id, 'room_id' => $from_id,
@@ -523,7 +479,6 @@ class GiveGift extends Model
} }
} }
} }
}
}else{ }else{
$text = $FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 礼物 ' .$gift_info['gift_name'].' x ' .$num; $text = $FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 礼物 ' .$gift_info['gift_name'].' x ' .$num;
$text = [ $text = [
@@ -553,7 +508,7 @@ class GiveGift extends Model
$push = new Push($uid, $from_id); $push = new Push($uid, $from_id);
$room_name = Db::name('vs_room')->where(['id' => $from_id, 'apply_status' => 2])->value('room_name'); $room_name = Db::name('vs_room')->where(['id' => $from_id, 'apply_status' => 2])->value('room_name');
$text = $FromUserInfo['nickname'] . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $gift_info['gift_name'] . 'X' . $num; $text = $FromUserInfo['nickname'] . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $gift_info['gift_name'] . 'X' . $num;
$text_list_new = [ $text_list_new[] = [
'text' => $text, 'text' => $text,
'gift_picture' => $gift_info['base_image'], 'gift_picture' => $gift_info['base_image'],
'room_id' => $from_id, 'room_id' => $from_id,
@@ -568,6 +523,7 @@ class GiveGift extends Model
} }
} }
}
//直播间送礼物 每日任务 //直播间送礼物 每日任务
model('DailyTasks')->tasks_complete($uid,3); model('DailyTasks')->tasks_complete($uid,3);
} }
@@ -701,7 +657,7 @@ class GiveGift extends Model
} }
}elseif(in_array($change_type,$out_types)){ }elseif(in_array($change_type,$out_types)){
//减少用户金币 //减少用户金币
$res1 = Db::name('user_wallet')->where(['user_id'=>$user_id])->setDec('coin',$money); $res1 = Db::name('user_wallet')->where(['user_id'=>$user_id,'coin'=>['>=',$money]])->setDec('coin',$money);
if(!$res1){ if(!$res1){
return false; return false;
} }