add: recycle product

This commit is contained in:
Timi
2026-11-08 20:06:15 +08:00
parent 585d8956bc
commit ad1787a035
22 changed files with 4284 additions and 8 deletions
+232
View File
@@ -0,0 +1,232 @@
import type { Attachment, Model, PageResult, User } from "timi-web-api";
import type { Customer } from "@/types/Customer";
import type { ProductSkuSpecSnapshot, StockRecord } from "@/types/Product";
/** 回收物与兑换规则的启用状态。配置没有删除,停用使用 INACTIVE。 */
export type RecycleStatus = "ACTIVE" | "INACTIVE";
/** 兑换单状态。 */
export type RecycleExchangeStatus = "PENDING" | "VERIFIED" | "CANCELLED" | "REVOKED";
/** 兑换单操作类型。 */
export type RecycleExchangeActionType = "VERIFY" | "CANCEL" | "REVOKE";
/** 回收物配置。回收物不是退货,不校验客户购买记录,也不累计客户余额。 */
export type RecycleItem = {
storeId?: string;
name: string;
/** 回收计量单位,例如「个」「公斤」 */
unitName: string;
/** 来源产品 ID,仅用于识别,不影响库存 */
productId?: string | null;
/** 来源 SKU ID,填写时必须同时填写其所属 productId */
skuId?: string | null;
status?: RecycleStatus;
remark?: string | null;
/** 来源产品名称,服务端回填,仅展示用 */
sourceProductName?: string | null;
/** 来源 SKU 规格摘要,服务端回填,仅展示用 */
sourceSkuName?: string | null;
} & Model;
/** 回收物配置分页与筛选条件。 */
export type RecycleItemPage = {
storeId?: string;
status?: RecycleStatus;
/** 名称关键字 */
keyword?: string;
offset: number;
limit: number;
};
/** 回收兑换规则:单份回收数量兑换单份业务单位数量。 */
export type RecycleExchangeRule = {
storeId?: string;
recycleItemId: string;
/** 单份规则回收数量 */
recycleQuantity: number | string;
/** 兑换 SKU ID */
skuId: string;
/** 兑换 SKU 业务单位 ID */
skuUnitId: string;
/** 单份规则兑换业务单位数量 */
exchangeQuantity: number | string;
status?: RecycleStatus;
sort?: number;
remark?: string | null;
/** 以下为服务端回填的展示字段,保存时无需提交 */
recycleName?: string | null;
recycleUnit?: string | null;
productName?: string | null;
productType?: string | null;
skuCode?: string | null;
skuName?: string | null;
specSummary?: string | null;
unitName?: string | null;
stockEnabled?: boolean | null;
allowDecimalQuantity?: boolean | null;
} & Model;
/** 兑换规则分页与筛选条件。 */
export type RecycleExchangeRulePage = {
storeId?: string;
status?: RecycleStatus;
recycleItemId?: string;
skuId?: string;
/** 回收物名称关键字 */
keyword?: string;
offset: number;
limit: number;
};
/**
* 兑换单。
*
* 规则、产品、客户后续变更都不改写单据,页面展示优先使用快照字段。
*/
export type RecycleExchange = {
storeId?: string;
customerId?: string;
requestNo?: string;
ruleId?: string;
recycleItemId?: string;
recycleNameSnapshot?: string;
recycleUnitSnapshot?: string;
sourceProductIdSnapshot?: string;
sourceSkuIdSnapshot?: string;
ruleRecycleQuantity?: number | string;
ruleExchangeQuantity?: number | string;
/** 规则倍数,正整数 */
multiple?: number;
/** 预设回收数量 = 规则回收数量 × 倍数 */
defaultRecycleQuantity?: number | string;
/** 预设兑换数量 = 规则兑换数量 × 倍数 */
defaultExchangeQuantity?: number | string;
/** 实际回收数量 */
recycleQuantity?: number | string;
/** 实际兑换数量 */
exchangeQuantity?: number | string;
productIdSnapshot?: string;
skuIdSnapshot?: string;
skuUnitIdSnapshot?: string;
productNameSnapshot?: string;
productTypeSnapshot?: string;
skuCodeSnapshot?: string;
skuNameSnapshot?: string;
specSummarySnapshot?: string;
skuSpecSnapshot?: ProductSkuSpecSnapshot[];
unitSnapshot?: string;
baseQuantityPerUnitSnapshot?: number | string;
baseQuantity?: number | string;
allowDecimalSnapshot?: boolean;
/** true 为兑换 SKU 启用库存管理,创建时预占,撤销时释放 */
stockEnabledSnapshot?: boolean;
status?: RecycleExchangeStatus;
operatorUserId?: string;
/** 业务发生时间 */
occurredAt?: number;
remark?: string | null;
customer?: Customer;
operator?: Partial<User>;
} & Model;
/** 兑换单操作记录。核销记录的退回字段为空。 */
export type RecycleExchangeAction = {
exchangeId?: string;
actionType?: RecycleExchangeActionType;
operatorUserId?: string;
occurredAt?: number;
reason?: string | null;
remark?: string | null;
/** true 为回收物全部退还客户 */
recycleReturned?: boolean | null;
/** true 为兑换商品已退回门店 */
stockReturned?: boolean | null;
stockRecordId?: string;
sourceStockRecordId?: string;
operator?: Partial<User>;
} & Model;
/** 兑换单详情。冲正照片按操作记录 ID 从 actionAttachments 读取。 */
export type RecycleExchangeDetail = {
exchange?: RecycleExchange;
actionList?: RecycleExchangeAction[];
attachmentList?: Attachment[];
actionAttachments?: Record<string, Attachment[]>;
stockRecordList?: StockRecord[];
};
export type RecycleExchangeCreateRequest = {
storeId?: string;
customerId: string;
ruleId: string;
requestNo: string;
multiple: number;
/** 实际回收数量,不传使用预设值 */
recycleQuantity?: string;
/** 实际兑换数量,不传使用预设值 */
exchangeQuantity?: string;
occurredAt?: number;
remark?: string | null;
attachmentList?: Partial<Attachment>[];
};
/** 兑换单动作请求。门店由服务端按兑换单归属解析,这里不需要也不应该传。 */
export type RecycleExchangeActionRequest = {
exchangeId: string;
requestNo: string;
occurredAt?: number;
remark?: string | null;
/** 冲正必填 */
reason?: string;
/** 撤销、冲正必填 */
recycleReturned?: boolean;
/** 库存商品冲正必填,必须为 true */
stockReturned?: boolean;
/** 库存商品冲正至少一张 PHOTO */
attachmentList?: Partial<Attachment>[];
};
export type RecycleExchangePage = {
storeId?: string;
customerId?: string;
recycleItemId?: string;
skuId?: string;
status?: RecycleExchangeStatus;
/** 业务时间起点,包含 */
beginAt?: number;
/** 业务时间终点,包含 */
endAt?: number;
index: number;
size: number;
};
/**
* 配置列表分页结果。
*
* 后端返回的 pages 按本次列表长度计算,末页可能不准,分页一律用 total 推算。
*/
export type RecyclePageResult<T> = PageResult<T> & {
pages?: number;
};
/** 回收统计行。同一回收物名称或单位变化后可能出现多行。 */
export type RecycleStatRow = {
recycleItemId?: string;
recycleName?: string;
recycleUnit?: string;
receivedQuantity?: number | string;
returnedQuantity?: number | string;
netQuantity?: number | string;
};
/** 兑换统计行。三项数量按创建、核销、冲正的业务时间分别归集。 */
export type RecycleExchangeStatRow = {
skuId?: string;
skuUnitId?: string;
productName?: string;
unit?: string;
createdQuantity?: number | string;
verifiedQuantity?: number | string;
revokedQuantity?: number | string;
};