|
@@ -26,6 +26,8 @@ import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
@@ -109,6 +111,8 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
private PracticeGroupSellPriceDao practiceGroupSellPriceDao;
|
|
|
@Autowired
|
|
|
private TeacherDefaultPracticeGroupSalaryDao teacherDefaultPracticeGroupSalaryDao;
|
|
|
+ @Autowired
|
|
|
+ private ContractService contractService;
|
|
|
|
|
|
private static Map<Integer, Map<Integer, List<Integer>>> schoolSubjectTeachersMap;
|
|
|
|
|
@@ -122,6 +126,9 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
|
|
|
private static Date activityStartDate, activityEndDate, applyStartDay, courseExpireDate;
|
|
|
|
|
|
+ private static final Logger LOGGER = LoggerFactory
|
|
|
+ .getLogger(PracticeGroupService.class);
|
|
|
+
|
|
|
private static List<String> applyDayTimes = new ArrayList<>();
|
|
|
|
|
|
static {
|
|
@@ -2093,7 +2100,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
|
|
@@ -2156,7 +2171,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
|
|
|
List<Integer> allTeacherIds = organAndSubjectTeachers.stream().map(TeacherBasicDto::getId).collect(Collectors.toList());
|
|
|
|
|
|
- List<CourseSchedule> userCourses = courseScheduleDao.findUserCourses(userId, allTeacherIds);
|
|
|
+ List<CourseSchedule> userCourses = courseScheduleDao.findUserCourses2(userId, allTeacherIds);
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(userCourses)) {
|
|
|
Map<CourseSchedule.CourseScheduleType, List<CourseSchedule>> courseTypeCourseMap = userCourses.stream().collect(Collectors.groupingBy(CourseSchedule::getType));
|
|
@@ -2222,16 +2237,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,31 +2345,23 @@ 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);
|
|
|
- Date applyStartDate = Date.from(now.atStartOfDay(zoneId).toInstant());
|
|
|
+ Date applyStartDate = Date.from(now.plusDays(1).atStartOfDay(zoneId).toInstant());
|
|
|
Date applyEndDate = Date.from(now.plusMonths(buyMonths).atStartOfDay(zoneId).toInstant());
|
|
|
Date firstMonday = DateUtil.getWeekDayWithDate(applyStartDate, Calendar.MONDAY);
|
|
|
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 +2452,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 +2503,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 +2564,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, "需要续费的课程组不存在");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2824,7 +2838,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
orderNo,
|
|
|
baseApiUrl+"/api-student/studentOrder/notify",
|
|
|
baseApiUrl+"/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
|
|
|
- "vip课购买",
|
|
|
+ "陪练课购买",
|
|
|
practiceGroupBuyParams.getName(),
|
|
|
practiceGroupBuyParams.getStudentId(),
|
|
|
classFee,
|
|
@@ -2895,6 +2909,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;
|
|
@@ -2940,6 +2957,12 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
practiceGroup.setGroupStatus(GroupStatusEnum.NORMAL);
|
|
|
practiceGroupDao.update(practiceGroup);
|
|
|
|
|
|
+ try {
|
|
|
+ contractService.transferPracticeCoursesContract(order.getUserId(),classGroup.getTotalClassTimes(),practiceGroup.getCoursesStartDate(),practiceGroup.getCoursesExpireDate(),order.getExpectAmount());
|
|
|
+ } catch (Exception e) {
|
|
|
+ LOGGER.error("小课[{}]购买协议错误:{}",order.getMusicGroupId(),e.getMessage(),e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
// List<ImGroupMember> imGroupMemberList = new ArrayList<>();
|
|
|
// imGroupMemberList.add(new ImGroupMember(practiceGroup.getUserId().toString()));
|
|
|
// imGroupMemberList.add(new ImGroupMember(practiceGroup.getStudentId().toString()));
|
|
@@ -3062,12 +3085,14 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
);
|
|
|
|
|
|
Map<String,BigDecimal> routingFee = (Map<String,BigDecimal>)payMap.get("routingFee");
|
|
|
+ newOrder.setOrderNo(orderNo);
|
|
|
newOrder.setOrganId(practiceGroup.getOrganId());
|
|
|
newOrder.setComAmount(routingFee.get("COM"));
|
|
|
newOrder.setPerAmount(routingFee.get("PER"));
|
|
|
newOrder.setMerNos((String) payMap.get("routingMerNos"));
|
|
|
newOrder.setPaymentChannel((String) payMap.get("type"));
|
|
|
newOrder.setUpdateTime(new Date());
|
|
|
+ newOrder.setCreateTime(new Date());
|
|
|
studentPaymentOrderService.insert(newOrder);
|
|
|
|
|
|
return BaseController.succeed(payMap);
|