Browse Source

保留两个字段

doge 4 hours ago
parent
commit
251d848e50

+ 0 - 2
app/Http/Controllers/admin/ActivityReward.php

@@ -89,8 +89,6 @@ class ActivityReward extends Controller
                 'end_time' => ['required', 'date', 'after_or_equal:start_time'],
                 'detail_image' => ['required'],
                 'pc_image' => ['required'],
-                'detail_banner' => ['required'],
-                'pc_banner' => ['required'],
                 'status' => ['required', 'integer', 'min:0', 'max:1'],
                 'type' => ['required', 'integer', 'min:1', 'max:6'],
                 'lang' => ['required', 'string'],

+ 1 - 0
app/Models/ActivityReward.php

@@ -21,6 +21,7 @@ class ActivityReward extends BaseModel
     const STATUS_DOWN = 0;
 
     protected $table = 'activity_rewards';
+    protected $hidden = ['created_at', 'updated_at', 'detail_banner', 'pc_banner'];
     protected $fillable = ['title', 'sub_title', 'detail_image', 'start_time', 'end_time', 'status','type','lang','content', 'params','pc_image','detail_banner', 'pc_banner',
         'publish_platforms', 'budget', 'reward_quota', 'sort', 'register_time_limited', 'register_start_time', 'register_end_time',
         'register_platforms', 'deposit_limited', 'deposit_min', 'deposit_max', 'show_ineligible', 'game_category', 'click_type', 'link', 'click_position'];

+ 4 - 4
app/Services/ActivityRewardService.php

