mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 15:09:19 +08:00
1
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
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/page',
|
||||
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,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 商品规格模块API导出
|
||||
*/
|
||||
|
||||
export * from './apis';
|
||||
export * from './types';
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './types.dto';
|
||||
export * from './types.vo';
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* 商品规格相关DTO类型定义
|
||||
*/
|
||||
|
||||
export namespace ProductSpecDTO {
|
||||
/** 创建商品规格参数 */
|
||||
export interface Create {
|
||||
/** 商品ID */
|
||||
productId: number;
|
||||
/** 规格名称 */
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** 成本价 */
|
||||
costPrice: number;
|
||||
}
|
||||
|
||||
/** 更新商品规格参数 */
|
||||
export interface Update {
|
||||
/** 规格名称 */
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** 成本价 */
|
||||
costPrice: number;
|
||||
}
|
||||
|
||||
/** 商品规格过滤条件 */
|
||||
export interface Filters {
|
||||
/** 商品ID */
|
||||
productId?: number;
|
||||
/** 规格ID */
|
||||
id?: number;
|
||||
/** 规格名称 */
|
||||
name?: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
}
|
||||
|
||||
/** 商品规格查询DTO(用于批量查询) */
|
||||
export interface Query {
|
||||
/** 商品名称 */
|
||||
productName: string;
|
||||
/** 规格编码 */
|
||||
specCode: string;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* 商品规格相关VO类型定义
|
||||
*/
|
||||
|
||||
export namespace ProductSpecVO {
|
||||
/** 商品规格信息 */
|
||||
export interface Info {
|
||||
/** 规格ID */
|
||||
id: number;
|
||||
/** 公司ID */
|
||||
companyId: number;
|
||||
/** 商品ID */
|
||||
productId: number;
|
||||
/** 商品名称 */
|
||||
productName: string;
|
||||
/** 规格名称 */
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** 成本价 */
|
||||
costPrice: number;
|
||||
/** 创建时间 */
|
||||
createTime: string;
|
||||
/** 更新时间 */
|
||||
updateTime: string;
|
||||
/** 创建人ID */
|
||||
createBy?: number;
|
||||
/** 更新人ID */
|
||||
updateBy?: number;
|
||||
}
|
||||
}
|
||||
@@ -40,96 +40,3 @@ export async function updateProductApi(id: number, data: ProductDTO.Update) {
|
||||
export async function deleteProductApi(id: number) {
|
||||
return requestClient.delete(`/ec/product/delete/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品规格管理API
|
||||
*/
|
||||
|
||||
/**
|
||||
* 分页获取商品规格列表
|
||||
*/
|
||||
export async function getProductSpecPageApi(
|
||||
params: PageQueryDTO<ProductDTO.SpecFilters>,
|
||||
) {
|
||||
return requestClient.post<PageResultVO<ProductVO.SpecInfo>>(
|
||||
'/ec/product-spec/page',
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建商品规格
|
||||
*/
|
||||
export async function createProductSpecApi(data: ProductDTO.CreateSpec) {
|
||||
return requestClient.post<ProductVO.SpecInfo>(
|
||||
'/ec/product-spec/create',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品规格
|
||||
*/
|
||||
export async function updateProductSpecApi(
|
||||
id: number,
|
||||
data: ProductDTO.UpdateSpec,
|
||||
) {
|
||||
return requestClient.put<ProductVO.SpecInfo>(
|
||||
`/ec/product-spec/update/${id}`,
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品规格
|
||||
*/
|
||||
export async function deleteProductSpecApi(id: number) {
|
||||
return requestClient.delete(`/ec/product-spec/delete/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 精准查询API - 用于数据导入
|
||||
*/
|
||||
|
||||
/**
|
||||
* 根据名称精准查询商品
|
||||
*/
|
||||
export async function getProductByNameApi(name: string) {
|
||||
return requestClient.get<ProductVO.Info>(
|
||||
`/ec/product/find-by-name/${encodeURIComponent(name)}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量根据名称查询商品
|
||||
*/
|
||||
export async function getProductsByNamesApi(names: string[]) {
|
||||
return requestClient.post<ProductVO.Info[]>(
|
||||
'/ec/product/find-by-names',
|
||||
names,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品名称和规格编码精准查询商品规格
|
||||
*/
|
||||
export async function getProductSpecByProductAndSpecApi(
|
||||
productName: string,
|
||||
specCode: string,
|
||||
) {
|
||||
return requestClient.get<ProductVO.SpecInfo>(
|
||||
`/ec/product-spec/find-by-product-and-spec/${encodeURIComponent(productName)}/${encodeURIComponent(specCode)}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量根据商品名称和规格编码查询商品规格
|
||||
*/
|
||||
export async function getProductSpecsByProductAndSpecsApi(
|
||||
queries: { productName: string; specCode: string }[],
|
||||
) {
|
||||
return requestClient.post<ProductVO.Info[]>(
|
||||
'/ec/product-spec/find-by-product-and-specs',
|
||||
queries,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -21,14 +21,8 @@ export namespace ProductDTO {
|
||||
name: string;
|
||||
/** 商品编码 */
|
||||
productCode?: string;
|
||||
/** 商品编码 */
|
||||
specCode?: string;
|
||||
/** 商品SKU */
|
||||
skuCode?: string;
|
||||
/** 主图图片ID */
|
||||
mainImageId?: number;
|
||||
/** 成本价 */
|
||||
costPrice: number;
|
||||
}
|
||||
|
||||
/** 商品规格DTO */
|
||||
@@ -65,18 +59,12 @@ export namespace ProductDTO {
|
||||
|
||||
/** 商品过滤条件 */
|
||||
export interface Filters {
|
||||
/** 商品ID */
|
||||
id?: number;
|
||||
/** 商品名称(模糊查询) */
|
||||
name?: string;
|
||||
/** 商品编码(模糊查询) */
|
||||
productCode?: string;
|
||||
/** 商品编码(模糊查询) */
|
||||
specCode?: string;
|
||||
/** 商品SKU(模糊查询) */
|
||||
skuCode?: string;
|
||||
/** 成本价范围-最小值 */
|
||||
minCostPrice?: number;
|
||||
/** 成本价范围-最大值 */
|
||||
maxCostPrice?: number;
|
||||
}
|
||||
|
||||
/** 商品规格过滤条件 */
|
||||
|
||||
@@ -50,21 +50,29 @@ export async function uploadShopLogoApi(file: File) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 精准查询API - 用于数据导入
|
||||
* 获取店铺当月统计信息
|
||||
*/
|
||||
|
||||
/**
|
||||
* 根据名称精准查询店铺
|
||||
*/
|
||||
export async function getShopByNameApi(name: string) {
|
||||
return requestClient.get<ShopVO.Info>(
|
||||
`/ec/shop/find-by-name/${encodeURIComponent(name)}`,
|
||||
export async function getShopCurrentMonthStatisticsApi(id: number) {
|
||||
return requestClient.get<ShopVO.Statistics>(
|
||||
`/ec/shop/statistics/current-month/${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量根据名称查询店铺
|
||||
* 获取店铺统计信息
|
||||
*/
|
||||
export async function getShopsByNamesApi(names: string[]) {
|
||||
return requestClient.post<ShopVO.Info[]>('/ec/shop/find-by-names', names);
|
||||
export async function getShopStatisticsApi(params: ShopDTO.StatisticsQuery) {
|
||||
return requestClient.post<ShopVO.Statistics>('/ec/shop/statistics', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取店铺商品详细信息
|
||||
*/
|
||||
export async function getShopProductPageApi(
|
||||
params: PageQueryDTO<ShopDTO.ProductFilters>,
|
||||
) {
|
||||
return requestClient.post<PageResultVO<ShopVO.ProductDetail>>(
|
||||
'/ec/shop/products/page',
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -30,4 +30,26 @@ export namespace ShopDTO {
|
||||
/** 平台 */
|
||||
platform?: string;
|
||||
}
|
||||
|
||||
/** 店铺统计查询参数 */
|
||||
export interface StatisticsQuery {
|
||||
/** 店铺ID */
|
||||
shopId: number;
|
||||
/** 开始日期 */
|
||||
startDate: string;
|
||||
/** 结束日期 */
|
||||
endDate: string;
|
||||
}
|
||||
|
||||
/** 店铺商品过滤条件 */
|
||||
export interface ProductFilters {
|
||||
/** 店铺ID */
|
||||
shopId: number;
|
||||
/** 商品名称(模糊查询) */
|
||||
productName?: string;
|
||||
/** 商品编码(模糊查询) */
|
||||
productCode?: string;
|
||||
/** 统计日期(不传默认为当日) */
|
||||
statDate?: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,4 +26,48 @@ export namespace ShopVO {
|
||||
/** 更新人ID */
|
||||
updateBy?: number;
|
||||
}
|
||||
|
||||
/** 店铺统计信息 */
|
||||
export interface Statistics {
|
||||
/** 销售额(商家实收金额总和) */
|
||||
salesAmount: number;
|
||||
/** 订单数 */
|
||||
orderCount: number;
|
||||
/** 客单价(销售额/订单数) */
|
||||
averageOrderValue: number;
|
||||
/** 成本(成本价*数量总和) */
|
||||
costAmount: number;
|
||||
/** 退款金额(已退款订单的实收金额总和) */
|
||||
refundAmount: number;
|
||||
/** 推广费 */
|
||||
promotionFee: number;
|
||||
/** 费比(推广费/销售额) */
|
||||
feeRatio: number;
|
||||
}
|
||||
|
||||
/** 店铺商品详细信息 */
|
||||
export interface ProductDetail {
|
||||
/** 商品ID */
|
||||
productId: number;
|
||||
/** 商品名称 */
|
||||
productName: string;
|
||||
/** 商品编码 */
|
||||
productCode?: string;
|
||||
/** 主图URL */
|
||||
mainImage?: string;
|
||||
/** 关联ID */
|
||||
relationId: number;
|
||||
/** 排序 */
|
||||
sortOrder: number;
|
||||
/** 创建时间 */
|
||||
createTime: string;
|
||||
/** 更新时间 */
|
||||
updateTime: string;
|
||||
/** 销售额(商家实收金额总和) */
|
||||
salesAmount: number;
|
||||
/** 订单数 */
|
||||
orderCount: number;
|
||||
/** 客单价(销售额/订单数) */
|
||||
averageOrderValue: number;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user