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