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
Dec 12, 2020
by
pengxiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
直播查询
parent
eba26a18
Expand all
Show 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,30 +36,30 @@ tamp_user_engine = create_engine(
...
@@ -36,30 +36,30 @@ tamp_user_engine = create_engine(
pool_timeout
=
5
,
pool_timeout
=
5
,
pool_recycle
=
600
pool_recycle
=
600
)
)
if
env
==
'prod'
:
tamp_user
_engine
=
create_engine
(
tamp_pay
_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_pay
_db'
],
host
=
config
[
env
][
'MySQL'
][
'host'
],
host
=
config
[
env
][
'MySQL'
][
'host'
],
port
=
config
[
env
][
'MySQL'
][
'port'
],
port
=
config
[
env
][
'MySQL'
][
'port'
],
user
=
config
[
env
][
'MySQL'
][
'user2
'
],
user
=
config
[
env
][
'MySQL'
][
'user
'
],
password
=
config
[
env
][
'MySQL'
][
'password'
],
password
=
config
[
env
][
'MySQL'
][
'password'
],
charset
=
"utf8"
charset
=
"utf8"
),
),
max_overflow
=
0
,
# 超过连接池大小外最多创建的连接
max_overflow
=
0
,
# 超过连接池大小外最多创建的连接
pool_size
=
100
,
# 连接池大小
pool_size
=
100
,
# 连接池大小
pool_timeout
=
5
,
pool_timeout
=
5
,
pool_recycle
=
600
pool_recycle
=
600
)
)
tamp_
pay
_engine
=
create_engine
(
tamp_
zhibo
_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_
pay
_db'
],
db
=
config
[
env
][
'MySQL'
][
'tamp_
zhibo
_db'
],
host
=
config
[
env
][
'MySQL'
][
'host'
],
host
=
config
[
env
][
'MySQL'
][
'host'
],
port
=
config
[
env
][
'MySQL'
][
'port'
],
port
=
config
[
env
][
'MySQL'
][
'port'
],
user
=
config
[
env
][
'MySQL'
][
'user'
],
user
=
config
[
env
][
'MySQL'
][
'user'
],
password
=
config
[
env
][
'MySQL'
][
'password'
],
password
=
config
[
env
][
'MySQL'
][
'password'
],
charset
=
"utf8"
),
charset
=
"utf8"
),
max_overflow
=
0
,
# 超过连接池大小外最多创建的连接
max_overflow
=
0
,
# 超过连接池大小外最多创建的连接
pool_size
=
100
,
# 连接池大小
pool_size
=
100
,
# 连接池大小
pool_timeout
=
5
,
pool_timeout
=
5
,
...
...
app/config/config.yaml
View file @
75132aad
...
@@ -2,6 +2,7 @@ dev:
...
@@ -2,6 +2,7 @@ dev:
MySQL
:
MySQL
:
tamp_user_db
:
tamp_user
tamp_user_db
:
tamp_user
tamp_pay_db
:
tamp_pay
tamp_pay_db
:
tamp_pay
tamp_zhibo_db
:
tamp_zhibo
host
:
mysql
host
:
mysql
port
:
3306
port
:
3306
user
:
dev
user
:
dev
...
@@ -24,6 +25,7 @@ test:
...
@@ -24,6 +25,7 @@ test:
MySQL
:
MySQL
:
tamp_user_db
:
tamp_user
tamp_user_db
:
tamp_user
tamp_pay_db
:
tamp_pay
tamp_pay_db
:
tamp_pay
tamp_zhibo_db
:
tamp_zhibo
host
:
118.190.63.109
host
:
118.190.63.109
port
:
3306
port
:
3306
user
:
root
user
:
root
...
@@ -46,10 +48,10 @@ prod:
...
@@ -46,10 +48,10 @@ prod:
MySQL
:
MySQL
:
tamp_user_db
:
tamp_user
tamp_user_db
:
tamp_user
tamp_pay_db
:
tamp_pay
tamp_pay_db
:
tamp_pay
tamp_zhibo_db
:
tamp_zhibo
host
:
pc-uf666afrpfg8yj768.rwlb.rds.aliyuncs.com
host
:
pc-uf666afrpfg8yj768.rwlb.rds.aliyuncs.com
port
:
3306
port
:
3306
user
:
tamp_pay
user
:
tamp_admin
user2
:
tamp_user
password
:
'
@imeng123'
password
:
'
@imeng123'
redis
:
redis
:
host
:
r-uf6atruhdbq89enqz0.redis.rds.aliyuncs.com
host
:
r-uf6atruhdbq89enqz0.redis.rds.aliyuncs.com
...
...
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
...
@@ -12,7 +12,7 @@ import time
from
sqlalchemy
import
and_
from
sqlalchemy
import
and_
from
sqlalchemy.testing
import
in_
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.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
...
@@ -21,6 +21,7 @@ from app.model.curriculum_order import OrderFlow
...
@@ -21,6 +21,7 @@ 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
from
xml.etree
import
cElementTree
as
etree
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.alipay.alipayWap
import
prePay
from
app.utils.apple_pay
import
apple_pay
from
app.utils.apple_pay
import
apple_pay
from
app.utils.wxpay
import
wx_jsapi_pay
from
app.utils.wxpay
import
wx_jsapi_pay
...
@@ -129,10 +130,12 @@ class CurriculumOrderService:
...
@@ -129,10 +130,12 @@ class CurriculumOrderService:
pageSize
=
args
[
'pageSize'
]
pageSize
=
args
[
'pageSize'
]
user_id
=
args
[
'user_id'
]
user_id
=
args
[
'user_id'
]
offset
=
(
pageNumber
-
1
)
*
pageSize
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_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_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
()
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
(
totalSize
=
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
and_
(
OrderFlow
.
createby
==
user_id
,
OrderFlow
.
ab_type
!=
'6'
,
OrderFlow
.
ab_status
==
'SUCCESS'
)
and_
(
OrderFlow
.
createby
==
user_id
,
OrderFlow
.
ab_type
!=
'6'
,
OrderFlow
.
ab_status
==
'SUCCESS'
)
)
.
count
()
)
.
count
()
...
@@ -141,6 +144,7 @@ class CurriculumOrderService:
...
@@ -141,6 +144,7 @@ class CurriculumOrderService:
)
.
order_by
(
OrderFlow
.
createtime
.
desc
())
.
offset
(
offset
)
.
limit
(
pageSize
)
)
.
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_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
}
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'
]
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
:
...
@@ -148,12 +152,14 @@ class CurriculumOrderService:
...
@@ -148,12 +152,14 @@ class CurriculumOrderService:
prod_id
=
order
.
get
(
'ab_proid'
,
''
)
prod_id
=
order
.
get
(
'ab_proid'
,
''
)
if
prod_type
==
'1'
and
curriculum_column
.
get
(
prod_id
,
None
):
if
prod_type
==
'1'
and
curriculum_column
.
get
(
prod_id
,
None
):
order
=
{
**
order
,
**
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
)}
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_score'
,
'ab_pay_mode'
,
'ab_ordernum'
,
'transaction_serial_no'
,
'pay_method'
,
'createtime'
,
'pay_time'
,
'complete_time'
,
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
:
for
r
in
temp_orders
:
keys
=
set
(
r
.
keys
())
-
allowed
keys
=
set
(
r
.
keys
())
-
allowed
for
key
in
keys
:
for
key
in
keys
:
...
@@ -361,13 +367,16 @@ def getAllOrders(args):
...
@@ -361,13 +367,16 @@ 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
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_user_session
=
tamp_user
.
session
tamp_zhibo_session
=
tamp_zhibo
.
session
# 全部订单
# 全部订单
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
()
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
(
totalSize
=
tamp_user_session
.
query
(
OrderFlow
)
.
filter
(
and_
(
OrderFlow
.
createby
==
user_id
,
OrderFlow
.
ab_status
==
'SUCCESS'
)
and_
(
OrderFlow
.
createby
==
user_id
,
OrderFlow
.
ab_status
==
'SUCCESS'
)
)
.
count
()
)
.
count
()
...
@@ -376,6 +385,7 @@ def getAllOrders(args):
...
@@ -376,6 +385,7 @@ def getAllOrders(args):
)
.
order_by
(
OrderFlow
.
createtime
.
desc
())
.
offset
(
offset
)
.
limit
(
pageSize
)
)
.
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_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
}
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'
]
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
:
...
@@ -383,12 +393,14 @@ def getAllOrders(args):
...
@@ -383,12 +393,14 @@ def getAllOrders(args):
prod_id
=
order
.
get
(
'ab_proid'
,
''
)
prod_id
=
order
.
get
(
'ab_proid'
,
''
)
if
prod_type
==
'1'
and
curriculum_column
.
get
(
prod_id
,
None
):
if
prod_type
==
'1'
and
curriculum_column
.
get
(
prod_id
,
None
):
order
=
{
**
order
,
**
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
)}
order
=
{
**
order
,
**
curriculum_res
.
get
(
prod_id
,
None
)}
temp_orders
.
append
(
order
)
temp_orders
.
append
(
order
)
allowed
=
{
'id'
,
'title'
,
'cover'
,
'info'
,
'ab_type'
,
'ab_payment'
,
'ab_score'
,
'ab_pay_mode'
,
'ab_ordernum'
,
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'
,
'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
:
for
r
in
temp_orders
:
keys
=
set
(
r
.
keys
())
-
allowed
keys
=
set
(
r
.
keys
())
-
allowed
for
key
in
keys
:
for
key
in
keys
:
...
...
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