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
adea982a
Commit
adea982a
authored
Apr 22, 2021
by
etscript
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加课程附件305
parent
2f578ede
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
11 deletions
+18
-11
order_service.py
app/service/order_service.py
+18
-11
No files found.
app/service/order_service.py
View file @
adea982a
...
...
@@ -18,7 +18,7 @@ from app.controller.errorhandler import CustomFlaskErr
from
app.model.account_balance
import
AccountBalance
# from app.model.account_topup_order import AccountTopupOrder
from
app.model.curriculum_order
import
OrderFlow
from
app.model.tamp_user_models
import
CurriculumPrice
,
CurriculumColumn
,
CurriculumRes
from
app.model.tamp_user_models
import
CurriculumPrice
,
CurriculumColumn
,
CurriculumRes
,
CsFileRecord
from
app.model.tamp_course_models
import
CoursePackage
from
xml.etree
import
cElementTree
as
etree
...
...
@@ -168,11 +168,11 @@ class CurriculumOrderService:
# 找出 1栏目表 , 3直播间信息表, [4,5]课程资源, 7附件 的list id
orders
=
[
r
.
to_dict
()
for
r
in
res
if
r
.
to_dict
()[
'ab_status'
]
==
'SUCCESS'
]
orders_dict
=
{
'1'
:[],
'3'
:[],
'4'
:[],
'5'
:[],
'7'
:[],
'300'
:[]}
orders_dict
=
{
'1'
:[],
'3'
:[],
'4'
:[],
'5'
:[],
'7'
:[],
'300'
:[]
,
'305'
:[]
}
for
i
in
orders
:
prod_type
=
i
.
get
(
'ab_type'
,
''
)
prod_id
=
i
.
get
(
'ab_proid'
,
''
)
if
(
prod_type
in
'13457'
or
prod_type
==
'300'
)
and
prod_id
:
if
(
prod_type
in
'13457'
or
prod_type
==
'300'
or
prod_type
==
'305'
)
and
prod_id
:
orders_dict
[
prod_type
]
.
append
(
prod_id
)
# 四组组合查询,将 需要的 1栏目表 , 3直播间信息表, [4,5]课程资源, 7附件 查出
...
...
@@ -192,6 +192,8 @@ class CurriculumOrderService:
CoursePackage
.
square_img
,
CoursePackage
.
bg_status
,
CoursePackage
.
bg_img
)
.
\
filter
(
CoursePackage
.
id
.
in_
(
orders_dict
[
"300"
]))
.
all
()
course_file
=
tamp_user_session
.
query
(
CsFileRecord
.
guid
,
CsFileRecord
.
original_name
)
.
\
filter
(
CsFileRecord
.
guid
.
in_
(
orders_dict
[
"305"
]))
.
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
}
...
...
@@ -199,6 +201,7 @@ class CurriculumOrderService:
zhibo_file
=
{
r
[
0
]:
{
'title'
:
r
[
1
]}
for
r
in
zhibo_file
}
# orders = [r.to_dict() for r in res if r.to_dict()['ab_status'] == 'SUCCESS']
course_package
=
{
r
[
0
]:
{
'title'
:
r
[
1
],
'square_img'
:
r
[
2
],
'bg_status'
:
r
[
3
],
'bg_img'
:
r
[
4
]}
for
r
in
course_package
}
course_file
=
{
r
[
0
]:
{
'title'
:
r
[
1
]}
for
r
in
course_file
}
allowed
=
{
'id'
,
'title'
,
'cover'
,
'info'
,
'ab_type'
,
'ab_payment'
,
'ab_score'
,
'ab_pay_mode'
,
'ab_ordernum'
,
'transaction_serial_no'
,
'pay_method'
,
'createtime'
,
'pay_time'
,
'complete_time'
,
'ab_status'
,
'ab_pro_siid'
,
'zb_start_time'
,
'square_img'
,
'bg_status'
,
'bg_img'
}
...
...
@@ -216,6 +219,8 @@ class CurriculumOrderService:
order
=
{
**
order
,
**
zhibo_file
.
get
(
prod_id
,
None
)}
elif
prod_type
==
'300'
and
course_package
.
get
(
prod_id
,
None
):
order
=
{
**
order
,
**
course_package
.
get
(
prod_id
,
None
)}
elif
prod_type
==
'305'
and
course_file
.
get
(
prod_id
,
None
):
order
=
{
**
order
,
**
course_file
.
get
(
prod_id
,
None
)}
keys
=
set
(
order
.
keys
())
-
allowed
for
key
in
keys
:
...
...
@@ -243,6 +248,13 @@ class CurriculumOrderService:
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
args
[
'ab_ordernum'
]
=
time
.
strftime
(
'
%
Y
%
m
%
d'
,
time
.
localtime
(
time
.
time
()))
+
str
(
int
(
time
.
time
()
*
100000
))
# 该用户是否重复购买同一商品
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_type'
]
==
"300"
:
data
=
{
...
...
@@ -296,13 +308,8 @@ class CurriculumOrderService:
subject
=
args
.
get
(
'prod_name'
,
''
)
out_trade_no
=
args
[
'ab_ordernum'
]
notify_url
=
config
[
env
][
'pay_url_prefix'
]
+
'/tamp_order/micro_shop/consumeOrderNotify'
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
)
pay_params
=
None
if
int
(
amount
)
==
0
:
args
[
'ab_status'
]
=
'SUCCESS'
elif
args
[
'ab_pay_mode'
]
==
4
:
...
...
@@ -349,7 +356,7 @@ class CurriculumOrderService:
ad
=
args
.
get
(
"ad"
)
if
ad
==
'April'
:
args
.
pop
(
'ad'
,
''
)
subject
=
subject
+
','
+
ad
subject
=
subject
+
',
ad=
'
+
ad
wx_pay
=
wx_jsapi_pay
.
WXPay
(
args
[
'openid'
],
out_trade_no
,
subject
,
args
[
'ab_payment'
],
args
[
'remote_addr'
],
notify_url
)
params
=
wx_pay
.
getReturnParams
()
pay_params
=
params
...
...
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