Эх сурвалжийг харах

优化微信支付响应结构体

zhangdongming 3 жил өмнө
parent
commit
17206f0741

+ 10 - 8
Controller/UnicomCombo/UnicomComboController.py

@@ -11,7 +11,7 @@ import logging
 import time
 
 from django.db import transaction
-from django.http import HttpResponse
+from django.http import HttpResponse, JsonResponse
 from django.views.generic.base import View
 
 from Model.models import UnicomDeviceInfo, UnicomCombo, Pay_Type, Order_Model, Store_Meal, AiStoreMeal, \
@@ -242,6 +242,7 @@ class UnicomComboView(View):
                               }
 
                 params = 'lang=cn' + '&activateType=' + activate_type
+                result = {'result_code': 0, 'reason': 'success', 'error_code': 0}
                 if pay_type == 2:  # 支付宝
                     pay_price = PayService.get_two_float(price, 2)
                     notify_url = 'unicom/wap/pay/ali-notify'
@@ -255,17 +256,18 @@ class UnicomComboView(View):
                     notify_url = 'unicom/wap/pay/wechat-notify'
                     ip = CommonService.get_ip_address(request)
                     params = 'activateType=' + activate_type
-                    order_dict['pay_url'], sign_params = PayService.create_wechat_payment(params, order_id,
-                                                                                          price, ip,
-                                                                                          notify_url,
-                                                                                          unicom_combo_qs['remark'],
-                                                                                          response)
-                    res_data = {'redirectUrl': order_dict['pay_url'], 'orderID': order_id,
-                                'result': sign_params}
+                    sign_params = PayService.create_wechat_payment(params, order_id,
+                                                                   price, ip,
+                                                                   notify_url,
+                                                                   unicom_combo_qs['remark'],
+                                                                   response)
+                    result['result'] = sign_params
                 else:
                     return response.json(444, {'param': 'pay_type'})
 
                 Order_Model.objects.create(**order_dict)
+                if pay_type == 3:
+                    return JsonResponse(status=200, data=result)
                 return response.json(0, res_data)
         except Exception as e:
             print(e)

+ 1 - 1
Object/utils/PayUtil.py

@@ -68,7 +68,7 @@ class PayService:
         sign_params = pay.re_finall(orderid=order_id)
         if not sign_params:
             return response.json(10, '生成订单错误.')
-        return notify_url, sign_params
+        return sign_params
 
     @staticmethod
     def get_two_float(f_str, n):