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;
}
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);
}
}
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;
}
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());
}
}
}
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;
}
Aggregations