fix(backend): coerce receive account order_num to int or None.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-07-30 13:44:22 +08:00
1 parent 51f868ea44
commit 9277b9c568
1 file changed
+15 -2
+15 -2
View File
@@ -5,7 +5,6 @@ from typing import Any, Dict, List, Optional, Tuple
ACCOUNT_TYPES = frozenset({"alipay", "personal", "corporate"})
_BANK_FIELDS = ("bank_name", "bank_province", "bank_city", "bank_branch")
_BANK_FIELD_ALIASES = {
"bank_name": ("bankName", "bank_name"),
"bank_province": ("bankProvince", "bank_province"),
@@ -73,6 +72,20 @@ def _pick_str(body: dict, camel: str, snake: str, default: str = "") -> str:
return str(raw).strip()
def _pick_order_num(body: dict) -> Optional[int]:
raw = _pick(body, "orderNum", "order_num", None)
if raw is None:
return None
if isinstance(raw, str):
raw = raw.strip()
if raw == "":
return None
try:
return int(raw)
except (TypeError, ValueError):
return None
def normalize_account_fields(body: dict) -> Tuple[bool, Optional[str], Dict[str, Any]]:
"""规范化收款账户写入字段,返回 (ok, error, snake_case dict)。"""
if not isinstance(body, dict):
@@ -85,7 +98,7 @@ def normalize_account_fields(body: dict) -> Tuple[bool, Optional[str], Dict[str,
bank_province = _pick_str(body, "bankProvince", "bank_province")
bank_city = _pick_str(body, "bankCity", "bank_city")
bank_branch = _pick_str(body, "bankBranch", "bank_branch")
order_num = _pick(body, "orderNum", "order_num")
order_num = _pick_order_num(body)
remark = _pick_str(body, "remark", "remark")
if not account_name: