|
|
@@ -2446,10 +2446,13 @@ public class ProductServiceImpl implements ProductService {
|
|
|
// 物料存在,更新
|
|
|
List<V_ProductPrivate> existProducts = v_productPrivateDao.findProductByPcmpcodeAndPbrandenAndEnUU(product.getCmpCode(), product.getBrand(), enUU);
|
|
|
if (CollectionUtils.isNotEmpty(existProducts)) {
|
|
|
- productInfo = productInfo.setByPrivate(existProducts.get(0));
|
|
|
+ V_ProductPrivate productPrivate = existProducts.get(0);
|
|
|
+ productInfo = productInfo.setByPrivate(productPrivate);
|
|
|
// 用户填写库存量是需要做对应的出入库。如果新填写的库存数大于原库存数,做入库。否则做出库。
|
|
|
inOutbound = recordInventory(product, existProducts.get(0));
|
|
|
- BeanUtils.copyProperties(product, productInfo, "id,standard");
|
|
|
+ BeanUtils.copyProperties(product, productInfo, Product.class);
|
|
|
+ productInfo.setStandard(productPrivate.getStandard());
|
|
|
+ productInfo.setId(productPrivate.getId());
|
|
|
} else {
|
|
|
// 物料不存在,新增操作
|
|
|
productInfo = product;
|
|
|
@@ -2457,7 +2460,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
}
|
|
|
if (null == productInfo.getStandard()) {
|
|
|
// 判断传入的数据是否是标准的
|
|
|
- ResultMap criterionResultMap = checkCriterion(product);
|
|
|
+ ResultMap criterionResultMap = checkStandard(product);
|
|
|
if (Objects.equals(CodeType.ERROR.code(), criterionResultMap.getCode())) {
|
|
|
productInfo.setStandard(IntegerConstant.NO_SHORT);
|
|
|
} else {
|
|
|
@@ -2481,7 +2484,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
// 保存到商城私有库
|
|
|
addToPrivate(productInfo, product);
|
|
|
if (needAddInventory) {
|
|
|
- inOutbound = initCommodityInOut(productInfo);
|
|
|
+ inOutbound = initCommodityInOut(productInfo, goods);
|
|
|
}
|
|
|
// 保存出入库信息
|
|
|
if (null != inOutbound) {
|
|
|
@@ -2496,19 +2499,39 @@ public class ProductServiceImpl implements ProductService {
|
|
|
return ResultMap.success();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 判断是否是标准物料
|
|
|
+ *
|
|
|
+ * @param product product
|
|
|
+ * @return ResultMap
|
|
|
+ */
|
|
|
+ private ResultMap checkStandard(Product product) {
|
|
|
+ List<Brand> brands = brandDao.findByName(product.getBrand());
|
|
|
+ // 先判断标准品牌信息
|
|
|
+ if (CollectionUtils.isNotEmpty(brands)) {
|
|
|
+ // 判断标准器件信息
|
|
|
+ List<Component> components = componentDao.findByBrandidAndCode(brands.get(0).getId(), product.getCmpCode());
|
|
|
+ if (CollectionUtils.isNotEmpty(components)) {
|
|
|
+ return ResultMap.success();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResultMap.error(new NotFoundException("非标准物料"));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 新增库存记录
|
|
|
*
|
|
|
* @param productInfo 物料信息
|
|
|
* @return CommodityInOutbound
|
|
|
*/
|
|
|
- private CommodityInOutbound initCommodityInOut(Product productInfo) {
|
|
|
+ private CommodityInOutbound initCommodityInOut(Product productInfo, Goods goods) {
|
|
|
CommodityInOutbound inOutbound = new CommodityInOutbound(InOutBoundType.OTHER_INBOUND);
|
|
|
- Goods goods = new Goods();
|
|
|
- goods = Goods.productConvertGoods(goods, productInfo);
|
|
|
- goods.setReserve(productInfo.getErpReserve());
|
|
|
- goods = goodsDao.save(goods);
|
|
|
- logger.info("上架商品库存操作", "卖家中心单个物料上传进行入库操作", "增加库存: " + productInfo.getErpReserve(), goods.getCode(), goods.getId());
|
|
|
+ if (!StringUtils.isEmpty(goods.getQtyPrice())) {
|
|
|
+ goods = Goods.productConvertGoods(goods, productInfo);
|
|
|
+ goods.setReserve(productInfo.getErpReserve());
|
|
|
+ goods = goodsDao.save(goods);
|
|
|
+ logger.info("上架商品库存操作", "卖家中心单个物料上传进行入库操作", "增加库存: " + productInfo.getErpReserve(), goods.getCode(), goods.getId());
|
|
|
+ }
|
|
|
InOutboundDetail inOutboundDetail = new InOutboundDetail(productInfo);
|
|
|
Set<InOutboundDetail> detailSet = new HashSet<>();
|
|
|
detailSet.add(inOutboundDetail);
|
|
|
@@ -2749,7 +2772,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
if (size == 1) {
|
|
|
GoodsQtyPrice qtyPrice = goods.getOriginalPrices().get(0);
|
|
|
// 前端设置的默认值,不用保存
|
|
|
- if (null == qtyPrice.getPrice()) {
|
|
|
+ if (null == qtyPrice.getUSDPrice() && null == qtyPrice.getRMBPrice()) {
|
|
|
goods.setQtyPrice("");
|
|
|
}
|
|
|
} else if (size > 1) {
|
|
|
@@ -2763,7 +2786,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
throw new IllegalOperatorException("第 " + errMsg.toString() + " 行价格未填写");
|
|
|
}
|
|
|
}
|
|
|
- if (!StringUtils.isEmpty(qtyPrices)) {
|
|
|
+ if (!StringUtils.isEmpty(qtyPrices) && !StringUtils.isEmpty(goods.getQtyPrice())) {
|
|
|
if (CollectionUtils.isNotEmpty(goods.getOriginalPrices())) {
|
|
|
qtyPrices.forEach(qtyPrice -> {
|
|
|
// 分段数量不能超过最大数量
|
|
|
@@ -2776,16 +2799,11 @@ public class ProductServiceImpl implements ProductService {
|
|
|
qtyPrices.get(0).setStart(startQty);
|
|
|
}
|
|
|
goods.setQtyPrice(JSON.toJSONString(qtyPrices));
|
|
|
+ goodsService.setGoodsDefault(goods);
|
|
|
+ boolean autoPublish = goods.getAutoPublish() == null ? true : goods.getAutoPublish();
|
|
|
+ goods.setAutoPublish(autoPublish);
|
|
|
+ goods = goodsDao.save(goods);
|
|
|
+ logger.info("上架商品", "新增上架商品", "通过卖家中心单个物料上传新增上架商品", goods.getCode(), goods.getId());
|
|
|
}
|
|
|
- goodsService.setGoodsDefault(goods);
|
|
|
- boolean autoPublish = goods.getAutoPublish() == null ? true : goods.getAutoPublish();
|
|
|
- goods.setAutoPublish(autoPublish);
|
|
|
- StoreIn storeIn = storeInService.findByEnUU(SystemSession.getUser().getEnterprise().getUu());
|
|
|
- if (storeIn != null && storeIn.getStatus() == StoreStatus.OPENED) {
|
|
|
- goods.setStoreid(storeIn.getUuid());
|
|
|
- goods.setStoreName(storeIn.getStoreName());
|
|
|
- }
|
|
|
- goods = goodsDao.save(goods);
|
|
|
- logger.info("上架商品", "新增上架商品", "通过卖家中心单个物料上传新增上架商品", goods.getCode(), goods.getId());
|
|
|
}
|
|
|
}
|