盲盒转盘礼物推送
This commit is contained in:
@@ -91,6 +91,7 @@ class BlindBoxTurntableGift extends Model
|
||||
$FromUserInfo['chat_bubble'] = model('Decorate')->user_decorate_detail($blind_box_turntable['user_id'],9);//聊天气泡
|
||||
$user_nickname = $FromUserInfo['nickname'];
|
||||
$userGiftMap = [];
|
||||
$giftCount = [];
|
||||
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();
|
||||
@@ -120,6 +121,15 @@ class BlindBoxTurntableGift extends Model
|
||||
'count' => $value['count'],
|
||||
'play_image' => $draw_gift['play_image']
|
||||
];
|
||||
// 统计相同礼物的数量
|
||||
if (isset($giftCount[$value['gift_id']])) {
|
||||
$giftCount[$value['gift_id']]['count']++;
|
||||
} else {
|
||||
$giftCount[$value['gift_id']] = [
|
||||
'gift_info' => $draw_gift,
|
||||
'count' => 1
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// 为每个用户单独推送消息
|
||||
@@ -129,14 +139,9 @@ class BlindBoxTurntableGift extends Model
|
||||
|
||||
// 构建用户专属文本消息,接收者名字只出现一次
|
||||
$userTextMessage = $user_nickname . ' 送给 ' . $userInfo['nickname'];
|
||||
$userGiftNames = [];
|
||||
$userPlayImages = [];
|
||||
|
||||
// 添加该用户收到的所有礼物
|
||||
foreach ($gifts as $gift) {
|
||||
$userTextMessage .= ' 盲盒转盘礼物 ' . $gift['gift_name'].' x ' .$gift['count'];
|
||||
$userGiftNames[] = $gift['gift_name'];
|
||||
$userPlayImages[] = $gift['play_image'];
|
||||
}
|
||||
|
||||
$userInfo['icon'][0] = model('UserData')->user_wealth_icon($userInfo['user_id']);
|
||||
@@ -145,18 +150,32 @@ class BlindBoxTurntableGift extends Model
|
||||
|
||||
$userText = [
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'ToUserInfos' => $userInfo,
|
||||
'GiftInfo' => [
|
||||
'play_image' => implode(',',$userPlayImages),
|
||||
'gift_name' => implode(',',$userGiftNames),
|
||||
],
|
||||
'ToUserInfo' => $userInfo,
|
||||
'GiftInfos' => array_values($gifts),
|
||||
'text' => $userTextMessage
|
||||
];
|
||||
|
||||
// 聊天室推送系统消息给每个用户
|
||||
model('Chat')->sendMsg(1005,$room_id,$userText);
|
||||
model('Chat')->sendMsg(10038,$room_id,$userText);
|
||||
}
|
||||
// 循环推送每个礼物的特效消息
|
||||
foreach ($giftCount as $giftId => $giftData) {
|
||||
$gift_inf = $giftData['gift_info'];
|
||||
$count = $giftData['count'];
|
||||
|
||||
// 推送礼物特效消息
|
||||
$effectData = [
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'ToUserInfo' => $ToUserInfo,
|
||||
'GiftInfo' => $gift_inf,
|
||||
'gift_num' => $count,
|
||||
'text' => null
|
||||
];
|
||||
|
||||
// 聊天室推送礼物特效消息
|
||||
model('Chat')->sendMsg(1005,$room_id,$effectData);
|
||||
}
|
||||
|
||||
$roomtype = Db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
if($roomtype == 6){
|
||||
//推送消息
|
||||
|
||||
Reference in New Issue
Block a user