Files
xin-procurement/web/domain/iPurchaseOrder.ts
T
2026-09-07 23:27:56 +08:00

233 lines
7.1 KiB
TypeScript
Raw 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.
/** 采购明细门店单元格(溯源订货明细) */
export interface IPurchaseStoreCell {
order_item_id: number;
store_id: number;
quantity: number;
weight: number;
/** 金额 = 称重>0 ? 称重×单价 : 数量×单价(单价 = 成本/包规) */
amount: number;
}
/** 采购明细行(商品维度聚合,行 × 门店列矩阵) */
export interface IPurchaseDetailRow {
product_id: number;
product_name: string;
/** 规格/包规 */
product_spec: string;
unit: string;
supplier_id: number;
supplier?: { id: number; name: string } | null;
/** 市场(取商品档案) */
market?: string;
/** 成本 */
cost_price: number;
/** 合计数量 */
quantity: number;
/** 合计实际称重 */
weight: number;
/** 合计订货金额(Σ明细 amount;单价 = amount÷quantity÷包规数值) */
amount: string;
cells: Record<number, number>;
}
/** 供应商采购明细行(供应商维度聚合,成本口径) */
export interface IPurchaseSupplierItem {
product_id: number;
product_name: string;
/** 规格/包规 */
product_spec: string;
unit: string;
/** 市场(取商品档案) */
market?: string;
/** 成本价 */
cost_price: string;
/** 数量(包数) */
quantity: number;
/** 重量(斤) */
weight: string;
/** 金额 = Σ 数量×成本价 */
amount: string;
}
/** 门店购买详情:新增单品参数 */
export interface PurchaseStoreItemAddParams {
product_id: number;
quantity: number;
weight?: number;
}
/** 门店购买详情:修改单品参数(同商品多笔订单明细时合并到最早一条) */
export interface PurchaseStoreItemUpdateParams {
quantity: number;
price?: number;
weight?: number;
}
/** 采购单 */
export default interface IPurchaseOrder {
id?: number;
purchase_no?: string;
purchase_date?: string;
/** 0进行中 3已完成 */
status?: number;
total_quantity?: string;
total_weight?: string;
estimate_amount?: string;
actual_amount?: string;
/** 应付商品金额 = Σ 已生成门店账单的商品金额(列表接口附;未生成账单为 null) */
bill_product_amount?: string | null;
operator_id?: number;
operator?: { id: number; nickname: string };
remark?: string;
created_at?: string;
}
/** 采购单详情(矩阵数据) */
export interface IPurchaseDetail {
purchase: IPurchaseOrder;
stores: { id: number; name: string }[];
items: IPurchaseDetailRow[];
/** 门店账单(采购单完成后按门店生成) */
bills: IBill[];
/** 单品「已对账」标记的商品ID列表(入库持久化) */
checked_product_ids: number[];
}
/** 门店账单(采购单完成后按门店生成,商品金额为订单汇总快照不可修改) */
export interface IBill {
id: number;
bill_no: string;
purchase_id: number;
store_id: number;
store_name?: string;
bill_date: string;
/** 商品金额(订单商品金额汇总) */
product_amount: string;
/** 配送费(生成账单时填写) */
delivery_fee: string;
box_num: number;
tray_num: number;
/** 周转筐单价(生成时快照) */
box_price: string;
/** 周转托盘单价(生成时快照) */
tray_price: string;
/** 附加金额 = 周转筐×筐单价 + 托盘×托盘单价 */
added_amount: string;
/** 账单总金额 = 商品金额 + 配送费 + 附加金额 + 售后金额 */
total_amount: string;
/** 支付状态:0未支付 1已支付 */
status?: number;
/** 关联支付记录ID(0=未发起支付) */
payment_id?: number;
/** 付款时间(线下收款手动登记) */
paid_at?: string | null;
/** 付款备注(线下收款信息) */
pay_remark?: string;
paid_operator_id?: number;
order_count?: number;
remark?: string;
/** 售后金额(生成账单时按门店填写,可正负,计入总金额) */
after_sale?: string;
created_at?: string;
/** 门店账单列表/详情接口附带 */
store?: { id: number; name: string; address?: string; contact?: string; phone?: string } | null;
purchase?: { id: number; purchase_no: string; purchase_date: string; status?: number } | null;
operator?: { id: number; nickname: string } | null;
paid_operator?: { id: number; nickname: string } | null;
orders_count?: number;
}
/** 账单支付状态映射 */
export const BILL_STATUS_MAP: Record<number, { text: string; color: string }> = {
0: { text: '未支付', color: 'warning' },
1: { text: '已支付', color: 'success' },
};
/** 账单生成预览行(按门店汇总,金额只读) */
export interface IBillPrepareStore {
store_id: number;
store_name: string;
/** 客户等级名(无等级为 null) */
level_name?: string | null;
/** 客户等级上浮比例(售后金额折算用;无等级为 '0' */
level_percent?: string;
order_count: number;
/** 商品金额(订单汇总,不可修改) */
product_amount: string;
/** 周转筐单价(站点配置) */
box_price: string;
/** 周转托盘单价(站点配置) */
tray_price: string;
/** 已生成的账单(未生成为 null) */
bill: IBill | null;
}
/** 账单生成预览(采购单 + 门店行) */
export interface IBillPrepare {
purchase: { id: number; purchase_no: string; status: number };
stores: IBillPrepareStore[];
}
/** 单元格下钻明细行(溯源订货单明细,附订单号/状态/可编辑标记) */
export interface IPurchaseCellItem {
id: number;
order_id: number;
order_no: string;
order_date: string;
/** 订货单状态:0待接单 1已接单 2采购中 3配送中 4已完成 9已取消 */
order_status: number;
product_name: string;
product_spec: string;
unit: string;
supplier_id: number;
supplier?: { id: number; name: string } | null;
/** 等级单价 */
price: string;
cost_price: string;
quantity: number;
weight: string;
/** 金额 = 数量×单价(整数金额返回 number) */
amount: number | string;
remark: string;
/** 首图 */
image?: string;
}
/** 单元格下钻数据(门店 + 商品 + 全部订货明细) */
export interface IPurchaseCell {
store: { id: number; name: string } | null;
product: { id: number; name: string } | null;
items: IPurchaseCellItem[];
}
/** 门店购买详情行(门店采购汇总,按商品聚合) */
export interface IPurchaseStoreItem {
product_id: number;
product_name: string;
/** 规格/包规 */
product_spec: string;
unit: string;
/** 市场(取商品档案) */
market?: string;
/** 单价(每包;多笔单价时为加权平均,保证 单价×数量=预计金额) */
price: string;
/** 数量(包数) */
quantity: number;
/** 预计金额 = Σ 明细 amount */
amount: string;
weight: string;
}
/** 门店购买详情(采购单内某门店的采购汇总) */
export interface IPurchaseStoreSummary {
store: { id: number; name: string } | null;
items: IPurchaseStoreItem[];
}
export const PURCHASE_STATUS_MAP: Record<number, { text: string; color: string }> = {
0: { text: '进行中', color: 'processing' },
3: { text: '已完成', color: 'success' },
};
export type ExportFormat = 'xlsx' | 'pdf';