Commit af4e006d authored by 邱阿朋's avatar 邱阿朋

refactor(vc): 重构广告相关功能的域名处理逻辑

- 修改域名切换逻辑,统一使用 switch_domain 方法
- 在广告成本页面中替换域名前缀
- 优化产品销售数据处理,统一字段名
- 删除未使用的 switch_ad_domain 函数
parent 905751b2
......@@ -22,13 +22,6 @@ def switch_domain(country):
return domain
def switch_ad_domain(country):
domain = "https://advertising.amazon.com/"
if country == "JP":
domain = "https://advertising.amazon.co.jp/"
return domain
def domain_page(logger,page, country):
url = switch_domain(country)
page.get(url)
......
......@@ -76,7 +76,8 @@ class AdvertCost(AutoInterface):
entity_id = info['id'][1:]
host = domain.switch_ad_domain(self.country)
# 替换域名前缀
host = domain.switch_domain(self.country).replace("vendorcentral", "advertising")
self.page.get(f"{host}cm/products?entityId=ENTITY{entity_id}")
# 判断是否正常
......
......@@ -67,6 +67,11 @@ class ProductSales(AutoInterface):
rabbit.connect(queue='product_sales', routing_key='product_sales', exchange='reports')
df = pd.read_excel(self.result_file_name, header=1)
# 统一字段名(只处理 Ordered Revenue 大小写问题)
if 'Ordered Revenue' not in df.columns and 'Ordered revenue' in df.columns:
df.rename(columns={'Ordered revenue': 'Ordered Revenue'}, inplace=True)
# 过滤掉 Ordered Revenue <= 0 的数据
data = df[df['Ordered Revenue'] > 0]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment