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