Browse Source

胡松修改代码,每天凌晨3点05分入库order表

zhengwangeng 4 years ago
parent
commit
be8aab67f6
1 changed files with 15 additions and 9 deletions
  1. 15 9
      dgp/get_order_daily.py

+ 15 - 9
dgp/get_order_daily.py

@@ -3,7 +3,7 @@
 """
 Created on Mon May 18 13:13:00 2020
 @author: chencong
-## amend1  20200925 11:39:00
+## amend1  20200927 11:39:00
 ## amend2  
 
 """
@@ -545,15 +545,22 @@ def mysql_insert_order(data):
     cursor = db.cursor()   
     #sql = 'insert ignore into quchen_text.order_daily (amount,channel,channel_id,date,from_novel,order_id,order_time,platform,reg_time,stage,user_id) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);'
     #sql = "update quchen_text.order set amount =%s where platform='掌中云' and order_id =%s"
-    sql = 'replace into quchen_text.order_daily (amount,channel,channel_id,date,from_novel,order_id,order_time,platform,reg_time,stage,user_id) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);'
-
+    sql1 = 'replace into quchen_text.order_daily (amount,channel,channel_id,date,from_novel,order_id,order_time,platform,reg_time,stage,user_id) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);'
+    sql2 = 'replace into quchen_text.order(amount,channel,channel_id,date,from_novel,order_id,order_time,platform,reg_time,stage,user_id) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);'
+    try:
+        cursor.executemany(sql1,data)
+        db.commit()
+        print('access insert order_daily',len(data))
+    except:
+        db.rollback()
+        print('defeat order_daily')
     try:
-        cursor.executemany(sql,data)
+        cursor.executemany(sql2,data)
         db.commit()
         print('access insert order',len(data))
     except:
         db.rollback()
-        print('defeat')
+        print('defeat order')
 
 
 
@@ -561,8 +568,8 @@ def start_all_job():
     request_time_stamp = time.time()
     st_unix = int((request_time_stamp+8*3600)//86400*86400-8*3600-86400) 
     et_unix = int((request_time_stamp+8*3600)//86400*86400-8*3600)
-    st_dt = time.strftime("%Y-%m-%dT%H:%M:%S",time.localtime(st_unix))+'+08:00'
-    et_dt = time.strftime("%Y-%m-%dT%H:%M:%S",time.localtime(et_unix))+'+08:00'
+    st_dt = time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime(st_unix)) + '+08:00'
+    et_dt = time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime(et_unix)) + '+08:00'
     get_yuewen_order(st_unix,et_unix)
     get_ysg_order(st_unix,et_unix)
     get_zhangdu_order(st_unix,et_unix)  
@@ -571,7 +578,7 @@ def start_all_job():
 
 
 
-start_job_time = '2020-09-26 03:05:00'
+start_job_time = '2020-09-27 03:05:00'
 
 
 if __name__ == '__main__':
@@ -579,4 +586,3 @@ if __name__ == '__main__':
     scheduler.add_job(start_all_job, 'interval',days=1,start_date=start_job_time)
     scheduler.start()
 
-