Commit 3697aaed by 刘豪

update new mysql db

parent 0b337ed6
...@@ -7,23 +7,23 @@ class ExDashboard(Base): ...@@ -7,23 +7,23 @@ class ExDashboard(Base):
def email_list(self, condition): def email_list(self, condition):
# 筛选字段 # # 筛选字段
con_str = super().condition_to_str(condition['condition']) # con_str = super().condition_to_str(condition['condition'])
#
# 订单数据库 # # 订单数据库
db = ConnList.Dashboard() # db = ConnList.Dashboard()
sql = "SELECT email \ # sql = "SELECT email \
FROM \ # FROM \
lie_email_list \ # lie_email_list \
WHERE %s" \ # WHERE %s" \
% con_str # % con_str
results = DBHandler.read(db=db, sql=sql) # results = DBHandler.read(db=db, sql=sql)
#
# 结果格式转换为字典 # # 结果格式转换为字典
final_result = super().result_to_list(results) # final_result = super().result_to_list(results)
print('final_result', len(final_result)) # print('final_result', len(final_result))
# return final_result
return final_result return ["hao@ichunt.com"]
""" """
汇总订单数据 汇总订单数据
......
...@@ -123,10 +123,9 @@ class ExOrder(Base): ...@@ -123,10 +123,9 @@ class ExOrder(Base):
def order_items(self, condition): 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.status as items_status',
'i.canal', 'i.supplier_name', 'i.supplier_id', 'i.brand_id', 'i.goods_name', 'i.brand_name', '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.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', 'o.sale_id', 'o.order_source', 'o.order_source', 'o.cancel_reason',
# 'u.user_id', 'u.mobile', 'u.email', # 'u.user_id', 'u.mobile', 'u.email',
...@@ -154,11 +153,45 @@ class ExOrder(Base): ...@@ -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" % ( 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) 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) 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] 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_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_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} 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"]))] 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 return final_result
""" """
......
...@@ -26,8 +26,8 @@ class MsgHandler: ...@@ -26,8 +26,8 @@ class MsgHandler:
"content": msg "content": msg
} }
} }
# print("send_dd_msg", data) print("send_dd_msg", data)
res = requests.post(robot_api + robot, json=data) # res = requests.post(robot_api + robot, json=data)
# print(res) # print(res)
@staticmethod @staticmethod
...@@ -38,8 +38,8 @@ class MsgHandler: ...@@ -38,8 +38,8 @@ class MsgHandler:
"content": msg "content": msg
} }
} }
# print("send_point_dd_msg", data) print("send_point_dd_msg", data)
res = requests.post(robot_api, json=data) # res = requests.post(robot_api, json=data)
# print(res) # print(res)
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment