Procházet zdrojové kódy

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

zouxuan před 5 roky
rodič
revize
9cb9932267

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/PracticeGroupDao.java

@@ -61,6 +61,18 @@ public interface PracticeGroupDao extends com.ym.mec.common.dal.BaseDAO<Long, Pr
      */
     void updateUserId(@Param("practiceGroupId") String practiceGroupId, @Param("teacherId") Integer teacherId);
 
+
+    /**
+     * @describe 获取学生指定的课程组
+     * @author Joburgess
+     * @date 2020/2/19
+     * @param userId:
+     * @param groupId:
+     * @return com.ym.mec.biz.dal.entity.PracticeGroup
+     */
+    PracticeGroup findUserPracticeGroup(@Param("userId") Integer userId,
+                                        @Param("groupId") Long groupId);
+
     /**
      * @describe 获取学生最后一次购买的陪练课组
      * @author Joburgess

+ 20 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/PracticeGroupBuyDto.java

@@ -14,8 +14,28 @@ public class PracticeGroupBuyDto extends PracticeGroup {
     @ApiModelProperty(value = "是否使用账户余额支付")
     private boolean useBalancePayment;
 
+    private boolean renew;
+
+    private Long groupId;
+
     private List<PracticeDrillTimeDto> drillTimes;
 
+    public Long getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(Long groupId) {
+        this.groupId = groupId;
+    }
+
+    public boolean isRenew() {
+        return renew;
+    }
+
+    public void setRenew(boolean renew) {
+        this.renew = renew;
+    }
+
     public boolean isUseBalancePayment() {
         return useBalancePayment;
     }

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/PracticeGroupService.java

@@ -120,7 +120,7 @@ public interface PracticeGroupService extends BaseService<Long, PracticeGroup> {
 	 * @param userId:
 	 * @return com.ym.mec.biz.dal.entity.PracticeGroup
 	 */
-	PracticeGroup findUserLatestPracticeGroup(Integer userId);
+	PracticeGroup findUserLatestPracticeGroup(Integer userId, Long groupId);
 
     /**
      * @describe 获取陪练课预约参数——付费
@@ -151,7 +151,7 @@ public interface PracticeGroupService extends BaseService<Long, PracticeGroup> {
      * @param buyMonths: 购买月数
      * @return java.util.Map
      */
