Просмотр исходного кода

提交:学员详情记录,学时审核改造

yangdamao 3 лет назад
Родитель
Сommit
dfc3b84d4d
17 измененных файлов с 248 добавлено и 108 удалено
  1. 14 2
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/course/CourseController.java
  2. 3 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CheckSectionWatchVo.java
  3. 5 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseBusinessAddBo.java
  4. 4 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseBusinessEditBo.java
  5. 4 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseSectionDetailBo.java
  6. 0 3
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseStatementVo.java
  7. 32 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/UserWatchStatisticsVo.java
  8. 4 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/domain/CourseBusiness.java
  9. 15 8
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseSectionWatchPerServiceImpl.java
  10. 43 20
      zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/UserPeriodServiceImpl.java
  11. 2 2
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserStudyRecordAddBo.java
  12. 2 2
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/domain/UserStudyRecord.java
  13. 5 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserStudyRecordMapper.java
  14. 11 5
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserStudyRecordService.java
  15. 68 52
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserStudyRecordServiceImpl.java
  16. 15 10
      zhongzheng-system/src/main/resources/mapper/modules/course/CourseSectionWatchPerMapper.xml
  17. 21 2
      zhongzheng-system/src/main/resources/mapper/modules/user/UserStudyRecordMapper.xml

+ 14 - 2
zhongzheng-admin/src/main/java/com/zhongzheng/controller/course/CourseController.java

