Search in sources :

Example 6 with CartItemVO

use of com.whoiszxl.cqrs.response.CartItemVO in project shopzz by whoiszxl.

the class OrderServiceImpl method buildOrderItems.

private List<OrderItem> buildOrderItems(long orderId, String orderNo) {
    // 获取当前选中的购物车item列表
    CartDetailApiResponse cartDetail = cartService.getCartDetail();
    List<CartItemVO> cartItemVOList = cartDetail.getCartItemVOList();
    List<OrderItem> result = new ArrayList<>();
    for (CartItemVO item : cartItemVOList) {
        if (item.getChecked() == 1) {
            OrderItem orderItem = buildOrderItem(item);
            orderItem.setOrderId(orderId);
            orderItem.setOrderNo(orderNo);
            result.add(orderItem);
        }
    }
    return result;
}
Also used : CartDetailApiResponse(com.whoiszxl.cqrs.response.CartDetailApiResponse) OrderItem(com.whoiszxl.entity.OrderItem) ArrayList(java.util.ArrayList) CartItemVO(com.whoiszxl.cqrs.response.CartItemVO)

Example 7 with CartItemVO

use of com.whoiszxl.cqrs.response.CartItemVO in project shopzz by whoiszxl.

the class CartServiceImpl method getCartDetail.

@Override
public CartDetailApiResponse getCartDetail() {
    String memberId = AuthUtils.getStrMemberId();
    CartDetailApiResponse response = new CartDetailApiResponse();
    Map<Object, Object> cartItems = redisUtils.hGetAll(RedisKeyPrefixConstants.MEMBER_CART_PREFIX + memberId);
    if (ObjectUtils.isEmpty(cartItems)) {
        return response;
    }
    List<CartItemVO> cartItemVOList = cartItems.values().stream().map(obj -> {
        String jsonValue = (String) obj;
        return JsonUtil.fromJson(jsonValue, CartItemVO.class);
    }).collect(Collectors.toList());
    response.setCartItemVOList(cartItemVOList);
    return response;
}
Also used : CartDetailApiResponse(com.whoiszxl.cqrs.response.CartDetailApiResponse) ResponseResult(com.whoiszxl.bean.ResponseResult) CartService(com.whoiszxl.service.CartService) StatusEnum(com.whoiszxl.enums.StatusEnum) Autowired(org.springframework.beans.factory.annotation.Autowired) CartDetailApiResponse(com.whoiszxl.cqrs.response.CartDetailApiResponse) StringUtils(org.apache.commons.lang3.StringUtils) RedisKeyPrefixConstants(com.whoiszxl.constants.RedisKeyPrefixConstants) Cart(com.whoiszxl.entity.Cart) SkuFeignDTO(com.whoiszxl.dto.SkuFeignDTO) CartMapper(com.whoiszxl.mapper.CartMapper) ObjectUtils(org.apache.commons.lang3.ObjectUtils) Service(org.springframework.stereotype.Service) Map(java.util.Map) CartAddCommand(com.whoiszxl.cqrs.command.CartAddCommand) ServiceImpl(com.baomidou.mybatisplus.extension.service.impl.ServiceImpl) BoundHashOperations(org.springframework.data.redis.core.BoundHashOperations) CartItemVO(com.whoiszxl.cqrs.response.CartItemVO) JsonUtil(com.whoiszxl.utils.JsonUtil) Collectors(java.util.stream.Collectors) ProductFeignClient(com.whoiszxl.feign.ProductFeignClient) List(java.util.List) ExceptionCatcher(com.whoiszxl.exception.ExceptionCatcher) RedisUtils(com.whoiszxl.utils.RedisUtils) AuthUtils(com.whoiszxl.utils.AuthUtils) StpUtil(cn.dev33.satoken.stp.StpUtil) CartItemVO(com.whoiszxl.cqrs.response.CartItemVO)

Aggregations

CartItemVO (com.whoiszxl.cqrs.response.CartItemVO)7 CartDetailApiResponse (com.whoiszxl.cqrs.response.CartDetailApiResponse)4 ServiceImpl (com.baomidou.mybatisplus.extension.service.impl.ServiceImpl)2 ResponseResult (com.whoiszxl.bean.ResponseResult)2 SkuFeignDTO (com.whoiszxl.dto.SkuFeignDTO)2 OrderItem (com.whoiszxl.entity.OrderItem)2 ExceptionCatcher (com.whoiszxl.exception.ExceptionCatcher)2 ProductFeignClient (com.whoiszxl.feign.ProductFeignClient)2 CartService (com.whoiszxl.service.CartService)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 ObjectUtils (org.apache.commons.lang3.ObjectUtils)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Service (org.springframework.stereotype.Service)2 StpUtil (cn.dev33.satoken.stp.StpUtil)1 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)1 OrderPayTypeConstants (com.whoiszxl.constants.OrderPayTypeConstants)1 OrderStatusConstants (com.whoiszxl.constants.OrderStatusConstants)1 RedisKeyPrefixConstants (com.whoiszxl.constants.RedisKeyPrefixConstants)1