feat(project): sync all pending tenant ui changes

This commit is contained in:
2026-02-20 16:50:20 +08:00
parent 937c9b4334
commit 788491ad3d
34 changed files with 7527 additions and 95 deletions

View File

@@ -1,7 +1,7 @@
/**
* 文件职责:商品管理模块 API 与 DTO 定义。
* 1. 维护商品列表、分类、详情、批量操作契约。
* 2. 提供商品查询、保存、状态变更、沽清与批量动作接口。
* 2. 提供分类、规格、加料、标签、时段供应等扩展模块接口。
*/
import type { PaginatedResult } from '#/api/store';
@@ -16,7 +16,32 @@ export type ProductKind = 'combo' | 'single';
/** 沽清模式。 */
export type ProductSoldoutMode = 'permanent' | 'timed' | 'today';
/** 分类信息。 */
/** 分类展示渠道。 */
export type ProductCategoryChannel = 'dine_in' | 'pickup' | 'wm';
/** 通用启停状态。 */
export type ProductSwitchStatus = 'disabled' | 'enabled';
/** 商品选择器项。 */
export interface ProductPickerItemDto {
categoryId: string;
categoryName: string;
id: string;
name: string;
price: number;
spuCode: string;
status: ProductStatus;
}
/** 商品选择器查询参数。 */
export interface ProductPickerQuery {
categoryId?: string;
keyword?: string;
limit?: number;
storeId: string;
}
/** 分类信息(列表页侧栏)。 */
export interface ProductCategoryDto {
id: string;
name: string;
@@ -24,6 +49,72 @@ export interface ProductCategoryDto {
sort: number;
}
/** 分类管理项。 */
export interface ProductCategoryManageDto extends ProductCategoryDto {
channels: ProductCategoryChannel[];
description: string;
icon: string;
status: ProductSwitchStatus;
}
/** 分类管理查询参数。 */
export interface ProductCategoryManageQuery {
keyword?: string;
status?: ProductSwitchStatus;
storeId: string;
}
/** 保存分类参数。 */
export interface SaveProductCategoryDto {
channels: ProductCategoryChannel[];
description: string;
icon: string;
id?: string;
name: string;
sort: number;
status: ProductSwitchStatus;
storeId: string;
}
/** 删除分类参数。 */
export interface DeleteProductCategoryDto {
categoryId: string;
storeId: string;
}
/** 分类状态变更参数。 */
export interface ChangeProductCategoryStatusDto {
categoryId: string;
status: ProductSwitchStatus;
storeId: string;
}
/** 分类排序项。 */
export interface ProductCategorySortItemDto {
categoryId: string;
sort: number;
}
/** 分类排序参数。 */
export interface SortProductCategoryDto {
items: ProductCategorySortItemDto[];
storeId: string;
}
/** 分类绑定商品参数。 */
export interface BindCategoryProductsDto {
categoryId: string;
productIds: string[];
storeId: string;
}
/** 分类解绑商品参数。 */
export interface UnbindCategoryProductDto {
categoryId: string;
productId: string;
storeId: string;
}
/** 商品列表项。 */
export interface ProductListItemDto {
categoryId: string;
@@ -141,13 +232,346 @@ export interface BatchProductActionResultDto {
totalCount: number;
}
/** 获取商品分类。 */
/** 规格值。 */
export interface ProductSpecValueDto {
extraPrice: number;
id: string;
name: string;
sort: number;
}
/** 规格配置。 */
export interface ProductSpecDto {
description: string;
id: string;
name: string;
productCount: number;
productIds: string[];
sort: number;
status: ProductSwitchStatus;
updatedAt: string;
values: ProductSpecValueDto[];
}
/** 规格查询参数。 */
export interface ProductSpecQuery {
keyword?: string;
status?: ProductSwitchStatus;
storeId: string;
}
/** 保存规格参数。 */
export interface SaveProductSpecDto {
description: string;
id?: string;
name: string;
productIds: string[];
sort: number;
status: ProductSwitchStatus;
storeId: string;
values: Array<{
extraPrice: number;
id?: string;
name: string;
sort: number;
}>;
}
/** 删除规格参数。 */
export interface DeleteProductSpecDto {
specId: string;
storeId: string;
}
/** 规格状态变更参数。 */
export interface ChangeProductSpecStatusDto {
specId: string;
status: ProductSwitchStatus;
storeId: string;
}
/** 加料项。 */
export interface ProductAddonItemDto {
id: string;
name: string;
price: number;
sort: number;
status: ProductSwitchStatus;
}
/** 加料组。 */
export interface ProductAddonGroupDto {
description: string;
id: string;
items: ProductAddonItemDto[];
maxSelect: number;
minSelect: number;
name: string;
productCount: number;
productIds: string[];
required: boolean;
sort: number;
status: ProductSwitchStatus;
updatedAt: string;
}
/** 加料组查询参数。 */
export interface ProductAddonQuery {
keyword?: string;
status?: ProductSwitchStatus;
storeId: string;
}
/** 保存加料组参数。 */
export interface SaveProductAddonGroupDto {
description: string;
id?: string;
items: Array<{
id?: string;
name: string;
price: number;
sort: number;
status: ProductSwitchStatus;
}>;
maxSelect: number;
minSelect: number;
name: string;
productIds: string[];
required: boolean;
sort: number;
status: ProductSwitchStatus;
storeId: string;
}
/** 删除加料组参数。 */
export interface DeleteProductAddonGroupDto {
groupId: string;
storeId: string;
}
/** 加料组状态变更参数。 */
export interface ChangeProductAddonGroupStatusDto {
groupId: string;
status: ProductSwitchStatus;
storeId: string;
}
/** 商品标签。 */
export interface ProductLabelDto {
color: string;
description: string;
id: string;
name: string;
productCount: number;
productIds: string[];
sort: number;
status: ProductSwitchStatus;
updatedAt: string;
}
/** 标签查询参数。 */
export interface ProductLabelQuery {
keyword?: string;
status?: ProductSwitchStatus;
storeId: string;
}
/** 保存标签参数。 */
export interface SaveProductLabelDto {
color: string;
description: string;
id?: string;
name: string;
productIds: string[];
sort: number;
status: ProductSwitchStatus;
storeId: string;
}
/** 删除标签参数。 */
export interface DeleteProductLabelDto {
labelId: string;
storeId: string;
}
/** 标签状态变更参数。 */
export interface ChangeProductLabelStatusDto {
labelId: string;
status: ProductSwitchStatus;
storeId: string;
}
/** 时段条目。 */
export interface ProductScheduleSlotDto {
endTime: string;
id: string;
startTime: string;
weekDays: number[];
}
/** 时段模板。 */
export interface ProductScheduleDto {
description: string;
id: string;
name: string;
productCount: number;
productIds: string[];
slots: ProductScheduleSlotDto[];
sort: number;
status: ProductSwitchStatus;
updatedAt: string;
}
/** 时段查询参数。 */
export interface ProductScheduleQuery {
keyword?: string;
status?: ProductSwitchStatus;
storeId: string;
}
/** 保存时段参数。 */
export interface SaveProductScheduleDto {
description: string;
id?: string;
name: string;
productIds: string[];
slots: Array<{
endTime: string;
id?: string;
startTime: string;
weekDays: number[];
}>;
sort: number;
status: ProductSwitchStatus;
storeId: string;
}
/** 删除时段参数。 */
export interface DeleteProductScheduleDto {
scheduleId: string;
storeId: string;
}
/** 时段状态变更参数。 */
export interface ChangeProductScheduleStatusDto {
scheduleId: string;
status: ProductSwitchStatus;
storeId: string;
}
/** 批量范围。 */
export interface ProductBatchScopeDto {
categoryId?: string;
productIds?: string[];
type: 'all' | 'category' | 'selected';
}
/** 批量调价参数。 */
export interface ProductBatchAdjustPriceDto {
amount: number;
mode: 'decrease' | 'increase' | 'set';
scope: ProductBatchScopeDto;
storeId: string;
}
/** 批量移动分类参数。 */
export interface ProductBatchMoveCategoryDto {
scope: ProductBatchScopeDto;
storeId: string;
targetCategoryId: string;
}
/** 批量上下架参数。 */
export interface ProductBatchSaleSwitchDto {
action: 'off' | 'on';
scope: ProductBatchScopeDto;
storeId: string;
}
/** 批量同步门店参数。 */
export interface ProductBatchSyncStoreDto {
productIds: string[];
sourceStoreId: string;
targetStoreIds: string[];
}
/** 批量工具通用结果。 */
export interface ProductBatchToolResultDto {
failedCount: number;
successCount: number;
totalCount: number;
}
/** 导入导出请求参数。 */
export interface ProductBatchImportExportDto {
scope: ProductBatchScopeDto;
storeId: string;
}
/** 导入导出回执。 */
export interface ProductBatchImportExportResultDto {
exportedCount?: number;
failedCount: number;
fileName: string;
skippedCount?: number;
successCount: number;
totalCount: number;
}
/** 获取商品分类(侧栏口径)。 */
export async function getProductCategoryListApi(storeId: string) {
return requestClient.get<ProductCategoryDto[]>('/product/category/list', {
params: { storeId },
});
}
/** 获取分类管理列表。 */
export async function getProductCategoryManageListApi(
params: ProductCategoryManageQuery,
) {
return requestClient.get<ProductCategoryManageDto[]>(
'/product/category/manage/list',
{
params,
},
);
}
/** 保存分类。 */
export async function saveProductCategoryApi(data: SaveProductCategoryDto) {
return requestClient.post<ProductCategoryManageDto>(
'/product/category/manage/save',
data,
);
}
/** 删除分类。 */
export async function deleteProductCategoryApi(data: DeleteProductCategoryDto) {
return requestClient.post('/product/category/manage/delete', data);
}
/** 修改分类状态。 */
export async function changeProductCategoryStatusApi(
data: ChangeProductCategoryStatusDto,
) {
return requestClient.post('/product/category/manage/status', data);
}
/** 批量排序分类。 */
export async function sortProductCategoryApi(data: SortProductCategoryDto) {
return requestClient.post('/product/category/manage/sort', data);
}
/** 将商品绑定到分类。 */
export async function bindCategoryProductsApi(data: BindCategoryProductsDto) {
return requestClient.post('/product/category/manage/products/bind', data);
}
/** 从分类解绑单个商品。 */
export async function unbindCategoryProductApi(data: UnbindCategoryProductDto) {
return requestClient.post('/product/category/manage/products/unbind', data);
}
/** 获取商品列表。 */
export async function getProductListApi(params: ProductListQuery) {
return requestClient.get<PaginatedResult<ProductListItemDto>>(
@@ -185,10 +609,175 @@ export async function soldoutProductApi(data: SoldoutProductDto) {
return requestClient.post('/product/soldout', data);
}
/** 批量商品操作。 */
/** 批量商品操作(列表页)。 */
export async function batchProductActionApi(data: BatchProductActionDto) {
return requestClient.post<BatchProductActionResultDto>(
'/product/batch',
data,
);
}
/** 获取规格列表。 */
export async function getProductSpecListApi(params: ProductSpecQuery) {
return requestClient.get<ProductSpecDto[]>('/product/spec/list', {
params,
});
}
/** 保存规格。 */
export async function saveProductSpecApi(data: SaveProductSpecDto) {
return requestClient.post<ProductSpecDto>('/product/spec/save', data);
}
/** 删除规格。 */
export async function deleteProductSpecApi(data: DeleteProductSpecDto) {
return requestClient.post('/product/spec/delete', data);
}
/** 修改规格状态。 */
export async function changeProductSpecStatusApi(
data: ChangeProductSpecStatusDto,
) {
return requestClient.post('/product/spec/status', data);
}
/** 获取加料组列表。 */
export async function getProductAddonGroupListApi(params: ProductAddonQuery) {
return requestClient.get<ProductAddonGroupDto[]>(
'/product/addon/group/list',
{
params,
},
);
}
/** 保存加料组。 */
export async function saveProductAddonGroupApi(data: SaveProductAddonGroupDto) {
return requestClient.post<ProductAddonGroupDto>(
'/product/addon/group/save',
data,
);
}
/** 删除加料组。 */
export async function deleteProductAddonGroupApi(
data: DeleteProductAddonGroupDto,
) {
return requestClient.post('/product/addon/group/delete', data);
}
/** 修改加料组状态。 */
export async function changeProductAddonGroupStatusApi(
data: ChangeProductAddonGroupStatusDto,
) {
return requestClient.post('/product/addon/group/status', data);
}
/** 获取标签列表。 */
export async function getProductLabelListApi(params: ProductLabelQuery) {
return requestClient.get<ProductLabelDto[]>('/product/label/list', {
params,
});
}
/** 保存标签。 */
export async function saveProductLabelApi(data: SaveProductLabelDto) {
return requestClient.post<ProductLabelDto>('/product/label/save', data);
}
/** 删除标签。 */
export async function deleteProductLabelApi(data: DeleteProductLabelDto) {
return requestClient.post('/product/label/delete', data);
}
/** 修改标签状态。 */
export async function changeProductLabelStatusApi(
data: ChangeProductLabelStatusDto,
) {
return requestClient.post('/product/label/status', data);
}
/** 获取时段列表。 */
export async function getProductScheduleListApi(params: ProductScheduleQuery) {
return requestClient.get<ProductScheduleDto[]>('/product/schedule/list', {
params,
});
}
/** 保存时段。 */
export async function saveProductScheduleApi(data: SaveProductScheduleDto) {
return requestClient.post<ProductScheduleDto>('/product/schedule/save', data);
}
/** 删除时段。 */
export async function deleteProductScheduleApi(data: DeleteProductScheduleDto) {
return requestClient.post('/product/schedule/delete', data);
}
/** 修改时段状态。 */
export async function changeProductScheduleStatusApi(
data: ChangeProductScheduleStatusDto,
) {
return requestClient.post('/product/schedule/status', data);
}
/** 批量调价。 */
export async function batchAdjustProductPriceApi(
data: ProductBatchAdjustPriceDto,
) {
return requestClient.post<ProductBatchToolResultDto>(
'/product/batch/price-adjust',
data,
);
}
/** 批量移动分类。 */
export async function batchMoveProductCategoryApi(
data: ProductBatchMoveCategoryDto,
) {
return requestClient.post<ProductBatchToolResultDto>(
'/product/batch/move-category',
data,
);
}
/** 批量上下架。 */
export async function batchSwitchProductSaleApi(
data: ProductBatchSaleSwitchDto,
) {
return requestClient.post<ProductBatchToolResultDto>(
'/product/batch/sale-switch',
data,
);
}
/** 批量同步门店。 */
export async function batchSyncProductStoreApi(data: ProductBatchSyncStoreDto) {
return requestClient.post<ProductBatchToolResultDto>(
'/product/batch/store-sync',
data,
);
}
/** 批量导入。 */
export async function batchImportProductApi(data: ProductBatchImportExportDto) {
return requestClient.post<ProductBatchImportExportResultDto>(
'/product/batch/import',
data,
);
}
/** 批量导出。 */
export async function batchExportProductApi(data: ProductBatchImportExportDto) {
return requestClient.post<ProductBatchImportExportResultDto>(
'/product/batch/export',
data,
);
}
/** 商品选择器列表。 */
export async function searchProductPickerApi(params: ProductPickerQuery) {
return requestClient.get<ProductPickerItemDto[]>('/product/picker/list', {
params,
});
}