Kaynağa Gözat

Merge branch 'dev/2024/0806/update-business-Y' of feifan/mall-backend-business into master

商户查看统计图
Yangzw 7 ay önce
ebeveyn
işleme
7793d9f356
13 değiştirilmiş dosya ile 309 ekleme ve 8 silme
  1. 50 0
      feifan-framework/feifan-common/src/main/java/cn/newfeifan/mall/framework/common/pojo/echarts/EChartsResult.java
  2. 3 0
      feifan-module-mall/feifan-module-product-api/src/main/java/cn/newfeifan/mall/module/product/enums/ErrorCodeConstants.java
  3. 93 0
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spuapplylog/SpuApplyLogController.java
  4. 39 0
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/convert/spuapply/SpuApplyConvert.java
  5. 4 2
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/service/sku/ProductSkuService.java
  6. 5 2
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/service/sku/ProductSkuServiceImpl.java
  7. 2 2
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/service/spu/ProductSpuServiceImpl.java
  8. 12 1
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/TradeOrderController.java
  9. 11 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/mysql/order/TradeOrderMapper.java
  10. 14 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderCountWithMoney.java
  11. 10 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderQueryService.java
  12. 42 1
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderQueryServiceImpl.java
  13. 24 0
      feifan-module-mall/feifan-module-trade-biz/src/main/resources/mapper/order/BrokerageUserMapper.xml

+ 50 - 0
feifan-framework/feifan-common/src/main/java/cn/newfeifan/mall/framework/common/pojo/echarts/EChartsResult.java

@@ -0,0 +1,50 @@
+package cn.newfeifan.mall.framework.common.pojo.echarts;
+
+import lombok.Builder;
+import lombok.Data;
+
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 返回echarts的结果类
+ */
+
+@Data
+@Builder
+public class EChartsResult {
+
+    /**
+     * day对象
+     */
+    private Axis xaxis;
+
+    /**
+     * 数量对象集合
+     */
+    private List<Series> series;
+
+
+    @Data
+    public static class Axis {
+        private String type;
+        private List<LocalDate> data;
+
+        public List<String> getData(){
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            return data.stream().map(date -> date.format(formatter)).collect(Collectors.toList());
+        }
+
+        public Axis(){
+            this.type = "category";
+        }
+    }
+
+    @Data
+    public static class Series{
+        private Long money;
+        private Integer count;
+    }
+}

+ 3 - 0
feifan-module-mall/feifan-module-product-api/src/main/java/cn/newfeifan/mall/module/product/enums/ErrorCodeConstants.java

@@ -52,5 +52,8 @@ public interface ErrorCodeConstants {
     ErrorCode FAVORITE_EXISTS = new ErrorCode(1_008_008_000, "该商品已经被收藏");
     ErrorCode FAVORITE_NOT_EXISTS = new ErrorCode(1_008_008_001, "商品收藏不存在");
     ErrorCode HIGH_PRECISION_PRICE_NOT_ENOUGH = new ErrorCode(1_008_008_002, "结算价不能大于成本价");
+    ErrorCode SKU_APPLY_NOT_EXISTS = new ErrorCode(1_008_008_003, "sku申请表不存在");
+    ErrorCode SPU_APPLY_NOT_EXISTS = new ErrorCode(1_008_008_004, "spu申请表不存在");
+    ErrorCode SPU_APPLY_LOG_NOT_EXISTS = new ErrorCode(1_008_008_005, "spu申请表日志不存在");
 
 }

+ 93 - 0
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spuapplylog/SpuApplyLogController.java

