he2802 2 years ago
parent
commit
cfb7a3d817

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

@@ -116,23 +116,27 @@ public class GoodsController extends BaseController {
         UserExamWrongRecordQueryBo wBo = new UserExamWrongRecordQueryBo();
         wBo.setOrderGoodsId(orderGoodsId);
         wBo.setUserId(loginUser.getUser().getUserId());
+        wBo.setDoMode(1L);
         Long wrongNum = iUserExamWrongRecordService.recordNum(wBo);
         numMap.put("wrongNum",wrongNum);
 
         CollectQuestionQueryBo collectQuestionQueryBo = new CollectQuestionQueryBo();
         collectQuestionQueryBo.setOrderGoodsId(orderGoodsId);
         collectQuestionQueryBo.setUserId(loginUser.getUser().getUserId());
+        collectQuestionQueryBo.setDoMode(1L);
         Integer collectNum = iCollectQuestionService.collectNum(collectQuestionQueryBo);
         numMap.put("collectNum",collectNum);
 
         UserExamRecordQueryBo userExamRecordQueryBo = new UserExamRecordQueryBo();
         userExamRecordQueryBo.setOrderGoodsId(orderGoodsId);
         userExamRecordQueryBo.setUserId(loginUser.getUser().getUserId());
+        userExamRecordQueryBo.setDoMode(1L);
         Long doNum = iUserExamRecordService.selectDoNum(userExamRecordQueryBo);
         numMap.put("doNum",doNum);
 
         userExamRecordQueryBo.setOrderGoodsId(orderGoodsId);
         userExamRecordQueryBo.setUserId(loginUser.getUser().getUserId());
+        userExamRecordQueryBo.setDoMode(1L);
         Long rightNum = iUserExamRecordService.selectRightNum(userExamRecordQueryBo);
         numMap.put("rightNum",rightNum);
         OrderGoods orderGoods = iOrderGoodsService.getOne(new LambdaQueryWrapper<OrderGoods>()
@@ -154,6 +158,43 @@ public class GoodsController extends BaseController {
         return AjaxResult.success(numMap);
     }
 
+
+    @ApiOperation("获取题库订单商品随机练习题目数统计信息")
+    @GetMapping("/bank/questionTempNum/{orderGoodsId}")
+    public AjaxResult<Map<String,Object>> questionTempNum(@PathVariable("orderGoodsId" ) Long orderGoodsId) {
+        ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
+
+        Map<String,Object> numMap = new HashMap<>();
+
+
+
+        UserExamRecordQueryBo userExamRecordQueryBo = new UserExamRecordQueryBo();
+        userExamRecordQueryBo.setOrderGoodsId(orderGoodsId);
+        userExamRecordQueryBo.setUserId(loginUser.getUser().getUserId());
+        userExamRecordQueryBo.setDoMode(2L);
+        Long doNum = iUserExamRecordService.selectDoNum(userExamRecordQueryBo);
+        numMap.put("doNum",doNum);
+
+       
+        OrderGoods orderGoods = iOrderGoodsService.getOne(new LambdaQueryWrapper<OrderGoods>()
+                .eq(OrderGoods::getOrderGoodsId, orderGoodsId));
+        if(Validator.isNotEmpty(orderGoods)){
+            OrderGoodsFree goodsFree =  iOrderGoodsFreeService.getOne(new LambdaQueryWrapper<OrderGoodsFree>()
+                    .eq(OrderGoodsFree::getOrderGoodsId, orderGoodsId));
+            Long goodsId = null;
+            if(Validator.isNotEmpty(goodsFree)){
+                goodsId = goodsFree.getFreeGoodsId(); //存在免费赠送题库商品
+            }else{
+                goodsId = orderGoods.getGoodsId();
+            }
+            Long totalNum = iGoodsService.getQuestionNum(goodsId);
+            numMap.put("totalNum",totalNum);
+        }
+
+
+        return AjaxResult.success(numMap);
+    }
+
     @ApiOperation("查询商品题库目录列表")
     @GetMapping("/bank/list")
     public AjaxResult<List<GoodsAttachedVo>> bankList(GoodsAttachedQueryBo bo) {

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

@@ -106,7 +106,7 @@ public class ExamTempServiceImpl extends ServiceImpl<ExamTempMapper, ExamTemp> i
         queryBo.setNumber(bo.getNumber());
         List<QuestionVo> questionlist = getQuestionList(queryBo);
 
-        add.setExamName(ServletUtils.getEncoded("RD")+bo.getOrderGoodsId());
+        add.setExamName(ServletUtils.getEncoded("随机练习试卷-")+bo.getOrderGoodsId());
 
         add.setCreateTime(DateUtils.getNowTime());
         add.setUpdateTime(DateUtils.getNowTime());

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/collect/service/impl/CollectQuestionServiceImpl.java

@@ -52,6 +52,7 @@ public class CollectQuestionServiceImpl extends ServiceImpl<CollectQuestionMappe
         lqw.eq(bo.getUserId() != null, CollectQuestion::getUserId, bo.getUserId());
         lqw.eq(bo.getGoodsId() != null, CollectQuestion::getGoodsId, bo.getGoodsId());
         lqw.eq(bo.getOrderGoodsId() != null, CollectQuestion::getOrderGoodsId, bo.getOrderGoodsId());
+        lqw.eq(bo.getDoMode() != null, CollectQuestion::getDoMode, bo.getDoMode());
         return this.count(lqw);
     }
 

+ 12 - 2
zhongzheng-system/src/main/resources/mapper/modules/user/UserExamRecordMapper.xml

@@ -288,7 +288,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                     e.exam_id,
                     q.*
                 FROM
-                    ( SELECT exam_id, group_concat( do_question_ids ) AS ids FROM user_exam_record WHERE user_id = #{userId} AND order_goods_id = #{orderGoodsId} and do_question_ids is not null and `status` = 1 GROUP BY exam_id ) e
+                    ( SELECT exam_id, group_concat( do_question_ids ) AS ids FROM user_exam_record WHERE user_id = #{userId}
+                                                                                                     AND order_goods_id = #{orderGoodsId}
+                                                                                                    <if test="doMode != null and doMode != ''">
+                                                                                                        AND do_mode = #{doMode}
+                                                                                                    </if>
+                                                                                                     and do_question_ids is not null and `status` = 1 GROUP BY exam_id ) e
                         LEFT JOIN question q ON FIND_IN_SET( q.question_id, e.ids )) AS eq
     </select>
 
@@ -305,7 +310,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 FROM
                     user_exam_record uer
                 WHERE
-                        record_id IN ( SELECT MAX( record_id ) record_id FROM user_exam_record WHERE user_id = #{userId} AND order_goods_id = #{orderGoodsId} and `status` = 1 GROUP BY exam_id )))
+                        record_id IN ( SELECT MAX( record_id ) record_id FROM user_exam_record WHERE user_id = #{userId}
+                                                                                                 AND order_goods_id = #{orderGoodsId}
+                                                                                                <if test="doMode != null and doMode != ''">
+                                                                                                    AND do_mode = #{doMode}
+                                                                                                </if>
+                                                                                                 and `status` = 1 GROUP BY exam_id )))
 
     </select>
 

+ 3 - 0
zhongzheng-system/src/main/resources/mapper/modules/user/UserExamWrongRecordMapper.xml

@@ -181,6 +181,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="recordId != null and recordId != ''">
             AND record_id = #{recordId}
         </if>
+        <if test="doMode != null and doMode != ''">
+            AND do_mode = #{doMode}
+        </if>
         GROUP BY
         exam_id
         ) uewr