Browse Source

Merge branch 'dev'

yangdamao 1 year ago
parent
commit
57f09d90ad

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

@@ -2,11 +2,14 @@ package com.zhongzheng.controller.goods;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.lang.Validator;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.zhongzheng.common.annotation.Log;
 import com.zhongzheng.common.core.controller.BaseController;
 import com.zhongzheng.common.core.domain.AjaxResult;
 import com.zhongzheng.common.core.page.TableDataInfo;
 import com.zhongzheng.common.enums.BusinessType;
+import com.zhongzheng.common.exception.CustomException;
+import com.zhongzheng.common.utils.poi.EasyPoiUtil;
 import com.zhongzheng.common.utils.poi.ExcelUtil;
 import com.zhongzheng.modules.bank.service.IQuestionService;
 import com.zhongzheng.modules.exam.bo.ExamNumberGoodsQueryBo;
@@ -15,12 +18,14 @@ import com.zhongzheng.modules.goods.bo.*;
 import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.*;
+import com.zhongzheng.modules.top.order.bo.TopOrderQuestionImportBo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -394,4 +399,25 @@ public class GoodsController extends BaseController {
         return AjaxResult.success(list);
     }
 
+    /**
+     * 二建商品更换腾讯
+     */
+    @ApiOperation("二建商品更换腾讯")
+    @PostMapping("/update/recording/url")
+    public AjaxResult<Void> updateRecordUrl(MultipartFile file,String goodsId) {
+        List<SectionImportBo> boList = EasyPoiUtil.importExcel(file,0,1,SectionImportBo.class);
+        if (CollectionUtils.isEmpty(boList)){
+            throw new CustomException("导入文件格式不正确或文件为空,请检查文件!");
+        }
+        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);
+    }
 }

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

@@ -53,8 +53,16 @@ private static final long serialVersionUID=1L;
     private Long liveEndTime;
     /** 录播和回放的url地址 */
     private String recordingUrl;
+    /** 录腾讯视频地址 */
+    private String tencentVideoUrl;
+    /** 保利威视频地址 */
+    private String paolivayVideoUrl;
     /** 节时长(分钟) */
     private Long durationTime;
+    /** 腾讯视频时长 */
+    private Long tencentVideoTime;
+    /** 保利威视频时长 */
+    private Long paolivayVideoTime;
     /** 封面地址 */
     private String coverUrl;
     /** 编码 */

+ 24 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/SectionImportBo.java

@@ -0,0 +1,24 @@
+package com.zhongzheng.modules.goods.bo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author yangdamao
+ * @date 2024年06月04日 15:00
+ */
+@Data
+public class SectionImportBo implements Serializable {
+
+    @Excel(name = "节名称")
+    private String sectionName;
+
+    @Excel(name = "节地址")
+    private String sectionUrl;
+
+    @Excel(name = "节时长")
+    private String sectionTime;
+
+}

+ 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;
+}

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/mapper/GoodsMapper.java

@@ -9,6 +9,7 @@ import com.zhongzheng.modules.bank.domain.QuestionModule;
 import com.zhongzheng.modules.course.bo.CourseQueryBo;
 import com.zhongzheng.modules.course.bo.ExternalQuestionBo;
 import com.zhongzheng.modules.course.bo.ReplenishExamBo;
+import com.zhongzheng.modules.course.domain.CourseSection;
 import com.zhongzheng.modules.course.vo.CourseVo;
 import com.zhongzheng.modules.course.vo.ExternalQuestionVo;
 import com.zhongzheng.modules.course.vo.ReplenishExamVo;
@@ -136,4 +137,6 @@ public interface GoodsMapper extends BaseMapper<Goods> {
     List<Exam> getExam();
 
     List<GoodsCourseTreeVo> getGoodsCourseTree(Long goodsId);
+
+    List<CourseSection> getGoodsSectionInfo(Long goodsId);
 }

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

@@ -173,4 +173,8 @@ public interface IGoodsService extends IService<Goods> {
 	String createUserAccount(UserAccountBo bo);
 
 	List<GoodsCourseTreeVo> getGoodsCourseTree(Long goodsId);
+
+    boolean updateRecordUrl(List<SectionImportBo> boList, String goodsId);
+
+	boolean updateGoodsVideo(UpdateGoodsVideoBo bo);
 }

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

@@ -5491,6 +5491,178 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         return baseMapper.getGoodsCourseTree(goodsId);
     }
 
+    @Override
+    public boolean updateRecordUrl(List<SectionImportBo> boList, String goodsId) {
+        //获取商品节信息
+        List<CourseSection> sections = baseMapper.getGoodsSectionInfo(Long.valueOf(goodsId));
+        if (CollectionUtils.isEmpty(sections)){
+            return false;
+        }
+        sections.forEach(x -> {
+            SectionImportBo bo = boList.stream().filter(k -> k.getSectionName().equals(x.getName())).findFirst().orElse(null);
+            if (ObjectUtils.isNull(bo)){
+                return;
+            }
+            x.setPaolivayVideoUrl(x.getRecordingUrl());
+            x.setPaolivayVideoTime(x.getDurationTime());
+            x.setTencentVideoUrl(bo.getSectionUrl());
+            x.setTencentVideoTime(Long.valueOf(bo.getSectionTime()));
+        });
+
+        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);
     }

+ 14 - 0
zhongzheng-system/src/main/resources/mapper/modules/goods/GoodsMapper.xml

@@ -1225,4 +1225,18 @@
             g.goods_id = #{goodsId}
     </select>
 
+    <select id="getGoodsSectionInfo" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.course.domain.CourseSection">
+        SELECT
+            cs.*
+        FROM
+            goods_course gc
+                LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
+                LEFT JOIN course_module_chapter cmc ON cm.menu_id = cmc.module_id
+                LEFT JOIN course_chapter_section ccs ON cmc.chapter_id = ccs.chapter_id
+                LEFT JOIN course_section cs ON ccs.section_id = cs.section_id
+        WHERE
+            gc.goods_id = #{goodsId}
+            AND cm.`status` = 1
+    </select>
+
 </mapper>