修复bug
This commit is contained in:
parent
c9a258210e
commit
95c2df33ad
|
@ -2253,7 +2253,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
IntervalRuleVo intervalRuleVo = JSONObject.parseObject(order.getRidingRuleJson(), IntervalRuleVo.class);
|
IntervalRuleVo intervalRuleVo = JSONObject.parseObject(order.getRidingRuleJson(), IntervalRuleVo.class);
|
||||||
List<IntervalRuleVo.IntervalRule> rule1 = intervalRuleVo.getRule();
|
List<IntervalRuleVo.IntervalRule> rule1 = intervalRuleVo.getRule();
|
||||||
//骑行时长
|
//骑行时长
|
||||||
Integer duration = DateUtils.timeDifferenceInMinutes(returnTime,unlockTime);//计算相隔多少分钟
|
int duration = DateUtils.timeDifferenceInMinutes(returnTime,unlockTime);//计算相隔多少分钟
|
||||||
BigDecimal durationInMinutes = new BigDecimal(duration);
|
BigDecimal durationInMinutes = new BigDecimal(duration);
|
||||||
if(rentalUnit.equals(ServiceConstants.RENTAL_UNIT_HOURS)){//租赁单位:hours-小时
|
if(rentalUnit.equals(ServiceConstants.RENTAL_UNIT_HOURS)){//租赁单位:hours-小时
|
||||||
BigDecimal durationInHours = durationInMinutes.divide(BigDecimal.valueOf(60), 0, RoundingMode.CEILING);
|
BigDecimal durationInHours = durationInMinutes.divide(BigDecimal.valueOf(60), 0, RoundingMode.CEILING);
|
||||||
|
@ -2264,18 +2264,21 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
}
|
}
|
||||||
//判断在哪个计费区间内,
|
//判断在哪个计费区间内,
|
||||||
for (IntervalRuleVo.IntervalRule intervalRule : rule1) {
|
for (IntervalRuleVo.IntervalRule intervalRule : rule1) {
|
||||||
Integer start = intervalRule.getStart();
|
int start = intervalRule.getStart();
|
||||||
Integer end = intervalRule.getEnd();
|
int end = intervalRule.getEnd();
|
||||||
Integer unit = intervalRule.getEachUnit();
|
int unit = intervalRule.getEachUnit();
|
||||||
BigDecimal fee = intervalRule.getFee();
|
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是否在当前区间内
|
// 判断duration是否在当前区间内
|
||||||
if (duration > start && duration <= end) {
|
if (duration > start && duration <= end) {
|
||||||
// duration位于当前区间[start, end]内
|
// duration位于当前区间[start, end]内
|
||||||
|
log.info("================在区间内--骑行时长---duration: {}, start: {}, end: {}, unit: {}, fee: {}", duration, start, end, unit, fee);
|
||||||
System.out.println("费用为: " + fee + "元/每" + unit + formatUnit(rentalUnit));
|
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) {
|
} 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));
|
System.out.println("达到区间的上限,但不落入下一个区间,费用为: " + fee + "元/每" + unit + formatUnit(rentalUnit));
|
||||||
throw new ServiceException("达到区间的上限,但不落入下一个区间,费用为: " + fee + "元/每" + unit + formatUnit(rentalUnit));
|
throw new ServiceException("达到区间的上限,但不落入下一个区间,费用为: " + fee + "元/每" + unit + formatUnit(rentalUnit));
|
||||||
|
|
|
@ -487,6 +487,9 @@ public class AsUserServiceImpl implements IAsUserService
|
||||||
BigDecimal balance = asUser.getBalance();
|
BigDecimal balance = asUser.getBalance();
|
||||||
EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(areaId);
|
EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(areaId);
|
||||||
BigDecimal deposit = new BigDecimal(area.getDeposit());
|
BigDecimal deposit = new BigDecimal(area.getDeposit());
|
||||||
|
if(deposit.compareTo(new BigDecimal(0))==0){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if(balance.compareTo(deposit)<0){
|
if(balance.compareTo(deposit)<0){
|
||||||
if(balance.compareTo(BigDecimal.ZERO)==0){//余额为0
|
if(balance.compareTo(BigDecimal.ZERO)==0){//余额为0
|
||||||
log.info("用户【{}】余额为0",userId);
|
log.info("用户【{}】余额为0",userId);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user