1
This commit is contained in:
@@ -448,7 +448,7 @@ def _create_wechat_order(order: PaymentOrder, db_configs: dict[str, str]) -> str
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if code == 200 and isinstance(result, dict) and result.get('code_url'):
|
if code == 200 and hasattr(result, 'get') and result.get('code_url'):
|
||||||
# 注意:微信返回的 code_url 可能需要进一步处理成二维码图片地址
|
# 注意:微信返回的 code_url 可能需要进一步处理成二维码图片地址
|
||||||
logger.info(f"WeChat order created successfully: order_no={order.order_no}")
|
logger.info(f"WeChat order created successfully: order_no={order.order_no}")
|
||||||
return result.get('code_url')
|
return result.get('code_url')
|
||||||
@@ -522,7 +522,7 @@ async def _query_wechat_order(db: AsyncSession, order: PaymentOrder, db_configs:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
code, result = client.query(out_trade_no=order.order_no)
|
code, result = client.query(out_trade_no=order.order_no)
|
||||||
if code == 200 and isinstance(result, dict) and result.get('trade_state'):
|
if code == 200 and hasattr(result, 'get') and result.get('trade_state'):
|
||||||
logger.info(
|
logger.info(
|
||||||
f"WeChat query succeeded: order_no={order.order_no}, "
|
f"WeChat query succeeded: order_no={order.order_no}, "
|
||||||
f"trade_state={result.get('trade_state')}"
|
f"trade_state={result.get('trade_state')}"
|
||||||
@@ -578,7 +578,7 @@ async def _refund_wechat_order(
|
|||||||
reason=refund_reason
|
reason=refund_reason
|
||||||
)
|
)
|
||||||
|
|
||||||
if code == 200 and isinstance(result, dict) and result.get('status') == 'SUCCESS':
|
if code == 200 and hasattr(result, 'get') and result.get('status') == 'SUCCESS':
|
||||||
logger.info(f"WeChat refund succeeded: order_no={order.order_no}")
|
logger.info(f"WeChat refund succeeded: order_no={order.order_no}")
|
||||||
return {"success": True, "refund_id": result.get('refund_id')}
|
return {"success": True, "refund_id": result.get('refund_id')}
|
||||||
else:
|
else:
|
||||||
@@ -588,7 +588,7 @@ async def _refund_wechat_order(
|
|||||||
)
|
)
|
||||||
return {
|
return {
|
||||||
"success": False,
|
"success": False,
|
||||||
"message": f"微信退款失败: code={code}, {result.get('code', '') if isinstance(result, dict) else ''}"
|
"message": f"微信退款失败: code={code}, {result.get('code', '') if hasattr(result, 'get') else ''}"
|
||||||
}
|
}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception(f"WeChat refund exception: order_no={order.order_no}")
|
logger.exception(f"WeChat refund exception: order_no={order.order_no}")
|
||||||
|
|||||||
Reference in New Issue
Block a user