From 774107e28f4c2da5ab73a051f9e562ab9247eff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Thu, 16 Oct 2025 10:16:20 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=A2=E5=8C=85=20=E6=8A=A2=E5=AE=8C?= =?UTF-8?q?=E9=94=80=E6=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/model/Chat.php | 2 ++ application/common/service/RedpacketService.php | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/application/api/model/Chat.php b/application/api/model/Chat.php index 7ee1a97..8e66e36 100644 --- a/application/api/model/Chat.php +++ b/application/api/model/Chat.php @@ -121,6 +121,8 @@ class Chat extends Model // ClearUserCharm = 1059, //发红包 // RedPacket = 1060, + //红包领完推送 + // RedPacketComplete = 1061, diff --git a/application/common/service/RedpacketService.php b/application/common/service/RedpacketService.php index 7023e20..b05ef77 100644 --- a/application/common/service/RedpacketService.php +++ b/application/common/service/RedpacketService.php @@ -111,6 +111,18 @@ class RedpacketService $amount = floatval($result[1]); $isFinished = $result[2] == 1; // Lua脚本返回是否抢完 + //给前端推送销毁这个红包 + // redis 记录该红包是否已经推送过了 只推送一次 + $redisKey = "redpacket:{$redpacketId}:is_finished"; + if (!$redis->get($redisKey)) { + $redis->set($redisKey, 1); + $text = [ + 'redpacket_id' => $redpacketId, + 'text' => '抢完了,请销毁该红包' + ]; + model('api/Chat')->sendMsg(1061,$redpacket['room_id'],$text); + } + // Lua脚本执行成功,记录到数据库 Db::startTrans();