he2802 2 anos atrás
pai
commit
c43b6b1fa3
15 arquivos alterados com 148 adições e 11 exclusões
  1. 10 0
      zhongzheng-api/src/main/java/com/zhongzheng/controller/order/OrderController.java
  2. 3 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseAddBo.java
  3. 3 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseEditBo.java
  4. 3 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseMenuQueryBo.java
  5. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/domain/Course.java
  6. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/mapper/CourseMenuMapper.java
  7. 7 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseMenuServiceImpl.java
  8. 8 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseUserMenuVo.java
  9. 4 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseVo.java
  10. 3 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/GoodsFirstChoiceAddBo.java
  11. 1 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/domain/GoodsCourse.java
  12. 1 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/IOrderGoodsService.java
  13. 87 8
      zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderGoodsServiceImpl.java
  14. 2 0
      zhongzheng-system/src/main/resources/mapper/modules/course/CourseMapper.xml
  15. 12 0
      zhongzheng-system/src/main/resources/mapper/modules/course/CourseMenuMapper.xml

+ 10 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/order/OrderController.java

@@ -10,6 +10,7 @@ import com.zhongzheng.framework.web.service.WxTokenService;
 import com.zhongzheng.modules.base.vo.BaseFilterVo;
 import com.zhongzheng.modules.course.service.ICourseEducationTypeService;
 import com.zhongzheng.modules.course.vo.CourseEducationTypeVo;
+import com.zhongzheng.modules.goods.bo.GoodsFirstChoiceAddBo;
 import com.zhongzheng.modules.order.bo.*;
 import com.zhongzheng.modules.order.service.IOrderGoodsService;
 import com.zhongzheng.modules.order.service.IOrderService;
@@ -227,4 +228,13 @@ public class OrderController extends BaseController {
     public AjaxResult<String> getOrderSevenYear(@PathVariable("orderGoodsId")Long orderGoodsId) {
         return AjaxResult.success("成功",iOrderGoodsService.getOrderSevenYear(orderGoodsId));
     }
+
+
+    @ApiOperation("优选商品重构")
+    @PostMapping("/firstChoiceGoods")
+    public AjaxResult<GoodsFirstChoiceAddBo> firstChoiceGoods(@RequestBody GoodsFirstChoiceAddBo bo) {
+        ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
+        bo.setUserId(loginUser.getUser().getUserId());
+        return AjaxResult.success(iOrderGoodsService.firstChoiceGoods(bo));
+    }
 }

+ 3 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseAddBo.java

@@ -78,5 +78,7 @@ public class CourseAddBo {
     /** 1显示 0隐藏 */
     @ApiModelProperty("1显示 0隐藏")
     private Integer courseShow;
-
+    /** 优选生成 0否 1是 */
+    @ApiModelProperty("优选生成 0否 1是")
+    private Integer firstChoice;
 }

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

@@ -96,4 +96,7 @@ public class CourseEditBo {
     /** 1显示 0隐藏 */
     @ApiModelProperty("1显示 0隐藏")
     private Integer courseShow;
+    /** 优选生成 0否 1是 */
+    @ApiModelProperty("优选生成 0否 1是")
+    private Integer firstChoice;
 }

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

@@ -79,4 +79,7 @@ public class CourseMenuQueryBo extends BaseEntity {
 
 	@ApiModelProperty("商品ID")
 	private Long goodsId;
+
+	@ApiModelProperty("是否获取学时 1获取")
+	private Integer getHours;
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/domain/Course.java

@@ -72,5 +72,7 @@ private static final long serialVersionUID=1L;
     private Long tenantId;
     @TableField(exist = false)
     private Long oId;
+    /** 优选生成 0否 1是 */
+    private Integer firstChoice;
 
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/mapper/CourseMenuMapper.java

@@ -43,4 +43,6 @@ public interface CourseMenuMapper extends BaseMapper<CourseMenu> {
     @InterceptorIgnore(tenantLine = "true")
     List<CourseMenu> selectByNotTenant(@Param("newCourseId") Long newCourseId,@Param("type") Integer type,@Param("newModuleId") Long newModuleId,@Param("newTenantId") Long newTenantId);
 
+    Long countChapterTotalTime(@Param("chapterId") Long chapterId);
+
 }

+ 7 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseMenuServiceImpl.java

@@ -269,6 +269,13 @@ public class CourseMenuServiceImpl extends ServiceImpl<CourseMenuMapper, CourseM
                 }
             }
         }
