From 8f31af203b1cb0aa577119da4693e72ebc6869ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Fri, 24 Oct 2025 21:02:54 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B2=E7=9B=92=E8=BD=AC=E7=9B=98=E7=A4=BC?= =?UTF-8?q?=E7=89=A9=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/model/BlindBoxTurntableGift.php | 41 ++++++++++++++----- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/application/api/model/BlindBoxTurntableGift.php b/application/api/model/BlindBoxTurntableGift.php index 0987cd7..1aaedb1 100644 --- a/application/api/model/BlindBoxTurntableGift.php +++ b/application/api/model/BlindBoxTurntableGift.php @@ -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){ //推送消息