From 30702deba764d7fc080516f767a6756598c02273 Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Thu, 3 Apr 2025 16:45:13 +0800 Subject: [PATCH] this is 4.2 update --- .../controller/global/GlobalController.java | 49 +++++++++++++++++-- .../controller/order/OrderController.java | 3 +- .../model/dto/cart/CartOrderAddRequest.java | 8 ++- .../model/dto/order/OrderAddRequest.java | 8 +++ .../GeneralGoodSingleBuyAddRequest.java | 9 +++- .../capital/OrderMainInfoAddRequest.java | 9 +++- .../cultural/heritage/model/entity/Order.java | 7 +++ .../heritage/model/vo/order/OrderVO.java | 4 ++ .../service/order/impl/OrderServiceImpl.java | 30 +++++++++++- src/main/resources/application-dev.yml | 14 ++---- src/main/resources/application-prod.yml | 6 +-- src/main/resources/application.yml | 2 +- 12 files changed, 123 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/cultural/heritage/controller/global/GlobalController.java b/src/main/java/com/cultural/heritage/controller/global/GlobalController.java index 4c94f5d..5e91b7e 100644 --- a/src/main/java/com/cultural/heritage/controller/global/GlobalController.java +++ b/src/main/java/com/cultural/heritage/controller/global/GlobalController.java @@ -89,12 +89,15 @@ public class GlobalController { private RedisTemplate redisTemplate; - // 节日集合的键 + // 优惠价格的键 private static final String COUPON_PRICER_KEY = "couponPrice"; // 预约须知的键 private static final String NOTICE_KEY = "noticeKey"; + // 邮费价格的键 + private static final String POSTAGE_PRICER_KEY = "postagePrice"; + /** @@ -279,6 +282,7 @@ public class GlobalController { conditions.put("isShelves", 1); List goodList = commonService.findByFieldEqTargetFields(conditions, goodService); List goodLabelVOS = commonService.convertList(goodList, GoodLabelVO.class); + Collections.reverse(goodLabelVOS); Map map = new HashMap<>(); for (GoodLabelVO goodLabelVO : goodLabelVOS) { @@ -308,7 +312,7 @@ public class GlobalController { /** * web端管理员修改商品优惠价格参数 - * @return 当前类别的商品列表 + * @return 优惠价格 */ @GetMapping("/update/coupon/price") @Operation(summary = "web端管理员修改商品优惠价格参数", description = "参数:无,方法名:updateCouponPrice") @@ -325,7 +329,7 @@ public class GlobalController { /** * web端(小程序端)查看商品优惠价格参数 - * @return 当前类别的商品列表 + * @return 优惠价格 */ @GetMapping("/query/coupon/price") @Operation(summary = "web端(小程序端)查看商品优惠价格参数", description = "参数:无,方法名:queryCouponPrice") @@ -342,7 +346,7 @@ public class GlobalController { /** * web端更新预约须知 - * @return 当前类别的商品列表 + * @return 预约须知 */ @GetMapping("/update/notice") @Operation(summary = "web端更新预约须知", description = "参数:无,方法名:updateNotice") @@ -359,7 +363,7 @@ public class GlobalController { /** * 小程序端预约须知 - * @return 当前类别的商品列表 + * @return 预约须知 */ @GetMapping("/query/notice") @Operation(summary = "web端更新预约须知", description = "参数:无,方法名:queryNotice") @@ -378,4 +382,39 @@ public class GlobalController { + + + /** + * web端管理员修改邮费参数 + * @return 邮费价格 + */ + @GetMapping("/update/postage/price") + @Operation(summary = "web端管理员修改邮费参数", description = "参数:无,方法名:updatePostagePrice") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + public BaseResponse updatePostagePrice(@RequestParam BigDecimal bigDecimal) { + + redisTemplate.opsForValue().set(POSTAGE_PRICER_KEY, bigDecimal.toString()); + + return ResultUtils.success(true); + } + + + + + /** + * web端(小程序端)查看邮费价格参数 + * @return 邮费价格 + */ + @GetMapping("/query/postage/price") + @Operation(summary = "web端(小程序端)查看邮费价格参数", description = "参数:无,方法名:queryPostagePrice") + public BaseResponse queryPostagePrice() { + + String postagePrice = (String) redisTemplate.opsForValue().get(POSTAGE_PRICER_KEY); + ThrowUtils.throwIf(postagePrice == null, ErrorCode.OPERATION_ERROR, "参数不存在"); + + return ResultUtils.success(new BigDecimal(postagePrice).setScale(2, RoundingMode.HALF_UP)); + } + + + } diff --git a/src/main/java/com/cultural/heritage/controller/order/OrderController.java b/src/main/java/com/cultural/heritage/controller/order/OrderController.java index 2a336ba..172d5b3 100644 --- a/src/main/java/com/cultural/heritage/controller/order/OrderController.java +++ b/src/main/java/com/cultural/heritage/controller/order/OrderController.java @@ -128,8 +128,7 @@ public class OrderController { orderService.validSingleGoodOrder(generalGoodSingleBuyAddRequest, isGeneral); // 封装成订单主要信息请求体 - OrderMainInfoAddRequest orderMainInfoAddRequest = new OrderMainInfoAddRequest(); - BeanUtils.copyProperties(generalGoodSingleBuyAddRequest, orderMainInfoAddRequest); + OrderMainInfoAddRequest orderMainInfoAddRequest = commonService.copyProperties(generalGoodSingleBuyAddRequest, OrderMainInfoAddRequest.class); // 计算单个商品购买的总金额 BigDecimal totalAmount = orderService.calculateTotalAmount(orderMainInfoAddRequest); diff --git a/src/main/java/com/cultural/heritage/model/dto/cart/CartOrderAddRequest.java b/src/main/java/com/cultural/heritage/model/dto/cart/CartOrderAddRequest.java index 3e97d7a..870cdf8 100644 --- a/src/main/java/com/cultural/heritage/model/dto/cart/CartOrderAddRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/cart/CartOrderAddRequest.java @@ -9,7 +9,7 @@ import java.util.List; @Data @Schema(description = "购物车订单创建请求体", requiredProperties = {"orderType", "userName", "addressId", - "couponId", "totalAmount", "note", "cartPayRequestList"}) + "couponId", "totalAmount", "note", "cartPayRequestList", "isPostage"}) public class CartOrderAddRequest implements Serializable { @@ -41,6 +41,12 @@ public class CartOrderAddRequest implements Serializable { private Long couponId; + /** + * 是否有邮费 + */ + @Schema(description = "是否有邮费", example = "true") + private Boolean isPostage; + /** * 订单备注 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 e8dbb40..2e328a3 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 @@ -58,6 +58,14 @@ public class OrderAddRequest implements Serializable { @Schema(description = "订单总金额", example = "500") private BigDecimal totalAmount; + + /** + * 邮费 + */ + @Schema(description = "邮费", example = "50") + private BigDecimal postage; + + /** * 订单状态 */ diff --git a/src/main/java/com/cultural/heritage/model/dto/order/capital/GeneralGoodSingleBuyAddRequest.java b/src/main/java/com/cultural/heritage/model/dto/order/capital/GeneralGoodSingleBuyAddRequest.java index 2ed41f8..1fbb58c 100644 --- a/src/main/java/com/cultural/heritage/model/dto/order/capital/GeneralGoodSingleBuyAddRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/order/capital/GeneralGoodSingleBuyAddRequest.java @@ -10,7 +10,7 @@ import java.util.List; @Data @Schema(description = "常规类商品单独购买创建请求体", requiredProperties = {"userId", "userName", "orderNumber", "addressId", "contactsId", - "couponId", "orderStatus", "note", "orderItemMainInfoAddRequestList"}) + "couponId", "orderStatus", "isPostage", "note", "orderItemMainInfoAddRequestList"}) public class GeneralGoodSingleBuyAddRequest implements Serializable { @@ -49,6 +49,13 @@ public class GeneralGoodSingleBuyAddRequest implements Serializable { private Long couponId; + /** + * 是否有邮费 + */ + @Schema(description = "是否有邮费", example = "true") + private Boolean isPostage; + + /** * 订单备注 */ 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 5a2d4ee..7e3a4d6 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 @@ -10,7 +10,7 @@ import java.util.List; @Data @Schema(description = "订单主要信息请求体", requiredProperties = {"userName", "addressId", "contactsId", -"couponId", "totalAmount", "orderStatus", "note", "orderItemMainInfoAddRequestList"}) +"couponId", "totalAmount", "orderStatus", "note", "orderItemMainInfoAddRequestList", "isPostage"}) public class OrderMainInfoAddRequest implements Serializable { @@ -56,6 +56,13 @@ public class OrderMainInfoAddRequest implements Serializable { private BigDecimal totalAmount; + /** + * 是否有邮费 + */ + @Schema(description = "是否有邮费", example = "true") + private Boolean isPostage; + + /** * 订单备注 */ 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 9871f1e..0724b24 100644 --- a/src/main/java/com/cultural/heritage/model/entity/Order.java +++ b/src/main/java/com/cultural/heritage/model/entity/Order.java @@ -100,6 +100,13 @@ public class Order implements Serializable { */ private String trackingNumber; + + /** + * 邮费 + */ + private BigDecimal postage; + + /** * 创建时间 */ 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 599ce09..4f176ef 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 @@ -82,6 +82,10 @@ public class OrderVO implements Serializable { */ private String trackingNumber; + /** + * 邮费 + */ + private BigDecimal postage; /** * 订单明细信息 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 b5be15b..10febb0 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 @@ -37,16 +37,20 @@ import com.cultural.heritage.utils.MultiDelayMessage; import com.cultural.heritage.utils.OrderNumberUtils; import com.cultural.heritage.utils.SqlUtils; import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.BeanUtils; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.*; @Service +@Slf4j public class OrderServiceImpl extends ServiceImpl implements OrderService { @@ -102,6 +106,15 @@ public class OrderServiceImpl extends ServiceImpl implements private PendingServiceOrderService pendingServiceOrderService; + @Resource + private RedisTemplate redisTemplate; + + + // 邮费价格的键 + private static final String POSTAGE_PRICER_KEY = "postagePrice"; + + + /** * 获取查询条件 */ @@ -149,9 +162,9 @@ public class OrderServiceImpl extends ServiceImpl implements String orderType = orderMainInfoAddRequest.getOrderType(); String note = orderMainInfoAddRequest.getNote(); BigDecimal totalAmount = orderMainInfoAddRequest.getTotalAmount(); + Boolean isPostage = orderMainInfoAddRequest.getIsPostage(); List orderItemMainInfoAddRequestList = orderMainInfoAddRequest.getOrderItemMainInfoAddRequestList(); - GoodTypeEnum orderTypeEnum = GoodTypeEnum.getEnumByValue(orderType); ThrowUtils.throwIf(orderTypeEnum == null, ErrorCode.PARAMS_ERROR); AddressSnapshot addressSnapshot = null; @@ -175,6 +188,20 @@ public class OrderServiceImpl extends ServiceImpl implements BeanUtils.copyProperties(couponVO, couponSnapshot); couponSnapshot.setId(couponId); } + + // 获取邮费 + BigDecimal postage = new BigDecimal("0.00"); + try { + // 判断是否有邮费 + if (isPostage) { + String postagePrice = (String) redisTemplate.opsForValue().get(POSTAGE_PRICER_KEY); + ThrowUtils.throwIf(postagePrice == null, ErrorCode.OPERATION_ERROR, "参数不存在"); + postage = new BigDecimal(postagePrice).setScale(2, RoundingMode.HALF_UP); + } + } catch (Exception e) { + log.info("邮费参数不存在"); + } + // 封装订单明细信息 List orderItemAddRequestList = orderItemMainInfoAddRequestList.stream().map(orderItemMainInfoAddRequest -> { Long goodId = orderItemMainInfoAddRequest.getGoodId(); @@ -200,6 +227,7 @@ public class OrderServiceImpl extends ServiceImpl implements orderAddRequest.setOrderType(orderType); orderAddRequest.setNote(note); orderAddRequest.setTotalAmount(totalAmount); + orderAddRequest.setPostage(postage); orderAddRequest.setAddressSnapshot(addressSnapshot); orderAddRequest.setContactsSnapshot(contactsSnapshot); orderAddRequest.setCouponSnapshot(couponSnapshot); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index fc62e9b..9942245 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -1,21 +1,13 @@ spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://154.8.193.216:3306/feiyi?serverTimezone=Asia/Shanghai + url: jdbc:mysql://1.94.237.210:3306/feiyi-dev?serverTimezone=Asia/Shanghai username: feiyi - password: 123456asd + password: Cxzyt331 hikari: maximum-pool-size: 20 max-lifetime: 120000 -# driver-class-name: com.mysql.cj.jdbc.Driver -# url: jdbc:mysql://123.249.108.160:3306/feiyi-sc?serverTimezone=Asia/Shanghai -# username: feiyi-sc -# password: 123456asd -# hikari: -# maximum-pool-size: 20 -# max-lifetime: 120000 - rabbitmq: host: 123.249.108.160 @@ -47,7 +39,7 @@ springdoc: server: - port: 9092 + port: 9090 servlet: context-path: /api diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 481ade6..4808cb0 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -2,9 +2,9 @@ spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://123.249.108.160:3306/feiyi-sc?serverTimezone=Asia/Shanghai - username: feiyi-sc - password: 123456asd + url: jdbc:mysql://1.94.237.210:3306/feiyi-prod?serverTimezone=Asia/Shanghai + username: feiyi-prod + password: Jcfyllsyg hikari: maximum-pool-size: 20 max-lifetime: 120000 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 18684a4..1ab53e5 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: profiles: - active: prod + active: dev