yangdamao 1 년 전
부모
커밋
bb50b6203b

+ 9 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/goods/GoodsController.java

@@ -411,4 +411,13 @@ public class GoodsController extends BaseController {
         }
         return toAjax(iGoodsService.updateRecordUrl(boList,goodsId) ? 1 : 0);
     }
+
+    /**
+     * 二建商品更换腾讯
+     */
+    @ApiOperation("二建商品更换腾讯")
+    @GetMapping("/update/goods/video")
+    public AjaxResult<Void> updateGoodsVideo(UpdateGoodsVideoBo bo) {
+        return toAjax(iGoodsService.updateGoodsVideo(bo) ? 1 : 0);
+    }
 }

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

@@ -55,10 +55,14 @@ private static final long serialVersionUID=1L;
     private String recordingUrl;
     /** 录腾讯视频地址 */
     private String tencentVideoUrl;
+    /** 保利威视频地址 */
+    private String paolivayVideoUrl;
     /** 节时长(分钟) */
     private Long durationTime;
     /** 腾讯视频时长 */
     private Long tencentVideoTime;
+    /** 保利威视频时长 */
+    private Long paolivayVideoTime;
     /** 封面地址 */
     private String coverUrl;
     /** 编码 */

+ 13 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/UpdateGoodsVideoBo.java

@@ -0,0 +1,13 @@
+package com.zhongzheng.modules.goods.bo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class UpdateGoodsVideoBo implements Serializable {
+
+    private Long goodsId;
+
+    private Integer sign;
+}

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

@@ -176,4 +176,5 @@ public interface IGoodsService extends IService<Goods> {
 
     boolean updateRecordUrl(List<SectionImportBo> boList, String goodsId);
 
+	boolean updateGoodsVideo(UpdateGoodsVideoBo bo);
 }

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

@@ -5503,6 +5503,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
             if (ObjectUtils.isNull(bo)){
                 return;
             }
+            x.setPaolivayVideoUrl(x.getRecordingUrl());
+            x.setPaolivayVideoTime(x.getDurationTime());
             x.setTencentVideoUrl(bo.getSectionUrl());
             x.setTencentVideoTime(Long.valueOf(bo.getSectionTime()));
         });
@@ -5510,6 +5512,157 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         return iCourseSectionService.updateBatchById(sections);
     }
 
+    @Override
+    public boolean updateGoodsVideo(UpdateGoodsVideoBo bo) {
+        Goods goods = getById(bo.getGoodsId());
+        if (ObjectUtils.isNull(goods)){
+            return false;
+        }
+        //获取商品 课程/模块/章/节
+        List<GoodsCourse> courseList = iGoodsCourseService.list(new LambdaQueryWrapper<GoodsCourse>().eq(GoodsCourse::getGoodsId, goods.getGoodsId()));
+        if (CollectionUtils.isNotEmpty(courseList)){
+            List<Long> courseIds = courseList.stream().map(GoodsCourse::getCourseId).collect(Collectors.toList());
+            List<CourseMenu> menuList = iCourseMenuService.list(new LambdaQueryWrapper<CourseMenu>().in(CourseMenu::getCourseId, courseIds).eq(CourseMenu::getStatus, 1));
+            menuList.forEach(x -> {
+                if (x.getType() == 1){
+                    //模块
+                    CourseModule courseModule = iCourseModuleService.getById(x.getMenuId());
+                    if (bo.getSign() == 2){
+                        //切换腾讯
+                        courseModule.setViewSign(2);
+                        iCourseModuleService.updateById(courseModule);
+                    }
+                    if (bo.getSign() == 1){
+                        //切换保利威
+                        courseModule.setViewSign(1);
+                        iCourseModuleService.updateById(courseModule);
+                    }
+                    List<CourseModuleChapter> moduleChapters = iCourseModuleChapterService.list(new LambdaQueryWrapper<CourseModuleChapter>().eq(CourseModuleChapter::getModuleId, x.getMenuId()));
+                    if (CollectionUtils.isEmpty(moduleChapters)){
+                        return;
+                    }
+                    List<Long> chapterIds = moduleChapters.stream().map(CourseModuleChapter::getChapterId).collect(Collectors.toList());
+                    List<CourseChapter> courseChapters = iCourseChapterService.listByIds(chapterIds);
+                    if (bo.getSign() == 2){
+                        //切换腾讯
+                        courseChapters.stream().forEach(k -> k.setViewSign(2));
+                        iCourseChapterService.updateBatchById(courseChapters);
+                    }
+                    if (bo.getSign() == 1){
+                        //切换保利威
+                        courseChapters.stream().forEach(k -> k.setViewSign(1));
+                        iCourseChapterService.updateBatchById(courseChapters);
+                    }
+
+                    List<CourseChapterSection> courseChapterSections = iCourseChapterSectionService.list(new LambdaQueryWrapper<CourseChapterSection>().in(CourseChapterSection::getChapterId, chapterIds));
+                    if (CollectionUtils.isEmpty(courseChapterSections)){
+                        return;
+                    }
+                    List<Long> sectionIds = courseChapterSections.stream().map(CourseChapterSection::getSectionId).collect(Collectors.toList());
+                    List<CourseSection> courseSections = iCourseSectionService.listByIds(sectionIds);
+                    if (bo.getSign() == 2){
+                        //切换腾讯
+                        courseSections.stream().forEach(j -> {
+                            j.setViewSign(2);
+                            j.setRecordingUrl(j.getTencentVideoUrl());
+                            j.setDurationTime(j.getTencentVideoTime());
+                        });
+                        iCourseSectionService.updateBatchById(courseSections);
+                    }
+                    if (bo.getSign() == 1){
+                        //切换保利威
+                        courseSections.stream().forEach(j -> {
+                            j.setViewSign(1);
+                            j.setRecordingUrl(j.getPaolivayVideoUrl());
+                            j.setDurationTime(j.getPaolivayVideoTime());
+                        });
+                        iCourseSectionService.updateBatchById(courseSections);
+                    }
+                }
+
+                if (x.getType() == 2){
+                    //章
+                    CourseChapter courseChapter = iCourseChapterService.getById(x.getMenuId());
+                    if (bo.getSign() == 2){
+                        //切换腾讯
+                        courseChapter.setViewSign(2);
+                        iCourseChapterService.updateById(courseChapter);
+                    }
+                    if (bo.getSign() == 1){
+                        //切换保利威
+                        courseChapter.setViewSign(1);
+                        iCourseChapterService.updateById(courseChapter);
+                    }
+
+                    List<CourseChapterSection> courseChapterSections = iCourseChapterSectionService.list(new LambdaQueryWrapper<CourseChapterSection>().eq(CourseChapterSection::getChapterId, courseChapter.getChapterId()));
+                    if (CollectionUtils.isEmpty(courseChapterSections)){
+                        return;
+                    }
+                    List<Long> sectionIds = courseChapterSections.stream().map(CourseChapterSection::getSectionId).collect(Collectors.toList());
+                    List<CourseSection> courseSections = iCourseSectionService.listByIds(sectionIds);
+                    if (bo.getSign() == 2){
+                        //切换腾讯
+                        courseSections.stream().forEach(j -> {
+                            j.setViewSign(2);
+                            j.setRecordingUrl(j.getTencentVideoUrl());
+                            j.setDurationTime(j.getTencentVideoTime());
+                        });
+                        iCourseSectionService.updateBatchById(courseSections);
+                    }
+                    if (bo.getSign() == 1){
+                        //切换保利威
+                        courseSections.stream().forEach(j -> {
+                            j.setViewSign(1);
+                            j.setRecordingUrl(j.getPaolivayVideoUrl());
+                            j.setDurationTime(j.getPaolivayVideoTime());
+                        });
+                        iCourseSectionService.updateBatchById(courseSections);
+                    }
+                }
+
+                if (x.getType() == 3){
+                    //节
+                    CourseSection j = iCourseSectionService.getById(x.getMenuId());
+                    if (bo.getSign() == 2){
+                        //切换腾讯
+                        j.setViewSign(2);
+                        j.setRecordingUrl(j.getTencentVideoUrl());
+                        j.setDurationTime(j.getTencentVideoTime());
+                        iCourseSectionService.updateById(j);
+                    }
+                    if (bo.getSign() == 1){
+                        //切换保利威
+                        j.setViewSign(1);
+                        j.setRecordingUrl(j.getPaolivayVideoUrl());
+                        j.setDurationTime(j.getPaolivayVideoTime());
+                        iCourseSectionService.updateById(j);
+                    }
+                }
+            });
+            List<Course> courses = iCourseService.list(new LambdaQueryWrapper<Course>().in(Course::getCourseId, courseIds));
+            if (bo.getSign() == 2){
+                //切换腾讯
+                courses.forEach(k -> k.setViewSign(2));
+                iCourseService.updateBatchById(courses);
+            }
+            if (bo.getSign() == 1){
+                //切换保利威
+                courses.forEach(k -> k.setViewSign(1));
+                iCourseService.updateBatchById(courses);
+            }
+        }
+        if (bo.getSign() == 2){
+            //切换腾讯
+            goods.setViewSign(2);
+        }
+        if (bo.getSign() == 1){
+            //切换保利威
+            goods.setViewSign(1);
+        }
+
+        return updateById(goods);
+    }
+
     private void updateHandoutsId(Long goodsId, Long tenantId, Long handoutsId) {
         baseMapper.updateHandoutsId(goodsId, tenantId, handoutsId);
     }