>
     if not success:
278 277
         return HttpResponse(WXPAY_NOTIFY_FAIL)
279 278
 
280
-    out_trade_no = data.get('out_trade_no', '')
281 279
     try:
282
-        order = OrderInfo.objects.get(order_id=out_trade_no)
280
+        order = OrderInfo.objects.select_for_update().get(order_id=data.get('out_trade_no', ''), status=True)
283 281
     except OrderInfo.DoesNotExist:
284
-        return response(OrderStatusCode.WX_ORDER_NOT_FOUND)
282
+        return HttpResponse(WXPAY_NOTIFY_FAIL)
285 283
 
286 284
     order.notify_msg = request.body
287 285
     order.transaction_id = data.get('transaction_id', '')
@@ -320,21 +318,22 @@ def wx_balance_withdraw_api(request):
320 318
         return response(WithdrawStatusCode.BALANCE_NOT_ENOUGH)
321 319
 
322 320
     # 根据 trade_type 获取 wechat 配置
323
-    wechat = WECHAT.get(trade_type, {})
321
+    wxcfg = WECHAT.get(trade_type, {})
324 322
     # WeChatPay 初始化
325
-    wxpay = WeChatPay(wechat.get('appID'), wechat.get('apiKey'), wechat.get('mchID'), mch_cert=wechat.get('mch_cert'), mch_key=wechat.get('mch_key'))
323
+    wxpay = WeChatPay(wxcfg.get('appID'), wxcfg.get('apiKey'), wxcfg.get('mchID'), mch_cert=wxcfg.get('mch_cert'), mch_key=wxcfg.get('mch_key'))
326 324
 
327 325
     if withdraw_type == 'TRANSFER':
328 326
         ret_data = wxpay.transfer.transfer(user.openid, amount, u'摄影师余额提现,企业付款', check_name='NO_CHECK')
329 327
     elif withdraw_type == 'PACKET':
328
+        wxrpk = wxcfg.get('redpack', {})
330 329
         ret_data = wxpay.redpack.send(
331 330
             user.openid,
332 331
             amount,
333
-            send_name=wechat.get('redpacket', {}).get('SEND_NAME'),
334
-            nick_name=wechat.get('redpacket', {}).get('NICK_NAME'),
335
-            act_name=wechat.get('redpacket', {}).get('ACT_NAME'),
336
-            wishing=wechat.get('redpacket', {}).get('WISHING'),
337
-            remark=wechat.get('redpacket', {}).get('REMARK'),
332
+            send_name=wxrpk.get('SEND_NAME'),
333
+            nick_name=wxrpk.get('NICK_NAME'),
334
+            act_name=wxrpk.get('ACT_NAME'),
335
+            wishing=wxrpk.get('WISHING'),
336
+            remark=wxrpk.get('REMARK'),
338 337
         )
339 338
 
340 339
     # 根据 ret_data 判断是否提现成功, 成功则减余额, 失败则提示

+ 0 - 13
utils/wechat_utils.py

@@ -1,13 +0,0 @@
1
-# -*- coding: utf-8 -*-
2
-
3
-
4
-def get_user_openid(user, trade_type):
5
-    if trade_type == 'MINIAPP':
6
-        openid = user.openid_miniapp
7
-    elif trade_type == 'JSAPI':
8
-        openid = user.openid_oauth
9
-    elif trade_type == 'APP':
10
-        openid = None
11
-    else:
12
-        openid = None
13
-    return openid

+ 4 - 0
utils/openid_utils.py

@@ -1,6 +1,10 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 
3 3
 
4
+def get_trade_type(trade_type):
5
+    return trade_type if trade_type != 'MINIAPP' else 'JSAPI'
6
+
7
+
4 8
 def get_user_openid(user, trade_type):
5 9
     if trade_type == 'MINIAPP':
6 10
         openid = user.openid_miniapp

kodo - Gogs: Go Git Service

No Description

FFIB: e812ec3fb2 switch gis to tencent 6 years ago
..
migrations 4efb7f6f87 Statistic 8 years ago
static 2e20a894a3 pre_adaptive_cameras 6 years ago
__init__.py 4efb7f6f87 Statistic 8 years ago
admin.py 4efb7f6f87 Statistic 8 years ago
apps.py 4efb7f6f87 Statistic 8 years ago
custom_message.py f4ded5ca43 Try sendcustomwxamessage 6 years ago
market_code.py 3bbfc60c06 :art: Support del_clerk_sale_submit_api 6 years ago
models.py 4efb7f6f87 Statistic 8 years ago
tests.py 4efb7f6f87 Statistic 8 years ago
views.py e812ec3fb2 switch gis to tencent 6 years ago