Browse Source

report_push: 完善sql:

Signed-off-by: Binren Zhnag <zhangbr@elab-plus.com>
Binren Zhnag 5 years ago
parent
commit
865debda5b
1 changed files with 4 additions and 11 deletions
  1. 4 11
      report_push.py

+ 4 - 11
report_push.py

@@ -185,7 +185,7 @@ class ReportPush(object):
         SELECT
         a.house_id,
         a.house_name,
-        SUM(a.pv),
+        ifnull(SUM(a.pv), 0),
         SUM(a.uv),
         SUM(a.new_cust_num),
         SUM(a.wx_num)
@@ -266,7 +266,7 @@ class ReportPush(object):
                 a.brand_id,
                 a.house_id,
                 a.house_name,
-                SUM(a.pv),
+                ifnull(SUM(a.pv), 0),
                 SUM(a.uv),
                 SUM(a.new_cust),
                 SUM(a.shouquan_cust)
@@ -484,28 +484,21 @@ class ReportPush(object):
         :param task_key:
         :return:
         """
-        message = []
+        result = {}
         try:
             # 根据任务key获取需要推送的客户以及可以的权限
-            result = {}
             customers = self.db.select(self.sql_4, [task_key])
             # a.task_key, a.customer_id, b.customer_type, b.`name`, b.mail, GROUP_CONCAT(c.house_or_brand_id)
             time_range = self.get_time_range(task_key)
             all_time_rang = self.get_time_range(4)
             # 有限时间范围内的数据
             xcx_top_data = self.xcx_top(time_range)
-            message.append(1)
             brand_top_data = self.brand_top(time_range)
-            message.append(2)
             customer_channel_details_data = self.customer_channel_details(time_range)
-            message.append(3)
             brand_customer_channel_details = self.brand_customer_channel_details(time_range)
-            message.append(4)
             # 所有历史数据
             xcx_top_data_all = self.xcx_top(all_time_rang)
-            message.append(5)
             brand_top_data_all = self.brand_top(all_time_rang)
-            message.append(5)
             for customer in customers:
                 customer_data = {}
                 name = customer[3]
@@ -654,7 +647,7 @@ class ReportPush(object):
         except:
             pass
         finally:
-            return message
+            return result
 
     def sort(self, data, idnex):
         data.sort(key=lambda obj: obj[idnex])