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
75132aad
Commit
75132aad
authored
4 years ago
by
pengxiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
直播查询
parent
eba26a18
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
488 additions
and
24 deletions
+488
-24
engine.py
app/api/engine.py
+15
-15
config.yaml
app/config/config.yaml
+4
-2
tamp_zhibo_models.py
app/model/tamp_zhibo_models.py
+450
-0
order_service.py
app/service/order_service.py
+19
-7
No files found.
app/api/engine.py
View file @
75132aad
...
...
@@ -36,21 +36,6 @@ tamp_user_engine = create_engine(
pool_timeout
=
5
,
pool_recycle
=
600
)
if
env
==
'prod'
:
tamp_user_engine
=
create_engine
(
'mysql+pymysql://{user}:{password}@{host}:{port}/{db}?charset={charset}'
.
format
(
db
=
config
[
env
][
'MySQL'
][
'tamp_user_db'
],
host
=
config
[
env
][
'MySQL'
][
'host'
],
port
=
config
[
env
][
'MySQL'
][
'port'
],
user
=
config
[
env
][
'MySQL'
][
'user2'
],
password
=
config
[
env
][
'MySQL'
][
'password'
],
charset
=
"utf8"
),
max_overflow
=
0
,
# 超过连接池大小外最多创建的连接
pool_size
=
100
,
# 连接池大小
pool_timeout
=
5
,
pool_recycle
=
600
)
tamp_pay_engine
=
create_engine
(
'mysql+pymysql://{user}:{password}@{host}:{port}/{db}?charset={charset}'
.
format
(
...
...
@@ -66,6 +51,21 @@ tamp_pay_engine = create_engine(
pool_recycle
=
600
)
tamp_zhibo_engine
=
create_engine
(
'mysql+pymysql://{user}:{password}@{host}:{port}/{db}?charset={charset}'
.
format
(
db
=
config
[
env
][
'MySQL'
][
'tamp_zhibo_db'
],
host
=
config
[
env
][
'MySQL'
][
'host'
],
port
=
config
[
env
][
'MySQL'
][
'port'
],
user
=
config
[
env
][
'MySQL'
][
'user'
],
password
=
config
[
env
][
'MySQL'
][
'password'
],
charset
=
"utf8"
),
max_overflow
=
0
,
# 超过连接池大小外最多创建的连接
pool_size
=
100
,
# 连接池大小
pool_timeout
=
5
,
pool_recycle
=
600
)
redis
=
redis
.
Redis
(
host
=
config
[
env
][
'redis'
][
'host'
],
port
=
config
[
env
][
'redis'
][
'port'
],
...
...
This diff is collapsed.
Click to expand it.
app/config/config.yaml
View file @
75132aad
...
...
@@ -2,6 +2,7 @@ dev:
MySQL
:
tamp_user_db
:
tamp_user
tamp_pay_db
:
tamp_pay
tamp_zhibo_db
:
tamp_zhibo
host
:
mysql
port
:
3306
user
:
dev
...
...
@@ -24,6 +25,7 @@ test:
MySQL
:
tamp_user_db
:
tamp_user
tamp_pay_db
:
tamp_pay
tamp_zhibo_db
:
tamp_zhibo
host
:
118.190.63.109
port
:
3306
user
:
root
...
...
@@ -46,10 +48,10 @@ prod:
MySQL
:
tamp_user_db
:
tamp_user
tamp_pay_db
:
tamp_pay
tamp_zhibo_db
:
tamp_zhibo
host
:
pc-uf666afrpfg8yj768.rwlb.rds.aliyuncs.com
port
:
3306
user
:
tamp_pay
user2
:
tamp_user
user
:
tamp_admin
password
:
'
@imeng123'
redis
:
host
:
r-uf6atruhdbq89enqz0.redis.rds.aliyuncs.com
...
...
This diff is collapsed.
Click to expand it.
app/model/tamp_zhibo_models.py
0 → 100644
View file @
75132aad
This diff is collapsed.
Click to expand it.
app/service/order_service.py
View file @
75132aad
...
...
@@ -12,7 +12,7 @@ import time
from
sqlalchemy
import
and_
from
sqlalchemy.testing
import
in_
from
app.api.engine
import
TAMP_SQL
,
tamp_pay_engine
,
tamp_user_engine
,
config
,
env
from
app.api.engine
import
TAMP_SQL
,
tamp_pay_engine
,
tamp_user_engine
,
config
,
env
,
tamp_zhibo_engine
from
app.config.errors
import
Errors
from
app.controller.errorhandler
import
CustomFlaskErr
from
app.model.account_balance
import
AccountBalance
...
...
@@ -21,6 +21,7 @@ from app.model.curriculum_order import OrderFlow
from
app.model.tamp_user_models
import
CurriculumPrice
,
CurriculumColumn
,
CurriculumRes
from
xml.etree
import
cElementTree
as
etree
from
app.model.tamp_zhibo_models
import
ZhiboTheme
from
app.utils.alipay.alipayWap
import
prePay
from
app.utils.apple_pay
import
apple_pay
from
app.utils.wxpay
import
wx_jsapi_pay
...
...
@@ -129,10 +130,12 @@ class CurriculumOrderService:
pageSize
=
args
[
'pageSize'
]
user_id
=
args
[
'user_id'
]
offset
=
(
pageNumber
-
1
)
*
pageSize
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user
:
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user
,
TAMP_SQL
(
tamp_zhibo_engine
)
as
tamp_zhibo
:
tamp_user_session
=
tamp_user
.
session
tamp_zhibo_session
=
tamp_zhibo
.
session
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
()
zhibo
=
tamp_zhibo_session
.
query
(
ZhiboTheme
.
id
,
ZhiboTheme
.
zt_name
,
ZhiboTheme
.
zt_img
,
ZhiboTheme
.
manager_name
,
ZhiboTheme
.
zt_starttime
)
.
all
()
totalSize
=
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
and_
(
OrderFlow
.
createby
==
user_id
,
OrderFlow
.
ab_type
!=
'6'
,
OrderFlow
.
ab_status
==
'SUCCESS'
)
)
.
count
()
...
...
@@ -141,6 +144,7 @@ class CurriculumOrderService:
)
.
order_by
(
OrderFlow
.
createtime
.
desc
())
.
offset
(
offset
)
.
limit
(
pageSize
)
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
}
zhibo
=
{
r
[
0
]:
{
'title'
:
r
[
1
],
'cover'
:
r
[
2
],
'info'
:
r
[
3
],
'zb_start_time'
:
r
[
4
]}
for
r
in
zhibo
}
orders
=
[
r
.
to_dict
()
for
r
in
res
if
r
.
to_dict
()[
'ab_status'
]
==
'SUCCESS'
]
temp_orders
=
[]
for
order
in
orders
:
...
...
@@ -148,12 +152,14 @@ class CurriculumOrderService:
prod_id
=
order
.
get
(
'ab_proid'
,
''
)
if
prod_type
==
'1'
and
curriculum_column
.
get
(
prod_id
,
None
):
order
=
{
**
order
,
**
curriculum_column
.
get
(
prod_id
,
None
)}
elif
prod_type
in
[
'3'
,
'4'
,
'5'
]
and
curriculum_res
.
get
(
prod_id
,
None
):
elif
prod_type
==
'3'
and
zhibo
.
get
(
prod_id
,
None
):
order
=
{
**
order
,
**
zhibo
.
get
(
prod_id
,
None
)}
elif
prod_type
in
[
'4'
,
'5'
]
and
curriculum_res
.
get
(
prod_id
,
None
):
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_score'
,
'ab_pay_mode'
,
'ab_ordernum'
,
'transaction_serial_no'
,
'pay_method'
,
'createtime'
,
'pay_time'
,
'complete_time'
,
'ab_status'
,
'ab_pro_siid'
}
'ab_status'
,
'ab_pro_siid'
,
'zb_start_time'
}
for
r
in
temp_orders
:
keys
=
set
(
r
.
keys
())
-
allowed
for
key
in
keys
:
...
...
@@ -361,13 +367,16 @@ def getAllOrders(args):
pageSize
=
args
[
'pageSize'
]
user_id
=
args
[
'user_id'
]
offset
=
(
pageNumber
-
1
)
*
pageSize
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user
:
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user
,
TAMP_SQL
(
tamp_zhibo_engine
)
as
tamp_zhibo
:
tamp_user_session
=
tamp_user
.
session
tamp_zhibo_session
=
tamp_zhibo
.
session
# 全部订单
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
()
zhibo
=
tamp_zhibo_session
.
query
(
ZhiboTheme
.
id
,
ZhiboTheme
.
zt_name
,
ZhiboTheme
.
zt_img
,
ZhiboTheme
.
manager_name
,
ZhiboTheme
.
zt_starttime
)
.
all
()
totalSize
=
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
and_
(
OrderFlow
.
createby
==
user_id
,
OrderFlow
.
ab_status
==
'SUCCESS'
)
)
.
count
()
...
...
@@ -376,6 +385,7 @@ def getAllOrders(args):
)
.
order_by
(
OrderFlow
.
createtime
.
desc
())
.
offset
(
offset
)
.
limit
(
pageSize
)
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
}
zhibo
=
{
r
[
0
]:
{
'title'
:
r
[
1
],
'cover'
:
r
[
2
],
'info'
:
r
[
3
],
'zb_start_time'
:
r
[
4
]}
for
r
in
zhibo
}
orders
=
[
r
.
to_dict
()
for
r
in
res
if
r
.
to_dict
()[
'ab_status'
]
==
'SUCCESS'
]
temp_orders
=
[]
for
order
in
orders
:
...
...
@@ -383,12 +393,14 @@ def getAllOrders(args):
prod_id
=
order
.
get
(
'ab_proid'
,
''
)
if
prod_type
==
'1'
and
curriculum_column
.
get
(
prod_id
,
None
):
order
=
{
**
order
,
**
curriculum_column
.
get
(
prod_id
,
None
)}
elif
prod_type
in
[
'3'
,
'4'
,
'5'
]
and
curriculum_res
.
get
(
prod_id
,
None
):
elif
prod_type
==
'3'
and
zhibo
.
get
(
prod_id
,
None
):
order
=
{
**
order
,
**
zhibo
.
get
(
prod_id
,
None
)}
elif
prod_type
in
[
'4'
,
'5'
]
and
curriculum_res
.
get
(
prod_id
,
None
):
order
=
{
**
order
,
**
curriculum_res
.
get
(
prod_id
,
None
)}
temp_orders
.
append
(
order
)
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'
}
'ab_status'
,
'ab_pro_siid'
,
'zt_start_time'
}
for
r
in
temp_orders
:
keys
=
set
(
r
.
keys
())
-
allowed
for
key
in
keys
:
...
...
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