feat: 成本同步功能完整实现

- ProductSpecController 新增 POST /ec/product-spec/sync-costs-to-orders 接口
- OrderMapper.updateCostFields() 批量更新订单成本字段
- OrderService 新增 syncCostsToOrders 方法
- UpdateProductResultDTO 返回完整成本变更规格列表(含 id/name/specCode/成本字段)
- 前端 ProductFormModal 同步弹窗:勾选规格 + 选择时间范围 + 显示更新条数
This commit is contained in:
小蟑螂
2026-04-14 22:04:38 +08:00
parent 26cb1a9a41
commit 83ed7478d2
11 changed files with 341 additions and 13 deletions
@@ -75,3 +75,10 @@ export async function getProductSpecsByProductAndSpecsApi(
queries,
);
}
/**
* 同步规格成本到历史订单
*/
export async function syncCostsToOrdersApi(data: ProductSpecDTO.SyncCost) {
return requestClient.post<number>('/ec/product-spec/sync-costs-to-orders', data);
}
@@ -58,4 +58,20 @@ export namespace ProductSpecDTO {
/** 规格编码 */
specCode: string;
}
/** 同步规格成本到订单 */
export interface SyncCost {
/** 规格ID */
specId: number;
/** 商品成本 */
productCost: number;
/** 运费成本 */
shippingCost?: number;
/** 其他成本 */
otherCost?: number;
/** 订单开始时间 */
startTime: string;
/** 订单结束时间 */
endTime: string;
}
}
@@ -29,8 +29,24 @@ export namespace ProductVO {
/** 更新商品响应 */
export interface UpdateProductResult {
/** 本次更新中成本发生变更的规格ID列表 */
costChangedSpecIds: number[];
/** 本次更新中成本发生变更的规格列表 */
costChangedSpecs: CostChangedSpec[];
}
/** 成本变更的规格信息 */
export interface CostChangedSpec {
/** 规格ID */
id: number;
/** 规格名称 */
name: string;
/** 规格编码 */
specCode?: string;
/** 商品成本 */
productCost: number;
/** 运费成本 */
shippingCost?: number;
/** 其他成本 */
otherCost?: number;
}
/** 商品规格信息 */