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
231172c7
Commit
231172c7
authored
4 years ago
by
pengxiong@wealthgrow.cn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复
parent
5168613b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5813 additions
and
5 deletions
+5813
-5
errorhandler.py
app/controller/errorhandler.py
+4
-1
order.py
app/controller/order.py
+5
-1
order_service.py
app/service/order_service.py
+21
-3
tamp_course_order.log
logs/tamp_course_order.log
+5783
-0
No files found.
app/controller/errorhandler.py
View file @
231172c7
...
@@ -57,7 +57,10 @@ def add_errorhandler(app):
...
@@ -57,7 +57,10 @@ def add_errorhandler(app):
# token = 'eyJhbHQiOiJIUzI1NiIsImFsZyI6IkhTMjU2IiwidHlwIjoiSldUIn0.eyJwYXlsb2FkIjoidGFtcC8xOTM3NzkzMDc5NzY5NDE1NjgiLCJpc3MiOiJjYWl4aWFvcXVhbiIsImlhdCI6MTYwNjI5MDYzMH0.WnADEiWd27A8wr2DmOyX1kcs0dWLxpoO-k1yiF0qbBk'
# token = 'eyJhbHQiOiJIUzI1NiIsImFsZyI6IkhTMjU2IiwidHlwIjoiSldUIn0.eyJwYXlsb2FkIjoidGFtcC8xOTM3NzkzMDc5NzY5NDE1NjgiLCJpc3MiOiJjYWl4aWFvcXVhbiIsImlhdCI6MTYwNjI5MDYzMH0.WnADEiWd27A8wr2DmOyX1kcs0dWLxpoO-k1yiF0qbBk'
url
=
config
[
env
][
'token_auth_url'
]
url
=
config
[
env
][
'token_auth_url'
]
start
=
time
.
time
()
start
=
time
.
time
()
res
=
requests
.
get
(
url
,
{
'tampToken'
:
token
})
requests
.
adapters
.
DEFAULT_RETRIES
=
5
# 增加重连次数
s
=
requests
.
session
()
s
.
keep_alive
=
False
res
=
s
.
get
(
url
+
'?tampToken='
+
token
)
print
(
'token鉴权时间'
,
time
.
time
()
-
start
)
print
(
'token鉴权时间'
,
time
.
time
()
-
start
)
resp
=
res
.
json
()
resp
=
res
.
json
()
if
resp
[
'statusCode'
]
!=
"0000"
:
if
resp
[
'statusCode'
]
!=
"0000"
:
...
...
This diff is collapsed.
Click to expand it.
app/controller/order.py
View file @
231172c7
...
@@ -14,6 +14,7 @@ from app.api import app
...
@@ -14,6 +14,7 @@ from app.api import app
from
app.controller.errorhandler
import
CustomFlaskErr
from
app.controller.errorhandler
import
CustomFlaskErr
from
app.config.errors
import
Errors
from
app.config.errors
import
Errors
from
app.service
import
order_service
from
app.service
import
order_service
from
app.api.engine
import
logging
class
TopUpOrder
(
Resource
):
class
TopUpOrder
(
Resource
):
...
@@ -204,7 +205,10 @@ class AllOrders(Resource):
...
@@ -204,7 +205,10 @@ class AllOrders(Resource):
self
.
parser
.
add_argument
(
'pageSize'
,
type
=
int
,
required
=
True
)
self
.
parser
.
add_argument
(
'pageSize'
,
type
=
int
,
required
=
True
)
args
=
self
.
parser
.
parse_args
()
args
=
self
.
parser
.
parse_args
()
args
[
'user_id'
]
=
request
.
user_id
args
[
'user_id'
]
=
request
.
user_id
data
=
order_service
.
getAllOrders
(
args
)
try
:
data
=
order_service
.
getAllOrders
(
args
)
except
Exception
as
e
:
logging
.
error
(
e
)
resp
=
request
.
return_success
resp
=
request
.
return_success
resp
[
'attributes'
]
=
data
resp
[
'attributes'
]
=
data
return
resp
return
resp
...
...
This diff is collapsed.
Click to expand it.
app/service/order_service.py
View file @
231172c7
...
@@ -44,6 +44,8 @@ class TopUpOrderService:
...
@@ -44,6 +44,8 @@ class TopUpOrderService:
keys
=
set
(
r
.
keys
())
-
allowed
keys
=
set
(
r
.
keys
())
-
allowed
for
key
in
keys
:
for
key
in
keys
:
del
r
[
key
]
del
r
[
key
]
tamp_user_session
.
commit
()
tamp_user_session
.
close
()
return
{
return
{
'content'
:
res
,
'content'
:
res
,
'pageNum'
:
pageNumber
,
'pageNum'
:
pageNumber
,
...
@@ -104,7 +106,9 @@ class TopUpOrderService:
...
@@ -104,7 +106,9 @@ class TopUpOrderService:
order_info
=
OrderFlow
(
**
args
)
order_info
=
OrderFlow
(
**
args
)
tamp_user_session
.
add
(
order_info
)
tamp_user_session
.
add
(
order_info
)
tamp_user_session
.
commit
()
tamp_user_session
.
commit
()
tamp_user_session
.
close
()
tamp_pay_session
.
commit
()
tamp_pay_session
.
commit
()
tamp_pay_session
.
close
()
return
pay_params
return
pay_params
...
@@ -143,6 +147,8 @@ class CurriculumOrderService:
...
@@ -143,6 +147,8 @@ class CurriculumOrderService:
keys
=
set
(
r
.
keys
())
-
allowed
keys
=
set
(
r
.
keys
())
-
allowed
for
key
in
keys
:
for
key
in
keys
:
del
r
[
key
]
del
r
[
key
]
tamp_user_session
.
commit
()
tamp_user_session
.
close
()
return
{
return
{
'content'
:
temp_orders
,
'content'
:
temp_orders
,
'pageNum'
:
pageNumber
,
'pageNum'
:
pageNumber
,
...
@@ -209,7 +215,9 @@ class CurriculumOrderService:
...
@@ -209,7 +215,9 @@ class CurriculumOrderService:
order_info
=
OrderFlow
(
**
args
)
order_info
=
OrderFlow
(
**
args
)
tamp_user_session
.
add
(
order_info
)
tamp_user_session
.
add
(
order_info
)
tamp_pay_session
.
commit
()
tamp_pay_session
.
commit
()
tamp_pay_session
.
close
()
tamp_user_session
.
commit
()
tamp_user_session
.
commit
()
tamp_user_session
.
close
()
return
pay_params
return
pay_params
...
@@ -234,7 +242,9 @@ def topUpSuccessAction(order_no):
...
@@ -234,7 +242,9 @@ def topUpSuccessAction(order_no):
'apple_balance'
:
AccountBalance
.
android_balance
+
account_topup_order
.
amount
'apple_balance'
:
AccountBalance
.
android_balance
+
account_topup_order
.
amount
})
})
tamp_user_session
.
commit
()
tamp_user_session
.
commit
()
tamp_user_session
.
close
()
tamp_pay_session
.
commit
()
tamp_pay_session
.
commit
()
tamp_pay_session
.
close
()
...
@@ -250,11 +260,14 @@ def consumeSucessAction(order_no):
...
@@ -250,11 +260,14 @@ def consumeSucessAction(order_no):
'complete_time'
:
datetime
.
datetime
.
now
()
'complete_time'
:
datetime
.
datetime
.
now
()
})
})
tamp_user_session
.
commit
()
tamp_user_session
.
commit
()
tamp_user_session
.
close
()
def
getAccountBalance
(
user_id
):
def
getAccountBalance
(
user_id
):
"""查询探普币余额"""
"""查询探普币余额"""
account_balance
=
tamp_pay_session
.
query
(
AccountBalance
)
.
filter
(
AccountBalance
.
user_id
==
user_id
)
.
first
()
account_balance
=
tamp_pay_session
.
query
(
AccountBalance
)
.
filter
(
AccountBalance
.
user_id
==
user_id
)
.
first
()
tamp_pay_session
.
commit
()
tamp_pay_session
.
close
()
if
not
account_balance
:
if
not
account_balance
:
return
{
'user_id'
:
user_id
,
'android_balance'
:
0
,
'apple_balance'
:
0
}
return
{
'user_id'
:
user_id
,
'android_balance'
:
0
,
'apple_balance'
:
0
}
else
:
else
:
...
@@ -310,13 +323,14 @@ def getAllOrders(args):
...
@@ -310,13 +323,14 @@ def getAllOrders(args):
pageSize
=
args
[
'pageSize'
]
pageSize
=
args
[
'pageSize'
]
user_id
=
args
[
'user_id'
]
user_id
=
args
[
'user_id'
]
offset
=
(
pageNumber
-
1
)
*
pageSize
offset
=
(
pageNumber
-
1
)
*
pageSize
totalSize
=
len
(
tamp_user_session
.
query
(
OrderFlow
.
id
)
.
filter
(
if
not
user_id
:
and_
(
OrderFlow
.
createby
==
user_id
,
OrderFlow
.
ab_type
==
'6'
,
OrderFlow
.
ab_status
==
'SUCCESS'
))
.
all
())
raise
CustomFlaskErr
(
Errors
.
TOKEN_INVALID
)
totalSize
=
len
(
tamp_user_session
.
query
(
OrderFlow
.
id
)
.
filter
(
and_
(
OrderFlow
.
createby
==
user_id
,
OrderFlow
.
ab_type
==
'6'
,
OrderFlow
.
ab_status
==
'SUCCESS'
))
.
all
())
res
=
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
OrderFlow
.
createby
==
user_id
)
.
order_by
(
res
=
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
OrderFlow
.
createby
==
user_id
)
.
order_by
(
OrderFlow
.
createtime
.
desc
())
.
all
()
OrderFlow
.
createtime
.
desc
())
.
all
()
topup_res
=
[
r
.
to_dict
()
for
r
in
res
]
topup_res
=
[
r
.
to_dict
()
for
r
in
res
]
allowed
=
{
'id'
,
'ab_ordernum'
,
'transaction_serial_no'
,
'ab_payment'
,
'ab_pay_mode'
,
'createtime'
,
'pay_time'
,
allowed
=
{
'id'
,
'ab_ordernum'
,
'transaction_serial_no'
,
'ab_payment'
,
'ab_pay_mode'
,
'createtime'
,
'pay_time'
,
'complete_time'
,
'order_status'
}
'complete_time'
,
'order_status'
,
'ab_type'
}
for
r
in
topup_res
:
for
r
in
topup_res
:
keys
=
set
(
r
.
keys
())
-
allowed
keys
=
set
(
r
.
keys
())
-
allowed
for
key
in
keys
:
for
key
in
keys
:
...
@@ -351,6 +365,10 @@ def getAllOrders(args):
...
@@ -351,6 +365,10 @@ def getAllOrders(args):
del
r
[
key
]
del
r
[
key
]
orders
=
[
*
topup_res
,
*
temp_orders
]
orders
=
[
*
topup_res
,
*
temp_orders
]
totalSize
=
len
(
orders
)
totalSize
=
len
(
orders
)
tamp_user_session
.
commit
()
tamp_user_session
.
close
()
tamp_pay_session
.
commit
()
tamp_pay_session
.
close
()
return
{
return
{
'content'
:
orders
[
offset
:
offset
+
pageSize
],
'content'
:
orders
[
offset
:
offset
+
pageSize
],
'pageNum'
:
pageNumber
,
'pageNum'
:
pageNumber
,
...
...
This diff is collapsed.
Click to expand it.
logs/tamp_course_order.log
View file @
231172c7
This source diff could not be displayed because it is too large. You can
view the blob
instead.
This diff is collapsed.
Click to expand it.
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