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
5736769a
Commit
5736769a
authored
Nov 29, 2020
by
pengxiong@wealthgrow.cn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支付宝微信交易流水号保存
parent
f56e0d8c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
15 deletions
+64
-15
order.py
app/controller/order.py
+2
-2
order_service.py
app/service/order_service.py
+18
-13
tamp_course_order.log
logs/tamp_course_order.log
+44
-0
No files found.
app/controller/order.py
View file @
5736769a
...
@@ -125,7 +125,7 @@ class TopUpOrderNotify(Resource):
...
@@ -125,7 +125,7 @@ class TopUpOrderNotify(Resource):
res_info
=
request
.
stream
.
read
(
request
.
content_length
or
0
)
.
decode
()
res_info
=
request
.
stream
.
read
(
request
.
content_length
or
0
)
.
decode
()
res
=
order_service
.
alipayWxPayCheck
(
res_info
)
res
=
order_service
.
alipayWxPayCheck
(
res_info
)
if
res
[
'success'
]:
if
res
[
'success'
]:
order_service
.
topUpSuccessAction
(
res
[
'order_no'
])
order_service
.
topUpSuccessAction
(
res
[
'order_no'
]
,
res
[
'transaction_id'
]
)
resp
=
make_response
(
res
[
'body'
])
resp
=
make_response
(
res
[
'body'
])
resp
.
hearders
=
res
[
'header'
]
resp
.
hearders
=
res
[
'header'
]
return
resp
return
resp
...
@@ -156,7 +156,7 @@ class ConsumeOrderNotify(Resource):
...
@@ -156,7 +156,7 @@ class ConsumeOrderNotify(Resource):
res_info
=
request
.
stream
.
read
(
request
.
content_length
or
0
)
.
decode
()
res_info
=
request
.
stream
.
read
(
request
.
content_length
or
0
)
.
decode
()
res
=
order_service
.
alipayWxPayCheck
(
res_info
)
res
=
order_service
.
alipayWxPayCheck
(
res_info
)
if
res
[
'success'
]:
if
res
[
'success'
]:
order_service
.
consumeSucessAction
(
res
[
'order_no'
])
order_service
.
consumeSucessAction
(
res
[
'order_no'
]
,
res
[
'transaction_id'
]
)
resp
=
make_response
(
res
[
'body'
])
resp
=
make_response
(
res
[
'body'
])
resp
.
hearders
=
res
[
'header'
]
resp
.
hearders
=
res
[
'header'
]
return
resp
return
resp
...
...
app/service/order_service.py
View file @
5736769a
...
@@ -233,7 +233,7 @@ class CurriculumOrderService:
...
@@ -233,7 +233,7 @@ class CurriculumOrderService:
return
pay_params
return
pay_params
def
topUpSuccessAction
(
order_no
):
def
topUpSuccessAction
(
order_no
,
transaction_id
):
"""."""
"""."""
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user
,
TAMP_SQL
(
tamp_pay_engine
)
as
tamp_pay
:
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user
,
TAMP_SQL
(
tamp_pay_engine
)
as
tamp_pay
:
tamp_user_session
,
tamp_pay_session
=
tamp_user
.
session
,
tamp_pay
.
session
tamp_user_session
,
tamp_pay_session
=
tamp_user
.
session
,
tamp_pay
.
session
...
@@ -247,6 +247,7 @@ def topUpSuccessAction(order_no):
...
@@ -247,6 +247,7 @@ def topUpSuccessAction(order_no):
return
False
return
False
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
OrderFlow
.
ab_ordernum
==
order_no
)
.
update
({
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
OrderFlow
.
ab_ordernum
==
order_no
)
.
update
({
'ab_status'
:
'SUCCESS'
,
'ab_status'
:
'SUCCESS'
,
'transaction_serial_no'
:
transaction_id
,
'pay_time'
:
datetime
.
datetime
.
now
(),
'pay_time'
:
datetime
.
datetime
.
now
(),
'complete_time'
:
datetime
.
datetime
.
now
()
'complete_time'
:
datetime
.
datetime
.
now
()
})
})
...
@@ -264,7 +265,7 @@ def topUpSuccessAction(order_no):
...
@@ -264,7 +265,7 @@ def topUpSuccessAction(order_no):
def
consumeSucessAction
(
order_no
):
def
consumeSucessAction
(
order_no
,
transaction_id
):
"""."""
"""."""
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user
:
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user
:
tamp_user_session
=
tamp_user
.
session
tamp_user_session
=
tamp_user
.
session
...
@@ -278,6 +279,7 @@ def consumeSucessAction(order_no):
...
@@ -278,6 +279,7 @@ def consumeSucessAction(order_no):
return
False
return
False
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
OrderFlow
.
ab_ordernum
==
order_no
)
.
update
({
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
OrderFlow
.
ab_ordernum
==
order_no
)
.
update
({
'ab_status'
:
'SUCCESS'
,
'ab_status'
:
'SUCCESS'
,
'transaction_serial_no'
:
transaction_id
,
'pay_time'
:
datetime
.
datetime
.
now
(),
'pay_time'
:
datetime
.
datetime
.
now
(),
'complete_time'
:
datetime
.
datetime
.
now
()
'complete_time'
:
datetime
.
datetime
.
now
()
})
})
...
@@ -314,27 +316,30 @@ def dict2xml(dict_):
...
@@ -314,27 +316,30 @@ def dict2xml(dict_):
def
alipayWxPayCheck
(
res_info
):
def
alipayWxPayCheck
(
res_info
):
"""支付宝,微信支付异步通知"""
"""支付宝,微信支付异步通知"""
success
=
False
success
=
False
body
=
None
body
=
''
transaction_id
=
''
header
=
{
'Content-Type'
:
'application/text'
}
header
=
{
'Content-Type'
:
'application/text'
}
res
=
{}
res
=
{}
if
'trade_status'
in
res_info
:
if
'xml'
in
res_info
:
# 微信支付
res
=
xml2dict
(
res_info
)
if
res
[
'return_code'
]
==
'SUCCESS'
and
res
[
'result_code'
]
==
'SUCCESS'
:
success
=
True
transaction_id
=
res
.
get
(
'transaction_id'
,
''
)
header
=
{
'Content-Type'
:
'application/xml'
}
body
=
'<xml> <return_code><![CDATA[SUCCESS]]></return_code> <return_msg><![CDATA[OK]]></return_msg> </xml>'
else
:
# 支付宝支付
# 支付宝支付
res_info
=
res_info
.
split
(
'&'
)
res_info
=
res_info
.
split
(
'&'
)
for
ss
in
res_info
:
for
ss
in
res_info
:
key
,
value
=
ss
.
split
(
'='
)
key
,
value
=
ss
.
split
(
'='
)
res
[
key
]
=
value
res
[
key
]
=
value
if
res
[
'
trade_status'
]
==
'TRADE_SUCCESS
'
:
if
res
[
'
code'
]
==
'10000
'
:
success
=
True
success
=
True
transaction_id
=
res
.
get
(
'trade_no'
,
''
)
body
=
'success'
.
encode
()
body
=
'success'
.
encode
()
else
:
# 微信支付
res
=
xml2dict
(
res_info
)
if
res
[
'result_code'
]
==
'SUCCESS'
and
res
[
'return_code'
]
==
'SUCCESS'
:
success
=
True
header
=
{
'Content-Type'
:
'application/xml'
}
body
=
'<xml> <return_code><![CDATA[SUCCESS]]></return_code> <return_msg><![CDATA[OK]]></return_msg> </xml>'
return
{
'success'
:
success
,
'header'
:
header
,
'body'
:
body
,
'order_no'
:
res
[
'out_trade_no'
]}
return
{
'success'
:
success
,
'header'
:
header
,
'body'
:
body
,
'order_no'
:
res
[
'out_trade_no'
]
,
'transaction_id'
:
transaction_id
}
def
getAllOrders
(
args
):
def
getAllOrders
(
args
):
...
...
logs/tamp_course_order.log
View file @
5736769a
...
@@ -33292,3 +33292,47 @@ WHERE order_flow.createby = %(createby_1)s AND order_flow.ab_proid = %(ab_proid_
...
@@ -33292,3 +33292,47 @@ WHERE order_flow.createby = %(createby_1)s AND order_flow.ab_proid = %(ab_proid_
2020-11-29 09:03:27 Sun sqlalchemy.engine.base.Engine INFO {'id': 'order_flow160661180784118', 'ab_ordernum': '20201129160661180782916', 'ab_price': None, 'ab_score': None, 'ab_score_deduct': None, 'ab_account_deduct': None, 'ab_payment': 100, 'ab_pay_mode': 6, 'ab_total_money': None, 'ab_type': 5, 'ab_proid': 'CURRICULUM_RES15916044963930', 'ab_pro_siid': None, 'ab_si_type': None, 'ab_si_name': None, 'ab_si_code': None, 'ab_si_pattern': None, 'ab_status': 'WAIT', 'ab_rights_status': None, 'createby': '193779307976941568', 'updatetime': None, 'updateby': None, 'deletetag': '0', 'unionid': None, 'transaction_serial_no': None}
2020-11-29 09:03:27 Sun sqlalchemy.engine.base.Engine INFO {'id': 'order_flow160661180784118', 'ab_ordernum': '20201129160661180782916', 'ab_price': None, 'ab_score': None, 'ab_score_deduct': None, 'ab_account_deduct': None, 'ab_payment': 100, 'ab_pay_mode': 6, 'ab_total_money': None, 'ab_type': 5, 'ab_proid': 'CURRICULUM_RES15916044963930', 'ab_pro_siid': None, 'ab_si_type': None, 'ab_si_name': None, 'ab_si_code': None, 'ab_si_pattern': None, 'ab_status': 'WAIT', 'ab_rights_status': None, 'createby': '193779307976941568', 'updatetime': None, 'updateby': None, 'deletetag': '0', 'unionid': None, 'transaction_serial_no': None}
2020-11-29 09:03:27 Sun sqlalchemy.engine.base.Engine INFO COMMIT
2020-11-29 09:03:27 Sun sqlalchemy.engine.base.Engine INFO COMMIT
2020-11-29 09:03:28 Sun werkzeug INFO 127.0.0.1 - - [29/Nov/2020 09:03:28] "[37mPOST /tamp_order/micro_shop/consumeOrder HTTP/1.1[0m" 200 -
2020-11-29 09:03:28 Sun werkzeug INFO 127.0.0.1 - - [29/Nov/2020 09:03:28] "[37mPOST /tamp_order/micro_shop/consumeOrder HTTP/1.1[0m" 200 -
2020-11-29 09:27:23 Sun werkzeug INFO * Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
2020-11-29 09:27:23 Sun werkzeug INFO * Restarting with stat
2020-11-29 09:27:25 Sun werkzeug WARNING * Debugger is active!
2020-11-29 09:27:25 Sun werkzeug INFO * Debugger PIN: 191-123-093
2020-11-29 09:37:01 Sun werkzeug INFO * Detected change in '/Users/pengxiong/Desktop/tamp_course_order/app/service/order_service.py', reloading
2020-11-29 09:37:02 Sun werkzeug INFO * Restarting with stat
2020-11-29 09:37:03 Sun werkzeug WARNING * Debugger is active!
2020-11-29 09:37:03 Sun werkzeug INFO * Debugger PIN: 191-123-093
2020-11-29 09:41:16 Sun werkzeug INFO * Detected change in '/Users/pengxiong/Desktop/tamp_course_order/app/service/order_service.py', reloading
2020-11-29 09:41:17 Sun werkzeug INFO * Restarting with stat
2020-11-29 09:41:18 Sun werkzeug WARNING * Debugger is active!
2020-11-29 09:41:18 Sun werkzeug INFO * Debugger PIN: 191-123-093
2020-11-29 09:41:40 Sun werkzeug INFO * Detected change in '/Users/pengxiong/Desktop/tamp_course_order/app/service/order_service.py', reloading
2020-11-29 09:41:40 Sun werkzeug INFO * Restarting with stat
2020-11-29 09:41:41 Sun werkzeug WARNING * Debugger is active!
2020-11-29 09:41:41 Sun werkzeug INFO * Debugger PIN: 191-123-093
2020-11-29 09:41:50 Sun werkzeug INFO * Detected change in '/Users/pengxiong/Desktop/tamp_course_order/app/service/order_service.py', reloading
2020-11-29 09:41:50 Sun werkzeug INFO * Restarting with stat
2020-11-29 09:41:52 Sun werkzeug WARNING * Debugger is active!
2020-11-29 09:41:52 Sun werkzeug INFO * Debugger PIN: 191-123-093
2020-11-29 09:42:11 Sun werkzeug INFO * Detected change in '/Users/pengxiong/Desktop/tamp_course_order/app/service/order_service.py', reloading
2020-11-29 09:42:11 Sun werkzeug INFO * Restarting with stat
2020-11-29 09:42:13 Sun werkzeug WARNING * Debugger is active!
2020-11-29 09:42:13 Sun werkzeug INFO * Debugger PIN: 191-123-093
2020-11-29 09:42:41 Sun werkzeug INFO * Detected change in '/Users/pengxiong/Desktop/tamp_course_order/app/service/order_service.py', reloading
2020-11-29 09:42:41 Sun werkzeug INFO * Restarting with stat
2020-11-29 09:42:42 Sun werkzeug WARNING * Debugger is active!
2020-11-29 09:42:42 Sun werkzeug INFO * Debugger PIN: 191-123-093
2020-11-29 09:43:43 Sun werkzeug INFO * Detected change in '/Users/pengxiong/Desktop/tamp_course_order/app/controller/order.py', reloading
2020-11-29 09:43:43 Sun werkzeug INFO * Restarting with stat
2020-11-29 09:43:45 Sun werkzeug WARNING * Debugger is active!
2020-11-29 09:43:45 Sun werkzeug INFO * Debugger PIN: 191-123-093
2020-11-29 09:45:26 Sun werkzeug INFO * Detected change in '/Users/pengxiong/Desktop/tamp_course_order/app/controller/order.py', reloading
2020-11-29 09:45:27 Sun werkzeug INFO * Restarting with stat
2020-11-29 09:45:28 Sun werkzeug WARNING * Debugger is active!
2020-11-29 09:45:28 Sun werkzeug INFO * Debugger PIN: 191-123-093
2020-11-29 09:45:58 Sun werkzeug INFO * Detected change in '/Users/pengxiong/Desktop/tamp_course_order/app/controller/order.py', reloading
2020-11-29 09:45:58 Sun werkzeug INFO * Restarting with stat
2020-11-29 09:45:59 Sun werkzeug WARNING * Debugger is active!
2020-11-29 09:45:59 Sun werkzeug INFO * Debugger PIN: 191-123-093
2020-11-29 09:46:10 Sun werkzeug INFO * Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
2020-11-29 09:46:10 Sun werkzeug INFO * Restarting with stat
2020-11-29 09:46:12 Sun werkzeug WARNING * Debugger is active!
2020-11-29 09:46:12 Sun werkzeug INFO * Debugger PIN: 191-123-093
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