From 6f9c9a70faa0844c34c4a9af1908db060f23e639 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期二, 05 十一月 2024 19:14:28 +0800 Subject: [PATCH] bug修改 --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java | 58 +++++++++++++++++++++++++++++++++------------------------- 1 files changed, 33 insertions(+), 25 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 25321f7..961a0a4 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 @@ -1637,7 +1637,8 @@ chargingOrderListInfoVO.setStatus(chargingOrder.getStatus()); BigDecimal bigDecimal = new BigDecimal("0.006"); if (chargingOrder.getOrderAmount()!=null){ - chargingOrderListInfoVO.setCommissionAmount(chargingOrder.getOrderAmount().multiply(bigDecimal)); + BigDecimal multiply = chargingOrder.getPaymentAmount().multiply(bigDecimal); + chargingOrderListInfoVO.setCommissionAmount(multiply.setScale(2, BigDecimal.ROUND_HALF_UP)); } chargingOrderListInfoVO.setElectrovalence(chargingOrder.getElectrovalence()); chargingOrderListInfoVO.setServiceCharge(chargingOrder.getServiceCharge()); @@ -1671,6 +1672,7 @@ } } } + chargingOrderListInfoVO.setChargingCapacity(chargingOrder.getChargingCapacity()); chargingOrderListInfoVO.setEndMode(chargingOrder.getEndMode()); @@ -1686,10 +1688,18 @@ } } if (!data6.isEmpty()){ - // 第一条数据soc为开始 最后一条数据soc为结束soc - chargingOrderListInfoVO.setStartSoc(data6.get(data6.size()-1).getSoc().toString()); - chargingOrderListInfoVO.setEndSoc(data6.get(0).getSoc().toString()); - chargingOrderListInfoVO.setChargingCapacity(data6.get(data6.size()-1).getCharging_degree()); + int min = 100; + int max = 0; + for (UploadRealTimeMonitoringData uploadRealTimeMonitoringData : data6) { + if (uploadRealTimeMonitoringData.getSoc()>max){ + max = uploadRealTimeMonitoringData.getSoc(); + } + if (uploadRealTimeMonitoringData.getSoc()!=0 &&uploadRealTimeMonitoringData.getSoc()<min){ + min = uploadRealTimeMonitoringData.getSoc(); + } + } + chargingOrderListInfoVO.setEndSoc(max+""); + chargingOrderListInfoVO.setStartSoc(min+""); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); for (UploadRealTimeMonitoringData uploadRealTimeMonitoringData : data6) { @@ -1977,6 +1987,8 @@ } } } + //会员折扣金额 + discountAmount = discountAmount.setScale(2, RoundingMode.DOWN); payAmount = payAmount.subtract(discountAmount); TChargingOrder order = new TChargingOrder(); @@ -1994,12 +2006,13 @@ order.setEndTime(LocalDateTime.parse(vo.getEnd_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SS"))); order.setStatus(5); order.setOrderAmount(orderAmount.setScale(2, RoundingMode.DOWN)); - order.setVipDiscountAmount(discountAmount.setScale(2, RoundingMode.DOWN)); + order.setVipDiscountAmount(discountAmount); order.setElectrovalence(periodElectricPrice_total.setScale(2, RoundingMode.DOWN)); order.setChargingCapacity(vo.getTotal_electricity()); order.setElectricity(vo.getTotal_electricity()); //计算优惠券 + BigDecimal couponDiscount = BigDecimal.ZERO; if(null != chargingOrder.getAppCouponId()){ //判断实际充电金额是否满足优惠券使用条件,如果不满足则不适用优惠券。 TAppCoupon appCoupon = appCouponClient.getAppCouponById(chargingOrder.getAppCouponId()).getData(); @@ -2012,17 +2025,12 @@ BigDecimal couponDiscountAmount = tCoupon.getDiscountAmount(); //如果优惠金额大于服务费金额,以服务费作为最大限制 if(periodServicePrice_total.compareTo(couponDiscountAmount) < 0){ - refundAmount = refundAmount.add(periodServicePrice_total); - order.setCouponDiscountAmount(periodServicePrice_total); - payAmount = payAmount.subtract(periodServicePrice_total); + couponDiscount = periodServicePrice_total; periodServicePrice_total = BigDecimal.ZERO; }else{ - refundAmount = refundAmount.add(couponDiscountAmount); - order.setCouponDiscountAmount(couponDiscountAmount); - payAmount = payAmount.subtract(couponDiscountAmount); + couponDiscount = couponDiscountAmount; periodServicePrice_total = periodServicePrice_total.subtract(couponDiscountAmount); } - appCoupon.setStatus(2); appCouponClient.updateAppCoupon(appCoupon); }else{ @@ -2039,14 +2047,10 @@ divide = divide.compareTo(tCoupon.getMaximumDiscountAmount()) > 0 ? tCoupon.getMaximumDiscountAmount() : divide; //如果优惠金额大于服务费金额,以服务费作为最大限制 if(periodServicePrice_total.compareTo(divide) < 0){ - refundAmount = refundAmount.add(periodServicePrice_total); - order.setCouponDiscountAmount(periodServicePrice_total); - payAmount = payAmount.subtract(periodServicePrice_total); + couponDiscount = periodServicePrice_total; periodServicePrice_total = BigDecimal.ZERO; }else{ - refundAmount = refundAmount.add(divide); - order.setCouponDiscountAmount(divide); - payAmount = payAmount.subtract(divide); + couponDiscount = divide; periodServicePrice_total = periodServicePrice_total.subtract(divide); } @@ -2059,7 +2063,11 @@ } } } - + //优惠券优惠金额 + couponDiscount = couponDiscount.setScale(2, RoundingMode.DOWN); + refundAmount = refundAmount.add(couponDiscount); + payAmount = payAmount.subtract(couponDiscount); + order.setCouponDiscountAmount(couponDiscount); order.setServiceCharge(periodServicePrice_total.setScale(2, RoundingMode.DOWN)); order.setPaymentAmount(payAmount.setScale(2, RoundingMode.DOWN)); order.setRefundAmount(refundAmount.setScale(2, RoundingMode.DOWN)); @@ -2076,8 +2084,8 @@ BigDecimal periodServicePrice = chargingOrderAccountingStrategy.getPeriodServicePrice(); BigDecimal multiply = couponDiscountAmount.multiply(periodServicePrice.divide(reduce, new MathContext(4, RoundingMode.HALF_EVEN))); periodServicePrice = periodServicePrice.subtract(multiply); - chargingOrderAccountingStrategy.setPeriodServicePrice(periodServicePrice.setScale(2, RoundingMode.DOWN)); - chargingOrderAccountingStrategy.setCouponDiscountAmount(multiply.setScale(2, RoundingMode.DOWN)); + chargingOrderAccountingStrategy.setPeriodServicePrice(periodServicePrice.setScale(2, RoundingMode.HALF_EVEN)); + chargingOrderAccountingStrategy.setCouponDiscountAmount(multiply.setScale(2, RoundingMode.HALF_EVEN)); } chargingOrderAccountingStrategyService.updateBatchById(list); } @@ -2584,19 +2592,19 @@ } if (tChargingOrder.getPaymentAmount()!=null){ paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount()); + orderCommission = orderCommission.add(tChargingOrder.getPaymentAmount().multiply(new BigDecimal("0.006")) + .setScale(2,BigDecimal.ROUND_DOWN)); } } // 三方交易手续费 三方收费*0.6% commissionAmount = sharingAmount.multiply(new BigDecimal("0.006")); - // 订单手续费 订单支付金额 - 退款金额*0.6% - orderCommission = paymentAmount.multiply(new BigDecimal("0.006")); tSettlementConfirm.setSharingAmount(sharingAmount.setScale(2, RoundingMode.HALF_DOWN)); tSettlementConfirm.setCommissionAmount(commissionAmount.setScale(2, RoundingMode.HALF_DOWN)); tSettlementConfirm.setElectrovalence(electrovalence.setScale(2, RoundingMode.HALF_DOWN)); tSettlementConfirm.setServiceCharge(serviceCharge.subtract(orderCommission).setScale(2, RoundingMode.HALF_DOWN)); - tSettlementConfirm.setOrderCommission(orderCommission.setScale(2,BigDecimal.ROUND_DOWN)); + tSettlementConfirm.setOrderCommission(orderCommission); tSettlementConfirm.setVipDiscount(vipDiscount); tSettlementConfirm.setCouponDiscount(couponDiscount); tSettlementConfirm.setSiteId(dto.getSiteId()); -- Gitblit v1.7.1