yumoqing da32159ad9 feat: 供应商和分销商管理模块 (supplychain)
- 7个数据库表: suppliers, supply_contracts, supply_contract_items,
  sub_distributors, distribution_agreements, distribution_agreement_items,
  supplychain_accounting
- CRUD JSON配置 (7个列表 + editable段)
- API端点: create/update/delete (21个) + calculate_accounting + query_discount (2个)
- 前端页面: index.ui + 5个功能页 + menu.ui
- 记账计算: 自动查找有效合同/协议折扣,计算进货金额、分销金额、利润
- 折扣查找优先级: 精确产品 > 产品分类 > 默认折扣
- productid/prodtypeid引用product模块(即将开发)
2026-05-25 15:37:06 +08:00

61 lines
2.1 KiB
Markdown
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.

---
name: supplychain-module
version: 1.0.0
description: 供应商和分销商管理模块 — 供销合同、分销协议、产品折扣及供销记账
trigger_conditions:
- 需要管理供应商信息
- 需要创建供销合同或分销协议
- 需要为产品设置进货或分销折扣
- 需要计算产品销售时的供销记账金额
---
# supplychain 模块技能文档
## 模块概述
supplychain 模块为分销商提供供应链管理功能,包括供应商管理、供销合同管理、二级分销商管理、分销协议管理,以及产品销售时的供销记账金额计算。
## 数据表结构
### 实体表
- **suppliers** — 供应商(基本信息、联系方式、财务信息)
- **supply_contracts** — 供销合同(运营创建,关联供应商,设置有效期)
- **sub_distributors** — 二级分销商(销售创建,基本信息)
- **distribution_agreements** — 分销协议(销售创建,关联二级分销商)
### 关系表
- **supply_contract_items** — 供销合同产品折扣明细(合同下的产品级折扣)
- **distribution_agreement_items** — 分销协议产品折扣明细(协议下的产品级折扣)
- **supplychain_accounting** — 供销记账记录(销售时自动计算)
## 折扣查找优先级
无论是进货折扣还是分销折扣,查找优先级均为:
1. 精确匹配 productid
2. 匹配 prodtypeid产品分类级折扣
3. 使用合同/协议的 default_discount
## API 调用
### 记账计算
```
POST /supplychain/api/calculate_accounting.dspy
Body: {productid, prodtypeid?, quantity, unit_price, sub_distributor_id?, sale_date?, ...}
```
### Python 函数调用
```python
# 在 .dspy 文件中
record = await calculate_sale_accounting(sor, resellerid, productid, quantity, unit_price,
sub_distributor_id, prodtypeid, sale_date, ...)
```
## 注意事项
- productid 和 prodtypeid 引用 product 模块(即将开发)
- 所有数据通过 resellerid 隔离(机构级多租户)
- 合同/协议编号自动生成
- 折扣值范围 0-11.0 表示无折扣)