From a63a74a8ec25347f376496c3487f66e710092cc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=85=81=E6=9E=9E?= <3422692813@qq.com> Date: Tue, 15 Oct 2024 15:04:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B010.15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/AllOrderInfoServiceImpl.java | 72 +++++++++++++++---- 1 file changed, 57 insertions(+), 15 deletions(-) diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/AllOrderInfoServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/AllOrderInfoServiceImpl.java index d3312a1e0..0e48a7c43 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/AllOrderInfoServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/AllOrderInfoServiceImpl.java @@ -1873,8 +1873,14 @@ public class AllOrderInfoServiceImpl extends ServiceImpl oilNumbers = oilNumberMapper.selectAllOil(nowAccountInfo.getStoreId()); List oilNames = oilNumbers.stream().map(oil -> oil.getOilNames() + oil.getOilType()).collect(Collectors.toList()); homeDataShowVo.setOilNames(oilNames); - //根据开始时间与结束时间获取所有天数 + //判断开始时间减去结束时间是否大于等于一年 List days = getAllDatesBetween(startTime, endTime); + Integer type = 0; + if (DateUtil.between(DateUtil.parse(startTime), DateUtil.parse(endTime), DateUnit.DAY) >= 60) { + days = getAllDatesBetweenYear(startTime, endTime); + type = 1; + } + //根据开始时间与结束时间获取所有天数 //查询所有订单 DateTime dateTime2 = DateUtil.beginOfDay(DateUtil.parse(startTime)); DateTime dateTime3 = DateUtil.endOfDay(DateUtil.parse(endTime)); @@ -1885,13 +1891,20 @@ public class AllOrderInfoServiceImpl extends ServiceImpl> oilData = new ArrayList<>(); for (String day : days) { Map mapData = new HashMap<>(); - mapData.put("day", day); + DateTime dateTime = new DateTime(); + DateTime dateTime1 = new DateTime(); + if (type == 1) { + DateTime parse = DateUtil.parse(day); + mapData.put("day", parse.toString("yyyy-MM")); + dateTime = DateUtil.beginOfMonth(parse); + dateTime1 = DateUtil.endOfMonth(parse); + } else { + mapData.put("day", day); + dateTime = DateUtil.beginOfDay(DateUtil.parse(day)); + dateTime1 = DateUtil.endOfDay(dateTime); + } List oilPrices = new ArrayList<>(); - DateTime dateTime = DateUtil.beginOfDay(DateUtil.parse(day)); - DateTime dateTime1 = DateUtil.endOfDay(dateTime); for (OilNumber oilNumber : oilNumbers) { - //查询油品交易总金额 -// double price = oilOrderMapper.selectSumMoneyByDayAndOilNumber(oilNumber.getOilName(), day, nowAccountInfo.getStoreId()); double price = calculateTotalPayAmount(oilOrders, dateTime, dateTime1, oilNumber.getOilName()); oilPrices.add(price); } @@ -1924,14 +1937,29 @@ public class AllOrderInfoServiceImpl extends ServiceImpl getAllDatesBetweenYear(String startTime, String endTime) { + + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate startDate = LocalDate.parse(startTime, formatter); + LocalDate endDate = LocalDate.parse(endTime, formatter); + + List dateList = new ArrayList<>(); + while (!startDate.isAfter(endDate)) { + dateList.add(startDate.format(formatter)); + startDate = startDate.plusDays(30); + } + + return dateList; + } + /** * 计算指定支付时间范围和油品名称下的累计支付金额 * - * @param oilOrders OilOrder对象的集合 - * @param startTime 支付开始时间 - * @param endTime 支付结束时间 - * @param oilName 目标油品名称 - * @return 符合条件的累计支付金额 + * @param oilOrders OilOrder对象的集合 + * @param startTime 支付开始时间 + * @param endTime 支付结束时间 + * @param oilName 目标油品名称 + * @return 符合条件的累计支付金额 */ public static double calculateTotalPayAmount(List oilOrders, Date startTime, Date endTime, String oilName) { double totalPayAmount = 0.0; @@ -2053,6 +2081,11 @@ public class AllOrderInfoServiceImpl extends ServiceImpl allDatesBetween = getAllDatesBetween(startTime, endTime); + Integer type = 0; + if (DateUtil.between(DateUtil.parse(startTime), DateUtil.parse(endTime), DateUnit.DAY) >= 60) { + allDatesBetween = getAllDatesBetweenYear(startTime, endTime); + type = 1; + } List oilNames = new ArrayList<>(); List> oilData = new ArrayList<>(); @@ -2064,11 +2097,20 @@ public class AllOrderInfoServiceImpl extends ServiceImpl params = new HashMap<>(); - params.put("time", time); + DateTime dateTime = new DateTime(); + DateTime dateTime1 = new DateTime(); + if (type == 1) { + DateTime parse = DateUtil.parse(time); + params.put("time", parse.toString("yyyy-MM")); + dateTime = DateUtil.beginOfMonth(parse); + dateTime1 = DateUtil.endOfMonth(parse); + } else { + params.put("time", time); + dateTime = DateUtil.beginOfDay(DateUtil.parse(time)); + dateTime1 = DateUtil.endOfDay(dateTime); + } + Double memberBalance = allOrderInfoMapper.getCountMemberBalance(nowAccountInfo.getStoreId(), dateTime1.toString()); List money = new ArrayList<>(); //油品交易额 List oilOrder = filterOrders(allOrderInfos, dateTime, dateTime1, "1", null, null);