From ee2bf95f3472a4179ee0fc7c8e4e2a35e1214bc8 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期三, 23 十月 2024 10:15:08 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java | 71 +++++++++++++++++++++-------------- 1 files changed, 43 insertions(+), 28 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 99dbb12..84b911b 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 @@ -812,21 +812,21 @@ chargingDetails.setId(one.getId().toString()); TChargingGun chargingGun = chargingGunClient.getChargingGunById(id).getData(); TChargingPile chargingPile = chargingPileClient.getChargingPileById(chargingGun.getChargingPileId()).getData(); - Site site = siteClient.getSiteByIds(Arrays.asList(chargingPile.getSiteId())).getData().get(0); - chargingDetails.setName(site.getName() + "-" + chargingPile.getName()); - chargingDetails.setCode(one.getCode()); - chargingDetails.setStatus(one.getStatus()); - chargingDetails.setChargingCost(one.getResidualAmount()); - UploadRealTimeMonitoringData data = uploadRealTimeMonitoringDataClient.chargingOrderInfo(one.getCode()).getData(); - 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)); - chargingDetails.setChargePower(power); - chargingDetails.setCompletionRatio(data.getSoc()); - chargingDetails.setRemainingChargeTime(data.getTime_remaining()); - chargingDetails.setChargedDegrees(data.getCharging_degree()); - Integer h = Integer.valueOf(data.getCumulative_charging_time() / 60); + Site site = siteClient.getSiteByIds(Arrays.asList(chargingPile.getSiteId())).getData().get(0); + chargingDetails.setName(site.getName() + "-" + chargingPile.getName()); + chargingDetails.setCode(one.getCode()); + chargingDetails.setStatus(one.getStatus()); + chargingDetails.setChargingCost(one.getResidualAmount()); + UploadRealTimeMonitoringData data = uploadRealTimeMonitoringDataClient.chargingOrderInfo(one.getCode()).getData(); + 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), new MathContext(4, RoundingMode.HALF_EVEN)); + chargingDetails.setChargePower(power); + chargingDetails.setCompletionRatio(data.getSoc()); + chargingDetails.setRemainingChargeTime(data.getTime_remaining()); + chargingDetails.setChargedDegrees(data.getCharging_degree()); + Integer h = Integer.valueOf(data.getCumulative_charging_time() / 60); Integer m = Integer.valueOf(data.getCumulative_charging_time() % 60); chargingDetails.setChargedTime(String.format("%02d", h) + ":" + String.format("%02d", m)); } @@ -1616,11 +1616,6 @@ return; } - //计算用户标签 - editUserTag(chargingOrder); - //用户推荐奖励 - referralReward(chargingOrder); - //如果使用优惠券需要判断优惠券是否满足使用条件 //根据实际的充电金额计算退款金额 退回费用=(原金额/总金额)*(总金额-实际充电金额) //退款金额=优惠券金额+剩余充电金额 @@ -1712,7 +1707,8 @@ 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()){ //判断会员是否还有充电优惠次数 @@ -1765,9 +1761,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); @@ -1780,9 +1784,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); @@ -1830,7 +1841,11 @@ appUserClient.updateAppUser(appUser); appUserIntegralChangeClient.addAppUserIntegralChange(appUserIntegralChange); } - + + //计算用户标签 + editUserTag(chargingOrder); + //用户推荐奖励 + referralReward(chargingOrder); //开始构建退款费用 if(refundAmount.compareTo(BigDecimal.ZERO) > 0){ -- Gitblit v1.7.1