mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 13:49:20 +08:00
refactor(ecom-dmb): 店铺/品类/平台概览统一改为对象结构(含后端计算的合计行)
This commit is contained in:
+30
-4
@@ -68,16 +68,16 @@ public class CompanyOverviewVO {
|
|||||||
private List<ShopEfficiencyQuadrant> shopEfficiencyQuadrants;
|
private List<ShopEfficiencyQuadrant> shopEfficiencyQuadrants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多店铺数据横向对比(16维度)
|
* 多店铺数据横向对比(包含合计行和店铺列表)
|
||||||
*/
|
*/
|
||||||
@Schema(description = "多店铺数据横向对比")
|
@Schema(description = "多店铺数据横向对比")
|
||||||
private List<ShopComparison> shopComparisons;
|
private ShopOverview shopComparisons;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多品类数据横向对比
|
* 多品类数据横向对比(包含合计行和品类列表)
|
||||||
*/
|
*/
|
||||||
@Schema(description = "多品类数据横向对比")
|
@Schema(description = "多品类数据横向对比")
|
||||||
private List<CategoryComparison> categoryComparisons;
|
private CategoryOverview categoryComparisons;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 平台维度概览(包含合计行和平台列表)
|
* 平台维度概览(包含合计行和平台列表)
|
||||||
@@ -92,6 +92,32 @@ public class CompanyOverviewVO {
|
|||||||
private List<PlatformSummary> platforms;
|
private List<PlatformSummary> platforms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多店铺概览(包含合计行和店铺列表)
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "多店铺概览")
|
||||||
|
public static class ShopOverview {
|
||||||
|
@Schema(description = "合计行")
|
||||||
|
private ShopComparison total;
|
||||||
|
|
||||||
|
@Schema(description = "各店铺对比列表")
|
||||||
|
private List<ShopComparison> shops;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多品类概览(包含合计行和品类列表)
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "多品类概览")
|
||||||
|
public static class CategoryOverview {
|
||||||
|
@Schema(description = "合计行")
|
||||||
|
private CategoryComparison total;
|
||||||
|
|
||||||
|
@Schema(description = "各品类对比列表")
|
||||||
|
private List<CategoryComparison> categories;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 平台维度汇总
|
* 平台维度汇总
|
||||||
*/
|
*/
|
||||||
|
|||||||
+156
-8
@@ -215,14 +215,14 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
overviewVO.setShopEfficiencyQuadrants(shopEfficiencyQuadrants);
|
overviewVO.setShopEfficiencyQuadrants(shopEfficiencyQuadrants);
|
||||||
|
|
||||||
// 9. 多店铺数据横向对比
|
// 9. 多店铺数据横向对比
|
||||||
List<CompanyOverviewVO.ShopComparison> shopComparisons = calculateShopComparisons(
|
CompanyOverviewVO.ShopOverview shopOverview = calculateShopComparisons(
|
||||||
shops, orders, promotionFees, brushOrders, refundStatusId, companyId, startDate, endDate);
|
shops, orders, promotionFees, brushOrders, refundStatusId, companyId, startDate, endDate);
|
||||||
overviewVO.setShopComparisons(shopComparisons);
|
overviewVO.setShopComparisons(shopOverview);
|
||||||
|
|
||||||
// 10. 多品类数据横向对比
|
// 10. 多品类数据横向对比
|
||||||
List<CompanyOverviewVO.CategoryComparison> categoryComparisons = calculateCategoryComparisons(
|
CompanyOverviewVO.CategoryOverview categoryOverview = calculateCategoryComparisons(
|
||||||
orders, promotionFees, brushOrders, refundStatusId, companyId, startDate, endDate);
|
orders, promotionFees, brushOrders, refundStatusId, companyId, startDate, endDate);
|
||||||
overviewVO.setCategoryComparisons(categoryComparisons);
|
overviewVO.setCategoryComparisons(categoryOverview);
|
||||||
|
|
||||||
// 11. 平台维度汇总
|
// 11. 平台维度汇总
|
||||||
CompanyOverviewVO.PlatformOverview platformOverview = calculatePlatformSummary(
|
CompanyOverviewVO.PlatformOverview platformOverview = calculatePlatformSummary(
|
||||||
@@ -457,7 +457,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
/**
|
/**
|
||||||
* 计算多店铺数据横向对比
|
* 计算多店铺数据横向对比
|
||||||
*/
|
*/
|
||||||
private List<CompanyOverviewVO.ShopComparison> calculateShopComparisons(
|
private CompanyOverviewVO.ShopOverview calculateShopComparisons(
|
||||||
List<ShopPO> shops, List<OrderPO> orders, List<PromotionFeePO> promotionFees,
|
List<ShopPO> shops, List<OrderPO> orders, List<PromotionFeePO> promotionFees,
|
||||||
List<BrushOrderPO> brushOrders, Long refundStatusId, Long companyId, LocalDate startDate, LocalDate endDate) {
|
List<BrushOrderPO> brushOrders, Long refundStatusId, Long companyId, LocalDate startDate, LocalDate endDate) {
|
||||||
List<CompanyOverviewVO.ShopComparison> comparisons = new ArrayList<>();
|
List<CompanyOverviewVO.ShopComparison> comparisons = new ArrayList<>();
|
||||||
@@ -616,7 +616,88 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
|
|
||||||
// 按销售额降序排序
|
// 按销售额降序排序
|
||||||
comparisons.sort(Comparator.comparing(CompanyOverviewVO.ShopComparison::getSalesAmount).reversed());
|
comparisons.sort(Comparator.comparing(CompanyOverviewVO.ShopComparison::getSalesAmount).reversed());
|
||||||
return comparisons;
|
|
||||||
|
// 计算合计行
|
||||||
|
CompanyOverviewVO.ShopComparison total = computeShopTotal(comparisons);
|
||||||
|
|
||||||
|
// 封装为 ShopOverview
|
||||||
|
CompanyOverviewVO.ShopOverview overview = new CompanyOverviewVO.ShopOverview();
|
||||||
|
overview.setTotal(total);
|
||||||
|
overview.setShops(comparisons);
|
||||||
|
return overview;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算店铺对比的合计行
|
||||||
|
*/
|
||||||
|
private CompanyOverviewVO.ShopComparison computeShopTotal(List<CompanyOverviewVO.ShopComparison> shops) {
|
||||||
|
BigDecimal totalSales = BigDecimal.ZERO;
|
||||||
|
int totalOrders = 0;
|
||||||
|
BigDecimal totalTargetAmount = BigDecimal.ZERO;
|
||||||
|
int totalTargetOrders = 0;
|
||||||
|
BigDecimal totalProductCost = BigDecimal.ZERO;
|
||||||
|
BigDecimal totalShippingCost = BigDecimal.ZERO;
|
||||||
|
BigDecimal totalOtherCost = BigDecimal.ZERO;
|
||||||
|
BigDecimal totalRefund = BigDecimal.ZERO;
|
||||||
|
BigDecimal totalPromoFee = BigDecimal.ZERO;
|
||||||
|
BigDecimal totalBrushFee = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
for (CompanyOverviewVO.ShopComparison s : shops) {
|
||||||
|
totalSales = totalSales.add(s.getSalesAmount() != null ? s.getSalesAmount() : BigDecimal.ZERO);
|
||||||
|
totalOrders += s.getOrderCount() != null ? s.getOrderCount() : 0;
|
||||||
|
totalTargetAmount = totalTargetAmount.add(s.getTargetAmount() != null ? s.getTargetAmount() : BigDecimal.ZERO);
|
||||||
|
totalTargetOrders += s.getTargetOrderCount() != null ? s.getTargetOrderCount() : 0;
|
||||||
|
totalProductCost = totalProductCost.add(s.getProductCost() != null ? s.getProductCost() : BigDecimal.ZERO);
|
||||||
|
totalShippingCost = totalShippingCost.add(s.getShippingCost() != null ? s.getShippingCost() : BigDecimal.ZERO);
|
||||||
|
totalOtherCost = totalOtherCost.add(s.getOtherCost() != null ? s.getOtherCost() : BigDecimal.ZERO);
|
||||||
|
totalRefund = totalRefund.add(s.getRefundAmount() != null ? s.getRefundAmount() : BigDecimal.ZERO);
|
||||||
|
totalPromoFee = totalPromoFee.add(s.getTotalPromotionFee() != null ? s.getTotalPromotionFee() : BigDecimal.ZERO);
|
||||||
|
totalBrushFee = totalBrushFee.add(s.getBrushFee() != null ? s.getBrushFee() : BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal avgOrderValue = totalOrders > 0
|
||||||
|
? totalSales.divide(new BigDecimal(totalOrders), 2, RoundingMode.HALF_UP)
|
||||||
|
: BigDecimal.ZERO;
|
||||||
|
BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost);
|
||||||
|
BigDecimal profitBeforeTax = totalSales.subtract(totalCost).subtract(totalRefund);
|
||||||
|
BigDecimal salesTax = totalSales.multiply(new BigDecimal("0.04"));
|
||||||
|
BigDecimal profitAfterTax = profitBeforeTax.subtract(salesTax);
|
||||||
|
BigDecimal roi = totalPromoFee.compareTo(BigDecimal.ZERO) > 0
|
||||||
|
? totalSales.subtract(totalRefund).divide(totalPromoFee, 4, RoundingMode.HALF_UP)
|
||||||
|
: BigDecimal.ZERO;
|
||||||
|
BigDecimal feeRatio = totalSales.compareTo(BigDecimal.ZERO) > 0
|
||||||
|
? totalPromoFee.add(totalBrushFee).divide(totalSales, 4, RoundingMode.HALF_UP)
|
||||||
|
: BigDecimal.ZERO;
|
||||||
|
BigDecimal salesAchievementRate = totalTargetAmount.compareTo(BigDecimal.ZERO) > 0
|
||||||
|
? totalSales.divide(totalTargetAmount, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))
|
||||||
|
: totalSales.compareTo(BigDecimal.ZERO) > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
|
||||||
|
BigDecimal orderAchievementRate = totalTargetOrders > 0
|
||||||
|
? new BigDecimal(totalOrders).divide(new BigDecimal(totalTargetOrders), 4, RoundingMode.HALF_UP)
|
||||||
|
.multiply(new BigDecimal("100"))
|
||||||
|
: totalOrders > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
|
||||||
|
|
||||||
|
CompanyOverviewVO.ShopComparison total = new CompanyOverviewVO.ShopComparison();
|
||||||
|
total.setShopId(0L);
|
||||||
|
total.setShopName("合计");
|
||||||
|
total.setSalesAmount(totalSales);
|
||||||
|
total.setOrderCount(totalOrders);
|
||||||
|
total.setAverageOrderValue(avgOrderValue);
|
||||||
|
total.setTargetAmount(totalTargetAmount);
|
||||||
|
total.setTargetOrderCount(totalTargetOrders);
|
||||||
|
total.setSalesAmountAchievementRate(salesAchievementRate);
|
||||||
|
total.setOrderCountAchievementRate(orderAchievementRate);
|
||||||
|
total.setProductCost(totalProductCost);
|
||||||
|
total.setShippingCost(totalShippingCost);
|
||||||
|
total.setOtherCost(totalOtherCost);
|
||||||
|
total.setRefundAmount(totalRefund);
|
||||||
|
total.setTotalPromotionFee(totalPromoFee);
|
||||||
|
total.setBrushFee(totalBrushFee);
|
||||||
|
total.setFeeRatio(feeRatio);
|
||||||
|
total.setTotalProfitBeforeTax(profitBeforeTax);
|
||||||
|
total.setSalesTaxAmount(salesTax);
|
||||||
|
total.setRoi(roi);
|
||||||
|
total.setProfitAfterTax(profitAfterTax);
|
||||||
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -730,7 +811,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
/**
|
/**
|
||||||
* Calculate category comparison data
|
* Calculate category comparison data
|
||||||
*/
|
*/
|
||||||
private List<CompanyOverviewVO.CategoryComparison> calculateCategoryComparisons(
|
private CompanyOverviewVO.CategoryOverview calculateCategoryComparisons(
|
||||||
List<OrderPO> orders, List<PromotionFeePO> promotionFees,
|
List<OrderPO> orders, List<PromotionFeePO> promotionFees,
|
||||||
List<BrushOrderPO> brushOrders, Long refundStatusId, Long companyId,
|
List<BrushOrderPO> brushOrders, Long refundStatusId, Long companyId,
|
||||||
LocalDate startDate, LocalDate endDate) {
|
LocalDate startDate, LocalDate endDate) {
|
||||||
@@ -890,8 +971,75 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
comparisons.sort(Comparator.comparing(CompanyOverviewVO.CategoryComparison::getSalesAmount).reversed());
|
comparisons.sort(Comparator.comparing(CompanyOverviewVO.CategoryComparison::getSalesAmount).reversed());
|
||||||
return comparisons;
|
|
||||||
|
// 计算合计行
|
||||||
|
CompanyOverviewVO.CategoryComparison total = computeCategoryTotal(comparisons);
|
||||||
|
|
||||||
|
// 封装为 CategoryOverview
|
||||||
|
CompanyOverviewVO.CategoryOverview overview = new CompanyOverviewVO.CategoryOverview();
|
||||||
|
overview.setTotal(total);
|
||||||
|
overview.setCategories(comparisons);
|
||||||
|
return overview;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算品类对比的合计行
|
||||||
|
*/
|
||||||
|
private CompanyOverviewVO.CategoryComparison computeCategoryTotal(List<CompanyOverviewVO.CategoryComparison> categories) {
|
||||||
|
BigDecimal totalSales = BigDecimal.ZERO;
|
||||||
|
int totalOrders = 0;
|
||||||
|
BigDecimal totalProductCost = BigDecimal.ZERO;
|
||||||
|
BigDecimal totalShippingCost = BigDecimal.ZERO;
|
||||||
|
BigDecimal totalOtherCost = BigDecimal.ZERO;
|
||||||
|
BigDecimal totalRefund = BigDecimal.ZERO;
|
||||||
|
BigDecimal totalPromoFee = BigDecimal.ZERO;
|
||||||
|
BigDecimal totalBrushFee = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
for (CompanyOverviewVO.CategoryComparison c : categories) {
|
||||||
|
totalSales = totalSales.add(c.getSalesAmount() != null ? c.getSalesAmount() : BigDecimal.ZERO);
|
||||||
|
totalOrders += c.getOrderCount() != null ? c.getOrderCount() : 0;
|
||||||
|
totalProductCost = totalProductCost.add(c.getProductCost() != null ? c.getProductCost() : BigDecimal.ZERO);
|
||||||
|
totalShippingCost = totalShippingCost.add(c.getShippingCost() != null ? c.getShippingCost() : BigDecimal.ZERO);
|
||||||
|
totalOtherCost = totalOtherCost.add(c.getOtherCost() != null ? c.getOtherCost() : BigDecimal.ZERO);
|
||||||
|
totalRefund = totalRefund.add(c.getRefundAmount() != null ? c.getRefundAmount() : BigDecimal.ZERO);
|
||||||
|
totalPromoFee = totalPromoFee.add(c.getTotalPromotionFee() != null ? c.getTotalPromotionFee() : BigDecimal.ZERO);
|
||||||
|
totalBrushFee = totalBrushFee.add(c.getBrushFee() != null ? c.getBrushFee() : BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal avgOrderValue = totalOrders > 0
|
||||||
|
? totalSales.divide(new BigDecimal(totalOrders), 2, RoundingMode.HALF_UP)
|
||||||
|
: BigDecimal.ZERO;
|
||||||
|
BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost);
|
||||||
|
BigDecimal profitBeforeTax = totalSales.subtract(totalCost).subtract(totalRefund);
|
||||||
|
BigDecimal salesTax = totalSales.multiply(new BigDecimal("0.04"));
|
||||||
|
BigDecimal profitAfterTax = profitBeforeTax.subtract(salesTax);
|
||||||
|
BigDecimal roi = totalPromoFee.compareTo(BigDecimal.ZERO) > 0
|
||||||
|
? totalSales.subtract(totalRefund).divide(totalPromoFee, 4, RoundingMode.HALF_UP)
|
||||||
|
: BigDecimal.ZERO;
|
||||||
|
BigDecimal feeRatio = totalSales.compareTo(BigDecimal.ZERO) > 0
|
||||||
|
? totalPromoFee.add(totalBrushFee).divide(totalSales, 4, RoundingMode.HALF_UP)
|
||||||
|
: BigDecimal.ZERO;
|
||||||
|
|
||||||
|
CompanyOverviewVO.CategoryComparison total = new CompanyOverviewVO.CategoryComparison();
|
||||||
|
total.setCategoryId(0L);
|
||||||
|
total.setCategoryName("合计");
|
||||||
|
total.setSalesAmount(totalSales);
|
||||||
|
total.setOrderCount(totalOrders);
|
||||||
|
total.setAverageOrderValue(avgOrderValue);
|
||||||
|
total.setProductCost(totalProductCost);
|
||||||
|
total.setShippingCost(totalShippingCost);
|
||||||
|
total.setOtherCost(totalOtherCost);
|
||||||
|
total.setRefundAmount(totalRefund);
|
||||||
|
total.setTotalPromotionFee(totalPromoFee);
|
||||||
|
total.setBrushFee(totalBrushFee);
|
||||||
|
total.setFeeRatio(feeRatio);
|
||||||
|
total.setTotalProfitBeforeTax(profitBeforeTax);
|
||||||
|
total.setSalesTaxAmount(salesTax);
|
||||||
|
total.setRoi(roi);
|
||||||
|
total.setProfitAfterTax(profitAfterTax);
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
private List<Long> getAutoStatisticsStatusIds(Long companyId) {
|
private List<Long> getAutoStatisticsStatusIds(Long companyId) {
|
||||||
LambdaQueryWrapper<OrderStatusPO> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<OrderStatusPO> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(OrderStatusPO::getCompanyId, companyId)
|
wrapper.eq(OrderStatusPO::getCompanyId, companyId)
|
||||||
|
|||||||
+19
-3
@@ -23,10 +23,10 @@ export namespace CompanyOverviewVO {
|
|||||||
shopSalesRatios?: ShopSalesRatio[];
|
shopSalesRatios?: ShopSalesRatio[];
|
||||||
/** 店铺效率象限(ROI vs 净利) */
|
/** 店铺效率象限(ROI vs 净利) */
|
||||||
shopEfficiencyQuadrants?: ShopEfficiencyQuadrant[];
|
shopEfficiencyQuadrants?: ShopEfficiencyQuadrant[];
|
||||||
/** 多店铺数据横向对比(16维度) */
|
/** 多店铺数据横向对比 */
|
||||||
shopComparisons?: ShopComparison[];
|
shopComparisons?: ShopOverview;
|
||||||
/** 多品类数据横向对比 */
|
/** 多品类数据横向对比 */
|
||||||
categoryComparisons?: CategoryComparison[];
|
categoryComparisons?: CategoryOverview;
|
||||||
/** 平台维度概览(包含合计行和平台列表) */
|
/** 平台维度概览(包含合计行和平台列表) */
|
||||||
platformSummary?: PlatformOverview;
|
platformSummary?: PlatformOverview;
|
||||||
/** 汇总ROI */
|
/** 汇总ROI */
|
||||||
@@ -202,4 +202,20 @@ export namespace CompanyOverviewVO {
|
|||||||
/** 各平台汇总列表 */
|
/** 各平台汇总列表 */
|
||||||
platforms: PlatformSummary[];
|
platforms: PlatformSummary[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 多店铺概览 */
|
||||||
|
export interface ShopOverview {
|
||||||
|
/** 合计行 */
|
||||||
|
total: ShopComparison;
|
||||||
|
/** 各店铺对比列表 */
|
||||||
|
shops: ShopComparison[];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 多品类概览 */
|
||||||
|
export interface CategoryOverview {
|
||||||
|
/** 合计行 */
|
||||||
|
total: CategoryComparison;
|
||||||
|
/** 各品类对比列表 */
|
||||||
|
categories: CategoryComparison[];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+28
-5
@@ -6,7 +6,7 @@ import { computed } from 'vue';
|
|||||||
defineOptions({ name: 'CategoryComparisonTable' });
|
defineOptions({ name: 'CategoryComparisonTable' });
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
categoryComparisons?: CompanyOverviewVO.CategoryComparison[];
|
categoryComparisons?: CompanyOverviewVO.CategoryOverview;
|
||||||
taxRate: number;
|
taxRate: number;
|
||||||
categoryExportMode?: boolean;
|
categoryExportMode?: boolean;
|
||||||
selectedExportCategoryIds?: number[];
|
selectedExportCategoryIds?: number[];
|
||||||
@@ -26,7 +26,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|||||||
const emit = defineEmits<Emits>();
|
const emit = defineEmits<Emits>();
|
||||||
|
|
||||||
const allCategoriesSelected = computed(() => {
|
const allCategoriesSelected = computed(() => {
|
||||||
const total = props.categoryComparisons?.length || 0;
|
const total = props.categoryComparisons?.categories?.length || 0;
|
||||||
return total > 0 && props.selectedExportCategoryIds.length === total;
|
return total > 0 && props.selectedExportCategoryIds.length === total;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ const formatPercentPlain = (value: number | undefined) => {
|
|||||||
'update:selectedExportCategoryIds',
|
'update:selectedExportCategoryIds',
|
||||||
allCategoriesSelected
|
allCategoriesSelected
|
||||||
? []
|
? []
|
||||||
: (categoryComparisons ?? []).map((c) => c.categoryId!)
|
: (categoryComparisons?.categories ?? []).map((c) => c.categoryId!)
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
@@ -174,7 +174,7 @@ const formatPercentPlain = (value: number | undefined) => {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody class="divide-y divide-slate-100 dark:divide-[hsl(240deg_3.7%_22%)]">
|
<tbody class="divide-y divide-slate-100 dark:divide-[hsl(240deg_3.7%_22%)]">
|
||||||
<tr
|
<tr
|
||||||
v-for="cat in categoryComparisons"
|
v-for="cat in (categoryComparisons?.categories || [])"
|
||||||
:key="cat.categoryId ?? 'uncategorized'"
|
:key="cat.categoryId ?? 'uncategorized'"
|
||||||
class="transition-colors hover:bg-blue-50/50 dark:hover:bg-[hsl(217.2deg_32.6%_17.5%/30%)] dark:bg-[hsl(217.2deg_32.6%_17.5%/50%)]"
|
class="transition-colors hover:bg-blue-50/50 dark:hover:bg-[hsl(217.2deg_32.6%_17.5%/30%)] dark:bg-[hsl(217.2deg_32.6%_17.5%/50%)]"
|
||||||
>
|
>
|
||||||
@@ -237,12 +237,35 @@ const formatPercentPlain = (value: number | undefined) => {
|
|||||||
{{ cat.profitAfterTax ? formatAmount(cat.profitAfterTax) : '-' }}
|
{{ cat.profitAfterTax ? formatAmount(cat.profitAfterTax) : '-' }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="!categoryComparisons?.length">
|
<tr v-if="!categoryComparisons?.categories?.length">
|
||||||
<td :colspan="categoryExportMode ? 16 : 15" class="p-8 text-center text-gray-400">
|
<td :colspan="categoryExportMode ? 16 : 15" class="p-8 text-center text-gray-400">
|
||||||
暂无数据
|
暂无数据
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
<!-- 合计行 -->
|
||||||
|
<tfoot v-if="categoryComparisons?.total" class="bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)]">
|
||||||
|
<tr class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||||
|
<td class="p-6 text-base">合计</td>
|
||||||
|
<!-- 规模 -->
|
||||||
|
<td class="p-6">{{ categoryComparisons?.total?.salesAmount ? formatAmount(categoryComparisons?.total?.salesAmount) : '-' }}</td>
|
||||||
|
<td class="p-6">{{ categoryComparisons?.total?.orderCount ? categoryComparisons?.total?.orderCount.toLocaleString() : '-' }}</td>
|
||||||
|
<td class="p-6">-</td>
|
||||||
|
<!-- 成本 -->
|
||||||
|
<td class="p-6">{{ categoryComparisons?.total?.productCost ? formatAmount(categoryComparisons?.total?.productCost) : '-' }}</td>
|
||||||
|
<td class="p-6">{{ categoryComparisons?.total?.shippingCost ? formatAmount(categoryComparisons?.total?.shippingCost) : '-' }}</td>
|
||||||
|
<td class="p-6">{{ categoryComparisons?.total?.otherCost ? formatAmount(categoryComparisons?.total?.otherCost) : '-' }}</td>
|
||||||
|
<td class="p-6 text-rose-600 dark:text-rose-400">{{ categoryComparisons?.total?.refundAmount ? formatAmount(categoryComparisons?.total?.refundAmount) : '-' }}</td>
|
||||||
|
<td class="p-6">{{ categoryComparisons?.total?.totalPromotionFee ? formatAmount(categoryComparisons?.total?.totalPromotionFee) : '-' }}</td>
|
||||||
|
<td class="p-6 text-orange-600 dark:text-orange-400">{{ categoryComparisons?.total?.brushFee ? formatAmount(categoryComparisons?.total?.brushFee) : '-' }}</td>
|
||||||
|
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ categoryComparisons?.total?.feeRatio !== undefined ? formatPercentPlain(categoryComparisons?.total?.feeRatio) : '-' }}</td>
|
||||||
|
<!-- 盈利 -->
|
||||||
|
<td class="p-6">{{ categoryComparisons?.total?.totalProfitBeforeTax ? formatAmount(categoryComparisons?.total?.totalProfitBeforeTax) : '-' }}</td>
|
||||||
|
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ categoryComparisons?.total?.salesTaxAmount ? formatAmount(categoryComparisons?.total?.salesTaxAmount) : '-' }}</td>
|
||||||
|
<td class="p-6 text-indigo-700 dark:text-indigo-400">{{ categoryComparisons?.total?.roi?.toFixed(2) || '-' }}</td>
|
||||||
|
<td class="bg-emerald-100 dark:bg-emerald-900/30 p-6 text-base text-emerald-600">{{ categoryComparisons?.total?.profitAfterTax ? formatAmount(categoryComparisons?.total?.profitAfterTax) : '-' }}</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+14
-14
@@ -293,36 +293,36 @@ const sortIcon = (field: string) => {
|
|||||||
<!-- 目标 -->
|
<!-- 目标 -->
|
||||||
<td class="p-6">{{ totalData.targetOrderCount?.toLocaleString() }}</td>
|
<td class="p-6">{{ totalData.targetOrderCount?.toLocaleString() }}</td>
|
||||||
<td class="p-6 text-blue-600 dark:text-blue-400">-</td>
|
<td class="p-6 text-blue-600 dark:text-blue-400">-</td>
|
||||||
<td class="p-6">{{ formatAmount(totalData.targetAmount) }}</td>
|
<td class="p-6">{{ totalData.targetAmount ? formatAmount(totalData.targetAmount) : '-' }}</td>
|
||||||
<td class="p-6 text-blue-600 dark:text-blue-400">-</td>
|
<td class="p-6 text-blue-600 dark:text-blue-400">-</td>
|
||||||
<!-- 规模 -->
|
<!-- 规模 -->
|
||||||
<td class="p-6">{{ formatAmount(totalData.salesAmount) }}</td>
|
<td class="p-6">{{ totalData.salesAmount ? formatAmount(totalData.salesAmount) : '-' }}</td>
|
||||||
<td class="p-6">{{ totalData.orderCount?.toLocaleString() }}</td>
|
<td class="p-6">{{ totalData.orderCount ? totalData.orderCount.toLocaleString() : '-' }}</td>
|
||||||
<td class="p-6">-</td>
|
<td class="p-6">-</td>
|
||||||
<!-- 成本 -->
|
<!-- 成本 -->
|
||||||
<td class="p-6">{{ formatAmount(totalData.productCost) }}</td>
|
<td class="p-6">{{ totalData.productCost ? formatAmount(totalData.productCost) : '-' }}</td>
|
||||||
<td class="p-6">{{ formatAmount(totalData.shippingCost) }}</td>
|
<td class="p-6">{{ totalData.shippingCost ? formatAmount(totalData.shippingCost) : '-' }}</td>
|
||||||
<td class="p-6">{{ formatAmount(totalData.otherCost) }}</td>
|
<td class="p-6">{{ totalData.otherCost ? formatAmount(totalData.otherCost) : '-' }}</td>
|
||||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ formatAmount(totalData.refundAmount) }}</td>
|
<td class="p-6 text-rose-600 dark:text-rose-400">{{ totalData.refundAmount ? formatAmount(totalData.refundAmount) : '-' }}</td>
|
||||||
<td class="p-6">{{ formatAmount(totalData.totalPromotionFee) }}</td>
|
<td class="p-6">{{ totalData.totalPromotionFee ? formatAmount(totalData.totalPromotionFee) : '-' }}</td>
|
||||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ formatAmount(totalData.brushFee) }}</td>
|
<td class="p-6 text-orange-600 dark:text-orange-400">{{ totalData.brushFee ? formatAmount(totalData.brushFee) : '-' }}</td>
|
||||||
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||||
{{ formatPercentPlain(totalData.feeRatio) }}
|
{{ totalData.feeRatio !== undefined ? formatPercentPlain(totalData.feeRatio) : '-' }}
|
||||||
</td>
|
</td>
|
||||||
<!-- 盈利 -->
|
<!-- 盈利 -->
|
||||||
<td class="p-6">
|
<td class="p-6">
|
||||||
{{ formatAmount(totalData.totalProfitBeforeTax) }}
|
{{ totalData.totalProfitBeforeTax ? formatAmount(totalData.totalProfitBeforeTax) : '-' }}
|
||||||
</td>
|
</td>
|
||||||
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||||
{{ formatAmount(totalData.salesTaxAmount) }}
|
{{ totalData.salesTaxAmount ? formatAmount(totalData.salesTaxAmount) : '-' }}
|
||||||
</td>
|
</td>
|
||||||
<td class="p-6 text-indigo-700 dark:text-indigo-400">
|
<td class="p-6 text-indigo-700 dark:text-indigo-400">
|
||||||
{{ totalData.roi?.toFixed(2) }}
|
{{ totalData.roi !== undefined ? totalData.roi.toFixed(2) : '-' }}
|
||||||
</td>
|
</td>
|
||||||
<td class="bg-emerald-100 dark:bg-emerald-900/30 p-6 text-base"
|
<td class="bg-emerald-100 dark:bg-emerald-900/30 p-6 text-base"
|
||||||
:class="totalData.profitAfterTax >= 0 ? 'text-emerald-600' : 'text-rose-600'"
|
:class="totalData.profitAfterTax >= 0 ? 'text-emerald-600' : 'text-rose-600'"
|
||||||
>
|
>
|
||||||
{{ formatAmount(totalData.profitAfterTax) }}
|
{{ totalData.profitAfterTax ? formatAmount(totalData.profitAfterTax) : '-' }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
|
|||||||
+31
-3
@@ -109,7 +109,7 @@ const formatPercentPlain = (value: number | undefined) => {
|
|||||||
if ((e.target as HTMLInputElement).checked) {
|
if ((e.target as HTMLInputElement).checked) {
|
||||||
emit(
|
emit(
|
||||||
'update:selectedExportShopIds',
|
'update:selectedExportShopIds',
|
||||||
shopComparisons?.map((s) => s.shopId) || [],
|
shopComparisons?.shops?.map((s) => s.shopId) || [],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
emit('update:selectedExportShopIds', []);
|
emit('update:selectedExportShopIds', []);
|
||||||
@@ -193,7 +193,7 @@ const formatPercentPlain = (value: number | undefined) => {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody class="divide-y divide-slate-100 dark:divide-[hsl(240deg_3.7%_22%)]">
|
<tbody class="divide-y divide-slate-100 dark:divide-[hsl(240deg_3.7%_22%)]">
|
||||||
<tr
|
<tr
|
||||||
v-for="shop in shopComparisons"
|
v-for="shop in (shopComparisons?.shops || [])"
|
||||||
:key="shop.shopId"
|
:key="shop.shopId"
|
||||||
class="transition-colors hover:bg-blue-50/50 dark:hover:bg-[hsl(217.2deg_32.6%_17.5%/30%)] dark:bg-[hsl(217.2deg_32.6%_17.5%/50%)]"
|
class="transition-colors hover:bg-blue-50/50 dark:hover:bg-[hsl(217.2deg_32.6%_17.5%/30%)] dark:bg-[hsl(217.2deg_32.6%_17.5%/50%)]"
|
||||||
>
|
>
|
||||||
@@ -328,12 +328,40 @@ const formatPercentPlain = (value: number | undefined) => {
|
|||||||
}}
|
}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="!shopComparisons?.length">
|
<tr v-if="!shopComparisons?.shops?.length">
|
||||||
<td colspan="17" class="p-8 text-center text-gray-400">
|
<td colspan="17" class="p-8 text-center text-gray-400">
|
||||||
暂无数据
|
暂无数据
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
<!-- 合计行 -->
|
||||||
|
<tfoot v-if="shopComparisons?.total" class="bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)]">
|
||||||
|
<tr class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||||
|
<td class="p-6 text-base" :class="shopExportMode ? 'border-l-0' : ''">合计</td>
|
||||||
|
<!-- 目标 -->
|
||||||
|
<td class="p-6">{{ shopComparisons?.total?.targetOrderCount?.toLocaleString() }}</td>
|
||||||
|
<td class="p-6 text-blue-600 dark:text-blue-400">-</td>
|
||||||
|
<td class="p-6">{{ shopComparisons?.total?.targetAmount ? formatAmount(shopComparisons?.total?.targetAmount) : '-' }}</td>
|
||||||
|
<td class="p-6 text-blue-600 dark:text-blue-400">-</td>
|
||||||
|
<!-- 规模 -->
|
||||||
|
<td class="p-6">{{ shopComparisons?.total?.salesAmount ? formatAmount(shopComparisons?.total?.salesAmount) : '-' }}</td>
|
||||||
|
<td class="p-6">{{ shopComparisons?.total?.orderCount ? shopComparisons?.total?.orderCount.toLocaleString() : '-' }}</td>
|
||||||
|
<td class="p-6">-</td>
|
||||||
|
<!-- 成本 -->
|
||||||
|
<td class="p-6">{{ shopComparisons?.total?.productCost ? formatAmount(shopComparisons?.total?.productCost) : '-' }}</td>
|
||||||
|
<td class="p-6">{{ shopComparisons?.total?.shippingCost ? formatAmount(shopComparisons?.total?.shippingCost) : '-' }}</td>
|
||||||
|
<td class="p-6">{{ shopComparisons?.total?.otherCost ? formatAmount(shopComparisons?.total?.otherCost) : '-' }}</td>
|
||||||
|
<td class="p-6 text-rose-600 dark:text-rose-400">{{ shopComparisons?.total?.refundAmount ? formatAmount(shopComparisons?.total?.refundAmount) : '-' }}</td>
|
||||||
|
<td class="p-6">{{ shopComparisons?.total?.totalPromotionFee ? formatAmount(shopComparisons?.total?.totalPromotionFee) : '-' }}</td>
|
||||||
|
<td class="p-6 text-orange-600 dark:text-orange-400">{{ shopComparisons?.total?.brushFee ? formatAmount(shopComparisons?.total?.brushFee) : '-' }}</td>
|
||||||
|
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ shopComparisons?.total?.feeRatio !== undefined ? formatPercentPlain(shopComparisons?.total?.feeRatio) : '-' }}</td>
|
||||||
|
<!-- 盈利 -->
|
||||||
|
<td class="p-6">{{ shopComparisons?.total?.totalProfitBeforeTax ? formatAmount(shopComparisons?.total?.totalProfitBeforeTax) : '-' }}</td>
|
||||||
|
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ shopComparisons?.total?.salesTaxAmount ? formatAmount(shopComparisons?.total?.salesTaxAmount) : '-' }}</td>
|
||||||
|
<td class="p-6 text-indigo-700 dark:text-indigo-400">{{ shopComparisons?.total?.roi !== undefined ? shopComparisons?.total?.roi.toFixed(2) : '-' }}</td>
|
||||||
|
<td class="bg-emerald-100 dark:bg-emerald-900/30 p-6 text-base text-emerald-600">{{ shopComparisons?.total?.profitAfterTax ? formatAmount(shopComparisons?.total?.profitAfterTax) : '-' }}</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user