fix: 全支付接口入口拦截小汐支付宝,微信支付路径不动

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-26 16:29:50 +08:00
parent 49e07c2673
commit 79c86ec373
8 changed files with 92 additions and 20 deletions

View File

@@ -122,6 +122,18 @@ class FaKuanPayView(APIView):
jine = float(fadan.FineAmount)
from jituan.services.club_write import resolve_club_id_for_write
from jituan.services.alipay_pay import alipay_pay_method_block_reason
pay_method = (request.data.get('pay_method') or request.data.get('payMethod') or 'wechat').lower()
pay_club = resolve_club_id_for_write(request, request.user)
_alipay_block = alipay_pay_method_block_reason(pay_method, pay_club)
if _alipay_block:
return Response({
'code': 400,
'message': _alipay_block,
'msg': _alipay_block,
}, status=status.HTTP_400_BAD_REQUEST)
timestamp_ms = int(time.time() * 1000)
timestamp_ns = int(time.time_ns() // 1000) % 1000000
random_num = random.randint(0, 99)
@@ -144,9 +156,6 @@ class FaKuanPayView(APIView):
# 生成支付参数(支持支付宝/微信)
# 支付必须用「当前小程序/打手写入俱乐部」的 AppID+openid
# 与罚单 ClubID申请人俱乐部混用会导致部分人 openid/appid 不一致而下单失败。
from jituan.services.club_write import resolve_club_id_for_write
pay_club = resolve_club_id_for_write(request, request.user)
pay_method = (request.data.get('pay_method') or request.data.get('payMethod') or 'wechat').lower()
if pay_method == 'alipay':
try:
from jituan.services.alipay_pay import generate_alipay_czjilu_pay_params
@@ -623,6 +632,14 @@ class KaohePayView(APIView):
logger.warning(f"费用为0应使用免费申请接口tag_id={tag_id}, cishu={new_cishu}")
return Response({'code': 400, 'message': '本次费用为0请直接使用免费申请接口'})
from jituan.services.club_write import resolve_club_id_for_write
from jituan.services.alipay_pay import alipay_pay_method_block_reason
pay_method = (request.data.get('pay_method') or request.data.get('payMethod') or 'wechat').lower()
pay_club = resolve_club_id_for_write(request, user)
_alipay_block = alipay_pay_method_block_reason(pay_method, pay_club)
if _alipay_block:
return Response({'code': 400, 'message': _alipay_block})
# 7. 生成订单ID
timestamp_ms = int(time.time() * 1000)
timestamp_ns = int(time.time_ns() // 1000) % 1000000
@@ -631,7 +648,6 @@ class KaohePayView(APIView):
logger.info(f"生成订单ID: {dingdanid}")
# 8. 创建支付订单Czjilu
from jituan.services.club_write import resolve_club_id_for_write
order = Czjilu.query.create(
dingdan_id=dingdanid,
zhuangtai=9, # 未支付
@@ -639,7 +655,7 @@ class KaohePayView(APIView):
jine=float(fee),
leixing=5, # 5-考核支付
shuoming=settings.KAOHE_PAY_DESCRIPTION,
club_id=resolve_club_id_for_write(request, user),
club_id=pay_club,
)
logger.info(f"创建支付订单成功: {dingdanid}")
@@ -669,7 +685,6 @@ class KaohePayView(APIView):
logger.info(f"attach内容: {attach_str},长度: {len(attach_str.encode('utf-8'))}字节")
# 11. 生成支付参数(支持支付宝/微信)
pay_method = (request.data.get('pay_method') or request.data.get('payMethod') or 'wechat').lower()
if pay_method == 'alipay':
try:
from jituan.services.alipay_pay import generate_alipay_czjilu_pay_params
@@ -677,7 +692,7 @@ class KaohePayView(APIView):
dingdanid=dingdanid,
jine=float(fee),
subject=settings.KAOHE_PAY_DESCRIPTION,
club_id=resolve_club_id_for_write(request, user),
club_id=pay_club,
)
logger.info(f"支付宝支付参数生成成功: {dingdanid}")
except Exception as e: