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'
...
@@ -22,6 +22,39 @@ CFG_FILEPATH = work_dir + '/app/config/config.yaml'
config
=
yaml
.
load
(
open
(
CFG_FILEPATH
,
'r'
),
Loader
=
yaml
.
FullLoader
)
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
(
tamp_user_engine
=
create_engine
(
'mysql+pymysql://{user}:{password}@{host}:{port}/{db}?charset={charset}'
.
format
(
'mysql+pymysql://{user}:{password}@{host}:{port}/{db}?charset={charset}'
.
format
(
db
=
config
[
env
][
'MySQL'
][
'tamp_user_db'
],
db
=
config
[
env
][
'MySQL'
][
'tamp_user_db'
],
...
...
app/config/errors.py
View file @
0965e2ba
...
@@ -17,6 +17,7 @@ class Errors:
...
@@ -17,6 +17,7 @@ class Errors:
APPLE_VOCHER_USED
=
'9005'
APPLE_VOCHER_USED
=
'9005'
INPUT_PARAMS_ERROR
=
'9006'
INPUT_PARAMS_ERROR
=
'9006'
REPEAT_BUY
=
'9007'
REPEAT_BUY
=
'9007'
PROD_NOPRICE
=
'9008'
MSG
=
{
MSG
=
{
TOKEN_INVALID
:
'TOKEN失效'
,
TOKEN_INVALID
:
'TOKEN失效'
,
...
@@ -25,5 +26,6 @@ class Errors:
...
@@ -25,5 +26,6 @@ class Errors:
TANGPU_BALANCE_NOT_ENOUGH
:
'探普币余额不足'
,
TANGPU_BALANCE_NOT_ENOUGH
:
'探普币余额不足'
,
APPLE_VOCHER_USED
:
'该支付凭证已使用'
,
APPLE_VOCHER_USED
:
'该支付凭证已使用'
,
INPUT_PARAMS_ERROR
:
'入参错误'
,
INPUT_PARAMS_ERROR
:
'入参错误'
,
REPEAT_BUY
:
'请勿重复购买商品'
REPEAT_BUY
:
'请勿重复购买商品'
,
PROD_NOPRICE
:
'商品未定价'
}
}
app/controller/order.py
View file @
0965e2ba
...
@@ -9,12 +9,13 @@
...
@@ -9,12 +9,13 @@
import
json
import
json
from
flask_restful
import
Resource
,
reqparse
from
flask_restful
import
Resource
,
reqparse
from
flask
import
request
,
make_response
from
flask
import
request
,
make_response
from
sqlalchemy.exc
import
InvalidRequestError
from
app.api
import
app
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
from
app.api.engine
import
logging
,
tamp_user_session
class
TopUpOrder
(
Resource
):
class
TopUpOrder
(
Resource
):
...
@@ -207,8 +208,8 @@ class AllOrders(Resource):
...
@@ -207,8 +208,8 @@ class AllOrders(Resource):
args
[
'user_id'
]
=
request
.
user_id
args
[
'user_id'
]
=
request
.
user_id
try
:
try
:
data
=
order_service
.
getAllOrders
(
args
)
data
=
order_service
.
getAllOrders
(
args
)
except
Exception
as
e
:
except
InvalidRequestError
:
logging
.
error
(
e
)
tamp_user_session
.
rollback
(
)
resp
=
request
.
return_success
resp
=
request
.
return_success
resp
[
'attributes'
]
=
data
resp
[
'attributes'
]
=
data
return
resp
return
resp
...
...
app/service/order_service.py
View file @
0965e2ba
...
@@ -9,9 +9,10 @@
...
@@ -9,9 +9,10 @@
import
datetime
import
datetime
import
time
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.config.errors
import
Errors
from
app.controller.errorhandler
import
CustomFlaskErr
from
app.controller.errorhandler
import
CustomFlaskErr
from
app.model.account_balance
import
AccountBalance
from
app.model.account_balance
import
AccountBalance
...
@@ -36,10 +37,10 @@ class TopUpOrderService:
...
@@ -36,10 +37,10 @@ class TopUpOrderService:
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
(
and_
(
OrderFlow
.
createby
==
user_id
,
OrderFlow
.
ab_type
==
'6'
,
OrderFlow
.
ab_status
==
'SUCCESS'
))
.
all
())
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
()
OrderFlow
.
createtime
.
desc
())
.
offset
(
offset
)
.
limit
(
pageSize
)
.
all
()
res
=
[
r
.
to_dict
()
for
r
in
res
]
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
:
for
r
in
res
:
keys
=
set
(
r
.
keys
())
-
allowed
keys
=
set
(
r
.
keys
())
-
allowed
for
key
in
keys
:
for
key
in
keys
:
...
@@ -125,7 +126,9 @@ class CurriculumOrderService:
...
@@ -125,7 +126,9 @@ class CurriculumOrderService:
offset
=
(
pageNumber
-
1
)
*
pageSize
offset
=
(
pageNumber
-
1
)
*
pageSize
curriculum_column
=
tamp_user_session
.
query
(
CurriculumColumn
.
id
,
CurriculumColumn
.
title
,
CurriculumColumn
.
cover
,
CurriculumColumn
.
info
)
.
all
()
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
()
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_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
}
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'
]
orders
=
[
r
.
to_dict
()
for
r
in
res
if
r
.
to_dict
()[
'ab_status'
]
==
'SUCCESS'
]
...
@@ -147,8 +150,6 @@ class CurriculumOrderService:
...
@@ -147,8 +150,6 @@ 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
,
...
@@ -159,66 +160,69 @@ class CurriculumOrderService:
...
@@ -159,66 +160,69 @@ class CurriculumOrderService:
def
create_order
(
self
,
args
):
def
create_order
(
self
,
args
):
"""。"""
"""。"""
args
[
'ab_ordernum'
]
=
time
.
strftime
(
'
%
Y
%
m
%
d'
,
time
.
localtime
(
time
.
time
()))
+
str
(
int
(
time
.
time
()
*
100000
))
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user_session
,
TAMP_SQL
(
tamp_pay_engine
)
as
tamp_pay_session
:
amount
=
tamp_user_session
.
query
(
CurriculumPrice
.
price
)
.
filter
(
CurriculumPrice
.
rel_id
==
args
[
'ab_proid'
])
.
first
()[
0
]
args
[
'ab_ordernum'
]
=
time
.
strftime
(
'
%
Y
%
m
%
d'
,
time
.
localtime
(
time
.
time
()))
+
str
(
int
(
time
.
time
()
*
100000
))
args
[
'id'
]
=
OrderFlow
.
__tablename__
+
str
(
int
(
time
.
time
()
*
100000
))
amount
=
tamp_user_session
.
query
(
CurriculumPrice
.
price
)
.
filter
(
CurriculumPrice
.
rel_id
==
args
[
'ab_proid'
])
.
first
()[
0
]
args
[
'ab_payment'
]
=
amount
if
not
amount
:
args
[
'ab_status'
]
=
'WAIT'
raise
CustomFlaskErr
(
Errors
.
PROD_NOPRICE
)
subject
=
args
.
get
(
'prod_name'
,
''
)
args
[
'id'
]
=
OrderFlow
.
__tablename__
+
str
(
int
(
time
.
time
()
*
100000
))
out_trade_no
=
args
[
'ab_ordernum'
]
args
[
'ab_payment'
]
=
amount
notify_path
=
'/tamp_order/micro_shop/topUpOrderNotify'
args
[
'ab_status'
]
=
'WAIT'
pay_params
=
None
subject
=
args
.
get
(
'prod_name'
,
''
)
# 该用户是否重复购买同一商品
out_trade_no
=
args
[
'ab_ordernum'
]
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
()
notify_path
=
'/tamp_order/micro_shop/topUpOrderNotify'
if
repeat_buy
:
pay_params
=
None
raise
CustomFlaskErr
(
Errors
.
REPEAT_BUY
)
# 该用户是否重复购买同一商品
if
args
[
'ab_pay_mode'
]
==
4
:
repeat_buy
=
tamp_user_session
.
query
(
OrderFlow
.
id
)
.
filter
(
and_
(
OrderFlow
.
createby
==
args
[
'user_id'
]),
# 探普币支付
OrderFlow
.
ab_proid
==
args
[
'ab_proid'
],
if
args
[
'env'
]
==
'ios'
:
OrderFlow
.
ab_status
==
'SUCCESS'
)
.
all
()
res
=
tamp_pay_session
.
query
(
AccountBalance
.
apple_balance
)
.
filter
(
AccountBalance
.
user_id
==
args
[
'user_id'
])
.
first
()
if
repeat_buy
:
if
not
res
:
raise
CustomFlaskErr
(
Errors
.
REPEAT_BUY
)
raise
CustomFlaskErr
(
Errors
.
TANGPU_BALANCE_NOT_ENOUGH
)
if
args
[
'ab_pay_mode'
]
==
4
:
elif
res
[
0
]
<
args
[
'ab_payment'
]:
# 探普币支付
raise
CustomFlaskErr
(
Errors
.
TANGPU_BALANCE_NOT_ENOUGH
)
if
args
[
'env'
]
==
'ios'
:
else
:
res
=
tamp_pay_session
.
query
(
AccountBalance
.
apple_balance
)
.
filter
(
tamp_pay_session
.
query
(
AccountBalance
.
apple_balance
)
.
filter
(
AccountBalance
.
user_id
==
args
[
'user_id'
])
.
update
({
AccountBalance
.
user_id
==
args
[
'user_id'
])
.
first
()
'apple_balance'
:
AccountBalance
.
apple_balance
-
args
[
'ab_payment'
]
if
not
res
:
})
raise
CustomFlaskErr
(
Errors
.
TANGPU_BALANCE_NOT_ENOUGH
)
args
[
'ab_status'
]
=
'SUCCESS'
elif
res
[
0
]
<
args
[
'ab_payment'
]:
elif
args
[
'env'
]
==
'android'
:
raise
CustomFlaskErr
(
Errors
.
TANGPU_BALANCE_NOT_ENOUGH
)
res
=
tamp_pay_session
.
query
(
AccountBalance
.
android_balance
)
.
filter
(
else
:
AccountBalance
.
user_id
==
args
[
'user_id'
])
.
first
()
tamp_pay_session
.
query
(
AccountBalance
.
apple_balance
)
.
filter
(
if
not
res
:
AccountBalance
.
user_id
==
args
[
'user_id'
])
.
update
({
raise
CustomFlaskErr
(
Errors
.
TANGPU_BALANCE_NOT_ENOUGH
)
'apple_balance'
:
AccountBalance
.
apple_balance
-
args
[
'ab_payment'
]
elif
res
[
0
]
<
args
[
'ab_payment'
]:
})
raise
CustomFlaskErr
(
Errors
.
TANGPU_BALANCE_NOT_ENOUGH
)
args
[
'ab_status'
]
=
'SUCCESS'
else
:
elif
args
[
'env'
]
==
'android'
:
tamp_pay_session
.
query
(
AccountBalance
.
android_balance
)
.
filter
(
res
=
tamp_pay_session
.
query
(
AccountBalance
.
android_balance
)
.
filter
(
AccountBalance
.
user_id
==
args
[
'user_id'
])
.
update
({
AccountBalance
.
user_id
==
args
[
'user_id'
])
.
first
()
'android_balance'
:
AccountBalance
.
android_balance
-
args
[
'ab_payment'
]
if
not
res
:
})
raise
CustomFlaskErr
(
Errors
.
TANGPU_BALANCE_NOT_ENOUGH
)
args
[
'ab_status'
]
=
'SUCCESS'
elif
res
[
0
]
<
args
[
'ab_payment'
]:
elif
args
[
'ab_pay_mode'
]
==
5
:
raise
CustomFlaskErr
(
Errors
.
TANGPU_BALANCE_NOT_ENOUGH
)
# 微信支付
else
:
wx_pay
=
WXPay
(
out_trade_no
,
subject
,
args
[
'ab_payment'
],
args
[
'remote_addr'
],
notify_path
=
notify_path
)
tamp_pay_session
.
query
(
AccountBalance
.
android_balance
)
.
filter
(
params
=
wx_pay
.
getReturnParams
()
AccountBalance
.
user_id
==
args
[
'user_id'
])
.
update
({
pay_params
=
params
'android_balance'
:
AccountBalance
.
android_balance
-
args
[
'ab_payment'
]
elif
args
[
'ab_pay_mode'
]
==
6
:
})
# 支付宝支付
args
[
'ab_status'
]
=
'SUCCESS'
total_amount
=
args
[
'ab_payment'
]
/
100
elif
args
[
'ab_pay_mode'
]
==
5
:
res
=
prePay
(
subject
,
out_trade_no
,
total_amount
,
notify_path
=
notify_path
)
# 微信支付
pay_params
=
res
wx_pay
=
WXPay
(
out_trade_no
,
subject
,
args
[
'ab_payment'
],
args
[
'remote_addr'
],
notify_path
=
notify_path
)
args
[
'createby'
]
=
args
.
pop
(
'user_id'
,
''
)
params
=
wx_pay
.
getReturnParams
()
args
.
pop
(
'prod_name'
,
''
)
pay_params
=
params
args
.
pop
(
'env'
,
''
)
elif
args
[
'ab_pay_mode'
]
==
6
:
args
.
pop
(
'remote_addr'
,
''
)
# 支付宝支付
order_info
=
OrderFlow
(
**
args
)
total_amount
=
args
[
'ab_payment'
]
/
100
tamp_user_session
.
add
(
order_info
)
res
=
prePay
(
subject
,
out_trade_no
,
total_amount
,
notify_path
=
notify_path
)
tamp_pay_session
.
commit
()
pay_params
=
res
tamp_pay_session
.
close
()
args
[
'createby'
]
=
args
.
pop
(
'user_id'
,
''
)
tamp_user_session
.
commit
()
args
.
pop
(
'prod_name'
,
''
)
tamp_user_session
.
close
()
args
.
pop
(
'env'
,
''
)
return
pay_params
args
.
pop
(
'remote_addr'
,
''
)
order_info
=
OrderFlow
(
**
args
)
tamp_user_session
.
add
(
order_info
)
return
pay_params
def
topUpSuccessAction
(
order_no
):
def
topUpSuccessAction
(
order_no
):
...
@@ -266,8 +270,6 @@ def consumeSucessAction(order_no):
...
@@ -266,8 +270,6 @@ def consumeSucessAction(order_no):
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
:
...
@@ -325,53 +327,54 @@ def getAllOrders(args):
...
@@ -325,53 +327,54 @@ def getAllOrders(args):
offset
=
(
pageNumber
-
1
)
*
pageSize
offset
=
(
pageNumber
-
1
)
*
pageSize
if
not
user_id
:
if
not
user_id
:
raise
CustomFlaskErr
(
Errors
.
TOKEN_INVALID
)
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
())
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user_session
:
res
=
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
OrderFlow
.
createby
==
user_id
)
.
order_by
(
totalSize
=
len
(
tamp_user_session
.
query
(
OrderFlow
.
id
)
.
filter
(
OrderFlow
.
createtime
.
desc
())
.
all
()
and_
(
OrderFlow
.
createby
==
user_id
,
OrderFlow
.
ab_type
==
'6'
,
OrderFlow
.
ab_status
==
'SUCCESS'
))
.
all
())
topup_res
=
[
r
.
to_dict
()
for
r
in
res
]
res
=
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
allowed
=
{
'id'
,
'ab_ordernum'
,
'transaction_serial_no'
,
'ab_payment'
,
'ab_pay_mode'
,
'createtime'
,
'pay_time'
,
and_
(
OrderFlow
.
createby
==
user_id
,
OrderFlow
.
ab_type
==
'6'
,
OrderFlow
.
ab_status
==
'SUCCESS'
))
.
order_by
(
'complete_time'
,
'order_status'
,
'ab_type'
}
OrderFlow
.
createtime
.
desc
())
.
offset
(
offset
)
.
limit
(
pageSize
)
.
all
()
for
r
in
topup_res
:
topup_res
=
[
r
.
to_dict
()
for
r
in
res
]
keys
=
set
(
r
.
keys
())
-
allowed
allowed
=
{
'id'
,
'ab_ordernum'
,
'transaction_serial_no'
,
'ab_payment'
,
'ab_pay_mode'
,
'createtime'
,
'pay_time'
,
for
key
in
keys
:
'complete_time'
,
'order_status'
,
'ab_type'
}
del
r
[
key
]
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
,
curriculum_column
=
tamp_user_session
.
query
(
CurriculumColumn
.
id
,
CurriculumColumn
.
title
,
CurriculumColumn
.
cover
,
CurriculumColumn
.
info
)
.
all
()
CurriculumColumn
.
info
)
.
all
()
curriculum_res
=
tamp_user_session
.
query
(
CurriculumRes
.
id
,
CurriculumRes
.
title
,
CurriculumRes
.
cover
,
curriculum_res
=
tamp_user_session
.
query
(
CurriculumRes
.
id
,
CurriculumRes
.
title
,
CurriculumRes
.
cover
,
CurriculumRes
.
teacher_name
)
.
all
()
CurriculumRes
.
teacher_name
)
.
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
.
in_
([
'1'
,
'2'
,
'3'
,
'4'
,
'5'
])))
.
order_by
(
OrderFlow
.
createtime
.
desc
())
.
all
()
OrderFlow
.
createtime
.
desc
())
.
all
()
curriculum_column
=
{
r
[
0
]:
{
'title'
:
r
[
1
],
'cover'
:
r
[
2
],
'info'
:
r
[
3
]}
for
r
in
curriculum_column
}
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
}
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'
]
orders
=
[
r
.
to_dict
()
for
r
in
res
if
r
.
to_dict
()[
'ab_status'
]
==
'SUCCESS'
]
temp_orders
=
[]
temp_orders
=
[]
for
order
in
orders
:
for
order
in
orders
:
prod_type
=
order
.
get
(
'ab_type'
,
''
)
prod_type
=
order
.
get
(
'ab_type'
,
''
)
prod_id
=
order
.
get
(
'ab_proid'
,
''
)
prod_id
=
order
.
get
(
'ab_proid'
,
''
)
if
prod_type
==
'1'
:
if
prod_type
==
'1'
:
order
=
{
**
order
,
**
curriculum_column
.
get
(
prod_id
,
None
)}
order
=
{
**
order
,
**
curriculum_column
.
get
(
prod_id
,
None
)}
temp_orders
.
append
(
order
)
temp_orders
.
append
(
order
)
elif
prod_type
in
[
'3'
,
'4'
,
'5'
]:
elif
prod_type
in
[
'3'
,
'4'
,
'5'
]:
order
=
{
**
order
,
**
curriculum_res
.
get
(
prod_id
,
None
)}
order
=
{
**
order
,
**
curriculum_res
.
get
(
prod_id
,
None
)}
temp_orders
.
append
(
order
)
temp_orders
.
append
(
order
)
temp_orders
=
temp_orders
[
offset
:
offset
+
pageSize
]
temp_orders
=
temp_orders
[
offset
:
offset
+
pageSize
]
allowed
=
{
'id'
,
'title'
,
'cover'
,
'info'
,
'ab_type'
,
'ab_payment'
,
'ab_pay_mode'
,
'ab_ordernum'
,
allowed
=
{
'id'
,
'title'
,
'cover'
,
'info'
,
'ab_type'
,
'ab_payment'
,
'ab_pay_mode'
,
'ab_ordernum'
,
'transaction_serial_no'
,
'pay_method'
,
'createtime'
,
'pay_time'
,
'complete_time'
,
'transaction_serial_no'
,
'pay_method'
,
'createtime'
,
'pay_time'
,
'complete_time'
,
'ab_status'
}
'ab_status'
}
for
r
in
temp_orders
:
for
r
in
temp_orders
:
keys
=
set
(
r
.
keys
())
-
allowed
keys
=
set
(
r
.
keys
())
-
allowed
for
key
in
keys
:
for
key
in
keys
:
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.commit()
tamp_user_session
.
close
()
# tamp_user_session.close()
tamp_pay_session
.
commit
()
return
{
tamp_pay_session
.
close
()
'content'
:
orders
[
offset
:
offset
+
pageSize
],
return
{
'pageNum'
:
pageNumber
,
'content'
:
orders
[
offset
:
offset
+
pageSize
],
'pageSize'
:
pageSize
,
'pageNum'
:
pageNumber
,
'totalSize'
:
totalSize
'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