update check amount

FFIB 5 years ago
parent
commit
6cabed04da
1 changed files with 9 additions and 1 deletions
  1. 9 1
      pay/views.py

+ 9 - 1
pay/views.py

@@ -66,7 +66,15 @@ def wx_order_create_api(request):
66 66
             return response(PackGoodsStatusCode.PACK_GOODS_NOT_FOUND)
67 67
 
68 68
     # 金额校验
69
-    if reduce(lambda g1, g2: g1.get('price', 0) * g1.get('num', 0) + g2.get('price', 0) * g2.get('num', 0), goods_info) != total_fee:
69
+    amount = 0
70
+    for g in goods_info:
71
+        try:
72
+            good = GoodsInfo.objects.get(good_id=g.get('good_id', ''))
73
+        except:
74
+            continue
75
+        amount = amount + good.price * g.get('num', 0)
76
+
77
+    if amount != total_fee:
70 78
         return response(OrderStatusCode.FEE_CHECK_FAIL)
71 79
 
72 80
     # JSAPI--公众号支付、NATIVE--原生扫码支付、APP--app支付,统一下单接口trade_type的传参可参考这里