diff --git a/ruoyi-mall/src/main/java/com/cyl/h5/service/H5OrderService.java b/ruoyi-mall/src/main/java/com/cyl/h5/service/H5OrderService.java index 4de4a4b..618c799 100644 --- a/ruoyi-mall/src/main/java/com/cyl/h5/service/H5OrderService.java +++ b/ruoyi-mall/src/main/java/com/cyl/h5/service/H5OrderService.java @@ -426,7 +426,7 @@ public class H5OrderService { OrderOperateHistory history = new OrderOperateHistory(); history.setOrderId(item.getId()); history.setOrderSn(item.getOrderSn()); - history.setOperateMan("" + item.getMemberId()); + history.setOperateMan(userId == null ? "后台管理员" : "" + item.getMemberId()); history.setOrderStatus(Constants.H5OrderStatus.CLOSED); history.setCreateTime(optDate); history.setCreateBy(userId); diff --git a/ruoyi-mall/src/main/java/com/cyl/manager/oms/mapper/AftersaleMapper.java b/ruoyi-mall/src/main/java/com/cyl/manager/oms/mapper/AftersaleMapper.java index 8fd272a..540f99b 100644 --- a/ruoyi-mall/src/main/java/com/cyl/manager/oms/mapper/AftersaleMapper.java +++ b/ruoyi-mall/src/main/java/com/cyl/manager/oms/mapper/AftersaleMapper.java @@ -6,6 +6,7 @@ import com.cyl.manager.oms.domain.Aftersale; import com.cyl.manager.oms.domain.AftersaleItem; import com.cyl.manager.oms.pojo.request.ManagerAftersaleOrderRequest; import com.cyl.manager.oms.pojo.vo.ManagerRefundOrderVO; +import com.cyl.manager.statistics.pojo.vo.OrderAndAftersaleStatisticsVO; import org.apache.ibatis.annotations.Param; /** @@ -26,4 +27,5 @@ public interface AftersaleMapper extends BaseMapper { int countByMemberId(Long memberId); + OrderAndAftersaleStatisticsVO statPendingAndProcessing(); } diff --git a/ruoyi-mall/src/main/java/com/cyl/manager/oms/mapper/OrderMapper.java b/ruoyi-mall/src/main/java/com/cyl/manager/oms/mapper/OrderMapper.java index d8cbd6e..b438545 100644 --- a/ruoyi-mall/src/main/java/com/cyl/manager/oms/mapper/OrderMapper.java +++ b/ruoyi-mall/src/main/java/com/cyl/manager/oms/mapper/OrderMapper.java @@ -1,5 +1,6 @@ package com.cyl.manager.oms.mapper; +import java.time.LocalDateTime; import java.util.List; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.cyl.h5.pojo.vo.CountOrderVO; @@ -7,6 +8,7 @@ import com.cyl.h5.pojo.vo.H5OrderVO; import com.cyl.manager.oms.domain.Order; import com.cyl.manager.oms.pojo.request.ManagerOrderQueryRequest; import com.cyl.manager.oms.pojo.vo.ManagerOrderVO; +import com.cyl.manager.statistics.pojo.vo.OrderAndAftersaleStatisticsVO; import com.cyl.manager.ums.pojo.vo.MemberDataStatisticsVO; import org.apache.ibatis.annotations.Param; @@ -37,4 +39,7 @@ public interface OrderMapper extends BaseMapper { MemberDataStatisticsVO statOrderCountAndAmount(Long memberId); + Integer statWaitDelivered(); + + OrderAndAftersaleStatisticsVO statTodayData(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime); } diff --git a/ruoyi-mall/src/main/java/com/cyl/manager/statistics/controller/IndexStatisticsManagerController.java b/ruoyi-mall/src/main/java/com/cyl/manager/statistics/controller/IndexStatisticsManagerController.java new file mode 100644 index 0000000..2b5a7b0 --- /dev/null +++ b/ruoyi-mall/src/main/java/com/cyl/manager/statistics/controller/IndexStatisticsManagerController.java @@ -0,0 +1,67 @@ +package com.cyl.manager.statistics.controller; + + +import com.cyl.manager.statistics.pojo.GoodsStatisticsQueryParam; +import com.cyl.manager.statistics.pojo.vo.MemberAndCartStatisticsVO; +import com.cyl.manager.statistics.pojo.vo.OrderAndAftersaleStatisticsVO; +import com.cyl.manager.statistics.pojo.vo.OrderStatisticsVO; +import com.cyl.manager.statistics.pojo.vo.ProductTopVO; +import com.cyl.manager.statistics.service.IndexStatisticsService; +import com.ruoyi.common.core.domain.AjaxResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * 管理端,首页统计数据接口 + * + * @author zhangcheng + * @since 2023/05/15 13:53 + */ +@Slf4j +@Api(tags = "管理端,首页统计数据接口") +@RestController +@RequestMapping("/dev/statistics/index") +public class IndexStatisticsManagerController { + + /** + * 首页统计 + */ + @Autowired + private IndexStatisticsService indexStatisticsService; + + @ApiOperation(value = "获取首页查询热卖商品TOP10") + @GetMapping("/goodsStatistics") + public ResponseEntity> goodsStatistics(@Validated GoodsStatisticsQueryParam goodsStatisticsQueryParam) { + + return ResponseEntity.ok(indexStatisticsService.goodsStatistics(goodsStatisticsQueryParam)); + } + + @ApiOperation(value = "订单信息") + @GetMapping("/orderStatistics") + public ResponseEntity> orderStatistics() { + + return ResponseEntity.ok(indexStatisticsService.orderStatistics()); + } + + @ApiOperation(value = "会员数,加购数") + @GetMapping("/memberAndCart/statistics") + public ResponseEntity statMemberAndCart(){ + return ResponseEntity.ok(indexStatisticsService.statMemberAndCart()); + } + + @ApiOperation(value = "订单与售后单统计") + @GetMapping("/order/aftersale/statistics") + public ResponseEntity orderAndAftersaleStatistics(){ + return ResponseEntity.ok(indexStatisticsService.orderAndAftersaleStatistics()); + } + +} diff --git a/ruoyi-mall/src/main/java/com/cyl/manager/statistics/mapper/IndexStatisticsMapper.java b/ruoyi-mall/src/main/java/com/cyl/manager/statistics/mapper/IndexStatisticsMapper.java new file mode 100644 index 0000000..5fac288 --- /dev/null +++ b/ruoyi-mall/src/main/java/com/cyl/manager/statistics/mapper/IndexStatisticsMapper.java @@ -0,0 +1,16 @@ +package com.cyl.manager.statistics.mapper; + + +import com.cyl.manager.statistics.pojo.GoodsStatisticsQueryParam; +import com.cyl.manager.statistics.pojo.vo.OrderStatisticsVO; +import com.cyl.manager.statistics.pojo.vo.ProductTopVO; + +import java.util.List; + +public interface IndexStatisticsMapper { + List goodsSkuStatistics(GoodsStatisticsQueryParam goodsStatisticsQueryParam); + + List goodsStatistics(GoodsStatisticsQueryParam goodsStatisticsQueryParam); + List orderStatistics(); + +} diff --git a/ruoyi-mall/src/main/java/com/cyl/manager/statistics/pojo/GoodsStatisticsQueryParam.java b/ruoyi-mall/src/main/java/com/cyl/manager/statistics/pojo/GoodsStatisticsQueryParam.java new file mode 100644 index 0000000..dfe861c --- /dev/null +++ b/ruoyi-mall/src/main/java/com/cyl/manager/statistics/pojo/GoodsStatisticsQueryParam.java @@ -0,0 +1,24 @@ +package com.cyl.manager.statistics.pojo; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * 商品统计 + * + * @author zhangcheng + * @since 2023/05/15 13:53 + */ +@Data +public class GoodsStatisticsQueryParam { + @NotNull(message = "统计类型 1:商品规格排行 2:商品排行") + private Integer statType; + @NotNull(message = "参数size不能为空") + private Integer size; + @NotBlank(message = "参数startDate不能为空") + private String startDate; + @NotBlank(message = "参数endDate不能为空") + private String endDate; +} diff --git a/ruoyi-mall/src/main/java/com/cyl/manager/statistics/pojo/vo/MemberAndCartStatisticsVO.java b/ruoyi-mall/src/main/java/com/cyl/manager/statistics/pojo/vo/MemberAndCartStatisticsVO.java new file mode 100644 index 0000000..d89dee7 --- /dev/null +++ b/ruoyi-mall/src/main/java/com/cyl/manager/statistics/pojo/vo/MemberAndCartStatisticsVO.java @@ -0,0 +1,10 @@ +package com.cyl.manager.statistics.pojo.vo; + +import lombok.Data; + +@Data +public class MemberAndCartStatisticsVO { + private Integer memberCount; + private Integer cartCount; + +} diff --git a/ruoyi-mall/src/main/java/com/cyl/manager/statistics/pojo/vo/OrderAndAftersaleStatisticsVO.java b/ruoyi-mall/src/main/java/com/cyl/manager/statistics/pojo/vo/OrderAndAftersaleStatisticsVO.java new file mode 100644 index 0000000..aee51c8 --- /dev/null +++ b/ruoyi-mall/src/main/java/com/cyl/manager/statistics/pojo/vo/OrderAndAftersaleStatisticsVO.java @@ -0,0 +1,21 @@ +package com.cyl.manager.statistics.pojo.vo; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class OrderAndAftersaleStatisticsVO { + /** 待处理售后 */ + private Integer pendingAftersaleCount; + /** 处理中售后 */ + private Integer processingAftersaleCount; + /** 待发货 */ + private Integer waitDeliveredCount; + /** 已发货 */ + private Integer todayHasDeliveredCount; + /** 订单数 */ + private Integer todayOrderCount; + /** 成交额 */ + private BigDecimal todayTransactionAmount; +} diff --git a/ruoyi-mall/src/main/java/com/cyl/manager/statistics/pojo/vo/OrderStatisticsVO.java b/ruoyi-mall/src/main/java/com/cyl/manager/statistics/pojo/vo/OrderStatisticsVO.java new file mode 100644 index 0000000..e46b88d --- /dev/null +++ b/ruoyi-mall/src/main/java/com/cyl/manager/statistics/pojo/vo/OrderStatisticsVO.java @@ -0,0 +1,16 @@ +package com.cyl.manager.statistics.pojo.vo; + +import lombok.Data; + +@Data +public class OrderStatisticsVO { + + private String date; + //订单笔数 + private Double orderCount; + //订单金额 + private Double orderAmount; + private Double numPaidOrders; + private Double numPendingOrders; + private Double numRefundOrders; +} diff --git a/ruoyi-mall/src/main/java/com/cyl/manager/statistics/pojo/vo/ProductTopVO.java b/ruoyi-mall/src/main/java/com/cyl/manager/statistics/pojo/vo/ProductTopVO.java new file mode 100644 index 0000000..3b9acde --- /dev/null +++ b/ruoyi-mall/src/main/java/com/cyl/manager/statistics/pojo/vo/ProductTopVO.java @@ -0,0 +1,12 @@ +package com.cyl.manager.statistics.pojo.vo; + +import lombok.Data; + +@Data +public class ProductTopVO { + + private String productName; + private int totalSales; + private String pic; + private String spData; +} diff --git a/ruoyi-mall/src/main/java/com/cyl/manager/statistics/service/IndexStatisticsService.java b/ruoyi-mall/src/main/java/com/cyl/manager/statistics/service/IndexStatisticsService.java new file mode 100644 index 0000000..971a4d1 --- /dev/null +++ b/ruoyi-mall/src/main/java/com/cyl/manager/statistics/service/IndexStatisticsService.java @@ -0,0 +1,79 @@ +package com.cyl.manager.statistics.service; + +import com.cyl.manager.oms.mapper.AftersaleMapper; +import com.cyl.manager.oms.mapper.OrderMapper; +import com.cyl.manager.oms.service.AftersaleService; +import com.cyl.manager.oms.service.OrderDeliveryHistoryService; +import com.cyl.manager.oms.service.OrderService; +import com.cyl.manager.statistics.mapper.IndexStatisticsMapper; +import com.cyl.manager.statistics.pojo.GoodsStatisticsQueryParam; +import com.cyl.manager.statistics.pojo.vo.MemberAndCartStatisticsVO; +import com.cyl.manager.statistics.pojo.vo.OrderAndAftersaleStatisticsVO; +import com.cyl.manager.statistics.pojo.vo.OrderStatisticsVO; +import com.cyl.manager.statistics.pojo.vo.ProductTopVO; +import com.cyl.manager.ums.mapper.MemberCartMapper; +import com.cyl.manager.ums.mapper.MemberMapper; +import com.cyl.manager.ums.service.MemberService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.List; +import java.util.Objects; + +/** + * 管理端,首页统计数据Service业务层处理 + * + * @author zhangcheng + * @since 2023/05/15 13:53 + */ +@Service +public class IndexStatisticsService { + @Autowired + private IndexStatisticsMapper indexStatisticsMapper; + @Autowired + private MemberMapper memberMapper; + @Autowired + private MemberCartMapper memberCartMapper; + @Autowired + private AftersaleMapper aftersaleMapper; + @Autowired + private OrderMapper orderMapper; + + + public List goodsStatistics(GoodsStatisticsQueryParam goodsStatisticsQueryParam) { + if (goodsStatisticsQueryParam.getStatType() == 1){ + return indexStatisticsMapper.goodsSkuStatistics(goodsStatisticsQueryParam); + }else { + return indexStatisticsMapper.goodsStatistics(goodsStatisticsQueryParam); + } + } + + public List orderStatistics() { + return indexStatisticsMapper.orderStatistics(); + } + + public MemberAndCartStatisticsVO statMemberAndCart() { + MemberAndCartStatisticsVO vo = new MemberAndCartStatisticsVO(); + vo.setMemberCount(memberMapper.selectCount(null)); + vo.setCartCount(memberCartMapper.selectCount(null)); + return vo; + } + + public OrderAndAftersaleStatisticsVO orderAndAftersaleStatistics() { + //统计售后 + OrderAndAftersaleStatisticsVO vo = aftersaleMapper.statPendingAndProcessing(); + //统计未发货数 + vo.setWaitDeliveredCount(orderMapper.statWaitDelivered()); + //统计今日订单数,成交金额,发货数 + LocalDateTime startTime = LocalDateTime.of(LocalDate.now(), LocalTime.MIN); + LocalDateTime endTime = LocalDateTime.of(LocalDate.now(), LocalTime.MAX); + OrderAndAftersaleStatisticsVO todayData = orderMapper.statTodayData(startTime, endTime); + vo.setTodayOrderCount(todayData.getTodayOrderCount()); + vo.setTodayHasDeliveredCount(todayData.getTodayHasDeliveredCount()); + vo.setTodayTransactionAmount(todayData.getTodayTransactionAmount()); + return vo; + } +} diff --git a/ruoyi-mall/src/main/resources/mapper/oms/AftersaleMapper.xml b/ruoyi-mall/src/main/resources/mapper/oms/AftersaleMapper.xml index 5fac3e9..af17ef9 100644 --- a/ruoyi-mall/src/main/resources/mapper/oms/AftersaleMapper.xml +++ b/ruoyi-mall/src/main/resources/mapper/oms/AftersaleMapper.xml @@ -95,5 +95,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from oms_aftersale where member_id=#{memberId} + diff --git a/ruoyi-mall/src/main/resources/mapper/oms/OrderMapper.xml b/ruoyi-mall/src/main/resources/mapper/oms/OrderMapper.xml index bf2392b..e22e600 100644 --- a/ruoyi-mall/src/main/resources/mapper/oms/OrderMapper.xml +++ b/ruoyi-mall/src/main/resources/mapper/oms/OrderMapper.xml @@ -232,5 +232,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from oms_order where status in (1,2,3) and aftersale_status=1 and member_id=#{memberId} + + diff --git a/ruoyi-mall/src/main/resources/mapper/statistics/IndexStatisticsMapper.xml b/ruoyi-mall/src/main/resources/mapper/statistics/IndexStatisticsMapper.xml new file mode 100644 index 0000000..3ed35a4 --- /dev/null +++ b/ruoyi-mall/src/main/resources/mapper/statistics/IndexStatisticsMapper.xml @@ -0,0 +1,87 @@ + + + + + SELECT + curdate( ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 1 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 2 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 3 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 4 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 5 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 6 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 7 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 8 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 9 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 10 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 11 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 12 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 13 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 14 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 15 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 16 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 17 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 18 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 19 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 20 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 21 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 22 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 23 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 24 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 25 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 26 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 27 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 28 DAY ) AS date UNION ALL + SELECT date_sub( curdate( ), INTERVAL 29 DAY ) AS date + + + + + + + + + + +