diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/shop/index.ts b/ecom-dmb-frontend/apps/web-antd/src/api/shop/index.ts index c686df5d..ee5cbfcc 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/shop/index.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/shop/index.ts @@ -7,3 +7,6 @@ export * from './shop.apis'; // 商品相关API export * from './product.apis'; + +// 推广费相关API +export * from './promotion-fee.apis'; diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/shop/promotion-fee.apis.ts b/ecom-dmb-frontend/apps/web-antd/src/api/shop/promotion-fee.apis.ts new file mode 100644 index 00000000..b4e2b34d --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/api/shop/promotion-fee.apis.ts @@ -0,0 +1,43 @@ +import { requestClient } from '#/api/request'; + +import type { PageQueryDTO, PageResultVO } from '#/types/common'; +import type { PromotionFeeDTO, PromotionFeeVO } from './types'; + +/** + * 推广费管理API + */ + +/** + * 分页获取推广费记录列表 + */ +export async function getPromotionFeePageApi(params: PageQueryDTO) { + return requestClient.post>('/ec/promotion-fee/page', params); +} + +/** + * 创建推广费记录 + */ +export async function createPromotionFeeApi(data: PromotionFeeDTO.Create) { + return requestClient.post('/ec/promotion-fee', data); +} + +/** + * 更新推广费记录 + */ +export async function updatePromotionFeeApi(data: PromotionFeeDTO.Update) { + return requestClient.put('/ec/promotion-fee', data); +} + +/** + * 删除推广费记录 + */ +export async function deletePromotionFeeApi(id: number) { + return requestClient.delete(`/ec/promotion-fee/${id}`); +} + +/** + * 获取推广费记录详情 + */ +export async function getPromotionFeeByIdApi(id: number) { + return requestClient.get(`/ec/promotion-fee/${id}`); +} diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/shop/types/dto.promotion-fee.ts b/ecom-dmb-frontend/apps/web-antd/src/api/shop/types/dto.promotion-fee.ts new file mode 100644 index 00000000..d439cdaa --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/api/shop/types/dto.promotion-fee.ts @@ -0,0 +1,81 @@ +/** + * 推广费管理相关DTO类型定义 + */ + +export namespace PromotionFeeDTO { + /** 推广费查询过滤条件 */ + export interface Filters { + /** 店铺ID */ + shopId?: number; + /** 推广费类型ID */ + feeTypeId?: number; + /** 平台 */ + platform?: string; + /** 推广费发生日期开始 */ + feeDateStart?: string; + /** 推广费发生日期结束 */ + feeDateEnd?: string; + } + + /** 创建推广费记录 */ + export interface Create { + /** 店铺ID */ + shopId: number; + /** 推广费类型ID */ + feeTypeId: number; + /** 推广费名称 */ + feeName: string; + /** 平台(淘宝、京东、拼多多等) */ + platform?: string; + /** 推广活动名称 */ + campaignName?: string; + /** 推广费金额 */ + feeAmount: number; + /** 基础金额(用于按比例计算) */ + baseAmount?: number; + /** 费率(用于按比例计算) */ + feeRate?: number; + /** 点击次数 */ + clickCount?: number; + /** 展示次数 */ + impressionCount?: number; + /** 转化次数 */ + conversionCount?: number; + /** 推广费发生日期 */ + feeDate: string; + /** 备注 */ + remark?: string; + } + + /** 更新推广费记录 */ + export interface Update { + /** 推广费记录ID */ + id: number; + /** 店铺ID */ + shopId: number; + /** 推广费类型ID */ + feeTypeId: number; + /** 推广费名称 */ + feeName: string; + /** 平台(淘宝、京东、拼多多等) */ + platform?: string; + /** 推广活动名称 */ + campaignName?: string; + /** 推广费金额 */ + feeAmount: number; + /** 基础金额(用于按比例计算) */ + baseAmount?: number; + /** 费率(用于按比例计算) */ + feeRate?: number; + /** 点击次数 */ + clickCount?: number; + /** 展示次数 */ + impressionCount?: number; + /** 转化次数 */ + conversionCount?: number; + /** 推广费发生日期 */ + feeDate: string; + /** 备注 */ + remark?: string; + } +} diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/shop/types/index.ts b/ecom-dmb-frontend/apps/web-antd/src/api/shop/types/index.ts index 875a82f4..579f0043 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/shop/types/index.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/shop/types/index.ts @@ -5,7 +5,9 @@ // DTO类型导出 export * from './dto.shop'; export * from './dto.product'; +export * from './dto.promotion-fee'; // VO类型导出 export * from './vo.shop'; export * from './vo.product'; +export * from './vo.promotion-fee'; diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/shop/types/vo.promotion-fee.ts b/ecom-dmb-frontend/apps/web-antd/src/api/shop/types/vo.promotion-fee.ts new file mode 100644 index 00000000..c8176a01 --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/api/shop/types/vo.promotion-fee.ts @@ -0,0 +1,51 @@ +/** + * 推广费管理相关VO类型定义 + */ + +export namespace PromotionFeeVO { + /** 推广费记录信息 */ + export interface Info { + /** 推广费记录ID */ + id: number; + /** 公司ID */ + companyId: number; + /** 店铺ID */ + shopId: number; + /** 店铺名称 */ + shopName?: string; + /** 推广费类型ID */ + feeTypeId: number; + /** 推广费类型名称 */ + feeTypeName?: string; + /** 推广费名称 */ + feeName: string; + /** 平台(淘宝、京东、拼多多等) */ + platform?: string; + /** 推广活动名称 */ + campaignName?: string; + /** 推广费金额 */ + feeAmount: number; + /** 基础金额(用于按比例计算) */ + baseAmount?: number; + /** 费率(用于按比例计算) */ + feeRate?: number; + /** 点击次数 */ + clickCount?: number; + /** 展示次数 */ + impressionCount?: number; + /** 转化次数 */ + conversionCount?: number; + /** 推广费发生日期 */ + feeDate: string; + /** 备注 */ + remark?: string; + /** 创建时间 */ + createTime: string; + /** 更新时间 */ + updateTime?: string; + /** 创建人ID */ + createBy?: number; + /** 更新人ID */ + updateBy?: number; + } +} diff --git a/ecom-dmb-frontend/apps/web-antd/src/router/routes/modules/shop.ts b/ecom-dmb-frontend/apps/web-antd/src/router/routes/modules/shop.ts index c6010608..af677232 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/router/routes/modules/shop.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/router/routes/modules/shop.ts @@ -37,6 +37,15 @@ const routes: RouteRecordRaw[] = [ title: '订单管理', }, }, + { + name: 'PromotionFeeManagement', + path: '/shop/promotion-fee-management', + component: () => import('#/views/shop/promotion-fee-management/index.vue'), + meta: { + icon: 'lucide:credit-card', + title: '推广费管理', + }, + }, { name: 'ConfigManagement', path: '/shop/config-management', diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/components/MatchSwitchModal.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/components/MatchSwitchModal.vue new file mode 100644 index 00000000..b4171856 --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/components/MatchSwitchModal.vue @@ -0,0 +1,375 @@ + + + + + diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/index.vue index 822f63ef..8b9d15fd 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/index.vue @@ -103,6 +103,106 @@ + + + + + + + + + + + + @@ -166,7 +276,8 @@ import FieldMapping from '#/views/ecommerce/data-import/components/FieldMapping. import FileUploadArea from './components/FileUploadArea.vue' import FileUploadModal from './components/FileUploadModal.vue' import EntityCreationModal from './components/EntityCreationModal.vue' -import { EntityMatchingService, type EntityMatchingResult } from './services/EntityMatchingService' +import MatchSwitchModal from './components/MatchSwitchModal.vue' +import { EntityMatchingService, type EntityMatchingResult, type MatchDetail } from './services/EntityMatchingService' import { batchImportOrdersApi } from '#/api/ecommerce' import { parseOrderCSV, extractShopNameFromFilename, convertToCSVOrderData } from './utils/csvParser' import { useVbenVxeGrid } from '#/adapter/vxe-table' @@ -175,6 +286,8 @@ import type { VxeGridProps } from '#/adapter/vxe-table' // 创建图标组件 const UploadIcon = createIconifyIcon('lucide:upload') const CheckCircleIcon = createIconifyIcon('lucide:check-circle') +const CheckIcon = createIconifyIcon('lucide:check') +const XIcon = createIconifyIcon('lucide:x') // 响应式数据 const uploadedFile = ref(null) @@ -191,6 +304,12 @@ const showEntityCreationModal = ref(false) const importLoading = ref(false) const importProgress = ref(0) +// 匹配切换相关 +const showMatchSwitchModal = ref(false) +const currentMatchDetail = ref(null) +const currentRowData = ref(null) +const currentFieldType = ref<'shop' | 'product' | 'spec' | 'orderStatus'>('shop') + // VbenVxeGrid 表格配置 const gridOptions: VxeGridProps = { columns: [ @@ -209,6 +328,7 @@ const gridOptions: VxeGridProps = { title: '商品名称', minWidth: 'auto', showOverflow: 'tooltip' as const, + slots: { default: 'productName' }, }, { field: 'orderNumber', @@ -220,6 +340,7 @@ const gridOptions: VxeGridProps = { field: 'orderStatusName', title: '订单状态', minWidth: 'auto', + slots: { default: 'orderStatusName' }, }, { field: 'quantity', @@ -237,6 +358,7 @@ const gridOptions: VxeGridProps = { title: '商品规格', minWidth: 'auto', showOverflow: 'tooltip' as const, + slots: { default: 'productSpecName' }, }, { field: 'specCode', @@ -249,6 +371,7 @@ const gridOptions: VxeGridProps = { title: '店铺名称', minWidth: 'auto', showOverflow: 'tooltip' as const, + slots: { default: 'shopName' }, }, { field: 'afterSaleStatus', @@ -490,6 +613,100 @@ const handleMatchRow = (row: any) => { message.info('匹配功能待实现') } + +// 获取匹配详情 +const getMatchDetail = (row: any) => { + if (!matchingResult.value) return null + + return matchingResult.value.matchDetails.find( + detail => detail.originalData.orderNumber === row.orderNumber && + detail.originalData.productName === row.productName + ) +} + +// 店铺匹配状态 +const getShopMatchStatus = (row: any): 'matched' | 'failed' | 'none' => { + const matchDetail = getMatchDetail(row) + if (!matchDetail) return 'none' + + if (matchDetail.matchedShop) return 'matched' + if (matchDetail.status === 'failed' && !matchDetail.matchedShop) return 'failed' + return 'none' +} + +// 商品匹配状态 +const getProductMatchStatus = (row: any): 'matched' | 'failed' | 'none' => { + const matchDetail = getMatchDetail(row) + if (!matchDetail) return 'none' + + if (matchDetail.matchedProduct) return 'matched' + if (matchDetail.status === 'failed' && !matchDetail.matchedProduct) return 'failed' + return 'none' +} + +// 规格匹配状态 +const getSpecMatchStatus = (row: any): 'matched' | 'failed' | 'none' => { + const matchDetail = getMatchDetail(row) + if (!matchDetail) return 'none' + + if (matchDetail.matchedSpec) return 'matched' + if (matchDetail.status === 'failed' && !matchDetail.matchedSpec) return 'failed' + return 'none' +} + +// 订单状态匹配状态 +const getOrderStatusMatchStatus = (row: any): 'matched' | 'failed' | 'none' => { + const matchDetail = getMatchDetail(row) + if (!matchDetail) return 'none' + + if (matchDetail.matchedOrderStatusId) return 'matched' + if (matchDetail.status === 'failed' && !matchDetail.matchedOrderStatusId) return 'failed' + return 'none' +} + + +// 显示匹配模态框 +const showMatchModal = (row: any, fieldType: 'shop' | 'product' | 'spec' | 'orderStatus') => { + const matchDetail = getMatchDetail(row) + if (matchDetail) { + currentMatchDetail.value = matchDetail + currentRowData.value = row + currentFieldType.value = fieldType + showMatchSwitchModal.value = true + } else { + message.warning('未找到该行的匹配信息') + } +} + +// 获取相同数据的数量 +const getSameDataCount = (row: any) => { + if (!row || !matchingResult.value) return 1 + + return matchingResult.value.matchDetails.filter(detail => + detail.originalData.productName === row.productName && + detail.originalData.orderNumber === row.orderNumber + ).length +} + +// 处理应用匹配 +const handleApplyMatch = (rowIndex: number, fieldType: string, matchId: string) => { + message.success(`已应用${fieldType}匹配 - 行 ${rowIndex}, 匹配ID: ${matchId}`) + // 这里可以实现具体的匹配应用逻辑 + // 1. 更新匹配详情 + // 2. 重新计算匹配状态 + // 3. 更新表格显示 +} + +// 处理应用到所有相同数据 +const handleApplyToAll = (rowIndex: number, fieldType: string, matchId: string) => { + message.success(`已应用${fieldType}匹配到所有相同数据 - 行 ${rowIndex}, 匹配ID: ${matchId}`) + // 这里可以实现应用到所有相同数据的逻辑 + // 1. 找到所有相同的数据行 + // 2. 批量更新匹配详情 + // 3. 重新计算匹配状态 + // 4. 更新表格显示 +} + // 格式化文件大小 const formatFileSize = (bytes: number) => { if (bytes === 0) return '0 Bytes' diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/services/EntityMatchingService.ts b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/services/EntityMatchingService.ts index 3d367410..1fa0079b 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/services/EntityMatchingService.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/services/EntityMatchingService.ts @@ -22,6 +22,29 @@ export interface EntityMatchingResult { products: string[]; specs: { productName: string; specCode: string }[]; }; + /** 匹配详情信息 */ + matchDetails: MatchDetail[]; +} + +export interface MatchDetail { + /** 行索引 */ + rowIndex: number; + /** 原始数据 */ + originalData: CSVOrderData; + /** 匹配状态 */ + status: 'matched' | 'failed' | 'partial'; + /** 匹配的店铺信息 */ + matchedShop?: ShopVO.Info; + /** 匹配的商品信息 */ + matchedProduct?: ProductVO.Info; + /** 匹配的规格信息 */ + matchedSpec?: ProductVO.SpecInfo; + /** 匹配的订单状态ID */ + matchedOrderStatusId?: number; + /** 失败原因 */ + failureReason?: string; + /** 生成的订单数据(如果匹配成功) */ + orderData?: OrderDTO.Create; } export interface FailedRecord { @@ -101,6 +124,7 @@ export class EntityMatchingService { const matchedOrders: OrderDTO.Create[] = []; const failedRecords: FailedRecord[] = []; + const matchDetails: MatchDetail[] = []; const entitiesToCreate = { shops: new Set(), products: new Set(), @@ -112,10 +136,17 @@ export class EntityMatchingService { // 检查行数据是否存在 if (!row) { - failedRecords.push({ + const failedRecord = { rowIndex: i + 1, originalData: null, reason: '行数据为空' + }; + failedRecords.push(failedRecord); + matchDetails.push({ + rowIndex: i + 1, + originalData: row || {} as CSVOrderData, + status: 'failed', + failureReason: '行数据为空' }); continue; } @@ -125,10 +156,17 @@ export class EntityMatchingService { const shop = this.shopCache.get(row.shopName); if (!shop) { entitiesToCreate.shops.add(row.shopName); - failedRecords.push({ + const failedRecord = { rowIndex: i + 1, originalData: row, reason: `店铺 "${row.shopName}" 不存在` + }; + failedRecords.push(failedRecord); + matchDetails.push({ + rowIndex: i + 1, + originalData: row, + status: 'failed', + failureReason: `店铺 "${row.shopName}" 不存在` }); continue; } @@ -137,10 +175,18 @@ export class EntityMatchingService { const product = this.productCache.get(row.productName); if (!product) { entitiesToCreate.products.add(row.productName); - failedRecords.push({ + const failedRecord = { rowIndex: i + 1, originalData: row, reason: `商品 "${row.productName}" 不存在` + }; + failedRecords.push(failedRecord); + matchDetails.push({ + rowIndex: i + 1, + originalData: row, + status: 'failed', + matchedShop: shop, + failureReason: `商品 "${row.productName}" 不存在` }); continue; } @@ -150,10 +196,19 @@ export class EntityMatchingService { const spec = this.specCache.get(specKey); if (!spec) { entitiesToCreate.specs.add({ productName: row.productName, specCode: row.specCode }); - failedRecords.push({ + const failedRecord = { rowIndex: i + 1, originalData: row, reason: `商品规格 "${row.productName}" - "${row.specCode}" 不存在` + }; + failedRecords.push(failedRecord); + matchDetails.push({ + rowIndex: i + 1, + originalData: row, + status: 'failed', + matchedShop: shop, + matchedProduct: product, + failureReason: `商品规格 "${row.productName}" - "${row.specCode}" 不存在` }); continue; } @@ -161,10 +216,20 @@ export class EntityMatchingService { // 匹配订单状态 const orderStatusId = this.orderStatusMap.get(row.orderStatusName); if (!orderStatusId) { - failedRecords.push({ + const failedRecord = { rowIndex: i + 1, originalData: row, reason: `订单状态 "${row.orderStatusName}" 不存在` + }; + failedRecords.push(failedRecord); + matchDetails.push({ + rowIndex: i + 1, + originalData: row, + status: 'failed', + matchedShop: shop, + matchedProduct: product, + matchedSpec: spec, + failureReason: `订单状态 "${row.orderStatusName}" 不存在` }); continue; } @@ -202,11 +267,30 @@ export class EntityMatchingService { }; matchedOrders.push(orderData); + + // 添加匹配成功的详情 + matchDetails.push({ + rowIndex: i + 1, + originalData: row, + status: 'matched', + matchedShop: shop, + matchedProduct: product, + matchedSpec: spec, + matchedOrderStatusId: orderStatusId, + orderData: orderData + }); } catch (error) { - failedRecords.push({ + const failedRecord = { rowIndex: i + 1, originalData: row, reason: `处理失败: ${error instanceof Error ? error.message : '未知错误'}` + }; + failedRecords.push(failedRecord); + matchDetails.push({ + rowIndex: i + 1, + originalData: row, + status: 'failed', + failureReason: `处理失败: ${error instanceof Error ? error.message : '未知错误'}` }); } } @@ -218,7 +302,8 @@ export class EntityMatchingService { shops: Array.from(entitiesToCreate.shops), products: Array.from(entitiesToCreate.products), specs: Array.from(entitiesToCreate.specs) - } + }, + matchDetails }; } diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/shop/promotion-fee-management/components/PromotionFeeFormModal.vue b/ecom-dmb-frontend/apps/web-antd/src/views/shop/promotion-fee-management/components/PromotionFeeFormModal.vue new file mode 100644 index 00000000..ab6cffae --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/views/shop/promotion-fee-management/components/PromotionFeeFormModal.vue @@ -0,0 +1,354 @@ + + + diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/shop/promotion-fee-management/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/shop/promotion-fee-management/index.vue new file mode 100644 index 00000000..2cec5ab3 --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/views/shop/promotion-fee-management/index.vue @@ -0,0 +1,345 @@ + + +