|
@@ -1,14 +1,12 @@
|
|
|
package com.zhongzheng.modules.top.goods.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.github.pagehelper.Page;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.modules.bank.domain.*;
|
|
@@ -21,8 +19,7 @@ import com.zhongzheng.modules.exam.domain.ExamPaper;
|
|
|
import com.zhongzheng.modules.exam.service.IExamPaperService;
|
|
|
import com.zhongzheng.modules.goods.domain.*;
|
|
|
import com.zhongzheng.modules.goods.service.*;
|
|
|
-import com.zhongzheng.modules.grade.service.IClassGradeInterfaceService;
|
|
|
-import com.zhongzheng.modules.order.service.IOrderInputTemplateService;
|
|
|
+import com.zhongzheng.modules.goods.vo.TopGoodsVo;
|
|
|
import com.zhongzheng.modules.pay.domain.PayServe;
|
|
|
import com.zhongzheng.modules.pay.domain.PaySupply;
|
|
|
import com.zhongzheng.modules.pay.service.IPayServeService;
|
|
@@ -32,14 +29,11 @@ import com.zhongzheng.modules.polyv.domain.PolyvVideo;
|
|
|
import com.zhongzheng.modules.polyv.service.IPolyvCataService;
|
|
|
import com.zhongzheng.modules.polyv.service.IPolyvVideoService;
|
|
|
import com.zhongzheng.modules.system.bo.GoodsCopyEnum;
|
|
|
-import com.zhongzheng.modules.system.service.ISysGoodsCopyRecordService;
|
|
|
-import com.zhongzheng.modules.top.goods.bo.TopGoodsAddBo;
|
|
|
-import com.zhongzheng.modules.top.goods.bo.TopGoodsEditBo;
|
|
|
import com.zhongzheng.modules.top.goods.bo.TopGoodsQueryBo;
|
|
|
import com.zhongzheng.modules.top.goods.domain.*;
|
|
|
import com.zhongzheng.modules.top.goods.mapper.TopGoodsMapper;
|
|
|
import com.zhongzheng.modules.top.goods.service.*;
|
|
|
-import com.zhongzheng.modules.top.goods.vo.TopGoodsVo;
|
|
|
+import com.zhongzheng.modules.top.goods.vo.TopBankGoodsExamVo;
|
|
|
import net.polyv.common.v1.util.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -47,7 +41,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
-import java.util.Collection;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -69,10 +63,6 @@ public class TopGoodsServiceImpl extends ServiceImpl<TopGoodsMapper, TopGoods> i
|
|
|
@Autowired
|
|
|
private ICourseService iCourseService;
|
|
|
@Autowired
|
|
|
- private IOrderInputTemplateService iOrderInputTemplateService;
|
|
|
- @Autowired
|
|
|
- private IClassGradeInterfaceService iClassGradeInterfaceService;
|
|
|
- @Autowired
|
|
|
private ICourseMenuService iCourseMenuService;
|
|
|
@Autowired
|
|
|
private ICourseMenuExamService iCourseMenuExamService;
|
|
@@ -139,8 +129,6 @@ public class TopGoodsServiceImpl extends ServiceImpl<TopGoodsMapper, TopGoods> i
|
|
|
@Autowired
|
|
|
private ICertificateTpService iCertificateTpService;
|
|
|
@Autowired
|
|
|
- private ISysGoodsCopyRecordService iSysGoodsCopyRecordService;
|
|
|
- @Autowired
|
|
|
private IGoodsCourseTeacherService goodsCourseTeacherService;
|
|
|
@Autowired
|
|
|
private ICourseChapterService iCourseChapterService;
|
|
@@ -168,9 +156,9 @@ public class TopGoodsServiceImpl extends ServiceImpl<TopGoodsMapper, TopGoods> i
|
|
|
private IMajorProjectService iMajorProjectService;
|
|
|
@Autowired
|
|
|
private IPayServeService iPayServeService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ITopGoodsCopyService iTopGoodsCopyService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private ITopGoodsCourseService iTopGoodsCourseService;
|
|
|
@Autowired
|
|
@@ -272,132 +260,12 @@ public class TopGoodsServiceImpl extends ServiceImpl<TopGoodsMapper, TopGoods> i
|
|
|
@Autowired
|
|
|
private ITopPayServeService iTopPayServeService;
|
|
|
|
|
|
- @Override
|
|
|
- public TopGoodsVo queryById(Long goodsId){
|
|
|
- TopGoods db = this.baseMapper.selectById(goodsId);
|
|
|
- return BeanUtil.toBean(db, TopGoodsVo.class);
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
- public List<TopGoodsVo> queryList(TopGoodsQueryBo bo) {
|
|
|
- LambdaQueryWrapper<TopGoods> lqw = Wrappers.lambdaQuery();
|
|
|
- lqw.eq(bo.getYear() != null, TopGoods::getYear, bo.getYear());
|
|
|
- lqw.eq(bo.getSupplyId() != null, TopGoods::getSupplyId, bo.getSupplyId());
|
|
|
- lqw.eq(bo.getGoodsType() != null, TopGoods::getGoodsType, bo.getGoodsType());
|
|
|
- lqw.eq(bo.getEducationTypeId() != null, TopGoods::getEducationTypeId, bo.getEducationTypeId());
|
|
|
- lqw.eq(bo.getBusinessId() != null, TopGoods::getBusinessId, bo.getBusinessId());
|
|
|
- lqw.eq(bo.getSchoolId() != null, TopGoods::getSchoolId, bo.getSchoolId());
|
|
|
- lqw.eq(bo.getMajorId() != null, TopGoods::getMajorId, bo.getMajorId());
|
|
|
- lqw.like(StrUtil.isNotBlank(bo.getGoodsName()), TopGoods::getGoodsName, bo.getGoodsName());
|
|
|
- lqw.eq(bo.getStandPrice() != null, TopGoods::getStandPrice, bo.getStandPrice());
|
|
|
- lqw.eq(bo.getLowestPrice() != null, TopGoods::getLowestPrice, bo.getLowestPrice());
|
|
|
- lqw.eq(bo.getStatus() != null, TopGoods::getStatus, bo.getStatus());
|
|
|
- lqw.eq(bo.getValidityStartTime() != null, TopGoods::getValidityStartTime, bo.getValidityStartTime());
|
|
|
- lqw.eq(bo.getValidityEndTime() != null, TopGoods::getValidityEndTime, bo.getValidityEndTime());
|
|
|
- lqw.eq(bo.getStudyStartTime() != null, TopGoods::getStudyStartTime, bo.getStudyStartTime());
|
|
|
- lqw.eq(bo.getStudyEndTime() != null, TopGoods::getStudyEndTime, bo.getStudyEndTime());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getCertificateIds()), TopGoods::getCertificateIds, bo.getCertificateIds());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getIntroduce()), TopGoods::getIntroduce, bo.getIntroduce());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getSuitableObject()), TopGoods::getSuitableObject, bo.getSuitableObject());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getBuyNote()), TopGoods::getBuyNote, bo.getBuyNote());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getPcDetailHtml()), TopGoods::getPcDetailHtml, bo.getPcDetailHtml());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getMobileDetailHtml()), TopGoods::getMobileDetailHtml, bo.getMobileDetailHtml());
|
|
|
- lqw.eq(bo.getGoodsStatus() != null, TopGoods::getGoodsStatus, bo.getGoodsStatus());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getCoverUrl()), TopGoods::getCoverUrl, bo.getCoverUrl());
|
|
|
- lqw.eq(bo.getClassHours() != null, TopGoods::getClassHours, bo.getClassHours());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getStandPriceJson()), TopGoods::getStandPriceJson, bo.getStandPriceJson());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getCode()), TopGoods::getCode, bo.getCode());
|
|
|
- lqw.eq(bo.getProjectId() != null, TopGoods::getProjectId, bo.getProjectId());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getGoodsAuditionConfig()), TopGoods::getGoodsAuditionConfig, bo.getGoodsAuditionConfig());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getGoodsPhotographConfig()), TopGoods::getGoodsPhotographConfig, bo.getGoodsPhotographConfig());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getGoodsPlayConfig()), TopGoods::getGoodsPlayConfig, bo.getGoodsPlayConfig());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getGoodsExamConfig()), TopGoods::getGoodsExamConfig, bo.getGoodsExamConfig());
|
|
|
- lqw.eq(bo.getHandoutsId() != null, TopGoods::getHandoutsId, bo.getHandoutsId());
|
|
|
- lqw.eq(bo.getMakeStartTime() != null, TopGoods::getMakeStartTime, bo.getMakeStartTime());
|
|
|
- lqw.eq(bo.getMakeEndTime() != null, TopGoods::getMakeEndTime, bo.getMakeEndTime());
|
|
|
- lqw.eq(bo.getStudyCount() != null, TopGoods::getStudyCount, bo.getStudyCount());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getGoodsPhotoExamConfig()), TopGoods::getGoodsPhotoExamConfig, bo.getGoodsPhotoExamConfig());
|
|
|
- lqw.eq(bo.getMakeGoodsId() != null, TopGoods::getMakeGoodsId, bo.getMakeGoodsId());
|
|
|
- lqw.eq(bo.getServiceTimeType() != null, TopGoods::getServiceTimeType, bo.getServiceTimeType());
|
|
|
- lqw.eq(bo.getServiceTimeNum() != null, TopGoods::getServiceTimeNum, bo.getServiceTimeNum());
|
|
|
- lqw.eq(bo.getSectionMaxNum() != null, TopGoods::getSectionMaxNum, bo.getSectionMaxNum());
|
|
|
- lqw.eq(bo.getExamNumber() != null, TopGoods::getExamNumber, bo.getExamNumber());
|
|
|
- lqw.eq(bo.getDoNumber() != null, TopGoods::getDoNumber, bo.getDoNumber());
|
|
|
- lqw.eq(bo.getTeacherId() != null, TopGoods::getTeacherId, bo.getTeacherId());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getSubjectIds()), TopGoods::getSubjectIds, bo.getSubjectIds());
|
|
|
- lqw.eq(bo.getCertificateTypeId() != null, TopGoods::getCertificateTypeId, bo.getCertificateTypeId());
|
|
|
- lqw.eq(bo.getCertificateId() != null, TopGoods::getCertificateId, bo.getCertificateId());
|
|
|
- lqw.eq(bo.getCertificateTpId() != null, TopGoods::getCertificateTpId, bo.getCertificateTpId());
|
|
|
- lqw.eq(bo.getLinePrice() != null, TopGoods::getLinePrice, bo.getLinePrice());
|
|
|
- lqw.eq(bo.getSpecTemplateId() != null, TopGoods::getSpecTemplateId, bo.getSpecTemplateId());
|
|
|
- lqw.eq(bo.getShowStatus() != null, TopGoods::getShowStatus, bo.getShowStatus());
|
|
|
- lqw.eq(bo.getShowSort() != null, TopGoods::getShowSort, bo.getShowSort());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getExternalLink()), TopGoods::getExternalLink, bo.getExternalLink());
|
|
|
- lqw.eq(bo.getExternalLinkStatus() != null, TopGoods::getExternalLinkStatus, bo.getExternalLinkStatus());
|
|
|
- lqw.eq(bo.getCommitPeriodStatus() != null, TopGoods::getCommitPeriodStatus, bo.getCommitPeriodStatus());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getCommitPeriodRemark()), TopGoods::getCommitPeriodRemark, bo.getCommitPeriodRemark());
|
|
|
- return entity2Vo(this.list(lqw));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 实体类转化成视图对象
|
|
|
- *
|
|
|
- * @param collection 实体类集合
|
|
|
- * @return
|
|
|
- */
|
|
|
- private List<TopGoodsVo> entity2Vo(Collection<TopGoods> collection) {
|
|
|
- List<TopGoodsVo> voList = collection.stream()
|
|
|
- .map(any -> BeanUtil.toBean(any, TopGoodsVo.class))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (collection instanceof Page) {
|
|
|
- Page<TopGoods> page = (Page<TopGoods>)collection;
|
|
|
- Page<TopGoodsVo> pageVo = new Page<>();
|
|
|
- BeanUtil.copyProperties(page,pageVo);
|
|
|
- pageVo.addAll(voList);
|
|
|
- voList = pageVo;
|
|
|
- }
|
|
|
- return voList;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Boolean insertByAddBo(TopGoodsAddBo bo) {
|
|
|
- TopGoods add = BeanUtil.toBean(bo, TopGoods.class);
|
|
|
- validEntityBeforeSave(add);
|
|
|
- add.setCreateTime(DateUtils.getNowTime());
|
|
|
- add.setUpdateTime(DateUtils.getNowTime());
|
|
|
- return this.save(add);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Boolean updateByEditBo(TopGoodsEditBo bo) {
|
|
|
- TopGoods update = BeanUtil.toBean(bo, TopGoods.class);
|
|
|
- validEntityBeforeSave(update);
|
|
|
- update.setUpdateTime(DateUtils.getNowTime());
|
|
|
- return this.updateById(update);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 保存前的数据校验
|
|
|
- *
|
|
|
- * @param entity 实体类数据
|
|
|
- */
|
|
|
- private void validEntityBeforeSave(TopGoods entity){
|
|
|
- //TODO 做一些数据校验,如唯一约束
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
- if(isValid){
|
|
|
- //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
- }
|
|
|
- return this.removeByIds(ids);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
+// @Transactional(rollbackFor = Exception.class)
|
|
|
public boolean goodsBatchCopyTenant() {
|
|
|
List<TopGoodsCopy> copyRecordList = new ArrayList<>();
|
|
|
- String tenantId = "867735392558919680";
|
|
|
+ Long tenantId = 867735392558919680L;
|
|
|
//全量同步
|
|
|
// 1 goods
|
|
|
List<Goods> goodsList = iGoodsService.list(new LambdaQueryWrapper<Goods>().eq(Goods::getTenantId,tenantId));
|
|
@@ -1326,7 +1194,9 @@ public class TopGoodsServiceImpl extends ServiceImpl<TopGoodsMapper, TopGoods> i
|
|
|
//所属专业
|
|
|
goods.setMajorId(getNewId(goods.getMajorId(), GoodsCopyEnum.MAJOR.getType()));
|
|
|
//项目
|
|
|
- goods.setProjectId(getNewId(goods.getProjectId().longValue(), GoodsCopyEnum.COURSE_PROJECT_TYPE.getType()));
|
|
|
+ if (ObjectUtils.isNotNull(goods.getProjectId())){
|
|
|
+ goods.setProjectId(getNewId(goods.getProjectId().longValue(), GoodsCopyEnum.COURSE_PROJECT_TYPE.getType()));
|
|
|
+ }
|
|
|
//讲义
|
|
|
goods.setHandoutsId(getNewId(goods.getHandoutsId(), GoodsCopyEnum.COURSE_HANDOUTS.getType()));
|
|
|
//科目
|
|
@@ -1882,4 +1752,48 @@ public class TopGoodsServiceImpl extends ServiceImpl<TopGoodsMapper, TopGoods> i
|
|
|
return records.stream().map(x -> x.getNewId().toString()).collect(Collectors.joining(","));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TopGoodsVo> selectList(TopGoodsQueryBo bo) {
|
|
|
+ if (Validator.isNotEmpty(bo.getGoodsName())) {
|
|
|
+ bo.setGoodsName(bo.getGoodsName().trim());
|
|
|
+ }
|
|
|
+ List<TopGoodsVo> list = baseMapper.selectAllList(bo);
|
|
|
+ if (Validator.isNotEmpty(bo.getSectionNum()) && bo.getSectionNum().longValue() == 1) {
|
|
|
+ for (TopGoodsVo vo : list) {
|
|
|
+ Long sectionNum = baseMapper.getSectionNum(vo.getGoodsId());
|
|
|
+ vo.setSectionNum(sectionNum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list.forEach(goods -> {
|
|
|
+ //多规格下的价格区间
|
|
|
+ if (ObjectUtils.isNotNull(goods.getSpecTemplateId())) {
|
|
|
+ List<TopGoodsSpecAttributeRelation> specAttributeRelations = topGoodsSpecAttributeRelationService
|
|
|
+ .list(new LambdaQueryWrapper<TopGoodsSpecAttributeRelation>()
|
|
|
+ .eq(TopGoodsSpecAttributeRelation::getSpecTemplateId, goods.getSpecTemplateId()));
|
|
|
+ if (CollectionUtils.isNotEmpty(specAttributeRelations)) {
|
|
|
+ List<Long> goodsIds = specAttributeRelations.stream().filter(x -> ObjectUtils.isNotNull(x.getGoodsId())).map(TopGoodsSpecAttributeRelation::getGoodsId).collect(Collectors.toList());
|
|
|
+ List<TopGoods> goodsList = listByIds(goodsIds);
|
|
|
+ //从小到大排序
|
|
|
+ List<TopGoods> collect = goodsList.stream().filter(x -> ObjectUtils.isNotNull(x.getStandPrice())).sorted(Comparator.comparing(TopGoods::getStandPrice)).collect(Collectors.toList());
|
|
|
+ goods.setMinPrice(collect.get(0).getStandPrice());
|
|
|
+ goods.setMaxPrice(collect.get(collect.size() - 1).getStandPrice());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //是否包含每日一练试卷
|
|
|
+ if (goods.getGoodsType() == 2) {
|
|
|
+ //题库商品
|
|
|
+ List<TopBankGoodsExamVo> examVos = iTopQuestionService.getBankGoodsExamList(goods.getGoodsId());
|
|
|
+ if (examVos.stream().filter(x -> StringUtils.isNotBlank(x.getPaperName())).anyMatch(x -> x.getPaperName().equals("每日一练"))) {
|
|
|
+ goods.setExamRecord(1);
|
|
|
+ } else {
|
|
|
+ goods.setExamRecord(0);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ goods.setExamRecord(0);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
}
|