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

暂无描述

Brightcells: bf80400a5b CLERK_NOT_AUTH 7 年之前
..
__init__.py 7d85bed0b0 move errno_utils.py/response_utils.py into error file 10 年之前
errno_utils.py bf80400a5b CLERK_NOT_AUTH 7 年之前