费用计算问题修复
This commit is contained in:
parent
a39239c327
commit
9fb8af07c3
@ -24,6 +24,10 @@ public interface GlobalConstants {
|
|||||||
|
|
||||||
Integer NUMBER_FIVE = 5;
|
Integer NUMBER_FIVE = 5;
|
||||||
|
|
||||||
|
Integer NUMBER_FIFTY_NINE = 59;
|
||||||
|
|
||||||
|
Integer NUMBER_SIXTY = 60;
|
||||||
|
|
||||||
Integer NUMBER_ONE_HUNDRED = 100;
|
Integer NUMBER_ONE_HUNDRED = 100;
|
||||||
|
|
||||||
// 字符串状态常量
|
// 字符串状态常量
|
||||||
@ -54,4 +58,5 @@ public interface GlobalConstants {
|
|||||||
|
|
||||||
Long LONG_FIVE = 5L;
|
Long LONG_FIVE = 5L;
|
||||||
|
|
||||||
|
Long LONG_SIXTY = 60L;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.cdzy.user.service.impl;
|
package com.cdzy.user.service.impl;
|
||||||
|
|
||||||
import com.cdzy.common.enums.Code;
|
import com.cdzy.common.enums.Code;
|
||||||
|
import com.cdzy.common.enums.GlobalConstants;
|
||||||
import com.cdzy.common.ex.EbikeException;
|
import com.cdzy.common.ex.EbikeException;
|
||||||
import com.cdzy.common.model.request.PageParam;
|
import com.cdzy.common.model.request.PageParam;
|
||||||
import com.cdzy.common.model.response.JsonResult;
|
import com.cdzy.common.model.response.JsonResult;
|
||||||
@ -54,7 +55,7 @@ import static com.cdzy.user.model.entity.table.EbikeRefundTableDef.EBIKE_REFUND;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class EbikeOrderImpl extends ServiceImpl<EbikeOrderMapper, EbikeOrder> implements EbikeOrderService {
|
public class EbikeOrderServiceImpl extends ServiceImpl<EbikeOrderMapper, EbikeOrder> implements EbikeOrderService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private EbikeOrderMapper ebikeOrderTransactionMapper;
|
private EbikeOrderMapper ebikeOrderTransactionMapper;
|
||||||
@ -415,14 +416,18 @@ public class EbikeOrderImpl extends ServiceImpl<EbikeOrderMapper, EbikeOrder> im
|
|||||||
BigDecimal durationFee = bikeInfo.getDurationFee();
|
BigDecimal durationFee = bikeInfo.getDurationFee();
|
||||||
Integer freeDurationMinutes = bikeInfo.getFreeDurationMinutes();
|
Integer freeDurationMinutes = bikeInfo.getFreeDurationMinutes();
|
||||||
Integer chargeDurationMinutes = bikeInfo.getChargeDurationMinutes();
|
Integer chargeDurationMinutes = bikeInfo.getChargeDurationMinutes();
|
||||||
// 骑行时长(分钟)
|
// 获取总骑行时长(秒)
|
||||||
long totalRideMinutes = Duration.between(startTime, endTime).toMinutes();
|
long totalRideSeconds = Duration.between(startTime, endTime).toSeconds();
|
||||||
|
// 免费时间(秒)
|
||||||
|
long freeDurationSeconds = freeDurationMinutes * GlobalConstants.LONG_SIXTY;
|
||||||
// 如果骑行时长小于等于免费时长,不收费
|
// 如果骑行时长小于等于免费时长,不收费
|
||||||
BigDecimal baseCost;
|
BigDecimal baseCost;
|
||||||
if (totalRideMinutes <= freeDurationMinutes) {
|
if (totalRideSeconds <= freeDurationSeconds) {
|
||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
} else {
|
} else {
|
||||||
long chargeableMinutes = totalRideMinutes - freeDurationMinutes;
|
long totalRoundedMinutes = (totalRideSeconds + GlobalConstants.NUMBER_FIFTY_NINE) / GlobalConstants.NUMBER_SIXTY;
|
||||||
|
// 可计费分钟数 = 向上取整后的总分钟 - 免费分钟
|
||||||
|
long chargeableMinutes = totalRoundedMinutes - freeDurationMinutes;
|
||||||
long chargeUnits = (chargeableMinutes + chargeDurationMinutes - 1) / chargeDurationMinutes;
|
long chargeUnits = (chargeableMinutes + chargeDurationMinutes - 1) / chargeDurationMinutes;
|
||||||
BigDecimal durationCost = durationFee.multiply(BigDecimal.valueOf(chargeUnits));
|
BigDecimal durationCost = durationFee.multiply(BigDecimal.valueOf(chargeUnits));
|
||||||
// 总基础费用
|
// 总基础费用
|
||||||
Loading…
x
Reference in New Issue
Block a user