Files
2026-05-14 12:14:23 +08:00

64 lines
1.8 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from __future__ import annotations
from dataclasses import dataclass
from datetime import date
PRIMARY_FIELD_NAME = "货品编码"
PRIMARY_FIELD_SOURCE = "统一规格编码"
@dataclass(frozen=True)
class BrandSyncTarget:
brand_name: str
table_name: str
warehouse_keys: tuple[int, ...]
@dataclass(frozen=True)
class FieldSpec:
feishu_name: str
source_name: str
field_type: int
formatter: str | None = None
scale: int | None = None
BRAND_SYNC_TARGETS = [
BrandSyncTarget(brand_name="羽心堂", table_name="羽心堂渠道库存-9:30和20:00", warehouse_keys=(2, 3, 7, 13)),
]
def month_sales_field_name(month_offset: int, today: date | None = None) -> str:
current = today or date.today()
month_index = current.year * 12 + current.month - 1 - month_offset
year = month_index // 12
month = month_index % 12 + 1
return f"{year}{month:02d}销售数量"
FIELD_SPECS = [
FieldSpec("货品名称", "商品名称", 1),
FieldSpec("分类", "一级分类", 1),
FieldSpec("条形码", "条形码", 1),
FieldSpec("零售价", "零售价", 2, "0.00", 2),
FieldSpec("渠道锁库库存", "可用总库存", 2, "0", 0),
FieldSpec("全渠道总库存", "总库存", 2, "0", 0),
FieldSpec("品牌", "品牌名称", 1),
FieldSpec("产品类别", "货品简称", 1),
]
LEGACY_NAME_MAP = {
"品牌名称": "品牌",
"一级分类": "分类",
"货品简称": "产品类别",
"商品名称": "货品名称",
"店铺名称": "店铺名称",
"店铺挂单量": "店铺可用库存",
"可用总库存": "渠道锁库库存",
"本月销售数量": month_sales_field_name(0),
"上月销售数量": month_sales_field_name(1),
"上上月销售数量": month_sales_field_name(2),
"统一规格编码": PRIMARY_FIELD_NAME,
}