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
5107ec0e
authored
Oct 15, 2021
by
刘豪
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
update new sql
parent
284c63ca
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
94 additions
and
34 deletions
config/conn_list.py
config/db.py
extract/ex_dashboard.py
extract/ex_order.py
extract/ex_sku_expose.py
extract/ex_user.py
pipeline/pi_daily.py
translate/ts_user.py
utils/msg_handler.py
config/conn_list.py
View file @
5107ec0e
...
...
@@ -2,9 +2,10 @@ import pymysql
from
config.db
import
*
import
pymongo
as
pm
import
redis
from
utils.db_handler
import
DBHandler
from
extract.ex_base
import
Base
class
ConnList
:
class
ConnList
(
Base
):
@staticmethod
def
Dashboard
():
...
...
@@ -179,10 +180,25 @@ class ConnList:
conf
[
'db_name'
],
charset
=
'utf8'
)
@staticmethod
def
LocalLx
():
conf
=
local_liexin
return
pymysql
.
connect
(
str
(
conf
[
'host'
]),
conf
[
'user'
],
conf
[
'password'
],
conf
[
'db_name'
],
charset
=
'utf8'
)
def
LxDb
():
# if ENV == "produce":
# db_name = "hunt2016"
# else:
# db_name = "liexin"
conf
=
{
'host'
:
"172.18.137.22"
,
'port'
:
3306
,
'user'
:
"huntdbslave"
,
'password'
:
"mLssy2@@!!@$#yy"
,
'db'
:
"hunt2016"
,
'charset'
:
'utf8'
}
return
pymysql
.
connect
(
**
conf
)
@staticmethod
def
LxOrderDb
():
conf
=
get_mysql_conf
(
"liexin_order"
)
return
pymysql
.
connect
(
**
conf
)
@staticmethod
def
LocalRank
():
...
...
@@ -196,3 +212,9 @@ class ConnList:
return
pymysql
.
connect
(
str
(
conf
[
'host'
]),
conf
[
'user'
],
conf
[
'password'
],
conf
[
'db_name'
],
charset
=
'utf8'
)
@staticmethod
def
handle_sql
(
db
,
col
,
sql_str
):
results
=
DBHandler
.
read
(
db
=
db
,
sql
=
sql_str
)
result_dict
=
super
()
.
result_to_dict
(
col
,
results
)
return
result_dict
\ No newline at end of file
config/db.py
View file @
5107ec0e
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import
sys
def
get_env
():
if
sys
.
platform
in
(
'darwin'
,
'win32'
):
return
'test'
else
:
return
'produce'
ENV
=
get_env
()
def
get_mysql_conf
(
db
):
if
ENV
==
'produce'
:
user
,
psd
=
'Usorder'
,
'OdsLssy2@@!!@$#yy2'
host
=
'business-master.ichunt.db'
else
:
host
=
'192.168.1.252'
user
,
psd
=
'liexin'
,
'liexin#zsyM'
conf
=
{
'host'
:
host
,
'port'
:
3306
,
'user'
:
user
,
'password'
:
psd
,
'db'
:
db
,
'charset'
:
'utf8'
}
return
conf
dashboard_server
=
{
'host'
:
'localhost'
,
...
...
extract/ex_dashboard.py
View file @
5107ec0e
...
...
@@ -8,22 +8,22 @@ 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
[
"hao@ichunt.com"
]
"""
汇总订单数据
...
...
extract/ex_order.py
View file @
5107ec0e
This diff is collapsed.
Click to expand it.
extract/ex_sku_expose.py
View file @
5107ec0e
...
...
@@ -178,7 +178,7 @@ class ExSkuExpose(Base):
'o.order_source not like
\'
%
pf=-1
%
\'
'
,
'o.order_source like
\'
%
search
%
\'
'
]}
ex_order
=
ExOrder
(
'料号明细'
)
data
=
ex_order
.
order_items
(
where
)
#
data = ex_order.order_items(where)
# 遍历订单数据
# for row in data:
...
...
extract/ex_user.py
View file @
5107ec0e
...
...
@@ -15,7 +15,8 @@ class ExUser(Base):
col_str
=
super
()
.
col_to_str
(
col
)
# 用户数据库
db
=
ConnList
.
Order
()
# db = ConnList.Order()
db
=
ConnList
.
LxDb
()
start_time
=
condition
[
'start_time'
]
end_time
=
condition
[
'end_time'
]
con_str
=
super
()
.
condition_to_str
(
condition
[
'condition'
])
...
...
@@ -47,7 +48,7 @@ class ExUser(Base):
col_str
=
super
()
.
col_to_str
(
col
)
# 用户数据库
db
=
ConnList
.
Order
()
db
=
ConnList
.
LxDb
()
start_time
=
condition
[
'start_time'
]
end_time
=
condition
[
'end_time'
]
con_str
=
super
()
.
condition_to_str
(
condition
[
'condition'
])
...
...
@@ -76,7 +77,7 @@ class ExUser(Base):
col_str
=
super
()
.
col_to_str
(
col
)
# 用户数据库
db
=
ConnList
.
Order
()
db
=
ConnList
.
LxDb
()
start_time
=
condition
[
'start_time'
]
end_time
=
condition
[
'end_time'
]
con_str
=
super
()
.
condition_to_str
(
condition
[
'condition'
])
...
...
@@ -288,7 +289,8 @@ class ExUser(Base):
col_str
=
super
()
.
col_to_str
(
col
)
# 用户数据库
db
=
ConnList
.
Order
()
# db = ConnList.Order()
db
=
ConnList
.
LxDb
()
sql
=
"SELECT
%
s
\
FROM lie_test_ip"
\
...
...
pipeline/pi_daily.py
View file @
5107ec0e
...
...
@@ -582,11 +582,12 @@ class PiDaily:
start_time
=
0
end_time
=
DateHandler
.
now_datetime
()
db
=
ConnList
.
Order
()
# db = ConnList.Order()
lx_order_db
=
ConnList
.
LxOrderDb
()
wr_db
=
ConnList
.
WrCrm
()
user
=
ExCrm
(
''
)
.
crm_user
(
start_time
,
end_time
)
ts_user
=
TsCrm
(
db
,
wr_db
,
user
)
ts_user
=
TsCrm
(
lx_order_
db
,
wr_db
,
user
)
print
(
len
(
user
))
ts_user
.
is_order
()
...
...
translate/ts_user.py
View file @
5107ec0e
...
...
@@ -155,7 +155,7 @@ class TsUser(TsBase):
new_paid_amount
=
0
old_amount
=
0
old_paid_amount
=
0
db
=
ConnList
.
Order
()
db
=
ConnList
.
LxOrderDb
()
for
row
in
self
.
data
:
user_id
=
row
[
'user_id'
]
...
...
utils/msg_handler.py
View file @
5107ec0e
...
...
@@ -26,8 +26,10 @@ class MsgHandler:
"content"
:
msg
}
}
res
=
requests
.
post
(
robot_api
+
robot
,
json
=
data
)
print
(
res
)
# todo: 将注释改回来
print
(
"send_dd_msg"
,
data
)
# res = requests.post(robot_api + robot, json=data)
# print(res)
@staticmethod
def
send_point_dd_msg
(
msg
,
robot_api
):
...
...
@@ -37,8 +39,10 @@ class MsgHandler:
"content"
:
msg
}
}
res
=
requests
.
post
(
robot_api
,
json
=
data
)
print
(
res
)
# todo: 将注释改回来
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