抢红包返回结果重组
This commit is contained in:
@@ -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,13 +81,26 @@ class RedpacketService
|
||||
|
||||
if ($result[0] == 0) {
|
||||
$message = $result[1];
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user