Selaa lähdekoodia

fix 赠送题库

he2802 3 vuotta sitten
vanhempi
commit
1d340e97b8

+ 2 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/cmmon/CommonCourseController.java

@@ -79,4 +79,6 @@ public class CommonCourseController extends BaseController {
         return AjaxResult.success(list);
     }
 
+
+
 }

+ 11 - 1
zhongzheng-api/src/main/java/com/zhongzheng/controller/cmmon/CommonGoodsController.java

@@ -3,6 +3,8 @@ package com.zhongzheng.controller.cmmon;
 import com.zhongzheng.common.core.controller.BaseController;
 import com.zhongzheng.common.core.domain.AjaxResult;
 import com.zhongzheng.common.core.page.TableDataInfo;
+import com.zhongzheng.modules.bank.bo.QuestionChapterExamQueryBo;
+import com.zhongzheng.modules.course.vo.CourseModuleFreeExamVo;
 import com.zhongzheng.modules.goods.bo.GoodsAttachedQueryBo;
 import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
 import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
@@ -75,6 +77,14 @@ public class CommonGoodsController extends BaseController {
     }
 
 
-
+    /**
+     * 查询课程商品模块绑定赠送卷列表
+     */
+    @ApiOperation("查询课程商品模块绑定赠送卷列表")
+    @GetMapping("/course/moduleFreeExamList/{goodsId}")
+    public AjaxResult<List<CourseModuleFreeExamVo>> moduleFreeExamList(@PathVariable("goodsId" ) Long goodsId) {
+        List<CourseModuleFreeExamVo> list = iGoodsService.moduleFreeExamList(goodsId);
+        return AjaxResult.success(list);
+    }
 
 }

+ 2 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/goods/GoodsController.java

@@ -18,6 +18,7 @@ import com.zhongzheng.modules.bank.vo.QuestionChapterVo;
 import com.zhongzheng.modules.collect.bo.CollectQuestionQueryBo;
 import com.zhongzheng.modules.collect.service.ICollectQuestionService;
 import com.zhongzheng.modules.course.bo.CourseQueryBo;
+import com.zhongzheng.modules.course.vo.CourseModuleFreeExamVo;
 import com.zhongzheng.modules.goods.bo.*;
 import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
 import com.zhongzheng.modules.goods.service.IGoodsAuditionConfigService;
@@ -187,4 +188,5 @@ public class GoodsController extends BaseController {
         return AjaxResult.success(iUserPeriodService.todayStudySectionNum(bo));
     }
 
+
 }

+ 2 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseMenuVo.java

@@ -70,7 +70,8 @@ public class CourseMenuVo {
 	private Long freeExamId;
 	@ApiModelProperty("免费试卷类型")
 	private Integer examType;
-
+	@ApiModelProperty("赠送卷名称")
+	private String freeExamName;
 	/** 章模块关系 */
 	@Excel(name = "章模块关系")
 	@ApiModelProperty("章模块关系")

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseModuleFreeExamVo.java

@@ -28,5 +28,7 @@ public class CourseModuleFreeExamVo {
 	@Excel(name = "赠送卷ID")
 	@ApiModelProperty("赠送卷ID")
 	private Long freeExamId;
+	@ApiModelProperty("赠送卷名称")
+	private String freeExamName;
 
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/IGoodsService.java

@@ -2,6 +2,7 @@ package com.zhongzheng.modules.goods.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.zhongzheng.modules.course.bo.CourseQueryBo;
+import com.zhongzheng.modules.course.vo.CourseModuleFreeExamVo;
 import com.zhongzheng.modules.exam.bo.ExamNumberGoodsQueryBo;
 import com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo;
 import com.zhongzheng.modules.goods.bo.*;
@@ -77,4 +78,5 @@ public interface IGoodsService extends IService<Goods> {
 
 	int queryUpGoods();
 
+	List<CourseModuleFreeExamVo> moduleFreeExamList(Long goodsId);
 }

+ 41 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -10,11 +10,16 @@ import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.modules.course.bo.CourseChapterSectionListAddBo;
+import com.zhongzheng.modules.course.bo.CourseMenuQueryBo;
 import com.zhongzheng.modules.course.bo.CourseQueryBo;
 import com.zhongzheng.modules.course.domain.CourseChapterSection;
 import com.zhongzheng.modules.course.mapper.CourseChapterMapper;
 import com.zhongzheng.modules.course.mapper.CourseMapper;
+import com.zhongzheng.modules.course.service.ICourseMenuService;
 import com.zhongzheng.modules.course.service.ICourseService;
+import com.zhongzheng.modules.course.vo.CourseMenuVo;
+import com.zhongzheng.modules.course.vo.CourseModuleFreeExamVo;
+import com.zhongzheng.modules.course.vo.CourseVo;
 import com.zhongzheng.modules.exam.bo.ExamNumberGoodsQueryBo;
 import com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo;
 import com.zhongzheng.modules.goods.bo.*;
@@ -71,9 +76,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     @Autowired
     private IOrderGoodsService iOrderGoodsService;
 
-    @Autowired
-    private IGoodsService iGoodsService;
 
+    @Autowired
+    private ICourseMenuService iCourseMenuService;
 
     @Override
     public GoodsVo queryById(Long goodsId){
@@ -442,4 +447,38 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         return baseMapper.queryUpGoods();
     }
 
+    /**
+     * 获取商品模块绑定赠送的题库卷列表
+     * @param goodsId
+     * @return
+     */
+    @Override
+    public List<CourseModuleFreeExamVo> moduleFreeExamList(Long goodsId) {
+        List<CourseModuleFreeExamVo> moduleExamList = new ArrayList<>();
+        List<CourseVo> courseVoList = iGoodsCourseService.selectList(goodsId);
+        for(CourseVo vo : courseVoList){
+            CourseMenuQueryBo bo = new CourseMenuQueryBo();
+            bo.setCourseId(vo.getCourseId());
+            bo.setType(1);//过滤模块
+            List<CourseMenuVo> moduleList = iCourseMenuService.selectList(bo);
+            for(CourseMenuVo menuVo : moduleList){
+                if(Validator.isNotEmpty(menuVo.getExamType())&&Validator.isNotEmpty(menuVo.getFreeExamId())){
+                    //获取模块绑定的免费卷ID
+                    CourseModuleFreeExamVo freeExamVo = BeanUtil.toBean(menuVo, CourseModuleFreeExamVo.class);
+                    boolean hasExit = false;
+                    for(int i=0;i<moduleExamList.size();i++){
+                        if(moduleExamList.get(i).getExamType()==freeExamVo.getExamType()&&moduleExamList.get(i).getFreeExamId().longValue()==freeExamVo.getFreeExamId().longValue()){
+                            hasExit = true;
+                            break;
+                        }
+                    }
+                    if(!hasExit){
+                        moduleExamList.add(freeExamVo);
+                    }
+                }
+            }
+        }
+        return moduleExamList;
+    }
+
 }

+ 4 - 24
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderServiceImpl.java

@@ -1093,33 +1093,13 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                 freeBankGoodsId = null;
             }
         }
