diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/CartController.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/CartController.java index 15bd6d404..04a6f0074 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/CartController.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/CartController.java @@ -25,13 +25,29 @@ public class CartController { private ICartService cartService; - @ApiOperation(value = "查询用户购物车", httpMethod = "GET") + @ApiOperation(value = "查询购物车", httpMethod = "GET") @GetMapping - public Result get() { + public Result getCart() { CartVO cart = cartService.getCart(); return Result.success(cart); } + @ApiOperation(value = "全选/全不选 购物车商品", httpMethod = "PUT") + @ApiImplicitParam(name = "checked", value = "全选/全不选", required = true, paramType = "param", dataType = "Boolean") + @PatchMapping("/_check") + public Result check(boolean checked) { + boolean result = cartService.checkAll(checked); + return Result.judge(result); + } + + @ApiOperation(value = "清空购物车", httpMethod = "DELETE") + @DeleteMapping + public Result deleteCart() { + boolean result = cartService.deleteCart(); + return Result.judge(result); + } + + @ApiOperation(value = "添加购物车商品", httpMethod = "POST") @ApiImplicitParam(name = "skuId", value = "SKU ID", required = true, paramType = "param", dataType = "Long") @PostMapping @@ -47,13 +63,6 @@ public class CartController { return Result.judge(result); } - @ApiOperation(value = "全选/全不选择购物车商品", httpMethod = "PUT") - @ApiImplicitParam(name = "checked", value = "全选/全不选", required = true, paramType = "param", dataType = "Boolean") - @PatchMapping("/batch") - public Result checkAll(boolean checked) { - boolean result = cartService.checkAll(checked); - return Result.judge(result); - } @ApiOperation(value = "删除购物车商品", httpMethod = "DELETE") @ApiImplicitParam(name = "skuId", value = "SKU ID", required = true, paramType = "param", dataType = "Long") @@ -63,10 +72,5 @@ public class CartController { return Result.judge(result); } - @ApiOperation(value = "清空购物车", httpMethod = "DELETE") - @DeleteMapping - public Result deleteCart() { - boolean result = cartService.deleteCart(); - return Result.judge(result); - } + } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/listener/OmsListener.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/listener/OmsListener.java index d256ea210..adc3ea7a8 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/listener/OmsListener.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/listener/OmsListener.java @@ -1,22 +1,16 @@ package com.youlai.mall.oms.listener; import com.rabbitmq.client.Channel; -import com.youlai.mall.oms.pojo.domain.OmsOrderItem; import com.youlai.mall.oms.service.IOrderItemService; import com.youlai.mall.oms.service.IOrderService; import com.youlai.mall.pms.api.app.PmsSkuFeignService; -import com.youlai.mall.pms.pojo.dto.SkuLockDTO; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.core.Message; import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.stereotype.Component; - import java.io.IOException; -import java.util.List; -import java.util.stream.Collectors; - /** * @author hxr @@ -29,14 +23,10 @@ import java.util.stream.Collectors; public class OmsListener { IOrderService orderService; - IOrderItemService orderItemService; - PmsSkuFeignService skuFeignService; - RabbitTemplate rabbitTemplate; - /** * 订单超时未支付,关闭订单,释放库存 */ @@ -48,6 +38,7 @@ public class OmsListener { skuFeignService.unlockStock(orderToken); } else { // 如果关单失败,则订单可能已经被处理,直接手动ACK确认消息 + // basicAck(tag,multiple),multiple为true开启批量确认,小于tag值队列中未被消费的消息一次性确认 channel.basicAck(message.getMessageProperties().getDeliveryTag(), true); } } catch (IOException e) { diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/CartServiceImpl.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/CartServiceImpl.java index 071ae8fb0..af831bca9 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/CartServiceImpl.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/CartServiceImpl.java @@ -109,6 +109,10 @@ public class CartServiceImpl implements ICartService { BoundHashOperations cartHashOperations = getCartHashOperations(); String hKey = cartItem.getSkuId() + ""; if (cartHashOperations.get(hKey) != null) { + + CartVO.CartItem cacheCartItem = (CartVO.CartItem) cartHashOperations.get(hKey); + + cartHashOperations.put(hKey, cartItem); } return true;