|
|
@@ -571,7 +571,8 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goods.setTaxRate();
|
|
|
|
|
|
if (goods.getReturnInWeek() == null) {
|
|
|
- goods.setReturnInWeek((short) 0);// 若无设置,默认不支持7天无理由退货
|
|
|
+ // 若无设置,默认不支持7天无理由退货
|
|
|
+ goods.setReturnInWeek((short) 0);
|
|
|
}
|
|
|
// 若B2C上架的商品必须有发布人姓名和发布人联系电话
|
|
|
if (goods.getSourceId() == null) {
|
|
|
@@ -593,16 +594,12 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
if (StringUtils.isEmpty(goods.getImg())) {
|
|
|
Long goodsProductid = goods.getProductid();
|
|
|
if (goodsProductid != null) {
|
|
|
- Product product = productDao.findOne
|
|
|
- (goodsProductid);
|
|
|
+ Product product = productDao.findOne(goodsProductid);
|
|
|
if (product != null) {
|
|
|
if (StringUtils.isEmpty(product.getCmpImg())) {
|
|
|
String cmpUuId = product.getCmpUuId();
|
|
|
- if (!StringUtils.isEmpty
|
|
|
- (cmpUuId)) {
|
|
|
- Component component = componentDao
|
|
|
- .findByUuid
|
|
|
- (cmpUuId);
|
|
|
+ if (!StringUtils.isEmpty(cmpUuId)) {
|
|
|
+ Component component = componentDao.findByUuid(cmpUuId);
|
|
|
if (component != null) {
|
|
|
goods.setImg(component.getImg());
|
|
|
}
|
|
|
@@ -629,8 +626,13 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
throw new IllegalOperatorException("器件" + goods.getCode() + "品牌" + goods.getBrandNameEn() + "关联的物料库信息丢失");
|
|
|
}
|
|
|
List<Goods> goodses = goodsDao.findRepeatGoodsInProductId(goods.getProductid(), goods.getProduceDate(), goods.getPackaging(), goods.getMinPackQty(), goods.getMinBuyQty(), goods.getMaxDelivery(), goods.getMinDelivery(), goods.getUnit());
|
|
|
- if ((goods.getId() == null && goodses.size() > 0) || (goodses.size() > 1)) {
|
|
|
- throw new IllegalOperatorException("该物料已存在(包装、日期、最小包装量、最小起订量、交期、单位)相同的信息");
|
|
|
+ if (!CollectionUtils.isEmpty(goodses)) {
|
|
|
+ for (Goods goods1 : goodses) {
|
|
|
+ if (!goods1.getId().equals(goods.getId())
|
|
|
+ && GoodsUtil.compareWithQtyPrice(goods1.getPrices(), goods.getPrices(), goods.getCurrencyName())) {
|
|
|
+ throw new IllegalOperatorException("该物料已存在(包装、日期、最小包装量、最小起订量、交期、单位、价格)相同的信息");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
//判断自定义标签是否重复
|
|
|
if (StringUtils.isEmpty(goods.getTag())) {
|
|
|
@@ -640,13 +642,12 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
throw new IllegalOperatorException("传入的产品信息缺失,请重新操作");
|
|
|
}
|
|
|
List<Goods> goodsList = goodsDao.findGoodsByProductidAndTag(goods.getProductid(), goods.getTag());
|
|
|
- if ((goods.getId() == null) &&
|
|
|
- (goodsList.size() > 0)) {
|
|
|
+ if ((goods.getId() == null) && (goodsList.size() > 0)) {
|
|
|
throw new IllegalOperatorException("该产品下已存在相同的自定义标签");
|
|
|
} else {
|
|
|
for (Goods goods1 : goodsList) {
|
|
|
- if (goods.getTag().equals(goods1.getTag()) &&
|
|
|
- (goods1.getId().longValue() != goods.getId().longValue())) {
|
|
|
+ if (goods.getTag().equals(goods1.getTag())
|
|
|
+ && (goods1.getId().longValue() != goods.getId().longValue())) {
|
|
|
throw new IllegalOperatorException("该产品下已存在相同的自定义标签");
|
|
|
}
|
|
|
}
|
|
|
@@ -1254,26 +1255,20 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
if (nowGoods.getReserve().doubleValue() != goods.getOldReserve().doubleValue()) {
|
|
|
return new ResultMap(CodeType.INFO_UPDATE.code(), "该库存的信息已经被修改了,请刷新界面之后重新操作。");
|
|
|
}
|
|
|
- if(StringUtils.isEmpty(goods.getTag())) {
|
|
|
+ if (StringUtils.isEmpty(goods.getTag())) {
|
|
|
return new ResultMap(CodeType.NOT_PERMIT.code(), "产品自定义标签必须填写");
|
|
|
}
|
|
|
List<Goods> tagInTheProdNums = goodsDao.findSameTagInTheProdNum(goods.getProdNum(), goods.getTag());
|
|
|
for (Goods tagInTheProdNum : tagInTheProdNums) {
|
|
|
- if(goods.getTag().equals(tagInTheProdNum.getTag())&&(goods.getId().longValue() != tagInTheProdNum.getId().longValue())) {
|
|
|
+ if (goods.getTag().equals(tagInTheProdNum.getTag()) && (goods.getId().longValue() != tagInTheProdNum.getId().longValue())) {
|
|
|
return new ResultMap(CodeType.NOT_PERMIT.code(), "标签不能与该器件现有产品的标签重复");
|
|
|
}
|
|
|
}
|
|
|
-// ProductStandardPutOnInfo putOnInfo = productStandardPutOnInfoDao.findOne(goods.getStandprodid());
|
|
|
-// if(putOnInfo != null) {
|
|
|
-// if(nowGoods.validProductStandardPutOnInfoAndGoodsSameData(putOnInfo)) {
|
|
|
-// return new ResultMap(CodeType.INFO_UPDATE.code(), "数据已经被更新了请刷新之后重新操作");
|
|
|
-// }
|
|
|
-// }
|
|
|
List<Goods> repeatGoodsInProductId = goodsDao.findRepeatGoodsInProductId(goods.getProductid(), goods.getProduceDate(), goods.getPackaging(), goods.getMinPackQty(), goods.getMinBuyQty(), goods.getMaxDelivery(), goods.getMinDelivery(), goods.getUnit());
|
|
|
for (Goods goods1 : repeatGoodsInProductId) {
|
|
|
- if(goods1.getId().longValue() !=
|
|
|
- goods.getId().longValue()) {
|
|
|
- throw new IllegalOperatorException("该物料已存在(包装、日期、最小包装量、最小起订量、交期、单位)相同的信息");
|
|
|
+ if (!goods1.getId().equals(goods.getId())
|
|
|
+ && GoodsUtil.compareWithQtyPrice(goods1.getPrices(), goods.getPrices(), goods.getCurrencyName())) {
|
|
|
+ throw new IllegalOperatorException("该物料已存在(包装、日期、最小包装量、最小起订量、交期、单位、价格)相同的信息");
|
|
|
}
|
|
|
}
|
|
|
// 比较两个goods编辑信息
|
|
|
@@ -1419,7 +1414,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
@Override
|
|
|
public ResultMap putOn(Long id) {
|
|
|
Goods goods = goodsDao.findOne(id);
|
|
|
- if(goods != null) {
|
|
|
+ if (goods != null) {
|
|
|
setGoodsDefault(goods);
|
|
|
ResultMap resultMap = checkGoods(goods);
|
|
|
if (resultMap.getCode() != CodeType.OK.code()) {
|
|
|
@@ -1431,7 +1426,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goodsHistoryDao.save(goodsHistory);
|
|
|
// TODO huxz 添加或修改商品价格信息
|
|
|
if (goods.getUuid() != null) {
|
|
|
- saveOrUpdatePriceInfos(goods, "NOMAL");
|
|
|
+// saveOrUpdatePriceInfos(goods, "NOMAL");
|
|
|
updateComponentTradeInfos(goods.getUuid());
|
|
|
}
|
|
|
return ResultMap.success(persistGoods);
|
|
|
@@ -1448,7 +1443,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public ResultMap addGoods(Goods goods) {
|
|
|
- if(goods == null) {
|
|
|
+ if (goods == null) {
|
|
|
throw new IllegalOperatorException("传入的需要添加的产品信息为空");
|
|
|
}
|
|
|
if (Integer.valueOf(goods.getSelfSale()).equals(IntegerConstant.B2C_SALE)) {
|