-        List<CourseModuleFreeExamVo> moduleExamList = new ArrayList<>();
         if(Validator.isEmpty(freeBankGoodsId)){
-            List<CourseVo> courseVoList = iGoodsCourseService.selectList(goodsId);
-            for(CourseVo vo : courseVoList){
-                CourseMenuQueryBo bo = new CourseMenuQueryBo();
-                bo.setCourseId(vo.getCourseId());
-                bo.setType(1);//过滤模块
-                List<CourseMenuVo> moduleList = iCourseMenuService.selectList(bo);
-                for(CourseMenuVo menuVo : moduleList){
-                    if(Validator.isNotEmpty(menuVo.getExamType())&&Validator.isNotEmpty(menuVo.getFreeExamId())){
-                        //获取模块绑定的免费卷ID
-                        CourseModuleFreeExamVo freeExamVo = BeanUtil.toBean(menuVo, CourseModuleFreeExamVo.class);
-                        boolean hasExit = false;
-                        for(int i=0;i<moduleExamList.size();i++){
-                            if(moduleExamList.get(i).getExamType()==freeExamVo.getExamType()&&moduleExamList.get(i).getFreeExamId().longValue()==freeExamVo.getFreeExamId().longValue()){
-                                hasExit = true;
-                                break;
-                            }
-                        }
-                        if(!hasExit){
-                            moduleExamList.add(freeExamVo);
-                        }
-                    }
-                }
-            }
+            List<CourseModuleFreeExamVo> moduleExamList = iGoodsService.moduleFreeExamList(goodsId);
             //课程模块有赠送的试卷
             if(moduleExamList.size()>0){
+                for(CourseModuleFreeExamVo examVo : moduleExamList){
+                    examVo.setFreeExamName(null);//MD5去除名称影响
+                }
                 String jsonList = JSON.toJSONString(moduleExamList);
                 String examListMd5 = ToolsUtils.StringToMd5(jsonList);
                 //判断该课程商品是否已经存在相同结构的赠送卷商品

+ 14 - 1
zhongzheng-system/src/main/resources/mapper/modules/course/CourseMenuMapper.xml

@@ -33,6 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="liveUrl" column="live_url"/>
         <result property="examType" column="exam_type"/>
         <result property="freeExamId" column="free_exam_id"/>
+        <result property="freeExamName" column="free_exam_name"/>
     </resultMap>
 
     <resultMap type="com.zhongzheng.modules.course.vo.CourseUserMenuVo" id="CourseUserMenuVo">
@@ -101,7 +102,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             NULL
             WHEN m.type = 3 THEN
             NULL
-            END free_exam_id
+            END free_exam_id,
+            CASE
+            WHEN m.type = 1 THEN
+            ( CASE cm.exam_type
+        WHEN 1 THEN (SELECT module_name FROM question_module WHERE module_exam_id = cm.free_exam_id)
+        WHEN 2 THEN (SELECT `name` FROM question_chapter WHERE chapter_exam_id = cm.free_exam_id)
+        WHEN 3 THEN (SELECT exam_name FROM exam WHERE exam_id = cm.free_exam_id)
+        ELSE (NULL) END)
+            WHEN m.type = 2 THEN
+            NULL
+            WHEN m.type = 3 THEN
+            NULL
+            END free_exam_name
 
         FROM
             course_menu m