|
@@ -35,6 +35,28 @@ from .schema import (
|
|
|
)
|
|
)
|
|
|
from ..openapi.crud import OpenTransferCRUD
|
|
from ..openapi.crud import OpenTransferCRUD
|
|
|
|
|
|
|
|
|
|
+# 支付宝资金专户转账错误码 → 友好提示
|
|
|
|
|
+_TRANSFER_ERROR_HINTS = {
|
|
|
|
|
+ "SYSTEM_ERROR": "系统繁忙,请稍后重试",
|
|
|
|
|
+ "INVALID_PARAMETER": "请求参数有误,请检查后重试",
|
|
|
|
|
+ "AMOUNT_LESS_THAN_ONE_CENT": "转账金额不能低于 0.01 元",
|
|
|
|
|
+ "BALANCE_IS_NOT_ENOUGH": "企业余额不足,建议充值",
|
|
|
|
|
+ "BANK_RESPONSE_ERROR": "银行处理失败:账户异常",
|
|
|
|
|
+ "CARD_BIN_ERROR": "收款银行账号不正确,请确认",
|
|
|
|
|
+ "DUPLICATE_DIFFERENT_REQUEST": "重复请求但参数不一致,请检查",
|
|
|
|
|
+ "EXCEED_LIMIT_SM_MIN_AMOUNT": "转账金额不能低于 0.1 元",
|
|
|
|
|
+ "EXCEED_LIMIT_DM_MAX_AMOUNT": "超出单日转账限额,请明天再试或联系管理员提升限额",
|
|
|
|
|
+ "INVALID_ACCOUNT_BOOK": "资金专户不存在,请检查专户号",
|
|
|
|
|
+ "INVALID_CARDNO": "无效的收款银行卡号",
|
|
|
|
|
+ "INVALID_IDENTITY_TYPE": "收款方身份类型不匹配",
|
|
|
|
|
+ "NO_AGREEMENT": "无转账权限,请联系管理员",
|
|
|
|
|
+ "PAYEE_CARD_INFO_ERROR": "收款方账号或银行卡信息有误,请核实",
|
|
|
|
|
+ "PAYEE_NOT_EXIST": "收款账号不存在或姓名有误",
|
|
|
|
|
+ "PAYER_BALANCE_NOT_ENOUGH": "付款方余额不足,建议充值",
|
|
|
|
|
+ "REQUEST_PROCESSING": "系统处理中,请稍后重试",
|
|
|
|
|
+ "TRANS_AUTH_NO_EXIST": "转账授权协议不存在,请先签约",
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
|
|
|
def _parse_dt(val: str | None) -> datetime | None:
|
|
def _parse_dt(val: str | None) -> datetime | None:
|
|
|
"""解析支付宝日期字符串"""
|
|
"""解析支付宝日期字符串"""
|
|
@@ -312,8 +334,11 @@ class AccountService:
|
|
|
result.parse_response_content(response)
|
|
result.parse_response_content(response)
|
|
|
|
|
|
|
|
if not result.is_success():
|
|
if not result.is_success():
|
|
|
- log.error(f"支付宝接口调用失败: {result.code} - {result.msg}")
|
|
|
|
|
- raise CustomException(msg=f"转账失败: {result.sub_msg or result.msg or result.code}")
|
|
|
|
|
|
|
+ sub_code = getattr(result, 'sub_code', '') or ''
|
|
|
|
|
+ sub_msg = getattr(result, 'sub_msg', '') or ''
|
|
|
|
|
+ hint = _TRANSFER_ERROR_HINTS.get(sub_code, sub_msg or result.msg or "转账失败")
|
|
|
|
|
+ log.error(f"支付宝接口调用失败: {result.code} - {result.msg} (sub_code={sub_code})")
|
|
|
|
|
+ raise CustomException(msg=f"转账失败: {hint}")
|
|
|
|
|
|
|
|
transfer_crud = TransferCRUD(auth)
|
|
transfer_crud = TransferCRUD(auth)
|
|
|
transfer_data = {
|
|
transfer_data = {
|