success(PromotionAmountFormatter::response($callback())); } catch (ValidationException $e) { return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first()); } catch (\Throwable $e) { Log::error('promotion_admin_failed', ['exception' => $e]); return $this->error(HttpStatus::CUSTOM_ERROR, '独立活动服务暂不可用'); } } public function index(PromotionAdminService $s) { return $this->run(fn () => $s->listing(request()->all())); } public function options(PromotionAdminService $s) { return $this->run(fn () => $s->options()); } public function submit(PromotionAdminService $s) { return $this->run(fn () => $s->save(request()->all())); } public function records(PromotionAdminService $s) { return $this->run(fn () => $s->records(request()->all())); } public function detail(PromotionAdminService $s) { return $this->run(function () use ($s) { $p = request()->validate(['id' => ['required_without:type', 'integer', 'min:1'], 'type' => ['required_without:id', 'integer', 'in:7,9']]); return $s->detail(isset($p['id']) ? (int)$p['id'] : null, isset($p['type']) ? (int)$p['type'] : null); }); } public function status(PromotionAdminService $s) { return $this->run(function () use ($s) { $p = request()->validate(['id' => ['required', 'integer', 'min:1'], 'status' => ['required', 'integer', 'in:0,1']]); return $s->status((int)$p['id'], (int)$p['status']); }); } }