소스 검색

订单缓存优化

Bob 1 주 전
부모
커밋
a41913c780

+ 6 - 4
pdf-office-payment/src/main/java/cn/kdan/cloud/pdf/office/payment/service/impl/OrderServiceImpl.java

@@ -201,7 +201,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             key = "T(String).valueOf(#createUserOrderDTO.userId)" +
                     ".concat('-').concat(#createUserOrderDTO.productId)" +
                     ".concat('-').concat(#createUserOrderDTO.paymentMethod)" +
-                    ".concat('-').concat(#createUserOrderDTO.num)",
+                    ".concat('-').concat(#createUserOrderDTO.num)" +
+                    ".concat('-').concat(#createUserOrderDTO.discountFlag)",
             cacheManager = "myRedisCacheManager", unless = "#result == null")
     public Map<String, String> createUserOrder(CreateUserOrderDTO createUserOrderDTO) {
         UserVO userVO = userApi.getById(createUserOrderDTO.getUserId()).getResult();
@@ -341,7 +342,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             key = "T(String).valueOf(#createUserOrderDTO.userId)" +
                     ".concat('-').concat(#createUserOrderDTO.productId)" +
                     ".concat('-').concat(#createUserOrderDTO.paymentMethod)" +
-                    ".concat('-').concat(#createUserOrderDTO.num)",
+                    ".concat('-').concat(#createUserOrderDTO.num)" +
+                    ".concat('-').concat(#createUserOrderDTO.discountFlag)",
             cacheManager = "myRedisCacheManager", unless = "#result == null")
     public Map<String, String> createUserSubscription(CreateUserOrderDTO createUserOrderDTO) {
         UserVO userVO = userApi.getById(createUserOrderDTO.getUserId()).getResult();
@@ -546,7 +548,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         //删除缓存中的订单
         deleteTheCacheInTheCacheManager(orders.getEmail() + "-" + orders.getProductId() + "-" + orders.getPayment());
         // 会员订单,通过userId
-        deleteTheCacheInTheCacheManager(orders.getUserId() + "-" + orders.getProductId() + "-" + orders.getPayment() + "-" + orders.getPayNumber());
+        deleteTheCacheInTheCacheManager(orders.getUserId() + "-" + orders.getProductId() + "-" + orders.getPayment() + "-" + orders.getPayNumber() + "-" + orders.getDiscountType());
         // 检查订单优惠券
         productApi.refundCouponByOrderId(orderId);
     }
@@ -567,7 +569,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                 this.baseMapper.updateById(order);
             }
             //删除缓存中的订单
-            deleteTheCacheInTheCacheManager(orders.getUserId() + "-" + orders.getProductId() + "-" + orders.getPayment() + "-" + orders.getPayNumber());
+            deleteTheCacheInTheCacheManager(orders.getUserId() + "-" + orders.getProductId() + "-" + orders.getPayment() + "-" + orders.getPayNumber() + "-" + orders.getDiscountType());
             // 检查订单优惠券
             productApi.refundCouponByOrderId(orders.getId());
         }

+ 1 - 1
pdf-office-payment/src/main/java/cn/kdan/cloud/pdf/office/payment/service/impl/PayCenterWebhookServiceImpl.java

@@ -323,7 +323,7 @@ public class PayCenterWebhookServiceImpl implements PayCenterWebhookService {
                         }
                     }
                     //删除缓存中的订单
-                    ordersService.deleteTheCacheInTheCacheManager(ordersVO.getUserId() + "-" + ordersVO.getProductId() + "-" + ordersVO.getPayment() + "-" + ordersVO.getPayNumber());
+                    ordersService.deleteTheCacheInTheCacheManager(ordersVO.getUserId() + "-" + ordersVO.getProductId() + "-" + ordersVO.getPayment() + "-" + ordersVO.getPayNumber() + "-" + ordersVO.getDiscountType());
                     // 关闭用户同类型订单
                     ordersService.closeOrderByUser(ordersVO.getUserId(), productVO.getPlatform());
                     if (emailFlag) {

+ 2 - 2
pdf-office-pdf-website/src/main/java/cn/kdan/cloud/pdf/office/website/service/impl/OrderServiceImpl.java

@@ -134,7 +134,7 @@ public class OrderServiceImpl implements OrderService {
 //                log.error("升级购买价格校验失败,商品id:{},用户id:{},升级价格:{},用户传入价格:{}", createOrderDTO.getProductId(), createOrderDTO.getUserId(), productPriceForBuy.getUpgradePrice(), createOrderDTO.getPrice());
 //                throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_PRICE_ERROR);
 //            }
-            } else if (createOrderDTO.getDiscountFlag() == 1) {
+            } else if (createOrderDTO.getDiscountFlag() == 1 || createOrderDTO.getDiscountFlag() == 11) {
                 if (createOrderDTO.getCouponCode() == null) {
                     log.error("优惠券校验失败,优惠券为空,{}", createOrderDTO);
                     throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_NOT_EXISTS);
@@ -252,7 +252,7 @@ public class OrderServiceImpl implements OrderService {
         }
         // 优惠券
         boolean couponFlag = false;
-        if (createOrderDTO.getDiscountFlag() == 1) {
+        if (createOrderDTO.getDiscountFlag() == 1 || createOrderDTO.getDiscountFlag() == 11) {
             if (createOrderDTO.getCouponCode() == null) {
                 log.error("优惠券校验失败,优惠券为空,{}", createOrderDTO);
                 throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_NOT_EXISTS);