|
|
@@ -603,34 +603,39 @@ public class ProductServiceImpl implements ProductService {
|
|
|
}
|
|
|
StringUtilB2C.removeFromList(ids, productPerson.getProductId());
|
|
|
}
|
|
|
- //删除匹配结果信息
|
|
|
- productMatchResultDao.deleteByProductids(ids);
|
|
|
-
|
|
|
- //更新在售产品信息
|
|
|
- List<Goods> goodses = goodsService.findByProductids(ids);
|
|
|
- goodsService.deleteGoods(goodses);
|
|
|
-
|
|
|
- //调整物料为禁用状态。
|
|
|
- List<ProductPrivate> productPrivates = productPrivateService.findByPrIds(ids);
|
|
|
- for (ProductPrivate productPrivate : productPrivates) {
|
|
|
- productPrivate.setB2cEnabled(IntegerConstant.NO_SHORT);
|
|
|
- StringUtilB2C.removeFromList(ids, productPrivate.getPrId());
|
|
|
- }
|
|
|
- ProductPrivate pPrivate = null;
|
|
|
- for (Long id : ids) {
|
|
|
- pPrivate = new ProductPrivate(id);
|
|
|
- if (CollectionUtils.isEmpty(productPrivates)) {
|
|
|
- productPrivates = new ArrayList<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(ids)) {
|
|
|
+ //删除匹配结果信息
|
|
|
+ productMatchResultDao.deleteByProductids(ids);
|
|
|
+
|
|
|
+ //更新在售产品信息
|
|
|
+ List<Goods> goodses = goodsService.findByProductids(ids);
|
|
|
+ goodsService.deleteGoods(goodses);
|
|
|
+
|
|
|
+ //调整物料为禁用状态。
|
|
|
+ List<ProductPrivate> productPrivates = productPrivateService.findByPrIds(ids);
|
|
|
+ for (ProductPrivate productPrivate : productPrivates) {
|
|
|
+ productPrivate.setB2cEnabled(IntegerConstant.NO_SHORT);
|
|
|
+ StringUtilB2C.removeFromList(ids, productPrivate.getPrId());
|
|
|
+ }
|
|
|
+ ProductPrivate pPrivate = null;
|
|
|
+ for (Long id : ids) {
|
|
|
+ pPrivate = new ProductPrivate(id);
|
|
|
+ if (CollectionUtils.isEmpty(productPrivates)) {
|
|
|
+ productPrivates = new ArrayList<>();
|
|
|
+ }
|
|
|
+ productPrivates.add(pPrivate);
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(productPrivates)) {
|
|
|
+ productPrivateDao.save(productPrivates);
|
|
|
}
|
|
|
- productPrivates.add(pPrivate);
|
|
|
- }
|
|
|
- if (CollectionUtils.isNotEmpty(productPrivates)) {
|
|
|
- productPrivateDao.save(productPrivates);
|
|
|
}
|
|
|
+ int code = 1;
|
|
|
if (StringUtils.isEmpty(message)) {
|
|
|
message = "删除成功";
|
|
|
+ } else {
|
|
|
+ code = CodeType.NOT_PERMIT.code();
|
|
|
}
|
|
|
- return ResultMap.success(message);
|
|
|
+ return new ResultMap(code, message);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2434,15 +2439,15 @@ public class ProductServiceImpl implements ProductService {
|
|
|
return criterionResultMap;
|
|
|
}
|
|
|
}
|
|
|
- Product productInfo;
|
|
|
+ Product productInfo = new Product();
|
|
|
CommodityInOutbound inOutbound = null;
|
|
|
// 物料存在,更新
|
|
|
- List<Product> existProducts = productDao.findProductByPcmpcodeAndPbrandenAndEnUU(product.getCmpCode(), product.getBrand(), enUU);
|
|
|
+ List<V_ProductPrivate> existProducts = v_productPrivateDao.findProductByPcmpcodeAndPbrandenAndEnUU(product.getCmpCode(), product.getBrand(), enUU);
|
|
|
if (CollectionUtils.isNotEmpty(existProducts)) {
|
|
|
- productInfo = existProducts.get(0);
|
|
|
+ productInfo = productInfo.setByPrivate(existProducts.get(0));
|
|
|
// 用户填写库存量是需要做对应的出入库。如果新填写的库存数大于原库存数,做入库。否则做出库。
|
|
|
inOutbound = recordInventory(product, existProducts.get(0));
|
|
|
- BeanUtils.copyProperties(product, productInfo, Product.class);
|
|
|
+ BeanUtils.copyProperties(product, productInfo, "id");
|
|
|
} else {
|
|
|
// 物料不存在,新增操作
|
|
|
productInfo = product;
|
|
|
@@ -2465,9 +2470,19 @@ public class ProductServiceImpl implements ProductService {
|
|
|
// 设置库存信息
|
|
|
assignmentGoods(goods, productInfo);
|
|
|
// 保存到商城私有库
|
|
|
- ProductPrivate productPrivate = new ProductPrivate(productInfo.getId());
|
|
|
- productPrivate.setAttach(product.getAttachment());
|
|
|
- productPrivateDao.save(productPrivate);
|
|
|
+ List<ProductPrivate> productPrivates = productPrivateDao.findByPrId(productInfo.getId());
|
|
|
+ if (CollectionUtils.isEmpty(productPrivates)) {
|
|
|
+ ProductPrivate productPrivate = new ProductPrivate(productInfo.getId());
|
|
|
+ productPrivate.setAttach(product.getAttachment());
|
|
|
+ productPrivate.setB2cEnabled(IntegerConstant.YES_SHORT);
|
|
|
+ productPrivateDao.save(productPrivate);
|
|
|
+ } else {
|
|
|
+ ProductPrivate productPrivate = productPrivates.get(0);
|
|
|
+ if (null == productPrivate.getB2cEnabled() || Objects.equals(IntegerConstant.NO_SHORT, productPrivate.getB2cEnabled())) {
|
|
|
+ productPrivate.setB2cEnabled(IntegerConstant.YES_SHORT);
|
|
|
+ productPrivateDao.save(productPrivate);
|
|
|
+ }
|
|
|
+ }
|
|
|
// 保存出入库信息
|
|
|
if (null != inOutbound) {
|
|
|
for (InOutboundDetail detail : inOutbound.getInOutboundDetails()) {
|
|
|
@@ -2563,7 +2578,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
* @param product 前台传入的物料数据
|
|
|
* @param existProduct 数据库存在的物料信息
|
|
|
*/
|
|
|
- private CommodityInOutbound recordInventory(Product product, Product existProduct) {
|
|
|
+ private CommodityInOutbound recordInventory(Product product, V_ProductPrivate existProduct) {
|
|
|
// 入库
|
|
|
String type;
|
|
|
CommodityInOutbound inOutbound;
|
|
|
@@ -2667,7 +2682,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
if (CollectionUtils.isEmpty(productPersonList)) {
|
|
|
ProductPerson productPerson = new ProductPerson(userUU, enUU, productInfo.getId());
|
|
|
productPerson = productPersonDao.save(productPerson);
|
|
|
- logger.info("个人物料", "新增个人物料", "通过卖家中心单个物料上传绑定个人物料", "", productPerson.getId());
|
|
|
+ logger.info("个人物料", "新增个人物料", "通过卖家中心单个物料上传绑定个人物料", productInfo.getProdNum(), productPerson.getId());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2686,6 +2701,41 @@ public class ProductServiceImpl implements ProductService {
|
|
|
goods.setProductid(productInfo.getId());
|
|
|
}
|
|
|
}
|
|
|
+ final Double minBuyQty = goods.getMinBuyQty();
|
|
|
+ // 判断前端传入的分段价格是默认的值还是填写错误
|
|
|
+ List<GoodsQtyPrice> qtyPrices = goods.getOriginalPrices();
|
|
|
+ int size = qtyPrices.size();
|
|
|
+ if (size == 1) {
|
|
|
+ GoodsQtyPrice qtyPrice = goods.getOriginalPrices().get(0);
|
|
|
+ // 前端设置的默认值,不用保存
|
|
|
+ if (null == qtyPrice.getPrice()) {
|
|
|
+ goods.setQtyPrice("");
|
|
|
+ }
|
|
|
+ } else if (size > 1) {
|
|
|
+ StringBuffer errMsg = new StringBuffer();
|
|
|
+ for (int i = 0; i < size; i++) {
|
|
|
+ if (null == qtyPrices.get(i).getRMBPrice() && null == qtyPrices.get(i).getUSDPrice()) {
|
|
|
+ jointErrMsg(errMsg, String.valueOf(i + 1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(errMsg.toString())) {
|
|
|
+ throw new IllegalOperatorException("第 " + errMsg.toString() + " 行价格未填写");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(goods.getQtyPrice())) {
|
|
|
+ if (CollectionUtils.isNotEmpty(goods.getOriginalPrices())) {
|
|
|
+ goods.getOriginalPrices().forEach(subPrice -> {
|
|
|
+ // 分段数量不能超过最大数量
|
|
|
+ Double endQty = NumberUtil.compare(subPrice.getEnd(), DoubleConstant.maxReserve) == 1 ? DoubleConstant.maxReserve : subPrice.getEnd();
|
|
|
+ subPrice.setEnd(endQty);
|
|
|
+
|
|
|
+ // 起始数量不能大于最小订购数
|
|
|
+ Double startQty = NumberUtil.compare(minBuyQty, subPrice.getStart()) == 1 ? subPrice.getStart() : minBuyQty;
|
|
|
+ subPrice.setStart(startQty);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ goods.setQtyPrice(JSON.toJSONString(goods.getOriginalPrices()));
|
|
|
+ }
|
|
|
goodsService.setGoodsDefault(goods);
|
|
|
boolean autoPublish = goods.getAutoPublish() == null ? true : goods.getAutoPublish();
|
|
|
goods.setAutoPublish(autoPublish);
|