盲盒转盘礼物推送
This commit is contained in:
@@ -117,25 +117,61 @@ class BlindBoxTurntableGift extends Model
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
$ToUserInfosList[$value['gift_user_id']] = $ToUserInfo;
|
$ToUserInfosList[$value['gift_user_id']] = $ToUserInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按用户分组礼物信息
|
||||||
|
$userGiftMap = [];
|
||||||
|
foreach ($blind_box_turntable_log as $value) {
|
||||||
|
$userId = $value['gift_user_id'];
|
||||||
|
if (!isset($userGiftMap[$userId])) {
|
||||||
|
$userGiftMap[$userId] = [
|
||||||
|
'userInfo' => Db::name('user')->where(['id' => $userId])->field('id as user_id,nickname,avatar,sex')->find(),
|
||||||
|
'gifts' => []
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$gift = Db::name('vs_gift')->where(['gid'=>$value['gift_id']])->find();
|
||||||
|
$userGiftMap[$userId]['gifts'][] = [
|
||||||
|
'gift_name' => $gift['gift_name'],
|
||||||
|
'count' => $value['count'],
|
||||||
|
'play_image' => $gift['play_image']
|
||||||
|
];
|
||||||
}
|
}
|
||||||
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']);//魅力图标
|
foreach($userGiftMap as $userId => $userData) {
|
||||||
$userInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $userInfo['user_id'],'room_id' => $room_id])->value('charm');//魅力
|
$userInfo = $userData['userInfo'];
|
||||||
$ToUserInfos[] = $userInfo;
|
$gifts = $userData['gifts'];
|
||||||
|
|
||||||
|
// 构建用户专属文本消息,接收者名字只出现一次
|
||||||
|
$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']);
|
||||||
|
$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');
|
||||||
|
|
||||||
|
$userText = [
|
||||||
|
'FromUserInfo' => $FromUserInfo,
|
||||||
|
'ToUserInfos' => [$userInfo],
|
||||||
|
'GiftInfo' => [
|
||||||
|
'play_image' => implode(',',$userPlayImages),
|
||||||
|
'gift_name' => implode(',',$userGiftNames),
|
||||||
|
],
|
||||||
|
'text' => $userTextMessage
|
||||||
|
];
|
||||||
|
|
||||||
|
// 聊天室推送系统消息给每个用户
|
||||||
|
model('Chat')->sendMsg(1005,$room_id,$userText);
|
||||||
}
|
}
|
||||||
$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');
|
$roomtype = Db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||||
if($roomtype == 6){
|
if($roomtype == 6){
|
||||||
//推送消息
|
//推送消息
|
||||||
|
|||||||
Reference in New Issue
Block a user