From 1ed5d1f77bddfd44ed3523df57b6869f17a8d742 Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Tue, 19 Nov 2024 18:50:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86=E9=87=91=E9=A2=9D?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8BBigDecimal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../heritage/aop/AuthInterceptor.java | 82 +++++++++++-------- .../book/BookingDateController.java | 6 +- .../controller/good/CartRecordController.java | 3 +- .../advanceOrder/AdvanceOrderAddRequest.java | 3 +- .../AdvanceOrderQueryRequest.java | 5 +- .../model/dto/cart/CartRecordAddRequest.java | 3 +- .../dto/cart/CartRecordUpdateRequest.java | 3 +- .../clothesgrade/ClothesGradeAddRequest.java | 5 +- .../ClothesGradeUpdateRequest.java | 5 +- .../clothesinfo/ClothesInfoAddRequest.java | 3 +- .../clothesinfo/ClothesInfoQueryRequest.java | 5 +- .../clothesinfo/ClothesInfoUpdateRequest.java | 3 +- .../model/dto/coupon/CouponAddRequest.java | 3 +- .../model/dto/coupon/CouponUpdateRequest.java | 3 +- .../model/dto/good/GoodAddRequest.java | 3 +- .../model/dto/good/GoodUpdateRequest.java | 3 +- .../model/dto/order/OrderAddRequest.java | 3 +- .../model/dto/order/OrderItemAddRequest.java | 5 +- .../model/dto/order/OrderQueryRequest.java | 5 +- .../capital/OrderMainInfoAddRequest.java | 3 +- .../model/dto/snapshot/CouponSnapshot.java | 3 +- .../model/dto/snapshot/GoodSnapshot.java | 3 +- .../heritage/model/entity/AdvanceOrder.java | 3 +- .../heritage/model/entity/CartRecord.java | 3 +- .../heritage/model/entity/ClothesGrade.java | 5 +- .../heritage/model/entity/ClothesInfo.java | 3 +- .../heritage/model/entity/Coupon.java | 3 +- .../cultural/heritage/model/entity/Good.java | 3 +- .../cultural/heritage/model/entity/Order.java | 3 +- .../heritage/model/entity/OrderItems.java | 5 +- .../model/vo/advanceorder/AdvanceOrderVO.java | 3 +- .../heritage/model/vo/cart/CartRecordVO.java | 3 +- .../model/vo/clothesgrade/ClothesGradeVO.java | 5 +- .../vo/clothesinfo/ClothesInfoLabelVO.java | 3 +- .../model/vo/clothesinfo/ClothesInfoVO.java | 3 +- .../heritage/model/vo/good/GoodVO.java | 3 +- .../model/vo/good/ServiceGoodCardVO.java | 3 +- .../heritage/model/vo/order/OrderVO.java | 3 +- .../book/impl/AdvanceOrderServiceImpl.java | 10 ++- .../book/impl/ClothesGradeServiceImpl.java | 11 +-- .../book/impl/ClothesInfoServiceImpl.java | 10 ++- .../good/impl/CartRecordServiceImpl.java | 7 +- .../service/good/impl/CouponServiceImpl.java | 5 +- .../service/good/impl/GoodServiceImpl.java | 5 +- .../service/order/impl/OrderServiceImpl.java | 13 +-- src/main/resources/application.yml | 14 ++-- .../java/com/cultural/heritage/test/Test.java | 5 ++ 47 files changed, 177 insertions(+), 117 deletions(-) diff --git a/src/main/java/com/cultural/heritage/aop/AuthInterceptor.java b/src/main/java/com/cultural/heritage/aop/AuthInterceptor.java index 96fc42d..39d277b 100644 --- a/src/main/java/com/cultural/heritage/aop/AuthInterceptor.java +++ b/src/main/java/com/cultural/heritage/aop/AuthInterceptor.java @@ -1,12 +1,22 @@ package com.cultural.heritage.aop; import com.cultural.heritage.annotation.AuthCheck; +import com.cultural.heritage.common.ErrorCode; +import com.cultural.heritage.constant.UserConstant; +import com.cultural.heritage.exception.BusinessException; +import com.cultural.heritage.model.entity.User; +import com.cultural.heritage.model.enums.UserRoleEnum; import com.cultural.heritage.service.user.UserService; import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletRequest; +import org.apache.commons.lang3.StringUtils; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; /** * 权限校验AOP @@ -24,42 +34,42 @@ public class AuthInterceptor { @Around("@annotation(authCheck)") public Object doInterceptor(ProceedingJoinPoint joinPoint, AuthCheck authCheck) throws Throwable { // 接口的权限 -// String mustRole = authCheck.mustRole(); -// RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes(); -// HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest(); -// -// //当前登录用户 -// User loginUser = userService.getLoginUser(request); -// //必须有该权限才通过 -// if (StringUtils.isNotBlank(mustRole)) { -// //mustUserRoleEnum是接口权限 -// UserRoleEnum mustUserRoleEnum = UserRoleEnum.getEnumByValues(mustRole); -// if(mustUserRoleEnum == null) { -// throw new BusinessException(ErrorCode.NO_AUTH_ERROR); -// } -// //用户权限 -// String userRole = loginUser.getUserRole(); -// //根据用户角色获取封装后的枚举类对象 -// UserRoleEnum userRoleEnum = UserRoleEnum.getEnumByValues(userRole); -// -// //如果被封号,直接拒绝 -// if (UserRoleEnum.BAN.equals(userRoleEnum)) { -// throw new BusinessException(ErrorCode.NO_AUTH_ERROR); -// } -// -// //如果接口需要Boss权限,则需要判断用户是否是boss管理员 -// if (UserRoleEnum.BOSS.equals(mustUserRoleEnum)) { -// if (!mustRole.equals(userRole)) { -// throw new BusinessException(ErrorCode.NO_AUTH_ERROR); -// } -// } -// //如果接口需要管理员权限,则需要判断用户是否是boss或者admin管理员 -// if (UserRoleEnum.ADMIN.equals(mustUserRoleEnum)) { -// if (!mustRole.equals(userRole) && !userRole.equals(UserConstant.BOSS_ROLE)) { -// throw new BusinessException(ErrorCode.NO_AUTH_ERROR); -// } -// } -// } + String mustRole = authCheck.mustRole(); + RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes(); + HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest(); + + //当前登录用户 + User loginUser = userService.getLoginUser(request); + //必须有该权限才通过 + if (StringUtils.isNotBlank(mustRole)) { + //mustUserRoleEnum是接口权限 + UserRoleEnum mustUserRoleEnum = UserRoleEnum.getEnumByValues(mustRole); + if(mustUserRoleEnum == null) { + throw new BusinessException(ErrorCode.NO_AUTH_ERROR); + } + //用户权限 + String userRole = loginUser.getUserRole(); + //根据用户角色获取封装后的枚举类对象 + UserRoleEnum userRoleEnum = UserRoleEnum.getEnumByValues(userRole); + + //如果被封号,直接拒绝 + if (UserRoleEnum.BAN.equals(userRoleEnum)) { + throw new BusinessException(ErrorCode.NO_AUTH_ERROR); + } + + //如果接口需要Boss权限,则需要判断用户是否是boss管理员 + if (UserRoleEnum.BOSS.equals(mustUserRoleEnum)) { + if (!mustRole.equals(userRole)) { + throw new BusinessException(ErrorCode.NO_AUTH_ERROR); + } + } + //如果接口需要管理员权限,则需要判断用户是否是boss或者admin管理员 + if (UserRoleEnum.ADMIN.equals(mustUserRoleEnum)) { + if (!mustRole.equals(userRole) && !userRole.equals(UserConstant.BOSS_ROLE)) { + throw new BusinessException(ErrorCode.NO_AUTH_ERROR); + } + } + } //通过权限校验,放行 return joinPoint.proceed(); } diff --git a/src/main/java/com/cultural/heritage/controller/book/BookingDateController.java b/src/main/java/com/cultural/heritage/controller/book/BookingDateController.java index f9f8a33..a027acd 100644 --- a/src/main/java/com/cultural/heritage/controller/book/BookingDateController.java +++ b/src/main/java/com/cultural/heritage/controller/book/BookingDateController.java @@ -47,7 +47,7 @@ public class BookingDateController { @Scheduled(cron = "0 0 0 * * ?") @Transactional(rollbackFor = Exception.class) @GetMapping("/init") - @Operation(summary = "初始化未来一天的预约日期", description = "参数:无,权限:自动调用,方法名:initCurrentBookingDate") + @Operation(summary = "(自动调用)初始化未来一天的预约日期", description = "参数:无,权限:自动调用,方法名:initCurrentBookingDate") public void initCurrentBookingDate() { // 初始化预约日期 List bookingDateList = new ArrayList<>(); @@ -68,7 +68,7 @@ public class BookingDateController { * @return 当前预约类型未来四天的预约日期列表 */ @PostMapping("/list") - @Operation(summary = "根据预约类别查询未来四天(包括今天)的预约日期", description = "参数:预约类型, 权限:所有人,方法名:listBookingDateByType") + @Operation(summary = "(小程序端)根据预约类别查询未来四天(包括今天)的预约日期", description = "参数:预约类型, 权限:所有人,方法名:listBookingDateByType") public BaseResponse> listBookingDateByType(@RequestBody CommonStringRequest commonStringRequest) { if (commonStringRequest == null || StringUtils.isBlank(commonStringRequest.getType())) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -95,7 +95,7 @@ public class BookingDateController { */ @PostMapping("/update") @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) - @Operation(summary = "更新当天的预约情况", description = "参数:预约日期更新请求体, 权限:管理员(admin, boss),方法名:updateBookingDate") + @Operation(summary = "Web端管理员更新当天的预约情况", description = "参数:预约日期更新请求体, 权限:管理员(admin, boss),方法名:updateBookingDate") public BaseResponse updateBookingDate(@RequestBody BookingDateUpdateRequest bookingDateUpdateRequest) { if (bookingDateUpdateRequest == null || bookingDateUpdateRequest.getId() <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR); diff --git a/src/main/java/com/cultural/heritage/controller/good/CartRecordController.java b/src/main/java/com/cultural/heritage/controller/good/CartRecordController.java index 3d2b89a..fda14c5 100644 --- a/src/main/java/com/cultural/heritage/controller/good/CartRecordController.java +++ b/src/main/java/com/cultural/heritage/controller/good/CartRecordController.java @@ -131,10 +131,11 @@ public class CartRecordController { /** * 展示用户批量购买后的订单信息 - * @param cartRecordQueryVOList 订单商品查询列表 + * @param cartRecordQueryVOList 商品id和数量的集合 * @return 订单商品信息列表 */ @PostMapping("/cart/list") + @Operation(summary = "展示用户批量购买后的订单信息", description = "参数:商品id和数量的集合,权限:所有人,方法名:listCartRecord") public BaseResponse> listCartRecord(@RequestBody List cartRecordQueryVOList, HttpServletRequest request) { if (cartRecordQueryVOList == null) { throw new BusinessException(ErrorCode.PARAMS_ERROR); diff --git a/src/main/java/com/cultural/heritage/model/dto/advanceOrder/AdvanceOrderAddRequest.java b/src/main/java/com/cultural/heritage/model/dto/advanceOrder/AdvanceOrderAddRequest.java index 70f67c0..321977c 100644 --- a/src/main/java/com/cultural/heritage/model/dto/advanceOrder/AdvanceOrderAddRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/advanceOrder/AdvanceOrderAddRequest.java @@ -5,6 +5,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data @Schema(description = "预约订单添加请求体", requiredProperties = {"type", "clothesType", "deposit", "contactsSnapshot", @@ -30,7 +31,7 @@ public class AdvanceOrderAddRequest implements Serializable { * 定金 */ @Schema(description = "定金", example = "100.00") - private Double deposit; + private BigDecimal deposit; /** diff --git a/src/main/java/com/cultural/heritage/model/dto/advanceOrder/AdvanceOrderQueryRequest.java b/src/main/java/com/cultural/heritage/model/dto/advanceOrder/AdvanceOrderQueryRequest.java index 391e1b7..218efc8 100644 --- a/src/main/java/com/cultural/heritage/model/dto/advanceOrder/AdvanceOrderQueryRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/advanceOrder/AdvanceOrderQueryRequest.java @@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data @@ -32,14 +33,14 @@ public class AdvanceOrderQueryRequest extends PageRequest implements Serializabl * 最小定金 */ @Schema(description = "最小定金", example = "80") - private Double minDeposit; + private BigDecimal minDeposit; /** * 最大定金 */ @Schema(description = "最大定金", example = "200") - private Double maxDeposit; + private BigDecimal maxDeposit; /** diff --git a/src/main/java/com/cultural/heritage/model/dto/cart/CartRecordAddRequest.java b/src/main/java/com/cultural/heritage/model/dto/cart/CartRecordAddRequest.java index 772d3f2..4923d53 100644 --- a/src/main/java/com/cultural/heritage/model/dto/cart/CartRecordAddRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/cart/CartRecordAddRequest.java @@ -5,6 +5,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data @Schema(description = "购物车记录添加请求体", requiredProperties = {"userId", "goodId", "quantity", "subtotal", "isGoodType"}) @@ -26,7 +27,7 @@ public class CartRecordAddRequest implements Serializable { * 小计 */ @Schema(description = "小计(商品单价 * 数量)", example = "60") - private Double subtotal; + private BigDecimal subtotal; /** * 是否是常规类商品 diff --git a/src/main/java/com/cultural/heritage/model/dto/cart/CartRecordUpdateRequest.java b/src/main/java/com/cultural/heritage/model/dto/cart/CartRecordUpdateRequest.java index ceec065..eefcb95 100644 --- a/src/main/java/com/cultural/heritage/model/dto/cart/CartRecordUpdateRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/cart/CartRecordUpdateRequest.java @@ -5,6 +5,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data @Schema(description = "购物车记录更新请求体", requiredProperties = {"id", "userId", "goodId", "quantity", "subtotal"}) @@ -33,7 +34,7 @@ public class CartRecordUpdateRequest implements Serializable { * 小计 */ @Schema(description = "小计(商品单价 * 数量)", example = "60") - private Double subtotal; + private BigDecimal subtotal; @Serial diff --git a/src/main/java/com/cultural/heritage/model/dto/clothesgrade/ClothesGradeAddRequest.java b/src/main/java/com/cultural/heritage/model/dto/clothesgrade/ClothesGradeAddRequest.java index 6688ed9..3735ec2 100644 --- a/src/main/java/com/cultural/heritage/model/dto/clothesgrade/ClothesGradeAddRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/clothesgrade/ClothesGradeAddRequest.java @@ -5,6 +5,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data @Schema(description = "服装等级添加请求体", requiredProperties = {"clothesType", "image", "minPrice", "maxPrice", "brief"}) @@ -28,14 +29,14 @@ public class ClothesGradeAddRequest implements Serializable { * 最低价格 */ @Schema(description = "最低价格", example = "80.00") - private Double minPrice; + private BigDecimal minPrice; /** * 最高价格 */ @Schema(description = "最高价格", example = "160") - private Double maxPrice; + private BigDecimal maxPrice; /** diff --git a/src/main/java/com/cultural/heritage/model/dto/clothesgrade/ClothesGradeUpdateRequest.java b/src/main/java/com/cultural/heritage/model/dto/clothesgrade/ClothesGradeUpdateRequest.java index 3be7579..fea8277 100644 --- a/src/main/java/com/cultural/heritage/model/dto/clothesgrade/ClothesGradeUpdateRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/clothesgrade/ClothesGradeUpdateRequest.java @@ -5,6 +5,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data @Schema(description = "服装等级更新请求体") @@ -36,14 +37,14 @@ public class ClothesGradeUpdateRequest implements Serializable { * 最低价格 */ @Schema(description = "最低价格", example = "80.00") - private Double minPrice; + private BigDecimal minPrice; /** * 最高价格 */ @Schema(description = "最高价格", example = "160") - private Double maxPrice; + private BigDecimal maxPrice; /** diff --git a/src/main/java/com/cultural/heritage/model/dto/clothesinfo/ClothesInfoAddRequest.java b/src/main/java/com/cultural/heritage/model/dto/clothesinfo/ClothesInfoAddRequest.java index b39ca4e..0606220 100644 --- a/src/main/java/com/cultural/heritage/model/dto/clothesinfo/ClothesInfoAddRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/clothesinfo/ClothesInfoAddRequest.java @@ -5,6 +5,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data @@ -45,7 +46,7 @@ public class ClothesInfoAddRequest implements Serializable { * 服装价格 */ @Schema(description = "服装价格", example = "100.00") - private Double price; + private BigDecimal price; /** diff --git a/src/main/java/com/cultural/heritage/model/dto/clothesinfo/ClothesInfoQueryRequest.java b/src/main/java/com/cultural/heritage/model/dto/clothesinfo/ClothesInfoQueryRequest.java index 6e36caf..da4d5b2 100644 --- a/src/main/java/com/cultural/heritage/model/dto/clothesinfo/ClothesInfoQueryRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/clothesinfo/ClothesInfoQueryRequest.java @@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data @EqualsAndHashCode(callSuper = true) @@ -32,14 +33,14 @@ public class ClothesInfoQueryRequest extends PageRequest implements Serializable * 最低价格 */ @Schema(description = "最低价格", example = "100.00") - private Double minPrice; + private BigDecimal minPrice; /** * 最高价格 */ @Schema(description = "最高价格", example = "200.00") - private Double maxPrice; + private BigDecimal maxPrice; /** diff --git a/src/main/java/com/cultural/heritage/model/dto/clothesinfo/ClothesInfoUpdateRequest.java b/src/main/java/com/cultural/heritage/model/dto/clothesinfo/ClothesInfoUpdateRequest.java index c29e5d8..5f08293 100644 --- a/src/main/java/com/cultural/heritage/model/dto/clothesinfo/ClothesInfoUpdateRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/clothesinfo/ClothesInfoUpdateRequest.java @@ -5,6 +5,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data @Schema(description = "服装添加请求体", requiredProperties = {"id", "name", "image", "effectImg", "intro", "price", "clothesType"}) @@ -50,7 +51,7 @@ public class ClothesInfoUpdateRequest implements Serializable { * 服装价格 */ @Schema(description = "服装价格", example = "100.00") - private Double price; + private BigDecimal price; /** diff --git a/src/main/java/com/cultural/heritage/model/dto/coupon/CouponAddRequest.java b/src/main/java/com/cultural/heritage/model/dto/coupon/CouponAddRequest.java index 6f35056..a40dfaf 100644 --- a/src/main/java/com/cultural/heritage/model/dto/coupon/CouponAddRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/coupon/CouponAddRequest.java @@ -5,6 +5,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data @Schema(description = "优惠券添加请求体", requiredProperties = @@ -22,7 +23,7 @@ public class CouponAddRequest implements Serializable { * 满减金额 */ @Schema(description = "满减金额", example = "50") - private Double conditionAmount; + private BigDecimal conditionAmount; /** diff --git a/src/main/java/com/cultural/heritage/model/dto/coupon/CouponUpdateRequest.java b/src/main/java/com/cultural/heritage/model/dto/coupon/CouponUpdateRequest.java index d577148..44e39ca 100644 --- a/src/main/java/com/cultural/heritage/model/dto/coupon/CouponUpdateRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/coupon/CouponUpdateRequest.java @@ -5,6 +5,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data @Schema(description = "优惠券更新请求体", requiredProperties = @@ -27,7 +28,7 @@ public class CouponUpdateRequest implements Serializable { * 满减金额 */ @Schema(description = "满减金额", example = "50") - private Double conditionAmount; + private BigDecimal conditionAmount; /** diff --git a/src/main/java/com/cultural/heritage/model/dto/good/GoodAddRequest.java b/src/main/java/com/cultural/heritage/model/dto/good/GoodAddRequest.java index 65a977f..80b3011 100644 --- a/src/main/java/com/cultural/heritage/model/dto/good/GoodAddRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/good/GoodAddRequest.java @@ -5,6 +5,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import java.io.Serializable; +import java.math.BigDecimal; @Data @Schema(description = "商品添加请求体", requiredProperties = {"name", "type", "price", "goodImg", "intro", @@ -28,7 +29,7 @@ public class GoodAddRequest implements Serializable { * 商品价格 */ @Schema(description = "商品价格", example = "20.00") - private Double price; + private BigDecimal price; /** * 商品图片 diff --git a/src/main/java/com/cultural/heritage/model/dto/good/GoodUpdateRequest.java b/src/main/java/com/cultural/heritage/model/dto/good/GoodUpdateRequest.java index 8d5e1ed..6b518cf 100644 --- a/src/main/java/com/cultural/heritage/model/dto/good/GoodUpdateRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/good/GoodUpdateRequest.java @@ -5,6 +5,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import java.io.Serializable; +import java.math.BigDecimal; @Data @Schema(description = "商品更新请求体", requiredProperties = {"id", "name", "type", "price", "goodImg", "intro", @@ -33,7 +34,7 @@ public class GoodUpdateRequest implements Serializable { * 商品价格 */ @Schema(description = "商品价格", example = "20.00") - private Double price; + private BigDecimal price; /** * 商品图片 diff --git a/src/main/java/com/cultural/heritage/model/dto/order/OrderAddRequest.java b/src/main/java/com/cultural/heritage/model/dto/order/OrderAddRequest.java index de58570..660063f 100644 --- a/src/main/java/com/cultural/heritage/model/dto/order/OrderAddRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/order/OrderAddRequest.java @@ -8,6 +8,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; import java.util.List; @Data @@ -61,7 +62,7 @@ public class OrderAddRequest implements Serializable { * 订单总金额 */ @Schema(description = "订单总金额", example = "500") - private Double totalAmount; + private BigDecimal totalAmount; /** * 订单状态 diff --git a/src/main/java/com/cultural/heritage/model/dto/order/OrderItemAddRequest.java b/src/main/java/com/cultural/heritage/model/dto/order/OrderItemAddRequest.java index a36322f..1c918c9 100644 --- a/src/main/java/com/cultural/heritage/model/dto/order/OrderItemAddRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/order/OrderItemAddRequest.java @@ -6,6 +6,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data @Schema(description = "订单明细添加请求体", requiredProperties = {"orderId", "goodSnapshot", "priceSnapshot", "quantity", "itemTotalAmount"}) @@ -30,7 +31,7 @@ public class OrderItemAddRequest implements Serializable { * 商品单价快照 */ @Schema(description = "商品单价", example = "30") - private Double priceSnapshot; + private BigDecimal priceSnapshot; /** @@ -44,7 +45,7 @@ public class OrderItemAddRequest implements Serializable { * 订单项金额(单价 * 数量) */ @Schema(description = "订单项金额(单价 * 数量)", example = "300") - private Double itemTotalAmount; + private BigDecimal itemTotalAmount; /** diff --git a/src/main/java/com/cultural/heritage/model/dto/order/OrderQueryRequest.java b/src/main/java/com/cultural/heritage/model/dto/order/OrderQueryRequest.java index d70068f..bf46a3d 100644 --- a/src/main/java/com/cultural/heritage/model/dto/order/OrderQueryRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/order/OrderQueryRequest.java @@ -7,6 +7,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; @Data @@ -47,14 +48,14 @@ public class OrderQueryRequest extends PageRequest implements Serializable { * 订单最小金额 */ @Schema(description = "订单最小金额", example = "50") - private Double minTotalAmount; + private BigDecimal minTotalAmount; /** * 订单最大金额 */ @Schema(description = "订单最大金额", example = "350") - private Double maxTotalAmount; + private BigDecimal maxTotalAmount; /** diff --git a/src/main/java/com/cultural/heritage/model/dto/order/capital/OrderMainInfoAddRequest.java b/src/main/java/com/cultural/heritage/model/dto/order/capital/OrderMainInfoAddRequest.java index 7462c0d..dd9fa6c 100644 --- a/src/main/java/com/cultural/heritage/model/dto/order/capital/OrderMainInfoAddRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/order/capital/OrderMainInfoAddRequest.java @@ -5,6 +5,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; import java.util.List; @Data @@ -66,7 +67,7 @@ public class OrderMainInfoAddRequest implements Serializable { * 订单总金额 */ @Schema(description = "订单总金额", example = "560") - private Double totalAmount; + private BigDecimal totalAmount; /** * 订单状态 diff --git a/src/main/java/com/cultural/heritage/model/dto/snapshot/CouponSnapshot.java b/src/main/java/com/cultural/heritage/model/dto/snapshot/CouponSnapshot.java index 673c045..989e74d 100644 --- a/src/main/java/com/cultural/heritage/model/dto/snapshot/CouponSnapshot.java +++ b/src/main/java/com/cultural/heritage/model/dto/snapshot/CouponSnapshot.java @@ -5,6 +5,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data @Schema(description = "订单优惠券信息", requiredProperties = {"name", "conditionAmount"}) @@ -21,7 +22,7 @@ public class CouponSnapshot implements Serializable { * 满减金额 */ @Schema(description = "满减金额", example = "50") - private Double conditionAmount; + private BigDecimal conditionAmount; diff --git a/src/main/java/com/cultural/heritage/model/dto/snapshot/GoodSnapshot.java b/src/main/java/com/cultural/heritage/model/dto/snapshot/GoodSnapshot.java index 7d72e3e..7c3cba9 100644 --- a/src/main/java/com/cultural/heritage/model/dto/snapshot/GoodSnapshot.java +++ b/src/main/java/com/cultural/heritage/model/dto/snapshot/GoodSnapshot.java @@ -5,6 +5,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data @Schema(description = "订单商品信息", requiredProperties = {"name", "type", "price", "goodImg", "festivalOrder", "reserveDate"}) @@ -27,7 +28,7 @@ public class GoodSnapshot implements Serializable { * 商品价格 */ @Schema(description = "商品价格", example = "200.00") - private Double price; + private BigDecimal price; /** * 商品图片 diff --git a/src/main/java/com/cultural/heritage/model/entity/AdvanceOrder.java b/src/main/java/com/cultural/heritage/model/entity/AdvanceOrder.java index f809eb0..12e85cd 100644 --- a/src/main/java/com/cultural/heritage/model/entity/AdvanceOrder.java +++ b/src/main/java/com/cultural/heritage/model/entity/AdvanceOrder.java @@ -10,6 +10,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; /** @@ -42,7 +43,7 @@ public class AdvanceOrder implements Serializable { /** * 定金 */ - private Double deposit; + private BigDecimal deposit; /** diff --git a/src/main/java/com/cultural/heritage/model/entity/CartRecord.java b/src/main/java/com/cultural/heritage/model/entity/CartRecord.java index 9dc2a09..0440648 100644 --- a/src/main/java/com/cultural/heritage/model/entity/CartRecord.java +++ b/src/main/java/com/cultural/heritage/model/entity/CartRecord.java @@ -7,6 +7,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; /** @@ -42,7 +43,7 @@ public class CartRecord implements Serializable { /** * 小计 */ - private Double subtotal; + private BigDecimal subtotal; /** diff --git a/src/main/java/com/cultural/heritage/model/entity/ClothesGrade.java b/src/main/java/com/cultural/heritage/model/entity/ClothesGrade.java index a5df2db..3f485f4 100644 --- a/src/main/java/com/cultural/heritage/model/entity/ClothesGrade.java +++ b/src/main/java/com/cultural/heritage/model/entity/ClothesGrade.java @@ -7,6 +7,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; /** @@ -41,13 +42,13 @@ public class ClothesGrade implements Serializable { /** * 最低价格 */ - private Double minPrice; + private BigDecimal minPrice; /** * 最高价格 */ - private Double maxPrice; + private BigDecimal maxPrice; /** diff --git a/src/main/java/com/cultural/heritage/model/entity/ClothesInfo.java b/src/main/java/com/cultural/heritage/model/entity/ClothesInfo.java index c2dda06..530a7ec 100644 --- a/src/main/java/com/cultural/heritage/model/entity/ClothesInfo.java +++ b/src/main/java/com/cultural/heritage/model/entity/ClothesInfo.java @@ -7,6 +7,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; /** @@ -53,7 +54,7 @@ public class ClothesInfo implements Serializable { /** * 服装价格 */ - private Double price; + private BigDecimal price; /** diff --git a/src/main/java/com/cultural/heritage/model/entity/Coupon.java b/src/main/java/com/cultural/heritage/model/entity/Coupon.java index 26bac2b..40e259b 100644 --- a/src/main/java/com/cultural/heritage/model/entity/Coupon.java +++ b/src/main/java/com/cultural/heritage/model/entity/Coupon.java @@ -10,6 +10,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; /** @@ -34,7 +35,7 @@ public class Coupon implements Serializable { /** * 满减金额 */ - private Double conditionAmount; + private BigDecimal conditionAmount; /** diff --git a/src/main/java/com/cultural/heritage/model/entity/Good.java b/src/main/java/com/cultural/heritage/model/entity/Good.java index 3b88d8f..3c29abb 100644 --- a/src/main/java/com/cultural/heritage/model/entity/Good.java +++ b/src/main/java/com/cultural/heritage/model/entity/Good.java @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.io.Serial; +import java.math.BigDecimal; import java.util.Date; /** @@ -37,7 +38,7 @@ public class Good { /** * 商品价格 */ - private Double price; + private BigDecimal price; /** * 商品图片 diff --git a/src/main/java/com/cultural/heritage/model/entity/Order.java b/src/main/java/com/cultural/heritage/model/entity/Order.java index 9c64112..df57b34 100644 --- a/src/main/java/com/cultural/heritage/model/entity/Order.java +++ b/src/main/java/com/cultural/heritage/model/entity/Order.java @@ -14,6 +14,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; @@ -80,7 +81,7 @@ public class Order implements Serializable { /** * 订单总金额 */ - private Double totalAmount; + private BigDecimal totalAmount; /** diff --git a/src/main/java/com/cultural/heritage/model/entity/OrderItems.java b/src/main/java/com/cultural/heritage/model/entity/OrderItems.java index c9279cc..c0713a1 100644 --- a/src/main/java/com/cultural/heritage/model/entity/OrderItems.java +++ b/src/main/java/com/cultural/heritage/model/entity/OrderItems.java @@ -11,6 +11,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; /** * 订单明细 @@ -47,7 +48,7 @@ public class OrderItems implements Serializable { * 商品单价快照 */ @Schema(description = "商品单价", example = "15.00") - private Double priceSnapshot; + private BigDecimal priceSnapshot; /** @@ -61,7 +62,7 @@ public class OrderItems implements Serializable { * 订单项金额(单价 * 数量) */ @Schema(description = "订单项金额(单价 * 数量)", example = "55.00") - private Double itemTotalAmount; + private BigDecimal itemTotalAmount; /** * 预约日期 diff --git a/src/main/java/com/cultural/heritage/model/vo/advanceorder/AdvanceOrderVO.java b/src/main/java/com/cultural/heritage/model/vo/advanceorder/AdvanceOrderVO.java index bc719ac..9b16c03 100644 --- a/src/main/java/com/cultural/heritage/model/vo/advanceorder/AdvanceOrderVO.java +++ b/src/main/java/com/cultural/heritage/model/vo/advanceorder/AdvanceOrderVO.java @@ -6,6 +6,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; @Data @@ -33,7 +34,7 @@ public class AdvanceOrderVO implements Serializable { /** * 定金 */ - private Double deposit; + private BigDecimal deposit; /** diff --git a/src/main/java/com/cultural/heritage/model/vo/cart/CartRecordVO.java b/src/main/java/com/cultural/heritage/model/vo/cart/CartRecordVO.java index db228ed..143cd75 100644 --- a/src/main/java/com/cultural/heritage/model/vo/cart/CartRecordVO.java +++ b/src/main/java/com/cultural/heritage/model/vo/cart/CartRecordVO.java @@ -5,6 +5,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data public class CartRecordVO implements Serializable { @@ -33,7 +34,7 @@ public class CartRecordVO implements Serializable { /** * 小计 */ - private Double subtotal; + private BigDecimal subtotal; /** diff --git a/src/main/java/com/cultural/heritage/model/vo/clothesgrade/ClothesGradeVO.java b/src/main/java/com/cultural/heritage/model/vo/clothesgrade/ClothesGradeVO.java index f7a8179..d2b6c11 100644 --- a/src/main/java/com/cultural/heritage/model/vo/clothesgrade/ClothesGradeVO.java +++ b/src/main/java/com/cultural/heritage/model/vo/clothesgrade/ClothesGradeVO.java @@ -4,6 +4,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data public class ClothesGradeVO implements Serializable { @@ -30,13 +31,13 @@ public class ClothesGradeVO implements Serializable { /** * 最低价格 */ - private Double minPrice; + private BigDecimal minPrice; /** * 最高价格 */ - private Double maxPrice; + private BigDecimal maxPrice; /** diff --git a/src/main/java/com/cultural/heritage/model/vo/clothesinfo/ClothesInfoLabelVO.java b/src/main/java/com/cultural/heritage/model/vo/clothesinfo/ClothesInfoLabelVO.java index 7ec8c79..2985d15 100644 --- a/src/main/java/com/cultural/heritage/model/vo/clothesinfo/ClothesInfoLabelVO.java +++ b/src/main/java/com/cultural/heritage/model/vo/clothesinfo/ClothesInfoLabelVO.java @@ -4,6 +4,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data public class ClothesInfoLabelVO implements Serializable { @@ -35,7 +36,7 @@ public class ClothesInfoLabelVO implements Serializable { /** * 服装价格 */ - private Double price; + private BigDecimal price; diff --git a/src/main/java/com/cultural/heritage/model/vo/clothesinfo/ClothesInfoVO.java b/src/main/java/com/cultural/heritage/model/vo/clothesinfo/ClothesInfoVO.java index 341c012..870b6bc 100644 --- a/src/main/java/com/cultural/heritage/model/vo/clothesinfo/ClothesInfoVO.java +++ b/src/main/java/com/cultural/heritage/model/vo/clothesinfo/ClothesInfoVO.java @@ -4,6 +4,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data public class ClothesInfoVO implements Serializable { @@ -42,7 +43,7 @@ public class ClothesInfoVO implements Serializable { /** * 服装价格 */ - private Double price; + private BigDecimal price; /** diff --git a/src/main/java/com/cultural/heritage/model/vo/good/GoodVO.java b/src/main/java/com/cultural/heritage/model/vo/good/GoodVO.java index b2a97f4..9162119 100644 --- a/src/main/java/com/cultural/heritage/model/vo/good/GoodVO.java +++ b/src/main/java/com/cultural/heritage/model/vo/good/GoodVO.java @@ -4,6 +4,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data public class GoodVO implements Serializable { @@ -26,7 +27,7 @@ public class GoodVO implements Serializable { /** * 商品价格 */ - private Double price; + private BigDecimal price; /** * 商品图片 diff --git a/src/main/java/com/cultural/heritage/model/vo/good/ServiceGoodCardVO.java b/src/main/java/com/cultural/heritage/model/vo/good/ServiceGoodCardVO.java index 2489c7d..2729cbb 100644 --- a/src/main/java/com/cultural/heritage/model/vo/good/ServiceGoodCardVO.java +++ b/src/main/java/com/cultural/heritage/model/vo/good/ServiceGoodCardVO.java @@ -4,6 +4,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; @Data public class ServiceGoodCardVO implements Serializable { @@ -26,7 +27,7 @@ public class ServiceGoodCardVO implements Serializable { /** * 商品价格 */ - private Double price; + private BigDecimal price; /** * 商品图片 diff --git a/src/main/java/com/cultural/heritage/model/vo/order/OrderVO.java b/src/main/java/com/cultural/heritage/model/vo/order/OrderVO.java index d194fe5..3429cb6 100644 --- a/src/main/java/com/cultural/heritage/model/vo/order/OrderVO.java +++ b/src/main/java/com/cultural/heritage/model/vo/order/OrderVO.java @@ -10,6 +10,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -64,7 +65,7 @@ public class OrderVO implements Serializable { /** * 订单总金额 */ - private Double totalAmount; + private BigDecimal totalAmount; /** * 订单状态 diff --git a/src/main/java/com/cultural/heritage/service/book/impl/AdvanceOrderServiceImpl.java b/src/main/java/com/cultural/heritage/service/book/impl/AdvanceOrderServiceImpl.java index 27d4dea..c7cce69 100644 --- a/src/main/java/com/cultural/heritage/service/book/impl/AdvanceOrderServiceImpl.java +++ b/src/main/java/com/cultural/heritage/service/book/impl/AdvanceOrderServiceImpl.java @@ -16,6 +16,8 @@ import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import java.math.BigDecimal; + @Service public class AdvanceOrderServiceImpl extends ServiceImpl implements AdvanceOrderService { @@ -27,7 +29,7 @@ public class AdvanceOrderServiceImpl extends ServiceImpl getQueryWrapper(AdvanceOrderQueryRequest advanceOrderQueryRequest) { Long id = advanceOrderQueryRequest.getId(); String type = advanceOrderQueryRequest.getType(); - Double minDeposit = advanceOrderQueryRequest.getMinDeposit(); - Double maxDeposit = advanceOrderQueryRequest.getMaxDeposit(); + BigDecimal minDeposit = advanceOrderQueryRequest.getMinDeposit(); + BigDecimal maxDeposit = advanceOrderQueryRequest.getMaxDeposit(); String startTime = advanceOrderQueryRequest.getStartTime(); String endTime = advanceOrderQueryRequest.getEndTime(); String orderStatus = advanceOrderQueryRequest.getOrderStatus(); diff --git a/src/main/java/com/cultural/heritage/service/book/impl/ClothesGradeServiceImpl.java b/src/main/java/com/cultural/heritage/service/book/impl/ClothesGradeServiceImpl.java index ecdd308..1e09f60 100644 --- a/src/main/java/com/cultural/heritage/service/book/impl/ClothesGradeServiceImpl.java +++ b/src/main/java/com/cultural/heritage/service/book/impl/ClothesGradeServiceImpl.java @@ -15,6 +15,7 @@ import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.List; @Service @@ -33,8 +34,8 @@ public class ClothesGradeServiceImpl extends ServiceImpl= maxPrice) { + if (minPrice.compareTo(BigDecimal.ZERO) >= maxPrice.compareTo(BigDecimal.ZERO)) { throw new BusinessException(ErrorCode.PARAMS_ERROR, "最低价格不能高于最高价格"); } if (StringUtils.isAnyBlank(clothesType, image, brief)) { diff --git a/src/main/java/com/cultural/heritage/service/book/impl/ClothesInfoServiceImpl.java b/src/main/java/com/cultural/heritage/service/book/impl/ClothesInfoServiceImpl.java index ce4cb34..46698bb 100644 --- a/src/main/java/com/cultural/heritage/service/book/impl/ClothesInfoServiceImpl.java +++ b/src/main/java/com/cultural/heritage/service/book/impl/ClothesInfoServiceImpl.java @@ -14,6 +14,8 @@ import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import java.math.BigDecimal; + @Service public class ClothesInfoServiceImpl extends ServiceImpl implements ClothesInfoService { @@ -28,7 +30,7 @@ public class ClothesInfoServiceImpl extends ServiceImpl getQueryWrapper(ClothesInfoQueryRequest clothesInfoQueryRequest) { Long id = clothesInfoQueryRequest.getId(); String name = clothesInfoQueryRequest.getName(); - Double minPrice = clothesInfoQueryRequest.getMinPrice(); - Double maxPrice = clothesInfoQueryRequest.getMaxPrice(); + BigDecimal minPrice = clothesInfoQueryRequest.getMinPrice(); + BigDecimal maxPrice = clothesInfoQueryRequest.getMaxPrice(); String clothesType = clothesInfoQueryRequest.getClothesType(); String sortField = clothesInfoQueryRequest.getSortField(); String sortOrder = clothesInfoQueryRequest.getSortOrder(); diff --git a/src/main/java/com/cultural/heritage/service/good/impl/CartRecordServiceImpl.java b/src/main/java/com/cultural/heritage/service/good/impl/CartRecordServiceImpl.java index ba2a46a..44f416b 100644 --- a/src/main/java/com/cultural/heritage/service/good/impl/CartRecordServiceImpl.java +++ b/src/main/java/com/cultural/heritage/service/good/impl/CartRecordServiceImpl.java @@ -22,6 +22,7 @@ import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.List; @Service @@ -53,7 +54,7 @@ public class CartRecordServiceImpl extends ServiceImpl impleme public void validCoupon(Coupon coupon, boolean update) { Long id = coupon.getId(); String name = coupon.getName(); - Double conditionAmount = coupon.getConditionAmount(); + BigDecimal conditionAmount = coupon.getConditionAmount(); Integer requirePoints = coupon.getRequirePoints(); Integer totalNum = coupon.getTotalNum(); Integer residueNum = coupon.getResidueNum(); @@ -70,7 +71,7 @@ public class CouponServiceImpl extends ServiceImpl impleme throw new BusinessException(ErrorCode.PARAMS_ERROR, "参数id错误"); } } - if (ObjectUtils.isEmpty(conditionAmount) || conditionAmount <= 0) { + if (ObjectUtils.isEmpty(conditionAmount) || conditionAmount.compareTo(BigDecimal.ZERO) <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR, "满减价格错误"); } if (ObjectUtils.isEmpty(requirePoints) || requirePoints <= 0) { diff --git a/src/main/java/com/cultural/heritage/service/good/impl/GoodServiceImpl.java b/src/main/java/com/cultural/heritage/service/good/impl/GoodServiceImpl.java index 19ee854..4f958a0 100644 --- a/src/main/java/com/cultural/heritage/service/good/impl/GoodServiceImpl.java +++ b/src/main/java/com/cultural/heritage/service/good/impl/GoodServiceImpl.java @@ -15,6 +15,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; @@ -79,7 +80,7 @@ public class GoodServiceImpl extends ServiceImpl implements Go String label = good.getLabel(); Integer inventory = good.getInventory(); Integer festivalOrder = good.getFestivalOrder(); - Double price = good.getPrice(); + BigDecimal price = good.getPrice(); if (update) { if (id == null) { @@ -95,7 +96,7 @@ public class GoodServiceImpl extends ServiceImpl implements Go if (ObjectUtils.isEmpty(festivalOrder) || festivalOrder <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR, "节日参数错误"); } - if (ObjectUtils.isEmpty(price) || price <= 0) { + if (ObjectUtils.isEmpty(price) || price.compareTo(BigDecimal.ZERO) <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR, "商品价格不能小于等于0"); } diff --git a/src/main/java/com/cultural/heritage/service/order/impl/OrderServiceImpl.java b/src/main/java/com/cultural/heritage/service/order/impl/OrderServiceImpl.java index c0712af..9f78265 100644 --- a/src/main/java/com/cultural/heritage/service/order/impl/OrderServiceImpl.java +++ b/src/main/java/com/cultural/heritage/service/order/impl/OrderServiceImpl.java @@ -27,6 +27,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -61,8 +62,8 @@ public class OrderServiceImpl extends ServiceImpl implements } Long userId = orderQueryRequest.getUserId(); Long orderId = orderQueryRequest.getOrderId(); - Double minTotalAmount = orderQueryRequest.getMinTotalAmount(); - Double maxTotalAmount = orderQueryRequest.getMaxTotalAmount(); + BigDecimal minTotalAmount = orderQueryRequest.getMinTotalAmount(); + BigDecimal maxTotalAmount = orderQueryRequest.getMaxTotalAmount(); String orderStatus = orderQueryRequest.getOrderStatus(); String orderNumber = orderQueryRequest.getOrderNumber(); Date startTime = orderQueryRequest.getStartTime(); @@ -99,7 +100,7 @@ public class OrderServiceImpl extends ServiceImpl implements String orderNumber = orderMainInfoAddRequest.getOrderNumber(); String orderStatus = orderMainInfoAddRequest.getOrderStatus(); String note = orderMainInfoAddRequest.getNote(); - Double totalAmount = orderMainInfoAddRequest.getTotalAmount(); + BigDecimal totalAmount = orderMainInfoAddRequest.getTotalAmount(); List orderItemMainInfoAddRequestList = orderMainInfoAddRequest.getOrderItemMainInfoAddRequestList(); @@ -134,7 +135,7 @@ public class OrderServiceImpl extends ServiceImpl implements orderItemAddRequest.setGoodSnapshot(goodSnapshot); orderItemAddRequest.setPriceSnapshot(goodSnapshot.getPrice()); orderItemAddRequest.setQuantity(quantity); - orderItemAddRequest.setItemTotalAmount(goodSnapshot.getPrice() * quantity); + orderItemAddRequest.setItemTotalAmount(goodSnapshot.getPrice().multiply(BigDecimal.valueOf(quantity))); orderItemAddRequest.setReservationDate(reservationDate); orderItemAddRequest.setTimeSlot(timeSlot); return orderItemAddRequest; @@ -166,9 +167,9 @@ public class OrderServiceImpl extends ServiceImpl implements String orderNumber = order.getOrderNumber(); Long userId = order.getUserId(); String userName = order.getUserName(); - Double totalAmount = order.getTotalAmount(); + BigDecimal totalAmount = order.getTotalAmount(); String orderStatus = order.getOrderStatus(); - if (ObjectUtils.isEmpty(totalAmount) || totalAmount <= 0) { + if (ObjectUtils.isEmpty(totalAmount) || totalAmount.compareTo(BigDecimal.ZERO) <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR, "价格错误"); } if (ObjectUtils.isEmpty(userId)) { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 7bcc45c..0bb2203 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,17 +1,17 @@ spring: datasource: # 生产环境 -# driver-class-name: com.mysql.cj.jdbc.Driver -# url: jdbc:mysql://154.8.193.216:3306/feiyi?serverTimezone=Asia/Shanghai -# username: feiyi -# password: 123456asd - -# 测试环境 driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://123.249.108.160:3306/feiyi?serverTimezone=Asia/Shanghai + url: jdbc:mysql://154.8.193.216:3306/feiyi?serverTimezone=Asia/Shanghai username: feiyi password: 123456asd +# 测试环境 +# driver-class-name: com.mysql.cj.jdbc.Driver +# url: jdbc:mysql://123.249.108.160:3306/feiyi?serverTimezone=Asia/Shanghai +# username: feiyi +# password: 123456asd + hikari: max-lifetime: 120000 data: diff --git a/src/test/java/com/cultural/heritage/test/Test.java b/src/test/java/com/cultural/heritage/test/Test.java index df80011..83b876b 100644 --- a/src/test/java/com/cultural/heritage/test/Test.java +++ b/src/test/java/com/cultural/heritage/test/Test.java @@ -1,5 +1,7 @@ package com.cultural.heritage.test; +import java.math.BigDecimal; + public class Test { public static void main(String[] args) { // Date date = new Date(); @@ -22,5 +24,8 @@ public class Test { // System.out.println(StringUtils.isAnyBlank("333", "333", null, "dfs")); // System.out.println(StringUtils.isAnyBlank(null)); // System.out.println(ObjectUtils.anyNull(null)); + Integer quantity = 10; + BigDecimal bigDecimal = BigDecimal.valueOf(quantity); + System.out.println(bigDecimal); } }