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) {