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

feat(spa): 添加发票PDF下载功能并优化数据处理- 针对日本、德国、英国、法国和加拿大站点增加发票PDF下载功能-...

feat(spa): 添加发票PDF下载功能并优化数据处理- 针对日本、德国、英国、法国和加拿大站点增加发票PDF下载功能- 自动创建spa_pdf目录用于存储下载的PDF文件- 实现PDF文件从默认位置移动到指定spa_pdf目录的逻辑
- 优化数据提取逻辑,确保原始余额数值正确解析
- 移除代码中多余的空行,提升代码整洁度
- 保留原有报表下载功能及相关点击操作逻辑
parent 5637b727
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
*.xls *.xls
return_goods return_goods
spa spa
spa_pdf
refund refund
*.xlsx *.xlsx
build build
......
...@@ -45,6 +45,21 @@ class Spa(AutoInterface): ...@@ -45,6 +45,21 @@ class Spa(AutoInterface):
# 点击选项卡 # 点击选项卡
self.page.ele("#a-autoid-2-announce").click() self.page.ele("#a-autoid-2-announce").click()
self.page.wait(2) self.page.wait(2)
# 点击下载pdf 只针对-> 日本,德国,英国,法国,加拿大
if self.country in ["JP", "DE", "UK", "FR", "CA"]:
file.make_dir('spa_pdf')
self.page.ele('xpath://li[a[contains(text(), "Invoice as a PDF")]]/a').click()
self.page.wait(2)
# 移动文件到pdf文件夹
src_file = f'Amazon_Invoice_{invoice_id}.pdf'
save_file = os.path.join(os.getcwd(), "spa_pdf", src_file)
file.move_file(src_file, save_file)
self.page.ele("#a-autoid-2-announce").click()
self.page.wait(2)
# 点击下载报表选项 # 点击下载报表选项
# self.page.ele(f"#invoiceDownloads-{invoice_id}_2").click() # self.page.ele(f"#invoiceDownloads-{invoice_id}_2").click()
self.page.ele('xpath://li[a[contains(text(), "Backup report")]]/a').click() self.page.ele('xpath://li[a[contains(text(), "Backup report")]]/a').click()
...@@ -277,9 +292,9 @@ class Spa(AutoInterface): ...@@ -277,9 +292,9 @@ class Spa(AutoInterface):
for _, item_row in df.iterrows(): for _, item_row in df.iterrows():
original_balance = item_row.get('Original balance', 0.0) original_balance = item_row.get('Original balance', 0.0)
push_data = { push_data = {
'invoice_id': item_row.get("Invoice ID",""), # 获取发票 ID 'invoice_id': item_row.get("Invoice ID", ""), # 获取发票 ID
'invoice_date': item_row.get("Invoice date", ""), # 发票日期 'invoice_date': item_row.get("Invoice date", ""), # 发票日期
'original_balance': helper.extract_numeric_value(original_balance,self.country), # spa费用金额 'original_balance': helper.extract_numeric_value(original_balance, self.country), # spa费用金额
'funding_type': item_row.get('Funding Type', ""), # 资金类型 'funding_type': item_row.get('Funding Type', ""), # 资金类型
'shop_code': self.shop_code, # 店铺code 'shop_code': self.shop_code, # 店铺code
} }
...@@ -375,7 +390,6 @@ class Spa(AutoInterface): ...@@ -375,7 +390,6 @@ class Spa(AutoInterface):
self.logger.info(f"所有sheet的总行数: {total_rows}") self.logger.info(f"所有sheet的总行数: {total_rows}")
self.logger.info(f"所有sheet的总金额: {total_amount}") self.logger.info(f"所有sheet的总金额: {total_amount}")
def run(self, file_name: str): def run(self, file_name: str):
# 获取数据 # 获取数据
relation_data = api.sku_relations(self.country) # 获取 ASIN 与 SKU 的对应关系数据 relation_data = api.sku_relations(self.country) # 获取 ASIN 与 SKU 的对应关系数据
......
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