From 95c2df33adbf670a6644b2fcd0f40ece6c44fe2a Mon Sep 17 00:00:00 2001 From: 18650502300 <18650502300@163.com> Date: Sat, 7 Dec 2024 09:11:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/AsDeviceServiceImpl.java | 17 ++++++++++------- .../system/service/impl/AsUserServiceImpl.java | 3 +++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java index e2bd01d..e892f80 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java @@ -2253,7 +2253,7 @@ public class AsDeviceServiceImpl extends ServiceImpl i IntervalRuleVo intervalRuleVo = JSONObject.parseObject(order.getRidingRuleJson(), IntervalRuleVo.class); List rule1 = intervalRuleVo.getRule(); //骑行时长 - Integer duration = DateUtils.timeDifferenceInMinutes(returnTime,unlockTime);//计算相隔多少分钟 + int duration = DateUtils.timeDifferenceInMinutes(returnTime,unlockTime);//计算相隔多少分钟 BigDecimal durationInMinutes = new BigDecimal(duration); if(rentalUnit.equals(ServiceConstants.RENTAL_UNIT_HOURS)){//租赁单位:hours-小时 BigDecimal durationInHours = durationInMinutes.divide(BigDecimal.valueOf(60), 0, RoundingMode.CEILING); @@ -2264,18 +2264,21 @@ public class AsDeviceServiceImpl extends ServiceImpl i } //判断在哪个计费区间内, for (IntervalRuleVo.IntervalRule intervalRule : rule1) { - Integer start = intervalRule.getStart(); - Integer end = intervalRule.getEnd(); - Integer unit = intervalRule.getEachUnit(); + int start = intervalRule.getStart(); + int end = intervalRule.getEnd(); + int unit = intervalRule.getEachUnit(); BigDecimal fee = intervalRule.getFee(); - log.info("骑行时长---duration: " + duration + ", start: " + start + ", end: " + end + ", unit: " + unit + ", fee: " + fee); + log.info("骑行时长---duration: {}, start: {}, end: {}, unit: {}, fee: {}", duration, start, end, unit, fee); // 判断duration是否在当前区间内 if (duration > start && duration <= end) { // duration位于当前区间[start, end]内 + log.info("================在区间内--骑行时长---duration: {}, start: {}, end: {}, unit: {}, fee: {}", duration, start, end, unit, fee); System.out.println("费用为: " + fee + "元/每" + unit + formatUnit(rentalUnit)); - ridingFee = new BigDecimal(fee.toString()).multiply(new BigDecimal(duration / unit)); + BigDecimal durationUnit = new BigDecimal(duration).divide(new BigDecimal(unit), RoundingMode.CEILING); + ridingFee = new BigDecimal(fee.toString()).multiply(durationUnit); + log.info("==================计算出的骑行费用为: {}", ridingFee); } else if (duration == end && intervalRule.getEnd() != 9999) { - log.info("不在区间内--骑行时长---duration: " + duration + ", start: " + start + ", end: " + end + ", unit: " + unit + ", fee: " + fee); + log.info("不在区间内--骑行时长---duration: {}, start: {}, end: {}, unit: {}, fee: {}", duration, start, end, unit, fee); // 特殊处理结束边界为具体值的情况,避免与默认无限大区间混淆 System.out.println("达到区间的上限,但不落入下一个区间,费用为: " + fee + "元/每" + unit + formatUnit(rentalUnit)); throw new ServiceException("达到区间的上限,但不落入下一个区间,费用为: " + fee + "元/每" + unit + formatUnit(rentalUnit)); diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java index 8965a98..58db59e 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java @@ -487,6 +487,9 @@ public class AsUserServiceImpl implements IAsUserService BigDecimal balance = asUser.getBalance(); EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(areaId); BigDecimal deposit = new BigDecimal(area.getDeposit()); + if(deposit.compareTo(new BigDecimal(0))==0){ + return true; + } if(balance.compareTo(deposit)<0){ if(balance.compareTo(BigDecimal.ZERO)==0){//余额为0 log.info("用户【{}】余额为0",userId);