Browse Source

add a sync file

huangyifan 1 năm trước cách đây
mục cha
commit
69468a157b

+ 4 - 2
sync_amz_data/public/sp_api_client.py

@@ -791,7 +791,7 @@ class SpApiRequest:
     def listing_infoTable(cls):
         conn = SpApiRequest.mysql_connect_auth_lst()
         cursor = conn.cursor()
-        cursor.execute(f"""select seller_id,country_code,asin,title from asj_ads.seller_listings where title is not null and title <>'' and (seller_id,country_code,asin) not in (select seller_id,country_code,asin from asj_ads.Goods where update_time>='{datetime.today().date()}') group by seller_id,title,country_code,asin""")
+        cursor.execute(f"""select seller_id,country_code,asin,title from asj_ads.seller_listings where title is not null and title <>'' and (seller_id,country_code,asin) not in (select seller_id,countryCode,asin from asj_ads.Goods where update_time>='{datetime.today().date()}') group by seller_id,title,country_code,asin""")
         query_ = cursor.fetchall()
         # print(query_)
         col_name = [i[0] for i in cursor.description]
@@ -1015,7 +1015,7 @@ class SpApiRequest:
                 if e.args[0][0]['code']=='InvalidInput':
                     return ''
                 print('first time to try...')
-                time.sleep(5)
+                time.sleep(15)
                 SpApiRequest.data_judge(refresh_token,sp_api, data_type, seller_id, auth_conn,days=days,**a_kw)
             except Exception as e:
                 print(e)
@@ -1071,6 +1071,7 @@ class SpApiRequest:
                         ## sp_api.GET_FLAT_FILE_OPEN_LISTINGS_DATA(auth_conn, seller_id)
                     except Exception as e:
                         print(e)
+                    time.sleep(3.5)
             elif region_circle == 'EU':
                 pass
                 for marketplace in [Marketplaces.DE,Marketplaces.AE, Marketplaces.BE,  Marketplaces.PL,
@@ -1085,6 +1086,7 @@ class SpApiRequest:
                         ## sp_api.GET_FLAT_FILE_OPEN_LISTINGS_DATA(auth_conn, seller_id)
                     except Exception as e:
                         print(e)
+                    time.sleep(3.5)
 
             else:
             # if region_circle not in ['NA','EU']:

+ 1 - 1
sync_get_open_listing_data.py

@@ -17,7 +17,7 @@ def func_run():
 # func_run()
 
 #
-
+#
 if __name__ == '__main__':
     sched = BlockingScheduler()
     sched.add_job(func_run,'cron',hour=4,minute=30,second=0)

+ 2 - 2
sync_get_order_data.py

@@ -6,12 +6,12 @@ from sync_amz_data.settings import MYSQL_AUTH_CONF, MYSQL_DATA_CONF
 from sync_amz_data.public import sp_api_client
 def func_run():
     try:
-        for days in (-2,-3,-4):
+        for days in (-2,-3):
             sp_api_client.SpApiRequest.get_allShops("GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL",days=days,**{})
     except Exception as e:
         print(e)
     try:
-        for days in (-2,-3,-4): #range(-29,-2):#
+        for days in (-2,-3): #range(-29,-2):#
            sp_api_client.SpApiRequest.get_allShops("GET_SALES_AND_TRAFFIC_REPORT",days=days,**{"level":"SKU"})
            sp_api_client.SpApiRequest.get_allShops("GET_SALES_AND_TRAFFIC_REPORT",days=days,**{"level":"PARENT"})
            sp_api_client.SpApiRequest.get_allShops("GET_SALES_AND_TRAFFIC_REPORT",days=days,**{"level":"CHILD"})

+ 33 - 0
sync_listing_order_Retry.py

@@ -0,0 +1,33 @@
+import warnings
+warnings.filterwarnings('ignore')
+from apscheduler.schedulers.blocking import BlockingScheduler
+from sync_amz_data.public import sp_api_client
+def func_run():
+    days = -2
+    try:
+        sp_api_client.SpApiRequest.get_allShops("GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL",days=days,**{})
+    except Exception as e:
+        print(e)
+    try:
+       sp_api_client.SpApiRequest.get_allShops("GET_SALES_AND_TRAFFIC_REPORT",days=days,**{"level":"SKU"})
+       sp_api_client.SpApiRequest.get_allShops("GET_SALES_AND_TRAFFIC_REPORT",days=days,**{"level":"PARENT"})
+       sp_api_client.SpApiRequest.get_allShops("GET_SALES_AND_TRAFFIC_REPORT",days=days,**{"level":"CHILD"})
+    except Exception as e:
+        print(e)
+
+    print("-"*40)
+    try:
+        sp_api_client.SpApiRequest.get_allShops("GET_FLAT_FILE_OPEN_LISTINGS_DATA")
+    except Exception as e:
+        print(e)
+    print("="*40)
+    try:
+        sp_api_client.SpApiRequest.listing_infoTable()
+    except Exception as e:
+        print(e)
+
+#
+if __name__ == '__main__':
+    sched = BlockingScheduler()
+    sched.add_job(func_run,'cron',hour=18,minute=0,second=0)
+    sched.start()