|
@@ -11,6 +11,7 @@ import com.hcloud.microserver.commoncore.util.GeneratorIdUtils;
|
|
import com.hcloud.microserver.commoncore.util.UUIDUtils;
|
|
import com.hcloud.microserver.commoncore.util.UUIDUtils;
|
|
import com.hcloud.microserver.facade.carbon.entity.*;
|
|
import com.hcloud.microserver.facade.carbon.entity.*;
|
|
import com.hcloud.microserver.facade.carbon.forms.*;
|
|
import com.hcloud.microserver.facade.carbon.forms.*;
|
|
|
|
+import com.hcloud.microserver.system.util.CurrUserUtil;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -152,6 +153,7 @@ public class ProductInfoServiceImpl implements ProductInfoService {
|
|
productInfo.setState(1);
|
|
productInfo.setState(1);
|
|
productInfo.setIsEnable(1);
|
|
productInfo.setIsEnable(1);
|
|
productInfo.setProductCode(getMaxProductCode());
|
|
productInfo.setProductCode(getMaxProductCode());
|
|
|
|
+ productInfo.setCreateUser(CurrUserUtil.getUserId());
|
|
|
|
|
|
// 批量添加产品归属信息
|
|
// 批量添加产品归属信息
|
|
List<ProductBelongForm> productBelongForms = productInfoForm.getProductBelongForms();
|
|
List<ProductBelongForm> productBelongForms = productInfoForm.getProductBelongForms();
|
|
@@ -185,24 +187,21 @@ public class ProductInfoServiceImpl implements ProductInfoService {
|
|
String collectiveGuid = collectiveFarmerForm.getGuid();
|
|
String collectiveGuid = collectiveFarmerForm.getGuid();
|
|
if (StringUtils.isNotEmpty(collectiveGuid) && collectiveGuid.matches("^\\w{32}$")) {
|
|
if (StringUtils.isNotEmpty(collectiveGuid) && collectiveGuid.matches("^\\w{32}$")) {
|
|
CollectiveFarmer collectiveFarmer = this.collectiveFarmerMapper.selectByPrimaryKey(collectiveGuid);
|
|
CollectiveFarmer collectiveFarmer = this.collectiveFarmerMapper.selectByPrimaryKey(collectiveGuid);
|
|
- List<FarmerInfo> farmerInfos = this.farmerInfoMapper.selectByCollectiveId(collectiveGuid);
|
|
|
|
- if (Objects.nonNull(collectiveFarmer) && Objects.nonNull(farmerInfos)) {
|
|
|
|
- List<ProductBelong> productBelongs = new ArrayList<>();
|
|
|
|
- farmerInfos.forEach(farmerInfo -> {
|
|
|
|
|
|
+ //集体主体与个人主体不强关联
|
|
|
|
+ if (Objects.nonNull(collectiveFarmer)) {
|
|
|
|
+ List<ProductBelong> productBelongs = new ArrayList<>();
|
|
ProductBelong productBelong = new ProductBelong();
|
|
ProductBelong productBelong = new ProductBelong();
|
|
productBelong.setGuid(UUIDUtils.randomUUID());
|
|
productBelong.setGuid(UUIDUtils.randomUUID());
|
|
- productBelong.setBelongType(1);
|
|
|
|
|
|
+ productBelong.setBelongType(2);
|
|
productBelong.setCreateTime(new Date());
|
|
productBelong.setCreateTime(new Date());
|
|
productBelong.setFkProductGuid(guid);
|
|
productBelong.setFkProductGuid(guid);
|
|
- productBelong.setFarmerName(farmerInfo.getFarmerName());
|
|
|
|
- productBelong.setFarmerNum(farmerInfo.getFamilyNum());
|
|
|
|
|
|
+ productBelong.setFarmerNum(collectiveFarmer.getCollectivePersonNum());
|
|
productBelong.setFarmerVillage(collectiveFarmer.getCollectiveName());
|
|
productBelong.setFarmerVillage(collectiveFarmer.getCollectiveName());
|
|
- productBelong.setFkFarmerGuid(farmerInfo.getGuid());
|
|
|
|
productBelong.setModifiedTime(new Date());
|
|
productBelong.setModifiedTime(new Date());
|
|
productBelong.setState(1);
|
|
productBelong.setState(1);
|
|
|
|
+ productBelong.setFkCollectiveGuid(collectiveGuid);
|
|
productBelongs.add(productBelong);
|
|
productBelongs.add(productBelong);
|
|
- });
|
|
|
|
- if (Objects.nonNull(productBelongs) && productBelongs.size() > 0) {
|
|
|
|
|
|
+
|
|
result = this.productBelongMapper.batchInsert(productBelongs);
|
|
result = this.productBelongMapper.batchInsert(productBelongs);
|
|
if (result < 1) {
|
|
if (result < 1) {
|
|
throw new RuntimeException("新增产品信息 -- 批量新增产品归属失败");
|
|
throw new RuntimeException("新增产品信息 -- 批量新增产品归属失败");
|
|
@@ -210,7 +209,6 @@ public class ProductInfoServiceImpl implements ProductInfoService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
// 添加产品信息
|
|
// 添加产品信息
|
|
result = this.productInfoMapper.insert(productInfo);
|
|
result = this.productInfoMapper.insert(productInfo);
|
|
@@ -299,23 +297,18 @@ public class ProductInfoServiceImpl implements ProductInfoService {
|
|
String collectiveGuid = collectiveFarmerForm.getGuid();
|
|
String collectiveGuid = collectiveFarmerForm.getGuid();
|
|
if (StringUtils.isNotEmpty(collectiveGuid) && collectiveGuid.matches("^\\w{32}$")) {
|
|
if (StringUtils.isNotEmpty(collectiveGuid) && collectiveGuid.matches("^\\w{32}$")) {
|
|
CollectiveFarmer collectiveFarmer = this.collectiveFarmerMapper.selectByPrimaryKey(collectiveGuid);
|
|
CollectiveFarmer collectiveFarmer = this.collectiveFarmerMapper.selectByPrimaryKey(collectiveGuid);
|
|
- List<FarmerInfo> farmerInfos = this.farmerInfoMapper.selectByCollectiveId(collectiveGuid);
|
|
|
|
- if (Objects.nonNull(collectiveFarmer) && Objects.nonNull(farmerInfos)) {
|
|
|
|
|
|
+ if (Objects.nonNull(collectiveFarmer)) {
|
|
List<ProductBelong> productBelongs = new ArrayList<>();
|
|
List<ProductBelong> productBelongs = new ArrayList<>();
|
|
- farmerInfos.forEach(farmerInfo -> {
|
|
|
|
- ProductBelong productBelong = new ProductBelong();
|
|
|
|
- productBelong.setGuid(UUIDUtils.randomUUID());
|
|
|
|
- productBelong.setBelongType(1);
|
|
|
|
- productBelong.setCreateTime(new Date());
|
|
|
|
- productBelong.setFkProductGuid(guid);
|
|
|
|
- productBelong.setFarmerName(farmerInfo.getFarmerName());
|
|
|
|
- productBelong.setFarmerNum(farmerInfo.getFamilyNum());
|
|
|
|
- productBelong.setFarmerVillage(collectiveFarmer.getCollectiveName());
|
|
|
|
- productBelong.setFkFarmerGuid(farmerInfo.getGuid());
|
|
|
|
- productBelong.setModifiedTime(new Date());
|
|
|
|
- productBelong.setState(1);
|
|
|
|
- productBelongs.add(productBelong);
|
|
|
|
- });
|
|
|
|
|
|
+ ProductBelong productBelong = new ProductBelong();
|
|
|
|
+ productBelong.setGuid(UUIDUtils.randomUUID());
|
|
|
|
+ productBelong.setBelongType(2);
|
|
|
|
+ productBelong.setCreateTime(new Date());
|
|
|
|
+ productBelong.setFkProductGuid(guid);
|
|
|
|
+ productBelong.setFarmerNum(collectiveFarmer.getCollectivePersonNum());
|
|
|
|
+ productBelong.setFarmerVillage(collectiveFarmer.getCollectiveName());
|
|
|
|
+ productBelong.setModifiedTime(new Date());
|
|
|
|
+ productBelong.setState(1);
|
|
|
|
+ productBelongs.add(productBelong);
|
|
if (Objects.nonNull(productBelongs) && productBelongs.size() > 0) {
|
|
if (Objects.nonNull(productBelongs) && productBelongs.size() > 0) {
|
|
result = this.productBelongMapper.batchInsert(productBelongs);
|
|
result = this.productBelongMapper.batchInsert(productBelongs);
|
|
if (result < 1) throw new RuntimeException("修改产品 -- 批量添加产品归属失败");
|
|
if (result < 1) throw new RuntimeException("修改产品 -- 批量添加产品归属失败");
|
|
@@ -328,11 +321,15 @@ public class ProductInfoServiceImpl implements ProductInfoService {
|
|
if (Objects.nonNull(goodsInfos) && goodsInfos.size() > 0) {
|
|
if (Objects.nonNull(goodsInfos) && goodsInfos.size() > 0) {
|
|
for (GoodsInfo goodsInfo : goodsInfos) {
|
|
for (GoodsInfo goodsInfo : goodsInfos) {
|
|
goodsInfo.setGoodsImages(productInfo.getProductImgs());
|
|
goodsInfo.setGoodsImages(productInfo.getProductImgs());
|
|
|
|
+ goodsInfo.setModifiedTime(new Date());
|
|
|
|
+ goodsInfo.setModifiedUser(CurrUserUtil.getUserId());
|
|
}
|
|
}
|
|
result = this.goodsInfoMapper.batchUpdate(goodsInfos);
|
|
result = this.goodsInfoMapper.batchUpdate(goodsInfos);
|
|
if (result < 0) throw new RuntimeException("修改产品 -- 批量更新商品失败");
|
|
if (result < 0) throw new RuntimeException("修改产品 -- 批量更新商品失败");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ productInfo.setModifiedUser(CurrUserUtil.getUserId());
|
|
|
|
+ productInfo.setModifiedTime(new Date());
|
|
result = this.productInfoMapper.updateByPrimaryKeySelective(productInfo);
|
|
result = this.productInfoMapper.updateByPrimaryKeySelective(productInfo);
|
|
if (result < 1) throw new RuntimeException("修改产品信息失败");
|
|
if (result < 1) throw new RuntimeException("修改产品信息失败");
|
|
}
|
|
}
|