|
@@ -2,7 +2,7 @@ package com.zhongzheng.modules.bs.goods.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
import cn.hutool.core.lang.Validator;
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.modules.bs.goods.bo.BsUserGoodsCollectionAddBo;
|
|
import com.zhongzheng.modules.bs.goods.bo.BsUserGoodsCollectionAddBo;
|
|
@@ -22,7 +22,6 @@ import com.zhongzheng.modules.order.service.IOrderBusinessConfigGoodsService;
|
|
|
import com.zhongzheng.modules.order.service.IOrderBusinessConfigService;
|
|
import com.zhongzheng.modules.order.service.IOrderBusinessConfigService;
|
|
|
import com.zhongzheng.modules.order.vo.CompanyOrderBusinessConfigGoodsVo;
|
|
import com.zhongzheng.modules.order.vo.CompanyOrderBusinessConfigGoodsVo;
|
|
|
import com.zhongzheng.modules.order.vo.OrderBusinessConfigVo;
|
|
import com.zhongzheng.modules.order.vo.OrderBusinessConfigVo;
|
|
|
-import net.bytebuddy.implementation.bytecode.Throw;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -51,10 +50,41 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public BsUserGoodsCollectionVo queryById(Long id) {
|
|
public BsUserGoodsCollectionVo queryById(Long id) {
|
|
|
- BsUserGoodsCollection db = this.baseMapper.selectById(id);
|
|
|
|
|
- return BeanUtil.toBean(db, BsUserGoodsCollectionVo.class);
|
|
|
|
|
|
|
+ BsUserGoodsCollection bsUserGoodsCollection = this.baseMapper.selectById(id);
|
|
|
|
|
+ return BeanUtil.toBean(bsUserGoodsCollection, BsUserGoodsCollectionVo.class);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public BsUserGoodsCollection selectById(BsUserGoodsCollectionQueryBo bo) {
|
|
|
|
|
+ BsUserGoodsCollection bsUserGoodsCollectionVo = new BsUserGoodsCollection();
|
|
|
|
|
+ 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()){
|
|
|
|
|
+ bsUserGoodsCollectionVo = bsUserGoodsCollections.get(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ 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()){
|
|
|
|
|
+ bsUserGoodsCollectionVo = bsUserGoodsCollections.get(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return bsUserGoodsCollectionVo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public String getReplace(List<String> string){
|
|
|
|
|
+ if (Validator.isEmpty(string)){
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ String strings = string.toString().replace("[", "").replace("]", "").toString();
|
|
|
|
|
+ return strings;
|
|
|
|
|
+ }
|
|
|
@Override
|
|
@Override
|
|
|
public List<BsUserGoodsCollectionVo> queryList(BsUserGoodsCollectionQueryBo bo) {
|
|
public List<BsUserGoodsCollectionVo> queryList(BsUserGoodsCollectionQueryBo bo) {
|
|
|
LambdaQueryWrapper<BsUserGoodsCollection> lqw = Wrappers.lambdaQuery();
|
|
LambdaQueryWrapper<BsUserGoodsCollection> lqw = Wrappers.lambdaQuery();
|
|
@@ -68,10 +98,11 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
|
|
|
lqw.eq(bo.getUserId() != null, BsUserGoodsCollection::getUserId, bo.getUserId());
|
|
lqw.eq(bo.getUserId() != null, BsUserGoodsCollection::getUserId, bo.getUserId());
|
|
|
lqw.eq(bo.getStatus() != null, BsUserGoodsCollection::getStatus, bo.getStatus());
|
|
lqw.eq(bo.getStatus() != null, BsUserGoodsCollection::getStatus, bo.getStatus());
|
|
|
lqw.eq(bo.getConfigId() != null, BsUserGoodsCollection::getConfigId, bo.getConfigId());
|
|
lqw.eq(bo.getConfigId() != null, BsUserGoodsCollection::getConfigId, bo.getConfigId());
|
|
|
- lqw.eq(bo.getCollectStatus() != null, BsUserGoodsCollection::getCollectStatus,1);
|
|
|
|
|
|
|
+ lqw.eq( BsUserGoodsCollection::getCollectStatus,1);
|
|
|
List<BsUserGoodsCollectionVo> bsUserGoodsCollectionVos = entity2Vo(this.list(lqw));
|
|
List<BsUserGoodsCollectionVo> bsUserGoodsCollectionVos = entity2Vo(this.list(lqw));
|
|
|
bsUserGoodsCollectionVos.forEach(item -> {
|
|
bsUserGoodsCollectionVos.forEach(item -> {
|
|
|
if (Validator.isNotEmpty(item.getConfigId())) {
|
|
if (Validator.isNotEmpty(item.getConfigId())) {
|
|
|
|
|
+ item.setTypeName(getTypeName(item.getType()));
|
|
|
OrderBusinessConfigGoodsQueryBo orderBusinessConfigGoodsQueryBo = new OrderBusinessConfigGoodsQueryBo();
|
|
OrderBusinessConfigGoodsQueryBo orderBusinessConfigGoodsQueryBo = new OrderBusinessConfigGoodsQueryBo();
|
|
|
orderBusinessConfigGoodsQueryBo.setConfigId(item.getConfigId());
|
|
orderBusinessConfigGoodsQueryBo.setConfigId(item.getConfigId());
|
|
|
List<CompanyOrderBusinessConfigGoodsVo> companyOrderBusinessConfigGoodsVos = iOrderBusinessConfigGoodsService.selectCompanyMergeList(orderBusinessConfigGoodsQueryBo);
|
|
List<CompanyOrderBusinessConfigGoodsVo> companyOrderBusinessConfigGoodsVos = iOrderBusinessConfigGoodsService.selectCompanyMergeList(orderBusinessConfigGoodsQueryBo);
|
|
@@ -91,42 +122,42 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
|
|
|
strings.add(companyGoodsVos.get(0).getGoodsName());
|
|
strings.add(companyGoodsVos.get(0).getGoodsName());
|
|
|
strings.add(companyGoodsVos.get(1).getGoodsName());
|
|
strings.add(companyGoodsVos.get(1).getGoodsName());
|
|
|
strings.add("等" + companyGoodsVos.size() + "个课程");
|
|
strings.add("等" + companyGoodsVos.size() + "个课程");
|
|
|
- item.setGoods(strings.toString().replace("[","").replace("]",""));
|
|
|
|
|
|
|
+ item.setGoods(getReplace(strings));
|
|
|
}else {
|
|
}else {
|
|
|
- List<String> collect2 = companyGoodsVos.stream().map(s -> s.getGoodsName()).distinct().collect(Collectors.toList());
|
|
|
|
|
- item.setGoods(collect2.toString().replace("[","").replace("]",""));
|
|
|
|
|
|
|
+ List<String> collect2 = companyGoodsVos.stream().map(CompanyGoodsVo::getGoodsName).distinct().collect(Collectors.toList());
|
|
|
|
|
+ item.setGoods(getReplace(collect2));
|
|
|
}
|
|
}
|
|
|
- List<String> subjectNames = companyGoodsVos.stream().map(s -> s.getSubjectNames()).distinct().collect(Collectors.toList());
|
|
|
|
|
|
|
+ List<String> subjectNames = companyGoodsVos.stream().map(CompanyGoodsVo::getSubjectNames).distinct().collect(Collectors.toList());
|
|
|
if (Validator.isNotEmpty(subjectNames) && subjectNames.size() > 2) {
|
|
if (Validator.isNotEmpty(subjectNames) && subjectNames.size() > 2) {
|
|
|
List<String> strings = new ArrayList<>();
|
|
List<String> strings = new ArrayList<>();
|
|
|
strings.add(subjectNames.get(0));
|
|
strings.add(subjectNames.get(0));
|
|
|
strings.add(subjectNames.get(1));
|
|
strings.add(subjectNames.get(1));
|
|
|
strings.add("等" + subjectNames.size() + "个科目");
|
|
strings.add("等" + subjectNames.size() + "个科目");
|
|
|
- item.setSubjectName(strings.toString().replace("[","").replace("]",""));
|
|
|
|
|
|
|
+ item.setSubjectName(getReplace(strings));
|
|
|
}else {
|
|
}else {
|
|
|
- item.setSubjectName(subjectNames.toString().replace("[","").replace("]",""));
|
|
|
|
|
|
|
+ item.setSubjectName(getReplace(subjectNames));
|
|
|
}
|
|
}
|
|
|
- List<Long> years = companyGoodsVos.stream().map(s -> s.getYear()).collect(Collectors.toList());
|
|
|
|
|
|
|
+ List<Long> years = companyGoodsVos.stream().map(CompanyGoodsVo::getYear).collect(Collectors.toList());
|
|
|
List<String> yearList = years.stream().map(String::valueOf).collect(Collectors.toList());
|
|
List<String> yearList = years.stream().map(String::valueOf).collect(Collectors.toList());
|
|
|
if (Validator.isNotEmpty(yearList)&&yearList.size()>2){
|
|
if (Validator.isNotEmpty(yearList)&&yearList.size()>2){
|
|
|
List<String> strings = new ArrayList<>();
|
|
List<String> strings = new ArrayList<>();
|
|
|
strings.add(yearList.get(0));
|
|
strings.add(yearList.get(0));
|
|
|
strings.add(yearList.get(1));
|
|
strings.add(yearList.get(1));
|
|
|
strings.add("等" + yearList.size() + "个年份");
|
|
strings.add("等" + yearList.size() + "个年份");
|
|
|
- item.setYear(strings.toString().replace("[","").replace("]",""));
|
|
|
|
|
|
|
+ item.setYear(getReplace(strings));
|
|
|
}else {
|
|
}else {
|
|
|
- item.setYear(yearList.toString().replace("[","").replace("]",""));
|
|
|
|
|
|
|
+ item.setYear(getReplace(yearList));
|
|
|
}
|
|
}
|
|
|
- List<BigDecimal> prices = companyGoodsVos.stream().map(s -> s.getStandPrice()).collect(Collectors.toList());
|
|
|
|
|
|
|
+ List<BigDecimal> prices = companyGoodsVos.stream().map(CompanyGoodsVo::getStandPrice).collect(Collectors.toList());
|
|
|
List<String> priecsList = prices.stream().map(String::valueOf).collect(Collectors.toList());
|
|
List<String> priecsList = prices.stream().map(String::valueOf).collect(Collectors.toList());
|
|
|
if (Validator.isNotEmpty(priecsList)&&priecsList.size()>2){
|
|
if (Validator.isNotEmpty(priecsList)&&priecsList.size()>2){
|
|
|
List<String> strings = new ArrayList<>();
|
|
List<String> strings = new ArrayList<>();
|
|
|
strings.add(priecsList.get(0));
|
|
strings.add(priecsList.get(0));
|
|
|
strings.add(priecsList.get(1));
|
|
strings.add(priecsList.get(1));
|
|
|
strings.add("等" + priecsList.size() + "个价格");
|
|
strings.add("等" + priecsList.size() + "个价格");
|
|
|
- item.setYear(strings.toString().replace("[","").replace("]",""));
|
|
|
|
|
|
|
+ item.setYear(getReplace(strings));
|
|
|
}else {
|
|
}else {
|
|
|
- item.setYear(priecsList.toString().replace("[","").replace("]",""));
|
|
|
|
|
|
|
+ item.setYear(getReplace(priecsList));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -134,6 +165,7 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
|
|
|
}
|
|
}
|
|
|
if(Validator.isNotEmpty(item.getGoodsId())){
|
|
if(Validator.isNotEmpty(item.getGoodsId())){
|
|
|
GoodsVo goodsVo = iGoodsService.selectDetail(item.getGoodsId());
|
|
GoodsVo goodsVo = iGoodsService.selectDetail(item.getGoodsId());
|
|
|
|
|
+ item.setTypeName(getTypeName(item.getType()));
|
|
|
item.setSubjectName(goodsVo.getSubjectNames());
|
|
item.setSubjectName(goodsVo.getSubjectNames());
|
|
|
item.setGoods(goodsVo.getGoodsName());
|
|
item.setGoods(goodsVo.getGoodsName());
|
|
|
item.setYear(goodsVo.getYear().toString());
|
|
item.setYear(goodsVo.getYear().toString());
|
|
@@ -168,6 +200,13 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
|
|
|
BsUserGoodsCollection add = BeanUtil.toBean(bo, BsUserGoodsCollection.class);
|
|
BsUserGoodsCollection add = BeanUtil.toBean(bo, BsUserGoodsCollection.class);
|
|
|
validEntityBeforeSave(add);
|
|
validEntityBeforeSave(add);
|
|
|
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::getCollectStatus, 1)
|
|
|
|
|
+ .eq(BsUserGoodsCollection::getStatus, 1));
|
|
|
|
|
+ if (!bsUserGoodsCollections.isEmpty()){
|
|
|
|
|
+ throw new CustomException("请勿重复收藏");
|
|
|
|
|
+ }
|
|
|
OrderBusinessConfigQueryBo orderBusinessConfigQueryBo = new OrderBusinessConfigQueryBo();
|
|
OrderBusinessConfigQueryBo orderBusinessConfigQueryBo = new OrderBusinessConfigQueryBo();
|
|
|
orderBusinessConfigQueryBo.setId(bo.getConfigId());
|
|
orderBusinessConfigQueryBo.setId(bo.getConfigId());
|
|
|
OrderBusinessConfigVo detail = iOrderBusinessConfigService.getDetail(orderBusinessConfigQueryBo);
|
|
OrderBusinessConfigVo detail = iOrderBusinessConfigService.getDetail(orderBusinessConfigQueryBo);
|
|
@@ -176,10 +215,16 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
|
|
|
add.setEducationType(detail.getEducationType());
|
|
add.setEducationType(detail.getEducationType());
|
|
|
add.setEducationName(detail.getEducationName());
|
|
add.setEducationName(detail.getEducationName());
|
|
|
add.setProjectId(detail.getProjectId());
|
|
add.setProjectId(detail.getProjectId());
|
|
|
- add.setProjectName(detail.getProjectName());
|
|
|
|
|
-
|
|
|
|
|
|
|
+ add.setProjectName(detail.getBusinessName()+detail.getProjectName());
|
|
|
}
|
|
}
|
|
|
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::getCollectStatus, 1)
|
|
|
|
|
+ .eq(BsUserGoodsCollection::getStatus, 1));
|
|
|
|
|
+ if (!bsUserGoodsCollections.isEmpty()){
|
|
|
|
|
+ throw new CustomException("请勿重复收藏");
|
|
|
|
|
+ }
|
|
|
GoodsQueryBo goodsQueryBo = new GoodsQueryBo();
|
|
GoodsQueryBo goodsQueryBo = new GoodsQueryBo();
|
|
|
goodsQueryBo.setGoodsId(bo.getGoodsId());
|
|
goodsQueryBo.setGoodsId(bo.getGoodsId());
|
|
|
List<Integer> integers = new ArrayList<>();
|
|
List<Integer> integers = new ArrayList<>();
|
|
@@ -193,7 +238,7 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
|
|
|
add.setEducationType(goods.getEducationTypeId());
|
|
add.setEducationType(goods.getEducationTypeId());
|
|
|
add.setEducationName(goods.getEducationName());
|
|
add.setEducationName(goods.getEducationName());
|
|
|
add.setProjectId(goods.getProjectId());
|
|
add.setProjectId(goods.getProjectId());
|
|
|
- add.setProjectName(goods.getProjectName());
|
|
|
|
|
|
|
+ add.setProjectName(goods.getBusinessName()+goods.getProjectName());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
add.setUserId(bo.getUserId());
|
|
add.setUserId(bo.getUserId());
|
|
@@ -203,19 +248,36 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public Boolean updateByEditBo(BsUserGoodsCollectionEditBo bo) {
|
|
|
|
|
- BsUserGoodsCollection update = BeanUtil.toBean(bo, BsUserGoodsCollection.class);
|
|
|
|
|
- validEntityBeforeSave(update);
|
|
|
|
|
- BsUserGoodsCollectionVo bsUserGoodsCollectionVo = this.queryById(update.getId());
|
|
|
|
|
- if (Validator.isNotEmpty(bsUserGoodsCollectionVo)&&bsUserGoodsCollectionVo.getCollectStatus()!=0){
|
|
|
|
|
- update.setCollectStatus(0);
|
|
|
|
|
- update.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
|
- }else {
|
|
|
|
|
- throw new CustomException("当前收藏商品不存在");
|
|
|
|
|
|
|
+ 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)){
|
|
|
|
|
+ throw new CustomException("当前商品不存在收藏列表");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- return this.updateById(update);
|
|
|
|
|
|
|
+ return this.removeById(bsUserGoodsCollection.getId());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public String getTypeName(Long Type){
|
|
|
|
|
+ if (Type == 1L) {
|
|
|
|
|
+ return "课程";
|
|
|
|
|
+ } else if (Type == 2L) {
|
|
|
|
|
+ return "题库";
|
|
|
|
|
+ } else if (Type == 3L) {
|
|
|
|
|
+ return "";
|
|
|
|
|
+ } else if (Type == 4L) {
|
|
|
|
|
+ return "";
|
|
|
|
|
+ } else if (Type == 5L) {
|
|
|
|
|
+ return "";
|
|
|
|
|
+ } else if (Type == 6L) {
|
|
|
|
|
+ return "直播";
|
|
|
|
|
+ } else if (Type == 10L) {
|
|
|
|
|
+ return "商品包";
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
/**
|
|
/**
|
|
|
* 保存前的数据校验
|
|
* 保存前的数据校验
|
|
|
*
|
|
*
|