网站建设自查自评,crm客户管理系统,wordpress 360加速插件,博客wordpress模板Apache Echarts 营业额统计 重点:已完成订单金额要排除其他状态的金额 根据时间选择区间 设计vo用于后端向前端传输数据,dto用于后端接收前端发送的数据 GetMapping(/turnoverStatistics)ApiOperation(营业额统计)public ResultTurnoverReportVO…Apache Echarts 营业额统计 重点:已完成订单金额要排除其他状态的金额 根据时间选择区间 设计vo用于后端向前端传输数据,dto用于后端接收前端发送的数据 GetMapping(/turnoverStatistics)ApiOperation(营业额统计)public ResultTurnoverReportVO turnoverStatistics(DateTimeFormat(pattern yyyy-MM-dd) LocalDate begin,DateTimeFormat(pattern yyyy-MM-dd) LocalDate end){log.info(营业额数据统计{},{},begin,end);return Result.success(reportService.getTurnoverStatistics(begin,end));} public TurnoverReportVO getTurnoverStatistics(LocalDate begin, LocalDate end) {//当前集合用于存放从begin到end范围内的每天的日期ListLocalDate dateList new ArrayList();dateList.add(begin);while (!begin.equals(end)) {//日期计算计算指定日期的后一天对应的日期//把每天的东西一个一个放进去begin begin.plusDays(1);dateList.add(begin);}//存放每天的营业额ListDouble turnoverList new ArrayList();for (LocalDate date : dateList) {//查询date日期对应的营业额数据营业额是指状态为“已完成”的订单金额合计LocalDateTime beginTime LocalDateTime.of(date, LocalTime.MIN);LocalDateTime endTime LocalDateTime.of(date, LocalTime.MAX);// select sum(amount) from orders where order_time beginTime and order_time endTime and status 5Map map new HashMap();map.put(begin, beginTime);map.put(end, endTime);map.put(status, Orders.COMPLETED);Double turnover orderMapper.sumByMap(map);turnover turnover null ? 0.0 : turnover;turnoverList.add(turnover);}//封装返回结果return TurnoverReportVO.builder().dateList(StringUtils.join(dateList, ,))//使用字符串拼接工具//将几个不同的时间字符串用逗号分隔开,组合成一个字符串.turnoverList(StringUtils.join(turnoverList, ,)).build();}