瀏覽代碼

Merge branch 'yifan' of ASJ_ADS/sync_amz_data into master

yifan_huang96 1 年之前
父節點
當前提交
a73592e1cd
共有 2 個文件被更改,包括 15 次插入4 次删除
  1. 13 4
      sync_amz_data/public/sp_api_client.py
  2. 2 0
      sync_get_open_listing_data.py

+ 13 - 4
sync_amz_data/public/sp_api_client.py

@@ -696,7 +696,7 @@ class SpApiRequest:
             time.sleep(5)
             conn = self.mysql_connect_auth_lst()
             cursor = conn.cursor()
-        query_judge = f"""select count(*) from asj_ads.orderReport where ReportDate='{shopReportday}' and country_code='{countryCode}'"""
+        query_judge = f"""select count(*) from asj_ads.orderReport_ where ReportDate='{shopReportday}' and country_code='{countryCode}'"""
         print(query_judge)
         cursor.execute(query_judge)
         rel = cursor.fetchall()
@@ -761,7 +761,16 @@ class SpApiRequest:
             cursor = conn.cursor()
         # print(list(conn.query("select * from amz_sp_api.orderReport")))
         sql = f"""
-            insert into asj_ads.orderReport
+            insert into asj_ads.orderReport_(`amazon-order-id`, `merchant-order-id`, `purchase-date`, `last-updated-date`, `order-status`,
+                           `fulfillment-channel`, `sales-channel`, `order-channel`, `ship-service-level`,
+                           `product-name`,
+                           `sku`, `asin`, `item-status`, `quantity`, `currency`, `item-price`, `item-tax`,
+                           `shipping-price`,
+                           `shipping-tax`, `gift-wrap-price`, `gift-wrap-tax`, `item-promotion-discount`,
+                           `ship-promotion-discount`, `ship-city`, `ship-state`, `ship-postal-code`, `ship-country`,
+                           `promotion-ids`, `is-business-order`, `purchase-order-number`, `price-designation`,
+                           `ReportDate`,
+                           `timezone`, `seller_id`, `country_code`,`insert_time`)
             values (%s,%s,%s,%s,%s,%s,%s, %s,%s,%s,%s,%s,%s,%s, %s,%s,%s,%s,%s,%s,%s, %s,%s,%s,%s,%s,%s,%s, %s,%s,%s,%s,%s,%s,%s,%s)
         """  # ok
         try:
@@ -1083,8 +1092,8 @@ class SpApiRequest:
             ## sp_api.GET_FLAT_FILE_OPEN_LISTINGS_DATA(auth_conn, seller_id)
 
 if __name__ == '__main__':
-    for days in range(2,35):
-        SpApiRequest.get_allShops("GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL",days=-days,**{"level":"SKU"})
+    for days in range(35,45):
+        SpApiRequest.get_allShops("GET_SALES_AND_TRAFFIC_REPORT",days=-days,**{"level":"SKU"})
     # SpApiRequest.listing_infoTable()
     # rel = SpApiRequest.get_catelog(account_name='ANLAPUS_US',country=Marketplaces.US,asin='B0BVXB4KT9')
     # print(rel)

+ 2 - 0
sync_get_open_listing_data.py

@@ -8,6 +8,8 @@ def func_run():
     except:
         sp_api_client.SpApiRequest.get_allShops("GET_FLAT_FILE_OPEN_LISTINGS_DATA")
     print("="*40)
+    print("="*40)
+    print("="*40)
     try:
         sp_api_client.SpApiRequest.listing_infoTable()
     except: