|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\api;
|
|
namespace App\Http\Controllers\api;
|
|
|
|
|
|
|
|
|
|
+use App\Constants\HttpStatus;
|
|
|
use App\Models\ActivityReward as ActivityRewardModel;
|
|
use App\Models\ActivityReward as ActivityRewardModel;
|
|
|
use App\Models\ActivityUser;
|
|
use App\Models\ActivityUser;
|
|
|
use App\Services\ActivityRewardService;
|
|
use App\Services\ActivityRewardService;
|
|
@@ -18,12 +19,23 @@ class ActivityReward extends BaseController
|
|
|
try {
|
|
try {
|
|
|
request()->validate([
|
|
request()->validate([
|
|
|
'member_id' => ['required', 'integer', 'exists:users,member_id'],
|
|
'member_id' => ['required', 'integer', 'exists:users,member_id'],
|
|
|
|
|
+ 'activity_id' => ['required', 'integer'],
|
|
|
]);
|
|
]);
|
|
|
$memberId = request()->input('member_id');
|
|
$memberId = request()->input('member_id');
|
|
|
|
|
|
|
|
|
|
+ if (ActivityUser::where('member_id', $memberId)
|
|
|
|
|
+ ->where('status', 0)->exists()) {
|
|
|
|
|
+ throw new Exception('完成活动才可以参与新活动', HttpStatus::CUSTOM_ERROR);
|
|
|
|
|
+ }
|
|
|
|
|
+ $activityId = request()->input('activity_id');
|
|
|
|
|
+ $time = time();
|
|
|
|
|
|
|
|
- ActivityUser::where('member_id', $memberId)->exists();
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $activity = ActivityRewardService::findOne([
|
|
|
|
|
+ 'start_time' => ['<=', $time],
|
|
|
|
|
+ 'end_time' => ['>=', $time],
|
|
|
|
|
+ 'status' => ActivityRewardModel::STATUS_UP,
|
|
|
|
|
+ 'id' => $activityId
|
|
|
|
|
+ ]);
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (ValidationException $e) {
|
|
} catch (ValidationException $e) {
|
|
@@ -31,7 +43,7 @@ class ActivityReward extends BaseController
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
|
return $this->error($e->getMessage());
|
|
return $this->error($e->getMessage());
|
|
|
}
|
|
}
|
|
|
- return $this->success();
|
|
|
|
|
|
|
+ return $this->success($activity);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function index(): JsonResponse
|
|
public function index(): JsonResponse
|