优化店务小程序预约作品价格交互
This commit is contained in:
+11
-1
@@ -168,7 +168,7 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
LocalDateTime endTime = startTime.plusMinutes(durationMinutes);
|
||||
ensureWithinBusinessHours(shopId, startTime, endTime);
|
||||
|
||||
BigDecimal unitPrice = product.getPrice() == null ? BigDecimal.ZERO : product.getPrice();
|
||||
BigDecimal unitPrice = resolveAppointmentUnitPrice(product, dto);
|
||||
BigDecimal amount = unitPrice.multiply(BigDecimal.valueOf(quantity));
|
||||
|
||||
OrderDO order = new OrderDO();
|
||||
@@ -890,6 +890,16 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
return product;
|
||||
}
|
||||
|
||||
private BigDecimal resolveAppointmentUnitPrice(ProductDO product, PlanningAppointmentCreateDTO dto) {
|
||||
if (dto.getManualProductPrice() == null) {
|
||||
return product.getPrice() == null ? BigDecimal.ZERO : product.getPrice();
|
||||
}
|
||||
if (dto.getManualProductPrice().compareTo(BigDecimal.ZERO) < 0) {
|
||||
throw new RuntimeException("本次价格不能小于0");
|
||||
}
|
||||
return dto.getManualProductPrice();
|
||||
}
|
||||
|
||||
private int requireAppointmentDuration(Integer durationMinutes) {
|
||||
if (durationMinutes == null || durationMinutes <= 0) {
|
||||
throw new RuntimeException("预约时长不能为空且必须大于0分钟");
|
||||
|
||||
Reference in New Issue
Block a user