yangdamao 2 лет назад
Родитель
Сommit
2309583ca8

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java

@@ -1789,6 +1789,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public boolean addGoodsExamTime(List<BankGoodsExamAddBo> addBo) {
         Long goodsId = addBo.get(0).getGoodsId();
         //先删除之前的时间

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/QuestionModuleVo.java

@@ -81,4 +81,7 @@ public class QuestionModuleVo {
 	@ApiModelProperty("修改时间")
 	@Excel(name = "修改时间")
 	private Long updateTime;
+
+	@ApiModelProperty("题目数量")
+	private Integer questionNum;
 }

+ 17 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -13,6 +13,7 @@ import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.modules.activity.bo.ActivityRecommendGoodsQueryBo;
+import com.zhongzheng.modules.bank.mapper.QuestionMapper;
 import com.zhongzheng.modules.course.bo.CourseMenuAddBo;
 import com.zhongzheng.modules.course.bo.CourseMenuListAddBo;
 import com.zhongzheng.modules.course.bo.CourseMenuQueryBo;
@@ -32,6 +33,7 @@ import com.zhongzheng.modules.grade.vo.ClassGradeVo;
 import com.zhongzheng.modules.grade.vo.SyncGoodsExport;
 import com.zhongzheng.modules.order.domain.OrderGoods;
 import com.zhongzheng.modules.order.service.IOrderGoodsService;
+import net.polyv.common.v1.util.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -105,6 +107,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     @Autowired
     private  IGoodsSpecService goodsSpecService;
 
+    @Autowired
+    private QuestionMapper questionMapper;
+
     @Override
     public GoodsVo queryById(Long goodsId){
         Goods db = this.baseMapper.selectById(goodsId);
@@ -160,6 +165,18 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
                     goods.setSpecTemplateId(relation.getSpecTemplateId());
                 }
             }
+            //是否包含每日一练试卷
+            if (goods.getGoodsType() == 2){
+                //题库商品
+                List<BankGoodsExamVo> examVos = questionMapper.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);
+            }
         });
         //继教二建统计学时
         if (Validator.isNotEmpty(bo.getChapterNum())) {

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/vo/GoodsVo.java

@@ -325,4 +325,7 @@ public class GoodsVo {
 	@ApiModelProperty("业务层次学习顺序:1限制章下做卷顺序 0不限制 2限制整个目录顺序")
 	private Integer goodsLearningOrder;
 
+	@ApiModelProperty("是否包含每日一练试卷:1是 0否")
+	private Integer examRecord;
+
 }

+ 4 - 1
zhongzheng-system/src/main/resources/mapper/modules/bank/QuestionModuleMapper.xml

@@ -31,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="projectId" column="project_id"/>
         <result property="subjectName" column="subject_name"/>
         <result property="chapterExamNum" column="chapter_exam_num"/>
+        <result property="questionNum" column="question_num"/>
         <result property="createTime" column="create_time"/>
         <result property="updateTime" column="update_time"/>
         <collection property="goodsList" column="module_exam_id" select="findGoodsList"/>
@@ -63,7 +64,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         cpt.project_name,
         cb.business_name,
         cs.subject_name,
-        (SELECT COUNT(qmc.chapter_exam_id) FROM question_module_chapter qmc where qmc.module_exam_id = qm.module_exam_id ) as chapter_exam_num
+        (SELECT COUNT(qmc.chapter_exam_id) FROM question_module_chapter qmc where qmc.module_exam_id = qm.module_exam_id ) as chapter_exam_num,
+        (SELECT COUNT(question_id) FROM exam_question WHERE exam_id IN
+               (SELECT exam_id FROM question_chapter_exam qce LEFT JOIN question_module_chapter qmc ON qce.chapter_exam_id = qmc.chapter_exam_id WHERE qmc.module_exam_id = qm.module_exam_id)) as question_num
         FROM
         question_module qm
         LEFT JOIN question_business qb ON qm.module_exam_id = qb.major_id