Search in sources :

Example 6 with ProductDto

use of com.paascloud.provider.model.dto.ProductDto in project paascloud-master by paascloud.

the class OmcCartServiceImpl method updateCartList.

@Override
public int updateCartList(List<CartProductVo> cartProductVoList) {
    logger.info("updateCartList - 更新购物车集合 cartProductVoList={}", cartProductVoList);
    LoginAuthDto loginUser = new LoginAuthDto();
    loginUser.setLoginName(GlobalConstant.Sys.SUPER_MANAGER_LOGIN_NAME);
    loginUser.setUserId(1L);
    for (CartProductVo cartProductVo : cartProductVoList) {
        Integer quantity = cartProductVo.getQuantity();
        Integer productChecked = cartProductVo.getChecked();
        Long productId = cartProductVo.getProductId();
        ProductDto productDto = mdcProductService.selectById(productId);
        if (PublicUtil.isEmpty(productDto)) {
            throw new MdcBizException(ErrorCodeEnum.MDC10021004, productId);
        }
        OmcCart omcCart = new OmcCart();
        omcCart.setUserId(loginUser.getUserId());
        omcCart.setQuantity(quantity);
        omcCart.setChecked(productChecked);
        omcCart.setProductId(productId);
        omcCart.setQuantity(quantity);
        this.saveCart(omcCart, loginUser);
    }
    return 1;
}
Also used : CartProductVo(com.paascloud.provider.model.vo.CartProductVo) MdcBizException(com.paascloud.provider.exceptions.MdcBizException) LoginAuthDto(com.paascloud.base.dto.LoginAuthDto) OmcCart(com.paascloud.provider.model.domain.OmcCart) ProductDto(com.paascloud.provider.model.dto.ProductDto)

Example 7 with ProductDto

use of com.paascloud.provider.model.dto.ProductDto in project paascloud-master by paascloud.

the class OmcOrderServiceImpl method reduceProductStock.

private void reduceProductStock(List<OmcOrderDetail> omcOrderDetailList) {
    for (OmcOrderDetail orderItem : omcOrderDetailList) {
        ProductDto product = mdcProductService.selectById(orderItem.getProductId());
        product.setChangeStock(0 - orderItem.getQuantity());
        mdcProductService.updateProductStockById(product);
    }
}
Also used : OmcOrderDetail(com.paascloud.provider.model.domain.OmcOrderDetail) ProductDto(com.paascloud.provider.model.dto.ProductDto)

Aggregations

ProductDto (com.paascloud.provider.model.dto.ProductDto)7 OmcCart (com.paascloud.provider.model.domain.OmcCart)3 MdcBizException (com.paascloud.provider.exceptions.MdcBizException)2 MdcProduct (com.paascloud.provider.model.domain.MdcProduct)2 OmcOrderDetail (com.paascloud.provider.model.domain.OmcOrderDetail)2 CartProductVo (com.paascloud.provider.model.vo.CartProductVo)2 ApiOperation (io.swagger.annotations.ApiOperation)2 PageInfo (com.github.pagehelper.PageInfo)1 LoginAuthDto (com.paascloud.base.dto.LoginAuthDto)1 OmcBizException (com.paascloud.provider.exceptions.OmcBizException)1 MdcProductCategory (com.paascloud.provider.model.domain.MdcProductCategory)1 CartVo (com.paascloud.provider.model.vo.CartVo)1 BigDecimal (java.math.BigDecimal)1