From 9b646c003c5dcc9c878c8c023af57e19eaef027a Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期二, 18 三月 2025 16:52:14 +0800 Subject: [PATCH] 修改报表bug --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java | 123 ++++++++++++++++++++++++++++------------- 1 files changed, 84 insertions(+), 39 deletions(-) diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java index ecb18b9..cc5f443 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java @@ -648,21 +648,19 @@ long times = rechargeAmount1.divide(s_total_amount, 0, RoundingMode.DOWN).longValue(); if(times > m){ //充电时间跨度两个计费策略,需要继续对下一个策略进行计算 - serviceCharge = s_server_amount.multiply(new BigDecimal(m)); + serviceCharge = serviceCharge.add(s_server_amount.multiply(new BigDecimal(m))); rechargeAmount1 = rechargeAmount1.subtract(s_total_amount.multiply(new BigDecimal(m))); - if(null != discount){ - discountAmount = discountAmount.add(serviceCharge.multiply(new BigDecimal(1).subtract(discount))); - } nowTimeMillis = null; }else{ - serviceCharge = s_server_amount.multiply(new BigDecimal(times)); - if(null != discount){ - discountAmount = discountAmount.add(serviceCharge.multiply(new BigDecimal(1).subtract(discount))); - } + serviceCharge = serviceCharge.add(s_server_amount.multiply(new BigDecimal(times))); break; } } } + if(null != discount){ + discountAmount = serviceCharge.multiply(new BigDecimal(1).subtract(discount)); + } + if(discountAmount.compareTo(BigDecimal.ZERO) >= 0){ //计算会员最大优惠金额 TVip vip = vipClient.getInfo1(appUser.getVipId()).getData(); @@ -673,9 +671,12 @@ } } discountAmount = discountAmount.setScale(4, RoundingMode.HALF_EVEN); + if(discountAmount.compareTo(BigDecimal.ZERO) >= 0){ + data.setChargeNum(data.getChargeNum() - 1); + appUserVipDetailClient.updateAppUserVipDetail(data); + } } } - //机子上显示的金额为用户充值的金额+会员折扣金额 BigDecimal account_balance = chargingOrder.getRechargeAmount().add(discountAmount).setScale(4, RoundingMode.HALF_EVEN); @@ -924,6 +925,18 @@ BigDecimal refund_fee = new BigDecimal(null == refund_fee1 ? "0" : refund_fee1.toString()).divide(new BigDecimal(100)); chargingOrderRefund.setRefundFee(refund_fee); chargingOrderRefundService.updateById(chargingOrderRefund); + //回退会员折扣次数 + if(chargingOrder.getVipDiscountAmount().compareTo(BigDecimal.ZERO) > 0){ + TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData(); + GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); + getAppUserVipDetail.setAppUserId(chargingOrder.getAppUserId()); + getAppUserVipDetail.setVipId(appUser.getVipId()); + TAppUserVipDetail data = appUserVipDetailClient.getAppUserVipDetail(getAppUserVipDetail).getData(); + if(null != data){ + data.setChargeNum(data.getChargeNum() + 1); + appUserVipDetailClient.updateAppUserVipDetail(data); + } + } } } if(2 == rechargePaymentType){ @@ -935,6 +948,19 @@ RefundResp resp = aliPaymentClient.refund(dto).getData(); if(null != resp){ chargingOrderRefundService.save(chargingOrderRefund); + //回退会员折扣次数 + if(chargingOrder.getVipDiscountAmount().compareTo(BigDecimal.ZERO) > 0){ + TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData(); + GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); + getAppUserVipDetail.setAppUserId(chargingOrder.getAppUserId()); + getAppUserVipDetail.setVipId(appUser.getVipId()); + TAppUserVipDetail data = appUserVipDetailClient.getAppUserVipDetail(getAppUserVipDetail).getData(); + if(null != data){ + data.setChargeNum(data.getChargeNum() + 1); + appUserVipDetailClient.updateAppUserVipDetail(data); + } + } + try { Thread.sleep(1000); } catch (InterruptedException e) { @@ -1244,7 +1270,6 @@ List<TChargingPile> allPile = chargingGunClient.getAllPile().getData(); List<Site> data9 = siteClient.getSiteAll().getData(); List<TAppUser> data6 = appUserClient.getAllUser().getData(); - List<Partner> data7 = siteClient.getAllPartner().getData(); List<TAppUserCar> data4 = appUserCarClient.getAllCar().getData(); String startTime1 = null; String startTime2 = null; @@ -1311,13 +1336,11 @@ List<ChargingOrderVO> list1 = this.baseMapper.chargingOrder(pageInfo1,dto,startTime1,startTime2,endTime1,endTime2); BigDecimal total = new BigDecimal("0"); long time = 0L; - BigDecimal income = new BigDecimal("0"); BigDecimal electronicMoney = new BigDecimal("0"); BigDecimal serviceMoney = new BigDecimal("0"); BigDecimal commissionMoney = new BigDecimal("0"); BigDecimal refundMoney = new BigDecimal("0"); BigDecimal paymentMoney = new BigDecimal("0"); - List<Long> collect = list.stream().map(TChargingOrder::getId).collect(Collectors.toList()); List<TChargingOrderAccountingStrategy> list3 = chargingOrderAccountingStrategyService.list(); for (ChargingOrderVO chargingOrderVO : list) { @@ -1328,7 +1351,6 @@ chargingOrderVO.setAuthRecord(t1.get(0)); } } - chargingOrderVO.setSharingAmount(chargingOrderVO.getServiceCharge()!=null?chargingOrderVO.getServiceCharge().multiply(new BigDecimal("0.2")).setScale(2,BigDecimal.ROUND_DOWN):new BigDecimal("0")); chargingOrderVO.setCommissionAmount(chargingOrderVO.getRechargeAmount()!=null?chargingOrderVO.getRechargeAmount().multiply(new BigDecimal("0.006")):new BigDecimal("0")); chargingOrderVO.setPlatFormMoney(chargingOrderVO.getRechargeAmount()!=null?chargingOrderVO.getRechargeAmount().multiply(new BigDecimal("0.006")).setScale(2,BigDecimal.ROUND_DOWN):new BigDecimal("0")); chargingOrderVO.setUid(chargingOrderVO.getId()+""); @@ -1351,7 +1373,17 @@ // 计算时间差 单位秒 long between = ChronoUnit.SECONDS.between(startTime, endTime); chargingOrderVO.setChargingSecond(between); - + + BigDecimal electronic_reduce = chargingOrderId.stream().map(TChargingOrderAccountingStrategy::getPeriodElectricPrice).reduce(BigDecimal.ZERO, BigDecimal::add); + chargingOrderVO.setElectrovalence(electronic_reduce); + BigDecimal service_reduce = chargingOrderId.stream().map(TChargingOrderAccountingStrategy::getPeriodServicePrice).reduce(BigDecimal.ZERO, BigDecimal::add); + if (!chargingOrderVO.getOrderSource().equals(2)){ + chargingOrderVO.setServiceCharge(service_reduce); + chargingOrderVO.setSharingAmount(BigDecimal.ZERO); + }else{ + chargingOrderVO.setServiceCharge(service_reduce.multiply(new BigDecimal("0.8"))); + chargingOrderVO.setSharingAmount(service_reduce.multiply(new BigDecimal("0.2"))); + } } // 充电时段数 int size = chargingOrderId.size(); @@ -1376,17 +1408,16 @@ } - List<Long> orderIds = list1.stream().map(TChargingOrder::getId).collect(Collectors.toList()); - if(orderIds.isEmpty())orderIds.add(-1L); List<TChargingOrderRefund> chargingOrderRefunds = chargingOrderRefundService.lambdaQuery() .eq(TChargingOrderRefund::getRefundStatus,2).list(); for (ChargingOrderVO chargingOrderVO : list1) { + List<TChargingOrderAccountingStrategy> list4 = list3.stream().filter(e -> e.getChargingOrderId().equals(chargingOrderVO.getId())).collect(Collectors.toList()); + BigDecimal service_reduce = list4.stream().map(TChargingOrderAccountingStrategy::getPeriodServicePrice).reduce(BigDecimal.ZERO, BigDecimal::add); if (!chargingOrderVO.getOrderSource().equals(2)) { paymentMoney = paymentMoney.add(chargingOrderVO.getPaymentAmount() != null ? chargingOrderVO.getPaymentAmount() : new BigDecimal("0")); }else{ - paymentMoney = paymentMoney.add(chargingOrderVO.getServiceCharge() != null ? chargingOrderVO.getServiceCharge().multiply(new BigDecimal("0.2")).setScale(2, BigDecimal.ROUND_DOWN) : new BigDecimal("0")); - + paymentMoney = paymentMoney.add(service_reduce.multiply(new BigDecimal("0.8")).setScale(2, BigDecimal.ROUND_DOWN)); } if (chargingOrderVO.getRechargeAmount()!=null){ commissionMoney = commissionMoney.add(chargingOrderVO.getRechargeAmount().multiply(new BigDecimal("0.006")).setScale(2,BigDecimal.ROUND_DOWN)); @@ -1406,16 +1437,18 @@ for (TChargingOrderRefund tChargingOrderRefund : list2) { refundMoney = refundMoney.add(tChargingOrderRefund.getRefundTotalAmount()); } - electronicMoney = electronicMoney.add(chargingOrderVO.getElectrovalence()!=null?chargingOrderVO.getElectrovalence():new BigDecimal("0")); + + //充电明细 + BigDecimal electronic_reduce = list4.stream().map(TChargingOrderAccountingStrategy::getPeriodElectricPrice).reduce(BigDecimal.ZERO, BigDecimal::add); + electronicMoney = electronicMoney.add(electronic_reduce); if (!chargingOrderVO.getOrderSource().equals(2)){ - serviceMoney = serviceMoney.add(chargingOrderVO.getServiceCharge()!=null?chargingOrderVO.getServiceCharge():new BigDecimal("0")); + serviceMoney = serviceMoney.add(service_reduce); }else{ - serviceMoney = serviceMoney.add(chargingOrderVO.getServiceCharge()!=null?chargingOrderVO.getServiceCharge().multiply(new BigDecimal("0.2")).setScale(2,BigDecimal.ROUND_DOWN):new BigDecimal("0")); + serviceMoney = serviceMoney.add(service_reduce.multiply(new BigDecimal("0.8"))); } } tCharingOrderVO.setTotal(total); tCharingOrderVO.setTime(time); -// tCharingOrderVO.setIncome(paymentMoney.subtract(commissionMoney)); tCharingOrderVO.setIncome(paymentMoney); tCharingOrderVO.setElectronicMoney(electronicMoney); tCharingOrderVO.setServiceMoney(serviceMoney); @@ -1473,28 +1506,38 @@ } @Override - public List<Map<String, Object>> getSumByType(List<Long> chargingOrderIds) { - return this.baseMapper.getSumByType(chargingOrderIds); + public List<Map<String, Object>> getSumByType(LocalDate start,LocalDate end,List<Integer> siteIds) { + LocalDateTime start1 = start.atStartOfDay(); + LocalDateTime end1 = end.atTime(LocalTime.MAX); + return this.baseMapper.getSumByType(start1,end1, siteIds); } @Override - public List<Map<String, Object>> getDateData(List<Long> chargingOrderIds) { - return this.baseMapper.getDateData(chargingOrderIds); + public List<Map<String, Object>> getDateData(LocalDate start,LocalDate end,List<Integer> siteIds) { + LocalDateTime start1 = start.atStartOfDay(); + LocalDateTime end1 = end.atTime(LocalTime.MAX); + return this.baseMapper.getDateData(start1,end1, siteIds); } @Override - public List<Map<String, Object>> getWeekData(List<Long> chargingOrderIds) { - return this.baseMapper.getWeekData(chargingOrderIds); + public List<Map<String, Object>> getWeekData(LocalDate start,LocalDate end) { + LocalDateTime start1 = start.atStartOfDay(); + LocalDateTime end1 = end.atTime(LocalTime.MAX); + return this.baseMapper.getWeekData(start1,end1); } @Override - public List<Map<String, Object>> getMonthData(List<Long> chargingOrderIds) { - return this.baseMapper.getMonthData(chargingOrderIds); + public List<Map<String, Object>> getMonthData(LocalDate start,LocalDate end) { + LocalDateTime start1 = start.atStartOfDay(); + LocalDateTime end1 = end.atTime(LocalTime.MAX); + return this.baseMapper.getMonthData(start1,end1); } @Override - public List<Map<String, Object>> getYearData(List<Long> chargingOrderIds) { - return this.baseMapper.getYearData(chargingOrderIds); + public List<Map<String, Object>> getYearData(LocalDate start,LocalDate end) { + LocalDateTime start1 = start.atStartOfDay(); + LocalDateTime end1 = end.atTime(LocalTime.MAX); + return this.baseMapper.getYearData(start1,end1); } @Resource @@ -2080,10 +2123,10 @@ if(null == chargingOrder){ return R.ok(); } -// Integer status = chargingOrder.getStatus(); -// if(status == 5){ -// return R.ok(); -// } + Integer status = chargingOrder.getStatus(); + if(status == 5){ + return R.ok(); + } //如果使用优惠券需要判断优惠券是否满足使用条件 //根据实际的充电金额计算退款金额 退回费用=(原金额/总金额)*(总金额-实际充电金额) @@ -2515,8 +2558,11 @@ @Override - public List<Map<String, Object>> getByDate(List<Long> chargingOrderIds) { - return this.baseMapper.getByDate(chargingOrderIds); + public List<Map<String, Object>> getByDate(LocalDate start,LocalDate end) { + + LocalDateTime start1 = start.atStartOfDay(); + LocalDateTime end1 = end.atTime(LocalTime.MAX); + return this.baseMapper.getByDate(start1,end1); } @Override @@ -3733,7 +3779,6 @@ chargingOrder.setStatus(2); chargingOrder.setPayTime(LocalDateTime.now()); chargingOrder.setChargeAmount(chargingOrder.getRechargeAmount()); - chargingOrder.setVipDiscountAmount(BigDecimal.ZERO); this.save(chargingOrder); Integer accountingStrategyId = tChargingGun.getAccountingStrategyId(); -- Gitblit v1.7.1