@@ -168,6 +168,7 @@ class ActivityRewardService extends BaseService
      */
     public static function submit(array $params = []): bool
     {
+        unset($params['detail_banner'], $params['pc_banner']);
         $info = !empty($params['id']) ? static::findOne(['id' => $params['id']]) : null;
         if (!empty($params['id']) && !$info) throw new Exception('操作失败', HttpStatus::CUSTOM_ERROR);
         if (array_key_exists('game_category', $params)) {
@@ -186,15 +187,14 @@ class ActivityRewardService extends BaseService
             $params['detail_image'] = Util::replacePartInUrl($params['detail_image']);
         if (isset($params['pc_image']))
             $params['pc_image'] = Util::replacePartInUrl($params['pc_image']);
-        if (isset($params['detail_banner']))
-            $params['detail_banner'] = Util::replacePartInUrl($params['detail_banner']);
-        if (isset($params['pc_banner']))
-            $params['pc_banner'] = Util::replacePartInUrl($params['pc_banner']);
 
         if (!empty($params['id'])) {
             $info->update($params);
         } else {
             $info = new ActivityReward($params);
+            // Legacy schemas require these unused columns; frontend inputs are never persisted.
+            $info->detail_banner = '';
+            $info->pc_banner = '';
             $info->quota_enabled = true; // Existing rows stay false; clients cannot change the mode.
             $info->save();
         }

+ 7 - 0
docs/前端接口/活动/图片字段调整-前端接入.md

@@ -0,0 +1,7 @@
+# 活动图片字段调整
+
+活动新增、编辑表单移除 `detail_banner`、`pc_banner`,不再显示、校验或提交这两个字段。
+
+保留 `detail_image`、`pc_image`,继续按原方式上传、校验和提交至 `POST /admin/ActivityReward/submit`。
+
+后台活动列表及会员活动列表、详情保留 `detail_image/pc_image`,不再返回 `detail_banner/pc_banner`。

+ 2 - 4
docs/前端接口/活动/游戏类型与活动类型选项-前端接入说明.md

@@ -94,10 +94,8 @@
   "sub_title": "活动详情以页面规则为准",
   "start_time": "2026-10-25 00:00:00",
   "end_time": "2026-11-30 23:59:59",
-  "detail_image": "/uploads/activity-detail.jpg",
-  "pc_image": "/uploads/activity-pc.jpg",
-  "detail_banner": "/uploads/activity-detail-banner.jpg",
-  "pc_banner": "/uploads/activity-pc-banner.jpg",
+  "detail_image": "/uploads/activity-detail-banner.jpg",
+  "pc_image": "/uploads/activity-pc-banner.jpg",
   "status": 1,
   "type": 3,
   "lang": "zh",

+ 2 - 4
docs/前端接口/活动/游戏类型其他选项与名称调整-前端接入说明.md

@@ -83,10 +83,8 @@
   "sub_title": "活动详情以页面规则为准",
   "start_time": "2026-10-25 00:00:00",
   "end_time": "2026-11-30 23:59:59",
-  "detail_image": "/uploads/activity-detail.jpg",
-  "pc_image": "/uploads/activity-pc.jpg",
-  "detail_banner": "/uploads/activity-detail-banner.jpg",
-  "pc_banner": "/uploads/activity-pc-banner.jpg",
+  "detail_image": "/uploads/activity-detail-banner.jpg",
+  "pc_image": "/uploads/activity-pc-banner.jpg",
   "status": 1,
   "type": 3,
   "lang": "zh",

+ 3 - 5
docs/前端接口/活动/资格条件与展示开关.md

@@ -74,7 +74,7 @@ bot-28 后台、bot-28 Telegram 活动页、会员站点使用各自配置的 AP
 | `id` | 新增省略;编辑传原记录 ID,整数且大于等于 `1` |
 | `title`、`sub_title` | 必填字符串,长度 `1`~`140` |
 | `start_time`、`end_time` | 必填日期时间,结束不早于开始;提交格式沿用原活动控件,如 `YYYY-MM-DD HH:mm:ss` |
-| `detail_image`、`pc_image`、`detail_banner`、`pc_banner` | 四个图片字段均必填,沿用现有上传后路径或 URL |
+| `detail_image`、`pc_image` | 两个图片字段必填,沿用现有上传后路径或 URL |
 | `status` | 必填,`1` 上架、`0` 下架 |
 | `type` | 必填整数 `1`~`6`,沿用现有类型选项;`2` 为足球首页 |
 | `lang` | 必填字符串,沿用现有语种选项,如 `zh` |
@@ -125,10 +125,8 @@ bot-28 后台、bot-28 Telegram 活动页、会员站点使用各自配置的 AP
   "sub_title": "限十位符合条件的会员获奖",
   "start_time": "2026-10-15 00:00:00",
   "end_time": "2026-10-31 23:59:59",
-  "detail_image": "/uploads/activity-app.jpg",
-  "pc_image": "/uploads/activity-pc.jpg",
-  "detail_banner": "/uploads/activity-app-banner.jpg",
-  "pc_banner": "/uploads/activity-pc-banner.jpg",
+  "detail_image": "/uploads/activity-app-banner.jpg",
+  "pc_image": "/uploads/activity-pc-banner.jpg",
   "status": 1,
   "type": 3,
   "lang": "zh",

+ 27 - 0
tests/Integration/ActivityCatalogTest.php

@@ -163,6 +163,33 @@ class ActivityCatalogTest extends TestCase
         $this->assertSame(0, DB::table('activity_reward_recipients')->count());
     }
 
+    public function test_removed_banners_are_not_required_saved_or_returned_and_images_remain(): void
+    {
+        $input = $this->form(); unset($input['detail_banner'], $input['pc_banner']);
+        $this->request('submit', $input, 'POST');
+        $body = (new AdminActivityReward())->store()->getData(true);
+        $this->assertSame(HttpStatus::OK, $body['code']);
+        $id = (int) DB::table('activity_rewards')->value('id');
+        $this->assertSame('', DB::table('activity_rewards')->where('id', $id)->value('detail_banner'));
+        $this->assertSame('', DB::table('activity_rewards')->where('id', $id)->value('pc_banner'));
+        $this->assertSame('/app.png', DB::table('activity_rewards')->where('id', $id)->value('detail_image'));
+        $this->assertSame('/pc.png', DB::table('activity_rewards')->where('id', $id)->value('pc_image'));
+        DB::table('activity_rewards')->where('id', $id)->update(['detail_banner' => '/old.png', 'pc_banner' => '/old-pc.png']);
+        $body = $this->save(['id' => $id, 'detail_banner' => ['ignored legacy input'], 'pc_banner' => ['ignored legacy input']]);
+        $this->assertSame(HttpStatus::OK, $body['code']);
+        $this->assertSame('/old.png', DB::table('activity_rewards')->where('id', $id)->value('detail_banner'));
+        $this->assertSame('/old-pc.png', DB::table('activity_rewards')->where('id', $id)->value('pc_banner'));
+        foreach (['detail_image', 'pc_image'] as $required) {
+            $missing = $this->form(['id' => $id]); unset($missing[$required]);
+            $this->request('submit', $missing, 'POST');
+            $this->assertSame(HttpStatus::CUSTOM_ERROR, (new AdminActivityReward())->store()->getData(true)['code']);
+        }
+        foreach ([ActivityReward::findOrFail($id)->toArray(), $this->listing()['data'][0]] as $row) {
+            $this->assertArrayNotHasKey('detail_banner', $row); $this->assertArrayNotHasKey('pc_banner', $row);
+            $this->assertArrayHasKey('detail_image', $row); $this->assertArrayHasKey('pc_image', $row);
+        }
+    }
+
     public function test_activity_click_behavior_saves_preserves_and_clears_for_normal_and_type_two_activities(): void
     {
         $this->request('options');