盘修改 礼物推送

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();
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){
$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){
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];
}
//获取盲盒配置
foreach ($blind_box_turntable_log as $key => $value) {
if($value['is_sued'] == 1){ //礼物已发放就不再重复发放
continue;
}
$give_gift_ext['gift_id'] = $value['gift_id'];
$give_gift_ext['count'] = $value['count'];
$give_gift_ext['gift_price'] = $value['gift_price'];
$give_gift_ext['all_gift_price'] = $value['all_gift_price'];
$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);
$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']);
continue;
}
db('vs_blind_box_turntable_results_log')->where('id', $value['id'])->update(['is_sued' => 1, 'updatetime' => time()]);
$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) {
$ToUserInfo = Db::name('user')->where(['id'=>$value['gift_user_id']])->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'];
$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'],
];
}
$text = [
'FromUserInfo' => $FromUserInfo,
'GiftInfo' => [
'play_image' => implode(',',$play_image),
],
'text' => $textMessage
];
//聊天室推送系统消息
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($draw_gift['is_public_server'] == 1){
//推送礼物横幅
$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];
}