ck 3 anni fa
parent
commit
c31b49515a
1 ha cambiato i file con 11 aggiunte e 7 eliminazioni
  1. 11 7
      app/etl/sync_to_ck_task.py

+ 11 - 7
app/etl/sync_to_ck_task.py

@@ -11,24 +11,28 @@ dt = DateUtils()
 
 def order_sync_ck(ymd):
     log.debug("sync order")
-    col = "date,stage,platform,channel,channel_id,user_id,order_time,reg_time,amount,from_novel,order_id,status"
-    sql ="select * from ods_order where date='{}'".format(ymd)
+    col = """date,stage,platform,channel,channel_id,user_id,order_time,reg_time,amount,from_novel,order_id,status,
+    platform_order_id,platform_user_id,wechat_app_id,book_tags,order_type"""
+    sql =f"""select  DATE_FORMAT(date,"%Y-%m-%d") date,
+            stage,platform,channel,channel_id,user_id,order_time,reg_time,amount,from_novel,order_id,status,
+    ifnull(platform_order_id,''),
+    ifnull(platform_user_id,''),
+    ifnull(wechat_app_id,''),
+    ifnull(book_tags,''),
+    ifnull(order_type,1) 
+    from ods_order where date='{ymd}'"""
     data = db.quchen_text.getData(sql)
-
     data1 = []
     for x in data:
         li = list(x)
-
         li[0]=str(li[0])
         li[3]='' if li[3]==None else li[3].replace(' ','')
         li[5]='' if li[5]==None else li[5]
         li[6]=str(li[6])
         li[7]='0000-00-00 00:00:00' if li[7]==None else str(li[7])
         li[9]='' if li[9]==None else li[9]
-
         data1.append(tuple(li))
 
-
     # 删除分区
     ck.execute("alter table order drop  partition '{}' ".format(ymd))
     ck.insertMany("order", col, tuple(data1))
@@ -70,7 +74,7 @@ def campaign_vx():
 
 
 if __name__ == '__main__':
-    order_sync_ck('2021-05-06')
+    order_sync_ck('2021-06-03')
     # dw_order_channel_cost_sync_ck(dt.get_n_days(-2))
     # for i in dt.getDateLists('2019-03-18','2020-12-17'):
     # #     order(i)