renqianlong 1 рік тому
батько
коміт
a3436473e2

+ 32 - 37
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/goods/service/impl/BsUserGoodsCollectionServiceImpl.java

@@ -57,20 +57,21 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
     @Override
     public BsUserGoodsCollection selectById(BsUserGoodsCollectionQueryBo bo) {
         BsUserGoodsCollection bsUserGoodsCollectionVo = new BsUserGoodsCollection();
-        if (Validator.isNotEmpty(bo.getConfigId())){
+        if (Validator.isNotEmpty(bo.getConfigId())) {
             List<BsUserGoodsCollection> bsUserGoodsCollections = this.list(new LambdaQueryWrapper<BsUserGoodsCollection>()
                     .eq(BsUserGoodsCollection::getConfigId, bo.getConfigId())
                     .eq(BsUserGoodsCollection::getStatus, 1));
-            if (!bsUserGoodsCollections.isEmpty()){
+            if (!bsUserGoodsCollections.isEmpty()) {
                 bsUserGoodsCollectionVo = bsUserGoodsCollections.get(0);
             }
         }
-        if (Validator.isNotEmpty(bo.getGoodsId())){
-            if (Validator.isNotEmpty(bo.getGoodsId())){;
+        if (Validator.isNotEmpty(bo.getGoodsId())) {
+            if (Validator.isNotEmpty(bo.getGoodsId())) {
+                ;
                 List<BsUserGoodsCollection> bsUserGoodsCollections = this.list(new LambdaQueryWrapper<BsUserGoodsCollection>()
                         .eq(BsUserGoodsCollection::getGoodsId, bo.getGoodsId())
                         .eq(BsUserGoodsCollection::getStatus, 1));
-                if (!bsUserGoodsCollections.isEmpty()){
+                if (!bsUserGoodsCollections.isEmpty()) {
                     bsUserGoodsCollectionVo = bsUserGoodsCollections.get(0);
                 }
             }
@@ -78,13 +79,14 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
         return bsUserGoodsCollectionVo;
     }
 
-    public String getReplace(List<String> string){
-        if (Validator.isEmpty(string)){
+    public String getReplace(List<String> string) {
+        if (Validator.isEmpty(string)) {
             return null;
         }
         String strings = string.toString().replace("[", "").replace("]", "").toString();
         return strings;
     }
+
     @Override
     public List<BsUserGoodsCollectionVo> queryList(BsUserGoodsCollectionQueryBo bo) {
         LambdaQueryWrapper<BsUserGoodsCollection> lqw = Wrappers.lambdaQuery();
@@ -99,7 +101,7 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
         lqw.eq(bo.getStatus() != null, BsUserGoodsCollection::getStatus, bo.getStatus());
         lqw.eq(bo.getConfigId() != null, BsUserGoodsCollection::getConfigId, bo.getConfigId());
         lqw.eq(bo.getCompanyId() != null, BsUserGoodsCollection::getCompanyId, bo.getCompanyId());
-        lqw.eq( BsUserGoodsCollection::getCollectStatus,1);
+        lqw.eq(BsUserGoodsCollection::getCollectStatus, 1);
         List<BsUserGoodsCollectionVo> bsUserGoodsCollectionVos = entity2Vo(this.list(lqw));
         bsUserGoodsCollectionVos.forEach(item -> {
             if (Validator.isNotEmpty(item.getConfigId())) {
@@ -127,7 +129,7 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
                             strings.add(companyGoodsVos.get(1).getGoodsName());
                             strings.add("等" + companyGoodsVos.size() + "个课程");
                             item.setGoods(getReplace(strings));
-                        }else {
+                        } else {
                             List<String> collect2 = companyGoodsVos.stream().map(CompanyGoodsVo::getGoodsName).distinct().collect(Collectors.toList());
                             item.setGoods(getReplace(collect2));
                         }
@@ -138,36 +140,36 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
                             strings.add(subjectNames.get(1));
                             strings.add("等" + subjectNames.size() + "个科目");
                             item.setSubjectName(getReplace(strings));
-                        }else {
+                        } else {
                             item.setSubjectName(getReplace(subjectNames));
                         }
                         List<Long> years = companyGoodsVos.stream().map(CompanyGoodsVo::getYear).collect(Collectors.toList());
                         List<String> yearList = years.stream().map(String::valueOf).collect(Collectors.toList());
-                        if (!yearList.isEmpty() &&yearList.size()>2){
+                        if (!yearList.isEmpty() && yearList.size() > 2) {
                             List<String> strings = new ArrayList<>();
                             strings.add(yearList.get(0));
                             strings.add(yearList.get(1));
                             strings.add("等" + yearList.size() + "个年份");
                             item.setYear(getReplace(strings));
-                        }else {
+                        } else {
                             item.setYear(getReplace(yearList));
                         }
                         List<BigDecimal> prices = companyGoodsVos.stream().map(CompanyGoodsVo::getStandPrice).collect(Collectors.toList());
                         List<String> priecsList = prices.stream().map(String::valueOf).collect(Collectors.toList());
-                        if (!priecsList.isEmpty()&&priecsList.size()>2){
+                        if (!priecsList.isEmpty() && priecsList.size() > 2) {
                             List<String> strings = new ArrayList<>();
                             strings.add(priecsList.get(0));
                             strings.add(priecsList.get(1));
                             strings.add("等" + priecsList.size() + "个价格");
                             item.setPrice(getReplace(strings));
-                        }else {
+                        } else {
                             item.setPrice(getReplace(priecsList));
                         }
                     }
 
                 }
             }
-            if(Validator.isNotEmpty(item.getGoodsId())){
+            if (Validator.isNotEmpty(item.getGoodsId())) {
                 GoodsVo goodsVo = iGoodsService.selectDetail(item.getGoodsId());
                 item.setTypeName(getTypeName(item.getGoodsType()));
                 item.setBusinessName(goodsVo.getBusinessName());
@@ -209,7 +211,7 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
                     .eq(BsUserGoodsCollection::getConfigId, bo.getConfigId())
                     .eq(BsUserGoodsCollection::getCollectStatus, 1)
                     .eq(BsUserGoodsCollection::getStatus, 1));
-            if (!bsUserGoodsCollections.isEmpty()){
+            if (!bsUserGoodsCollections.isEmpty()) {
                 throw new CustomException("请勿重复收藏");
             }
             OrderBusinessConfigQueryBo orderBusinessConfigQueryBo = new OrderBusinessConfigQueryBo();
@@ -220,31 +222,23 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
             add.setEducationTypeId(detail.getEducationType());
             add.setEducationName(detail.getEducationName());
             add.setProjectId(detail.getProjectId());
-            add.setProjectName(detail.getBusinessName()+detail.getProjectName());
+            add.setProjectName(detail.getBusinessName() + detail.getProjectName());
         }
         if (Validator.isNotEmpty(bo.getGoodsId())) {
             List<BsUserGoodsCollection> bsUserGoodsCollections = this.list(new LambdaQueryWrapper<BsUserGoodsCollection>()
                     .eq(BsUserGoodsCollection::getGoodsId, bo.getGoodsId())
                     .eq(BsUserGoodsCollection::getCollectStatus, 1)
                     .eq(BsUserGoodsCollection::getStatus, 1));
-            if (!bsUserGoodsCollections.isEmpty()){
+            if (!bsUserGoodsCollections.isEmpty()) {
                 throw new CustomException("请勿重复收藏");
             }
-            GoodsQueryBo goodsQueryBo = new GoodsQueryBo();
-            goodsQueryBo.setGoodsId(bo.getGoodsId());
-            List<Integer> integers = new ArrayList<>();
-            integers.add(1);
-            goodsQueryBo.setStatus(integers);
-            List<CompanyGoodsVo> list = iGoodsService.selectBsGoodList(goodsQueryBo);
-            if (Validator.isNotEmpty(list)) {
-                CompanyGoodsVo goods = list.get(0);
-                add.setGoodsType(goods.getGoodsType().longValue());
-                add.setGoodsName(goods.getGoodsName());
-                add.setEducationTypeId(goods.getEducationTypeId());
-                add.setEducationName(goods.getEducationName());
-                add.setProjectId(goods.getProjectId());
-                add.setProjectName(goods.getBusinessName()+goods.getProjectName());
-            }
+            GoodsVo goodsVo = iGoodsService.selectDetail(bo.getGoodsId());
+            add.setGoodsType(goodsVo.getGoodsType().longValue());
+            add.setGoodsName(goodsVo.getGoodsName());
+            add.setEducationTypeId(goodsVo.getEducationTypeId());
+            add.setEducationName(goodsVo.getEducationName());
+            add.setProjectId(goodsVo.getProjectId());
+            add.setProjectName(goodsVo.getBusinessName() + goodsVo.getProjectName());
         }
         add.setUserId(bo.getUserId());
         add.setCreateTime(DateUtils.getNowTime());
@@ -255,16 +249,16 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
     @Override
     public Boolean updateByEditBo(BsUserGoodsCollectionQueryBo bo) {
         BsUserGoodsCollection bsUserGoodsCollection = new BsUserGoodsCollection();
-        if (Validator.isNotEmpty(bo.getConfigId())||Validator.isNotEmpty(bo.getGoodsId())){
-             bsUserGoodsCollection = this.selectById(bo);
-            if (ObjectUtil.isEmpty(bsUserGoodsCollection)){
+        if (Validator.isNotEmpty(bo.getConfigId()) || Validator.isNotEmpty(bo.getGoodsId())) {
+            bsUserGoodsCollection = this.selectById(bo);
+            if (ObjectUtil.isEmpty(bsUserGoodsCollection)) {
                 throw new CustomException("当前商品不存在收藏列表");
             }
         }
         return this.removeById(bsUserGoodsCollection.getId());
     }
 
-    public String getTypeName(Long Type){
+    public String getTypeName(Long Type) {
         if (Type == 1L) {
             return "课程";
         } else if (Type == 2L) {
@@ -283,6 +277,7 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
         return null;
 
     }
+
     /**
      * 保存前的数据校验
      *