|
|
@@ -21,6 +21,7 @@ import org.apache.log4j.Logger;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
@@ -60,15 +61,37 @@ public class ProdServiceImpl implements ProdService {
|
|
|
List<Product> products = new ArrayList<Product>();
|
|
|
Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
for (Prod prod : prods) {
|
|
|
- List<Product> productExists = productDao.getProductByEnUUAndProdNum(enuu, prod.getPr_code());
|
|
|
- Product product = ModelConverter.convert(prod);
|
|
|
- if (!CollectionUtils.isEmpty(productExists)) {
|
|
|
- Product existProduct = productExists.get(0);
|
|
|
- BeanUtils.copyProperties(product, productExists.get(0), "id");
|
|
|
- existProduct.setCmpUuId(null);// 将已存在的变更过物料uuid置为null,以便后续进行重新匹配
|
|
|
- products.add(existProduct);
|
|
|
+ if (StringUtils.isEmpty(prod.getPr_orispeccode()) || StringUtils.isEmpty(prod.getPr_brand())) {
|
|
|
+ List<Product> productList = productDao.findByEnUUAndPcmpcodeAndPbrandenAndB2cEnabled(enuu,prod.getPr_orispeccode(),prod.getPr_brand(),IntegerConstant.YES_SHORT);
|
|
|
+ if (!CollectionUtils.isEmpty(productList)) {
|
|
|
+ Product product = ModelConverter.convert(prod);
|
|
|
+ Product existProduct = productList.get(0);
|
|
|
+ BeanUtils.copyProperties(product, productList.get(0), "id");
|
|
|
+ existProduct.setCmpUuId(null);// 将已存在的变更过物料uuid置为null,以便后续进行重新匹配
|
|
|
+ products.add(existProduct);
|
|
|
+ } else {
|
|
|
+ List<Product> productExists = productDao.getProductByEnUUAndProdNum(enuu, prod.getPr_code());
|
|
|
+ Product product = ModelConverter.convert(prod);
|
|
|
+ if (!CollectionUtils.isEmpty(productExists)) {
|
|
|
+ Product existProduct = productExists.get(0);
|
|
|
+ BeanUtils.copyProperties(product, productExists.get(0), "id");
|
|
|
+ existProduct.setCmpUuId(null);// 将已存在的变更过物料uuid置为null,以便后续进行重新匹配
|
|
|
+ products.add(existProduct);
|
|
|
+ } else {
|
|
|
+ products.add(product);
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
- products.add(product);
|
|
|
+ List<Product> productExists = productDao.getProductByEnUUAndProdNum(enuu, prod.getPr_code());
|
|
|
+ Product product = ModelConverter.convert(prod);
|
|
|
+ if (!CollectionUtils.isEmpty(productExists)) {
|
|
|
+ Product existProduct = productExists.get(0);
|
|
|
+ BeanUtils.copyProperties(product, productExists.get(0), "id");
|
|
|
+ existProduct.setCmpUuId(null);// 将已存在的变更过物料uuid置为null,以便后续进行重新匹配
|
|
|
+ products.add(existProduct);
|
|
|
+ } else {
|
|
|
+ products.add(product);
|
|
|
+ }
|
|
|
}
|
|
|
ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(prod.getPr_id());
|
|
|
if (null == productPrivate) {
|
|
|
@@ -136,4 +159,28 @@ public class ProdServiceImpl implements ProdService {
|
|
|
logger.log("物料资料", "ERP获取店铺路径,企业:" + SystemSession.getUser().getEnterprise().getEnName());
|
|
|
return url;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String setB2cEnable(String pr_code, Integer isEnable) {
|
|
|
+ List<Product> productList = productDao.getProductByEnUUAndProdNum(SystemSession.getUser().getEnterprise().getUu(),pr_code);
|
|
|
+ if (!CollectionUtils.isEmpty(productList)) {
|
|
|
+ for (Product product : productList) {
|
|
|
+ ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
|
|
|
+ if (null == productPrivate) {
|
|
|
+ productPrivate = new ProductPrivate();
|
|
|
+ productPrivate.setPrId(product.getId());
|
|
|
+ }
|
|
|
+ if (isEnable.equals(IntegerConstant.YES_SHORT)) {
|
|
|
+ productPrivate.setB2cEnabled(IntegerConstant.YES_SHORT);
|
|
|
+ } else {
|
|
|
+ productPrivate.setB2cEnabled(IntegerConstant.NO_SHORT);
|
|
|
+ }
|
|
|
+ // 统计现在有多少在售信息
|
|
|
+ int batchCount = goodsDao.findCountByProductid(product.getId());
|
|
|
+ productPrivate.setBatchCount(batchCount);
|
|
|
+ productPrivateDao.save(productPrivate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "success";
|
|
|
+ }
|
|
|
}
|