| 123456789101112131415161718192021 |
- <?php
- namespace App\Http\Controllers\admin;
- use App\Http\Controllers\Controller;
- use App\Services\RechargeBonusAdminService;
- use Illuminate\Support\Facades\Log;
- use Illuminate\Validation\ValidationException;
- class RechargeBonus extends Controller
- {
- public function index(RechargeBonusAdminService $service) { return $this->run(fn () => $service->listing()); }
- public function save(RechargeBonusAdminService $service) { return $this->run(fn () => $service->save(request()->all())); }
- public function status(RechargeBonusAdminService $service) { return $this->run(fn () => $service->status(request()->all())); }
- private function run(callable $callback)
- {
- try { return $this->success($callback()); }
- catch (ValidationException $e) { return $this->error(-3, $e->validator->errors()->first()); }
- catch (\Throwable $e) { Log::error('recharge_bonus_failed', ['exception' => $e]); return $this->error(-3, '充值赠送操作失败,请稍后重试'); }
- }
- }
|