Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tamp_course_order
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
彭熊
tamp_course_order
Commits
f56e0d8c
Commit
f56e0d8c
authored
Nov 29, 2020
by
pengxiong@wealthgrow.cn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
notify_url根据host_url拼接
parent
dd255f3a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
923 additions
and
15 deletions
+923
-15
order.py
app/controller/order.py
+2
-0
order_service.py
app/service/order_service.py
+9
-7
alipayWap.py
app/utils/alipay/alipayWap.py
+4
-5
wx_app_pay.py
app/utils/wxpay/wx_app_pay.py
+2
-3
tamp_course_order.log
logs/tamp_course_order.log
+906
-0
No files found.
app/controller/order.py
View file @
f56e0d8c
...
...
@@ -47,6 +47,7 @@ class TopUpOrder(Resource):
args
=
self
.
parser
.
parse_args
()
args
[
'user_id'
]
=
request
.
user_id
args
[
'remote_addr'
]
=
request
.
remote_addr
args
[
'host_url'
]
=
request
.
host_url
data
=
order_service
.
TopUpOrderService
()
.
create_order
(
args
)
resp
=
request
.
return_success
resp
[
'attributes'
]
=
data
...
...
@@ -92,6 +93,7 @@ class ConsumeOrder(Resource):
args
[
'user_id'
]
=
request
.
user_id
args
[
'env'
]
=
request
.
headers
[
'env'
]
args
[
'remote_addr'
]
=
request
.
remote_addr
args
[
'host_url'
]
=
request
.
host_url
data
=
order_service
.
CurriculumOrderService
()
.
create_order
(
args
)
resp
=
request
.
return_success
resp
[
'attributes'
]
=
data
...
...
app/service/order_service.py
View file @
f56e0d8c
...
...
@@ -63,17 +63,17 @@ class TopUpOrderService:
args
[
'ab_status'
]
=
'WAIT'
subject
=
'探普币充值'
out_trade_no
=
args
[
'ab_ordernum'
]
notify_
path
=
'/
tamp_order/micro_shop/topUpOrderNotify'
notify_
url
=
args
[
'host_url'
]
+
'
tamp_order/micro_shop/topUpOrderNotify'
pay_params
=
None
if
args
[
'pay_method'
]
==
5
:
# 微信支付
wx_pay
=
WXPay
(
out_trade_no
,
subject
,
args
[
'amount'
],
args
[
'remote_addr'
],
notify_
path
=
notify_path
)
wx_pay
=
WXPay
(
out_trade_no
,
subject
,
args
[
'amount'
],
args
[
'remote_addr'
],
notify_
url
=
notify_url
)
params
=
wx_pay
.
getReturnParams
()
pay_params
=
params
elif
args
[
'pay_method'
]
==
6
:
# 支付宝支付
total_amount
=
args
[
'amount'
]
/
100
res
=
prePay
(
subject
,
out_trade_no
,
total_amount
,
notify_
path
=
notify_path
)
res
=
prePay
(
subject
,
out_trade_no
,
total_amount
,
notify_
url
=
notify_url
)
pay_params
=
res
elif
args
[
'pay_method'
]
==
7
:
# 苹果支付
...
...
@@ -100,6 +100,7 @@ class TopUpOrderService:
AccountBalance
.
user_id
==
args
[
'user_id'
])
.
update
({
'apple_balance'
:
AccountBalance
.
apple_balance
+
args
[
'amount'
]
})
args
.
pop
(
'host_url'
,
''
)
args
.
pop
(
'remote_addr'
,
''
)
args
.
pop
(
'receipt_data'
,
''
)
args
.
pop
(
'product_id'
,
''
)
...
...
@@ -108,7 +109,7 @@ class TopUpOrderService:
args
[
'createby'
]
=
args
.
pop
(
'user_id'
,
''
)
args
[
'ab_type'
]
=
'6'
order_info
=
OrderFlow
(
**
args
)
with
TAMP_SQL
(
tamp_user_
session
)
as
tamp_user
:
with
TAMP_SQL
(
tamp_user_
engine
)
as
tamp_user
:
tamp_user_session
=
tamp_user
.
session
tamp_user_session
.
add
(
order_info
)
return
pay_params
...
...
@@ -176,7 +177,7 @@ class CurriculumOrderService:
args
[
'ab_status'
]
=
'WAIT'
subject
=
args
.
get
(
'prod_name'
,
''
)
out_trade_no
=
args
[
'ab_ordernum'
]
notify_
path
=
'/tamp_order/micro_shop/topUp
OrderNotify'
notify_
url
=
args
[
'host_url'
]
+
'tamp_order/micro_shop/consume
OrderNotify'
pay_params
=
None
# 该用户是否重复购买同一商品
repeat_buy
=
tamp_user_session
.
query
(
OrderFlow
.
id
)
.
filter
(
and_
(
OrderFlow
.
createby
==
args
[
'user_id'
]),
...
...
@@ -214,18 +215,19 @@ class CurriculumOrderService:
args
[
'ab_status'
]
=
'SUCCESS'
elif
args
[
'ab_pay_mode'
]
==
5
:
# 微信支付
wx_pay
=
WXPay
(
out_trade_no
,
subject
,
args
[
'ab_payment'
],
args
[
'remote_addr'
],
notify_
path
=
notify_path
)
wx_pay
=
WXPay
(
out_trade_no
,
subject
,
args
[
'ab_payment'
],
args
[
'remote_addr'
],
notify_
url
)
params
=
wx_pay
.
getReturnParams
()
pay_params
=
params
elif
args
[
'ab_pay_mode'
]
==
6
:
# 支付宝支付
total_amount
=
args
[
'ab_payment'
]
/
100
res
=
prePay
(
subject
,
out_trade_no
,
total_amount
,
notify_
path
=
notify_path
)
res
=
prePay
(
subject
,
out_trade_no
,
total_amount
,
notify_
url
)
pay_params
=
res
args
[
'createby'
]
=
args
.
pop
(
'user_id'
,
''
)
args
.
pop
(
'prod_name'
,
''
)
args
.
pop
(
'env'
,
''
)
args
.
pop
(
'remote_addr'
,
''
)
args
.
pop
(
'host_url'
,
''
)
order_info
=
OrderFlow
(
**
args
)
tamp_user_session
.
add
(
order_info
)
return
pay_params
...
...
app/utils/alipay/alipayWap.py
View file @
f56e0d8c
...
...
@@ -58,15 +58,14 @@ hwtSuAgS7rSrMeMS9omsZro9L1eHDjA8Ja4L0UNGi7i8dGFnp1BtOQ==
-----END PRIVATE KEY-----'''
APP_ID
=
'2021002112638152'
URL_PREFIX
=
config
[
env
][
'pay_url_prefix'
]
ssl
.
_create_default_https_context
=
ssl
.
_create_unverified_context
def
init_alipay
(
notify_
path
=
'/webservice/notify'
):
def
init_alipay
(
notify_
url
):
"""初始化alipay配置."""
alipay
=
AliPay
(
appid
=
APP_ID
,
app_notify_url
=
URL_PREFIX
+
notify_path
,
app_notify_url
=
notify_url
,
app_private_key_string
=
app_private_key_string
,
alipay_public_key_string
=
alipay_public_key_string
,
# 支付宝的公钥,验证支付宝回传消息使用,不是你自己的公钥,
...
...
@@ -76,9 +75,9 @@ def init_alipay(notify_path='/webservice/notify'):
return
alipay
def
prePay
(
subject
,
out_trade_no
,
total_amount
,
notify_
path
=
'/webservice/notify'
):
def
prePay
(
subject
,
out_trade_no
,
total_amount
,
notify_
url
):
"""创建预付订单."""
result
=
init_alipay
(
notify_
path
)
.
api_alipay_trade_app_pay
(
result
=
init_alipay
(
notify_
url
)
.
api_alipay_trade_app_pay
(
subject
=
subject
,
out_trade_no
=
out_trade_no
,
total_amount
=
total_amount
,
...
...
app/utils/wxpay/wx_app_pay.py
View file @
f56e0d8c
...
...
@@ -38,12 +38,11 @@ def genNonce_str():
class
WXPay
(
object
):
"""微信H5支付."""
def
__init__
(
self
,
out_trade_no
,
body
,
total_fee
,
remote_addr
,
notify_
path
=
'/webservice/notify'
):
def
__init__
(
self
,
out_trade_no
,
body
,
total_fee
,
remote_addr
,
notify_
url
):
"""线上:tamper.tanpuyun.com
测试:testtamper.tanpuyun.com"""
self
.
timeStamp
=
int
(
time
.
time
())
self
.
req_url
=
'https://api.mch.weixin.qq.com/pay/unifiedorder'
self
.
url_prefix
=
config
[
env
][
'pay_url_prefix'
]
self
.
appid
=
'wx3ad4c5856975a2c4'
self
.
mch_id
=
'1515329071'
self
.
nonce_str
=
genNonce_str
()
...
...
@@ -53,7 +52,7 @@ class WXPay(object):
self
.
out_trade_no
=
out_trade_no
self
.
total_fee
=
int
(
total_fee
*
100
)
self
.
spbill_create_ip
=
remote_addr
self
.
notify_url
=
self
.
url_prefix
+
notify_path
self
.
notify_url
=
notify_url
self
.
trade_type
=
'APP'
self
.
key
=
'eqwor3wquevncz9384ssp438oarefskl'
self
.
getStringSign
()
...
...
logs/tamp_course_order.log
View file @
f56e0d8c
This source diff could not be displayed because it is too large. You can
view the blob
instead.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment