diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/bi/overview/model/vo/CompanyOverviewVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/bi/overview/model/vo/CompanyOverviewVO.java index d0d2df1e..b59b74a6 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/bi/overview/model/vo/CompanyOverviewVO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/bi/overview/model/vo/CompanyOverviewVO.java @@ -252,8 +252,15 @@ public class CompanyOverviewVO { private BigDecimal orderCost; + /** 退款金额(计入经营规模) */ private BigDecimal refundAmount; + /** 退款单量 */ + private Integer refundOrderCount; + + /** 退款件数 */ + private Integer refundQuantitySum; + private BigDecimal totalPromotionFee; private BigDecimal brushFee; @@ -310,8 +317,15 @@ public class CompanyOverviewVO { private BigDecimal orderCost; + /** 退款金额(计入经营规模) */ private BigDecimal refundAmount; + /** 退款单量 */ + private Integer refundOrderCount; + + /** 退款件数 */ + private Integer refundQuantitySum; + private BigDecimal totalPromotionFee; private BigDecimal brushFee; @@ -376,8 +390,15 @@ public class CompanyOverviewVO { private BigDecimal orderCost; + /** 退款金额(计入经营规模) */ private BigDecimal refundAmount; + /** 退款单量 */ + private Integer refundOrderCount; + + /** 退款件数 */ + private Integer refundQuantitySum; + private BigDecimal totalPromotionFee; private BigDecimal brushFee; diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/bi/overview/service/impl/CompanyOverviewServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/bi/overview/service/impl/CompanyOverviewServiceImpl.java index d1dcffbe..30488e17 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/bi/overview/service/impl/CompanyOverviewServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/bi/overview/service/impl/CompanyOverviewServiceImpl.java @@ -574,6 +574,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService { s.setOtherCost(m.otherCost); s.setOrderCost(m.orderCost()); s.setRefundAmount(m.refund); + s.setRefundOrderCount(m.refundOrderCount); + s.setRefundQuantitySum(m.refundQuantitySum); s.setTotalPromotionFee(promo); s.setBrushFee(brush); s.setFeeRatio(safeDivide(promo, m.sales)); @@ -605,6 +607,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService { s.setOtherCost(m.otherCost); s.setOrderCost(m.orderCost()); s.setRefundAmount(m.refund); + s.setRefundOrderCount(m.refundOrderCount); + s.setRefundQuantitySum(m.refundQuantitySum); s.setTotalPromotionFee(promo); s.setBrushFee(brush); s.setFeeRatio(safeDivide(promo, m.sales)); @@ -632,6 +636,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService { s.setOtherCost(m.otherCost); s.setOrderCost(m.orderCost()); s.setRefundAmount(m.refund); + s.setRefundOrderCount(m.refundOrderCount); + s.setRefundQuantitySum(m.refundQuantitySum); s.setTotalPromotionFee(promo); s.setBrushFee(brush); s.setFeeRatio(safeDivide(promo.add(brush), m.sales)); @@ -786,6 +792,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService { int dealQuantitySum; int salesQuantitySum; BigDecimal refund = BigDecimal.ZERO; + int refundOrderCount; + int refundQuantitySum; BigDecimal productCost = BigDecimal.ZERO; BigDecimal freightCost = BigDecimal.ZERO; BigDecimal otherCost = BigDecimal.ZERO; @@ -809,6 +817,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService { a.dealQuantitySum = row.getDealQuantitySum() != null ? row.getDealQuantitySum().intValue() : 0; a.salesQuantitySum = row.getSalesQuantitySum() != null ? row.getSalesQuantitySum().intValue() : 0; a.refund = nz(row.getRefundAmount()); + a.refundOrderCount = row.getRefundOrderCount() != null ? row.getRefundOrderCount().intValue() : 0; + a.refundQuantitySum = row.getRefundQuantitySum() != null ? row.getRefundQuantitySum().intValue() : 0; a.productCost = nz(row.getProductCost()); a.freightCost = nz(row.getFreightCost()); a.otherCost = nz(row.getOtherCost()); @@ -824,6 +834,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService { a.dealQuantitySum = dealQuantitySum + o.dealQuantitySum; a.salesQuantitySum = salesQuantitySum + o.salesQuantitySum; a.refund = refund.add(o.refund); + a.refundOrderCount = refundOrderCount + o.refundOrderCount; + a.refundQuantitySum = refundQuantitySum + o.refundQuantitySum; a.productCost = productCost.add(o.productCost); a.freightCost = freightCost.add(o.freightCost); a.otherCost = otherCost.add(o.otherCost); diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/bi/overview/types/types.vo.ts b/ecom-dmb-frontend/apps/web-antd/src/api/bi/overview/types/types.vo.ts index e3501ab5..8131aad2 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/bi/overview/types/types.vo.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/bi/overview/types/types.vo.ts @@ -113,7 +113,12 @@ export namespace CompanyOverviewVO { otherCost?: number; /** 订单成本(商品成本+运费+其他成本,不含推广费、刷单费) */ orderCost?: number; + /** 退款金额(经营规模) */ refundAmount?: number; + /** 退款单量 */ + refundOrderCount?: number; + /** 退款件数 */ + refundQuantitySum?: number; totalPromotionFee?: number; brushFee?: number; /** 费比(推广费/销售额,小数) */ @@ -141,7 +146,12 @@ export namespace CompanyOverviewVO { shippingCost?: number; otherCost?: number; orderCost?: number; + /** 退款金额(经营规模) */ refundAmount?: number; + /** 退款单量 */ + refundOrderCount?: number; + /** 退款件数 */ + refundQuantitySum?: number; totalPromotionFee?: number; brushFee?: number; feeRatio?: number; @@ -172,7 +182,12 @@ export namespace CompanyOverviewVO { shippingCost?: number; otherCost?: number; orderCost?: number; + /** 退款金额(经营规模) */ refundAmount?: number; + /** 退款单量 */ + refundOrderCount?: number; + /** 退款件数 */ + refundQuantitySum?: number; totalPromotionFee?: number; brushFee?: number; feeRatio?: number; diff --git a/ecom-dmb-frontend/apps/web-antd/src/utils/overview-table-hints.ts b/ecom-dmb-frontend/apps/web-antd/src/utils/overview-table-hints.ts index 466f2252..1a63658f 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/utils/overview-table-hints.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/utils/overview-table-hints.ts @@ -30,6 +30,8 @@ export const overviewTableHints = { otherCost: '其他成本合计。', orderCost: '商品成本 + 运费 + 其他成本。', refundAmount: '计入退款状态的商家实收合计。', + refundOrderCount: '计入退款状态的订单笔数。', + refundQuantitySum: '计入退款状态的商品件数合计。', totalPromotionFee: '推广费合计。', promotionFeeSku: '店铺推广费 *(该 SKU 订单数 / 区间总订单数)。', /** @deprecated 使用 promotionFeeSku */ diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/CategorySummaryTable.vue b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/CategorySummaryTable.vue index 8ae47a76..c1f25fa4 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/CategorySummaryTable.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/CategorySummaryTable.vue @@ -203,6 +203,12 @@ const cellRoi = (v: number | null | undefined) => > 成交金额 + + 退款金额 + 成交单量 + + 退款单量 + 净销售单量 成交量 + + 退款件数 + 净销量 @@ -247,12 +259,6 @@ const cellRoi = (v: number | null | undefined) => > 订单成本 - - 退款金额 - + {{ formatIntCell(cat.dealOrderCount) }} + {{ formatIntCell(cat.refundOrderCount) }} {{ formatIntCell(cat.salesOrderCount) }} {{ formatIntCell(cat.dealQuantitySum) }} + {{ formatIntCell(cat.refundQuantitySum) }} {{ formatIntCell(cat.salesQuantitySum) }} @@ -365,12 +374,6 @@ const cellRoi = (v: number | null | undefined) => > - - - 合计 + {{ formatIntCell(categorySummary?.total?.dealOrderCount) }} + {{ formatIntCell(categorySummary?.total?.refundOrderCount) }} {{ formatIntCell(categorySummary?.total?.salesOrderCount) }} {{ formatIntCell(categorySummary?.total?.dealQuantitySum) }} + {{ formatIntCell(categorySummary?.total?.refundQuantitySum) }} {{ formatIntCell(categorySummary?.total?.salesQuantitySum) }} @@ -432,7 +438,6 @@ const cellRoi = (v: number | null | undefined) => - diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/PlatformSummaryCard.vue b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/PlatformSummaryCard.vue index 4e6c85cb..3893cca0 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/PlatformSummaryCard.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/PlatformSummaryCard.vue @@ -86,9 +86,12 @@ const platformData = computed(() => { salesAmountAchievementRate: p.salesAmountAchievementRate ?? 0, salesAmount: p.salesAmount ?? 0, dealAmount: p.dealAmount ?? 0, + refundAmount: p.refundAmount ?? 0, salesOrderCount: p.salesOrderCount ?? 0, dealOrderCount: p.dealOrderCount ?? 0, + refundOrderCount: p.refundOrderCount ?? 0, dealQuantitySum: p.dealQuantitySum ?? 0, + refundQuantitySum: p.refundQuantitySum ?? 0, salesQuantitySum: p.salesQuantitySum ?? 0, salesAverageOrderValue: p.salesAverageOrderValue ?? 0, dealAverageOrderValue: p.dealAverageOrderValue ?? 0, @@ -96,7 +99,6 @@ const platformData = computed(() => { shippingCost: p.shippingCost ?? 0, otherCost: p.otherCost ?? 0, orderCost: p.orderCost ?? 0, - refundAmount: p.refundAmount ?? 0, totalPromotionFee: p.totalPromotionFee ?? 0, brushFee: p.brushFee ?? 0, feeRatio: p.feeRatio ?? 0, @@ -294,6 +296,12 @@ const sortedData = computed(() => { > 成交金额 + + 退款金额 + { > 成交单量 + + 退款单量 + { > 成交量 + + 退款件数 + { > 订单成本 - - 退款金额 - { {{ formatPercentPlain(p.salesAmountAchievementRate) }} + {{ formatIntCell(p.dealOrderCount) }} + {{ formatIntCell(p.refundOrderCount) }} {{ formatIntCell(p.salesOrderCount) }} {{ formatIntCell(p.dealQuantitySum) }} + {{ formatIntCell(p.refundQuantitySum) }} {{ formatIntCell(p.salesQuantitySum) }} @@ -478,7 +495,6 @@ const sortedData = computed(() => { - @@ -522,10 +538,13 @@ const sortedData = computed(() => { + {{ formatIntCell(totalData.dealOrderCount) }} + {{ formatIntCell(totalData.refundOrderCount) }} {{ formatIntCell(totalData.salesOrderCount) }} {{ formatIntCell(totalData.dealQuantitySum) }} + {{ formatIntCell(totalData.refundQuantitySum) }} {{ formatIntCell(totalData.salesQuantitySum) }} @@ -538,7 +557,6 @@ const sortedData = computed(() => { - diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/ShopSummaryTable.vue b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/ShopSummaryTable.vue index 4ad2e7f7..974b973c 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/ShopSummaryTable.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/ShopSummaryTable.vue @@ -226,13 +226,19 @@ const cellRoi = (v: number | null | undefined) => 销售达成率 - + 成交金额 + + 退款金额 + 成交单量 + + 退款单量 + 净销售单量 成交量 + + 退款件数 + 净销量 @@ -278,12 +290,6 @@ const cellRoi = (v: number | null | undefined) => > 订单成本 - - 退款金额 - > + + + {{ formatIntCell(shop.dealOrderCount) }} + + {{ formatIntCell(shop.refundOrderCount) }} + {{ formatIntCell(shop.salesOrderCount) }} {{ formatIntCell(shop.dealQuantitySum) }} + + {{ formatIntCell(shop.refundQuantitySum) }} + {{ formatIntCell(shop.salesQuantitySum) }} @@ -441,12 +459,6 @@ const cellRoi = (v: number | null | undefined) => > - - - + {{ formatIntCell(shopSummary?.total?.dealOrderCount) }} + {{ formatIntCell(shopSummary?.total?.refundOrderCount) }} {{ formatIntCell(shopSummary?.total?.salesOrderCount) }} {{ formatIntCell(shopSummary?.total?.dealQuantitySum) }} + {{ formatIntCell(shopSummary?.total?.refundQuantitySum) }} {{ formatIntCell(shopSummary?.total?.salesQuantitySum) }} @@ -545,7 +560,6 @@ const cellRoi = (v: number | null | undefined) => - diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/composables/useOverviewTableColumnPrefs.ts b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/composables/useOverviewTableColumnPrefs.ts index dcdb71f9..f8d88d1b 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/composables/useOverviewTableColumnPrefs.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/composables/useOverviewTableColumnPrefs.ts @@ -8,6 +8,7 @@ import type { import { columnsForTable, defaultVisibleIds, + OVERVIEW_COLUMN_AUTO_APPEND, OVERVIEW_TABLE_COLUMN_PREFS_KEY, } from '../constants/overview-table-columns'; @@ -17,11 +18,21 @@ function normalizeIds( tableKey: OverviewTableKey, raw: string[] | undefined, ): OverviewColumnId[] { - const allowed = new Set(columnsForTable(tableKey).map((c) => c.id)); + const order = columnsForTable(tableKey).map((c) => c.id); + const allowed = new Set(order); const picked = (raw ?? []).filter((id): id is OverviewColumnId => allowed.has(id as OverviewColumnId), ); - return picked.length > 0 ? picked : defaultVisibleIds(tableKey); + if (picked.length === 0) { + return defaultVisibleIds(tableKey); + } + // 新列(如退款单量/件数)历史偏好没有时自动勾选 + for (const id of OVERVIEW_COLUMN_AUTO_APPEND) { + if (allowed.has(id) && !picked.includes(id)) { + picked.push(id); + } + } + return order.filter((id) => picked.includes(id)); } function loadAll(): PrefsMap { diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/constants/overview-table-columns.ts b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/constants/overview-table-columns.ts index cb63ae00..da47500c 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/constants/overview-table-columns.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/constants/overview-table-columns.ts @@ -10,10 +10,13 @@ export type OverviewColumnId = | 'targetAmount' | 'salesAmountAchievementRate' | 'dealAmount' + | 'refundAmount' | 'salesAmount' | 'dealOrderCount' + | 'refundOrderCount' | 'salesOrderCount' | 'dealQuantitySum' + | 'refundQuantitySum' | 'salesQuantitySum' | 'dealAverageOrderValue' | 'salesAverageOrderValue' @@ -21,7 +24,6 @@ export type OverviewColumnId = | 'shippingCost' | 'otherCost' | 'orderCost' - | 'refundAmount' | 'salesTaxAmount' | 'totalPromotionFee' | 'brushFee' @@ -51,17 +53,23 @@ export const OVERVIEW_COL_GROUPS: OverviewColGroupDef[] = [ { id: 'profit', label: '盈利分析维度', tone: 'profit' }, ]; -/** 全量指标列(店铺/平台含目标;品类/商品不含) */ +/** + * 全量指标列。 + * 规模:成交 → 退款 → 净销售(金额/单量/件数)再客单价;成本不含退款金额。 + */ export const OVERVIEW_COLUMNS: OverviewColumnDef[] = [ { id: 'targetOrderCount', label: '目标单量', group: 'target' }, { id: 'orderCountAchievementRate', label: '单量达成率', group: 'target' }, { id: 'targetAmount', label: '目标额', group: 'target' }, { id: 'salesAmountAchievementRate', label: '销售达成率', group: 'target' }, { id: 'dealAmount', label: '成交金额', group: 'scale' }, + { id: 'refundAmount', label: '退款金额', group: 'scale' }, { id: 'salesAmount', label: '净销售额', group: 'scale' }, { id: 'dealOrderCount', label: '成交单量', group: 'scale' }, + { id: 'refundOrderCount', label: '退款单量', group: 'scale' }, { id: 'salesOrderCount', label: '净销售单量', group: 'scale' }, { id: 'dealQuantitySum', label: '成交量', group: 'scale' }, + { id: 'refundQuantitySum', label: '退款件数', group: 'scale' }, { id: 'salesQuantitySum', label: '净销量', group: 'scale' }, { id: 'dealAverageOrderValue', label: '成交客单价', group: 'scale' }, { id: 'salesAverageOrderValue', label: '净销售客单价', group: 'scale' }, @@ -69,7 +77,6 @@ export const OVERVIEW_COLUMNS: OverviewColumnDef[] = [ { id: 'shippingCost', label: '运费', group: 'cost' }, { id: 'otherCost', label: '其他成本', group: 'cost' }, { id: 'orderCost', label: '订单成本', group: 'cost' }, - { id: 'refundAmount', label: '退款金额', group: 'cost' }, { id: 'salesTaxAmount', label: '税额', group: 'cost' }, { id: 'totalPromotionFee', label: '推广费', group: 'cost' }, { id: 'brushFee', label: '刷单费', group: 'cost' }, @@ -80,6 +87,12 @@ export const OVERVIEW_COLUMNS: OverviewColumnDef[] = [ { id: 'profitAfterTax', label: '税后净利', group: 'profit' }, ]; +/** 历史偏好升级时自动勾选的新列 */ +export const OVERVIEW_COLUMN_AUTO_APPEND: OverviewColumnId[] = [ + 'refundOrderCount', + 'refundQuantitySum', +]; + const TARGET_IDS = new Set( OVERVIEW_COLUMNS.filter((c) => c.group === 'target').map((c) => c.id), ); diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/utils/overview-bridge.ts b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/utils/overview-bridge.ts index 52d913cc..0f228ced 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/utils/overview-bridge.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/utils/overview-bridge.ts @@ -52,15 +52,19 @@ function aggregateShopTotal( salesAmountAchievementRate: sum('salesAmountAchievementRate'), salesAmount, dealAmount, + refundAmount: sum('refundAmount'), + refundOrderCount: sum('refundOrderCount'), + refundQuantitySum: sum('refundQuantitySum'), salesOrderCount, dealOrderCount, + dealQuantitySum: sum('dealQuantitySum'), + salesQuantitySum: sum('salesQuantitySum'), salesAverageOrderValue, dealAverageOrderValue, productCost: sum('productCost'), shippingCost: sum('shippingCost'), otherCost: sum('otherCost'), orderCost: sum('orderCost'), - refundAmount: sum('refundAmount'), totalPromotionFee, brushFee: sum('brushFee'), feeRatio, @@ -123,15 +127,19 @@ function aggregateCategoryTotal( categoryName: '合计', salesAmount, dealAmount, + refundAmount: sum('refundAmount'), + refundOrderCount: sum('refundOrderCount'), + refundQuantitySum: sum('refundQuantitySum'), salesOrderCount, dealOrderCount, + dealQuantitySum: sum('dealQuantitySum'), + salesQuantitySum: sum('salesQuantitySum'), salesAverageOrderValue, dealAverageOrderValue, productCost: sum('productCost'), shippingCost: sum('shippingCost'), otherCost: sum('otherCost'), orderCost: sum('orderCost'), - refundAmount: sum('refundAmount'), totalPromotionFee, brushFee: sum('brushFee'), feeRatio, @@ -197,15 +205,19 @@ function aggregatePlatformTotal( salesAmountAchievementRate: sum('salesAmountAchievementRate'), salesAmount, dealAmount, + refundAmount: sum('refundAmount'), + refundOrderCount: sum('refundOrderCount'), + refundQuantitySum: sum('refundQuantitySum'), salesOrderCount, dealOrderCount, + dealQuantitySum: sum('dealQuantitySum'), + salesQuantitySum: sum('salesQuantitySum'), salesAverageOrderValue, dealAverageOrderValue, productCost: sum('productCost'), shippingCost: sum('shippingCost'), otherCost: sum('otherCost'), orderCost: sum('orderCost'), - refundAmount: sum('refundAmount'), totalPromotionFee, brushFee: sum('brushFee'), feeRatio,