Переглянути джерело

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

zouxuan 5 роки тому
батько
коміт
2b3ba4ca29

+ 20 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CourseListDto.java

@@ -1,7 +1,6 @@
 package com.ym.mec.biz.dal.dto;
 
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
-import com.ym.mec.biz.dal.entity.VipGroup;
 import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -72,6 +71,26 @@ public class CourseListDto {
 
     private Integer isApply;
 
+    private Integer practiceType;
+
+    private String practiceRenewUrl;
+
+    public String getPracticeRenewUrl() {
+        return practiceRenewUrl;
+    }
+
+    public void setPracticeRenewUrl(String practiceRenewUrl) {
+        this.practiceRenewUrl = practiceRenewUrl;
+    }
+
+    public Integer getPracticeType() {
+        return practiceType;
+    }
+
+    public void setPracticeType(Integer practiceType) {
+        this.practiceType = practiceType;
+    }
+
     public String getPracticeId() {
         return practiceId;
     }

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysConfigService.java

@@ -163,6 +163,11 @@ public interface SysConfigService extends BaseService<Long, SysConfig> {
     String STUDENT_STUDY_REPORT_URL = "student_study_report_url";
 
     /**
+     * @describe 陪练课续费地址
+     */
+    String PRACTICE_RENEW_URL = "practice_renew_url";
+
+    /**
      * @return com.ym.mec.biz.dal.entity.SysConfig
      * @params paramName
      * @describe 根据配置名称获取配置信息

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -110,6 +110,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
     private GroupDao groupDao;
     @Autowired
     private CourseScheduleEvaluateDao courseScheduleEvaluateDao;
+    @Autowired
+    private SysConfigService sysConfigService;
 
     @Override
     public BaseDAO<Integer, ClassGroup> getDAO() {
@@ -643,6 +645,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         Set<Integer> schoolIds = courseListDtos.stream().map(CourseListDto::getTeacherSchoolId).collect(Collectors.toSet());
         Map<Integer, String> schoolNames = MapUtil.convertMybatisMap(schoolDao.queryNameByIds(StringUtils.join(schoolIds, ",")));
 
+        SysConfig practiceRenewUrlConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_RENEW_URL);
+
         Long classTimes = null;
         for (CourseListDto e:courseListDtos) {
             if(StringUtils.isNotEmpty(e.getMusicId())){
@@ -658,6 +662,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             e.setIsApply(isApplyMap.get(e.getMusicId()));
             if(ClassGroupTypeEnum.PRACTICE == e.getType()){
                 e.setStudentNames(practiceStuNames.get(e.getPracticeId()));
+                e.setPracticeRenewUrl(practiceRenewUrlConfig.getParanValue());
             }
             if (ClassGroupTypeEnum.VIP == e.getType()) {
                 e.setStudentNames(vipStuNames.get(e.getVipId()));

+ 30 - 19
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java

@@ -2093,7 +2093,15 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         if(Objects.isNull(groupId)){
             throw new BizException("请选择续费的课程");
         }
-        return practiceGroupDao.findUserPracticeGroup2(userId, groupId);
+        Date now=new Date();
+        PracticeGroupDto userPracticeGroup = practiceGroupDao.findUserPracticeGroup2(userId, groupId);
+        if(Objects.isNull(userPracticeGroup)){
+            throw new BizException("需要续费的课程组不存在");
+        }
+        if(userPracticeGroup.getCoursesExpireDate().before(now)){
+            throw new BizException("此课程组已超过可续费期限");
+        }
+        return userPracticeGroup;
     }
 
     @Override
@@ -2222,16 +2230,17 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
     @Override
     public Map<Integer, List<String>> getEnableApplyDatesWithWeek() {
         Map<Integer, List<String>> result = new HashMap<>();
-        SysConfig practiceApplyStartTimeConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_APPLY_START_TIME);
-        SysConfig practiceApplyEndTimeConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_APPLY_END_TIME);
         SysConfig practiceApplyIntervalTimeConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_APPLY_INTERVAL_TIME);
         Integer practiceApplyIntervalMinutes = practiceApplyIntervalTimeConfig.getParanValue(Integer.class);
-        LocalTime dayStartTime=LocalTime.parse(practiceApplyStartTimeConfig.getParanValue(),DateUtil.timeFormatter);
-        LocalTime dayEndTime=LocalTime.parse(practiceApplyEndTimeConfig.getParanValue(),DateUtil.timeFormatter);
+        LocalTime dayStartTime=LocalTime.parse("00:00:00",DateUtil.timeFormatter);
+        LocalTime dayEndTime=LocalTime.parse("00:00:00",DateUtil.timeFormatter);
         List<String> dayApplyTimes=new ArrayList<>();
-        while (dayEndTime.isAfter(dayStartTime)){
+        while (true){
             dayApplyTimes.add(dayStartTime.format(DateUtil.timeFormatter));
             dayStartTime=dayStartTime.plusMinutes(practiceApplyIntervalMinutes);
+            if(dayStartTime.compareTo(dayEndTime)==0){
+                break;
+            }
         }
         for (int i = 1; i <= 7; i++) {
             List<String> tempTimes = new ArrayList<>();
@@ -2329,21 +2338,14 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         WeekFields weekFields = WeekFields.of(DayOfWeek.MONDAY, 1);
         ZoneId zoneId = ZoneId.systemDefault();
 
-        Date today=new Date();
-
         LocalDate now = LocalDate.now();
         if(renew){
             PracticeGroup userLatestPracticeGroup = practiceGroupDao.findUserPracticeGroup(userId,groupId);
             if(Objects.nonNull(userLatestPracticeGroup)){
-                if(userLatestPracticeGroup.getCoursesExpireDate().after(today)){
-                    throw new BizException("此课程组已超过可续费期限");
-                }
-                LocalDate lastExpiredDay=LocalDateTime.ofInstant(userLatestPracticeGroup.getCoursesExpireDate().toInstant(),DateUtil.zoneId).toLocalDate();
+                LocalDate lastExpiredDay=LocalDateTime.ofInstant(userLatestPracticeGroup.getCoursesExpireDate().toInstant(),DateUtil.zoneId).plusSeconds(1).toLocalDate();
                 if(Objects.nonNull(lastExpiredDay)&&lastExpiredDay.compareTo(now)>=0){
                     now=lastExpiredDay;
                 }
-            }else{
-                throw new BizException("需要续费的课程组不存在");
             }
         }
         now.plusDays(1);
@@ -2353,7 +2355,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         Date secondSunday = DateUtil.getWeekDayWithDate(applyEndDate, Calendar.SUNDAY);
 
         Map<Integer, List<String>> weekNumApplyTimesMap = getEnableApplyDatesWithWeek();
-        List<CourseSchedule> allTeacherCourses = courseScheduleDao.findTeacherCoursesWithDateRange(teacherId, firstMonday, secondSunday);
+        List<CourseSchedule> allTeacherCourses = courseScheduleDao.findTeacherCoursesWithDateRange(teacherId, applyStartDate, secondSunday);
         allTeacherCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
 
         JSONObject teacherLeaveData = null;
@@ -2444,9 +2446,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         }
 
         if (CollectionUtils.isEmpty(allTeacherCourses)) {
-            if(weekNumApplyTimesMap.size()<=1){
-                weekNumApplyTimesMap=new HashMap<>();
-            }
             result.put("teacherFreeDays", weekNumApplyTimesMap);
             return result;
         }
@@ -2498,7 +2497,11 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
                     continue;
                 }
             }
-            weekNumApplyTimesMap.put(courseStartTime.getDayOfWeek().getValue(), applyTimeStrs);
+            if(CollectionUtils.isEmpty(applyTimeStrs)){
+                weekNumApplyTimesMap.remove(courseStartTime.getDayOfWeek().getValue());
+            }else{
+                weekNumApplyTimesMap.put(courseStartTime.getDayOfWeek().getValue(), applyTimeStrs);
+            }
         }
         if(weekNumApplyTimesMap.size()<=1){
             weekNumApplyTimesMap=new HashMap<>();
@@ -2555,10 +2558,15 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             }
             PracticeGroup userLatestPracticeGroup = practiceGroupDao.findUserPracticeGroup(practiceGroupBuyParams.getStudentId(),practiceGroupBuyParams.getGroupId());
             if(Objects.nonNull(userLatestPracticeGroup)){
+                if(userLatestPracticeGroup.getCoursesExpireDate().before(now)){
+                    throw new BizException("此课程组已超过可续费期限");
+                }
                 LocalDate lastExpiredDay=LocalDateTime.ofInstant(userLatestPracticeGroup.getCoursesExpireDate().toInstant(),DateUtil.zoneId).toLocalDate();
                 if(Objects.nonNull(lastExpiredDay)&&lastExpiredDay.compareTo(courseStartDay)>=0){
                     courseStartDay=lastExpiredDay;
                 }
+            }else{
+                return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "需要续费的课程组不存在");
             }
         }
 
@@ -2895,6 +2903,9 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         if(order.getStatus().equals(DealStatusEnum.SUCCESS)){
             courseScheduleDao.updateGroupCourseLock(order.getMusicGroupId(),GroupType.PRACTICE,0);
         }else{
+            if(Objects.nonNull(order.getBalancePaymentAmount())){
+                sysUserCashAccountService.updateBalance(order.getUserId(), order.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "陪练课购买失败");
+            }
             studentPaymentOrderDao.update(order);
             groupService.deleteGroupInfo(order.getMusicGroupId(),GroupType.PRACTICE);
             return;

+ 3 - 1
mec-biz/src/main/resources/config/mybatis/ClassGroupMapper.xml

@@ -736,6 +736,7 @@
         <result column="offline_classes_num_" property="offLineClassesNum"/>
         <result column="teacher_school_id_" property="teacherSchoolId"/>
         <result column="class_mode_" property="classMode"/>
+        <result column="practice_type_" property="practiceType"/>
         <result column="payment_status_" property="paymentStatus"
                 typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
     </resultMap>
@@ -766,7 +767,8 @@
     <select id="queryStudentPracticeCourses" resultMap="CourseListDto">
         SELECT cg.id_ class_group_id_,pg.name_ music_group_name_,su.real_name_,
         cg.current_class_times_,cg.total_class_times_,pg.single_class_minutes_,
-        pg.id_ practice_id_,cg.type_,1 class_mode_
+        pg.id_ practice_id_,cg.type_,1 class_mode_,
+        IF(pg.buy_months_ IS NULL,0,1) practice_type_
         FROM practice_group pg
         LEFT JOIN class_group cg ON cg.music_group_id_ = pg.id_
         LEFT JOIN sys_user su ON pg.user_id_ = su.id_

+ 6 - 2
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -529,7 +529,7 @@
             LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cs.id_  AND sa.user_id_=#{studentId}
         WHERE
         (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
-        AND cs.is_lock_=0
+        AND (cs.is_lock_=0 OR cs.is_lock_ IS NULL)
         AND cs.class_date_ = DATE_FORMAT(#{classDate},'%Y%m%d')
         AND cssp.user_id_ = #{studentId}
         <if test="quitClassGroupIds != null and quitClassGroupIds.size()>0">
@@ -570,7 +570,7 @@
             LEFT JOIN teacher_attendance ta ON cs.id_=ta.course_schedule_id_ AND ta.teacher_id_=#{teacherId}
         WHERE
         (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
-        AND cs.is_lock_=0
+        AND (cs.is_lock_=0 OR cs.is_lock_ IS NULL)
         AND cs.class_date_ = DATE_FORMAT(#{classDate},'%Y%m%d')
         <if test="type!=null and type!=''">
             AND cs.type_=#{type}
@@ -738,6 +738,7 @@
         LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
         WHERE
         (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
+        AND (cs.is_lock_=0 OR cs.is_lock_ IS NULL)
         AND cssp.user_id_ = #{studentId}
         <if test="month==null">
             AND DATE_FORMAT( NOW(), '%Y%m' ) = DATE_FORMAT( cs.class_date_, '%Y%m' )
@@ -761,6 +762,7 @@
             LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
         WHERE
           (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
+          AND (cs.is_lock_=0 OR cs.is_lock_ IS NULL)
           AND csts.user_id_ = #{teacherId}
           AND cg.del_flag_ = 0
         <if test="month==null">
@@ -2229,9 +2231,11 @@
           course_schedule_student_payment cssp
           LEFT JOIN course_schedule cs ON cs.id_=cssp.course_schedule_id_
           LEFT JOIN sys_user su ON cs.actual_teacher_id_=su.id_
+          LEFT JOIN practice_group pg ON pg.id_=cssp.music_group_id_
         WHERE cs.group_type_='PRACTICE'
           AND cssp.user_id_=#{userId}
           AND cssp.expect_price_=0
+          AND pg.buy_months_ IS NULL
     </select>
     <select id="findTeacherCoursesWithIncludeDateRange" resultMap="CourseSchedule" useCache="false" flushCache="true">
         SELECT

+ 1 - 0
mec-biz/src/main/resources/config/mybatis/PracticeGroupMapper.xml

@@ -136,6 +136,7 @@
 		WHERE
 			student_id_=#{userId}
 			AND pg.group_status_!='FINISH'
+			AND pg.buy_months_ IS NOT NULL
 	</select>
 	<select id="findUserPracticeGroup" resultMap="PracticeGroup">
 		SELECT * FROM practice_group WHERE student_id_=#{userId} AND id_=#{groupId};

+ 1 - 1
mec-student/src/main/java/com/ym/mec/student/controller/PracticeGroupController.java

@@ -172,7 +172,7 @@ public class PracticeGroupController extends BaseController {
         if (sysUser == null) {
             return failed(HttpStatus.FORBIDDEN, "请登录");
         }
-        return succeed(practiceGroupService.repay(sysUser.getId(),groupId));
+        return practiceGroupService.repay(sysUser.getId(),groupId);
     }
 
 }