feat(ecom-dmb): 优化商品成本同步逻辑

后端:
- UpdateProductResultDTO 改回只返回成本变更的规格ID列表
- ProductServiceImpl 构建 ID 列表而非完整对象
- 新增 BatchSyncCostDTO 批量同步请求DTO
- ProductSpecService 新增 getByIds 批量查询规格方法
- ProductSpecController 新增批量同步接口 batch-sync-costs-to-orders
- ProductSpecController 新增 batch-get-by-ids 接口查询规格详情

前端:
- UpdateProductResult 类型改为返回 costChangedSpecIds: number[]
- 新增 BatchSyncCost 和 getProductSpecsByIdsApi 批量接口
- ProductFormModal 改为批量同步,修复 responseReturn .data 的误用 bug
This commit is contained in:
小蟑螂
2026-04-17 11:40:23 +08:00
parent ac39f5d850
commit 5c4ef6c990
10 changed files with 171 additions and 104 deletions
@@ -77,8 +77,25 @@ export async function getProductSpecsByProductAndSpecsApi(
}
/**
* 同步规格成本到历史订单
* 根据ID列表批量查询商品规格
*/
export async function getProductSpecsByIdsApi(specIds: number[]) {
return requestClient.post<ProductSpecVO.Info[]>(
'/ec/product-spec/batch-get-by-ids',
specIds,
);
}
/**
* 同步规格成本到历史订单(单个规格)
*/
export async function syncCostsToOrdersApi(data: ProductSpecDTO.SyncCost) {
return requestClient.post<number>('/ec/product-spec/sync-costs-to-orders', data);
}
/**
* 批量同步规格成本到历史订单
*/
export async function batchSyncCostsToOrdersApi(data: ProductSpecDTO.BatchSyncCost) {
return requestClient.post<number>('/ec/product-spec/batch-sync-costs-to-orders', data);
}
@@ -59,7 +59,7 @@ export namespace ProductSpecDTO {
specCode: string;
}
/** 同步规格成本到订单 */
/** 同步规格成本到订单(单个规格) */
export interface SyncCost {
/** 规格ID */
specId: number;
@@ -74,4 +74,14 @@ export namespace ProductSpecDTO {
/** 订单结束时间 */
endTime: string;
}
/** 批量同步规格成本到订单 */
export interface BatchSyncCost {
/** 规格ID列表 */
specIds: number[];
/** 订单开始时间 */
startTime: string;
/** 订单结束时间 */
endTime: string;
}
}
@@ -31,24 +31,8 @@ export namespace ProductVO {
/** 更新商品响应 */
export interface UpdateProductResult {
/** 本次更新中成本发生变更的规格列表 */
costChangedSpecs: CostChangedSpec[];
}
/** 成本变更的规格信息 */
export interface CostChangedSpec {
/** 规格ID */
id: number;
/** 规格名称 */
name: string;
/** 规格编码 */
specCode?: string;
/** 商品成本 */
productCost: number;
/** 运费成本 */
shippingCost?: number;
/** 其他成本 */
otherCost?: number;
/** 本次更新中成本发生变更的规格ID列表 */
costChangedSpecIds: number[];
}
/** 商品规格信息 */