Search in sources :

Example 6 with MdcBizException

use of com.paascloud.provider.exceptions.MdcBizException in project paascloud-master by paascloud.

the class OmcCartServiceImpl method updateCart.

@Override
public int updateCart(Long userId, Long productId, int count) {
    logger.info("updateCart - 更新货品数量 userId={}, productId={}, count={}", userId, productId, count);
    Preconditions.checkArgument(userId != null, ErrorCodeEnum.UAC10011001.msg());
    Preconditions.checkArgument(productId != null, ErrorCodeEnum.MDC10021021.msg());
    int resultInt;
    OmcCart cart = this.getCartByUserIdAndProductId(userId, productId);
    if (cart == null) {
        logger.error("找不到商品信息, userId={}, productId={}", userId, productId);
        throw new MdcBizException(ErrorCodeEnum.MDC10021004, productId);
    }
    if (count == 0) {
        List<String> productList = Lists.newArrayList();
        productList.add(productId.toString());
        resultInt = omcCartMapper.deleteByUserIdProductIds(userId, productList);
    } else {
        cart.setQuantity(count);
        resultInt = omcCartMapper.updateByPrimaryKeySelective(cart);
    }
    return resultInt;
}
Also used : MdcBizException(com.paascloud.provider.exceptions.MdcBizException) OmcCart(com.paascloud.provider.model.domain.OmcCart)

Example 7 with MdcBizException

use of com.paascloud.provider.exceptions.MdcBizException in project paascloud-master by paascloud.

the class MdcDictServiceImpl method saveMdcDict.

@Override
public void saveMdcDict(MdcDict mdcDict, LoginAuthDto loginAuthDto) {
    Long pid = mdcDict.getPid();
    mdcDict.setUpdateInfo(loginAuthDto);
    MdcDict parentMenu = mapper.selectByPrimaryKey(pid);
    if (PublicUtil.isEmpty(parentMenu)) {
        throw new MdcBizException(ErrorCodeEnum.MDC10021020, pid);
    }
    if (mdcDict.isNew()) {
        MdcDict updateMenu = new MdcDict();
        updateMenu.setId(pid);
        Long dictId = super.generateId();
        mdcDict.setId(dictId);
        mapper.insertSelective(mdcDict);
    } else {
        mapper.updateByPrimaryKeySelective(mdcDict);
    }
}
Also used : MdcBizException(com.paascloud.provider.exceptions.MdcBizException) MdcDict(com.paascloud.provider.model.domain.MdcDict)

Example 8 with MdcBizException

use of com.paascloud.provider.exceptions.MdcBizException in project paascloud-master by paascloud.

the class MdcProductCategoryServiceImpl method getMdcCategoryVoById.

@Override
public MdcCategoryVo getMdcCategoryVoById(final Long categoryId) {
    MdcProductCategory category = mdcProductCategoryMapper.selectByPrimaryKey(categoryId);
    if (category == null) {
        logger.error("找不到数据字典信息id={}", categoryId);
        throw new MdcBizException(ErrorCodeEnum.MDC10023001, categoryId);
    }
    // 获取父级菜单信息
    MdcProductCategory parentCategory = mdcProductCategoryMapper.selectByPrimaryKey(category.getPid());
    ModelMapper modelMapper = new ModelMapper();
    MdcCategoryVo categoryVo = modelMapper.map(category, MdcCategoryVo.class);
    categoryVo.setId(category.getId());
    categoryVo.setPid(category.getPid());
    if (parentCategory != null) {
        categoryVo.setParentCategoryName(parentCategory.getName());
    }
    return categoryVo;
}
Also used : MdcBizException(com.paascloud.provider.exceptions.MdcBizException) MdcProductCategory(com.paascloud.provider.model.domain.MdcProductCategory) MdcCategoryVo(com.paascloud.provider.model.vo.MdcCategoryVo) ModelMapper(org.modelmapper.ModelMapper)

Example 9 with MdcBizException

use of com.paascloud.provider.exceptions.MdcBizException in project paascloud-master by paascloud.

the class MdcProductCategoryServiceImpl method updateCategoryStatus.

private void updateCategoryStatus(List<MdcProductCategory> mdcCategoryList, LoginAuthDto loginAuthDto, int status) {
    MdcProductCategory update = new MdcProductCategory();
    for (MdcProductCategory category : mdcCategoryList) {
        update.setId(category.getId());
        update.setVersion(category.getVersion() + 1);
        update.setStatus(status);
        update.setUpdateInfo(loginAuthDto);
        int result = mapper.updateByPrimaryKeySelective(update);
        if (result < 1) {
            throw new MdcBizException(ErrorCodeEnum.MDC10023003, category.getId());
        }
    }
}
Also used : MdcBizException(com.paascloud.provider.exceptions.MdcBizException) MdcProductCategory(com.paascloud.provider.model.domain.MdcProductCategory)

Example 10 with MdcBizException

use of com.paascloud.provider.exceptions.MdcBizException 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)

Aggregations

MdcBizException (com.paascloud.provider.exceptions.MdcBizException)11 MdcDict (com.paascloud.provider.model.domain.MdcDict)3 MdcProductCategory (com.paascloud.provider.model.domain.MdcProductCategory)3 OmcCart (com.paascloud.provider.model.domain.OmcCart)3 ProductDto (com.paascloud.provider.model.dto.ProductDto)2 CartProductVo (com.paascloud.provider.model.vo.CartProductVo)2 ModelMapper (org.modelmapper.ModelMapper)2 LoginAuthDto (com.paascloud.base.dto.LoginAuthDto)1 MdcProduct (com.paascloud.provider.model.domain.MdcProduct)1 GaodeLocation (com.paascloud.provider.model.dto.gaode.GaodeLocation)1 CartVo (com.paascloud.provider.model.vo.CartVo)1 MdcCategoryVo (com.paascloud.provider.model.vo.MdcCategoryVo)1 MdcDictVo (com.paascloud.provider.model.vo.MdcDictVo)1 BigDecimal (java.math.BigDecimal)1 Transactional (org.springframework.transaction.annotation.Transactional)1