|
|
package com.yoho.ufo.service.impl;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.yoho.core.common.utils.DateUtil;
|
|
|
import com.yoho.ufo.dal.UfoProductDetailsMapper;
|
|
|
import com.yoho.ufo.dal.UfoProductPoolDetailMapper;
|
|
|
import com.yoho.ufo.dal.UfoProductPoolMapper;
|
|
|
import com.yoho.ufo.exception.PlatformException;
|
|
|
import com.yoho.ufo.model.goodsmanage.ProductDetails;
|
|
|
import com.yoho.ufo.model.goodsmanage.ProductPool;
|
|
|
import com.yoho.ufo.model.goodsmanage.ProductPoolDetails;
|
|
|
import com.yoho.ufo.service.IProductPoolDetailsService;
|
|
|
import com.yoho.ufo.util.OrikaUtils;
|
|
|
import com.yohobuy.ufo.model.common.PageModel;
|
|
|
import com.yohobuy.ufo.model.common.PageResponseBO;
|
|
|
import com.yohobuy.ufo.model.request.productpool.ProductPoolDetailsRequestBo;
|
|
|
import com.yohobuy.ufo.model.request.productpool.ProductPoolDetailsResponseBo;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 商品池详情管理
|
...
|
...
|
@@ -33,6 +41,9 @@ public class ProductPoolDetailsServiceImpl implements IProductPoolDetailsService |
|
|
@Autowired
|
|
|
private UfoProductDetailsMapper ufoProductDetailsMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private UfoProductPoolMapper ufoProductPoolMapper;
|
|
|
|
|
|
@Override
|
|
|
public PageResponseBO<ProductPoolDetailsResponseBo> getProductPoolDetailsPageList(ProductPoolDetailsRequestBo productPoolDetailsRequestBo) {
|
|
|
LOGGER.info("getProductPoolDetailsPageList param = {}", productPoolDetailsRequestBo);
|
...
|
...
|
@@ -53,4 +64,61 @@ public class ProductPoolDetailsServiceImpl implements IProductPoolDetailsService |
|
|
LOGGER.info("deleteProductById productId = {}, productPoolId = {}", productId, productPoolId);
|
|
|
return ufoProductPoolDetailMapper.deleteProductPoolDetail(productPoolId, productId);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int saveProduct(ProductPoolDetailsRequestBo requestBo) throws PlatformException {
|
|
|
//校验
|
|
|
if(null == requestBo) {
|
|
|
return 0;
|
|
|
}
|
|
|
checkParam(requestBo);
|
|
|
|
|
|
//插入数据库
|
|
|
ProductPoolDetails product = new ProductPoolDetails();
|
|
|
product.setPoolId(requestBo.getPoolId());
|
|
|
product.setProductId(requestBo.getProductId());
|
|
|
product.setOrderBy(requestBo.getOrderBy());
|
|
|
product.setCreateTime(DateUtil.getCurrentTimeSecond());
|
|
|
List<ProductPoolDetails> productList = Lists.newArrayList(product);
|
|
|
return ufoProductPoolDetailMapper.batchInsertProductPoolDetails(productList);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int updateProductOrderBy(ProductPoolDetailsRequestBo requestBo) throws PlatformException {
|
|
|
//校验
|
|
|
if(null == requestBo || null == requestBo.getPoolId() || null == requestBo.getProductId()) {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
//查询是否已存在
|
|
|
List<ProductPoolDetails> productList = ufoProductPoolDetailMapper.selectByPoolIdAndOrderBy(requestBo.getPoolId(), requestBo.getOrderBy());
|
|
|
if(CollectionUtils.isNotEmpty(productList)) {
|
|
|
throw new PlatformException("该排序值在商品池中已存在!", 400);
|
|
|
}
|
|
|
|
|
|
//更新记录
|
|
|
return ufoProductPoolDetailMapper.updateProductOrderBy(requestBo.getPoolId(), requestBo.getProductId(), requestBo.getOrderBy());
|
|
|
}
|
|
|
|
|
|
private void checkParam(ProductPoolDetailsRequestBo requestBo) throws PlatformException{
|
|
|
Integer poolId = requestBo.getPoolId();
|
|
|
Integer productId = requestBo.getProductId();
|
|
|
Integer orderByNum = requestBo.getOrderBy();
|
|
|
//判断商品池是否存在
|
|
|
ProductPool pool = ufoProductPoolMapper.selectOneById(poolId);
|
|
|
if(null == pool) {
|
|
|
throw new PlatformException("添加失败!商品池不存在!", 400);
|
|
|
}
|
|
|
|
|
|
//判断商品是否存在
|
|
|
List<ProductPoolDetails> productList = ufoProductPoolDetailMapper.selectByPoolIdAndProductId(poolId, productId);
|
|
|
if(CollectionUtils.isNotEmpty(productList)) {
|
|
|
throw new PlatformException("添加失败!商品池中该商品已存在!", 400);
|
|
|
}
|
|
|
|
|
|
productList = ufoProductPoolDetailMapper.selectByPoolIdAndOrderBy(poolId, orderByNum);
|
|
|
if(CollectionUtils.isNotEmpty(productList)) {
|
|
|
throw new PlatformException("添加失败!商品池中该排序值已存在!", 400);
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|