瀏覽代碼

搜索条件新增

change 3 年之前
父節點
當前提交
1e88d253ff

+ 14 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/user/UserBankRecordController.java

@@ -8,8 +8,10 @@ import com.zhongzheng.framework.web.service.WxTokenService;
 import com.zhongzheng.modules.user.bo.UserBankRecordAddBo;
 import com.zhongzheng.modules.user.bo.UserBankRecordEditBo;
 import com.zhongzheng.modules.user.bo.UserBankRecordQueryBo;
+import com.zhongzheng.modules.user.bo.UserStudyRecordPhotoAddBo;
 import com.zhongzheng.modules.user.entity.ClientLoginUser;
 import com.zhongzheng.modules.user.service.IUserBankRecordService;
+import com.zhongzheng.modules.user.service.IUserStudyRecordPhotoService;
 import com.zhongzheng.modules.user.vo.UserBankRecordVo;
 import lombok.RequiredArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -47,6 +49,8 @@ public class UserBankRecordController extends BaseController {
 
     private final WxTokenService wxTokenService;
 
+    private final IUserStudyRecordPhotoService userStudyRecordPhotoService;
+
     /**
      * 查询用户的做题历史列表
      */
@@ -68,6 +72,16 @@ public class UserBankRecordController extends BaseController {
         return toAjax(iUserBankRecordService.updateByEditBo(bo) ? 1 : 0);
     }
 
+    /**
+     * 修改用户的做题历史
+     */
+    @ApiOperation("视频商品做题拍照上传照片")
+    @Log(title = "视频商品做题拍照上传照片", businessType = BusinessType.UPDATE)
+    @PostMapping("/addPhoto")
+    public AjaxResult<Void> addPhoto(@RequestBody UserStudyRecordPhotoAddBo bo) {
+        return toAjax(userStudyRecordPhotoService.insertByAddBo(bo) ? 1 : 0);
+    }
+
     /**
      * 获取用户的做题历史详细信息
      */

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserStudyRecordPhotoAddBo.java

@@ -33,4 +33,8 @@ public class UserStudyRecordPhotoAddBo {
     /** 绑定学时 */
     @ApiModelProperty("绑定学时")
     private Long periodId;
+
+    /** 1 视频 2卷 */
+    @ApiModelProperty("1 视频 2卷")
+    private Integer status;
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserStudyRecordPhotoEditBo.java

@@ -38,4 +38,8 @@ public class UserStudyRecordPhotoEditBo {
     @ApiModelProperty("绑定学时")
     private Long periodId;
 
+    /** 1 视频 2卷 */
+    @ApiModelProperty("1 视频 2卷")
+    private Integer status;
+
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserStudyRecordPhotoQueryBo.java

@@ -45,4 +45,8 @@ public class UserStudyRecordPhotoQueryBo extends BaseEntity {
 	/** 绑定学时 */
 	@ApiModelProperty("绑定学时")
 	private Long periodId;
+
+	/** 1 视频 2卷 */
+	@ApiModelProperty("1 视频 2卷")
+	private Integer status;
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/domain/UserStudyRecordPhoto.java

@@ -38,4 +38,7 @@ private static final long serialVersionUID=1L;
     private Long updateTime;
     /** 绑定学时 */
     private Long periodId;
+
+    /** 1 视频 2卷 */
+    private Integer status;
 }

+ 7 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserStudyRecordMapper.java

@@ -7,6 +7,7 @@ import com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo;
 import com.zhongzheng.modules.user.bo.UserQueryBo;
 import com.zhongzheng.modules.user.bo.UserStudyRecordAddBo;
 import com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo;
+import com.zhongzheng.modules.user.domain.UserBankRecord;
 import com.zhongzheng.modules.user.domain.UserStudyRecord;
 import com.zhongzheng.modules.user.vo.*;
 import org.apache.ibatis.annotations.Param;
@@ -41,6 +42,8 @@ public interface UserStudyRecordMapper extends BaseMapper<UserStudyRecord> {
 
     Long selectStudyRecord(UserStudyRecord bo);
 
+    Long selectStudyExamRecord(UserBankRecordVo bo);
+
     Long selectPeriod(UserStudyRecord entity);
 
     UserPeriodStatus selectPeriodCount(UserStudyRecord entity);
@@ -54,4 +57,8 @@ public interface UserStudyRecordMapper extends BaseMapper<UserStudyRecord> {
     List<Long> getPlanGoods(Long planId);
 
     Long selectPlandCount(@Param("goodsId") Long goodsId,@Param("planId") Long planId);
+
+    Long selectStudyExamRecordOr(UserBankRecordVo userBankRecordVo);
+
+    UserPeriodStatus selectStudyExamRecordCount(UserBankRecordVo userBankRecordVo);
 }

+ 82 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserBankRecordServiceImpl.java

@@ -4,16 +4,21 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.util.StrUtil;
 import com.zhongzheng.common.utils.DateUtils;
-import com.zhongzheng.modules.user.bo.UserBankQuestionRecordAddBo;
-import com.zhongzheng.modules.user.bo.UserBankRecordAddBo;
-import com.zhongzheng.modules.user.bo.UserBankRecordEditBo;
-import com.zhongzheng.modules.user.bo.UserBankRecordQueryBo;
+import com.zhongzheng.modules.grade.domain.UserPeriod;
+import com.zhongzheng.modules.grade.domain.UserPeriodStatus;
+import com.zhongzheng.modules.grade.service.IUserPeriodService;
+import com.zhongzheng.modules.grade.service.IUserPeriodStatusService;
+import com.zhongzheng.modules.user.bo.*;
 import com.zhongzheng.modules.user.domain.User;
 import com.zhongzheng.modules.user.domain.UserBankRecord;
+import com.zhongzheng.modules.user.domain.UserStudyRecord;
+import com.zhongzheng.modules.user.domain.UserStudyRecordPhoto;
 import com.zhongzheng.modules.user.mapper.UserBankRecordMapper;
+import com.zhongzheng.modules.user.mapper.UserStudyRecordMapper;
 import com.zhongzheng.modules.user.service.IUserBankQuestionRecordService;
 import com.zhongzheng.modules.user.service.IUserBankRecordService;
 import com.zhongzheng.modules.user.service.IUserService;
+import com.zhongzheng.modules.user.service.IUserStudyRecordPhotoService;
 import com.zhongzheng.modules.user.vo.UserBankRecordVo;
 import com.zhongzheng.modules.user.vo.UserVo;
 import org.slf4j.Logger;
@@ -49,6 +54,18 @@ public class UserBankRecordServiceImpl extends ServiceImpl<UserBankRecordMapper,
     @Autowired
     private IUserService userService;
 
+    @Autowired
+    private UserStudyRecordMapper userStudyRecordMapper;
+
+    @Autowired
+    private IUserPeriodService iUserPeriodService;
+
+    @Autowired
+    private IUserPeriodStatusService iUserPeriodStatusService;
+
+    @Autowired
+    private IUserStudyRecordPhotoService userStudyRecordPhotoService;
+
 
 
     private static Logger log = LoggerFactory.getLogger(UserBankRecordServiceImpl.class);
@@ -124,6 +141,7 @@ public class UserBankRecordServiceImpl extends ServiceImpl<UserBankRecordMapper,
 
 
 
+
     private Boolean increaseUser(UserVo userVo,Long score){
         User user = BeanUtil.toBean(userVo, User.class);
         user.setIntegral(score);
@@ -136,9 +154,69 @@ public class UserBankRecordServiceImpl extends ServiceImpl<UserBankRecordMapper,
         UserBankRecord update = BeanUtil.toBean(bo, UserBankRecord.class);
         validEntityBeforeSave(update);
         update.setUpdateTime(DateUtils.getNowTime());
+        updateExam(update);
         return this.updateById(update);
     }
 
+    private void updateExam(UserBankRecord add) {
+        //试卷及格绑定成绩和记录做题,待审,通过不记录
+        UserBankRecordVo userBankRecordVo = this.queryById(add.getRecordId());
+        if (userStudyRecordMapper.selectStudyExamRecord(userBankRecordVo)  < 1 && add.getStatus().equals(1)){
+            //增加一条审核记录
+            UserPeriod userPeriod = new UserPeriod();
+            userPeriod.setUserId(userBankRecordVo.getUserId());
+            userPeriod.setCourseId(userBankRecordVo.getCourseId());
+            userPeriod.setExamId(userBankRecordVo.getExamId());
+            userPeriod.setGoodsId(userBankRecordVo.getGoodsId());
+            userPeriod.setType(2);
+            userPeriod.setCreateTime(DateUtils.getNowTime());
+            userPeriod.setUpdateTime(DateUtils.getNowTime());
+            userPeriod.setModuleId(userBankRecordVo.getModuleId());
+            userPeriod.setChapterId(userBankRecordVo.getChapterId());
+            userPeriod.setGradeId(userBankRecordVo.getGradeId());
+            iUserPeriodService.save(userPeriod);
+            UserPeriodStatus userPeriodStatusAddBo = new UserPeriodStatus();
+            userPeriodStatusAddBo.setPeriodStatus(1);
+            userPeriodStatusAddBo.setStatus(2);
+            userPeriodStatusAddBo.setRecordStartTime(userBankRecordVo.getCreateTime());
+            userPeriodStatusAddBo.setRecordEndTime(userBankRecordVo.getUpdateTime());
+            userPeriodStatusAddBo.setPeriodId(userPeriod.getId());
+            userPeriodStatusAddBo.setCreateTime(DateUtils.getNowTime());
+            userPeriodStatusAddBo.setUpdateTime(DateUtils.getNowTime());
+            iUserPeriodStatusService.save(userPeriodStatusAddBo);
+            //将照片绑定学时
+            LambdaQueryWrapper<UserStudyRecordPhoto> lqw = Wrappers.lambdaQuery();
+            lqw.eq(UserStudyRecordPhoto::getRecordId, userBankRecordVo.getRecordId());
+            lqw.eq(UserStudyRecordPhoto::getStatus, 2);
+            UserStudyRecordPhoto userStudyRecordPhoto = new UserStudyRecordPhoto();
+            userStudyRecordPhoto.setPeriodId(userPeriodStatusAddBo.getId());
+            userStudyRecordPhoto.setUpdateTime(DateUtils.getNowTime());
+            userStudyRecordPhotoService.update(userStudyRecordPhoto,lqw);
+        }
+
+        if (userStudyRecordMapper.selectStudyExamRecordOr(userBankRecordVo) > 0 && add.getStatus().equals(1)){
+            UserPeriodStatus userPeriodStatus = userStudyRecordMapper.selectStudyExamRecordCount(userBankRecordVo);
+            userPeriodStatus.setPeriodStatus(0);
+            iUserPeriodStatusService.updateById(userPeriodStatus);
+            UserPeriodStatus userPeriodStatusAddBo = new UserPeriodStatus();
+            userPeriodStatusAddBo.setPeriodStatus(1);
+            userPeriodStatusAddBo.setStatus(2);
+            userPeriodStatusAddBo.setRecordStartTime(userBankRecordVo.getCreateTime());
+            userPeriodStatusAddBo.setRecordEndTime(userBankRecordVo.getUpdateTime());
+            userPeriodStatusAddBo.setPeriodId(userPeriodStatus.getId());
+            userPeriodStatusAddBo.setCreateTime(DateUtils.getNowTime());
+            userPeriodStatusAddBo.setUpdateTime(DateUtils.getNowTime());
+            iUserPeriodStatusService.save(userPeriodStatusAddBo);
+            //将照片绑定学时
+            LambdaQueryWrapper<UserStudyRecordPhoto> lqw = Wrappers.lambdaQuery();
+            lqw.eq(UserStudyRecordPhoto::getRecordId, userBankRecordVo.getRecordId());
+            lqw.eq(UserStudyRecordPhoto::getStatus, 2);
+            UserStudyRecordPhoto userStudyRecordPhoto = new UserStudyRecordPhoto();
+            userStudyRecordPhoto.setPeriodId(userPeriodStatusAddBo.getId());
+            userStudyRecordPhoto.setUpdateTime(DateUtils.getNowTime());
+            userStudyRecordPhotoService.update(userStudyRecordPhoto,lqw);
+        }
+    }
     /**
      * 保存前的数据校验
      *

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserPlanServiceImpl.java

@@ -636,7 +636,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
         lqw.eq(bo.getStudyDay() != null, UserPlan::getStudyDay, bo.getStudyDay());
         lqw.eq(bo.getEndTime() != null, UserPlan::getEndTime, bo.getEndTime());
         lqw.eq(bo.getStartTime() != null, UserPlan::getStartTime, bo.getStartTime());
-        lqw.in(bo.getStatus() != null, UserPlan::getStatus, bo.getStatus());
+        lqw.in( UserPlan::getStatus, 1);
         lqw.eq(bo.getPitchNum() != null, UserPlan::getPitchNum, bo.getPitchNum());
         lqw.eq(bo.getStudyNum() != null, UserPlan::getStudyNum, bo.getStudyNum());
         List<UserPlan> userPlans = this.list(lqw);

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserStudyRecordServiceImpl.java

@@ -285,6 +285,7 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
             userPeriodStatusAddBo.setCreateTime(DateUtils.getNowTime());
             userPeriodStatusAddBo.setUpdateTime(DateUtils.getNowTime());
             iUserPeriodStatusService.save(userPeriodStatusAddBo);
+            periodId = userPeriodStatusAddBo.getId();
         } else {
             //待审有结束时间跳过下面两步
             if (baseMapper.selectPeriod(entity) < 1) {

+ 7 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/UserBankRecordVo.java

@@ -1,5 +1,7 @@
 package com.zhongzheng.modules.user.vo;
 
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.zhongzheng.common.annotation.Excel;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
@@ -72,4 +74,9 @@ public class UserBankRecordVo {
 	@Excel(name = "grade_id")
 	@ApiModelProperty("grade_id")
 	private Long gradeId;
+
+	/** 创建时间 */
+	private Long createTime;
+	/** 更新时间 */
+	private Long updateTime;
 }

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/UserStudyRecordPhotoVo.java

@@ -40,4 +40,9 @@ public class UserStudyRecordPhotoVo {
 	/** 绑定学时 */
 	@ApiModelProperty("创建时间")
 	private Long createTime;
+
+	/** 1 视频 2卷 */
+	@ApiModelProperty("1 视频 2卷")
+	private Integer status;
+
 }

+ 213 - 1
zhongzheng-system/src/main/resources/mapper/modules/user/UserStudyRecordMapper.xml

@@ -438,7 +438,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </if>
     </select>
 
-    <select id="selectStudyRecord" parameterType="com.zhongzheng.modules.user.domain.UserStudyRecord" resultType="Long">
+    <select id="selectStudyRecord" parameterType="com.zhongzheng.modules.user.domain.UserBankRecord" resultType="Long">
         SELECT
         COUNT( 1 )
         FROM
@@ -493,10 +493,85 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <otherwise>
                 AND up.goods_id = 0
             </otherwise>
+        </choose>
+        <choose>
+            <when test="examId != null and examId !=''">
+                AND up.exam_id = #{examId}
+            </when>
+            <otherwise>
+                AND up.exam_id = 0
+            </otherwise>
         </choose>
           AND up.user_id = #{userId}
     </select>
 
+    <select id="selectStudyExamRecord" parameterType="com.zhongzheng.modules.user.vo.UserBankRecordVo" resultType="Long">
+        SELECT
+        COUNT( 1 )
+        FROM
+        user_period up
+        LEFT JOIN user_period_status ups on up.id = ups.period_id
+        WHERE
+        1 =1
+        <choose>
+            <when test="chapterId != null and chapterId !=''">
+                AND up.chapter_id = #{chapterId}
+            </when>
+            <otherwise>
+                AND up.chapter_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="sectionId != null and sectionId !=''">
+                AND up.section_id = #{sectionId}
+            </when>
+            <otherwise>
+                AND up.section_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="moduleId != null and moduleId !=''">
+                AND up.module_id = #{moduleId}
+            </when>
+            <otherwise>
+                AND up.module_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="courseId != null and courseId !=''">
+                AND up.course_id = #{courseId}
+            </when>
+            <otherwise>
+                AND up.course_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="gradeId != null and gradeId !=''">
+                AND up.grade_id = #{gradeId}
+            </when>
+            <otherwise>
+                AND up.grade_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="goodsId != null and goodsId !=''">
+                AND up.goods_id = #{goodsId}
+            </when>
+            <otherwise>
+                AND up.goods_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="examId != null and examId !=''">
+                AND up.exam_id = #{examId}
+            </when>
+            <otherwise>
+                AND up.exam_id = 0
+            </otherwise>
+        </choose>
+        AND up.user_id = #{userId}
+    </select>
+
     <select id="selectPeriod" parameterType="com.zhongzheng.modules.user.domain.UserStudyRecord" resultType="Long">
     SELECT
     COUNT( 1 )
@@ -728,4 +803,141 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
           and usr.plan_id = #{planId}
           and usr.goods_id = #{goodsId}
     </select>
+
+    <select id="selectStudyExamRecordOr" parameterType="com.zhongzheng.modules.user.vo.UserBankRecordVo" resultType="Long">
+        SELECT
+        COUNT( 1 )
+        FROM
+        user_period up
+        LEFT JOIN user_period_status ups on up.id = ups.period_id
+        WHERE
+        1 =1
+          and ups.period_status = 1
+          and ups.status in (0,3)
+        <choose>
+            <when test="chapterId != null and chapterId !=''">
+                AND up.chapter_id = #{chapterId}
+            </when>
+            <otherwise>
+                AND up.chapter_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="sectionId != null and sectionId !=''">
+                AND up.section_id = #{sectionId}
+            </when>
+            <otherwise>
+                AND up.section_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="moduleId != null and moduleId !=''">
+                AND up.module_id = #{moduleId}
+            </when>
+            <otherwise>
+                AND up.module_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="courseId != null and courseId !=''">
+                AND up.course_id = #{courseId}
+            </when>
+            <otherwise>
+                AND up.course_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="gradeId != null and gradeId !=''">
+                AND up.grade_id = #{gradeId}
+            </when>
+            <otherwise>
+                AND up.grade_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="goodsId != null and goodsId !=''">
+                AND up.goods_id = #{goodsId}
+            </when>
+            <otherwise>
+                AND up.goods_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="examId != null and examId !=''">
+                AND up.exam_id = #{examId}
+            </when>
+            <otherwise>
+                AND up.exam_id = 0
+            </otherwise>
+        </choose>
+        AND up.user_id = #{userId}
+    </select>
+
+    <select id="selectStudyExamRecordCount" parameterType="com.zhongzheng.modules.user.vo.UserBankRecordVo" resultMap="UserPeriodStatus">
+        SELECT
+        ups.*
+        FROM
+        user_period up
+        LEFT JOIN user_period_status ups on up.id = ups.period_id
+        WHERE
+        1 =1
+        <choose>
+            <when test="chapterId != null and chapterId !=''">
+                AND up.chapter_id = #{chapterId}
+            </when>
+            <otherwise>
+                AND up.chapter_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="sectionId != null and sectionId !=''">
+                AND up.section_id = #{sectionId}
+            </when>
+            <otherwise>
+                AND up.section_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="moduleId != null and moduleId !=''">
+                AND up.module_id = #{moduleId}
+            </when>
+            <otherwise>
+                AND up.module_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="courseId != null and courseId !=''">
+                AND up.course_id = #{courseId}
+            </when>
+            <otherwise>
+                AND up.course_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="gradeId != null and gradeId !=''">
+                AND up.grade_id = #{gradeId}
+            </when>
+            <otherwise>
+                AND up.grade_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="goodsId != null and goodsId !=''">
+                AND up.goods_id = #{goodsId}
+            </when>
+            <otherwise>
+                AND up.goods_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="examId != null and examId !=''">
+                AND up.exam_id = #{examId}
+            </when>
+            <otherwise>
+                AND up.exam_id = 0
+            </otherwise>
+        </choose>
+        AND up.user_id = #{userId}
+        AND ups.period_status = 1
+    </select>
 </mapper>