|
@@ -2,13 +2,18 @@ package com.uas.platform.b2c.external.erp.prod.service.impl;
|
|
|
|
|
|
|
|
import com.uas.api.b2c_erp.seller.model.Prod;
|
|
import com.uas.api.b2c_erp.seller.model.Prod;
|
|
|
import com.uas.api.b2c_erp.seller.service.ProdService;
|
|
import com.uas.api.b2c_erp.seller.service.ProdService;
|
|
|
|
|
+import com.uas.platform.b2c.core.constant.IntegerConstant;
|
|
|
import com.uas.platform.b2c.core.constant.Status;
|
|
import com.uas.platform.b2c.core.constant.Status;
|
|
|
import com.uas.platform.b2c.core.support.SystemSession;
|
|
import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
import com.uas.platform.b2c.core.support.log.ErpB2cBufferedLogger;
|
|
import com.uas.platform.b2c.core.support.log.ErpB2cBufferedLogger;
|
|
|
import com.uas.platform.b2c.external.erp.product.util.ModelConverter;
|
|
import com.uas.platform.b2c.external.erp.product.util.ModelConverter;
|
|
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.ProductDao;
|
|
import com.uas.platform.b2c.prod.commodity.dao.ProductDao;
|
|
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.ProductPrivateDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.Product;
|
|
import com.uas.platform.b2c.prod.commodity.model.Product;
|
|
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.ProductPrivate;
|
|
|
import com.uas.platform.b2c.prod.commodity.service.ProductService;
|
|
import com.uas.platform.b2c.prod.commodity.service.ProductService;
|
|
|
|
|
+import com.uas.platform.b2c.prod.commodity.service.ReleaseProductByBatchService;
|
|
|
import com.uas.platform.b2c.prod.store.dao.StoreInDao;
|
|
import com.uas.platform.b2c.prod.store.dao.StoreInDao;
|
|
|
import com.uas.platform.b2c.prod.store.model.StoreIn;
|
|
import com.uas.platform.b2c.prod.store.model.StoreIn;
|
|
|
import com.uas.platform.core.logging.BufferedLoggerManager;
|
|
import com.uas.platform.core.logging.BufferedLoggerManager;
|
|
@@ -16,6 +21,7 @@ import org.apache.log4j.Logger;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
@@ -37,6 +43,15 @@ public class ProdServiceImpl implements ProdService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private StoreInDao storeInDao;
|
|
private StoreInDao storeInDao;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private GoodsDao goodsDao;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ProductPrivateDao productPrivateDao;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ReleaseProductByBatchService releaseProductByBatchService;
|
|
|
|
|
+
|
|
|
private static final ErpB2cBufferedLogger logger = BufferedLoggerManager.getLogger(ErpB2cBufferedLogger.class);
|
|
private static final ErpB2cBufferedLogger logger = BufferedLoggerManager.getLogger(ErpB2cBufferedLogger.class);
|
|
|
|
|
|
|
|
private final Logger loggerOut = Logger.getLogger(getClass());
|
|
private final Logger loggerOut = Logger.getLogger(getClass());
|
|
@@ -46,16 +61,48 @@ public class ProdServiceImpl implements ProdService {
|
|
|
List<Product> products = new ArrayList<Product>();
|
|
List<Product> products = new ArrayList<Product>();
|
|
|
Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
for (Prod prod : prods) {
|
|
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 {
|
|
} 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) {
|
|
|
|
|
+ productPrivate = new ProductPrivate();
|
|
|
|
|
+ productPrivate.setPrId(prod.getPr_id());
|
|
|
}
|
|
}
|
|
|
|
|
+ productPrivate.setB2cEnabled(IntegerConstant.YES_SHORT);
|
|
|
|
|
+ // 统计现在有多少在售信息
|
|
|
|
|
+ int batchCount = goodsDao.findCountByProductid(prod.getPr_id());
|
|
|
|
|
+ productPrivate.setBatchCount(batchCount);
|
|
|
|
|
+ productPrivateDao.save(productPrivate);
|
|
|
}
|
|
}
|
|
|
productDao.save(products);// 保存上传的物料
|
|
productDao.save(products);// 保存上传的物料
|
|
|
|
|
|
|
@@ -112,4 +159,28 @@ public class ProdServiceImpl implements ProdService {
|
|
|
logger.log("物料资料", "ERP获取店铺路径,企业:" + SystemSession.getUser().getEnterprise().getEnName());
|
|
logger.log("物料资料", "ERP获取店铺路径,企业:" + SystemSession.getUser().getEnterprise().getEnName());
|
|
|
return url;
|
|
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";
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|