文章目录
-
- 概要
- 整体架构流程
- 技术细节
- 小结
概要
订单状态统计是电子商务、供应链管理、客户服务等多个领域中的一项核心业务需求.
需求分析以及接口设计
技术细节
1.Controller层:
@ApiOperation("各个状态的订单统计")@GetMapping("/statistics")public Result<OrderStatisticsVO> statistics(){log.info("各个状态的订单统计");OrderStatisticsVO orderStatisticsVO = orderService.statistics();return Result.success(orderStatisticsVO);}
2.Service层:
@Overridepublic OrderStatisticsVO statistics() {//根据订单的状态查询出订单的数量//待接单Integer toBeConfirmed = orderMapper.countStatus(Orders.TO_BE_CONFIRMED);//已接单Integer confirmed = orderMapper.countStatus(Orders.CONFIRMED);//派送中Integer deliveryInProgress = orderMapper.countStatus(Orders.DELIVERY_IN_PROGRESS);//封装到VO中OrderStatisticsVO orderStatisticsVO = new OrderStatisticsVO();orderStatisticsVO.setToBeConfirmed(toBeConfirmed);orderStatisticsVO.setConfirmed(confirmed);orderStatisticsVO.setDeliveryInProgress(deliveryInProgress);return orderStatisticsVO;}
3.Mapper层:
@Select("select count(id) from `sky-take-out`.orders where status = #{status}")Integer countStatus(Integer status);