Explorar o código

Merge branch 'yifan' of ASJ_ADS/sync_amz_data into master

yifan_huang96 hai 1 ano
pai
achega
acb925bc5f
Modificáronse 1 ficheiros con 7 adicións e 5 borrados
  1. 7 5
      sync_amz_data/public/sp_api_client.py

+ 7 - 5
sync_amz_data/public/sp_api_client.py

@@ -282,12 +282,14 @@ class SpApiRequest:
     def fba_inventorySQL(self,conn,seller_id):
         cursor = conn.cursor()
         # 执行语句
-        cursor.execute(f"""select asin,sku,seller_id,marketplace_id,country_code,quantity from 
-                                                (select * from asj_ads.seller_listings order by update_datetime desc) as t
-                                               where seller_id='{seller_id}' and marketplace_id='{self.marketplace.marketplace_id}'
+        cursor.execute(f""" select asin,sku,seller_id,marketplace_id,country_code,quantity,fulfillment_channel 
+                                from 
+                                    (select asin,sku,seller_id,marketplace_id,country_code,quantity,fulfillment_channel,
+                                        ROW_NUMBER() over(partition by asin,sku,seller_id,marketplace_id,country_code order by update_datetime desc) as row_
+                                        from asj_ads.seller_listings) as t
+                            where row_=1 and seller_id='{seller_id}' and marketplace_id='{self.marketplace.marketplace_id}'
                                                and fulfillment_channel='FBA'
-                                               group by asin,sku,seller_id,marketplace_id,country_code,quantity
-                                                """)
+                                                """)#,quantity
         query_ = cursor.fetchall()
         col_name = [i[0] for i in cursor.description]
         df_datatable = pd.DataFrame(query_, columns=col_name)