From fd535f969bc21eb2a37dbd9a432640a8d36ae88c 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:42:04 +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 --- .../common/service/RedpacketService.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/application/common/service/RedpacketService.php b/application/common/service/RedpacketService.php index 44bc17e..7a6043f 100644 --- a/application/common/service/RedpacketService.php +++ b/application/common/service/RedpacketService.php @@ -113,17 +113,18 @@ class RedpacketService $isFinished = $result[2] == 1; // Lua脚本返回是否抢完 //给前端推送销毁这个红包 // redis 记录该红包是否已经推送过了 只推送一次 - $redisKey = "redpacket:{$redpacketId}:is_finished"; - if (!Cache::get($redisKey)) { - Cache::set($redisKey, 1, $redpacket['countdown']+get_system_config_value('red_packet_time')+60); - $text = [ - 'redpacket_id' => $redpacketId, - 'text' => '抢完了,请销毁该红包' - ]; - model('api/Chat')->sendMsg(1061,$redpacket['room_id'],$text); + if($isFinished){ + $redisKey = "redpacket:{$redpacketId}:is_finished"; + if (!Cache::get($redisKey)) { + Cache::set($redisKey, 1, $redpacket['countdown']+get_system_config_value('red_packet_time')+60); + $text = [ + 'redpacket_id' => $redpacketId, + 'text' => '抢完了,请销毁该红包' + ]; + model('api/Chat')->sendMsg(1061,$redpacket['room_id'],$text); + } } - // Lua脚本执行成功,记录到数据库 Db::startTrans(); try {