|
@@ -411,12 +411,27 @@ class Lottery extends Api
|
|
|
'total_amount' => $orderInfo->amount,
|
|
|
'goods' => $goodsList
|
|
|
];
|
|
|
+ // 获取当前正在进行的单个抽奖活动
|
|
|
+ $activity = LotteryActivityService::getCurrentRunningActivity();
|
|
|
+
|
|
|
+ // 如果没有正在进行的活动,返回null
|
|
|
+ if (!$activity) {
|
|
|
+ $this->success('获取成功', null);
|
|
|
+ }
|
|
|
// 用户 订单 是否已经分发过 抽奖机会
|
|
|
$isGranted = LotteryChanceService::isGrantedChanceForOrder($orderInfo, $userId);
|
|
|
if($isGranted){
|
|
|
- $this->error('该订单已分发过抽奖机会');
|
|
|
+ // 直接返回 所剩 机会
|
|
|
+ $userChance = LotteryChanceService::getUserChance($activity->id, $userId);
|
|
|
+ $arrReturn = [
|
|
|
+ 'lottery_id' => $activity->id,
|
|
|
+ 'lottery_type' => $activity->lottery_type,
|
|
|
+ 'lottery_name' => $activity->name,
|
|
|
+ 'chances' => $userChance->total_chances,
|
|
|
+ ];
|
|
|
+ $this->success('获取成功', $arrReturn);
|
|
|
}
|
|
|
- $grantedChances = LotteryChanceService::checkAndGrantChanceForOrderOne($orderInfo, $userId);
|
|
|
+ $grantedChances = LotteryChanceService::checkAndGrantChanceForOrderOne($activity, $orderInfo, $userId);
|
|
|
$this->success('获取成功', $grantedChances);
|
|
|
}
|
|
|
}
|