fix: 全支付接口入口拦截小汐支付宝,微信支付路径不动
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user