renyupeng 9 mesi fa
parent
commit
4de0f0bb99
1 ha cambiato i file con 7 aggiunte e 7 eliminazioni
  1. 7 7
      ETL/KuaishouRuleOrderDataTherad.py

+ 7 - 7
ETL/KuaishouRuleOrderDataTherad.py

@@ -20,8 +20,8 @@ class KuaishouRuleOrderData:
 
     def KuaishouRuleOrderDataHandler(self,database):
         sql = """
-        select item_id from {database}.kuaishou_supply_chain where stat_date='{date}'
-group by item_id
+        select promoter_id from {database}.kuaishou_supply_chain where stat_date='{date}'
+group by promoter_id
         """.format(date=self.date,database=database)
         results = MysqlProUtils().QueryAll(sql=sql)
         items_per_thread = len(results)
@@ -37,7 +37,7 @@ group by item_id
 
     def Theard_hander(self, data,database):
         for result in data:
-            item_id = result[0]
+            promoter_id = result[0].decode('utf-8')
             handler_sql = """
                         replace into {database}.kuaishou_rule_order_data(relate_id, item_id, item_title, promoter_id, promoter_name,
                                                           item_create_id, item_create_name, promoter_create_id,
@@ -64,7 +64,7 @@ group by item_id
                        count(distinct case when order_status!=80 then oid  end) as valid_order_num
                   from {database}.kuaishou_supply_chain
                   where stat_date <= {stat_date}
-                    and item_id = {item_id}
+                    and promoter_id = {promoter_id}
                   group by promoter_id, item_id) a
                      left join
                  (select item_id,
@@ -77,7 +77,7 @@ group by item_id
                          collect_sample_name,
                          create_time
                   from {database}.kuaishou_item_collect_samples
-                  where item_id = {item_id}) b
+                  where promoter_id = {promoter_id}) b
                  on a.promoter_id = b.promoter_id and a.item_id = b.item_id
                      left join (select item_id, relate_id, user_id, user_name, item_title
                                 from {database}.kuaishou_item_list
@@ -89,10 +89,10 @@ group by item_id
                        count(distinct case when order_status!=80 then oid  end) as valid_order_num
                   from {database}.kuaishou_supply_chain
                   where stat_date <= date_format(date_sub('{stat_date}', interval 1 day), '%Y%m%d')
-                    and item_id = {item_id}
+                    and promoter_id = {promoter_id}
                   group by promoter_id, item_id) e
                                on a.promoter_id = e.promoter_id and a.item_id = e.item_id
-                        """.format(stat_date=self.stat_date, item_id=item_id,database=database)
+                        """.format(stat_date=self.stat_date, promoter_id=promoter_id,database=database)
             try:
                 print(handler_sql)
                 MysqlProUtils().Operate(sql=handler_sql)