From 5523125c65d22a9faaf795622a015d40b5220c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Tue, 14 Oct 2025 10:47:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A2=E7=BA=A2=E5=8C=85=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E9=87=8D=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/service/RedpacketService.php | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/application/common/service/RedpacketService.php b/application/common/service/RedpacketService.php index 7b70a2d..d660001 100644 --- a/application/common/service/RedpacketService.php +++ b/application/common/service/RedpacketService.php @@ -57,12 +57,11 @@ class RedpacketService // 检查是否已经抢过 if ($this->hasUserGrabbed($redpacketId, $userId)) { - $detail = $this->getGrabResult($redpacketId, $userId); - +// $detail = $this->getGrabResult($redpacketId, $userId); return [ - 'code' => 0, + 'code' => 1, 'msg' => '已经抢过该红包', - 'data' => $detail + 'data' => ['code' => 2] //1-抢到了,2-已经抢过红包,3-没有抢到 ]; } @@ -82,12 +81,25 @@ class RedpacketService if ($result[0] == 0) { $message = $result[1]; - - return [ - 'code' => 0, - 'msg' => $message, - 'data' => null - ]; + if ($message == '红包已抢完') { + return [ + 'code' => 1, + 'msg' => '手慢了,红包已抢完', + 'data' => ['code' => 3] //1-抢到了,2-已经抢过红包,3-没有抢到 + ]; + } elseif ($message == '已经抢过该红包') { + return [ + 'code' => 1, + 'msg' => '已经抢过该红包', + 'data' => ['code' => 2] //1-抢到了,2-已经抢过红包,3-没有抢到 + ]; + }else{ + return [ + 'code' => 0, + 'msg' => $message, + 'data' => null + ]; + } } $amount = floatval($result[1]); @@ -149,7 +161,8 @@ class RedpacketService 'code' => 1, 'msg' => '抢红包成功', // 'data' => $grabResult - 'data' => null +// 'data' => null + 'data' => ['code' => 1] //1-抢到了,2-已经抢过红包,3-没有抢到 ]; } catch (\Exception $e) {