|
@@ -1,14 +1,15 @@
|
|
|
package com.fs.hisStore.service.impl;
|
|
package com.fs.hisStore.service.impl;
|
|
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.Date;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
import cn.hutool.json.JSONArray;
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.company.domain.CompanyUser;
|
|
import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.mapper.CompanyUserMapper;
|
|
import com.fs.company.mapper.CompanyUserMapper;
|
|
|
|
|
+import com.fs.his.domain.FsPackage;
|
|
|
import com.fs.hisStore.domain.FsStoreProductScrm;
|
|
import com.fs.hisStore.domain.FsStoreProductScrm;
|
|
|
import com.fs.hisStore.domain.FsStoreProductAttrValueScrm;
|
|
import com.fs.hisStore.domain.FsStoreProductAttrValueScrm;
|
|
|
import com.fs.hisStore.domain.FsUserCompanyPackageScrm;
|
|
import com.fs.hisStore.domain.FsUserCompanyPackageScrm;
|
|
@@ -25,6 +26,7 @@ import org.springframework.stereotype.Service;
|
|
|
import com.fs.hisStore.mapper.FsStoreProductPackageScrmMapper;
|
|
import com.fs.hisStore.mapper.FsStoreProductPackageScrmMapper;
|
|
|
import com.fs.hisStore.domain.FsStoreProductPackageScrm;
|
|
import com.fs.hisStore.domain.FsStoreProductPackageScrm;
|
|
|
import com.fs.hisStore.service.IFsStoreProductPackageScrmService;
|
|
import com.fs.hisStore.service.IFsStoreProductPackageScrmService;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 商品组合套餐Service业务层处理
|
|
* 商品组合套餐Service业务层处理
|
|
@@ -184,4 +186,79 @@ public class FsStoreProductPackageScrmServiceImpl implements IFsStoreProductPack
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public int bulkCopyFsPackageByPackage(Long[] packageIds) {
|
|
|
|
|
+ if (packageIds.length>0){
|
|
|
|
|
+ List<FsStoreProductPackageScrm> list = fsStoreProductPackageMapper.selectFsPackageListByIds(packageIds);
|
|
|
|
|
+ if(list != null && !list.isEmpty()){
|
|
|
|
|
+ try {
|
|
|
|
|
+ for (FsStoreProductPackageScrm fsPackage : list) {
|
|
|
|
|
+ //重命名
|
|
|
|
|
+ fsPackage.setPackageId(null);
|
|
|
|
|
+ fsPackage.setTitle(fsPackage.getTitle() + " - 副本");
|
|
|
|
|
+ fsPackage.setCreateTime(new Date());
|
|
|
|
|
+ fsPackage.setUpdateTime(new Date());
|
|
|
|
|
+ fsStoreProductPackageMapper.insertFsStoreProductPackage(fsPackage);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int updateFsStoreProductPackagesByCompany(Long[] packageIds, Long status, Long[] companyIds) {
|
|
|
|
|
+ //判断套餐商品所属公司
|
|
|
|
|
+ Set<String> companySet = new LinkedHashSet<>();
|
|
|
|
|
+ List<FsStoreProductPackageScrm> list = fsStoreProductPackageMapper.selectFsPackageListByIds(packageIds);
|
|
|
|
|
+ if (list != null && !list.isEmpty()) {
|
|
|
|
|
+ List<Long> productIds = new ArrayList<>();
|
|
|
|
|
+ for (FsStoreProductPackageScrm fsStoreProductPackageScrm : list) {
|
|
|
|
|
+ String products = fsStoreProductPackageScrm.getProducts();
|
|
|
|
|
+ if (StringUtils.isNotBlank(products)) {
|
|
|
|
|
+ List<StorePackageProductDTO> dtos = JSON.parseArray(products, StorePackageProductDTO.class);
|
|
|
|
|
+ if (dtos != null && !dtos.isEmpty()) {
|
|
|
|
|
+ dtos.forEach(dto -> {
|
|
|
|
|
+ productIds.add(dto.getId());
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!productIds.isEmpty()) {
|
|
|
|
|
+ List<FsStoreProductScrm> productScrmList = fsStoreProductMapper.getStoreProductInProductIds(productIds);
|
|
|
|
|
+ if(productScrmList!=null&& !productScrmList.isEmpty()) {
|
|
|
|
|
+ productScrmList.forEach(fsStoreProductScrm -> {
|
|
|
|
|
+ String companyIdsTemp = fsStoreProductScrm.getCompanyIds();
|
|
|
|
|
+ if (StringUtils.isNotBlank(companyIdsTemp)) {
|
|
|
|
|
+ List<String> companyIdList = Arrays.asList(companyIdsTemp.split(","));
|
|
|
|
|
+ if (!companyIdList.isEmpty()) {
|
|
|
|
|
+ companySet.addAll(companyIdList);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ StringBuilder companyIdsStr = new StringBuilder();
|
|
|
|
|
+ if (companyIds != null && companyIds.length>0){
|
|
|
|
|
+ for (Long companyId : companyIds) {
|
|
|
|
|
+ if (!companySet.contains(companyId.toString())) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ companyIdsStr.append(companyId).append(",");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ String companyParam = "";
|
|
|
|
|
+ if (companyIdsStr.length()>0){
|
|
|
|
|
+ companyIdsStr.deleteCharAt(companyIdsStr.length()-1);
|
|
|
|
|
+ companyParam = companyIdsStr.toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ return fsStoreProductPackageMapper.updateFsStoreProductPackagesByCompany(packageIds,status,companyParam);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|