Pu Zhibing
2024-10-22 02a2d744f6bdaba1ba7dcfb3e8b4f78a47ef07da
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -927,7 +927,7 @@
      if(null != data){
         chargingDetails.setChargeCurrent(data.getOutput_current());
         chargingDetails.setChargeVoltage(data.getOutput_voltage());
         BigDecimal power = data.getOutput_current().multiply(data.getOutput_voltage()).divide(new BigDecimal(1000));
         BigDecimal power = data.getOutput_current().multiply(data.getOutput_voltage()).divide(new BigDecimal(1000), new MathContext(4, RoundingMode.HALF_EVEN));
         chargingDetails.setChargePower(power);
         chargingDetails.setCompletionRatio(data.getSoc());
         chargingDetails.setRemainingChargeTime(data.getTime_remaining());
@@ -1882,6 +1882,7 @@
      if(null != chargingOrder.getVipDiscount()){
         //服务费折扣
         discountAmount = periodServicePrice_total.multiply((new BigDecimal(1).subtract(chargingOrder.getVipDiscount())));
         periodServicePrice_total = periodServicePrice_total.multiply(chargingOrder.getVipDiscount());
         
         TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData();
         if(null != appUser.getVipId()){
@@ -1935,9 +1936,17 @@
         if(1 == preferentialMode){
            //满减
            if(payAmount.compareTo(tCoupon.getMeetTheConditions()) >= 0){
               refundAmount = refundAmount.add(tCoupon.getDiscountAmount());
               order.setCouponDiscountAmount(tCoupon.getDiscountAmount());
               payAmount = payAmount.subtract(tCoupon.getDiscountAmount());
               BigDecimal couponDiscountAmount = tCoupon.getDiscountAmount();
               //如果优惠金额大于服务费金额,以服务费作为最大限制
               if(periodServicePrice_total.compareTo(couponDiscountAmount) < 0){
                  refundAmount = refundAmount.add(periodServicePrice_total);
                  order.setCouponDiscountAmount(periodServicePrice_total);
                  payAmount = payAmount.subtract(periodServicePrice_total);
               }else{
                  refundAmount = refundAmount.add(couponDiscountAmount);
                  order.setCouponDiscountAmount(couponDiscountAmount);
                  payAmount = payAmount.subtract(couponDiscountAmount);
               }
            }else{
               order.setAppCouponId(null);
               order.setCouponDiscountAmount(BigDecimal.ZERO);
@@ -1950,9 +1959,16 @@
               //折扣金额
               BigDecimal divide = payAmount.multiply(new BigDecimal(10).subtract(tCoupon.getDiscount())).divide(new BigDecimal(10));
               divide = divide.compareTo(tCoupon.getMaximumDiscountAmount()) > 0 ? tCoupon.getMaximumDiscountAmount() : divide;
               refundAmount = refundAmount.add(divide);
               order.setCouponDiscountAmount(divide);
               payAmount = payAmount.subtract(divide);
               //如果优惠金额大于服务费金额,以服务费作为最大限制
               if(periodServicePrice_total.compareTo(divide) < 0){
                  refundAmount = refundAmount.add(periodServicePrice_total);
                  order.setCouponDiscountAmount(periodServicePrice_total);
                  payAmount = payAmount.subtract(periodServicePrice_total);
               }else{
                  refundAmount = refundAmount.add(divide);
                  order.setCouponDiscountAmount(divide);
                  payAmount = payAmount.subtract(divide);
               }
            }else{
               order.setAppCouponId(null);
               order.setCouponDiscountAmount(BigDecimal.ZERO);