implements
*/
private ProductSpecVO convertSpecToVO(ProductSpecPO productSpec) {
ProductSpecVO productSpecVO = new ProductSpecVO();
- BeanUtils.copyProperties(productSpec, productSpecVO);
+ BeanCopyUtils.copyProperties(productSpec, productSpecVO);
return productSpecVO;
}
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/workbench/service/impl/WorkbenchServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/workbench/service/impl/WorkbenchServiceImpl.java
index 8184f780..9f39d3e4 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/workbench/service/impl/WorkbenchServiceImpl.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/workbench/service/impl/WorkbenchServiceImpl.java
@@ -3,14 +3,10 @@ package top.xyquan.ecomdmbbackend.modules.ecom.workbench.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
-import top.xyquan.ecomdmbbackend.modules.ecom.brushorder.mapper.BrushOrderMapper;
-import top.xyquan.ecomdmbbackend.modules.ecom.brushorder.model.po.BrushOrderPO;
import top.xyquan.ecomdmbbackend.modules.ecom.category.model.po.CategoryPO;
import top.xyquan.ecomdmbbackend.modules.ecom.category.service.CategoryService;
-import top.xyquan.ecomdmbbackend.modules.ecom.order.mapper.OrderMapper;
import top.xyquan.ecomdmbbackend.modules.ecom.order.mapper.OrderStatAggMapper;
import top.xyquan.ecomdmbbackend.modules.ecom.order.stat.service.OrderStatReadFacade;
-import top.xyquan.ecomdmbbackend.modules.ecom.order.model.po.OrderPO;
import top.xyquan.ecomdmbbackend.modules.ecom.order.status.support.OrderStatusStatResolver;
import top.xyquan.ecomdmbbackend.modules.ecom.order.status.support.OrderStatusStatSets;
import top.xyquan.ecomdmbbackend.modules.ecom.overview.model.vo.CompanyOverviewVO;
@@ -18,11 +14,7 @@ import top.xyquan.ecomdmbbackend.modules.ecom.overview.service.CompanyOverviewSe
import top.xyquan.ecomdmbbackend.modules.ecom.platform.mapper.PlatformMapper;
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.po.PlatformPO;
import top.xyquan.ecomdmbbackend.modules.ecom.product.mapper.ProductMapper;
-import top.xyquan.ecomdmbbackend.modules.ecom.product.mapper.ProductSpecMapper;
import top.xyquan.ecomdmbbackend.modules.ecom.product.model.po.ProductPO;
-import top.xyquan.ecomdmbbackend.modules.ecom.product.model.po.ProductSpecPO;
-import top.xyquan.ecomdmbbackend.modules.ecom.promotion.mapper.PromotionFeeMapper;
-import top.xyquan.ecomdmbbackend.modules.ecom.promotion.model.po.PromotionFeePO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.po.ShopPO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.service.ShopService;
import top.xyquan.ecomdmbbackend.modules.ecom.workbench.model.dto.WorkbenchQueryDTO;
@@ -63,9 +55,9 @@ import java.util.stream.Collectors;
*
* - 「实际销售额、成本、退款、多维行、趋势」等与 {@link OrderStatusStatSets} 一致:仅统计配置为「计入销售额」的订单状态,
* 金额字段由 {@code stat} 解析商家实收、成本、退款等。
- * - 「总 GMV」为同店铺、同时间范围内全部订单状态的 {@link OrderPO#getReceivedAmount()} 合计。
+ * - 「总 GMV」为同店铺、同时间范围内全部订单状态的商家实收合计(由汇总表 KPI 提供)。
* - 推广费、刷单费为区间汇总;多维行与趋势中的「净利润」按销售额 / 净销售额占比将区间推广、刷单、税额分摊到各维度或各日,
- * 与 {@link #aggregateTotals} 得到的区间总毛利润、总税额自洽。
+ * 与 {@link #totalsFromOrderRows} 得到的区间总毛利润、总税额自洽。
*
*
* 分 Tab 输出:{@link #financeSlice}、{@link #multiAnalysis}、{@link #salesRank}。
@@ -79,12 +71,8 @@ public class WorkbenchServiceImpl implements WorkbenchService {
private static final DateTimeFormatter TREND_DATE_FMT = DateTimeFormatter.ofPattern("M/d");
private final CurrentUserContext currentUserContext;
- private final OrderMapper orderMapper;
private final ShopService shopService;
private final OrderStatusStatResolver orderStatusStatResolver;
- private final PromotionFeeMapper promotionFeeMapper;
- private final BrushOrderMapper brushOrderMapper;
- private final ProductSpecMapper productSpecMapper;
private final ProductMapper productMapper;
private final CategoryService categoryService;
private final PlatformMapper platformMapper;
@@ -92,24 +80,16 @@ public class WorkbenchServiceImpl implements WorkbenchService {
private final CompanyOverviewService companyOverviewService;
public WorkbenchServiceImpl(CurrentUserContext currentUserContext,
- OrderMapper orderMapper,
ShopService shopService,
OrderStatusStatResolver orderStatusStatResolver,
- PromotionFeeMapper promotionFeeMapper,
- BrushOrderMapper brushOrderMapper,
- ProductSpecMapper productSpecMapper,
ProductMapper productMapper,
CategoryService categoryService,
PlatformMapper platformMapper,
OrderStatReadFacade orderStatReadFacade,
CompanyOverviewService companyOverviewService) {
this.currentUserContext = currentUserContext;
- this.orderMapper = orderMapper;
this.shopService = shopService;
this.orderStatusStatResolver = orderStatusStatResolver;
- this.promotionFeeMapper = promotionFeeMapper;
- this.brushOrderMapper = brushOrderMapper;
- this.productSpecMapper = productSpecMapper;
this.productMapper = productMapper;
this.categoryService = categoryService;
this.platformMapper = platformMapper;
@@ -413,15 +393,6 @@ public class WorkbenchServiceImpl implements WorkbenchService {
.stream().collect(Collectors.toMap(CategoryPO::getId, CategoryPO::getName, (a, b) -> a));
}
- private static List statusList(java.util.Set ids) {
- if (ids == null || ids.isEmpty()) {
- return List.of(-1L);
- }
- List list = new ArrayList<>(ids);
- Collections.sort(list);
- return list;
- }
-
private static BigDecimal dayNetSales(OrderStatAggMapper.DailyRow row) {
if (row == null) {
return BigDecimal.ZERO;
@@ -488,95 +459,6 @@ public class WorkbenchServiceImpl implements WorkbenchService {
}
}
- /** 当前区间:计入销售额订单、推广/刷单、汇总 Totals(导出等仍用) */
- private CurrentPeriodBundle loadCurrentPeriod(ShopContext ctx) {
- List unionStatusIds = ctx.stat().getUnionStatusIds();
- List orders = loadOrders(ctx.companyId(), ctx.shopIds(),
- ctx.range().startDateTime(), ctx.range().endDateTime(), unionStatusIds);
- List promotionFees = loadPromotionFees(ctx.companyId(), ctx.shopIds(),
- ctx.range().startDate(), ctx.range().endDate());
- List brushOrders = loadBrushOrders(ctx.companyId(), ctx.shopIds(),
- ctx.range().startDateTime(), ctx.range().endDateTime());
- Totals totals = aggregateTotals(orders, ctx.stat(), promotionFees, brushOrders, ctx.taxRate());
- return new CurrentPeriodBundle(orders, promotionFees, brushOrders, totals);
- }
-
- /** 环比/同比:用于 KPI 对比与总 GMV(导出等仍用) */
- private ComparePeriodBundle loadComparePeriods(ShopContext ctx) {
- List unionStatusIds = ctx.stat().getUnionStatusIds();
- List curOrdersAllStatuses = loadOrdersAllStatuses(ctx.companyId(), ctx.shopIds(),
- ctx.range().startDateTime(), ctx.range().endDateTime());
- DateRange lastRange = lastMonthSameSpan(ctx.range());
- List lastOrders = loadOrders(ctx.companyId(), ctx.shopIds(),
- lastRange.startDateTime(), lastRange.endDateTime(), unionStatusIds);
- List lastOrdersAllStatuses = loadOrdersAllStatuses(ctx.companyId(), ctx.shopIds(),
- lastRange.startDateTime(), lastRange.endDateTime());
- List lastPromo = loadPromotionFees(ctx.companyId(), ctx.shopIds(),
- lastRange.startDate(), lastRange.endDate());
- List lastBrush = loadBrushOrders(ctx.companyId(), ctx.shopIds(),
- lastRange.startDateTime(), lastRange.endDateTime());
- Totals prev = aggregateTotals(lastOrders, ctx.stat(), lastPromo, lastBrush, ctx.taxRate());
-
- DateRange yoyRange = new DateRange(ctx.range().startDate().minusYears(1), ctx.range().endDate().minusYears(1));
- List yoyOrders = loadOrders(ctx.companyId(), ctx.shopIds(),
- yoyRange.startDateTime(), yoyRange.endDateTime(), unionStatusIds);
- List yoyOrdersAllStatuses = loadOrdersAllStatuses(ctx.companyId(), ctx.shopIds(),
- yoyRange.startDateTime(), yoyRange.endDateTime());
- List yoyPromo = loadPromotionFees(ctx.companyId(), ctx.shopIds(),
- yoyRange.startDate(), yoyRange.endDate());
- List yoyBrush = loadBrushOrders(ctx.companyId(), ctx.shopIds(),
- yoyRange.startDateTime(), yoyRange.endDateTime());
- Totals yoy = aggregateTotals(yoyOrders, ctx.stat(), yoyPromo, yoyBrush, ctx.taxRate());
-
- return new ComparePeriodBundle(lastRange, yoyRange, prev, yoy,
- sumAllReceivedAmount(curOrdersAllStatuses),
- sumAllReceivedAmount(lastOrdersAllStatuses),
- sumAllReceivedAmount(yoyOrdersAllStatuses));
- }
-
- /** 四维订单聚合 + 名称解析 */
- private DimensionAggMaps aggregateDimensions(List orders,
- List shops,
- Map shopById,
- OrderStatusStatSets stat) {
- Map specToProduct = buildSpecToProductMap(orders);
- Map productById = loadProducts(specToProduct.values());
- Map categoryNames = loadCategoryNames(productById.values());
- Map platformNames = loadPlatformNames(shops);
-
- Map platformAgg = new HashMap<>();
- Map shopAgg = new HashMap<>();
- Map categoryAgg = new HashMap<>();
- Map productAgg = new HashMap<>();
-
- for (OrderPO o : orders) {
- ShopPO shop = shopById.get(o.getShopId());
- if (shop == null) {
- continue;
- }
- long platformKey = shop.getPlatformId() != null ? shop.getPlatformId() : 0L;
- long shopKey = shop.getId() != null ? shop.getId() : 0L;
- long productId = o.getProductSpecId() != null
- ? specToProduct.getOrDefault(o.getProductSpecId(), -1L)
- : -1L;
- long categoryKey = 0L;
- if (productId > 0) {
- ProductPO p = productById.get(productId);
- if (p != null && p.getCategoryId() != null) {
- categoryKey = p.getCategoryId();
- }
- }
-
- addOrder(platformAgg, String.valueOf(platformKey), o, stat);
- addOrder(shopAgg, String.valueOf(shopKey), o, stat);
- addOrder(categoryAgg, String.valueOf(categoryKey), o, stat);
- addOrder(productAgg, String.valueOf(productId), o, stat);
- }
-
- return new DimensionAggMaps(platformAgg, shopAgg, categoryAgg, productAgg,
- platformNames, categoryNames, productById, shopById);
- }
-
private WorkbenchMultiAnalysisPanelVO buildMultiPanel(DimensionAggMaps aggs, Totals cur) {
BigDecimal salesAllocBase = cur.totalSales();
return WorkbenchMultiAnalysisPanelVO.builder()
@@ -615,29 +497,6 @@ public class WorkbenchServiceImpl implements WorkbenchService {
.build();
}
- private WorkbenchFinancePanelVO buildFinancePanel(ShopContext ctx,
- CurrentPeriodBundle current,
- ComparePeriodBundle compare,
- Map platformAgg,
- Map platformNames) {
- List ordersAllStatuses = loadOrdersAllStatuses(ctx.companyId(), ctx.shopIds(),
- ctx.range().startDateTime(), ctx.range().endDateTime());
- BigDecimal totalGmvCur = sumAllReceivedAmount(ordersAllStatuses);
- BigDecimal salesAllocBase = current.totals().totalSales();
-
- return WorkbenchFinancePanelVO.builder()
- .kpis(buildKpis(current.totals(), compare.prev(), compare.yoy(), ctx.range(), ctx.taxRate(),
- totalGmvCur, compare.totalGmvPrev(), compare.totalGmvYoy()))
- .gmvTrend(buildTrend(current.orders(), ctx.stat(),
- ctx.range().startDate(), ctx.range().endDate(), current.totals()))
- .platformSalesShare(buildPlatformSalesSlices(platformAgg, platformNames, salesAllocBase))
- .momCompareDateStart(compare.lastRange().startDate().toString())
- .momCompareDateEnd(compare.lastRange().endDate().toString())
- .yoyCompareDateStart(compare.yoyRange().startDate().toString())
- .yoyCompareDateEnd(compare.yoyRange().endDate().toString())
- .build();
- }
-
/**
* 按公司 + 可选平台/单店筛选店铺列表;指定 {@code shopId} 时校验归属与平台一致性。
*/
@@ -660,103 +519,6 @@ public class WorkbenchServiceImpl implements WorkbenchService {
return shopService.list(w);
}
- /**
- * 查询「计入销售额」口径订单:状态 id 落在 {@code unionStatusIds} 内;若公司未配置任何计入状态则查不到数据(条件恒假)。
- */
- private List loadOrders(Long companyId, List shopIds,
- LocalDateTime start, LocalDateTime end, List unionStatusIds) {
- if (shopIds.isEmpty()) {
- return Collections.emptyList();
- }
- LambdaQueryWrapper orderWrapper = new LambdaQueryWrapper<>();
- orderWrapper.eq(OrderPO::getCompanyId, companyId)
- .in(OrderPO::getShopId, shopIds)
- .ge(OrderPO::getOrderTime, start)
- .le(OrderPO::getOrderTime, end);
- if (!unionStatusIds.isEmpty()) {
- orderWrapper.in(OrderPO::getStatusId, unionStatusIds);
- } else {
- orderWrapper.isNull(OrderPO::getId);
- }
- return orderMapper.selectList(orderWrapper);
- }
-
- /**
- * 总 GMV 用:同店铺、时间范围内全部订单状态的列表,不按「计入销售额」过滤。
- */
- private List loadOrdersAllStatuses(Long companyId, List shopIds,
- LocalDateTime start, LocalDateTime end) {
- if (shopIds.isEmpty()) {
- return Collections.emptyList();
- }
- LambdaQueryWrapper w = new LambdaQueryWrapper<>();
- w.eq(OrderPO::getCompanyId, companyId)
- .in(OrderPO::getShopId, shopIds)
- .ge(OrderPO::getOrderTime, start)
- .le(OrderPO::getOrderTime, end);
- return orderMapper.selectList(w);
- }
-
- /** 将订单列表的商家实收相加,用于总 GMV KPI */
- private static BigDecimal sumAllReceivedAmount(List orders) {
- BigDecimal s = BigDecimal.ZERO;
- if (orders == null) {
- return s;
- }
- for (OrderPO o : orders) {
- if (o.getReceivedAmount() != null) {
- s = s.add(o.getReceivedAmount());
- }
- }
- return s;
- }
-
- /** 推广费按费用发生日落在 [start, end] 闭区间内 */
- private List loadPromotionFees(Long companyId, List shopIds, LocalDate start, LocalDate end) {
- if (shopIds.isEmpty()) {
- return Collections.emptyList();
- }
- LambdaQueryWrapper w = new LambdaQueryWrapper<>();
- w.eq(PromotionFeePO::getCompanyId, companyId)
- .in(PromotionFeePO::getShopId, shopIds)
- .ge(PromotionFeePO::getFeeDate, start)
- .le(PromotionFeePO::getFeeDate, end);
- return promotionFeeMapper.selectList(w);
- }
-
- /** 刷单记录按刷单时间落在 [start, end] 内 */
- private List loadBrushOrders(Long companyId, List shopIds, LocalDateTime start, LocalDateTime end) {
- if (shopIds.isEmpty()) {
- return Collections.emptyList();
- }
- LambdaQueryWrapper w = new LambdaQueryWrapper<>();
- w.eq(BrushOrderPO::getCompanyId, companyId)
- .in(BrushOrderPO::getShopId, shopIds)
- .ge(BrushOrderPO::getBrushTime, start)
- .le(BrushOrderPO::getBrushTime, end);
- return brushOrderMapper.selectList(w);
- }
-
- /** 批量解析订单中出现的规格 id → 商品 id,减少重复查库 */
- private Map buildSpecToProductMap(List orders) {
- List specIds = orders.stream()
- .map(OrderPO::getProductSpecId)
- .filter(Objects::nonNull)
- .distinct()
- .toList();
- if (specIds.isEmpty()) {
- return Collections.emptyMap();
- }
- List specs = productSpecMapper.selectList(new LambdaQueryWrapper()
- .in(ProductSpecPO::getId, specIds)
- .select(ProductSpecPO::getId, ProductSpecPO::getProductId));
- Map map = new HashMap<>();
- for (ProductSpecPO s : specs) {
- map.put(s.getId(), s.getProductId());
- }
- return map;
- }
-
/** 按商品 id 批量加载主数据,供类目解析与商品名称展示 */
private Map loadProducts(Iterable productIds) {
List ids = new ArrayList<>();
@@ -773,22 +535,6 @@ public class WorkbenchServiceImpl implements WorkbenchService {
return list.stream().collect(Collectors.toMap(ProductPO::getId, p -> p, (a, b) -> a));
}
- /** 从商品上收集类目 id,再批量查类目名称 */
- private Map loadCategoryNames(Iterable products) {
- List catIds = new ArrayList<>();
- for (ProductPO p : products) {
- if (p.getCategoryId() != null) {
- catIds.add(p.getCategoryId());
- }
- }
- catIds = catIds.stream().distinct().toList();
- if (catIds.isEmpty()) {
- return Collections.emptyMap();
- }
- List cats = categoryService.list(new LambdaQueryWrapper().in(CategoryPO::getId, catIds));
- return cats.stream().collect(Collectors.toMap(CategoryPO::getId, CategoryPO::getName, (a, b) -> a));
- }
-
/** 从店铺收集平台 id,再批量查平台名称(多维「平台」行展示) */
private Map loadPlatformNames(List shops) {
List pids = shops.stream()
@@ -803,11 +549,6 @@ public class WorkbenchServiceImpl implements WorkbenchService {
return list.stream().collect(Collectors.toMap(PlatformPO::getId, PlatformPO::getPlatformName, (a, b) -> a));
}
- /** 将单条订单累加到指定 key 的 {@link Agg} 桶中 */
- private void addOrder(Map map, String key, OrderPO o, OrderStatusStatSets stat) {
- map.computeIfAbsent(key, k -> new Agg()).add(o, stat);
- }
-
/**
* 将「字符串 key → 聚合桶」转为多维表格行:每行毛利润 = 销售−成本−退款;
* 推广费、刷单费按该行销售额占 {@code salesTotalCompany} 比例分摊;税额按该行净销售额占全部分桶净销售额之和比例分摊;
@@ -885,60 +626,6 @@ public class WorkbenchServiceImpl implements WorkbenchService {
return amount.multiply(part).divide(total, 4, RoundingMode.HALF_UP);
}
- /**
- * 趋势点:毛利润按日订单聚合;净利润按区间总推广/刷单/税额,以「日销售额占比」「日净销售额占比」分摊到各日,
- * 与 {@link #buildDimRows} 及 KPI 净利润口径一致。
- */
- private List buildTrend(List orders, OrderStatusStatSets stat,
- LocalDate start, LocalDate end, Totals periodTotals) {
- Map byDay = new HashMap<>();
- for (OrderPO o : orders) {
- if (o.getOrderTime() == null) {
- continue;
- }
- LocalDate day = o.getOrderTime().toLocalDate();
- byDay.computeIfAbsent(day, x -> new Agg()).add(o, stat);
- }
- BigDecimal salesTotal = periodTotals.totalSales();
- BigDecimal promoTotal = periodTotals.promotion();
- BigDecimal brushTotal = periodTotals.brush();
- BigDecimal taxTotal = periodTotals.tax();
-
- BigDecimal netSum = BigDecimal.ZERO;
- for (LocalDate x = start; !x.isAfter(end); x = x.plusDays(1)) {
- netSum = netSum.add(byDay.getOrDefault(x, new Agg()).netSalesBase());
- }
-
- List list = new ArrayList<>();
- LocalDate d = start;
- while (!d.isAfter(end)) {
- Agg a = byDay.getOrDefault(d, new Agg());
- BigDecimal salesYuan = yuan2(a.sales);
- BigDecimal gross = a.sales.subtract(a.cost).subtract(a.refund);
- BigDecimal profitYuan = yuan2(gross);
- BigDecimal refundYuan = yuan2(a.refund);
-
- BigDecimal promoB = allocShare(a.sales, salesTotal, promoTotal);
- BigDecimal brushB = allocShare(a.sales, salesTotal, brushTotal);
- BigDecimal taxB = allocShare(a.netSalesBase(), netSum.max(BigDecimal.ONE), taxTotal);
- if (netSum.compareTo(BigDecimal.ZERO) <= 0) {
- taxB = BigDecimal.ZERO;
- }
- BigDecimal netDay = gross.subtract(promoB).subtract(brushB).subtract(taxB);
- BigDecimal netProfitYuan = yuan2(netDay);
-
- list.add(WorkbenchTrendPointVO.builder()
- .date(d.format(TREND_DATE_FMT))
- .salesYuan(salesYuan)
- .profitYuan(profitYuan)
- .netProfitYuan(netProfitYuan)
- .refundYuan(refundYuan)
- .build());
- d = d.plusDays(1);
- }
- return list;
- }
-
/**
* 各平台实际销售额占比:与多维分析「平台」维度同源订单聚合;分母为当前筛选下公司实际销售额合计。
*/
@@ -1076,51 +763,6 @@ public class WorkbenchServiceImpl implements WorkbenchService {
.setScale(2, RoundingMode.HALF_UP);
}
- /**
- * 将一段时间内的订单 + 推广 + 刷单聚合成 {@link Totals}:销售额/退款/成本分项、推广与刷单合计、
- * 按「销售额−退款」为税基的税额、毛利润、净利润、计入销售额订单数与客单价。
- */
- private Totals aggregateTotals(List orders, OrderStatusStatSets stat,
- List promotionFees, List brushOrders,
- BigDecimal taxRate) {
- BigDecimal sales = BigDecimal.ZERO;
- BigDecimal refund = BigDecimal.ZERO;
- BigDecimal cost = BigDecimal.ZERO;
- BigDecimal productCost = BigDecimal.ZERO;
- BigDecimal freight = BigDecimal.ZERO;
- BigDecimal other = BigDecimal.ZERO;
- int orderCount = 0;
- for (OrderPO o : orders) {
- sales = sales.add(stat.receivedForSales(o));
- refund = refund.add(stat.receivedForRefund(o));
- productCost = productCost.add(stat.productCostForStats(o));
- freight = freight.add(stat.freightCostForStats(o));
- other = other.add(stat.otherCostForStats(o));
- cost = cost.add(stat.totalCostForStats(o));
- if (stat.includesSales(o.getStatusId())) {
- orderCount++;
- }
- }
- BigDecimal promotion = promotionFees.stream()
- .map(f -> f.getFeeAmount() != null ? f.getFeeAmount() : BigDecimal.ZERO)
- .reduce(BigDecimal.ZERO, BigDecimal::add);
- BigDecimal brush = brushOrders.stream()
- .map(b -> b.getBrushAmount() != null ? b.getBrushAmount() : BigDecimal.ZERO)
- .reduce(BigDecimal.ZERO, BigDecimal::add);
-
- BigDecimal grossOrder = sales.subtract(cost).subtract(refund);
- BigDecimal profitBeforeTax = grossOrder.subtract(promotion).subtract(brush);
- BigDecimal tax = salesTaxOnNetSales(sales, refund, taxRate);
- BigDecimal netProfit = profitBeforeTax.subtract(tax);
-
- BigDecimal aov = orderCount > 0
- ? sales.divide(BigDecimal.valueOf(orderCount), 2, RoundingMode.HALF_UP)
- : BigDecimal.ZERO;
-
- return new Totals(sales, refund, cost, productCost, freight, other, promotion, brush, tax,
- grossOrder, netProfit, orderCount, aov);
- }
-
/**
* 与单店概览一致:订单流水中「销售额−成本」的合计,再扣推广、刷单得税前;再扣税得净利。
*/
@@ -1207,13 +849,6 @@ public class WorkbenchServiceImpl implements WorkbenchService {
Map shopById) {
}
- /** 当前区间订单与费用 */
- private record CurrentPeriodBundle(List orders,
- List promotionFees,
- List brushOrders,
- Totals totals) {
- }
-
/** 环比/同比汇总 */
private record ComparePeriodBundle(DateRange lastRange,
DateRange yoyRange,
@@ -1265,41 +900,22 @@ public class WorkbenchServiceImpl implements WorkbenchService {
BigDecimal netProfit,
int orderCount,
BigDecimal averageOrderValue) {
- /** max(0, 销售额 − 退款),作税额分摊分母用 */
- BigDecimal netSalesBase() {
- BigDecimal b = totalSales.subtract(totalRefund);
- return b.max(BigDecimal.ZERO);
- }
}
- /**
- * 多维或按日聚合用的累加桶:与 {@link OrderStatusStatSets} 同步累计销售额、退款、成本,并统计计入销售额的订单笔数。
- */
+ /** 多维或按日聚合用的累加桶:累计销售额、退款、成本 */
private static final class Agg {
BigDecimal sales = BigDecimal.ZERO;
BigDecimal refund = BigDecimal.ZERO;
BigDecimal cost = BigDecimal.ZERO;
- int orders;
-
- /** 累加单笔订单的销售额、退款、成本;若状态计入销售额则订单笔数 +1 */
- void add(OrderPO o, OrderStatusStatSets stat) {
- sales = sales.add(stat.receivedForSales(o));
- refund = refund.add(stat.receivedForRefund(o));
- cost = cost.add(stat.totalCostForStats(o));
- if (stat.includesSales(o.getStatusId())) {
- orders++;
- }
- }
/** 累加 SQL 聚合行 */
void addFromAggRow(OrderStatAggMapper.ShopProductRow row) {
sales = sales.add(nz(row.getSalesAmount()));
refund = refund.add(nz(row.getRefundAmount()));
cost = cost.add(nz(row.getProductCost())).add(nz(row.getFreightCost())).add(nz(row.getOtherCost()));
- orders += row.getOrderCount() != null ? row.getOrderCount().intValue() : 0;
}
- /** 桶内净销售额 max(0, 销售−退款),与 {@link Totals#netSalesBase()} 含义一致,用于税额分摊 */
+ /** 桶内净销售额 max(0, 销售−退款),用于税额分摊 */
BigDecimal netSalesBase() {
BigDecimal b = sales.subtract(refund);
return b.max(BigDecimal.ZERO);
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/open/api/filter/ApiKeyAuthenticationFilter.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/open/api/filter/ApiKeyAuthenticationFilter.java
index fe62a16d..122a2691 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/open/api/filter/ApiKeyAuthenticationFilter.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/open/api/filter/ApiKeyAuthenticationFilter.java
@@ -6,6 +6,7 @@ import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.lang.NonNull;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@@ -41,13 +42,16 @@ public class ApiKeyAuthenticationFilter extends OncePerRequestFilter {
}
@Override
- protected boolean shouldNotFilter(HttpServletRequest request) {
+ protected boolean shouldNotFilter(@NonNull HttpServletRequest request) {
String uri = request.getRequestURI();
return uri == null || !uri.startsWith(OPEN_PATH_PREFIX);
}
@Override
- protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
+ protected void doFilterInternal(
+ @NonNull HttpServletRequest request,
+ @NonNull HttpServletResponse response,
+ @NonNull FilterChain filterChain)
throws ServletException, IOException {
try {
String apiKey = extractApiKey(request);
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/open/key/service/impl/OpenApiKeyServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/open/key/service/impl/OpenApiKeyServiceImpl.java
index fd1f5e80..48e8e5e4 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/open/key/service/impl/OpenApiKeyServiceImpl.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/open/key/service/impl/OpenApiKeyServiceImpl.java
@@ -1,10 +1,10 @@
package top.xyquan.ecomdmbbackend.modules.open.key.service.impl;
+import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
-import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@@ -256,7 +256,7 @@ public class OpenApiKeyServiceImpl implements OpenApiKeyService {
}
private void copyToVo(OpenApiKeyPO po, OpenApiKeyVO vo) {
- BeanUtils.copyProperties(po, vo, "ipWhitelist");
+ BeanCopyUtils.copyProperties(po, vo, "ipWhitelist");
List permissions =
openApiKeyPermissionMapper.selectPermissionsByApiKeyId(po.getId());
vo.setPermissions(permissions);
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/controller/AccountController.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/controller/AccountController.java
index ccfde210..ce837a8a 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/controller/AccountController.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/controller/AccountController.java
@@ -1,4 +1,4 @@
-package top.xyquan.ecomdmbbackend.modules.org.account.controller;
+package top.xyquan.ecomdmbbackend.modules.org.company.account.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -9,11 +9,11 @@ import top.xyquan.ecomdmbbackend.common.annotation.RequirePermission;
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.AccountFilterDTO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.CreateAccountDTO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.UpdateAccountDTO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.vo.AccountVO;
-import top.xyquan.ecomdmbbackend.modules.org.account.service.AccountService;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.AccountFilterDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.CreateAccountDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.UpdateAccountDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo.CompanyAccountVO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.service.AccountService;
/**
* 公司账户管理控制器
@@ -35,8 +35,8 @@ public class AccountController {
@Operation(summary = "创建账户(拥有者)", description = "公司拥有者创建本公司账户;手机号已存在时将用户拉入本公司,不存在则新建用户")
@PostMapping("/create")
@RequirePermission(value = "org:company:manage", description = "创建账户", allowSuper = true)
- public ApiResponse createAccountForCompany(@Valid @RequestBody CreateAccountDTO createAccountDTO) {
- AccountVO accountVO = accountService.createAccountForCompany(createAccountDTO);
+ public ApiResponse createAccountForCompany(@Valid @RequestBody CreateAccountDTO createAccountDTO) {
+ CompanyAccountVO accountVO = accountService.createAccountForCompany(createAccountDTO);
return ApiResponse.success("账户创建成功", accountVO);
}
@@ -44,8 +44,8 @@ public class AccountController {
@Operation(summary = "分页查询账户(拥有者)", description = "公司拥有者分页查询本公司账户")
@PostMapping("/list")
@RequirePermission(value = "org:company:manage", description = "查询账户列表", allowSuper = true)
- public ApiResponse> getAccountPageForCompany(@Valid @RequestBody PageQueryDTO pageQuery) {
- PageResultVO pageResult = accountService.getAccountPageForCompany(pageQuery);
+ public ApiResponse> getAccountPageForCompany(@Valid @RequestBody PageQueryDTO pageQuery) {
+ PageResultVO pageResult = accountService.getAccountPageForCompany(pageQuery);
return ApiResponse.success("获取账户列表成功", pageResult);
}
@@ -53,10 +53,10 @@ public class AccountController {
@Operation(summary = "更新账户信息", description = "公司拥有者更新本公司账户信息")
@PutMapping("/update/{accountId}")
@RequirePermission(value = "org:company:manage", description = "更新账户", allowSuper = true)
- public ApiResponse updateAccount(
+ public ApiResponse updateAccount(
@Parameter(description = "账户ID", example = "1") @PathVariable Long accountId,
@Valid @RequestBody UpdateAccountDTO updateAccountDTO) {
- AccountVO accountVO = accountService.updateAccountForCompany(updateAccountDTO, accountId);
+ CompanyAccountVO accountVO = accountService.updateAccountForCompany(updateAccountDTO, accountId);
return ApiResponse.success("账户更新成功", accountVO);
}
@@ -73,9 +73,9 @@ public class AccountController {
@Operation(summary = "获取账户详情", description = "获取账户详细信息")
@GetMapping("/detail/{accountId}")
@RequirePermission(value = "org:company:manage", description = "获取账户详情", allowSuper = true)
- public ApiResponse getAccountDetail(
+ public ApiResponse getAccountDetail(
@Parameter(description = "账户ID", example = "1") @PathVariable Long accountId) {
- AccountVO accountVO = accountService.getAccountDetail(accountId);
+ CompanyAccountVO accountVO = accountService.getAccountDetail(accountId);
return ApiResponse.success("获取账户详情成功", accountVO);
}
}
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/controller/SuperAccountController.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/controller/SuperAccountController.java
index f1fa7654..3be46af8 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/controller/SuperAccountController.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/controller/SuperAccountController.java
@@ -1,4 +1,4 @@
-package top.xyquan.ecomdmbbackend.modules.org.account.controller;
+package top.xyquan.ecomdmbbackend.modules.org.company.account.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -9,11 +9,11 @@ import top.xyquan.ecomdmbbackend.common.annotation.RequirePermission;
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.AccountFilterDTO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.SuperCreateAccountDTO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.SuperUpdateAccountDTO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.vo.AccountVO;
-import top.xyquan.ecomdmbbackend.modules.org.account.service.SuperAccountService;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.AccountFilterDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.SuperCreateAccountDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.SuperUpdateAccountDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo.CompanyAccountVO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.service.SuperAccountService;
/**
* 超级管理员账户管理控制器
@@ -32,26 +32,26 @@ public class SuperAccountController {
@Operation(summary = "创建账户", description = "超级管理员创建账户,可指定公司")
@PostMapping("/create")
@RequirePermission(value = "org:company:manage", description = "创建账户", allowSuper = true)
- public ApiResponse createAccount(@Valid @RequestBody SuperCreateAccountDTO superCreateAccountDTO) {
- AccountVO accountVO = superAccountService.createAccount(superCreateAccountDTO);
+ public ApiResponse createAccount(@Valid @RequestBody SuperCreateAccountDTO superCreateAccountDTO) {
+ CompanyAccountVO accountVO = superAccountService.createAccount(superCreateAccountDTO);
return ApiResponse.success("账户创建成功", accountVO);
}
@Operation(summary = "分页查询账户", description = "超级管理员分页查询所有账户")
@PostMapping("/list")
@RequirePermission(value = "org:company:manage", description = "查询账户列表", allowSuper = true)
- public ApiResponse> getAccountPage(@Valid @RequestBody PageQueryDTO pageQuery) {
- PageResultVO pageResult = superAccountService.getAccountPage(pageQuery);
+ public ApiResponse> getAccountPage(@Valid @RequestBody PageQueryDTO pageQuery) {
+ PageResultVO pageResult = superAccountService.getAccountPage(pageQuery);
return ApiResponse.success("获取账户列表成功", pageResult);
}
@Operation(summary = "更新账户信息", description = "超级管理员更新账户信息")
@PutMapping("/update/{accountId}")
@RequirePermission(value = "org:company:manage", description = "更新账户", allowSuper = true)
- public ApiResponse updateAccount(
+ public ApiResponse updateAccount(
@Parameter(description = "账户ID", example = "1") @PathVariable Long accountId,
@Valid @RequestBody SuperUpdateAccountDTO superUpdateAccountDTO) {
- AccountVO accountVO = superAccountService.updateAccount(superUpdateAccountDTO, accountId);
+ CompanyAccountVO accountVO = superAccountService.updateAccount(superUpdateAccountDTO, accountId);
return ApiResponse.success("账户更新成功", accountVO);
}
@@ -67,9 +67,9 @@ public class SuperAccountController {
@Operation(summary = "获取账户详情", description = "超级管理员获取账户详细信息")
@GetMapping("/detail/{accountId}")
@RequirePermission(value = "org:company:manage", description = "查询账户详情", allowSuper = true)
- public ApiResponse getAccountDetail(
+ public ApiResponse getAccountDetail(
@Parameter(description = "账户ID", example = "1") @PathVariable Long accountId) {
- AccountVO accountVO = superAccountService.getAccountDetail(accountId);
+ CompanyAccountVO accountVO = superAccountService.getAccountDetail(accountId);
return ApiResponse.success("获取账户详情成功", accountVO);
}
}
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/AccountFilterDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/AccountFilterDTO.java
index f3172af6..8b4f224a 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/AccountFilterDTO.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/AccountFilterDTO.java
@@ -1,4 +1,4 @@
-package top.xyquan.ecomdmbbackend.modules.org.account.model.dto;
+package top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/CreateAccountDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/CreateAccountDTO.java
index 826d4c20..ea94b00c 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/CreateAccountDTO.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/CreateAccountDTO.java
@@ -1,4 +1,4 @@
-package top.xyquan.ecomdmbbackend.modules.org.account.model.dto;
+package top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/SuperCreateAccountDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/SuperCreateAccountDTO.java
index 7bccea63..5c9715dd 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/SuperCreateAccountDTO.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/SuperCreateAccountDTO.java
@@ -1,4 +1,4 @@
-package top.xyquan.ecomdmbbackend.modules.org.account.model.dto;
+package top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/SuperUpdateAccountDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/SuperUpdateAccountDTO.java
index b806069b..72c22df5 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/SuperUpdateAccountDTO.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/SuperUpdateAccountDTO.java
@@ -1,4 +1,4 @@
-package top.xyquan.ecomdmbbackend.modules.org.account.model.dto;
+package top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Pattern;
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/UpdateAccountDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/UpdateAccountDTO.java
index 8b04fdb6..1a7f83db 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/UpdateAccountDTO.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/dto/UpdateAccountDTO.java
@@ -1,4 +1,4 @@
-package top.xyquan.ecomdmbbackend.modules.org.account.model.dto;
+package top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Pattern;
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/AccountPageVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/AccountPageVO.java
index c8eded18..651b35fc 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/AccountPageVO.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/AccountPageVO.java
@@ -1,4 +1,4 @@
-package top.xyquan.ecomdmbbackend.modules.org.account.model.vo;
+package top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -13,7 +13,7 @@ import java.util.List;
public class AccountPageVO {
@Schema(description = "账户列表")
- private List records;
+ private List records;
@Schema(description = "总记录数", example = "100")
private Long total;
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/AccountVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/CompanyAccountVO.java
similarity index 96%
rename from ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/AccountVO.java
rename to ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/CompanyAccountVO.java
index edf254bf..1148e97d 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/AccountVO.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/model/vo/CompanyAccountVO.java
@@ -1,4 +1,4 @@
-package top.xyquan.ecomdmbbackend.modules.org.account.model.vo;
+package top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -10,7 +10,7 @@ import java.time.LocalDateTime;
*/
@Data
@Schema(description = "账户信息")
-public class AccountVO {
+public class CompanyAccountVO {
@Schema(description = "用户ID", example = "1")
private Long id;
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/AccountService.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/AccountService.java
index de4c16f7..068f532f 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/AccountService.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/AccountService.java
@@ -1,13 +1,13 @@
-package top.xyquan.ecomdmbbackend.modules.org.account.service;
+package top.xyquan.ecomdmbbackend.modules.org.company.account.service;
import com.baomidou.mybatisplus.extension.service.IService;
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.AccountFilterDTO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.CreateAccountDTO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.UpdateAccountDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.AccountFilterDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.CreateAccountDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.UpdateAccountDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo.CompanyAccountVO;
import top.xyquan.ecomdmbbackend.modules.sys.user.model.po.UserPO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.vo.AccountVO;
/**
* 账户管理服务接口
@@ -23,7 +23,7 @@ public interface AccountService extends IService {
* @param createAccountDTO 创建账户信息
* @return 账户信息
*/
- AccountVO createAccountForCompany(CreateAccountDTO createAccountDTO);
+ CompanyAccountVO createAccountForCompany(CreateAccountDTO createAccountDTO);
/**
* 更新账户信息(拥有者接口)
@@ -32,7 +32,7 @@ public interface AccountService extends IService {
* @param accountId 账户ID
* @return 更新后的账户信息
*/
- AccountVO updateAccountForCompany(UpdateAccountDTO updateAccountDTO, Long accountId);
+ CompanyAccountVO updateAccountForCompany(UpdateAccountDTO updateAccountDTO, Long accountId);
/**
* 删除账户(逻辑删除)
@@ -47,7 +47,7 @@ public interface AccountService extends IService {
* @param accountId 账户ID
* @return 账户详情
*/
- AccountVO getAccountDetail(Long accountId);
+ CompanyAccountVO getAccountDetail(Long accountId);
/**
* 分页查询账户(超管接口)
@@ -55,7 +55,7 @@ public interface AccountService extends IService {
* @param pageQuery 分页查询参数
* @return 分页结果
*/
- PageResultVO getAccountPage(PageQueryDTO pageQuery);
+ PageResultVO getAccountPage(PageQueryDTO pageQuery);
/**
* 分页查询账户(拥有者接口,只能查询本公司账户)
@@ -63,5 +63,5 @@ public interface AccountService extends IService {
* @param pageQuery 分页查询参数
* @return 分页结果
*/
- PageResultVO getAccountPageForCompany(PageQueryDTO pageQuery);
+ PageResultVO getAccountPageForCompany(PageQueryDTO pageQuery);
}
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/SuperAccountService.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/SuperAccountService.java
index 3e606293..139114f9 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/SuperAccountService.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/SuperAccountService.java
@@ -1,13 +1,13 @@
-package top.xyquan.ecomdmbbackend.modules.org.account.service;
+package top.xyquan.ecomdmbbackend.modules.org.company.account.service;
import com.baomidou.mybatisplus.extension.service.IService;
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.AccountFilterDTO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.SuperCreateAccountDTO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.SuperUpdateAccountDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.AccountFilterDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.SuperCreateAccountDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.SuperUpdateAccountDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo.CompanyAccountVO;
import top.xyquan.ecomdmbbackend.modules.sys.user.model.po.UserPO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.vo.AccountVO;
/**
* 超级管理员账户管理服务接口
@@ -20,7 +20,7 @@ public interface SuperAccountService extends IService {
* @param superCreateAccountDTO 创建账户信息
* @return 账户信息
*/
- AccountVO createAccount(SuperCreateAccountDTO superCreateAccountDTO);
+ CompanyAccountVO createAccount(SuperCreateAccountDTO superCreateAccountDTO);
/**
* 更新账户信息(超管接口)
@@ -29,7 +29,7 @@ public interface SuperAccountService extends IService {
* @param accountId 账户ID
* @return 更新后的账户信息
*/
- AccountVO updateAccount(SuperUpdateAccountDTO superUpdateAccountDTO, Long accountId);
+ CompanyAccountVO updateAccount(SuperUpdateAccountDTO superUpdateAccountDTO, Long accountId);
/**
* 删除账户(逻辑删除)
@@ -44,7 +44,7 @@ public interface SuperAccountService extends IService {
* @param accountId 账户ID
* @return 账户详情
*/
- AccountVO getAccountDetail(Long accountId);
+ CompanyAccountVO getAccountDetail(Long accountId);
/**
* 分页查询账户(超管接口)
@@ -52,5 +52,5 @@ public interface SuperAccountService extends IService {
* @param pageQuery 分页查询参数
* @return 分页结果
*/
- PageResultVO getAccountPage(PageQueryDTO pageQuery);
+ PageResultVO getAccountPage(PageQueryDTO pageQuery);
}
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/impl/AccountServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/impl/AccountServiceImpl.java
index 5d400c97..053d69b8 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/impl/AccountServiceImpl.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/impl/AccountServiceImpl.java
@@ -1,10 +1,10 @@
-package top.xyquan.ecomdmbbackend.modules.org.account.service.impl;
+package top.xyquan.ecomdmbbackend.modules.org.company.account.service.impl;
+import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.beans.BeanUtils;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@@ -12,12 +12,12 @@ import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
import top.xyquan.ecomdmbbackend.modules.sys.user.mapper.UserMapper;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.AccountFilterDTO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.CreateAccountDTO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.UpdateAccountDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.AccountFilterDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.CreateAccountDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.UpdateAccountDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo.CompanyAccountVO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.service.AccountService;
import top.xyquan.ecomdmbbackend.modules.sys.user.model.po.UserPO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.vo.AccountVO;
-import top.xyquan.ecomdmbbackend.modules.org.account.service.AccountService;
import top.xyquan.ecomdmbbackend.modules.org.company.service.CompanyService;
import top.xyquan.ecomdmbbackend.modules.org.department.member.model.po.DepartmentMemberPO;
import top.xyquan.ecomdmbbackend.modules.org.department.member.model.vo.DepartmentMemberVO;
@@ -80,7 +80,7 @@ public class AccountServiceImpl extends ServiceImpl implemen
* @return 账户VO
*/
@Override
- public AccountVO createAccountForCompany(CreateAccountDTO createAccountDTO) {
+ public CompanyAccountVO createAccountForCompany(CreateAccountDTO createAccountDTO) {
Long companyId = currentUserContext.getCurrentCompanyId();
if (companyId == null) {
throw new BusinessException("无法获取公司信息");
@@ -124,7 +124,7 @@ public class AccountServiceImpl extends ServiceImpl implemen
* 将已存在用户加入当前公司
* 不修改密码;可选更新姓名、备注;同时建立公司成员及部门关联
*/
- private AccountVO addExistingUserToCompany(
+ private CompanyAccountVO addExistingUserToCompany(
UserPO user,
Long companyId,
CreateAccountDTO createAccountDTO,
@@ -160,7 +160,7 @@ public class AccountServiceImpl extends ServiceImpl implemen
* 新建用户并加入当前公司
* 登录账号与手机号相同,系统角色固定为 user,须传入密码
*/
- private AccountVO createNewUserAndAddToCompany(
+ private CompanyAccountVO createNewUserAndAddToCompany(
Long companyId,
CreateAccountDTO createAccountDTO,
CompanyMemberRole memberRole) {
@@ -169,7 +169,7 @@ public class AccountServiceImpl extends ServiceImpl implemen
}
UserPO user = new UserPO();
- BeanUtils.copyProperties(createAccountDTO, user);
+ BeanCopyUtils.copyProperties(createAccountDTO, user);
user.setPassword(passwordEncoder.encode(createAccountDTO.getPassword()));
user.setLoginCode(createAccountDTO.getPhone());
user.setRole("user");
@@ -197,7 +197,7 @@ public class AccountServiceImpl extends ServiceImpl implemen
* @return 账户VO
*/
@Override
- public AccountVO updateAccountForCompany(UpdateAccountDTO updateAccountDTO, Long accountId) {
+ public CompanyAccountVO updateAccountForCompany(UpdateAccountDTO updateAccountDTO, Long accountId) {
// 查询账户
UserPO user = super.getById(accountId);
if (user == null) {
@@ -287,7 +287,7 @@ public class AccountServiceImpl extends ServiceImpl implemen
* @return 账户VO
*/
@Override
- public AccountVO getAccountDetail(Long accountId) {
+ public CompanyAccountVO getAccountDetail(Long accountId) {
// 查询账户
UserPO user = super.getById(accountId);
if (user == null) {
@@ -304,7 +304,7 @@ public class AccountServiceImpl extends ServiceImpl implemen
* @return 分页结果VO
*/
@Override
- public PageResultVO getAccountPage(PageQueryDTO pageQuery) {
+ public PageResultVO getAccountPage(PageQueryDTO pageQuery) {
// 构建查询条件
LambdaQueryWrapper wrapper = buildQueryWrapper(pageQuery.getFilters());
@@ -313,7 +313,7 @@ public class AccountServiceImpl extends ServiceImpl implemen
IPage pageResult = this.page(page, wrapper);
// 转换为VO
- List records = pageResult.getRecords().stream()
+ List records = pageResult.getRecords().stream()
.map(this::convertToVO)
.collect(Collectors.toList());
@@ -327,7 +327,7 @@ public class AccountServiceImpl extends ServiceImpl implemen
* @return 分页结果VO
*/
@Override
- public PageResultVO getAccountPageForCompany(PageQueryDTO pageQuery) {
+ public PageResultVO getAccountPageForCompany(PageQueryDTO pageQuery) {
// 从用户上下文获取公司ID
Long companyId = currentUserContext.getCurrentCompanyId();
if (companyId == null) {
@@ -411,9 +411,9 @@ public class AccountServiceImpl extends ServiceImpl implemen
* @param user 用户PO
* @return 账户VO
*/
- private AccountVO convertToVO(UserPO user) {
- AccountVO accountVO = new AccountVO();
- BeanUtils.copyProperties(user, accountVO);
+ private CompanyAccountVO convertToVO(UserPO user) {
+ CompanyAccountVO accountVO = new CompanyAccountVO();
+ BeanCopyUtils.copyProperties(user, accountVO);
// 设置状态名称
accountVO.setStatusName(getStatusName(user.getStatus()));
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/impl/SuperAccountServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/impl/SuperAccountServiceImpl.java
index cb16069e..2b9c2be6 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/impl/SuperAccountServiceImpl.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/account/service/impl/SuperAccountServiceImpl.java
@@ -1,10 +1,10 @@
-package top.xyquan.ecomdmbbackend.modules.org.account.service.impl;
+package top.xyquan.ecomdmbbackend.modules.org.company.account.service.impl;
+import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.beans.BeanUtils;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@@ -12,12 +12,12 @@ import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
import top.xyquan.ecomdmbbackend.modules.sys.user.mapper.UserMapper;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.AccountFilterDTO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.SuperCreateAccountDTO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.dto.SuperUpdateAccountDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.AccountFilterDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.SuperCreateAccountDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.dto.SuperUpdateAccountDTO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.model.vo.CompanyAccountVO;
+import top.xyquan.ecomdmbbackend.modules.org.company.account.service.SuperAccountService;
import top.xyquan.ecomdmbbackend.modules.sys.user.model.po.UserPO;
-import top.xyquan.ecomdmbbackend.modules.org.account.model.vo.AccountVO;
-import top.xyquan.ecomdmbbackend.modules.org.account.service.SuperAccountService;
import top.xyquan.ecomdmbbackend.modules.org.company.service.CompanyService;
import top.xyquan.ecomdmbbackend.modules.org.department.member.model.po.DepartmentMemberPO;
import top.xyquan.ecomdmbbackend.modules.org.department.member.model.vo.DepartmentMemberVO;
@@ -67,7 +67,7 @@ public class SuperAccountServiceImpl extends ServiceImpl imp
* @return 账户VO
*/
@Override
- public AccountVO createAccount(SuperCreateAccountDTO superCreateAccountDTO) {
+ public CompanyAccountVO createAccount(SuperCreateAccountDTO superCreateAccountDTO) {
// 验证登录账号是否已存在
if (StringUtils.hasText(superCreateAccountDTO.getLoginCode())) {
LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
@@ -88,7 +88,7 @@ public class SuperAccountServiceImpl extends ServiceImpl imp
// 创建账户
UserPO user = new UserPO();
- BeanUtils.copyProperties(superCreateAccountDTO, user);
+ BeanCopyUtils.copyProperties(superCreateAccountDTO, user);
user.setPassword(passwordEncoder.encode(superCreateAccountDTO.getPassword()));
user.setStatus(1); // 正常状态(与 sys_user 表定义一致:1=正常,0=停用)
user.setPwdSecurityLevel(calculatePasswordSecurityLevel(superCreateAccountDTO.getPassword()));
@@ -120,7 +120,7 @@ public class SuperAccountServiceImpl extends ServiceImpl imp
* @return 账户VO
*/
@Override
- public AccountVO updateAccount(SuperUpdateAccountDTO superUpdateAccountDTO, Long accountId) {
+ public CompanyAccountVO updateAccount(SuperUpdateAccountDTO superUpdateAccountDTO, Long accountId) {
// 查询账户
UserPO user = super.getById(accountId);
if (user == null) {
@@ -247,7 +247,7 @@ public class SuperAccountServiceImpl extends ServiceImpl imp
* @return 账户详情
*/
@Override
- public AccountVO getAccountDetail(Long accountId) {
+ public CompanyAccountVO getAccountDetail(Long accountId) {
// 查询账户
UserPO user = super.getById(accountId);
if (user == null) {
@@ -264,7 +264,7 @@ public class SuperAccountServiceImpl extends ServiceImpl imp
* @return 分页结果VO
*/
@Override
- public PageResultVO getAccountPage(PageQueryDTO pageQuery) {
+ public PageResultVO getAccountPage(PageQueryDTO pageQuery) {
// 构建查询条件
LambdaQueryWrapper wrapper = buildQueryWrapper(pageQuery.getFilters());
@@ -273,7 +273,7 @@ public class SuperAccountServiceImpl extends ServiceImpl imp
IPage pageResult = this.page(page, wrapper);
// 转换为VO
- List records = pageResult.getRecords().stream()
+ List records = pageResult.getRecords().stream()
.map(this::convertToVO)
.collect(Collectors.toList());
@@ -376,9 +376,9 @@ public class SuperAccountServiceImpl extends ServiceImpl imp
/**
* 转换为VO
*/
- private AccountVO convertToVO(UserPO user) {
- AccountVO accountVO = new AccountVO();
- BeanUtils.copyProperties(user, accountVO);
+ private CompanyAccountVO convertToVO(UserPO user) {
+ CompanyAccountVO accountVO = new CompanyAccountVO();
+ BeanCopyUtils.copyProperties(user, accountVO);
// 设置状态名称
accountVO.setStatusName(getStatusName(user.getStatus()));
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/member/service/impl/CompanyMemberServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/member/service/impl/CompanyMemberServiceImpl.java
index 99949129..d395bcae 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/member/service/impl/CompanyMemberServiceImpl.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/company/member/service/impl/CompanyMemberServiceImpl.java
@@ -1,8 +1,8 @@
package top.xyquan.ecomdmbbackend.modules.org.company.member.service.impl;
+import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
@@ -68,7 +68,7 @@ public class CompanyMemberServiceImpl extends ServiceImpl {
MenuVO menuVO = new MenuVO();
- BeanUtils.copyProperties(menu, menuVO);
+ BeanCopyUtils.copyProperties(menu, menuVO);
return menuVO;
})
.collect(Collectors.toList());
@@ -315,7 +315,7 @@ public class CompanyMenuServiceImpl extends ServiceImpl im
// 创建公司
CompanyPO company = new CompanyPO();
- BeanUtils.copyProperties(createCompanyDTO, company);
+ BeanCopyUtils.copyProperties(createCompanyDTO, company);
// 设置默认值
if (company.getStatus() == null) {
@@ -179,7 +179,7 @@ public class CompanyServiceImpl extends ServiceImpl im
// 更新公司
CompanyPO company = new CompanyPO();
- BeanUtils.copyProperties(updateCompanyDTO, company);
+ BeanCopyUtils.copyProperties(updateCompanyDTO, company);
// 设置公司ID(必须在updateById之前设置)
company.setId(id);
@@ -386,7 +386,7 @@ public class CompanyServiceImpl extends ServiceImpl im
*/
private CompanyVO convertToVO(CompanyPO company) {
CompanyVO companyVO = new CompanyVO();
- BeanUtils.copyProperties(company, companyVO);
+ BeanCopyUtils.copyProperties(company, companyVO);
// 计算是否过期
if (company.getExpireTime() != null) {
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/department/member/service/impl/DepartmentMemberServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/department/member/service/impl/DepartmentMemberServiceImpl.java
index 58405d87..f65514a2 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/department/member/service/impl/DepartmentMemberServiceImpl.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/department/member/service/impl/DepartmentMemberServiceImpl.java
@@ -1,8 +1,8 @@
package top.xyquan.ecomdmbbackend.modules.org.department.member.service.impl;
+import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
@@ -122,7 +122,7 @@ public class DepartmentMemberServiceImpl extends ServiceImpl {
MenuVO menuVO = new MenuVO();
- BeanUtils.copyProperties(menu, menuVO);
+ BeanCopyUtils.copyProperties(menu, menuVO);
return menuVO;
})
.collect(Collectors.toList());
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/position/service/impl/PositionServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/position/service/impl/PositionServiceImpl.java
index e188092d..5c16d5fb 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/position/service/impl/PositionServiceImpl.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/position/service/impl/PositionServiceImpl.java
@@ -1,10 +1,10 @@
package top.xyquan.ecomdmbbackend.modules.org.position.service.impl;
+import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
@@ -55,7 +55,7 @@ public class PositionServiceImpl extends ServiceImpl
// 创建岗位
PositionPO position = new PositionPO();
- BeanUtils.copyProperties(createPositionDTO, position);
+ BeanCopyUtils.copyProperties(createPositionDTO, position);
// 设置公司ID
position.setCompanyId(companyId);
@@ -109,7 +109,7 @@ public class PositionServiceImpl extends ServiceImpl
// 更新岗位
PositionPO position = new PositionPO();
- BeanUtils.copyProperties(updatePositionDTO, position);
+ BeanCopyUtils.copyProperties(updatePositionDTO, position);
position.setId(id); // 确保ID正确设置
position.setCompanyId(companyId); // 设置公司ID
@@ -209,7 +209,7 @@ public class PositionServiceImpl extends ServiceImpl
// 创建岗位
PositionPO position = new PositionPO();
- BeanUtils.copyProperties(createPositionDTO, position);
+ BeanCopyUtils.copyProperties(createPositionDTO, position);
// 设置公司ID
position.setCompanyId(companyId);
@@ -234,7 +234,7 @@ public class PositionServiceImpl extends ServiceImpl
*/
private PositionVO convertToVO(PositionPO position) {
PositionVO positionVO = new PositionVO();
- BeanUtils.copyProperties(position, positionVO);
+ BeanCopyUtils.copyProperties(position, positionVO);
return positionVO;
}
}
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/plan/pricing/service/impl/PlanPricingServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/plan/pricing/service/impl/PlanPricingServiceImpl.java
index 0f69a2f4..8e288af6 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/plan/pricing/service/impl/PlanPricingServiceImpl.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/plan/pricing/service/impl/PlanPricingServiceImpl.java
@@ -1,10 +1,10 @@
package top.xyquan.ecomdmbbackend.modules.sub.plan.pricing.service.impl;
+import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
@@ -59,7 +59,7 @@ public class PlanPricingServiceImpl extends ServiceImpl implements
// 创建套餐
PlanPO plan = new PlanPO();
- BeanUtils.copyProperties(createPlanDTO, plan);
+ BeanCopyUtils.copyProperties(createPlanDTO, plan);
// 设置默认值
if (plan.getStatus() == null) {
@@ -100,7 +100,7 @@ public class PlanServiceImpl extends ServiceImpl implements
// 更新套餐
PlanPO plan = new PlanPO();
- BeanUtils.copyProperties(updatePlanDTO, plan);
+ BeanCopyUtils.copyProperties(updatePlanDTO, plan);
// 设置更新人ID
plan.setUpdateBy(SecurityUtils.getCurrentUserId());
@@ -172,7 +172,7 @@ public class PlanServiceImpl extends ServiceImpl implements
*/
private PlanVO convertToVO(PlanPO plan) {
PlanVO planVO = new PlanVO();
- BeanUtils.copyProperties(plan, planVO);
+ BeanCopyUtils.copyProperties(plan, planVO);
return planVO;
}
@@ -181,7 +181,7 @@ public class PlanServiceImpl extends ServiceImpl implements
*/
private PlanListVO convertToListVO(PlanPO plan) {
PlanListVO planListVO = new PlanListVO();
- BeanUtils.copyProperties(plan, planListVO);
+ BeanCopyUtils.copyProperties(plan, planListVO);
return planListVO;
}
}
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/subscription/service/impl/SubscriptionServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/subscription/service/impl/SubscriptionServiceImpl.java
index 957c32b7..1e09e474 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/subscription/service/impl/SubscriptionServiceImpl.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/subscription/service/impl/SubscriptionServiceImpl.java
@@ -1,10 +1,10 @@
package top.xyquan.ecomdmbbackend.modules.sub.subscription.service.impl;
+import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
@@ -57,7 +57,7 @@ public class SubscriptionServiceImpl extends ServiceImpl im
// 创建当前公司的文件记录
SysFilePO sysFile = new SysFilePO();
- BeanUtils.copyProperties(otherCompanyFile, sysFile);
+ BeanCopyUtils.copyProperties(otherCompanyFile, sysFile);
sysFile.setId(null);
sysFile.setCompanyId(companyId);
sysFile.setStoragePath(storagePath);
@@ -268,7 +268,7 @@ public class SysFileServiceImpl extends ServiceImpl im
if (verifyFileExists(otherCompanyFile)) {
// 创建当前公司的文件记录
SysFilePO newFile = new SysFilePO();
- BeanUtils.copyProperties(otherCompanyFile, newFile);
+ BeanCopyUtils.copyProperties(otherCompanyFile, newFile);
newFile.setId(null);
newFile.setCompanyId(companyId);
newFile.setFilename(item.getFilename());
@@ -363,7 +363,7 @@ public class SysFileServiceImpl extends ServiceImpl im
if (otherCompanyFile != null) {
// 其他公司已有相同文件,复制记录并关联当前公司
sysFile = new SysFilePO();
- BeanUtils.copyProperties(otherCompanyFile, sysFile);
+ BeanCopyUtils.copyProperties(otherCompanyFile, sysFile);
sysFile.setId(null);
sysFile.setCompanyId(companyId);
sysFile.setStoragePath(item.getStoragePath());
@@ -521,7 +521,7 @@ public class SysFileServiceImpl extends ServiceImpl im
*/
private SysFileVO convertToVO(SysFilePO sysFile) {
SysFileVO vo = new SysFileVO();
- BeanUtils.copyProperties(sysFile, vo);
+ BeanCopyUtils.copyProperties(sysFile, vo);
// 使用工具类生成访问URL
String accessUrl = SysFileUtils.getFileAccessUrl(sysFile.getStoragePath(), sysFile.getStorageType());
@@ -628,7 +628,7 @@ public class SysFileServiceImpl extends ServiceImpl im
return null;
}
SysFileVO vo = new SysFileVO();
- BeanUtils.copyProperties(file, vo);
+ BeanCopyUtils.copyProperties(file, vo);
return vo;
}
}
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/menu/service/impl/MenuServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/menu/service/impl/MenuServiceImpl.java
index 152d79f3..fbadb29a 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/menu/service/impl/MenuServiceImpl.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/menu/service/impl/MenuServiceImpl.java
@@ -1,9 +1,9 @@
package top.xyquan.ecomdmbbackend.modules.sys.menu.service.impl;
+import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
@@ -59,7 +59,7 @@ public class MenuServiceImpl extends ServiceImpl implements
// 创建菜单
MenuPO menu = new MenuPO();
- BeanUtils.copyProperties(createMenuDTO, menu);
+ BeanCopyUtils.copyProperties(createMenuDTO, menu);
// 设置默认值
if (menu.getSuperMenu() == null) {
@@ -122,7 +122,7 @@ public class MenuServiceImpl extends ServiceImpl implements
}
// 更新菜单
- BeanUtils.copyProperties(updateMenuDTO, existingMenu);
+ BeanCopyUtils.copyProperties(updateMenuDTO, existingMenu);
existingMenu.setId(id); // 确保ID正确设置
// 设置更新人ID
@@ -285,7 +285,7 @@ public class MenuServiceImpl extends ServiceImpl implements
*/
private MenuVO convertToVO(MenuPO menu) {
MenuVO menuVO = new MenuVO();
- BeanUtils.copyProperties(menu, menuVO);
+ BeanCopyUtils.copyProperties(menu, menuVO);
// 查询菜单关联的权限
List permissions = baseMapper.selectPermissionsByMenuId(menu.getId());
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/permission/service/impl/PermissionServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/permission/service/impl/PermissionServiceImpl.java
index d989484a..94bb5864 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/permission/service/impl/PermissionServiceImpl.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/permission/service/impl/PermissionServiceImpl.java
@@ -1,11 +1,11 @@
package top.xyquan.ecomdmbbackend.modules.sys.permission.service.impl;
+import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
@@ -58,7 +58,7 @@ public class PermissionServiceImpl extends ServiceImpl implements
// 转换为VO
UserVO userVO = new UserVO();
- BeanUtils.copyProperties(user, userVO);
+ BeanCopyUtils.copyProperties(user, userVO);
fillCompanyFromCurrentToken(userVO);
userVO.setCompanyCount(countAvailableCompanies(userId));
return userVO;
@@ -255,7 +255,7 @@ public class UserServiceImpl extends ServiceImpl implements
// 转换为VO并返回
UserVO userVO = new UserVO();
- BeanUtils.copyProperties(user, userVO);
+ BeanCopyUtils.copyProperties(user, userVO);
fillCompanyFromCurrentToken(userVO);
return userVO;
}
@@ -321,7 +321,7 @@ public class UserServiceImpl extends ServiceImpl implements
// 转换为VO并返回
UserVO userVO = new UserVO();
- BeanUtils.copyProperties(user, userVO);
+ BeanCopyUtils.copyProperties(user, userVO);
fillCompanyFromCurrentToken(userVO);
return userVO;
}
@@ -557,7 +557,7 @@ public class UserServiceImpl extends ServiceImpl implements
*/
private UserVO convertToUserVO(UserPO user) {
UserVO userVO = new UserVO();
- BeanUtils.copyProperties(user, userVO);
+ BeanCopyUtils.copyProperties(user, userVO);
fillCompanyByCompanyId(userVO, user.getLastCompanyId());
return userVO;
}
diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/utils/PermissionUtils.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/utils/PermissionUtils.java
index 4726ef21..2715fe56 100644
--- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/utils/PermissionUtils.java
+++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/utils/PermissionUtils.java
@@ -3,6 +3,7 @@ package top.xyquan.ecomdmbbackend.utils;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
+import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import top.xyquan.ecomdmbbackend.modules.sys.permission.service.PermissionCheckService;
@@ -16,7 +17,7 @@ public class PermissionUtils implements ApplicationContextAware {
private static ApplicationContext applicationContext;
@Override
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ public void setApplicationContext(@NonNull ApplicationContext applicationContext) throws BeansException {
PermissionUtils.applicationContext = applicationContext;
}