|
|
@@ -348,6 +348,17 @@ class QuotaService:
|
|
|
except ImportError:
|
|
|
raise CustomException(msg="支付宝SDK未正确安装,请检查alipay-sdk-python依赖")
|
|
|
|
|
|
+ # 本地检查批次号是否已存在,避免无效调用支付宝
|
|
|
+ try:
|
|
|
+ issue_batch_crud = IssueBatchCRUD(auth)
|
|
|
+ existing_batch = await issue_batch_crud.get_by_batch_no(data.batch_no)
|
|
|
+ if existing_batch:
|
|
|
+ raise CustomException(msg=f"批次号 {data.batch_no} 已存在,请勿重复创建")
|
|
|
+ except CustomException:
|
|
|
+ raise
|
|
|
+ except Exception:
|
|
|
+ pass
|
|
|
+
|
|
|
model = AlipayEbppInvoiceExpensecontrolIssuebatchCreateModel()
|
|
|
model.enterprise_id = data.enterprise_id
|
|
|
model.issue_name = data.issue_name
|
|
|
@@ -388,8 +399,10 @@ class QuotaService:
|
|
|
result.parse_response_content(response)
|
|
|
|
|
|
if not result.is_success():
|
|
|
- log.error(f"支付宝接口调用失败: {result.code} - {result.msg}")
|
|
|
- raise CustomException(msg=f"手工批量发放额度失败: {result.msg}")
|
|
|
+ sub_msg = getattr(result, 'sub_msg', '') or ''
|
|
|
+ err_detail = f"{result.msg}" + (f" - {sub_msg}" if sub_msg else "")
|
|
|
+ log.error(f"支付宝接口调用失败: {result.code} - {err_detail}")
|
|
|
+ raise CustomException(msg=f"手工批量发放额度失败: {sub_msg or result.msg}")
|
|
|
|
|
|
# 保存批次记录到本地
|
|
|
try:
|