|
@@ -26,6 +26,7 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.im.ImFeignService;
|
|
|
import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
+import com.ym.mec.util.date.DateConvertor;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import com.ym.mec.util.string.MessageFormatter;
|
|
|
|
|
@@ -43,18 +44,23 @@ import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.MessageFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
+import static com.ym.mec.biz.dal.enums.GroupType.MUSIC;
|
|
|
+import static com.ym.mec.biz.dal.enums.GroupType.VIP;
|
|
|
+
|
|
|
@Service
|
|
|
public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> implements VipGroupService {
|
|
|
|
|
@@ -827,6 +833,120 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public HttpResponseResult importActivityVipGroup(String data) {
|
|
|
+ if(StringUtils.isBlank(data)){
|
|
|
+ return BaseController.succeed();
|
|
|
+ }
|
|
|
+ List<JSONObject> datas = JSON.parseArray(data, JSONObject.class);
|
|
|
+ Date date = new Date();
|
|
|
+ for (JSONObject courseData : datas) {
|
|
|
+ boolean skipHoliday = "是".equals(courseData.getString("skip_holiday"))?true:false;
|
|
|
+ String vipGroupCategory = courseData.getString("vip_group_category");
|
|
|
+ int courseMinute = "考前辅导课".equals(vipGroupCategory)?25:45;
|
|
|
+ int onlineCourseNum = courseData.getIntValue("online_course_num");
|
|
|
+ int onlineWeekNum = courseData.getIntValue("online_course_week_num");
|
|
|
+ String onlineCourseStartTime = courseData.getString("online_course_start_time");
|
|
|
+ int offlineCourseNum = courseData.getIntValue("offline_course_num");
|
|
|
+ int offlineWeekNum = courseData.getIntValue("offline_course_week_num");
|
|
|
+ String offlineCourseStartTime = courseData.getString("offline_course_start_time");
|
|
|
+ int totalCourseNum = onlineCourseNum + offlineCourseNum;
|
|
|
+ Integer teacherId = courseData.getInteger("teacher_id");
|
|
|
+ Integer studentId = courseData.getInteger("student_id");
|
|
|
+ SysUser student = studentDao.getUser(studentId);
|
|
|
+
|
|
|
+ LocalDate onlineCourseStartDay = LocalDate.parse(courseData.getString("online_course_start_day"), DateUtil.dateFormatter);
|
|
|
+ LocalDate offlineCourseStartDay = LocalDate.parse(courseData.getString("offline_course_start_day"), DateUtil.dateFormatter);
|
|
|
+
|
|
|
+ LocalDate courseStartDay = onlineCourseStartDay;
|
|
|
+ if(onlineCourseStartDay.compareTo(offlineCourseStartDay)>0){
|
|
|
+ courseStartDay = offlineCourseStartDay;
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<String> holidayDays = new HashSet<>();
|
|
|
+
|
|
|
+ if (skipHoliday) {
|
|
|
+ SysConfig holidaySetting = sysConfigService.findByParamName(SysConfigService.HOLIDAY_SETTING);
|
|
|
+ if(Objects.nonNull(holidaySetting)&&StringUtils.isNotBlank(holidaySetting.getParanValue())){
|
|
|
+ holidayDays = new HashSet<>(JSON.parseArray(holidaySetting.getParanValue(), String.class));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<CourseSchedule> courseSchedules = new ArrayList<>();
|
|
|
+ int onlineCourseNumCreated = 0;
|
|
|
+ int offlineCourseNumCreated = 0;
|
|
|
+
|
|
|
+ while (true) {
|
|
|
+ if (skipHoliday && holidayDays.contains(courseStartDay.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))) {
|
|
|
+ courseStartDay = courseStartDay.plusDays(1);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ int dayOfWeek = courseStartDay.getDayOfWeek().getValue();//当前星期
|
|
|
+
|
|
|
+ if (onlineWeekNum < 1 || onlineWeekNum > 7) {
|
|
|
+ throw new BizException("排课循环周期错误,请核查");
|
|
|
+ }
|
|
|
+ if(courseStartDay.compareTo(onlineCourseStartDay)>=0&&onlineCourseNumCreated<onlineCourseNum&&dayOfWeek==onlineWeekNum){
|
|
|
+ Date classDate = DateConvertor.toDate(courseStartDay);
|
|
|
+ String startClassTime = DateUtil.getDate(classDate) + " " + onlineCourseStartTime;
|
|
|
+ String endClassTime = DateUtil.dateToString(DateUtil.addMinutes(DateUtil.stringToDate(startClassTime), courseMinute));
|
|
|
+
|
|
|
+ CourseSchedule courseSchedule = new CourseSchedule();
|
|
|
+ courseSchedule.setStatus(CourseStatusEnum.NOT_START);
|
|
|
+ courseSchedule.setClassDate(classDate);
|
|
|
+ courseSchedule.setStartClassTime(DateUtil.stringToDate(startClassTime));
|
|
|
+ courseSchedule.setEndClassTime(DateUtil.stringToDate(endClassTime));
|
|
|
+ courseSchedule.setCreateTime(date);
|
|
|
+ courseSchedule.setUpdateTime(date);
|
|
|
+ courseSchedule.setTeachMode(TeachModeEnum.ONLINE);
|
|
|
+ courseSchedule.setType(CourseSchedule.CourseScheduleType.VIP);
|
|
|
+ courseSchedule.setGroupType(VIP);
|
|
|
+ courseSchedule.setOrganId(student.getOrganId());
|
|
|
+ courseSchedule.setTeacherId(teacherId);
|
|
|
+ courseSchedule.setActualTeacherId(teacherId);
|
|
|
+ courseSchedules.add(courseSchedule);
|
|
|
+
|
|
|
+ onlineCourseNum++;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (offlineWeekNum < 1 || offlineWeekNum > 7) {
|
|
|
+ throw new BizException("排课循环周期错误,请核查");
|
|
|
+ }
|
|
|
+ if(courseStartDay.compareTo(offlineCourseStartDay)>=0&&offlineCourseNumCreated<offlineCourseNum&&dayOfWeek==offlineWeekNum){
|
|
|
+ Date classDate = DateConvertor.toDate(courseStartDay);
|
|
|
+ String startClassTime = DateUtil.getDate(classDate) + " " + offlineCourseStartTime;
|
|
|
+ String endClassTime = DateUtil.dateToString(DateUtil.addMinutes(DateUtil.stringToDate(startClassTime), courseMinute));
|
|
|
+
|
|
|
+ CourseSchedule courseSchedule = new CourseSchedule();
|
|
|
+ courseSchedule.setStatus(CourseStatusEnum.NOT_START);
|
|
|
+ courseSchedule.setClassDate(classDate);
|
|
|
+ courseSchedule.setStartClassTime(DateUtil.stringToDate(startClassTime));
|
|
|
+ courseSchedule.setEndClassTime(DateUtil.stringToDate(endClassTime));
|
|
|
+ courseSchedule.setCreateTime(date);
|
|
|
+ courseSchedule.setUpdateTime(date);
|
|
|
+ courseSchedule.setTeachMode(TeachModeEnum.OFFLINE);
|
|
|
+ courseSchedule.setType(CourseSchedule.CourseScheduleType.VIP);
|
|
|
+ courseSchedule.setGroupType(VIP);
|
|
|
+ courseSchedule.setOrganId(student.getOrganId());
|
|
|
+ courseSchedule.setTeacherId(teacherId);
|
|
|
+ courseSchedule.setActualTeacherId(teacherId);
|
|
|
+ courseSchedules.add(courseSchedule);
|
|
|
+
|
|
|
+ offlineCourseNum++;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (courseSchedules.size()>=totalCourseNum) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ courseStartDay = courseStartDay.plusDays(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public List<Organization> getPublicOrgans(Integer eduTeacherId, Integer teacherId) {
|
|
|
if(Objects.isNull(eduTeacherId)){
|
|
|
throw new BizException("教务老师不存在");
|