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
0965e2ba
Commit
0965e2ba
authored
Nov 27, 2020
by
pengxiong@wealthgrow.cn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug修复
parent
231172c7
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
6683 additions
and
122 deletions
+6683
-122
engine.py
app/api/engine.py
+33
-0
errors.py
app/config/errors.py
+3
-1
order.py
app/controller/order.py
+4
-3
order_service.py
app/service/order_service.py
+121
-118
tamp_course_order.log
logs/tamp_course_order.log
+6522
-0
No files found.
app/api/engine.py
View file @
0965e2ba
...
...
@@ -22,6 +22,39 @@ CFG_FILEPATH = work_dir + '/app/config/config.yaml'
config
=
yaml
.
load
(
open
(
CFG_FILEPATH
,
'r'
),
Loader
=
yaml
.
FullLoader
)
class
TAMP_SQL
(
object
):
"""[sqlalchemy 封装]
Args:
object ([type]): [description]
Returns:
[type]: [description]
"""
def
__init__
(
self
,
db_engine
):
# db = "mysql+mysqlconnector://root:password@localhost:3306/test"
# engine = create_engine(db)
# 创建DBSession类型:
self
.
DBSession
=
scoped_session
(
sessionmaker
(
bind
=
db_engine
))
def
__enter__
(
self
):
self
.
session
=
self
.
DBSession
()
return
self
.
session
def
__exit__
(
self
,
ext_type
,
exc_val
,
exc_tb
):
print
(
ext_type
)
self
.
session
.
commit
()
self
.
session
.
close
()
def
add
(
self
,
model
):
# model = User(id='5', name='Bob')
# 添加到session:
self
.
session
.
add
(
model
)
# 提交即保存到数据库:
self
.
session
.
commit
()
tamp_user_engine
=
create_engine
(
'mysql+pymysql://{user}:{password}@{host}:{port}/{db}?charset={charset}'
.
format
(
db
=
config
[
env
][
'MySQL'
][
'tamp_user_db'
],
...
...
app/config/errors.py
View file @
0965e2ba
...
...
@@ -17,6 +17,7 @@ class Errors:
APPLE_VOCHER_USED
=
'9005'
INPUT_PARAMS_ERROR
=
'9006'
REPEAT_BUY
=
'9007'
PROD_NOPRICE
=
'9008'
MSG
=
{
TOKEN_INVALID
:
'TOKEN失效'
,
...
...
@@ -25,5 +26,6 @@ class Errors:
TANGPU_BALANCE_NOT_ENOUGH
:
'探普币余额不足'
,
APPLE_VOCHER_USED
:
'该支付凭证已使用'
,
INPUT_PARAMS_ERROR
:
'入参错误'
,
REPEAT_BUY
:
'请勿重复购买商品'
REPEAT_BUY
:
'请勿重复购买商品'
,
PROD_NOPRICE
:
'商品未定价'
}
app/controller/order.py
View file @
0965e2ba
...
...
@@ -9,12 +9,13 @@
import
json
from
flask_restful
import
Resource
,
reqparse
from
flask
import
request
,
make_response
from
sqlalchemy.exc
import
InvalidRequestError
from
app.api
import
app
from
app.controller.errorhandler
import
CustomFlaskErr
from
app.config.errors
import
Errors
from
app.service
import
order_service
from
app.api.engine
import
logging
from
app.api.engine
import
logging
,
tamp_user_session
class
TopUpOrder
(
Resource
):
...
...
@@ -207,8 +208,8 @@ class AllOrders(Resource):
args
[
'user_id'
]
=
request
.
user_id
try
:
data
=
order_service
.
getAllOrders
(
args
)
except
Exception
as
e
:
logging
.
error
(
e
)
except
InvalidRequestError
:
tamp_user_session
.
rollback
(
)
resp
=
request
.
return_success
resp
[
'attributes'
]
=
data
return
resp
...
...
app/service/order_service.py
View file @
0965e2ba
...
...
@@ -9,9 +9,10 @@
import
datetime
import
time
from
sqlalchemy.sql.elements
import
and_
from
sqlalchemy
import
and_
from
sqlalchemy.testing
import
in_
from
app.api.engine
import
tamp_pay_session
,
tamp_user_session
from
app.api.engine
import
tamp_pay_session
,
tamp_user_session
,
TAMP_SQL
,
tamp_pay_engine
,
tamp_user_engine
from
app.config.errors
import
Errors
from
app.controller.errorhandler
import
CustomFlaskErr
from
app.model.account_balance
import
AccountBalance
...
...
@@ -36,10 +37,10 @@ class TopUpOrderService:
user_id
=
args
[
'user_id'
]
offset
=
(
pageNumber
-
1
)
*
pageSize
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
(
and_
(
OrderFlow
.
createby
==
user_id
,
OrderFlow
.
ab_type
==
'6'
,
OrderFlow
.
ab_status
==
'SUCCESS'
)
)
.
order_by
(
OrderFlow
.
createtime
.
desc
())
.
offset
(
offset
)
.
limit
(
pageSize
)
.
all
()
res
=
[
r
.
to_dict
()
for
r
in
res
]
allowed
=
{
'id'
,
'ab_ordernum'
,
'transaction_serial_no'
,
'ab_payment'
,
'ab_pay_mode'
,
'createtime'
,
'pay_time'
,
'complete_time'
,
'
order_status
'
}
allowed
=
{
'id'
,
'ab_ordernum'
,
'transaction_serial_no'
,
'ab_payment'
,
'ab_pay_mode'
,
'createtime'
,
'pay_time'
,
'complete_time'
,
'
ab_type
'
}
for
r
in
res
:
keys
=
set
(
r
.
keys
())
-
allowed
for
key
in
keys
:
...
...
@@ -125,7 +126,9 @@ class CurriculumOrderService:
offset
=
(
pageNumber
-
1
)
*
pageSize
curriculum_column
=
tamp_user_session
.
query
(
CurriculumColumn
.
id
,
CurriculumColumn
.
title
,
CurriculumColumn
.
cover
,
CurriculumColumn
.
info
)
.
all
()
curriculum_res
=
tamp_user_session
.
query
(
CurriculumRes
.
id
,
CurriculumRes
.
title
,
CurriculumRes
.
cover
,
CurriculumRes
.
teacher_name
)
.
all
()
res
=
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
OrderFlow
.
createby
==
user_id
)
.
order_by
(
OrderFlow
.
createtime
.
desc
())
.
all
()
res
=
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
and_
(
OrderFlow
.
createby
==
user_id
,
OrderFlow
.
ab_type
.
in_
([
'1'
,
'2'
,
'3'
,
'4'
,
'5'
])))
.
order_by
(
OrderFlow
.
createtime
.
desc
())
.
all
()
curriculum_column
=
{
r
[
0
]:
{
'title'
:
r
[
1
],
'cover'
:
r
[
2
],
'info'
:
r
[
3
]}
for
r
in
curriculum_column
}
curriculum_res
=
{
r
[
0
]:
{
'title'
:
r
[
1
],
'cover'
:
r
[
2
],
'info'
:
r
[
3
]}
for
r
in
curriculum_res
}
orders
=
[
r
.
to_dict
()
for
r
in
res
if
r
.
to_dict
()[
'ab_status'
]
==
'SUCCESS'
]
...
...
@@ -147,8 +150,6 @@ class CurriculumOrderService:
keys
=
set
(
r
.
keys
())
-
allowed
for
key
in
keys
:
del
r
[
key
]
tamp_user_session
.
commit
()
tamp_user_session
.
close
()
return
{
'content'
:
temp_orders
,
'pageNum'
:
pageNumber
,
...
...
@@ -159,66 +160,69 @@ class CurriculumOrderService:
def
create_order
(
self
,
args
):
"""。"""
args
[
'ab_ordernum'
]
=
time
.
strftime
(
'
%
Y
%
m
%
d'
,
time
.
localtime
(
time
.
time
()))
+
str
(
int
(
time
.
time
()
*
100000
))
amount
=
tamp_user_session
.
query
(
CurriculumPrice
.
price
)
.
filter
(
CurriculumPrice
.
rel_id
==
args
[
'ab_proid'
])
.
first
()[
0
]
args
[
'id'
]
=
OrderFlow
.
__tablename__
+
str
(
int
(
time
.
time
()
*
100000
))
args
[
'ab_payment'
]
=
amount
args
[
'ab_status'
]
=
'WAIT'
subject
=
args
.
get
(
'prod_name'
,
''
)
out_trade_no
=
args
[
'ab_ordernum'
]
notify_path
=
'/tamp_order/micro_shop/topUpOrderNotify'
pay_params
=
None
# 该用户是否重复购买同一商品
repeat_buy
=
tamp_user_session
.
query
(
OrderFlow
.
id
)
.
filter
(
and_
(
OrderFlow
.
createby
==
args
[
'user_id'
]),
OrderFlow
.
ab_proid
==
args
[
'ab_proid'
],
OrderFlow
.
ab_status
==
'SUCCESS'
)
.
all
()
if
repeat_buy
:
raise
CustomFlaskErr
(
Errors
.
REPEAT_BUY
)
if
args
[
'ab_pay_mode'
]
==
4
:
# 探普币支付
if
args
[
'env'
]
==
'ios'
:
res
=
tamp_pay_session
.
query
(
AccountBalance
.
apple_balance
)
.
filter
(
AccountBalance
.
user_id
==
args
[
'user_id'
])
.
first
()
if
not
res
:
raise
CustomFlaskErr
(
Errors
.
TANGPU_BALANCE_NOT_ENOUGH
)
elif
res
[
0
]
<
args
[
'ab_payment'
]:
raise
CustomFlaskErr
(
Errors
.
TANGPU_BALANCE_NOT_ENOUGH
)
else
:
tamp_pay_session
.
query
(
AccountBalance
.
apple_balance
)
.
filter
(
AccountBalance
.
user_id
==
args
[
'user_id'
])
.
update
({
'apple_balance'
:
AccountBalance
.
apple_balance
-
args
[
'ab_payment'
]
})
args
[
'ab_status'
]
=
'SUCCESS'
elif
args
[
'env'
]
==
'android'
:
res
=
tamp_pay_session
.
query
(
AccountBalance
.
android_balance
)
.
filter
(
AccountBalance
.
user_id
==
args
[
'user_id'
])
.
first
()
if
not
res
:
raise
CustomFlaskErr
(
Errors
.
TANGPU_BALANCE_NOT_ENOUGH
)
elif
res
[
0
]
<
args
[
'ab_payment'
]:
raise
CustomFlaskErr
(
Errors
.
TANGPU_BALANCE_NOT_ENOUGH
)
else
:
tamp_pay_session
.
query
(
AccountBalance
.
android_balance
)
.
filter
(
AccountBalance
.
user_id
==
args
[
'user_id'
])
.
update
({
'android_balance'
:
AccountBalance
.
android_balance
-
args
[
'ab_payment'
]
})
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
)
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
)
pay_params
=
res
args
[
'createby'
]
=
args
.
pop
(
'user_id'
,
''
)
args
.
pop
(
'prod_name'
,
''
)
args
.
pop
(
'env'
,
''
)
args
.
pop
(
'remote_addr'
,
''
)
order_info
=
OrderFlow
(
**
args
)
tamp_user_session
.
add
(
order_info
)
tamp_pay_session
.
commit
()
tamp_pay_session
.
close
()
tamp_user_session
.
commit
()
tamp_user_session
.
close
()
return
pay_params
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user_session
,
TAMP_SQL
(
tamp_pay_engine
)
as
tamp_pay_session
:
args
[
'ab_ordernum'
]
=
time
.
strftime
(
'
%
Y
%
m
%
d'
,
time
.
localtime
(
time
.
time
()))
+
str
(
int
(
time
.
time
()
*
100000
))
amount
=
tamp_user_session
.
query
(
CurriculumPrice
.
price
)
.
filter
(
CurriculumPrice
.
rel_id
==
args
[
'ab_proid'
])
.
first
()[
0
]
if
not
amount
:
raise
CustomFlaskErr
(
Errors
.
PROD_NOPRICE
)
args
[
'id'
]
=
OrderFlow
.
__tablename__
+
str
(
int
(
time
.
time
()
*
100000
))
args
[
'ab_payment'
]
=
amount
args
[
'ab_status'
]
=
'WAIT'
subject
=
args
.
get
(
'prod_name'
,
''
)
out_trade_no
=
args
[
'ab_ordernum'
]
notify_path
=
'/tamp_order/micro_shop/topUpOrderNotify'
pay_params
=
None
# 该用户是否重复购买同一商品
repeat_buy
=
tamp_user_session
.
query
(
OrderFlow
.
id
)
.
filter
(
and_
(
OrderFlow
.
createby
==
args
[
'user_id'
]),
OrderFlow
.
ab_proid
==
args
[
'ab_proid'
],
OrderFlow
.
ab_status
==
'SUCCESS'
)
.
all
()
if
repeat_buy
:
raise
CustomFlaskErr
(
Errors
.
REPEAT_BUY
)
if
args
[
'ab_pay_mode'
]
==
4
:
# 探普币支付
if
args
[
'env'
]
==
'ios'
:
res
=
tamp_pay_session
.
query
(
AccountBalance
.
apple_balance
)
.
filter
(
AccountBalance
.
user_id
==
args
[
'user_id'
])
.
first
()
if
not
res
:
raise
CustomFlaskErr
(
Errors
.
TANGPU_BALANCE_NOT_ENOUGH
)
elif
res
[
0
]
<
args
[
'ab_payment'
]:
raise
CustomFlaskErr
(
Errors
.
TANGPU_BALANCE_NOT_ENOUGH
)
else
:
tamp_pay_session
.
query
(
AccountBalance
.
apple_balance
)
.
filter
(
AccountBalance
.
user_id
==
args
[
'user_id'
])
.
update
({
'apple_balance'
:
AccountBalance
.
apple_balance
-
args
[
'ab_payment'
]
})
args
[
'ab_status'
]
=
'SUCCESS'
elif
args
[
'env'
]
==
'android'
:
res
=
tamp_pay_session
.
query
(
AccountBalance
.
android_balance
)
.
filter
(
AccountBalance
.
user_id
==
args
[
'user_id'
])
.
first
()
if
not
res
:
raise
CustomFlaskErr
(
Errors
.
TANGPU_BALANCE_NOT_ENOUGH
)
elif
res
[
0
]
<
args
[
'ab_payment'
]:
raise
CustomFlaskErr
(
Errors
.
TANGPU_BALANCE_NOT_ENOUGH
)
else
:
tamp_pay_session
.
query
(
AccountBalance
.
android_balance
)
.
filter
(
AccountBalance
.
user_id
==
args
[
'user_id'
])
.
update
({
'android_balance'
:
AccountBalance
.
android_balance
-
args
[
'ab_payment'
]
})
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
)
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
)
pay_params
=
res
args
[
'createby'
]
=
args
.
pop
(
'user_id'
,
''
)
args
.
pop
(
'prod_name'
,
''
)
args
.
pop
(
'env'
,
''
)
args
.
pop
(
'remote_addr'
,
''
)
order_info
=
OrderFlow
(
**
args
)
tamp_user_session
.
add
(
order_info
)
return
pay_params
def
topUpSuccessAction
(
order_no
):
...
...
@@ -266,8 +270,6 @@ def consumeSucessAction(order_no):
def
getAccountBalance
(
user_id
):
"""查询探普币余额"""
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
:
return
{
'user_id'
:
user_id
,
'android_balance'
:
0
,
'apple_balance'
:
0
}
else
:
...
...
@@ -325,53 +327,54 @@ def getAllOrders(args):
offset
=
(
pageNumber
-
1
)
*
pageSize
if
not
user_id
:
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
(
OrderFlow
.
createtime
.
desc
())
.
all
()
topup_res
=
[
r
.
to_dict
()
for
r
in
res
]
allowed
=
{
'id'
,
'ab_ordernum'
,
'transaction_serial_no'
,
'ab_payment'
,
'ab_pay_mode'
,
'createtime'
,
'pay_time'
,
'complete_time'
,
'order_status'
,
'ab_type'
}
for
r
in
topup_res
:
keys
=
set
(
r
.
keys
())
-
allowed
for
key
in
keys
:
del
r
[
key
]
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user_session
:
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
(
and_
(
OrderFlow
.
createby
==
user_id
,
OrderFlow
.
ab_type
==
'6'
,
OrderFlow
.
ab_status
==
'SUCCESS'
))
.
order_by
(
OrderFlow
.
createtime
.
desc
())
.
offset
(
offset
)
.
limit
(
pageSize
)
.
all
()
topup_res
=
[
r
.
to_dict
()
for
r
in
res
]
allowed
=
{
'id'
,
'ab_ordernum'
,
'transaction_serial_no'
,
'ab_payment'
,
'ab_pay_mode'
,
'createtime'
,
'pay_time'
,
'complete_time'
,
'order_status'
,
'ab_type'
}
for
r
in
topup_res
:
keys
=
set
(
r
.
keys
())
-
allowed
for
key
in
keys
:
del
r
[
key
]
curriculum_column
=
tamp_user_session
.
query
(
CurriculumColumn
.
id
,
CurriculumColumn
.
title
,
CurriculumColumn
.
cover
,
CurriculumColumn
.
info
)
.
all
()
curriculum_res
=
tamp_user_session
.
query
(
CurriculumRes
.
id
,
CurriculumRes
.
title
,
CurriculumRes
.
cover
,
CurriculumRes
.
teacher_name
)
.
all
()
res
=
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
OrderFlow
.
createby
==
user_id
)
.
order_by
(
OrderFlow
.
createtime
.
desc
())
.
all
()
curriculum_column
=
{
r
[
0
]:
{
'title'
:
r
[
1
],
'cover'
:
r
[
2
],
'info'
:
r
[
3
]}
for
r
in
curriculum_column
}
curriculum_res
=
{
r
[
0
]:
{
'title'
:
r
[
1
],
'cover'
:
r
[
2
],
'info'
:
r
[
3
]}
for
r
in
curriculum_res
}
orders
=
[
r
.
to_dict
()
for
r
in
res
if
r
.
to_dict
()[
'ab_status'
]
==
'SUCCESS'
]
temp_orders
=
[]
for
order
in
orders
:
prod_type
=
order
.
get
(
'ab_type'
,
''
)
prod_id
=
order
.
get
(
'ab_proid'
,
''
)
if
prod_type
==
'1'
:
order
=
{
**
order
,
**
curriculum_column
.
get
(
prod_id
,
None
)}
temp_orders
.
append
(
order
)
elif
prod_type
in
[
'3'
,
'4'
,
'5'
]:
order
=
{
**
order
,
**
curriculum_res
.
get
(
prod_id
,
None
)}
temp_orders
.
append
(
order
)
temp_orders
=
temp_orders
[
offset
:
offset
+
pageSize
]
allowed
=
{
'id'
,
'title'
,
'cover'
,
'info'
,
'ab_type'
,
'ab_payment'
,
'ab_pay_mode'
,
'ab_ordernum'
,
'transaction_serial_no'
,
'pay_method'
,
'createtime'
,
'pay_time'
,
'complete_time'
,
'ab_status'
}
for
r
in
temp_orders
:
keys
=
set
(
r
.
keys
())
-
allowed
for
key
in
keys
:
del
r
[
key
]
orders
=
[
*
topup_res
,
*
temp_orders
]
totalSize
=
len
(
orders
)
tamp_user_session
.
commit
()
tamp_user_session
.
close
()
tamp_pay_session
.
commit
()
tamp_pay_session
.
close
()
return
{
'content'
:
orders
[
offset
:
offset
+
pageSize
],
'pageNum'
:
pageNumber
,
'pageSize'
:
pageSize
,
'totalSize'
:
totalSize
}
curriculum_column
=
tamp_user_session
.
query
(
CurriculumColumn
.
id
,
CurriculumColumn
.
title
,
CurriculumColumn
.
cover
,
CurriculumColumn
.
info
)
.
all
()
curriculum_res
=
tamp_user_session
.
query
(
CurriculumRes
.
id
,
CurriculumRes
.
title
,
CurriculumRes
.
cover
,
CurriculumRes
.
teacher_name
)
.
all
()
res
=
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
and_
(
OrderFlow
.
createby
==
user_id
,
OrderFlow
.
ab_type
.
in_
([
'1'
,
'2'
,
'3'
,
'4'
,
'5'
])))
.
order_by
(
OrderFlow
.
createtime
.
desc
())
.
all
()
curriculum_column
=
{
r
[
0
]:
{
'title'
:
r
[
1
],
'cover'
:
r
[
2
],
'info'
:
r
[
3
]}
for
r
in
curriculum_column
}
curriculum_res
=
{
r
[
0
]:
{
'title'
:
r
[
1
],
'cover'
:
r
[
2
],
'info'
:
r
[
3
]}
for
r
in
curriculum_res
}
orders
=
[
r
.
to_dict
()
for
r
in
res
if
r
.
to_dict
()[
'ab_status'
]
==
'SUCCESS'
]
temp_orders
=
[]
for
order
in
orders
:
prod_type
=
order
.
get
(
'ab_type'
,
''
)
prod_id
=
order
.
get
(
'ab_proid'
,
''
)
if
prod_type
==
'1'
:
order
=
{
**
order
,
**
curriculum_column
.
get
(
prod_id
,
None
)}
temp_orders
.
append
(
order
)
elif
prod_type
in
[
'3'
,
'4'
,
'5'
]:
order
=
{
**
order
,
**
curriculum_res
.
get
(
prod_id
,
None
)}
temp_orders
.
append
(
order
)
temp_orders
=
temp_orders
[
offset
:
offset
+
pageSize
]
allowed
=
{
'id'
,
'title'
,
'cover'
,
'info'
,
'ab_type'
,
'ab_payment'
,
'ab_pay_mode'
,
'ab_ordernum'
,
'transaction_serial_no'
,
'pay_method'
,
'createtime'
,
'pay_time'
,
'complete_time'
,
'ab_status'
}
for
r
in
temp_orders
:
keys
=
set
(
r
.
keys
())
-
allowed
for
key
in
keys
:
del
r
[
key
]
orders
=
[
*
topup_res
,
*
temp_orders
]
totalSize
=
len
(
orders
)
# tamp_user_session.commit()
# tamp_user_session.close()
return
{
'content'
:
orders
[
offset
:
offset
+
pageSize
],
'pageNum'
:
pageNumber
,
'pageSize'
:
pageSize
,
'totalSize'
:
totalSize
}
logs/tamp_course_order.log
View file @
0965e2ba
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