Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lzzzzl
/
PipData
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3697aaed
authored
Oct 27, 2021
by
刘豪
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
update new mysql db
parent
0b337ed6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
23 deletions
extract/ex_dashboard.py
extract/ex_order.py
utils/msg_handler.py
extract/ex_dashboard.py
View file @
3697aaed
...
...
@@ -7,23 +7,23 @@ class ExDashboard(Base):
def
email_list
(
self
,
condition
):
# 筛选字段
con_str
=
super
()
.
condition_to_str
(
condition
[
'condition'
])
# 订单数据库
db
=
ConnList
.
Dashboard
()
sql
=
"SELECT email
\
FROM
\
lie_email_list
\
WHERE
%
s"
\
%
con_str
results
=
DBHandler
.
read
(
db
=
db
,
sql
=
sql
)
# 结果格式转换为字典
final_result
=
super
()
.
result_to_list
(
results
)
print
(
'final_result'
,
len
(
final_result
))
return
final_result
#
#
筛选字段
#
con_str = super().condition_to_str(condition['condition'])
#
#
#
订单数据库
#
db = ConnList.Dashboard()
#
sql = "SELECT email \
#
FROM \
#
lie_email_list \
#
WHERE %s" \
#
% con_str
#
results = DBHandler.read(db=db, sql=sql)
#
#
#
结果格式转换为字典
#
final_result = super().result_to_list(results)
#
print('final_result', len(final_result))
# return final_result
return
[
"hao@ichunt.com"
]
"""
汇总订单数据
...
...
extract/ex_order.py
View file @
3697aaed
...
...
@@ -123,10 +123,9 @@ class ExOrder(Base):
def
order_items
(
self
,
condition
):
# 筛选字段
col
=
[
'i.order_id'
,
'i.goods_id'
,
'i.goods_price'
,
'i.goods_number'
,
'i.single_pre_price'
,
'i.goods_type'
,
col
=
[
'i.
rec_id'
,
'i.
order_id'
,
'i.goods_id'
,
'i.goods_price'
,
'i.goods_number'
,
'i.single_pre_price'
,
'i.goods_type'
,
'i.status as items_status'
,
'i.canal'
,
'i.supplier_name'
,
'i.supplier_id'
,
'i.brand_id'
,
'i.goods_name'
,
'i.brand_name'
,
'i.goods_class'
,
'o.user_id'
,
'o.order_sn'
,
'o.status'
,
'o.currency'
,
'o.pay_time'
,
'o.create_time'
,
'o.order_pay_type'
,
'o.sale_id'
,
'o.order_source'
,
'o.order_source'
,
'o.cancel_reason'
,
# 'u.user_id', 'u.mobile', 'u.email',
...
...
@@ -154,11 +153,45 @@ class ExOrder(Base):
lx_order_sql
=
"SELECT
%
s FROM lie_order_items i LEFT JOIN lie_order o ON i.order_id = o.order_id LEFT JOIN lie_order_invoice v ON v.order_id = i.order_id where o.create_time BETWEEN
%
d AND
%
d AND o.is_type=0 AND o.order_type=1 AND
%
s"
%
(
col_str
,
start_time
,
end_time
,
con_str
)
lx_order_results_dict
=
ConnList
.
handle_sql
(
db
=
lx_order_db
,
col
=
col
,
sql_str
=
lx_order_sql
)
order_rec_ids
=
[
k
.
get
(
"rec_id"
)
for
k
in
lx_order_results_dict
]
lx_order_ext_sql
=
"SELECT rec_id, goods_class FROM lie_order_items_ext where rec_id IN
%
s"
%
(
str
(
tuple
(
order_rec_ids
)))
order_ext_results_dict
=
ConnList
.
handle_sql
(
db
=
lx_order_db
,
col
=
[
'rec_id'
,
'goods_class'
],
sql_str
=
lx_order_ext_sql
)
order_ext_rec_id_dict
=
{
e
.
get
(
"rec_id"
):
e
.
get
(
"goods_class"
)
for
e
in
order_ext_results_dict
}
order_user_ids
=
[
r
.
get
(
"user_id"
)
for
r
in
lx_order_results_dict
]
user_main_sql
=
"SELECT user_id, mobile, email FROM lie_user_main where is_test = 0 AND user_id IN
%
s"
%
(
str
(
tuple
(
order_user_ids
)))
user_main_results_dict
=
ConnList
.
handle_sql
(
db
=
lx_db
,
col
=
[
'user_id'
,
'mobile'
,
'email'
],
sql_str
=
user_main_sql
)
user_main_dict
=
{
str
(
u
.
get
(
"user_id"
)):
u
for
u
in
user_main_results_dict
}
final_result
=
[]
for
order_data_dict
in
lx_order_results_dict
:
if
user_main_dict
.
get
(
str
(
order_data_dict
[
"user_id"
])):
rec_id
=
order_data_dict
.
get
(
"rec_id"
)
order_data_dict
.
pop
(
"rec_id"
)
order_data_dict
[
"goods_class"
]
=
order_ext_rec_id_dict
.
get
(
rec_id
,
""
)
final_result
.
append
(
dict
(
order_data_dict
,
**
user_main_dict
[
str
(
order_data_dict
[
"user_id"
])]))
final_result
=
[
dict
(
order_data_dict
,
**
user_main_dict
[
str
(
order_data_dict
[
"user_id"
])])
for
order_data_dict
in
lx_order_results_dict
if
user_main_dict
.
get
(
str
(
order_data_dict
[
"user_id"
]))]
# order_rec_ids = [k.get("rec_id") for k in lx_order_results_dict]
#
# lx_order_ext_sql = "SELECT rec_id, goods_class FROM lie_order_items_ext where rec_id IN %s" % (
# str(tuple(order_rec_ids)))
# order_ext_results_dict = handle_sql(db=order_db, col=['rec_id', 'goods_class'],
# sql_str=lx_order_ext_sql)
# order_ext_rec_id_dict = {e.get("rec_id"): e.get("goods_class") for e in order_ext_results_dict}
# order_user_ids = [r.get("user_id") for r in lx_order_results_dict]
# user_main_sql = "SELECT user_id, mobile, email FROM lie_user_main where is_test = 0 AND user_id IN %s" % (
# str(tuple(order_user_ids)))
# user_main_results_dict = handle_sql(db=db, col=['user_id', 'mobile', 'email'],
# sql_str=user_main_sql)
# user_main_dict = {str(u.get("user_id")): u for u in user_main_results_dict}
# final_result = []
# try:
# for order_data_dict in lx_order_results_dict:
# if user_main_dict.get(str(order_data_dict["user_id"])):
# rec_id = order_data_dict.get("rec_id")
# order_data_dict.pop("rec_id")
# order_data_dict["goods_class"] = order_ext_rec_id_dict.get(rec_id, "")
# final_result.append(dict(order_data_dict, **user_main_dict[str(order_data_dict["user_id"])]))
return
final_result
"""
...
...
utils/msg_handler.py
View file @
3697aaed
...
...
@@ -26,8 +26,8 @@ class MsgHandler:
"content"
:
msg
}
}
#
print("send_dd_msg", data)
res
=
requests
.
post
(
robot_api
+
robot
,
json
=
data
)
print
(
"send_dd_msg"
,
data
)
#
res = requests.post(robot_api + robot, json=data)
# print(res)
@staticmethod
...
...
@@ -38,8 +38,8 @@ class MsgHandler:
"content"
:
msg
}
}
#
print("send_point_dd_msg", data)
res
=
requests
.
post
(
robot_api
,
json
=
data
)
print
(
"send_point_dd_msg"
,
data
)
#
res = requests.post(robot_api, json=data)
# print(res)
"""
...
...
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