-    Map getPayPracticeTeacherFreeTimes(Integer userId, Integer teacherId, Integer buyMonths, Date firstClassTime);
+    Map getPayPracticeTeacherFreeTimes(Integer userId, Integer teacherId, Integer buyMonths, boolean renew, Long groupId);
 
     /**
      * @describe 获取一周内可以预约课程的时间——付费

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

@@ -2082,8 +2082,11 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
     }
 
     @Override
-    public PracticeGroup findUserLatestPracticeGroup(Integer userId) {
-        return practiceGroupDao.findUserLatestPracticeGroup(userId);
+    public PracticeGroup findUserLatestPracticeGroup(Integer userId, Long groupId) {
+        if(Objects.isNull(groupId)){
+            throw new BizException("请选择续费的课程");
+        }
+        return practiceGroupDao.findUserPracticeGroup(userId, groupId);
     }
 
     @Override
@@ -2234,7 +2237,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
     }
 
     @Override
-    public Map getPayPracticeTeacherFreeTimes(Integer userId, Integer teacherId, Integer buyMonths, Date firstClassTime) {
+    public Map getPayPracticeTeacherFreeTimes(Integer userId, Integer teacherId, Integer buyMonths, boolean renew, Long groupId) {
         if (Objects.isNull(teacherId)) {
             throw new BizException("请选择教师");
         }
@@ -2245,6 +2248,9 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         if (Objects.isNull(student.getOrganId())) {
             throw new BizException("未找到用户分部属性");
         }
+        if(renew&&Objects.isNull(groupId)){
+            throw new BizException("请选择需要续费的课程");
+        }
         Teacher teacher = teacherDao.get(teacherId);
         if (Objects.isNull(teacher)) {
             throw new BizException("教师不存在");
@@ -2316,11 +2322,20 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         WeekFields weekFields = WeekFields.of(DayOfWeek.MONDAY, 1);
         ZoneId zoneId = ZoneId.systemDefault();
 
-        LocalDateTime now = LocalDateTime.now();
+        LocalDate now = LocalDate.now();
+        if(renew){
+            PracticeGroup userLatestPracticeGroup = practiceGroupDao.findUserPracticeGroup(userId,groupId);
+            if(Objects.nonNull(userLatestPracticeGroup)){
+                LocalDate lastExpiredDay=LocalDateTime.ofInstant(userLatestPracticeGroup.getCoursesExpireDate().toInstant(),DateUtil.zoneId).toLocalDate();
+                if(Objects.nonNull(lastExpiredDay)&&lastExpiredDay.compareTo(now)>=0){
+                    now=lastExpiredDay;
+                }
+            }
+        }
         now.plusDays(1);
-        Date applyStartDate = Date.from(now.atZone(zoneId).toInstant());
+        Date applyStartDate = Date.from(now.atStartOfDay(zoneId).toInstant());
         now.plusMonths(buyMonths);
-        Date applyEndDate = Date.from(now.atZone(zoneId).toInstant());
+        Date applyEndDate = Date.from(now.atStartOfDay(zoneId).toInstant());
         Date firstMonday = DateUtil.getWeekDayWithDate(applyStartDate, Calendar.MONDAY);
         Date secondSunday = DateUtil.getWeekDayWithDate(applyEndDate, Calendar.SUNDAY);
 
@@ -2337,10 +2352,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             checkTeacherLeaveDate = false;
         }
 
-        if (Objects.nonNull(firstClassTime)) {
-            LocalDateTime localFirstClassTime = LocalDateTime.ofInstant(firstClassTime.toInstant(), zoneId);
-            weekNumApplyTimesMap.remove(localFirstClassTime.getDayOfWeek().getValue());
-        }
         weekNumApplyTimesMap.remove(holiday);
 
         if (teacherId == 100473) {
@@ -2524,14 +2535,17 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         Date practiceBuyActivityExpireDate=DateUtil.stringToDate(practiceBuyActivityExpireDateConfig.getParanValue(),"yyyy-MM-dd HH:mm:ss");
 
         Date now=new Date();
-        PracticeGroup userLatestPracticeGroup = practiceGroupDao.findUserLatestPracticeGroup(practiceGroupBuyParams.getUserId());
         LocalDate courseStartDay=LocalDate.now();
-        if(Objects.nonNull(userLatestPracticeGroup)){
-            LocalDate lastExpiredDay=LocalDateTime.ofInstant(userLatestPracticeGroup.getCoursesExpireDate().toInstant(),DateUtil.zoneId).toLocalDate();
-            if(Objects.nonNull(lastExpiredDay)&&lastExpiredDay.compareTo(courseStartDay)>=0){
-                courseStartDay=lastExpiredDay;
+        if(practiceGroupBuyParams.isRenew()){
+            PracticeGroup userLatestPracticeGroup = practiceGroupDao.findUserPracticeGroup(practiceGroupBuyParams.getUserId(),practiceGroupBuyParams.getGroupId());
+            if(Objects.nonNull(userLatestPracticeGroup)){
+                LocalDate lastExpiredDay=LocalDateTime.ofInstant(userLatestPracticeGroup.getCoursesExpireDate().toInstant(),DateUtil.zoneId).toLocalDate();
+                if(Objects.nonNull(lastExpiredDay)&&lastExpiredDay.compareTo(courseStartDay)>=0){
+                    courseStartDay=lastExpiredDay;
+                }
             }
         }
+
         courseStartDay=courseStartDay.plusDays(1);
         Date courseStartDate=Date.from(courseStartDay.atStartOfDay(DateUtil.zoneId).toInstant());
         practiceGroupBuyParams.setCoursesStartDate(courseStartDate);
@@ -2712,7 +2726,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             courseScheduleService.checkNewCourseSchedules(practiceCourses,false);
         } catch (Exception e) {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-            return BaseController.failed(HttpStatus.FOUND, "课程冲突");
+            return BaseController.failed(HttpStatus.FOUND, e.getMessage());
         }
 
         StudentPaymentOrder studentPaymentOrder=new StudentPaymentOrder();

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

@@ -121,11 +121,16 @@
 			practice_group pg
 			LEFT JOIN sys_user su ON pg.user_id_ = su.id_
 			LEFT JOIN `subject` s ON pg.subject_id_ = s.id_
+			LEFT JOIN student_payment_order spo ON spo.music_group_id_=pg.id_ AND spo.group_type_='PRACTICE'
 		WHERE
 			student_id_=#{userId}
+			AND spo.status_="SUCCESS"
+	</select>
+    <select id="findUserPracticeGroup" resultMap="PracticeGroup">
+		SELECT * FROM practice_group WHERE student_id_=#{userId} AND id_=#{groupId};
 	</select>
 
-	<sql id="practiceGroupQueryCondition">
+    <sql id="practiceGroupQueryCondition">
 		<where>
 			<if test="search!=null and search!=''">
 				AND (pg.name_ LIKE CONCAT('%',#{search},'%') OR pg.id_= #{search})

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

@@ -120,22 +120,22 @@ public class PracticeGroupController extends BaseController {
 
     @ApiOperation("获取指定教师的空闲时间——付费")
     @GetMapping(value = "/getPayPracticeTeacherFreeTimes")
-    public Object getPayPracticeTeacherFreeTimes(Integer teacherId,Integer buyMonths, Date firstClassTime){
+    public Object getPayPracticeTeacherFreeTimes(Integer teacherId,Integer buyMonths, boolean renew, Long groupId){
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if (sysUser == null) {
             return failed(HttpStatus.FORBIDDEN, "请登录");
         }
-        return succeed(practiceGroupService.getPayPracticeTeacherFreeTimes(sysUser.getId(),teacherId, buyMonths,firstClassTime));
+        return succeed(practiceGroupService.getPayPracticeTeacherFreeTimes(sysUser.getId(),teacherId, buyMonths,renew,groupId));
     }
 
     @ApiOperation("获取学生上一次的购买信息--付费")
     @GetMapping(value = "/findUserLatestPracticeGroup")
-    public HttpResponseResult findUserLatestPracticeGroup(){
+    public HttpResponseResult findUserLatestPracticeGroup(Long groupId){
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if (sysUser == null) {
             return failed(HttpStatus.FORBIDDEN, "请登录");
         }
-        return succeed(practiceGroupService.findUserLatestPracticeGroup(sysUser.getId()));
+        return succeed(practiceGroupService.findUserLatestPracticeGroup(sysUser.getId(),groupId));
     }
 
     @ApiOperation("陪练课购买")