文章目录
-
- 概要
- 整体架构流程
- 技术细节
- 小结
概要
订单状态统计是电子商务、供应链管理、客户服务等多个领域中的一项核心业务需求.
需求分析以及接口设计
技术细节
1.Controller层:
@ApiOperation("各个状态的订单统计")
@GetMapping("/statistics")
public Result<OrderStatisticsVO> statistics(){
log.info("各个状态的订单统计");
OrderStatisticsVO orderStatisticsVO = orderService.statistics();
return Result.success(orderStatisticsVO);
}
2.Service层:
@Override
public 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);