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

refactor(advert_cost): 重构广告费用计算逻辑

-增加对美国站点的支持
- 优化日本站点的数据处理方式- 添加默认值处理,避免空值导致的错误
- 修复花费金额的数据类型问题
parent 9e9ce32b
...@@ -117,12 +117,17 @@ class AdvertCost(AutoInterface): ...@@ -117,12 +117,17 @@ class AdvertCost(AutoInterface):
data = pd.read_excel(self.result_file_name, keep_default_na=False, na_values=[]) data = pd.read_excel(self.result_file_name, keep_default_na=False, na_values=[])
for _, item_row in data.iterrows(): for _, item_row in data.iterrows():
if self.country == "US":
asin = item_row.get('Products', '').split("-")[0] asin = item_row.get('Products', '').split("-")[0]
spend = item_row.get('Spend(USD)', ''), # 金额 spend = item_row.get('Spend(USD)', 0.00), # 金额
elif self.country == "JP":
if self.country == 'JP':
asin = item_row.get('商品', '').split("-")[0] asin = item_row.get('商品', '').split("-")[0]
spend = item_row.get('花费(JPY)', ''), # 金额 spend = item_row.get('花费(JPY)', 0.00), # 金额
if isinstance(spend, tuple):
spend = float(spend[0])
else:
asin = ''
spend = 0.00
push_data = { push_data = {
'asin': asin, # ASIN 'asin': asin, # ASIN
......
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