refactor: 重构订单,店铺,商品

This commit is contained in:
2026-08-05 22:45:18 +08:00
parent 90f95f860e
commit 145e131b3e
196 changed files with 5595 additions and 10122 deletions
@@ -1,16 +1,16 @@
/**
* 刷单记录相关DTO类型定义
* 刷单记录相关 DTO 类型定义
*/
export namespace BrushOrderDTO {
/** 创建刷单记录参数 */
export interface Create {
/** 店铺ID */
/** 店铺 ID */
shopId: number;
/** 商品ID(可选) */
/** 商品 ID(可选) */
productId?: number;
/** 商品规格ID(可选) */
productSpecId?: number;
/** 商品 SKU ID(可选) */
productSkuId?: number;
/** 刷单金额 */
brushAmount: number;
/** 刷单时间 */
@@ -23,12 +23,12 @@ export namespace BrushOrderDTO {
/** 更新刷单记录参数 */
export interface Update {
/** 店铺ID */
/** 店铺 ID */
shopId: number;
/** 商品ID(可选) */
/** 商品 ID(可选) */
productId?: number;
/** 商品规格ID(可选) */
productSpecId?: number;
/** 商品 SKU ID(可选) */
productSkuId?: number;
/** 刷单金额 */
brushAmount: number;
/** 刷单时间 */
@@ -41,9 +41,9 @@ export namespace BrushOrderDTO {
/** 刷单记录过滤条件 */
export interface Filters {
/** 店铺ID */
/** 店铺 ID */
shopId?: number;
/** 商品ID */
/** 商品 ID */
productId?: number;
/** 平台订单号(模糊查询) */
platformOrderNo?: string;
@@ -1,26 +1,26 @@
/**
* 刷单记录相关VO类型定义
* 刷单记录相关 VO 类型定义
*/
export namespace BrushOrderVO {
/** 刷单记录信息 */
export interface Info {
/** 刷单记录ID */
/** 刷单记录 ID */
id: number;
/** 公司ID */
/** 公司 ID */
companyId: number;
/** 店铺ID */
/** 店铺 ID */
shopId: number;
/** 店铺名称 */
shopName: string;
/** 商品ID */
/** 商品 ID */
productId?: number;
/** 商品名称 */
productName?: string;
/** 商品规格ID */
productSpecId?: number;
/** 商品规格名称 */
productSpecName?: string;
/** 商品 SKU ID */
productSkuId?: number;
/** 商品 SKU 名称 */
productSkuName?: string;
/** 刷单金额 */
brushAmount: number;
/** 刷单时间 */
@@ -33,9 +33,9 @@ export namespace BrushOrderVO {
createTime: string;
/** 更新时间 */
updateTime: string;
/** 创建人ID */
/** 创建人 ID */
createBy?: number;
/** 更新人ID */
/** 更新人 ID */
updateBy?: number;
}
}
@@ -1,64 +1,12 @@
import type { OrderStatusDTO, OrderStatusVO } from './types';
import type { OrderStatusVO } from './types';
import { requestClient } from '#/api/request';
/**
* 订单状态管理API
* 订单状态静态字典 API(无 CRUD)。
*/
/**
* 创建订单状态
*/
export async function createOrderStatusApi(data: OrderStatusDTO.Create) {
return requestClient.post<OrderStatusVO.Info>(
'/ec/order-status/create',
data,
);
}
/**
* 更新订单状态
*/
export async function updateOrderStatusApi(
id: number,
data: OrderStatusDTO.Update,
) {
return requestClient.put<OrderStatusVO.Info>(
`/ec/order-status/update/${id}`,
data,
);
}
/**
* 部分更新订单状态(统计维度开关,字段可选)
*/
export async function patchOrderStatusApi(
id: number,
data: OrderStatusDTO.Patch,
) {
return requestClient.request<OrderStatusVO.Info>(
`/ec/order-status/update/${id}`,
{ data, method: 'PATCH' },
);
}
/**
* 删除订单状态
*/
export async function deleteOrderStatusApi(id: number) {
return requestClient.delete(`/ec/order-status/delete/${id}`);
}
/**
* 获取所有订单状态列表
*/
/** 获取全部订单状态元数据列表 */
export async function getAllOrderStatusListApi() {
return requestClient.get<OrderStatusVO.Info[]>('/ec/order-status/list');
}
/**
* 获取订单状态详情
*/
export async function getOrderStatusByIdApi(id: number) {
return requestClient.get<OrderStatusVO.Info>(`/ec/order-status/detail/${id}`);
return requestClient.get<OrderStatusVO.Meta[]>('/ec/order-status/list');
}
@@ -1,58 +1,2 @@
/**
* 订单状态相关DTO类型定义
*/
export namespace OrderStatusDTO {
/** 创建订单状态参数 */
export interface Create {
/** 状态名称(中文) */
statusName: string;
/** 状态描述 */
description?: string;
/** 状态颜色(十六进制,如 #1890ff) */
color?: string;
/** 排序 */
sortOrder?: number;
/** 是否计入销售额/单量等统计 0否 1是 */
includeSalesAmount?: number;
/** 是否计入商品成本统计 0否 1是 */
includeProductCost?: number;
/** 是否计入运费成本统计 0否 1是 */
includeFreightCost?: number;
/** 是否计入其他成本统计 0否 1是 */
includeOtherCost?: number;
/** 是否计入退款金额统计 0否 1是 */
includeRefund?: number;
}
/** 更新订单状态参数 */
export interface Update {
/** 状态名称(中文) */
statusName: string;
/** 状态描述 */
description?: string;
/** 状态颜色(十六进制,如 #1890ff) */
color?: string;
/** 排序 */
sortOrder?: number;
/** 是否计入销售额/单量等统计 0否 1是 */
includeSalesAmount: number;
/** 是否计入商品成本统计 0否 1是 */
includeProductCost: number;
/** 是否计入运费成本统计 0否 1是 */
includeFreightCost: number;
/** 是否计入其他成本统计 0否 1是 */
includeOtherCost: number;
/** 是否计入退款金额统计 0否 1是 */
includeRefund: number;
}
/** PATCH 部分更新(任意字段可选,与后端 PatchOrderStatusDTO 对齐) */
export interface Patch {
includeSalesAmount?: number;
includeProductCost?: number;
includeFreightCost?: number;
includeOtherCost?: number;
includeRefund?: number;
}
}
/** 订单状态模块已无写操作 DTO,保留空命名空间供扩展 */
export namespace OrderStatusDTO {}
@@ -1,39 +1,18 @@
/**
* 订单状态相关VO类型定义
* 订单状态静态字典 VO
*/
export namespace OrderStatusVO {
/** 订单状态信息 */
export interface Info {
/** 订单状态ID */
id: number;
/** 公司ID */
companyId?: number;
/** 状态名称(中文) */
statusName: string;
/** 状态描述 */
description?: string;
/** 状态颜色(十六进制,如 #1890ff) */
/** 订单状态元数据(code/label/color…) */
export interface Meta {
code: string;
label: string;
color?: string;
/** 排序 */
sortOrder?: number;
/** 是否计入销售额/单量等统计 0否 1是 */
includeSalesAmount: number;
/** 是否计入商品成本统计 0否 1是 */
includeProductCost: number;
/** 是否计入运费成本统计 0否 1是 */
includeFreightCost: number;
/** 是否计入其他成本统计 0否 1是 */
includeOtherCost: number;
/** 是否计入退款金额统计 0否 1是 */
includeRefund: number;
/** 创建时间 */
createTime: string;
/** 更新时间 */
updateTime: string;
/** 创建人ID */
createBy?: number;
/** 更新人ID */
updateBy?: number;
includeSalesAmount: boolean;
includeProductCost: boolean;
includeFreightCost: boolean;
includeOtherCost: boolean;
includeRefund: boolean;
}
}
@@ -1,37 +1,69 @@
/**
* 订单相关DTO类型定义
* 订单相关 DTO 类型定义
*/
/** 创建/更新订单明细 */
export namespace OrderItemDTO {
export interface Create {
/** 商品规格 ID */
productSkuId?: number;
/** 规格编码 */
skuCode?: string;
/** 链接商品名称 */
linkProductName: string;
/** 链接规格名称 */
linkSkuName?: string;
/** 数量 */
quantity: number;
/** 销售单价 */
unitPrice?: number;
/** 行实收/行销售额 */
lineAmount?: number;
/** 单件商品成本快照 */
productCost?: number;
/** 单件运费成本快照 */
shippingCost?: number;
/** 单件其他成本快照 */
otherCost?: number;
/** 明细备注 */
remark?: string;
}
}
export namespace OrderDTO {
/** 创建订单参数 */
export interface Create {
/** 店铺ID */
/** 店铺 ID */
shopId: number;
/** 平台订单号 */
platformOrderNo?: string;
/** 订单状态ID */
statusId: number;
/** 商家实收金额 */
receivedAmount: number;
/** 订单状态码 */
status: string;
/** 实付/商家实收金额 */
payAmount: number;
/** 兼容旧字段名(后端 JsonAlias) */
receivedAmount?: number;
/** 下单时间 */
orderTime: string;
/** 商品规格ID */
productSpecId: number;
/** 规格编码(可选,服务端可按规格ID补全) */
specCode?: string;
/** 链接商品名称(冗余存储) */
linkProductName: string;
/** 链接规格名称(冗余存储) */
linkSpecName?: string;
/** 数量 */
quantity: number;
/** 销售单价 */
unitPrice: number;
/** 单件商品成本(下单时快照) */
productCost: number;
/** 单件运费成本(下单时快照) */
/** 订单明细(未传时后端用扁平字段合成一行) */
items?: OrderItemDTO.Create[];
/** 商品规格 ID(扁平导入/表单兼容) */
productSkuId?: number;
/** SKU 编码 */
skuCode?: string;
/** 链接商品名称(扁平导入/表单兼容) */
linkProductName?: string;
/** 链接 SKU 名称(扁平导入/表单兼容) */
linkSkuName?: string;
/** 数量(扁平导入/表单兼容) */
quantity?: number;
/** 销售单价(扁平导入/表单兼容) */
unitPrice?: number;
/** 单件商品成本(扁平导入/表单兼容) */
productCost?: number;
/** 单件运费成本(扁平导入/表单兼容) */
shippingCost?: number;
/** 单件其他成本(下单时快照) */
/** 单件其他成本(扁平导入/表单兼容) */
otherCost?: number;
/** 备注 */
remark?: string;
@@ -39,49 +71,47 @@ export namespace OrderDTO {
/** 更新订单参数 */
export interface Update {
/** 店铺ID */
/** 店铺 ID */
shopId: number;
/** 平台订单号 */
platformOrderNo?: string;
/** 订单状态ID */
statusId?: number;
/** 商家实收金额 */
receivedAmount: number;
/** 订单状态码 */
status?: string;
/** 实付/商家实收金额 */
payAmount: number;
/** 兼容旧字段名 */
receivedAmount?: number;
/** 下单时间 */
orderTime: string;
/** 商品规格ID */
productSpecId?: number;
/** 规格编码 */
specCode?: string;
/** 链接商品名称(冗余存储) */
/** 订单明细(全量替换) */
items?: OrderItemDTO.Create[];
/** 扁平字段(未传 items 时合成一行) */
productSkuId?: number;
skuCode?: string;
linkProductName?: string;
/** 链接规格名称(冗余存储) */
linkSpecName?: string;
/** 数量 */
linkSkuName?: string;
quantity?: number;
/** 销售单价 */
unitPrice?: number;
/** 单件商品成本(下单时快照) */
productCost?: number;
/** 单件运费成本(下单时快照) */
shippingCost?: number;
/** 单件其他成本(下单时快照) */
otherCost?: number;
/** 备注 */
remark?: string;
}
/** 订单过滤条件 */
export interface Filters {
/** 店铺ID */
/** 店铺 ID */
shopId?: number;
/** 平台订单号(默认前缀匹配;含 %/_ 时全模糊) */
platformOrderNo?: string;
/** 订单状态ID */
statusId?: number;
/** 实收金额范围-最小值 */
/** 订单状态码 */
status?: string;
/** 实付金额范围-最小值 */
minPayAmount?: number;
/** 实付金额范围-最大值 */
maxPayAmount?: number;
/** 兼容旧字段名 */
minReceivedAmount?: number;
/** 实收金额范围-最大值 */
maxReceivedAmount?: number;
/** 确认状态(0 未确认 / 1 已确认) */
confirm?: number;
@@ -89,7 +119,7 @@ export namespace OrderDTO {
startOrderTime?: string;
/** 下单时间范围-结束时间 */
endOrderTime?: string;
/** 商品ID */
/** 商品 ID */
productId?: number;
}
@@ -101,7 +131,7 @@ export namespace OrderDTO {
/** 批量删除订单参数 */
export interface BatchDelete {
/** 订单ID列表 */
/** 订单 ID 列表 */
orderIds: number[];
}
}
@@ -1,74 +1,113 @@
/**
* 订单相关VO类型定义
* 订单相关 VO 类型定义
*/
import type { OrderStatusVO } from '#/api/ecommerce/order-status/types';
import type { ProductSpecVO } from '#/api/ecommerce/product-spec/types';
import type { ProductSkuVO } from '#/api/ecommerce/product-sku/types';
import type { ProductVO } from '#/api/ecommerce/product/types';
import type { ShopVO } from '#/api/ecommerce/shop/types';
export namespace OrderVO {
/** 订单信息 */
/** 订单明细行 */
export namespace OrderItemVO {
export interface Info {
/** 订单ID */
/** 明细 ID */
id?: number;
/** 行号 */
lineNo?: number;
/** 商品 ID */
productId?: number;
/** 商品规格 ID */
productSkuId?: number;
/** 规格编码 */
skuCode?: string;
/** 链接商品名称 */
linkProductName: string;
/** 链接规格名称 */
linkSkuName?: string;
/** 商品图片 URL */
goodsImg?: string;
/** 数量 */
quantity: number;
/** 销售单价 */
unitPrice?: number;
/** 行实收/行销售额 */
lineAmount?: number;
/** 单件商品成本快照 */
productCost?: number;
/** 单件运费成本快照 */
shippingCost?: number;
/** 单件其他成本快照 */
otherCost?: number;
/** 明细备注 */
remark?: string;
/** 关联商品 */
product?: ProductVO.Info;
/** 关联规格 */
productSku?: ProductSkuVO.Info;
}
}
export namespace OrderVO {
/** 订单信息(主表 + 明细列表) */
export interface Info {
/** 订单 ID */
id: number;
/** 公司ID */
/** 公司 ID */
companyId: number;
/** 店铺ID */
/** 店铺 ID */
shopId: number;
/** 店铺名称 */
shopName: string;
/** 平台代码 */
platformCode?: string;
/** 平台订单号 */
platformOrderNo: string;
/** 订单状态ID */
statusId: number;
/** 订单状态名称(中文) */
statusName: string;
/** 商家实收金额 */
receivedAmount: number;
/** 订单状态码(如 PENDING_SHIPMENT) */
status: string;
/** 订单状态中文名 */
statusLabel: string;
/** 订单状态展示色 */
statusColor?: string;
/** 来源 */
source?: string;
/** 实付/商家实收金额 */
payAmount: number;
/** 兼容旧字段名(后端 JSON 别名) */
receivedAmount?: number;
/** 商品金额合计 */
goodsAmount?: number;
/** 折扣金额合计 */
discountAmount?: number;
/** 邮费 */
postage?: number;
/** 下单时间 */
orderTime: string;
/** 创建时间 */
createTime: string;
/** 更新时间 */
updateTime: string;
/** 创建人ID */
/** 创建人 ID */
createBy?: number;
/** 更新人ID */
/** 更新人 ID */
updateBy?: number;
/** 商品规格ID */
productSpecId?: number;
/** 规格编码 */
specCode?: string;
/** 链接商品名称(冗余存储) */
linkProductName: string;
/** 链接规格名称(冗余存储) */
linkSpecName?: string;
/** 数量 */
quantity: number;
/** 销售单价 */
unitPrice: number;
/** 单件商品成本(下单时快照) */
productCost: number;
/** 单件运费成本(下单时快照) */
shippingCost?: number;
/** 单件其他成本(下单时快照) */
otherCost?: number;
/** 备注 */
remark?: string;
/** 关联商品信息 */
product?: ProductVO.Info;
/** 关联商品规格信息 */
productSpec?: ProductSpecVO.Info;
/** 关联订单状态信息 */
orderStatus?: OrderStatusVO.Info;
/** 导入任务 ID */
importTaskId?: number;
/** 确认(0-否 1-是) */
confirm?: number;
/** 明细行数(列表汇总) */
itemCount?: number;
/** 首行链接商品名(列表汇总) */
firstLinkProductName?: string;
/** 订单明细 */
items?: OrderItemVO.Info[];
/** 关联店铺信息 */
shop?: ShopVO.Info;
}
}
/**
* 订单字段信息VO
* 订单字段信息 VO(导入映射;fieldName 仍用 received_amount,后端映射 payAmount)
*/
export namespace OrderFieldVO {
/** 订单字段信息 */
@@ -89,7 +128,7 @@ export namespace OrderFieldVO {
}
/**
* 批量导入结果相关VO类型定义
* 批量导入结果相关 VO 类型定义
*/
export namespace BatchImportResultVO {
@@ -1,49 +1,12 @@
import type { PlatformDTO, PlatformVO } from './types';
import type { PageQueryDTO, PageResultVO } from '#/types/common';
import type { PlatformVO } from './types';
import { requestClient } from '#/api/request';
/**
* 平台管理API
* 平台静态字典 API(无 CRUD)。
*/
/**
* 分页获取平台列表
*/
export async function getPlatformPageApi(
params: PageQueryDTO<PlatformDTO.Filters>,
) {
return requestClient.post<PageResultVO<PlatformVO.Info>>(
'/ec/platform/list',
params,
);
}
/**
* 创建平台
*/
export async function createPlatformApi(data: PlatformDTO.Create) {
return requestClient.post<PlatformVO.Info>('/ec/platform/create', data);
}
/**
* 更新平台
*/
export async function updatePlatformApi(id: number, data: PlatformDTO.Update) {
return requestClient.put<PlatformVO.Info>(`/ec/platform/update/${id}`, data);
}
/**
* 删除平台
*/
export async function deletePlatformApi(id: number) {
return requestClient.delete(`/ec/platform/delete/${id}`);
}
/**
* 获取所有启用的平台列表
*/
export async function getActivePlatformsApi() {
return requestClient.get<PlatformVO.Info[]>('/ec/platform/active');
/** 获取全部预置电商平台字典 */
export async function getPlatformListApi() {
return requestClient.get<PlatformVO.Meta[]>('/ec/platform/list');
}
@@ -1,30 +1,2 @@
export namespace PlatformDTO {
/**
* 创建平台
*/
export interface Create {
platformName: string;
platformCode: string;
sortOrder?: number;
isActive?: number;
}
/**
* 更新平台
*/
export interface Update {
platformName: string;
platformCode: string;
sortOrder: number;
isActive: number;
}
/**
* 过滤条件
*/
export interface Filters {
platformName?: string;
platformCode?: string;
isActive?: number;
}
}
/** 平台模块已无写操作 DTO,保留空命名空间供扩展 */
export namespace PlatformDTO {}
@@ -1,14 +1,8 @@
export namespace PlatformVO {
/**
* 平台信息
*/
export interface Info {
id: number;
platformName: string;
platformCode: string;
/** 平台静态字典项(code/label/sortOrder) */
export interface Meta {
code: string;
label: string;
sortOrder: number;
isActive: number;
createTime: string;
updateTime: string;
}
}
@@ -15,28 +15,28 @@ export namespace ProductOverviewVO {
dailyDataList: TrendDataItem[];
}
/** 规格销量排名项 */
export interface SpecSalesRankItem {
/** 规格ID */
specId?: number;
/** 规格名称 */
specName?: string;
/** 规格编码 */
specCode?: string;
/** SKU 销量排名项 */
export interface SkuSalesRankItem {
/** SKU ID */
skuId?: number;
/** SKU 名称 */
skuName?: string;
/** SKU 编码 */
skuCode?: string;
/** 订单量 */
orderCount?: number;
/** 销售额 */
salesAmount?: number;
}
/** 规格销售明细项 */
export interface SpecSummaryItem {
/** 规格ID */
specId: number;
/** 规格名称 */
specName: string;
/** 规格编码 */
specCode: string;
/** SKU 销售明细项 */
export interface SkuSummaryItem {
/** SKU ID */
skuId: number;
/** SKU 名称 */
skuName: string;
/** SKU 编码 */
skuCode: string;
/** 销售额 */
salesAmount: number;
/** 订单量 */
@@ -69,8 +69,8 @@ export namespace ProductOverviewVO {
profitAfterTax: number;
}
/** 规格销售汇总合计行 */
export interface SpecSummaryTotal {
/** SKU 销售汇总合计行 */
export interface SkuSummaryTotal {
/** 销售额 */
salesAmount: number;
/** 订单量 */
@@ -103,17 +103,17 @@ export namespace ProductOverviewVO {
profitAfterTax: number;
}
/** 规格销售汇总 */
export interface SpecSummary {
/** 各规格明细列表 */
list: SpecSummaryItem[];
/** SKU 销售汇总 */
export interface SkuSummary {
/** 各 SKU 明细列表 */
list: SkuSummaryItem[];
/** 合计行 */
total: SpecSummaryTotal;
total: SkuSummaryTotal;
}
/** 商品概览响应 */
export interface Overview {
/** 商品ID */
/** 商品 ID */
productId: number;
/** 商品名称 */
productName: string;
@@ -135,12 +135,12 @@ export namespace ProductOverviewVO {
orderCountAchievementRate: number;
/** 销售额目标达成率 */
salesAmountAchievementRate: number;
/** 汇总ROI */
/** 汇总 ROI */
totalROI: number;
// ========== 各规格销量 Top10 ==========
/** 各规格销量 Top10 */
specSalesTop10: SpecSalesRankItem[];
// ========== 各 SKU 销量 Top10 ==========
/** 各 SKU 销量 Top10(后端字段名仍为 specSalesTop10) */
specSalesTop10: SkuSalesRankItem[];
// ========== 趋势数据 ==========
/** 销售额趋势分析 */
@@ -148,8 +148,8 @@ export namespace ProductOverviewVO {
/** 单量趋势分析 */
orderCountTrend: TrendData;
// ========== 规格销售汇总 ==========
/** 规格销售汇总 */
specSummaries: SpecSummary;
// ========== SKU 销售汇总 ==========
/** SKU 销售汇总(后端字段名仍为 specSummaries) */
specSummaries: SkuSummary;
}
}
@@ -0,0 +1,103 @@
import type { ProductSkuDTO, ProductSkuVO } from './types';
import type { ProductVO } from '#/api/ecommerce/product/types';
import type { PageQueryDTO, PageResultVO } from '#/types/common';
import { requestClient } from '#/api/request';
/**
* 创建商品 SKU
*/
export async function createProductSkuApi(data: ProductSkuDTO.Create) {
return requestClient.post<ProductSkuVO.Info>(
'/ec/product-sku/create',
data,
);
}
/**
* 更新商品 SKU
*/
export async function updateProductSkuApi(
id: number,
data: ProductSkuDTO.Update,
) {
return requestClient.put<ProductSkuVO.Info>(
`/ec/product-sku/update/${id}`,
data,
);
}
/**
* 删除商品 SKU
*/
export async function deleteProductSkuApi(id: number) {
return requestClient.delete(`/ec/product-sku/delete/${id}`);
}
/**
* 分页获取商品 SKU 列表
*/
export async function getProductSkuPageApi(
params: PageQueryDTO<ProductSkuDTO.Filters>,
) {
return requestClient.post<PageResultVO<ProductSkuVO.Info>>(
'/ec/product-sku/list',
params,
);
}
/**
* 根据商品名称和 SKU 编码精准查询商品 SKU
*/
export async function getProductSkuByProductAndSkuApi(
productName: string,
skuCode: string,
) {
return requestClient.get<ProductSkuVO.Info>(
`/ec/product-sku/find-by-product-and-sku/${encodeURIComponent(productName)}/${encodeURIComponent(skuCode)}`,
);
}
/**
* 批量根据商品名称和 SKU 编码查询商品 SKU
*/
export async function getProductSkusByProductAndSkusApi(
queries: ProductSkuDTO.Query[],
) {
return requestClient.post<ProductVO.Info[]>(
'/ec/product-sku/find-by-product-and-skus',
queries,
);
}
/**
* 根据 ID 列表批量查询商品 SKU
*/
export async function getProductSkusByIdsApi(skuIds: number[]) {
return requestClient.post<ProductSkuVO.Info[]>(
'/ec/product-sku/batch-get-by-ids',
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);
}
@@ -1,5 +1,5 @@
/**
* 商品规格模块API导出
* 商品 SKU 模块 API 导出
*/
export * from './apis';
@@ -1,16 +1,16 @@
/**
* 商品规格相关DTO类型定义
* 商品 SKU 相关 DTO 类型定义
*/
export namespace ProductSpecDTO {
/** 创建商品规格参数 */
export namespace ProductSkuDTO {
/** 创建商品 SKU 参数 */
export interface Create {
/** 商品ID */
/** 商品 ID */
productId: number;
/** 规格名称 */
/** SKU 名称 */
name: string;
/** 规格编码 */
specCode?: string;
/** SKU 编码 */
skuCode?: string;
/** 商品成本 */
productCost: number;
/** 运费成本 */
@@ -21,14 +21,14 @@ export namespace ProductSpecDTO {
remark?: string;
}
/** 更新商品规格参数 */
/** 更新商品 SKU 参数 */
export interface Update {
/** 规格ID */
/** SKU ID */
id: number;
/** 规格名称 */
/** SKU 名称 */
name: string;
/** 规格编码 */
specCode?: string;
/** SKU 编码 */
skuCode?: string;
/** 商品成本 */
productCost: number;
/** 运费成本 */
@@ -39,32 +39,32 @@ export namespace ProductSpecDTO {
remark?: string;
}
/** 商品规格过滤条件 */
/** 商品 SKU 过滤条件 */
export interface Filters {
/** 商品ID */
/** 商品 ID */
productId?: number;
/** 规格ID */
/** SKU ID */
id?: number;
/** 规格名称 */
/** SKU 名称 */
name?: string;
/** 规格编码 */
specCode?: string;
/** 关键字(模糊查询规格名称、规格编码) */
/** SKU 编码 */
skuCode?: string;
/** 关键字(模糊查询 SKU 名称、SKU 编码) */
keywords?: string;
}
/** 商品规格查询DTO(用于批量查询) */
/** 商品 SKU 查询 DTO(用于批量查询) */
export interface Query {
/** 商品名称 */
productName: string;
/** 规格编码 */
specCode: string;
/** SKU 编码 */
skuCode: string;
}
/** 同步规格成本到订单(单个规格) */
/** 同步 SKU 成本到订单(单个 SKU) */
export interface SyncCost {
/** 规格ID */
specId: number;
/** SKU ID */
skuId: number;
/** 商品成本 */
productCost: number;
/** 运费成本 */
@@ -77,13 +77,13 @@ export namespace ProductSpecDTO {
endTime: string;
}
/** 批量同步规格成本到订单(按订单 orderTime,起止为含时分秒的 LocalDateTime 字符串) */
/** 批量同步 SKU 成本到订单 */
export interface BatchSyncCost {
/** 规格ID列表 */
specIds: number[];
/** 订单时间下限(含),如 `2024-01-01 00:00:00` */
/** SKU ID 列表 */
skuIds: number[];
/** 订单时间下限(含) */
startTime: string;
/** 订单时间上限(含),如 `2024-01-31 23:59:59` */
/** 订单时间上限(含) */
endTime: string;
}
}
@@ -1,22 +1,22 @@
/**
* 商品规格相关VO类型定义
* 商品 SKU 相关 VO 类型定义
*/
export namespace ProductSpecVO {
/** 商品规格信息 */
export namespace ProductSkuVO {
/** 商品 SKU 信息 */
export interface Info {
/** 规格ID */
/** SKU ID */
id: number;
/** 公司ID */
/** 公司 ID */
companyId: number;
/** 商品ID */
/** 商品 ID */
productId: number;
/** 商品名称 */
productName: string;
/** 规格名称 */
/** SKU 名称 */
name: string;
/** 规格编码 */
specCode?: string;
/** SKU 编码 */
skuCode?: string;
/** 商品成本 */
productCost: number;
/** 运费成本 */
@@ -29,9 +29,11 @@ export namespace ProductSpecVO {
createTime: string;
/** 更新时间 */
updateTime: string;
/** 创建人ID */
/** 创建人 ID */
createBy?: number;
/** 更新人ID */
/** 更新人 ID */
updateBy?: number;
/** 成本是否变更(本次更新中成本字段有变化) */
costChanged?: boolean;
}
}
@@ -1,108 +0,0 @@
import type { ProductSpecDTO, ProductSpecVO } from './types';
import type { ProductVO } from '#/api/ecommerce/product/types';
import type { PageQueryDTO, PageResultVO } from '#/types/common';
import { requestClient } from '#/api/request';
/**
* 商品规格管理API
*/
/**
* 创建商品规格
*/
export async function createProductSpecApi(data: ProductSpecDTO.Create) {
return requestClient.post<ProductSpecVO.Info>(
'/ec/product-spec/create',
data,
);
}
/**
* 更新商品规格
*/
export async function updateProductSpecApi(
id: number,
data: ProductSpecDTO.Update,
) {
return requestClient.put<ProductSpecVO.Info>(
`/ec/product-spec/update/${id}`,
data,
);
}
/**
* 删除商品规格
*/
export async function deleteProductSpecApi(id: number) {
return requestClient.delete(`/ec/product-spec/delete/${id}`);
}
/**
* 分页获取商品规格列表
*/
export async function getProductSpecPageApi(
params: PageQueryDTO<ProductSpecDTO.Filters>,
) {
return requestClient.post<PageResultVO<ProductSpecVO.Info>>(
'/ec/product-spec/list',
params,
);
}
/**
* 根据商品名称和规格编码精准查询商品规格
*/
export async function getProductSpecByProductAndSpecApi(
productName: string,
specCode: string,
) {
return requestClient.get<ProductSpecVO.Info>(
`/ec/product-spec/find-by-product-and-spec/${encodeURIComponent(productName)}/${encodeURIComponent(specCode)}`,
);
}
/**
* 批量根据商品名称和规格编码查询商品规格
* 返回商品信息列表,每个商品包含匹配的规格信息
*/
export async function getProductSpecsByProductAndSpecsApi(
queries: ProductSpecDTO.Query[],
) {
return requestClient.post<ProductVO.Info[]>(
'/ec/product-spec/find-by-product-and-specs',
queries,
);
}
/**
* 根据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);
}
/**
* 统计指定规格与时间范围内将参与成本同步的订单数量(与批量同步匹配规则一致)
*/
export async function countOrdersForCostSyncApi(data: ProductSpecDTO.BatchSyncCost) {
return requestClient.post<number>('/ec/product-spec/count-orders-for-cost-sync', data);
}
@@ -1,5 +1,5 @@
/**
* 商品相关DTO类型定义
* 商品相关 DTO 类型定义
*/
export namespace ProductDTO {
@@ -9,12 +9,12 @@ export namespace ProductDTO {
name: string;
/** 商品编码 */
productCode?: string;
/** 类目ID */
/** 类目 ID */
categoryId?: number;
/** 主图图片ID */
/** 主图图片 ID */
mainImageId?: number;
/** 商品规格列表(可选) */
specs?: Spec[];
/** 商品 SKU 列表(可选) */
skus?: Sku[];
}
/** 更新商品参数 */
@@ -23,22 +23,22 @@ export namespace ProductDTO {
name: string;
/** 商品编码 */
productCode?: string;
/** 类目ID */
/** 类目 ID */
categoryId?: number;
/** 主图图片ID */
/** 主图图片 ID */
mainImageId?: number;
/** 商品规格列表:含 id 为更新,不含 id 为新增 */
specs?: UpdateSpec[];
/** 编辑时从商品上移除的规格 ID(须为打开表单时已有的规格) */
removedSpecIds?: number[];
/** 商品 SKU 列表:含 id 为更新,不含 id 为新增 */
skus?: UpdateSku[];
/** 编辑时从商品上移除的 SKU ID(须为打开表单时已有的 SKU) */
removedSkuIds?: number[];
}
/** 商品规格DTO(创建时) */
export interface Spec {
/** 规格名称 */
/** 商品 SKU DTO(创建时) */
export interface Sku {
/** SKU 名称 */
name: string;
/** 规格编码 */
specCode?: string;
/** SKU 编码 */
skuCode?: string;
/** 商品成本 */
productCost: number;
/** 运费成本 */
@@ -49,14 +49,14 @@ export namespace ProductDTO {
remark?: string;
}
/** 创建商品规格参数(独立接口用) */
export interface CreateSpec {
/** 商品ID */
/** 创建商品 SKU 参数(独立接口用) */
export interface CreateSku {
/** 商品 ID */
productId: number;
/** 规格名称 */
/** SKU 名称 */
name: string;
/** 规格编码 */
specCode?: string;
/** SKU 编码 */
skuCode?: string;
/** 商品成本 */
productCost: number;
/** 运费成本 */
@@ -67,14 +67,14 @@ export namespace ProductDTO {
remark?: string;
}
/** 更新商品规格参数 */
export interface UpdateSpec {
/** 规格ID:有值表示更新已有规格;不传或空表示新增一条规格 */
/** 更新商品 SKU 参数 */
export interface UpdateSku {
/** SKU ID:有值表示更新已有 SKU;不传或空表示新增一条 SKU */
id?: number;
/** 规格名称 */
/** SKU 名称 */
name: string;
/** 规格编码 */
specCode?: string;
/** SKU 编码 */
skuCode?: string;
/** 商品成本 */
productCost: number;
/** 运费成本 */
@@ -91,24 +91,24 @@ export namespace ProductDTO {
name?: string;
/** 商品编码(精准查询) */
productCode?: string;
/** 规格编码(精准查询) */
specCode?: string;
/** 规格名称(模糊查询) */
specName?: string;
/** 关键字(模糊查询商品名称、商品编码、规格名称、规格编码) */
/** SKU 编码(精准查询) */
skuCode?: string;
/** SKU 名称(模糊查询) */
skuName?: string;
/** 关键字(模糊查询商品名称、商品编码、SKU 名称、SKU 编码) */
keywords?: string;
}
/** 商品规格过滤条件 */
export interface SpecFilters {
/** 商品ID */
/** 商品 SKU 过滤条件 */
export interface SkuFilters {
/** 商品 ID */
productId?: number;
/** 商品名称(模糊查询) */
productName?: string;
/** 规格名称(模糊查询) */
/** SKU 名称(模糊查询) */
name?: string;
/** 规格编码(模糊查询) */
specCode?: string;
/** SKU 编码(模糊查询) */
skuCode?: string;
/** 成本价范围-最小值 */
minCostPrice?: number;
/** 成本价范围-最大值 */
@@ -1,15 +1,15 @@
/**
* 商品相关VO类型定义
* 商品相关 VO 类型定义
*/
export namespace ProductVO {
/** 商品信息 */
export interface Info {
/** 商品ID */
/** 商品 ID */
id: number;
/** 公司ID */
/** 公司 ID */
companyId: number;
/** 类目ID */
/** 类目 ID */
categoryId?: number;
/** 类目名称 */
categoryName?: string;
@@ -17,51 +17,51 @@ export namespace ProductVO {
name: string;
/** 商品编码 */
productCode?: string;
/** 主图URL */
/** 主图 URL */
mainImage?: string;
/** 创建时间 */
createTime: string;
/** 更新时间 */
updateTime: string;
/** 创建人ID */
/** 创建人 ID */
createBy?: number;
/** 更新人ID */
/** 更新人 ID */
updateBy?: number;
/** 商品规格列表 */
specs?: SpecInfo[];
/** 商品 SKU 列表 */
skus?: SkuInfo[];
}
/** 更新商品响应 */
export interface UpdateProductResult {
/**
* 需提示同步:成本已变更且有关联订单;或新增规格(编码非空、商品/运费/其他成本至少一项大于 0)且有关联订单
* 需提示同步:成本已变更且有关联订单;或新增 SKU(编码非空、成本至少一项大于 0)且有关联订单
*/
specIdsCostChangedWithLinkedOrders: number[];
skuIdsCostChangedWithLinkedOrders: number[];
/** 更新后的商品完整信息 */
product: ProductVO.Info;
}
/** 创建商品响应 */
export interface CreateProductResult {
/** 新增规格:编码非空、至少一项成本大于 0、且有关联订单的规格 ID */
specIdsCostChangedWithLinkedOrders: number[];
/** 新增 SKU:编码非空、至少一项成本大于 0、且有关联订单的 SKU ID */
skuIdsCostChangedWithLinkedOrders: number[];
product: ProductVO.Info;
}
/** 商品规格信息 */
export interface SpecInfo {
/** 规格ID */
/** 商品 SKU 信息 */
export interface SkuInfo {
/** SKU ID */
id: number;
/** 公司ID */
/** 公司 ID */
companyId: number;
/** 商品ID */
/** 商品 ID */
productId: number;
/** 商品名称 */
productName: string;
/** 规格名称 */
/** SKU 名称 */
name: string;
/** 规格编码 */
specCode?: string;
/** SKU 编码 */
skuCode?: string;
/** 商品成本 */
productCost: number;
/** 运费成本 */
@@ -74,9 +74,9 @@ export namespace ProductVO {
createTime: string;
/** 更新时间 */
updateTime: string;
/** 创建人ID */
/** 创建人 ID */
createBy?: number;
/** 更新人ID */
/** 更新人 ID */
updateBy?: number;
}
}
@@ -9,8 +9,8 @@ export namespace ShopDTO {
name: string;
/** logo图片ID */
logoImageId?: number;
/** 平台ID */
platformId?: number;
/** 平台代码 */
platformCode?: string;
}
/** 更新店铺参数 */
@@ -19,16 +19,16 @@ export namespace ShopDTO {
name: string;
/** logo图片ID */
logoImageId?: number;
/** 平台ID */
platformId?: number;
/** 平台代码 */
platformCode?: string;
}
/** 店铺过滤条件 */
export interface Filters {
/** 店铺名称(模糊查询) */
name?: string;
/** 平台ID */
platformId?: number;
/** 平台代码 */
platformCode?: string;
}
/** 店铺商品分页查询过滤条件 */
@@ -43,9 +43,9 @@ export namespace ShopVO {
logo?: string;
/** logo图片ID */
logoImageId?: number;
/** 平台ID */
platformId?: number;
/** 平台名称 */
/** 平台代码 */
platformCode?: string;
/** 平台名称(后端回填) */
platformName?: string;
/** 外部店铺ID(如拼多多 mall_id) */
externalShopId?: null | string;
@@ -185,8 +185,8 @@ export namespace CompanyOverviewVO {
/** 平台维度汇总 */
export interface PlatformSummary {
/** 平台ID */
platformId: number;
/** 平台代码 */
platformCode: string;
/** 平台名称 */
platformName: string;
/** 目标单量 */
@@ -7,8 +7,8 @@ export namespace WorkbenchDTO {
dateRange: string[];
/** 税率,默认 0.04 */
taxRate?: number;
/** 平台 ID,不传表示全平台 */
platformId?: number;
/** 平台代码,不传表示全平台 */
platformCode?: string;
/** 店铺 ID,不传表示当前筛选下全部门店 */
shopId?: number;
}
@@ -16,7 +16,7 @@ export namespace WorkbenchDTO {
/** 工作台四表导出(与后端 WorkbenchExportDTO 对齐) */
export interface ExportPayload extends Query {
shopIds?: number[];
platformIds?: number[];
platformCodes?: string[];
categoryIds?: number[];
productIds?: number[];
}