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

feat(return_goods): 优化退款数据处理

- 在 item_data_result 中增加 'Reason' 列,以便在结果中包含退货原因
- 在写入数据库时添加 'Reason' 字段,将退货原因保存到数据库中
- 优化代码格式,调整部分缩进和空格
parent b477d522
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
# coding: utf-8
# 导出退款记录
import os
import time
from datetime import datetime
import pandas as pd
......@@ -74,7 +75,7 @@ def main():
# 下载退货详情表格读取数据
item_data = export_item_read_data(return_id)
# 按 'Purchase order' 和 'ASIN' 分组,并对 'Quantity' 和 Total amount 进行求和
item_data_result = item_data.groupby(['Purchase order', 'ASIN'], as_index=False).agg({
item_data_result = item_data.groupby(['Purchase order', 'ASIN', 'Reason'], as_index=False).agg({
'Quantity': 'sum',
'Total amount': 'sum',
})
......@@ -92,6 +93,7 @@ def main():
'Quantity': item_row.get('Quantity', 0),
# 替换回会数量和金额为详情里面的值
'Return quantity': item_row.get('Quantity', 0), # 替换回会数量
'Reason': item_row.get('Reason', ""),
'Total cost': item_row.get('Total amount', 0), # 替换金额
'Group Name': relation.get("name", ""),
'Group Code': relation.get("code", ""),
......@@ -130,7 +132,7 @@ def push_data_queue(file_name):
'sku_quantity': item_row.get('Quantity', 0), # 退回数量
'sku_amount': item_row.get('Total amount', 0), # Total cost
'currency': item_row.get('Currency code', ''), # Currency code
'data_date': str(item_row.get('Return Date','')), # Return Date
'data_date': str(item_row.get('Return Date', '')), # Return Date
'erp_sku': item_row.get("erp_sku", ''), # ERP SKU # SKU1匹配
'shop_code': shop_code, # 店铺code
'supplier_code': item_row.get('Vendor code', ''), # 供应商编码
......
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