huangyifan 1 년 전
부모
커밋
2e1b9602c0
3개의 변경된 파일14개의 추가작업 그리고 5개의 파일을 삭제
  1. 9 2
      sync_amz_data/public/sp_api_client.py
  2. 1 1
      sync_get_open_listing_data.py
  3. 4 2
      sync_get_order_data.py

+ 9 - 2
sync_amz_data/public/sp_api_client.py

@@ -559,7 +559,14 @@ class SpApiRequest:
             time.sleep(5)
             conn = self.mysql_connect_auth_lst()
             cursor = conn.cursor()
-        query_judge = f"""select count(*) from asj_ads.SalesAndTrafficByAsin where data_date='{shopReportday}' and countryCode='{countryCode}'"""
+        if level == 'SKU':
+            query_judge = f"""select count(*) from asj_ads.SalesAndTrafficByAsin where data_date='{shopReportday}' and countryCode='{countryCode}' and childAsin is not Null and sku is not Null"""
+        elif level == 'CHILD':
+            query_judge = f"""select count(*) from asj_ads.SalesAndTrafficByAsin where data_date='{shopReportday}' and countryCode='{countryCode}' and sku is null"""
+        elif level == 'PARENT':
+            query_judge = f"""select count(*) from asj_ads.SalesAndTrafficByAsin where data_date='{shopReportday}' and countryCode='{countryCode}' and sku is null and childAsin is null"""
+        else:
+            return ''
         print(query_judge)
         cursor.execute(query_judge)
         rel = cursor.fetchall()
@@ -1094,7 +1101,7 @@ class SpApiRequest:
 if __name__ == '__main__':
     for days in range(35,45):
         SpApiRequest.get_allShops("GET_SALES_AND_TRAFFIC_REPORT",days=-days,**{"level":"SKU"})
-    # SpApiRequest.listing_infoTable()
+    SpApiRequest.listing_infoTable()
     # rel = SpApiRequest.get_catelog(account_name='ANLAPUS_US',country=Marketplaces.US,asin='B0BVXB4KT9')
     # print(rel)
 

+ 1 - 1
sync_get_open_listing_data.py

@@ -14,7 +14,7 @@ def func_run():
         sp_api_client.SpApiRequest.listing_infoTable()
     except:
         sp_api_client.SpApiRequest.listing_infoTable()
-    # func_run()
+# func_run()
 
 
 

+ 4 - 2
sync_get_order_data.py

@@ -6,13 +6,15 @@ from apscheduler.schedulers.blocking import BlockingScheduler
 from sync_amz_data.public import sp_api_client
 def func_run():
     try:
-        for days in (-2,-3):
+        for days in (-2,-3,-4):
             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):
+        for days in range(-2,-3,-4):
            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)