+        if ( Validator.isNotEmpty(bo.getGetHours()) && bo.getGetHours() == 1) {
+            for (CourseUserMenuVo courseMenuVo : courseMenuVos) {
+                if(courseMenuVo.getType()==2){
+                    courseMenuVo.setTotalTime(baseMapper.countChapterTotalTime(courseMenuVo.getMenuId()));
+                }
+            }
+        }
         if (bo.getRebuild() != null && bo.getRebuild() == 1) {
             List<CourseUserMenuVo> courseMenuVoss = courseMenuVos.stream().filter(s ->
                     s.getRebuild() != null && s.getRebuild().equals(1)

+ 8 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseUserMenuVo.java

@@ -101,4 +101,12 @@ public class CourseUserMenuVo {
 	@ApiModelProperty("公共标识:1公共章 0非公共章")
 	private Integer commonSign;
 
+	/** 是否优选  0没有 1选中 */
+	@Excel(name = "是否优选  0没有 1选中")
+	@ApiModelProperty("是否优选  0没有 1选中")
+	private Integer firstChoiceStatus;
+
+	@ApiModelProperty("章下节总秒数")
+	private Long totalTime;
 }
+

+ 4 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseVo.java

@@ -117,5 +117,8 @@ public class CourseVo {
 	private Integer courseShow;
 	@ApiModelProperty("课程双师资绑定状态")
 	private Integer bindStatus;
-
+	/** 优选生成 0否 1是 */
+	@Excel(name = "优选生成 0否 1是")
+	@ApiModelProperty("优选生成 0否 1是")
+	private Integer firstChoice;
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/GoodsFirstChoiceAddBo.java

@@ -30,6 +30,9 @@ public class GoodsFirstChoiceAddBo {
     @ApiModelProperty("课程ID")
     private Long courseId;
 
+    @ApiModelProperty("班级ID")
+    private Long gradeId;
+
     @ApiModelProperty("章列表ID")
     private List<Long> chapterIdList;
 }

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/domain/GoodsCourse.java

@@ -38,4 +38,5 @@ private static final long serialVersionUID=1L;
     /** 别名 */
     private String aliasName;
     private Long tenantId;
+
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/IOrderGoodsService.java

@@ -126,5 +126,5 @@ public interface IOrderGoodsService extends IService<OrderGoods> {
 
     String getOrderSevenYear(Long orderGoodsId);
 
-    Long firstChoiceGoods(GoodsFirstChoiceAddBo bo);
+    GoodsFirstChoiceAddBo firstChoiceGoods(GoodsFirstChoiceAddBo bo);
 }

+ 87 - 8
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderGoodsServiceImpl.java

@@ -16,11 +16,15 @@ import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.type.EncryptHandler;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.SecurityUtils;
+import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
 import com.zhongzheng.modules.base.domain.ShoppingCart;
 import com.zhongzheng.modules.base.domain.UserProfile;
 import com.zhongzheng.modules.base.service.IShoppingCartService;
 import com.zhongzheng.modules.base.service.IUserProfileService;
+import com.zhongzheng.modules.course.domain.Course;
+import com.zhongzheng.modules.course.domain.CourseBusiness;
+import com.zhongzheng.modules.course.domain.CourseMenu;
 import com.zhongzheng.modules.course.mapper.CourseMapper;
 import com.zhongzheng.modules.course.mapper.CourseMenuMapper;
 import com.zhongzheng.modules.course.service.ICourseChapterSectionService;
@@ -39,6 +43,7 @@ import com.zhongzheng.modules.exam.service.IExamBeforeService;
 import com.zhongzheng.modules.exam.vo.ExamApplyGoodsVo;
 import com.zhongzheng.modules.goods.bo.*;
 import com.zhongzheng.modules.goods.domain.Goods;
+import com.zhongzheng.modules.goods.domain.GoodsCourse;
 import com.zhongzheng.modules.goods.domain.GoodsQuestionRel;
 import com.zhongzheng.modules.goods.domain.QuestionMerchant;
 import com.zhongzheng.modules.goods.service.IGoodsCourseService;
@@ -48,6 +53,7 @@ import com.zhongzheng.modules.goods.service.IQuestionMerchantService;
 import com.zhongzheng.modules.goods.vo.GoodsSectionListVo;
 import com.zhongzheng.modules.goods.vo.GoodsSectionNumVo;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
+import com.zhongzheng.modules.grade.bo.ClassGradeGoodsAddBo;
 import com.zhongzheng.modules.grade.domain.ClassGradeGoods;
 import com.zhongzheng.modules.grade.domain.ClassGradeUser;
 import com.zhongzheng.modules.grade.service.IClassGradeGoodsService;
@@ -74,11 +80,10 @@ import com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo;
 import com.zhongzheng.modules.user.bo.UserExamGoodsQueryBo;
 import com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo;
 import com.zhongzheng.modules.user.domain.User;
+import com.zhongzheng.modules.user.domain.UserExamGoods;
+import com.zhongzheng.modules.user.domain.UserExamGoodsSupplement;
 import com.zhongzheng.modules.user.domain.UserSubscribe;
-import com.zhongzheng.modules.user.service.IUserExamGoodsService;
-import com.zhongzheng.modules.user.service.IUserService;
-import com.zhongzheng.modules.user.service.IUserStudyRecordService;
-import com.zhongzheng.modules.user.service.IUserSubscribeService;
+import com.zhongzheng.modules.user.service.*;
 import com.zhongzheng.modules.user.vo.SubjectStudyRecordVo;
 import net.polyv.common.v1.util.StringUtils;
 import net.polyv.live.v1.entity.channel.operate.LiveChannelBasicInfoResponse;
@@ -111,6 +116,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
     @Autowired
     private IClassGradeService iClassGradeService;
 
+
     @Autowired
     private IOrderService iOrderService;
 
@@ -176,6 +182,10 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
     @Autowired
     private IQuestionMerchantService iQuestionMerchantService;
 
+    @Autowired
+    private IUserExamGoodsSupplementService iUserExamGoodsSupplementService;
+
+
     @Override
     public OrderGoodsVo queryById(Long orderGoodsId) {
         OrderGoods db = this.baseMapper.selectById(orderGoodsId);
@@ -920,8 +930,9 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
     }
 
     @Override
-    public Long firstChoiceGoods(GoodsFirstChoiceAddBo bo) {
-        if(Validator.isEmpty(bo.getGoodsId())||Validator.isEmpty(bo.getOrderGoodsId())){
+    @Transactional(rollbackFor = Exception.class)
+    public GoodsFirstChoiceAddBo firstChoiceGoods(GoodsFirstChoiceAddBo bo) {
+        if(Validator.isEmpty(bo.getGradeId())||Validator.isEmpty(bo.getGoodsId())||Validator.isEmpty(bo.getOrderGoodsId())||Validator.isEmpty(bo.getCourseId())){
             throw new CustomException("参数错误");
         }
         Goods goodsOld = iGoodsService.getOne(new LambdaQueryWrapper<Goods>()
@@ -934,9 +945,77 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
         }
         OrderGoods orderGoods = getOne(new LambdaQueryWrapper<OrderGoods>()
                 .eq(OrderGoods::getOrderGoodsId, bo.getOrderGoodsId()));
-        if(Validator.isEmpty(orderGoods)||orderGoods.getGoodsId()!=bo.getGoodsId()){
+        if(Validator.isEmpty(orderGoods)||orderGoods.getGoodsId().longValue()!=bo.getGoodsId().longValue()||orderGoods.getGradeId().longValue()!=bo.getGradeId().longValue()){
             throw new CustomException("订单商品数据错误");
         }
-        return null;
+        Course courseOld =courseMapper.selectOne(new LambdaQueryWrapper<Course>()
+                .eq(Course::getCourseId, bo.getCourseId()));
+        Course courseNew = BeanUtil.toBean(courseOld, Course.class);
+        courseNew.setCourseId(null);
+        courseNew.setFirstChoice(1);
+        courseNew.setCreateTime(DateUtils.getNowTime());
+        courseNew.setUpdateTime(DateUtils.getNowTime());
+        courseNew.setCode(ServletUtils.getEncoded("KC"));
+        courseMapper.insert(courseNew);
+
+        LambdaQueryWrapper<CourseMenu> lqw = Wrappers.lambdaQuery();
+        lqw.eq(bo.getCourseId() != null, CourseMenu::getCourseId, bo.getCourseId());
+        lqw.in( CourseMenu::getMenuId, bo.getChapterIdList());
+        lqw.eq(CourseMenu::getType, 2);
+        List<CourseMenu> menuList = courseMenuMapper.selectList(lqw);
+        if(Validator.isEmpty(menuList)||menuList.size()==0){
+            throw new CustomException("章数据错误");
+        }
+        for(CourseMenu menu : menuList){
+            menu.setCourseId(courseNew.getCourseId());
+            menu.setFirstChoiceStatus(0);
+            menu.setCreateTime(DateUtils.getNowTime());
+            menu.setUpdateTime(DateUtils.getNowTime());
+            courseMenuMapper.insert(menu);
+        }
+
+        Goods goodsNew = BeanUtil.toBean(goodsOld, Goods.class);
+        goodsNew.setGoodsId(null);
+        goodsNew.setCreateTime(DateUtils.getNowTime());
+        goodsNew.setUpdateTime(DateUtils.getNowTime());
+        goodsNew.setCode(ServletUtils.getEncoded("KC"));
+        goodsNew.setFirstChoiceGoods(1);
+        goodsNew.setFirstChoiceStatus(0);
+        goodsNew.setCode(ServletUtils.getEncoded("SP"));
+        iGoodsService.save(goodsNew);
+
+        GoodsCourse goodsCourseOld = iGoodsCourseService.getOne(new LambdaQueryWrapper<GoodsCourse>()
+                .eq(GoodsCourse::getGoodsId, bo.getGoodsId()).eq(GoodsCourse::getCourseId, bo.getCourseId()));
+        if(Validator.isEmpty(goodsCourseOld)){
+            throw new CustomException("商品课程错误");
+        }
+        GoodsCourse goodsCourseNew = BeanUtil.toBean(goodsCourseOld, GoodsCourse.class);
+        goodsCourseNew.setCourseId(courseNew.getCourseId());
+        goodsCourseNew.setGoodsId(goodsNew.getGoodsId());
+        iGoodsCourseService.save(goodsCourseNew);
+
+        orderGoods.setGoodsId(goodsNew.getGoodsId());
+        updateById(orderGoods);
+
+        ClassGradeGoodsAddBo gradeGoodsAddBo = new ClassGradeGoodsAddBo();
+        gradeGoodsAddBo.setGoodsId(goodsNew.getGoodsId());
+        gradeGoodsAddBo.setGradeId(orderGoods.getGradeId());
+        iClassGradeGoodsService.insertByAddBo(gradeGoodsAddBo);
+
+        LambdaUpdateWrapper<UserExamGoods> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
+        objectLambdaUpdateWrapper.eq(UserExamGoods::getOrderGoodsId, bo.getOrderGoodsId());
+        objectLambdaUpdateWrapper.set(UserExamGoods::getGoodsId, goodsNew.getGoodsId());
+        objectLambdaUpdateWrapper.set(UserExamGoods::getUpdateTime,DateUtils.getNowTime());
+        iUserExamGoodsService.update(null, objectLambdaUpdateWrapper);
+
+        LambdaUpdateWrapper<UserExamGoodsSupplement> objectLambdaUpdateWrapper2 = Wrappers.lambdaUpdate();
+        objectLambdaUpdateWrapper2.eq(UserExamGoodsSupplement::getOrderGoodsId, bo.getOrderGoodsId());
+        objectLambdaUpdateWrapper2.set(UserExamGoodsSupplement::getGoodsId, goodsNew.getGoodsId());
+        objectLambdaUpdateWrapper2.set(UserExamGoodsSupplement::getUpdateTime,DateUtils.getNowTime());
+        iUserExamGoodsSupplementService.update(null, objectLambdaUpdateWrapper2);
+
+        bo.setGoodsId(goodsNew.getGoodsId());
+        bo.setCourseId(goodsCourseNew.getCourseId());
+        return bo;
     }
 }

+ 2 - 0
zhongzheng-system/src/main/resources/mapper/modules/course/CourseMapper.xml

@@ -26,6 +26,7 @@
         <result property="subjectId" column="subject_id"/>
         <result property="projectId" column="project_id"/>
         <result property="courseShow" column="course_show"/>
+        <result property="firstChoice" column="first_choice"/>
     </resultMap>
 
     <resultMap type="com.zhongzheng.modules.course.vo.CourseVo" id="CourseResultVo">
@@ -56,6 +57,7 @@
         <result property="categoryName" column="category_name"/>
         <result property="subjectName" column="subject_name"/>
         <result property="courseShow" column="course_show"/>
+        <result property="firstChoice" column="first_choice"/>
         <collection property="goodsList" column="course_id" select="findGoodsList"/>
     </resultMap>
 

+ 12 - 0
zhongzheng-system/src/main/resources/mapper/modules/course/CourseMenuMapper.xml

@@ -59,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="teacherName" column="teacher_name"/>
         <result property="goodsId" column="goods_id"/>
         <result property="commonSign" column="common_sign"/>
+        <result property="firstChoiceStatus" column="first_choice_status"/>
     </resultMap>
 
     <select id="getList" parameterType="com.zhongzheng.modules.course.bo.CourseMenuQueryBo"  resultMap="CourseMenuResultVo">
@@ -388,4 +389,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectByNotTenant" parameterType="map"  resultType="com.zhongzheng.modules.course.domain.CourseMenu">
         SELECT * FROM `course_menu` WHERE course_id = #{newCourseId} AND menu_id = #{newModuleId} AND type = #{type} AND tenant_id = #{newTenantId}
     </select>
+
+    <select id="countChapterTotalTime" parameterType="map"  resultType="Long">
+        SELECT
+            IFNULL( SUM( s.duration_time ), 0 )
+        FROM
+            course_chapter_section cs
+                LEFT JOIN course_section s ON cs.section_id = s.section_id
+        WHERE
+            cs.chapter_id = #{chapterId}
+          AND s.`status` = 1
+    </select>
 </mapper>