@@ -105,8 +105,9 @@ public class CourseController extends BaseController {
     @ApiOperation("课程统计报表")
     @GetMapping("/statement")
     public TableDataInfo<CourseStatementVo> getCourseStatement(CourseStatementBo bo) {
-        TableDataInfo<CourseStatementVo> list = iUserStudyRecordService.getCourseStatement(bo);
-        return list;
+        startPage();
+        List<CourseStatementVo> list = iUserStudyRecordService.getCourseStatement(bo);
+        return getDataTable(list);
     }
 
     /**
@@ -120,6 +121,17 @@ public class CourseController extends BaseController {
         return getDataTable(list);
     }
 
+
+    /**
+     * 学员观看记录
+     */
+    @ApiOperation("学员观看记录")
+    @GetMapping("/user/watch")
+    public AjaxResult<List<UserWatchStatisticsVo>> getUserWatchStatistics(CourseSectionDetailBo bo) {
+        List<UserWatchStatisticsVo> list = iUserStudyRecordService.getUserWatchStatistics(bo);
+        return AjaxResult.success(list);
+    }
+
     /**
      * 删除课程
      */

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CheckSectionWatchVo.java

@@ -35,6 +35,9 @@ public class CheckSectionWatchVo implements Serializable {
     @ApiModelProperty("用户ID")
     private Long userId;
 
+    @ApiModelProperty("直播地址")
+    private String channelId;
+
     @ApiModelProperty("是否购买课程:1是 0否")
     private Integer buyCourse;
 }

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseBusinessAddBo.java

@@ -78,4 +78,9 @@ public class CourseBusinessAddBo {
     /** 别名 */
     @ApiModelProperty("别名")
     private String aliasName;
+
+    @ApiModelProperty("学时审核类型:1人工,2自动")
+    private Integer periodType;
+    @ApiModelProperty("学时审核层级:1初审,2初审和复审")
+    private Integer periodNumber;
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseBusinessEditBo.java

@@ -90,4 +90,8 @@ public class CourseBusinessEditBo {
     /** 别名 */
     @ApiModelProperty("别名")
     private String aliasName;
+    @ApiModelProperty("学时审核类型:1人工,2自动")
+    private Integer periodType;
+    @ApiModelProperty("学时审核层级:1初审,2初审和复审")
+    private Integer periodNumber;
 }

+ 4 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseSectionDetailBo.java

@@ -33,6 +33,9 @@ public class CourseSectionDetailBo implements Serializable {
     private String phone;
 
     @ApiModelProperty("开课状态:1是,0否 ")
-    private Integer purchaseStatus;
+    private String purchaseStatus;
+
+    @ApiModelProperty("学员ID")
+    private String userId;
 
 }

+ 0 - 3
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseStatementVo.java

@@ -29,9 +29,6 @@ public class CourseStatementVo implements Serializable {
     @ApiModelProperty("课程节名称")
     private String sectionName;
 
-    @ApiModelProperty("课程节状态")
-    private Long sectionStatus;
-
     @ApiModelProperty("直播开始时间")
     private Long liveStartTime;
 

+ 32 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/UserWatchStatisticsVo.java

@@ -0,0 +1,32 @@
+package com.zhongzheng.modules.course.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author yangdamao
+ * @date 2022年08月18日 9:57
+ */
+@Data
+@ApiModel("学员观看记录Vo")
+public class UserWatchStatisticsVo implements Serializable {
+
+    @ApiModelProperty("进入时间")
+    private Long startTime;
+
+    @ApiModelProperty("离开时间")
+    private Long endTime;
+
+    @ApiModelProperty("观看时长,秒")
+    private Long watchLiveDuration;
+
+    @ApiModelProperty("观看类型: 1录播 2直播 3回放")
+    private Integer sectionType;
+
+    @ApiModelProperty("1小程序 2PC网站")
+    private String fromPlat;
+
+}

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/domain/CourseBusiness.java

@@ -68,4 +68,8 @@ private static final long serialVersionUID=1L;
     private String goodsFieldJson;
     /** 别名 */
     private String aliasName;
+    /** 学时审核类型:1人工,2自动 */
+    private Integer periodType;
+    /** 学时审核层级:1初审,2初审和复审 */
+    private Integer periodNumber;
 }

+ 15 - 8
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseSectionWatchPerServiceImpl.java

@@ -15,6 +15,7 @@ import com.zhongzheng.modules.course.bo.SectionWatchQueryBo;
 import com.zhongzheng.modules.course.domain.CourseSection;
 import com.zhongzheng.modules.course.domain.CourseSectionWatchPer;
 import com.zhongzheng.modules.course.mapper.CourseSectionWatchPerMapper;
+import com.zhongzheng.modules.course.service.ICourseSectionService;
 import com.zhongzheng.modules.course.service.ICourseSectionWatchPerService;
 import com.zhongzheng.modules.course.vo.CourseSectionWatchPerVo;
 import com.zhongzheng.modules.goods.domain.Goods;
@@ -38,6 +39,9 @@ public class CourseSectionWatchPerServiceImpl extends ServiceImpl<CourseSectionW
     @Autowired
     private IGoodsService goodsService;
 
+    @Autowired
+    private ICourseSectionService courseSectionService;
+
     @Override
     public CourseSectionWatchPerVo getSectionWatchPer(SectionWatchPerBo bo) {
         CourseSectionWatchPerVo vo = new CourseSectionWatchPerVo();
@@ -79,14 +83,14 @@ public class CourseSectionWatchPerServiceImpl extends ServiceImpl<CourseSectionW
     @Override
     public CheckSectionWatchVo checkSectionWatchPer(SectionWatchQueryBo bo) {
         //校验商品有效期
-        Goods goods = goodsService.getById(bo.getGoodsId());
-        if (ObjectUtils.isNotNull(goods.getValidityStartTime()) && ObjectUtils.isNotNull(goods.getValidityEndTime())){
-            Long validityStartTime = goods.getValidityStartTime();
-            Long validityEndTime = goods.getValidityEndTime();
-            if (System.currentTimeMillis() < validityStartTime || System.currentTimeMillis() > validityEndTime){
-                throw new CustomException("该商品不在有效期");
-            }
-        }
+//        Goods goods = goodsService.getById(bo.getGoodsId());
+//        if (ObjectUtils.isNotNull(goods.getValidityStartTime()) && ObjectUtils.isNotNull(goods.getValidityEndTime())){
+//            Long validityStartTime = goods.getValidityStartTime();
+//            Long validityEndTime = goods.getValidityEndTime();
+//            if (System.currentTimeMillis() < validityStartTime || System.currentTimeMillis() > validityEndTime){
+//                throw new CustomException("该商品不在有效期");
+//            }
+//        }
         CheckSectionWatchVo watchVo = new CheckSectionWatchVo();
         watchVo.setGoodsId(bo.getGoodsId());
         watchVo.setCourseId(bo.getCourseId());
@@ -117,6 +121,9 @@ public class CourseSectionWatchPerServiceImpl extends ServiceImpl<CourseSectionW
         Long orderGoodsId = baseMapper.getOrderGoodsIdByUser(bo);
         watchVo.setOrderGoodsId(orderGoodsId);
         watchVo.setBuyCourse(0);
+        //获取课程节信息
+        CourseSection courseSection = courseSectionService.getById(watchVo.getSectionId());
+        watchVo.setChannelId(courseSection.getLiveUrl());
         return watchVo;
     }
 }

+ 43 - 20
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/UserPeriodServiceImpl.java

@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.zhongzheng.common.core.domain.model.LoginUser;
 import com.zhongzheng.common.core.redis.RedisCache;
 import com.zhongzheng.common.exception.CustomException;
@@ -13,6 +14,8 @@ import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.SecurityUtils;
 import com.zhongzheng.modules.base.service.ICertificateTpService;
 import com.zhongzheng.modules.course.domain.CourseBusiness;
+import com.zhongzheng.modules.course.service.ICourseBusinessService;
+import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
@@ -101,6 +104,9 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
     @Autowired
     private com.zhongzheng.modules.alisms.service.IAliSmsService IAliSmsService;
 
+    @Autowired
+    private ICourseBusinessService iCourseBusinessService;
+
 
     @Override
     public UserPeriodVo queryById(Long id) {
@@ -165,16 +171,22 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
     @Transactional(rollbackFor = Exception.class)
     public Boolean updateByEditBo(UserPeriodEditBo bo) {
         LoginUser loginUser = SecurityUtils.getLoginUser();
-        //查询此人学时审核是否有权限
-        if (!loginUser.getUser().isAdmin()) {
-            if (baseMapper.selectCountPeriod(loginUser.getUser().getUserId(), bo.getId()) < 1) {
-                throw new IllegalArgumentException("您没有审核权限");
+        //获取业务学时审核数据
+        Goods goods = iGoodsService.getById(bo.getGoodsId());
+        CourseBusiness business = iCourseBusinessService.getById(goods.getBusinessId());
+        if (ObjectUtils.isNull(business.getPeriodType()) || business.getPeriodType() == 1){
+            //人工审核
+            //查询此人学时审核是否有权限
+            if (!loginUser.getUser().isAdmin()) {
+                if (baseMapper.selectCountPeriod(loginUser.getUser().getUserId(), bo.getId()) < 1) {
+                    throw new IllegalArgumentException("您没有审核权限");
+                }
+            }
+            //获取旧的状态
+            UserPeriodStatusVo oldData = userPeriodStatusService.queryById(bo.getId());
+            if (oldData.getStatus() != 2) {
+                throw new CustomException("无法修改非待审核记录");
             }
-        }
-        //获取旧的状态
-        UserPeriodStatusVo oldData = userPeriodStatusService.queryById(bo.getId());
-        if (oldData.getStatus() != 2) {
-            throw new CustomException("无法修改非待审核记录");
         }
         //更改审核状态
         UserPeriodStatus userUp = new UserPeriodStatus();
@@ -203,6 +215,11 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
             bo.setGradeId(userPeriodVo.getGradeId());
             sendPeriodSMS(bo);
             sendPeriodSevenSMS(bo);
+        }else {
+            if (ObjectUtils.isNotNull(business.getPeriodNumber()) && business.getPeriodNumber() == 1){
+                //只需要初审,不用复审
+                this.confirmPeriod(bo);
+            }
         }
         return true;
     }
@@ -284,21 +301,27 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
     //学时审核确定通过
     @Override
     public Boolean confirmPeriod(UserPeriodEditBo bo) {
-        if (Validator.isEmpty(bo.getUserId()) || Validator.isEmpty(bo.getGoodsId()) || Validator.isEmpty(bo.getGradeId())) {
-            throw new CustomException("参数不全");
-        }
         ClassGradeUser classGradeUser = iClassGradeUserService.getOne(new LambdaQueryWrapper<ClassGradeUser>()
                 .eq(ClassGradeUser::getUserId, bo.getUserId())
                 .eq(ClassGradeUser::getGradeId, bo.getGradeId())
                 .last("limit 1"));
-        if (Validator.isEmpty(classGradeUser) || classGradeUser.getPeriodStatus() != 3) {
-            throw new CustomException("非审核中状态无法确认审核");
-        }
-        LoginUser loginUser = SecurityUtils.getLoginUser();
-        //查询此人学时审核是否有权限
-        if (!loginUser.getUser().isAdmin()) {
-            if (baseMapper.selectCountConfirmPeriod(loginUser.getUser().getUserId(), bo.getGoodsId()) < 1) {
-                throw new CustomException("您没有确认审核权限");
+        //获取业务学时审核数据
+        Goods goods = iGoodsService.getById(bo.getGoodsId());
+        CourseBusiness business = iCourseBusinessService.getById(goods.getBusinessId());
+        if (ObjectUtils.isNull(business.getPeriodType()) || business.getPeriodType() == 1){
+            //人工审核
+            if (Validator.isEmpty(bo.getUserId()) || Validator.isEmpty(bo.getGoodsId()) || Validator.isEmpty(bo.getGradeId())) {
+                throw new CustomException("参数不全");
+            }
+            if (Validator.isEmpty(classGradeUser) || classGradeUser.getPeriodStatus() != 3) {
+                throw new CustomException("非审核中状态无法确认审核");
+            }
+            LoginUser loginUser = SecurityUtils.getLoginUser();
+            //查询此人学时审核是否有权限
+            if (!loginUser.getUser().isAdmin()) {
+                if (baseMapper.selectCountConfirmPeriod(loginUser.getUser().getUserId(), bo.getGoodsId()) < 1) {
+                    throw new CustomException("您没有确认审核权限");
+                }
             }
         }
         LambdaUpdateWrapper<ClassGradeUser> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();

+ 2 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserStudyRecordAddBo.java

@@ -82,8 +82,8 @@ public class UserStudyRecordAddBo {
 
     @ApiModelProperty(" 是否购买课程:1是,0否")
     private Integer buyCourse;
-    @ApiModelProperty(" 是否开始观看:1是,0否")
-    private Integer firstEntry;
+    @ApiModelProperty(" 标识")
+    private String identification;;
     @ApiModelProperty(" 节类型 1录播 2直播 3回放")
     private Integer sectionType;
 }

+ 2 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/domain/UserStudyRecord.java

@@ -73,8 +73,8 @@ private static final long serialVersionUID=1L;
 
     /**  是否购买课程:1是,0否  */
     private Integer buyCourse;
-    /**  是否开始观看:1是,0否 */
-    private Integer firstEntry;
+    /**  标识 */
+    private String identification;
     /**  节类型 1录播 2直播 3回放 */
     private Integer sectionType;
 }

+ 5 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserStudyRecordMapper.java

@@ -3,6 +3,8 @@ package com.zhongzheng.modules.user.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.modules.course.bo.CourseSectionDetailBo;
 import com.zhongzheng.modules.course.bo.CourseSectionDetailVo;
+import com.zhongzheng.modules.course.bo.CourseStatementBo;
+import com.zhongzheng.modules.course.bo.CourseStatementVo;
 import com.zhongzheng.modules.grade.domain.UserPeriodStatus;
 import com.zhongzheng.modules.grade.vo.ClassPeriodVo;
 import com.zhongzheng.modules.grade.vo.UserPeriodStatusVo;
@@ -25,7 +27,7 @@ import java.util.List;
  */
 public interface UserStudyRecordMapper extends BaseMapper<UserStudyRecord> {
 
-    List<UserStudyRecordVo> selectList(UserStudyRecordQueryBo bo);
+    List<UserStudyRecordVo> getListByBo(UserStudyRecordQueryBo bo);
 
     List<UserStudyRecord> selectUserStudy(@Param("userId") Long userId, @Param("courseId") Integer courseId);
 
@@ -94,4 +96,6 @@ public interface UserStudyRecordMapper extends BaseMapper<UserStudyRecord> {
     SectionStudyRecordVo getUserWatchLast(UserStudyRecordQueryBo bo);
 
     List<CourseSectionDetailVo> getUserByRecord(CourseSectionDetailBo bo);
+
+    List<CourseStatementVo> getCourseStatement(CourseStatementBo bo);
 }

+ 11 - 5
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserStudyRecordService.java

@@ -2,10 +2,7 @@ package com.zhongzheng.modules.user.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.zhongzheng.common.core.page.TableDataInfo;
-import com.zhongzheng.modules.course.bo.CourseSectionDetailBo;
-import com.zhongzheng.modules.course.bo.CourseSectionDetailVo;
-import com.zhongzheng.modules.course.bo.CourseStatementBo;
-import com.zhongzheng.modules.course.bo.CourseStatementVo;
+import com.zhongzheng.modules.course.bo.*;
 import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
 import com.zhongzheng.modules.grade.domain.UserPeriodStatus;
 import com.zhongzheng.modules.grade.vo.ClassPeriodVo;
@@ -116,7 +113,7 @@ public interface IUserStudyRecordService extends IService<UserStudyRecord> {
 	 * @param bo
 	 * @return java.util.List<com.zhongzheng.modules.course.bo.CourseStatementVo>
 	 */
-	TableDataInfo<CourseStatementVo> getCourseStatement(CourseStatementBo bo);
+	List<CourseStatementVo> getCourseStatement(CourseStatementBo bo);
 
 	/**
 	 * 课程详情统计
@@ -126,4 +123,13 @@ public interface IUserStudyRecordService extends IService<UserStudyRecord> {
 	 * @return java.util.List<com.zhongzheng.modules.course.bo.CourseSectionDetailVo>
 	 */
 	List<CourseSectionDetailVo> getCourseDetailStatistics(CourseSectionDetailBo bo);
+
+	/**
+	 * 学员观看记录
+	 * @author change
+	 * @date 2022/8/18 10:04
+	 * @param bo
+	 * @return java.util.List<com.zhongzheng.modules.course.bo.UserWatchStatisticsVo>
+	 */
+	List<UserWatchStatisticsVo> getUserWatchStatistics(CourseSectionDetailBo bo);
 }

+ 68 - 52
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserStudyRecordServiceImpl.java

@@ -1,46 +1,42 @@
 package com.zhongzheng.modules.user.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.convert.Convert;
 import cn.hutool.core.lang.Validator;
-import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-import com.microsoft.schemas.office.visio.x2012.main.SectionType;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.Page;
 import com.zhongzheng.common.core.page.TableDataInfo;
 import com.zhongzheng.common.core.redis.RedisCache;
 import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
-import com.zhongzheng.modules.bank.domain.Exam;
 import com.zhongzheng.modules.course.bo.*;
+import com.zhongzheng.modules.course.domain.CourseBusiness;
 import com.zhongzheng.modules.course.domain.CoursePhotoLog;
 import com.zhongzheng.modules.course.domain.CourseSection;
+import com.zhongzheng.modules.course.service.ICourseBusinessService;
 import com.zhongzheng.modules.course.service.ICourseChapterSectionService;
 import com.zhongzheng.modules.course.service.ICoursePhotoLogService;
 import com.zhongzheng.modules.course.service.ICourseSectionService;
 import com.zhongzheng.modules.course.vo.CourseChapterSectionVo;
 import com.zhongzheng.modules.course.vo.CourseSectionVo;
+import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.service.IGoodsService;
-import com.zhongzheng.modules.goods.vo.GoodsUserVo;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
-import com.zhongzheng.modules.grade.bo.UserPeriodAddBo;
-import com.zhongzheng.modules.grade.bo.UserPeriodStatusAddBo;
+import com.zhongzheng.modules.grade.bo.UserPeriodEditBo;
 import com.zhongzheng.modules.grade.domain.ClassGradeUser;
 import com.zhongzheng.modules.grade.domain.UserPeriod;
 import com.zhongzheng.modules.grade.domain.UserPeriodStatus;
 import com.zhongzheng.modules.grade.service.IClassGradeUserService;
 import com.zhongzheng.modules.grade.service.IUserPeriodService;
 import com.zhongzheng.modules.grade.service.IUserPeriodStatusService;
-
 import com.zhongzheng.modules.grade.vo.ClassPeriodStudentVo;
-
 import com.zhongzheng.modules.grade.vo.ClassPeriodVo;
-import com.zhongzheng.modules.grade.vo.UserPeriodStatusVo;
 import com.zhongzheng.modules.inform.bo.InformRemindQueryBo;
 import com.zhongzheng.modules.inform.bo.InformUserAddBo;
 import com.zhongzheng.modules.inform.service.IInformRemindService;
@@ -59,10 +55,6 @@ import net.polyv.live.v1.entity.channel.viewdata.LiveListChannelViewlogResponse;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.github.pagehelper.Page;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.io.IOException;
@@ -138,6 +130,8 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
     private IUserExamGoodsService iUserExamGoodsService;
     @Autowired
     private IPolyvLiveService ployvLiveService;
+    @Autowired
+    private ICourseBusinessService iCourseBusinessService;
 
     @Autowired
     private  RedisCache redisCache;
@@ -264,7 +258,7 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
 
     @Override
     public List<UserStudyRecordVo> selectList(UserStudyRecordQueryBo bo) {
-        return userStudyRecordMapper.selectList(bo);
+        return userStudyRecordMapper.getListByBo(bo);
     }
 
     @Override
@@ -341,7 +335,7 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
         //获取节类型
         CourseSection section = iCourseSectionService.getById(bo.getSectionId());
         add.setSectionType(section.getSectionType());
-        add.setFirstEntry(ObjectUtils.isNull(bo.getFirstEntry())?0:bo.getFirstEntry());
+        add.setIdentification(bo.getIdentification());
         this.save(add);
         if (ObjectUtils.isNull(bo.getOrderGoodsId())){
             //没有购买商品,通过分享观看
@@ -432,6 +426,19 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
                     classGradeUser1.setUpdateTime(DateUtils.getNowTime());
                     List<ClassGradeUser> list1 = iClassGradeUserService.list(classGradeUser);
                     iClassGradeUserService.update(classGradeUser1, classGradeUser);
+                    //查询商品业务学时审核类型
+                    Goods goods = iGoodsService.getById(bo.getGoodsId());
+                    CourseBusiness business = iCourseBusinessService.getById(goods.getBusinessId());
+                    if (ObjectUtils.isNotNull(business) && ObjectUtils.isNotNull(business.getPeriodType()) && business.getPeriodType() == 2){
+                        //自动审核
+                        UserPeriodEditBo editBo = new UserPeriodEditBo();
+                        editBo.setGoodsId(bo.getGoodsId());
+                        editBo.setGradeId(bo.getGradeId());
+                        editBo.setUserId(bo.getUserId());
+                        iUserPeriodService.updateByEditBo(editBo);
+                        iUserPeriodService.confirmPeriod(editBo);
+                        return;
+                    }
 
                     InformRemindQueryBo informRemindQueryBo = new InformRemindQueryBo();
                     informRemindQueryBo.setSort(8L);
@@ -639,32 +646,19 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
     }
 
     @Override
-    public TableDataInfo<CourseStatementVo> getCourseStatement(CourseStatementBo bo) {
-        com.baomidou.mybatisplus.extension.plugins.pagination.Page<UserStudyRecord> page =
-                page(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<UserStudyRecord>(bo.getPageNum(), bo.getPageSize()),
-                new LambdaQueryWrapper<UserStudyRecord>()
-                        .eq(UserStudyRecord::getGoodsId, bo.getGoodsId())
-                        .groupBy(UserStudyRecord::getSectionId));
-        if (CollectionUtils.isEmpty(page.getRecords())){
-            return new TableDataInfo<>();
+    public List<CourseStatementVo> getCourseStatement(CourseStatementBo bo) {
+        List<CourseStatementVo> voList = baseMapper.getCourseStatement(bo);
+        if (CollectionUtils.isEmpty(voList)){
+            return new ArrayList<>();
         }
-        List<CourseStatementVo> statementVos = page.getRecords().stream().map(item -> {
-            CourseStatementVo vo = new CourseStatementVo();
-            //课程节信息
-            CourseSection section = iCourseSectionService.getById(item.getSectionId());
-            if (ObjectUtils.isNotNull(section)) {
-                vo.setSectionName(section.getName());
-                vo.setLiveStartTime(section.getLiveStartTime());
-                vo.setLiveEndTime(section.getLiveEndTime());
-                vo.setLiveUrl(section.getLiveUrl());
-            }
+        voList.forEach(item -> {
             //统计观看人数
             List<UserStudyRecord> recordList = list(new LambdaQueryWrapper<UserStudyRecord>()
                     .eq(UserStudyRecord::getGoodsId, item.getGoodsId())
                     .eq(UserStudyRecord::getSectionId, item.getSectionId()));
             if (CollectionUtils.isNotEmpty(recordList)) {
                 Map<Long, List<UserStudyRecord>> map = recordList.stream().collect(Collectors.groupingBy(UserStudyRecord::getUserId));
-                vo.setWatchNumber(map.keySet().size());
+                item.setWatchNumber(map.keySet().size());
                 Integer unBuyCourse = 0;
                 Integer buyCourse = 0;
                 for (UserStudyRecord record : recordList) {
@@ -675,25 +669,24 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
                         buyCourse++;
                     }
                 }
-                vo.setBuyCourseNumber(buyCourse);
-                vo.setUnBuyCourseNumber(unBuyCourse);
+                item.setBuyCourseNumber(buyCourse);
+                item.setUnBuyCourseNumber(unBuyCourse);
                 Map<String, List<UserStudyRecord>> collect = recordList.stream().filter(x -> ObjectUtils.isNotNull(x.getFromPlat())).collect(Collectors.groupingBy(UserStudyRecord::getFromPlat));
                 if (CollectionUtils.isNotEmpty(collect)) {
                     collect.forEach((k, v) -> {
                         if (k.equals("1")) {
                             //小程序
-                            vo.setAppWatchNumber(collect.get(k).size());
+                            item.setAppWatchNumber(collect.get(k).size());
                         } else {
                             //PC
-                            vo.setAdminWatchNumber(collect.get(k).size());
+                            item.setAdminWatchNumber(collect.get(k).size());
                         }
                     });
                 }
             }
-            return vo;
-        }).collect(Collectors.toList());
+        });
         //查询保利威直播状态
-        Set<String> setUrl = statementVos.stream().map(CourseStatementVo::getLiveUrl).collect(Collectors.toSet());
+        Set<String> setUrl = voList.stream().map(CourseStatementVo::getLiveUrl).collect(Collectors.toSet());
         List<LiveChannelBasicInfoResponse> result = setUrl.stream().map(url -> {
             PolyvLiveQueryBo queryBo = new PolyvLiveQueryBo();
             queryBo.setChannelId(url);
@@ -707,17 +700,14 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
             }
             return response;
         }).collect(Collectors.toList());
-        statementVos.forEach(item -> {
+        voList.forEach(item -> {
             for (LiveChannelBasicInfoResponse response : result) {
                 if (net.polyv.common.v1.util.StringUtils.isNotBlank(item.getLiveUrl()) && item.getLiveUrl().equals(response.getChannelId())){
                     item.setWatchStatus(response.getWatchStatus());
                 }
             }
         });
-        TableDataInfo<CourseStatementVo> info = new TableDataInfo<CourseStatementVo>();
-        info.setRows(statementVos);
-        info.setTotal(page.getTotal());
-        return info;
+        return voList;
     }
 
     @Override
@@ -737,7 +727,6 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
             List<UserStudyRecord> list = list(new LambdaQueryWrapper<UserStudyRecord>()
                     .eq(UserStudyRecord::getUserId, item.getUserId())
                     .eq(UserStudyRecord::getGoodsId, bo.getGoodsId())
-                    .eq(UserStudyRecord::getCourseId, bo.getCourseId())
                     .eq(UserStudyRecord::getSectionId, bo.getSectionId()));
             item.setLiveDuration(liveStartTime);
             if (list.stream().anyMatch(x -> x.getBuyCourse() == 1)){
@@ -746,12 +735,39 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
             }
             Long sum = list.stream().filter(x -> ObjectUtils.isNotNull(x.getStudyDuration())).mapToLong(UserStudyRecord::getStudyDuration).sum();
             item.setWatchLiveDuration(sum);
-            Integer size = list.stream().filter(x -> ObjectUtils.isNotNull(x.getFirstEntry()) && x.getFirstEntry() == 1).collect(Collectors.toList()).size();
-            item.setWatchNumber(size);
+            Map<String, List<UserStudyRecord>> collect = list.stream().filter(x -> StringUtils.isNotBlank(x.getIdentification())).collect(Collectors.groupingBy(UserStudyRecord::getIdentification));
+            item.setWatchNumber(collect.keySet().size());
         }
         return detailVos;
     }
 
+    @Override
+    public List<UserWatchStatisticsVo> getUserWatchStatistics(CourseSectionDetailBo bo) {
+        //学员的观看记录
+        List<UserStudyRecord> list = list(new LambdaQueryWrapper<UserStudyRecord>()
+                .eq(UserStudyRecord::getUserId, bo.getUserId())
+                .eq(UserStudyRecord::getGoodsId, bo.getGoodsId())
+                .eq(UserStudyRecord::getSectionId, bo.getSectionId()));
+        if (CollectionUtils.isEmpty(list)){
+            return new ArrayList<>();
+        }
+        List<UserWatchStatisticsVo> result = new ArrayList<>();
+        Map<String, List<UserStudyRecord>> map = list.stream().filter(x -> StringUtils.isNotBlank(x.getIdentification())).collect(Collectors.groupingBy(UserStudyRecord::getIdentification));
+        map.forEach((k,v) -> {
+            UserWatchStatisticsVo vo = new UserWatchStatisticsVo();
+            List<UserStudyRecord> records = map.get(k).stream().sorted(Comparator.comparing(UserStudyRecord::getCreateTime)).collect(Collectors.toList());
+            UserStudyRecord user = records.get(0);
+            vo.setStartTime(user.getStartTime());
+            vo.setEndTime(records.get(records.size() - 1).getEndTime());
+            vo.setFromPlat(user.getFromPlat());
+            vo.setSectionType(user.getSectionType());
+            Long sum = records.stream().filter(x -> ObjectUtils.isNotNull(x.getStudyDuration())).mapToLong(UserStudyRecord::getStudyDuration).sum();
+            vo.setWatchLiveDuration(sum);
+            result.add(vo);
+        });
+        return result;
+    }
+
 
     /**
      * 获取最后一次看完的节

+ 15 - 10
zhongzheng-system/src/main/resources/mapper/modules/course/CourseSectionWatchPerMapper.xml

@@ -53,15 +53,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="getOrderGoodsIdByUser" parameterType="com.zhongzheng.modules.course.bo.SectionWatchQueryBo" resultType="java.lang.Long">
-        SELECT FROM `order` o
-                        LEFT JOIN order_goods og ON o.order_sn = og.order_sn
-        WHERE  og.pay_status IN ( 2, 3, 4 )
-          AND og.refund_status != 2
-		          AND og.STATUS = 1
-		          AND o.`status` = 1
-		          AND g.`status` = 1
-							AND og.goods_id = #{goodsId}
-							AND o.user_id = #{userId}
-        ORDER BY o.create_time DESC LIMIT 1
+        SELECT
+            og.order_goods_id
+        FROM
+            `order` o
+                LEFT JOIN order_goods og ON o.order_sn = og.order_sn
+        WHERE
+            og.pay_status IN ( 2, 3, 4 )
+            AND og.refund_status != 2
+            AND og.STATUS = 1
+            AND o.`status` = 1
+            AND og.goods_id = #{goodsId}
+            AND o.user_id = #{userId}
+        ORDER BY
+            o.create_time DESC
+            LIMIT 1
     </select>
 </mapper>

+ 21 - 2
zhongzheng-system/src/main/resources/mapper/modules/user/UserStudyRecordMapper.xml

@@ -155,7 +155,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
 
-    <select id="selectList" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo"  resultMap="UserStudyRecordResult">
+    <select id="getListByBo" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo"  resultMap="UserStudyRecordResult">
         SELECT DISTINCT
         temp.course_id,
         c.cover_url,
@@ -1362,7 +1362,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         WHERE
             u.`status` = 1
           AND ur.goods_id = #{goodsId}
-          AND ur.course_id = #{courseId}
           AND ur.section_id = #{sectionId}
         <if test="userName != null and userName !='' ">
             AND u.realname  like concat('%', #{userName}, '%')
@@ -1380,6 +1379,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             ur.user_id
     </select>
 
+    <select id="getCourseStatement" parameterType="com.zhongzheng.modules.course.bo.CourseStatementBo" resultType="com.zhongzheng.modules.course.bo.CourseStatementVo">
+        SELECT
+            ur.goods_id as goodsId,
+            ur.section_id as sectionId,
+            cs.name as sectionName,
+            cs.live_start_time as liveStartTime,
+            cs.live_end_time as liveEndTime,
+            cs.live_url as liveUrl
+        FROM
+            user_study_record ur
+            LEFT JOIN `course_section` cs ON ur.section_id = cs.section_id
+        WHERE
+            ur.goods_id = #{goodsId}
+            <if test="sectionName != null and sectionName !='' ">
+                AND cs.name  like concat('%', #{sectionName}, '%')
+            </if>
+            GROUP BY
+            ur.section_id
+    </select>
+
     <select id="userSectionLiveList" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo" resultMap="SectionStudyRecordVoResult">
         SELECT
             r.*,