validate([ 'page' => ['nullable', 'integer', 'min:1'], 'limit' => ['nullable', 'integer', 'min:1', 'max:200'], 'member_id' => ['nullable', 'string', 'max:64'], 'account' => ['nullable', 'string', 'max:64'], 'type' => ['nullable', 'string', 'in:' . implode(',', array_keys(WalletFreezeRecord::TYPE_LABELS))], 'status' => ['nullable', 'string', 'in:' . implode(',', array_keys(WalletFreezeRecord::STATUS_LABELS))], 'start_date' => ['nullable', 'date_format:Y-m-d', 'required_with:end_date'], 'end_date' => ['nullable', 'date_format:Y-m-d', 'required_with:start_date', 'after_or_equal:start_date'], ]); return $this->success(WalletFreezeService::list($params)); } catch (ValidationException $e) { return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first()); } catch (Exception $e) { return $this->error(HttpStatus::CUSTOM_ERROR, $e->getMessage()); } } public function freeze() { return $this->apply(true); } public function unfreeze() { return $this->apply(false); } private function apply(bool $isFreeze) { try { $params = request()->validate([ 'request_id' => ['required', 'uuid'], 'member_id' => ['nullable', 'required_without:account', 'string', 'max:64'], 'account' => ['nullable', 'required_without:member_id', 'string', 'max:64'], 'amount' => ['required', 'numeric', 'min:0.01', 'regex:' . self::AMOUNT_PATTERN], 'wager_amount' => ['required', 'numeric', 'min:0', 'regex:' . self::AMOUNT_PATTERN], 'reason' => ['required', 'string', 'min:1', 'max:255'], ]); $memberId = ManualAuditService::resolveMemberId($params['member_id'] ?? null, $params['account'] ?? null); $method = $isFreeze ? 'freeze' : 'unfreeze'; return $this->success(WalletFreezeService::$method((string)$params['request_id'], (int)request()->user->id, $memberId, (string)$params['amount'], (string)$params['wager_amount'], trim((string)$params['reason']))); } catch (ValidationException $e) { return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first()); } catch (Exception $e) { return $this->error(HttpStatus::CUSTOM_ERROR, $e->getMessage()); } } }