fix: 批量退款处理人ID默认138377,限制chuliid最长11位

batch_20260710 超长导致762单全部失败;与客服手机号字段一致。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-10 23:21:23 +08:00
parent 73f0ce36f2
commit 6689b7af00
2 changed files with 23 additions and 4 deletions

View File

@@ -11,6 +11,23 @@ from users.business_models import User
logger = logging.getLogger(__name__)
# tuikuanjilu.chuliid / RefundRecord.ProcessorID 数据库列最长 11
PROCESSOR_ID_MAX_LEN = 11
def normalize_processor_id(processor_id, *, default='138377'):
"""处理人 ID 须 <=11 位(与客服手机号字段一致),超长则截断。"""
val = (processor_id or default or '').strip()
if not val:
val = default
if len(val) > PROCESSOR_ID_MAX_LEN:
logger.warning(
'processor_id 超长已截断: %s -> %s',
val, val[:PROCESSOR_ID_MAX_LEN],
)
val = val[:PROCESSOR_ID_MAX_LEN]
return val
class MerchantRefundApproveError(Exception):
"""单笔商家退款同意失败。"""
@@ -19,7 +36,7 @@ class MerchantRefundApproveError(Exception):
def approve_merchant_refund_order(
order,
*,
processor_id='batch_script',
processor_id='138377',
tuikuan_liyou='',
require_status_4=True,
):
@@ -36,6 +53,7 @@ def approve_merchant_refund_order(
返回 (True, 'ok');失败抛 MerchantRefundApproveError。
"""
dingdan_id = order.OrderID
processor_id = normalize_processor_id(processor_id)
if order.Platform != 2:
raise MerchantRefundApproveError(f'订单 {dingdan_id} 不是商家发单(Platform=2)')