@@ -0,0 +1,93 @@
+package cn.newfeifan.mall.module.product.controller.admin.spuapplylog;
+
+import cn.newfeifan.mall.framework.common.pojo.CommonResult;
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
+import cn.newfeifan.mall.framework.excel.core.util.ExcelUtils;
+import cn.newfeifan.mall.framework.operatelog.core.annotations.OperateLog;
+import cn.newfeifan.mall.module.product.controller.admin.spuapplylog.vo.SpuApplyLogPageReqVO;
+import cn.newfeifan.mall.module.product.controller.admin.spuapplylog.vo.SpuApplyLogRespVO;
+import cn.newfeifan.mall.module.product.controller.admin.spuapplylog.vo.SpuApplyLogSaveReqVO;
+import cn.newfeifan.mall.module.product.dal.dataobject.spuapplylog.SpuApplyLogDO;
+import cn.newfeifan.mall.module.product.service.spuapplylog.SpuApplyLogService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+import java.io.IOException;
+import java.util.List;
+
+import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
+import static cn.newfeifan.mall.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
+
+@Tag(name = "管理后台 - 商品审核记录")
+@RestController
+@RequestMapping("/product/spu-apply-log")
+@Validated
+public class SpuApplyLogController {
+
+    @Resource
+    private SpuApplyLogService spuApplyLogService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建商品审核记录")
+    @PreAuthorize("@ss.hasPermission('product:spu-apply-log:create')")
+    public CommonResult<Long> createSpuApplyLog(@Valid @RequestBody SpuApplyLogSaveReqVO createReqVO) {
+        return success(spuApplyLogService.createSpuApplyLog(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新商品审核记录")
+    @PreAuthorize("@ss.hasPermission('product:spu-apply-log:update')")
+    public CommonResult<Boolean> updateSpuApplyLog(@Valid @RequestBody SpuApplyLogSaveReqVO updateReqVO) {
+        spuApplyLogService.updateSpuApplyLog(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除商品审核记录")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('product:spu-apply-log:delete')")
+    public CommonResult<Boolean> deleteSpuApplyLog(@RequestParam("id") Long id) {
+        spuApplyLogService.deleteSpuApplyLog(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得商品审核记录")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('product:spu-apply-log:query')")
+    public CommonResult<SpuApplyLogRespVO> getSpuApplyLog(@RequestParam("id") Long id) {
+        SpuApplyLogDO spuApplyLog = spuApplyLogService.getSpuApplyLog(id);
+        return success(BeanUtils.toBean(spuApplyLog, SpuApplyLogRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得商品审核记录分页")
+    @PreAuthorize("@ss.hasPermission('product:spu-apply-log:query')")
+    public CommonResult<PageResult<SpuApplyLogRespVO>> getSpuApplyLogPage(@Valid SpuApplyLogPageReqVO pageReqVO) {
+        PageResult<SpuApplyLogDO> pageResult = spuApplyLogService.getSpuApplyLogPage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, SpuApplyLogRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出商品审核记录 Excel")
+    @PreAuthorize("@ss.hasPermission('product:spu-apply-log:export')")
+    @OperateLog(type = EXPORT)
+    public void exportSpuApplyLogExcel(@Valid SpuApplyLogPageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<SpuApplyLogDO> list = spuApplyLogService.getSpuApplyLogPage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "商品审核记录.xls", "数据", SpuApplyLogRespVO.class,
+                        BeanUtils.toBean(list, SpuApplyLogRespVO.class));
+    }
+
+}

+ 39 - 0
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/convert/spuapply/SpuApplyConvert.java

@@ -0,0 +1,39 @@
+package cn.newfeifan.mall.module.product.convert.spuapply;
+
+import cn.newfeifan.mall.framework.common.util.collection.CollectionUtils;
+import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
+import cn.newfeifan.mall.module.product.controller.admin.spu.vo.ProductSkuRespVO;
+import cn.newfeifan.mall.module.product.controller.admin.spuapply.vo.SpuApplyRespVO;
+import cn.newfeifan.mall.module.product.dal.dataobject.skuapply.SkuApplyDO;
+import cn.newfeifan.mall.module.product.dal.dataobject.spuapply.SpuApplyDO;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+import java.util.List;
+import java.util.Map;
+
+import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.convertMultiMap;
+
+/**
+ * 商品 SPU 申请 Convert
+ *
+ * @author 非繁源码
+ */
+
+@Mapper
+public interface SpuApplyConvert {
+
+    SpuApplyConvert INSTANCE = Mappers.getMapper(SpuApplyConvert.class);
+
+    default SpuApplyRespVO convert(SpuApplyDO spu, List<SkuApplyDO> skus) {
+        SpuApplyRespVO spuVO = BeanUtils.toBean(spu, SpuApplyRespVO.class);
+        spuVO.setSkus(BeanUtils.toBean(skus, ProductSkuRespVO.class));
+        return spuVO;
+    }
+
+    default List<SpuApplyRespVO> convertForSpuDetailRespListVO(List<SpuApplyDO> spus, List<SkuApplyDO> skus) {
+        Map<Long, List<SkuApplyDO>> skuMultiMap = convertMultiMap(skus, SkuApplyDO::getSpuApplyId);
+        return CollectionUtils.convertList(spus, spu -> convert(spu, skuMultiMap.get(spu.getId())));
+    }
+
+}

+ 4 - 2
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/service/sku/ProductSkuService.java

@@ -4,6 +4,7 @@ import cn.newfeifan.mall.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO;
 import cn.newfeifan.mall.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO;
 import cn.newfeifan.mall.module.product.dal.dataobject.sku.ProductSkuDO;
 
+import javax.validation.constraints.NotNull;
 import java.util.Collection;
 import java.util.List;
 
@@ -40,9 +41,10 @@ public interface ProductSkuService {
     /**
      * 对 sku 的组合的属性等进行合法性校验
      *
-     * @param list sku组合的集合
+     * @param list          sku组合的集合
+     * @param highPrecision
      */
-    void validateSkuList(List<ProductSkuSaveReqVO> list, Boolean specType);
+    void validateSkuList(List<ProductSkuSaveReqVO> list, Boolean specType, @NotNull Boolean highPrecision);
 
     /**
      * 批量创建 SKU

+ 5 - 2
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/service/sku/ProductSkuServiceImpl.java

@@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -77,7 +78,7 @@ public class ProductSkuServiceImpl implements ProductSkuService {
     }
 
     @Override
-    public void validateSkuList(List<ProductSkuSaveReqVO> skus, Boolean specType) {
+    public void validateSkuList(List<ProductSkuSaveReqVO> skus, Boolean specType, Boolean highPrecision) {
         // 0、校验skus是否为空
         if (CollUtil.isEmpty(skus)) {
             throw exception(SKU_NOT_EXISTS);
@@ -86,11 +87,13 @@ public class ProductSkuServiceImpl implements ProductSkuService {
         // 校验结算价是否大于成本价
         for (ProductSkuSaveReqVO sku : skus) {
             // 如果是高精度商品
-            if(sku.getSettlementPrice().equals(0)){
+            if(highPrecision){
+                sku.setSettlementPrice(0);
                 if(sku.getHighPrecisionSettlementPrice().compareTo(sku.getHighPrecisionPrice()) > 0){
                     throw exception(HIGH_PRECISION_PRICE_NOT_ENOUGH);
                 }
             }else {
+                sku.setHighPrecisionSettlementPrice(BigDecimal.ZERO);
                 if(sku.getSettlementPrice() > sku.getCostPrice()){
                     throw exception(HIGH_PRECISION_PRICE_NOT_ENOUGH);
                 }

+ 2 - 2
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/service/spu/ProductSpuServiceImpl.java

@@ -66,7 +66,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
 
         // 校验 SKU
         List<ProductSkuSaveReqVO> skuSaveReqList = createReqVO.getSkus();
-        productSkuService.validateSkuList(skuSaveReqList, createReqVO.getSpecType());
+        productSkuService.validateSkuList(skuSaveReqList, createReqVO.getSpecType(), createReqVO.getHighPrecision());
 
         ProductSpuDO spu = BeanUtils.toBean(createReqVO, ProductSpuDO.class);
         // 初始化 SPU 中 SKU 相关属性
@@ -101,7 +101,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
 //        brandService.validateProductBrand(updateReqVO.getBrandId());
         // 校验SKU
         List<ProductSkuSaveReqVO> skuSaveReqList = updateReqVO.getSkus();
-        productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType());
+        productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType(),updateReqVO.getHighPrecision());
 
         // 更新 SPU
         ProductSpuDO updateObj = BeanUtils.toBean(updateReqVO, ProductSpuDO.class);

+ 12 - 1
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/TradeOrderController.java

@@ -5,6 +5,8 @@ import cn.hutool.core.collection.CollectionUtil;
 import cn.newfeifan.mall.framework.common.pojo.CommonResult;
 import cn.newfeifan.mall.framework.common.pojo.PageParam;
 import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.pojo.echarts.EChartsResult;
+import cn.newfeifan.mall.framework.common.util.date.DateUtils;
 import cn.newfeifan.mall.framework.excel.core.util.ExcelUtils;
 import cn.newfeifan.mall.framework.operatelog.core.annotations.OperateLog;
 import cn.newfeifan.mall.module.member.api.user.MemberUserApi;
@@ -26,7 +28,6 @@ import cn.newfeifan.mall.module.trade.dal.dataobject.order.TradeOrderLogDO;
 import cn.newfeifan.mall.module.trade.enums.order.TradeOrderRefundStatusEnum;
 import cn.newfeifan.mall.module.trade.enums.order.TradeOrderStateEnum;
 import cn.newfeifan.mall.module.trade.enums.order.TradeOrderStatusEnum;
-import cn.newfeifan.mall.module.trade.service.aftersale.AfterSaleService;
 import cn.newfeifan.mall.module.trade.service.order.TradeOrderLogService;
 import cn.newfeifan.mall.module.trade.service.order.TradeOrderQueryService;
 import cn.newfeifan.mall.module.trade.service.order.TradeOrderUpdateService;
@@ -41,6 +42,7 @@ import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -50,6 +52,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.IOException;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
@@ -353,5 +356,13 @@ public class TradeOrderController {
                 list);
     }
 
+    @GetMapping("/getOrderCountWithMoney")
+    @Operation(summary = "获得对应日期订单数量及金额")
+    @PreAuthorize("@ss.hasPermission('trade:order:query')")
+    public CommonResult<EChartsResult> getOrderCountWithMoney(@DateTimeFormat(pattern = DateUtils.FORMAT_YEAR_MONTH_DAY) LocalDate startTime, @DateTimeFormat(pattern = DateUtils.FORMAT_YEAR_MONTH_DAY) LocalDate endTime) {
+
+        return success(tradeOrderQueryService.getOrderCountWithMoney(startTime,endTime));
+    }
+
 
 }

+ 11 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/mysql/order/TradeOrderMapper.java

@@ -14,6 +14,7 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.List;
 import java.util.Map;
@@ -205,4 +206,14 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> {
                 .betweenIfPresent(TradeOrderDO::getCreateTime, reqVO.getCreateTime())
         );
     }
+
+    /**
+     * 获取订单统计
+     * @param startTime 开始时间
+     * @param endTime 结束时间
+     * @param merId 商户id
+     * @param shopId 店铺id
+     * @return 订单统计
+     */
+    List<Object> selectOrderCountWithTime(@Param("start") LocalDate startTime, @Param("end") LocalDate endTime, @Param("merId") Long merId, @Param("shopId") Long shopId);
 }

+ 14 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderCountWithMoney.java

@@ -0,0 +1,14 @@
+package cn.newfeifan.mall.module.trade.service.order;
+
+import lombok.Data;
+
+/**
+ * 订单状态数量统计
+ */
+
+@Data
+public class TradeOrderCountWithMoney {
+
+    private Integer count;
+    private Long money;
+}

+ 10 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderQueryService.java

@@ -1,6 +1,7 @@
 package cn.newfeifan.mall.module.trade.service.order;
 
 import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.pojo.echarts.EChartsResult;
 import cn.newfeifan.mall.module.pay.controller.admin.order.vo.PayOrderPageItemRespVO;
 import cn.newfeifan.mall.module.trade.controller.admin.order.vo.TradeOrderPageItemRespVO;
 import cn.newfeifan.mall.module.trade.controller.admin.order.vo.TradeOrderPageReqVO;
@@ -10,6 +11,7 @@ import cn.newfeifan.mall.module.trade.dal.dataobject.order.TradeOrderDO;
 import cn.newfeifan.mall.module.trade.dal.dataobject.order.TradeOrderItemDO;
 import cn.newfeifan.mall.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO;
 
+import java.time.LocalDate;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
@@ -224,4 +226,12 @@ public interface TradeOrderQueryService {
      * @return 数量
      */
     Long getOrderCountByRefundStatus(Integer refundStatus, TradeOrderPageReqVO reqVO);
+
+    /**
+     * 获取订单数量和金额
+     * @param startTime 开始时间
+     * @param endTime 结束时间
+     * @return EChartsResult
+     */
+    EChartsResult getOrderCountWithMoney(LocalDate startTime, LocalDate endTime);
 }

+ 42 - 1
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderQueryServiceImpl.java

@@ -6,11 +6,12 @@ import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.pojo.echarts.EChartsResult;
+import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
 import cn.newfeifan.mall.module.distri.dal.mysql.ordersettlement.OrderSettlementMapper;
 import cn.newfeifan.mall.module.member.api.user.MemberUserApi;
 import cn.newfeifan.mall.module.member.api.user.dto.MemberUserRespDTO;
 import cn.newfeifan.mall.module.pay.controller.admin.order.vo.PayOrderPageItemRespVO;
-import cn.newfeifan.mall.module.product.api.sku.ProductSkuApi;
 import cn.newfeifan.mall.module.product.dal.dataobject.spu.ProductSpuDO;
 import cn.newfeifan.mall.module.product.service.spu.ProductSpuService;
 import cn.newfeifan.mall.module.system.controller.admin.user.vo.user.UserShopDetailsVO;
@@ -40,7 +41,12 @@ import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.time.DayOfWeek;
+import java.time.LocalDate;
+import java.time.temporal.TemporalAdjusters;
 import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.convertSet;
@@ -82,6 +88,8 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
 
     @Resource
     private OrderSettlementMapper orderSettlementMapper;
+    @Resource
+    private AdminUserService adminUserService;
 
 
     // =================== Order ===================
@@ -279,6 +287,39 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
         return tradeOrderMapper.selectCountByRefundStatus(refundStatus, reqVO);
     }
 
+    @Override
+    public EChartsResult getOrderCountWithMoney(LocalDate startTime, LocalDate endTime) {
+
+        UserShopDetailsVO userShopDetails = adminUserService.getUserShopDetails();
+
+        LocalDate today = LocalDate.now(); // 获取今天的日期
+
+        if (startTime == null && endTime == null) {
+            startTime = today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)); // 获取本周的开始日期
+            endTime = today.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY)); // 获取本周的结束日期
+        }
+        List<LocalDate> weekDates = generateWeekDates(startTime, endTime); // 生成本周的日期数组
+        return EChartsResult.builder()
+                .xaxis(new EChartsResult.Axis()
+                        .setData(weekDates))
+                .series(BeanUtils.toBean(tradeOrderMapper.selectOrderCountWithTime(startTime, endTime, userShopDetails.getMerId(), userShopDetails.getShopId()), EChartsResult.Series.class))
+                .build()
+                ;
+    }
+
+    /**
+     * 生成指定日期范围内的日期数组
+     *
+     * @param start 开始日期
+     * @param end   结束日期
+     * @return 日期数组
+     */
+    private static List<LocalDate> generateWeekDates(LocalDate start, LocalDate end) {
+        return Stream.iterate(start, date -> date.plusDays(1))
+                .limit(end.toEpochDay() - start.toEpochDay() + 1)
+                .collect(Collectors.toList());
+    }
+
     @Override
     public List<ExpressTrackRespDTO> getExpressTrackList(Long id, Long userId) {
         // 查询订单

+ 24 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/resources/mapper/order/BrokerageUserMapper.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.newfeifan.mall.module.trade.dal.mysql.order.TradeOrderMapper">
+
+    <select id="selectOrderCountWithTime"
+            resultType="cn.newfeifan.mall.module.trade.service.order.TradeOrderCountWithMoney">
+        WITH RECURSIVE date_series AS (
+        SELECT #{start} AS date_val
+        UNION ALL
+        SELECT DATE_ADD(date_val, INTERVAL 1 DAY)
+        FROM date_series
+        WHERE date_val &lt; #{end}
+        )
+        SELECT
+            ds.date_val AS order_date,
+            COUNT(o.id) AS count,
+        IFNULL(SUM(o.pay_rmb) + (SUM(o.pay_integral) / 10000), 0) AS money
+        FROM date_series ds
+            LEFT JOIN trade_order o ON DATE(o.create_time) = ds.date_val and o.merchant_id = #{merId} and o.shop_id = #{shopId} and o.pay_status = 1
+        WHERE ds.date_val BETWEEN #{start} AND #{end}
+        GROUP BY ds.date_val
+        ORDER BY ds.date_val;
+    </select>
+</mapper>