feat: 完善sku成本

This commit is contained in:
2026-08-15 09:26:55 +08:00
parent 3828e309df
commit 2dda6a2d30
24 changed files with 912 additions and 239 deletions
@@ -80,24 +80,3 @@ export async function getProductSkusByIdsApi(skuIds: number[]) {
skuIds,
);
}
/**
* 同步 SKU 成本到历史订单(单个 SKU)
*/
export async function syncCostsToOrdersApi(data: ProductSkuDTO.SyncCost) {
return requestClient.post<number>('/ec/product-sku/sync-costs-to-orders', data);
}
/**
* 批量同步 SKU 成本到历史订单
*/
export async function batchSyncCostsToOrdersApi(data: ProductSkuDTO.BatchSyncCost) {
return requestClient.post<number>('/ec/product-sku/batch-sync-costs-to-orders', data);
}
/**
* 统计指定 SKU 与时间范围内将参与成本同步的订单数量
*/
export async function countOrdersForCostSyncApi(data: ProductSkuDTO.BatchSyncCost) {
return requestClient.post<number>('/ec/product-sku/count-orders-for-cost-sync', data);
}
@@ -0,0 +1,57 @@
import type { ProductSkuCostDTO, ProductSkuCostVO } from './types';
import type { ProductSkuVO } from '#/api/ec/product/sku/types';
import { requestClient } from '#/api/request';
/**
* 同步 SKU 成本到历史订单(单个 SKU)
*/
export async function syncCostsToOrdersApi(data: ProductSkuCostDTO.SyncCost) {
return requestClient.post<number>('/ec/product/sku/cost/sync-to-orders', data);
}
/**
* 批量同步 SKU 当前生效成本到历史订单
*/
export async function batchSyncCostsToOrdersApi(
data: ProductSkuCostDTO.BatchSyncCost,
) {
return requestClient.post<number>(
'/ec/product/sku/cost/batch-sync-to-orders',
data,
);
}
/**
* 统计指定 SKU 与时间范围内将参与成本同步的订单数量
*/
export async function countOrdersForCostSyncApi(
data: ProductSkuCostDTO.BatchSyncCost,
) {
return requestClient.post<number>(
'/ec/product/sku/cost/count-orders-for-sync',
data,
);
}
/**
* 查询 SKU 成本历史
*/
export async function listSkuCostsApi(skuId: number) {
return requestClient.get<ProductSkuCostVO.History[]>(
`/ec/product/sku/cost/${skuId}`,
);
}
/**
* SKU 调价(按生效日追加 / 同日纠错)
*/
export async function adjustSkuCostApi(
skuId: number,
data: ProductSkuCostDTO.AdjustCost,
) {
return requestClient.post<ProductSkuVO.Info>(
`/ec/product/sku/cost/${skuId}`,
data,
);
}
@@ -0,0 +1,5 @@
/**
* 商品 SKU 成本模块 API
*/
export * from './apis';
export * from './types';
@@ -0,0 +1,2 @@
export * from './types.dto';
export * from './types.vo';
@@ -0,0 +1,31 @@
/**
* SKU 成本相关 DTO
*/
export namespace ProductSkuCostDTO {
/** 同步 SKU 成本到订单(单个 SKU) */
export interface SyncCost {
skuId: number;
productCost: number;
shippingCost?: number;
otherCost?: number;
startTime: string;
endTime: string;
}
/** 批量同步 SKU 成本到订单 */
export interface BatchSyncCost {
skuIds: number[];
startTime: string;
endTime: string;
}
/** SKU 调价(按生效日) */
export interface AdjustCost {
/** 生效起始日 yyyy-MM-dd */
effectiveFrom: string;
productCost: number;
shippingCost?: number;
otherCost?: number;
remark?: string;
}
}
@@ -0,0 +1,16 @@
/**
* SKU 成本相关 VO
*/
export namespace ProductSkuCostVO {
/** 成本历史条目 */
export interface History {
id: number;
/** 生效起始日 yyyy-MM-dd */
effectiveFrom: string;
productCost: number;
shippingCost?: number;
otherCost?: number;
remark?: string;
createTime?: string;
}
}
@@ -64,30 +64,4 @@ export namespace ProductSkuDTO {
/** SKU 编码 */
skuCode: string;
}
/** 同步 SKU 成本到订单(单个 SKU) */
export interface SyncCost {
/** SKU ID */
skuId: number;
/** 商品成本 */
productCost: number;
/** 运费成本 */
shippingCost?: number;
/** 其他成本 */
otherCost?: number;
/** 订单开始时间 */
startTime: string;
/** 订单结束时间 */
endTime: string;
}
/** 批量同步 SKU 成本到订单 */
export interface BatchSyncCost {
/** SKU ID 列表 */
skuIds: number[];
/** 订单时间下限(含) */
startTime: string;
/** 订单时间上限(含) */
endTime: string;
}
}
@@ -23,6 +23,8 @@ export namespace ProductSkuVO {
shippingCost?: number;
/** 其他成本 */
otherCost?: number;
/** 当前成本生效起始日 yyyy-MM-dd */
costEffectiveFrom?: string;
/** 备注 */
remark?: string;
/** SKU 图 URL(系统文件或渠道外链) */
@@ -68,6 +68,8 @@ export namespace ProductVO {
shippingCost?: number;
/** 其他成本 */
otherCost?: number;
/** 当前成本生效起始日 yyyy-MM-dd */
costEffectiveFrom?: string;
/** 备注 */
remark?: string;
/** SKU 图 URL(系统文件或渠道外链) */