Ken 1 день назад
Родитель
Сommit
90bdf26646
1 измененных файлов с 9 добавлено и 5 удалено
  1. 9 5
      app/Http/Controllers/api/ActivityReward.php

+ 9 - 5
app/Http/Controllers/api/ActivityReward.php

@@ -26,12 +26,13 @@ class ActivityReward extends BaseController
     public function rule(): JsonResponse
     {
         try {
-            $activityRole =ConfigService::getVal("activity_rule");
-        }catch (Exception $e){
+            $activityRole = ConfigService::getVal("activity_rule");
+        } catch (Exception $e) {
             return $this->error($e->getMessage(), [], $e->getCode());
         }
         return $this->success($activityRole);
     }
+
     //验证手机号
     public function verifyPhone(): JsonResponse
     {
@@ -106,12 +107,15 @@ class ActivityReward extends BaseController
 
             $time = time();
             $activity = ActivityRewardService::findOne([
-                'start_time' => ['<=', $time],
-                'end_time' => ['>=', $time],
+//                'start_time' => ['<=', $time],
+//                'end_time' => ['>=', $time],
                 'status' => ActivityRewardModel::STATUS_UP,
                 'id' => $activityId
             ]);
-            if (!$activity) throw new Exception('活动不存在或不在活动时间内', HttpStatus::CUSTOM_ERROR);
+            if (!$activity) throw new Exception('活动不存在', HttpStatus::CUSTOM_ERROR);
+            if ($activity->start_time > $time) throw new Exception('活动未开始', HttpStatus::CUSTOM_ERROR);
+            if ($activity->end_time < $time) throw new Exception('活动已结束', HttpStatus::CUSTOM_ERROR);
+
 
             ActivityUserService::submit([
                 'activity_id' => $activityId,