hgw %!s(int64=3) %!d(string=hai) anos
pai
achega
0a338cdcbf

+ 1 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/CourseScheduleDao.java

@@ -49,6 +49,7 @@ public interface CourseScheduleDao extends BaseMapper<CourseSchedule> {
      * @param param 传入参数
      *              <p> - studentId 学生id
      *              <p> - status 课程状态 NOT_START未开始 ING进行中 COMPLETE已完成
+     *              <p> - statusList 课程状态集合 NOT_START未开始 ING进行中 COMPLETE已完成
      *              <p> - classDate  年月日
      *              <p> - startClassDate 开始时间-年月日
      *              <p> - endClassDate 结束时间-年月日

+ 10 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseGroupServiceImpl.java

@@ -261,7 +261,7 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
             List<CourseScheduleStudentPayment> list = courseScheduleStudentPaymentService.list(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
                     .eq(CourseScheduleStudentPayment::getCourseGroupId, groupId));
             if (CollectionUtils.isNotEmpty(list)) {
-                throw new BizException("课程组已有学生付款或有待付款的订单,无法下架/取消课程组!");
+                throw new BizException("该课程组已有学生付款或支付中无法下架或取消!");
             }
         } else if (courseStateFunc.test(CourseGroupEnum.COMPLETE)) {
             throw new BizException("课程组已完结!");
@@ -590,6 +590,10 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
                 .eq(CourseGroup::getId, groupId)
                 .eq(CourseGroup::getType, CourseScheduleEnum.LIVE.getCode())
         );
+        //只要不是销售中的课程组都提示无法购买
+        if(!courseGroup.getStatus().equals(CourseGroupEnum.APPLY.getCode())){
+            throw new BizException("课程已结束销售!");
+        }
         if (Objects.isNull(courseGroup)) {
             throw new BizException("课程组不存在!");
         }
@@ -867,6 +871,11 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
                 } else {
                     //人数未达标则修改课程组为取消状态
                     courseGroup.setStatus(CourseGroupEnum.CANCEL.getCode());
+                    //更新课程组下课程状态为取消
+                    courseScheduleService.update(Wrappers.<CourseSchedule>lambdaUpdate()
+                            .eq(CourseSchedule::getCourseGroupId, courseGroup.getId())
+                            .set(CourseSchedule::getStatus, CourseScheduleEnum.CANCEL.getCode())
+                    );
                 }
                 this.updateById(courseGroup);
             } catch (Exception ignored) {

+ 5 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Lists;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.dao.CourseScheduleDao;
@@ -43,8 +44,6 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.text.DateFormat;
-import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.temporal.TemporalAdjusters;
@@ -534,9 +533,12 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
      * @param studentId 学员id
      */
     private Map<String, List<CourseTimeEntity>> getAllPracticeCourseTime(Long teacherId, Long studentId, String startDate, String endDate) {
+        //未开始、进行中的课程
+        List<String> statusList = Lists.newArrayList(CourseScheduleEnum.NOT_START.getCode(), CourseScheduleEnum.ING.getCode());
         //查询该老师指定时间段的课程
         List<CourseSchedule> courseList = this.list(Wrappers.<CourseSchedule>lambdaQuery()
                 .eq(CourseSchedule::getTeacherId, teacherId)
+                .in(CourseSchedule::getStatus, statusList)
                 .ge(CourseSchedule::getClassDate, startDate)
                 .le(CourseSchedule::getClassDate, endDate)
         );
@@ -548,6 +550,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         param.put("studentId", studentId);
         param.put("startClassDate", startDate);
         param.put("endClassDate", endDate);
+        param.put("statusList", statusList);
         List<CourseSchedule> studentCourse = baseMapper.queryStudentCourse(param);
         //将数据合并
         if (CollectionUtils.isNotEmpty(studentCourse)) {

+ 1 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseGroupMapper.xml

@@ -47,7 +47,7 @@
     </insert>
 
     <select id="queryTeacherCourseGroup" resultType="com.yonge.cooleshow.biz.dal.vo.CourseGroupVo">
-        select
+        select distinct
         b.id_                         as courseGroupId,
         b.name_                       as courseGroupName,
         s.name_                       as subjectName,

+ 6 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -108,6 +108,12 @@
             <if test="param.status != null">
                 AND b.status_ = #{param.status}
             </if>
+            <if test="param.statusList != null">
+                AND b.status_ IN
+                <foreach collection="param.statusList" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
         </where>
         order by b.start_time_ desc
     </select>