订单新增是否免费订单标识
This commit is contained in:
parent
9fb8af07c3
commit
7a6e27980a
@ -211,4 +211,9 @@ public class EbikeOrder implements Serializable {
|
||||
* 删除状态(true表示已删除)
|
||||
*/
|
||||
private Boolean isDeleted;
|
||||
|
||||
/**
|
||||
* 是否免费订单 true-免费 false-收费
|
||||
*/
|
||||
private Boolean isFreeOrder;
|
||||
}
|
||||
|
||||
@ -211,4 +211,9 @@ public class EbikeOrder implements Serializable {
|
||||
* 删除状态(true表示已删除)
|
||||
*/
|
||||
private Boolean isDeleted;
|
||||
|
||||
/**
|
||||
* 是否免费订单 true-免费 false-收费
|
||||
*/
|
||||
private Boolean isFreeOrder;
|
||||
}
|
||||
|
||||
@ -96,24 +96,19 @@ public class EbikeOrderServiceImpl extends ServiceImpl<EbikeOrderMapper, EbikeOr
|
||||
.createTime(LocalDateTime.now())
|
||||
.build();
|
||||
save(order);
|
||||
try {
|
||||
// 尝试开锁
|
||||
EbikeUnlockResultDto unlockResult = attemptUnlockWithValidation(bikeCode, userId);
|
||||
if (!unlockResult.isSuccess()) {
|
||||
throw new EbikeException("开锁失败: " + unlockResult.getErrorMsg());
|
||||
}
|
||||
// 开锁成功
|
||||
EbikeOrder orders = EbikeOrder.builder()
|
||||
.orderId(order.getOrderId())
|
||||
.orderStatus(OrderStatus.IN_PROGRESS)
|
||||
.updateTime(LocalDateTime.now())
|
||||
.build();
|
||||
updateById(orders);
|
||||
return getById(order.getOrderId());
|
||||
} catch (Exception e) {
|
||||
log.error("开锁失败, userId={}, bikeCode={}", userId, bikeCode, e);
|
||||
throw new RuntimeException("开锁失败", e);
|
||||
// 尝试开锁
|
||||
EbikeUnlockResultDto unlockResult = attemptUnlockWithValidation(bikeCode, userId);
|
||||
if (!unlockResult.isSuccess()) {
|
||||
throw new EbikeException("开锁失败: " + unlockResult.getErrorMsg());
|
||||
}
|
||||
// 开锁成功
|
||||
EbikeOrder orders = EbikeOrder.builder()
|
||||
.orderId(order.getOrderId())
|
||||
.orderStatus(OrderStatus.IN_PROGRESS)
|
||||
.updateTime(LocalDateTime.now())
|
||||
.build();
|
||||
updateById(orders);
|
||||
return getById(order.getOrderId());
|
||||
}
|
||||
|
||||
|
||||
@ -252,12 +247,14 @@ public class EbikeOrderServiceImpl extends ServiceImpl<EbikeOrderMapper, EbikeOr
|
||||
order.setTotalAmount(BigDecimal.ZERO);
|
||||
order.setActualAmount(BigDecimal.ZERO);
|
||||
order.setOrderStatus(OrderStatus.PAID);
|
||||
order.setIsFreeOrder(Boolean.TRUE);
|
||||
updateById(order);
|
||||
return order.getOrderId();
|
||||
}
|
||||
order.setOrderStatus(OrderStatus.PENDING_PAYMENT);
|
||||
order.setTotalAmount(totalAmount);
|
||||
order.setActualAmount(totalAmount);
|
||||
order.setIsFreeOrder(Boolean.FALSE);
|
||||
updateById(order);
|
||||
//生成支付订单
|
||||
EbikePayment payment = EbikePayment.builder()
|
||||
@ -422,7 +419,7 @@ public class EbikeOrderServiceImpl extends ServiceImpl<EbikeOrderMapper, EbikeOr
|
||||
long freeDurationSeconds = freeDurationMinutes * GlobalConstants.LONG_SIXTY;
|
||||
// 如果骑行时长小于等于免费时长,不收费
|
||||
BigDecimal baseCost;
|
||||
if (totalRideSeconds <= freeDurationSeconds) {
|
||||
if (totalRideSeconds <= freeDurationSeconds) {
|
||||
return BigDecimal.ZERO;
|
||||
} else {
|
||||
long totalRoundedMinutes = (totalRideSeconds + GlobalConstants.NUMBER_FIFTY_NINE) / GlobalConstants.NUMBER_SIXTY;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user