Ken 1 день назад
Родитель
Сommit
20352a69c2
3 измененных файлов с 27 добавлено и 0 удалено
  1. 12 0
      app/Http/Controllers/api/ActivityReward.php
  2. 12 0
      app/Services/ConfigService.php
  3. 3 0
      routes/api.php

+ 12 - 0
app/Http/Controllers/api/ActivityReward.php

@@ -5,8 +5,10 @@ namespace App\Http\Controllers\api;
 use App\Constants\HttpStatus;
 use App\Models\ActivityReward as ActivityRewardModel;
 use App\Models\ActivityUser;
+use App\Models\Config;
 use App\Services\ActivityRewardService;
 use App\Services\ActivityUserService;
+use App\Services\ConfigService;
 use App\Services\PhoneCodeService;
 use App\Services\SmsService;
 use App\Services\UserService;
@@ -20,6 +22,16 @@ use Exception;
 class ActivityReward extends BaseController
 {
 
+    //活动规则
+    public function role(): JsonResponse
+    {
+        try {
+            $activityRole =ConfigService::getVal("activity_role");
+        }catch (Exception $e){
+            return $this->error($e->getMessage(), [], $e->getCode());
+        }
+        return $this->success($activityRole);
+    }
     //验证手机号
     public function verifyPhone(): JsonResponse
     {

+ 12 - 0
app/Services/ConfigService.php

@@ -3,8 +3,10 @@
 
 namespace App\Services;
 
+use App\Constants\HttpStatus;
 use App\Services\BaseService;
 use App\Models\Config;
+use Exception;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\Cache;
@@ -15,6 +17,9 @@ use Illuminate\Support\Facades\Log;
  */
 class ConfigService extends BaseService
 {
+    public static string $MODEL = Config::class;
+
+
     /**
      * @description: 模型
      * @return {string}
@@ -162,6 +167,13 @@ class ConfigService extends BaseService
         return $result;
     }
 
+    public static function getVal(string $field)
+    {
+        $config = static::$MODEL::where('field', $field)->first();
+        if ($config) return $config->val;
+        throw new Exception("参数不存在", HttpStatus::CUSTOM_ERROR);
+    }
+
     /**
      * 每天把19:56–20:30这段时间的开奖切换成 极速PC28
      */

+ 3 - 0
routes/api.php

@@ -23,6 +23,9 @@ Route::prefix('/ActivityReward')->group(function () {
     Route::post('/participate', [ActivityReward::class, 'participate']);
     Route::post('/sendPhoneCode', [ActivityReward::class, 'sendPhoneCode']);
     Route::post('/verifyPhone', [ActivityReward::class, 'verifyPhone']);
+    Route::get('/role', [ActivityReward::class, 'role']);
+
+
 });