|
|
@@ -32,6 +32,7 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
|
@@ -48,6 +49,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.ym.mec.biz.dal.enums.SignInStatusEnum.*;
|
|
|
import static java.math.BigDecimal.ROUND_DOWN;
|
|
|
+import static java.math.BigDecimal.ZERO;
|
|
|
|
|
|
@Service
|
|
|
public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGroup> implements PracticeGroupService {
|
|
|
@@ -55,8 +57,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
@Autowired
|
|
|
private PracticeGroupDao practiceGroupDao;
|
|
|
@Autowired
|
|
|
- private SysConfigService sysConfigService;
|
|
|
- @Autowired
|
|
|
private SubjectDao subjectDao;
|
|
|
@Autowired
|
|
|
private OrganizationDao organizationDao;
|
|
|
@@ -144,6 +144,8 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
private StudentService studentService;
|
|
|
@Autowired
|
|
|
private CourseScheduleTeacherSalaryService courseScheduleTeacherSalaryService;
|
|
|
+ @Autowired
|
|
|
+ private RedisTemplate<String,Object> redisTemplate;
|
|
|
|
|
|
private static Map<Integer, Map<Integer, List<Integer>>> schoolSubjectTeachersMap;
|
|
|
|
|
|
@@ -249,7 +251,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
@Override
|
|
|
public Map<String, Object> checkCanApplyFreePracticeGroup(Integer userId) {
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
- SysConfig practiceFreeApplyExpireDateConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_FREE_APPLY_EXPIRE_DATE);
|
|
|
+ SysConfig practiceFreeApplyExpireDateConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_FREE_APPLY_EXPIRE_DATE);
|
|
|
result.put("practiceFreeApplyExpireDate", practiceFreeApplyExpireDateConfig.getParanValue());
|
|
|
return result;
|
|
|
}
|
|
|
@@ -283,7 +285,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
}
|
|
|
|
|
|
boolean checkTeacherLeaveDate = true;
|
|
|
- SysConfig allTeacherLeaveDataConfig = sysConfigService.findByParamName(SysConfigService.TEACHER_LEAVE_DATA);
|
|
|
+ SysConfig allTeacherLeaveDataConfig = sysConfigDao.findByParamName(SysConfigService.TEACHER_LEAVE_DATA);
|
|
|
JSONObject allTeacherLeaveData = JSONObject.parseObject(allTeacherLeaveDataConfig.getParanValue());
|
|
|
JSONObject organTeacherLeaveData = null;
|
|
|
if (Objects.nonNull(allTeacherLeaveData)) {
|
|
|
@@ -293,7 +295,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
checkTeacherLeaveDate = false;
|
|
|
}
|
|
|
|
|
|
- SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
Integer practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
List<Integer> teacherIds = organAndSubjectTeachers.stream().map(TeacherBasicDto::getId).collect(Collectors.toList());
|
|
|
teacherDao.lockTeachers(teacherIds);
|
|
|
@@ -565,7 +567,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
teacherDao.lockTeachers(teacherIds);
|
|
|
|
|
|
boolean checkTeacherLeaveDate = true;
|
|
|
- SysConfig allTeacherLeaveDataConfig = sysConfigService.findByParamName(SysConfigService.TEACHER_LEAVE_DATA);
|
|
|
+ SysConfig allTeacherLeaveDataConfig = sysConfigDao.findByParamName(SysConfigService.TEACHER_LEAVE_DATA);
|
|
|
JSONObject allTeacherLeaveData = JSONObject.parseObject(allTeacherLeaveDataConfig.getParanValue());
|
|
|
JSONObject organTeacherLeaveData = null;
|
|
|
if (Objects.nonNull(allTeacherLeaveData)) {
|
|
|
@@ -575,7 +577,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
checkTeacherLeaveDate = false;
|
|
|
}
|
|
|
|
|
|
- SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
Integer practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
Date now = new Date();
|
|
|
if (now.before(applyStartDay)) {
|
|
|
@@ -767,12 +769,12 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
@Override
|
|
|
public Map getPracticeApplyParams(Integer userId) {
|
|
|
Map result = new HashMap();
|
|
|
- SysConfig practiceSubjectIdListConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_SUBJECT_ID_LIST);
|
|
|
- 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);
|
|
|
- SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
- SysConfig practiceFreeApplyExpireDateConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_FREE_APPLY_EXPIRE_DATE);
|
|
|
+ SysConfig practiceSubjectIdListConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_SUBJECT_ID_LIST);
|
|
|
+ SysConfig practiceApplyStartTimeConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_APPLY_START_TIME);
|
|
|
+ SysConfig practiceApplyEndTimeConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_APPLY_END_TIME);
|
|
|
+ SysConfig practiceApplyIntervalTimeConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_APPLY_INTERVAL_TIME);
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ SysConfig practiceFreeApplyExpireDateConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_FREE_APPLY_EXPIRE_DATE);
|
|
|
Student student = studentDao.get(userId);
|
|
|
List<Subject> subjects = subjectDao.findBySubjectByIdList(practiceSubjectIdListConfig.getParanValue());
|
|
|
List<Integer> subjectIds = Arrays.asList(practiceSubjectIdListConfig.getParanValue().split(",")).stream().mapToInt(idStr -> Integer.valueOf(idStr)).boxed().collect(Collectors.toList());
|
|
|
@@ -797,7 +799,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
|
|
|
@Override
|
|
|
public Object getPracticeApplySubjects() {
|
|
|
- SysConfig practiceSubjectIdListConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_SUBJECT_ID_LIST);
|
|
|
+ SysConfig practiceSubjectIdListConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_SUBJECT_ID_LIST);
|
|
|
List<Subject> subjects = subjectDao.findBySubjectByIdList(practiceSubjectIdListConfig.getParanValue());
|
|
|
return subjects;
|
|
|
}
|
|
|
@@ -820,7 +822,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
}
|
|
|
|
|
|
Integer practiceCourseMinutes = 25;
|
|
|
- SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
if (Objects.nonNull(practiceCourseMinutesConfig)) {
|
|
|
practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
}
|
|
|
@@ -909,11 +911,11 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
Map result = new HashMap();
|
|
|
Set<Date> allTeacherFreeDates = new HashSet<>();
|
|
|
|
|
|
- SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
Integer practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
|
|
|
boolean checkTeacherLeaveDate = true;
|
|
|
- SysConfig allTeacherLeaveDataConfig = sysConfigService.findByParamName(SysConfigService.TEACHER_LEAVE_DATA);
|
|
|
+ SysConfig allTeacherLeaveDataConfig = sysConfigDao.findByParamName(SysConfigService.TEACHER_LEAVE_DATA);
|
|
|
JSONObject allTeacherLeaveData = JSONObject.parseObject(allTeacherLeaveDataConfig.getParanValue());
|
|
|
if (Objects.isNull(allTeacherLeaveData)) {
|
|
|
checkTeacherLeaveDate = false;
|
|
|
@@ -973,7 +975,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- SysConfig practiceFreeApplyExpireDateConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_FREE_APPLY_EXPIRE_DATE);
|
|
|
+ SysConfig practiceFreeApplyExpireDateConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_FREE_APPLY_EXPIRE_DATE);
|
|
|
Date practiceFreeApplyExpireDate = DateUtil.stringToDate(practiceFreeApplyExpireDateConfig.getParanValue());
|
|
|
|
|
|
Date now = new Date();
|
|
|
@@ -1338,7 +1340,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
}
|
|
|
Map result = new HashMap();
|
|
|
Set<Date> allTeacherFreeDates = new HashSet<>();
|
|
|
- SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
Integer practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
List<Integer> teacherIds = new ArrayList<>();
|
|
|
|
|
|
@@ -1367,7 +1369,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
teacherDao.lockTeachers(teacherIds);
|
|
|
|
|
|
boolean checkTeacherLeaveDate = true;
|
|
|
- SysConfig allTeacherLeaveDataConfig = sysConfigService.findByParamName(SysConfigService.TEACHER_LEAVE_DATA);
|
|
|
+ SysConfig allTeacherLeaveDataConfig = sysConfigDao.findByParamName(SysConfigService.TEACHER_LEAVE_DATA);
|
|
|
JSONObject allTeacherLeaveData = JSONObject.parseObject(allTeacherLeaveDataConfig.getParanValue());
|
|
|
JSONObject organTeacherLeaveData = null;
|
|
|
if (Objects.nonNull(allTeacherLeaveData)) {
|
|
|
@@ -1377,7 +1379,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
checkTeacherLeaveDate = false;
|
|
|
}
|
|
|
|
|
|
- SysConfig practiceFreeApplyExpireDateConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_FREE_APPLY_EXPIRE_DATE);
|
|
|
+ SysConfig practiceFreeApplyExpireDateConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_FREE_APPLY_EXPIRE_DATE);
|
|
|
Date practiceFreeApplyExpireDate = DateUtil.stringToDate(practiceFreeApplyExpireDateConfig.getParanValue());
|
|
|
|
|
|
Date now = new Date();
|
|
|
@@ -1637,9 +1639,9 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
calendar.add(Calendar.DATE, -1);
|
|
|
calendar.set(Calendar.SECOND, 0);
|
|
|
calendar.set(Calendar.MILLISECOND, 0);
|
|
|
- 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);
|
|
|
+ SysConfig practiceApplyStartTimeConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_APPLY_START_TIME);
|
|
|
+ SysConfig practiceApplyEndTimeConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_APPLY_END_TIME);
|
|
|
+ SysConfig practiceApplyIntervalTimeConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_APPLY_INTERVAL_TIME);
|
|
|
String enableStartTimeStr = practiceApplyStartTimeConfig.getParanValue();
|
|
|
String enableEndTimeStr = practiceApplyEndTimeConfig.getParanValue();
|
|
|
Integer practiceApplyIntervalMinutes = practiceApplyIntervalTimeConfig.getParanValue(Integer.class);
|
|
|
@@ -1670,9 +1672,9 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
calendar.add(Calendar.DATE, -1);
|
|
|
calendar.set(Calendar.SECOND, 0);
|
|
|
calendar.set(Calendar.MILLISECOND, 0);
|
|
|
- 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);
|
|
|
+ SysConfig practiceApplyStartTimeConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_APPLY_START_TIME);
|
|
|
+ SysConfig practiceApplyEndTimeConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_APPLY_END_TIME);
|
|
|
+ SysConfig practiceApplyIntervalTimeConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_APPLY_INTERVAL_TIME);
|
|
|
String enableStartTimeStr = practiceApplyStartTimeConfig.getParanValue();
|
|
|
String enableEndTimeStr = practiceApplyEndTimeConfig.getParanValue();
|
|
|
Integer practiceApplyIntervalMinutes = practiceApplyIntervalTimeConfig.getParanValue(Integer.class);
|
|
|
@@ -1713,7 +1715,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
throw new BizException("请选择老师");
|
|
|
}
|
|
|
Map result = new HashMap();
|
|
|
- SysConfig practiceSubjectIdListConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_SUBJECT_ID_LIST);
|
|
|
+ SysConfig practiceSubjectIdListConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_SUBJECT_ID_LIST);
|
|
|
if (Objects.isNull(practiceGroup.getSubjectId())
|
|
|
|| !Arrays.asList(practiceSubjectIdListConfig.getParanValue().split(",")).contains(practiceGroup.getSubjectId().toString())) {
|
|
|
result.put("status", "DISABLE_SUBJECT");
|
|
|
@@ -1721,11 +1723,11 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
return result;
|
|
|
}
|
|
|
Integer practiceCourseMinutes = 25;
|
|
|
- SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
if (Objects.nonNull(practiceCourseMinutesConfig)) {
|
|
|
practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
}
|
|
|
- SysConfig practiceCourseSalaryConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_SALARY);
|
|
|
+ SysConfig practiceCourseSalaryConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_SALARY);
|
|
|
Date now = new Date();
|
|
|
if (practiceGroup.getFirstCourseTime().after(practiceGroup.getSecondCourseTime())) {
|
|
|
Date tmp = practiceGroup.getSecondCourseTime();
|
|
|
@@ -2339,15 +2341,15 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
@Override
|
|
|
public Map getPayPracticeApplyParams(Integer userId, Integer organId) {
|
|
|
Map result = new HashMap();
|
|
|
- SysConfig practiceSubjectIdListConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_SUBJECT_ID_LIST);
|
|
|
- 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);
|
|
|
- SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
- SysConfig practicePayMaxMonthConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_PAY_MAX_MONTH);
|
|
|
- SysConfig practicePayDrillTimesOnOneWeekConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_PAY_DRILL_TIMES_ON_ONE_WEEK);
|
|
|
- SysConfig practicePromotionActivityStartDateConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_PROMOTION_ACTIVITY_START_DATE);
|
|
|
- SysConfig practiceBuyActivityExpireDateConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_BUY_ACTIVITY_EXPIRE_DATE);
|
|
|
+ SysConfig practiceSubjectIdListConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_SUBJECT_ID_LIST);
|
|
|
+ SysConfig practiceApplyStartTimeConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_APPLY_START_TIME);
|
|
|
+ SysConfig practiceApplyEndTimeConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_APPLY_END_TIME);
|
|
|
+ SysConfig practiceApplyIntervalTimeConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_APPLY_INTERVAL_TIME);
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ SysConfig practicePayMaxMonthConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_PAY_MAX_MONTH);
|
|
|
+ SysConfig practicePayDrillTimesOnOneWeekConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_PAY_DRILL_TIMES_ON_ONE_WEEK);
|
|
|
+ SysConfig practicePromotionActivityStartDateConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_PROMOTION_ACTIVITY_START_DATE);
|
|
|
+ SysConfig practiceBuyActivityExpireDateConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_BUY_ACTIVITY_EXPIRE_DATE);
|
|
|
SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
|
|
|
Student student = studentDao.get(userId);
|
|
|
List<Subject> subjects = subjectDao.findBySubjectByIdList(practiceSubjectIdListConfig.getParanValue());
|
|
|
@@ -2393,7 +2395,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
// }
|
|
|
|
|
|
Integer practiceCourseMinutes = 25;
|
|
|
- SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
if (Objects.nonNull(practiceCourseMinutesConfig)) {
|
|
|
practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
}
|
|
|
@@ -2480,7 +2482,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
@Override
|
|
|
public Map<Integer, List<String>> getEnableApplyDatesWithWeek() {
|
|
|
Map<Integer, List<String>> result = new HashMap<>();
|
|
|
- SysConfig practiceApplyIntervalTimeConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_APPLY_INTERVAL_TIME);
|
|
|
+ SysConfig practiceApplyIntervalTimeConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_APPLY_INTERVAL_TIME);
|
|
|
Integer practiceApplyIntervalMinutes = practiceApplyIntervalTimeConfig.getParanValue(Integer.class);
|
|
|
LocalTime dayStartTime = LocalTime.parse("00:00:00", DateUtil.timeFormatter);
|
|
|
LocalTime dayEndTime = LocalTime.parse("00:00:00", DateUtil.timeFormatter);
|
|
|
@@ -2524,11 +2526,11 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
Map result = new HashMap();
|
|
|
Set<Integer> disableApplyWeekDay = new HashSet<>();
|
|
|
|
|
|
- SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
Integer practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
|
|
|
boolean checkTeacherLeaveDate = true;
|
|
|
- SysConfig allTeacherLeaveDataConfig = sysConfigService.findByParamName(SysConfigService.TEACHER_LEAVE_DATA);
|
|
|
+ SysConfig allTeacherLeaveDataConfig = sysConfigDao.findByParamName(SysConfigService.TEACHER_LEAVE_DATA);
|
|
|
JSONObject allTeacherLeaveData = JSONObject.parseObject(allTeacherLeaveDataConfig.getParanValue());
|
|
|
if (Objects.isNull(allTeacherLeaveData)) {
|
|
|
checkTeacherLeaveDate = false;
|
|
|
@@ -2843,12 +2845,12 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
throw new BizException("老师不存在");
|
|
|
}
|
|
|
|
|
|
- SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
Integer practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
- SysConfig practiceCourseSalaryConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_SALARY);
|
|
|
- SysConfig practiceBuyActivityExpireDateConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_BUY_ACTIVITY_EXPIRE_DATE);
|
|
|
+ SysConfig practiceCourseSalaryConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_SALARY);
|
|
|
+ SysConfig practiceBuyActivityExpireDateConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_BUY_ACTIVITY_EXPIRE_DATE);
|
|
|
Date practiceBuyActivityExpireDate = DateUtil.stringToDate(practiceBuyActivityExpireDateConfig.getParanValue(), "yyyy-MM-dd HH:mm:ss");
|
|
|
- SysConfig practicePromotionActivityStartDateConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_PROMOTION_ACTIVITY_START_DATE);
|
|
|
+ SysConfig practicePromotionActivityStartDateConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_PROMOTION_ACTIVITY_START_DATE);
|
|
|
Date practicePromotionActivityStartDate = DateUtil.stringToDate(practicePromotionActivityStartDateConfig.getParanValue(), "yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
Date now = new Date();
|
|
|
@@ -3281,9 +3283,9 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
throw new BizException("老师不存在");
|
|
|
}
|
|
|
|
|
|
- SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
Integer practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
- SysConfig practiceCourseSalaryConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_SALARY);
|
|
|
+ SysConfig practiceCourseSalaryConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_SALARY);
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
@@ -3893,7 +3895,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
throw new BizException("错误的课酬结算标准!");
|
|
|
}
|
|
|
}else {
|
|
|
- SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
Integer practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
TeacherDefaultPracticeGroupSalary teacherDefaultPracticeGroupSalary = teacherDefaultPracticeGroupSalaryDao.findByTeacherAndCourseMinutes(practiceGroup.getUserId(),practiceCourseMinutes);
|
|
|
|
|
|
@@ -3964,7 +3966,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
if (studentPaymentOrder.getStatus().equals(DealStatusEnum.SUCCESS)) {
|
|
|
Date now = new Date();
|
|
|
Student student = studentDao.get(order.getUserId());
|
|
|
- Integer activityId = order.getActivityId();
|
|
|
+ Integer activityId = Integer.parseInt(order.getActivityId());
|
|
|
VipGroupActivity activity = vipGroupActivityDao.get(activityId);
|
|
|
ActivityUserMapper activityUserMapper = new ActivityUserMapper();
|
|
|
activityUserMapper.setActivityId(activityId);
|
|
|
@@ -4148,6 +4150,113 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
+ public void doubleEleven2021OrderCallback(StudentPaymentOrder studentPaymentOrder) {
|
|
|
+ Integer userId = studentPaymentOrder.getUserId();
|
|
|
+ StudentPaymentOrder order = studentPaymentOrderDao.lockOrder(studentPaymentOrder.getId());
|
|
|
+ if(!order.getStatus().equals(DealStatusEnum.ING)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //更新订单状态
|
|
|
+ int updateCount = studentPaymentOrderService.update(studentPaymentOrder);
|
|
|
+ if (updateCount <= 0) {
|
|
|
+ throw new BizException("订单更新失败");
|
|
|
+ }
|
|
|
+ if (studentPaymentOrder.getStatus().equals(DealStatusEnum.SUCCESS)) {
|
|
|
+ Date now = new Date();
|
|
|
+ Student student = studentDao.get(order.getUserId());
|
|
|
+ Integer activityId = order.getActivityId();
|
|
|
+
|
|
|
+ ActivityUserMapper activityUserMapper = new ActivityUserMapper();
|
|
|
+ activityUserMapper.setActivityId(activityId);
|
|
|
+ activityUserMapper.setUserId(order.getUserId());
|
|
|
+ activityUserMapper.setPaymentOrderId(order.getId());
|
|
|
+ activityUserMapper.setTeacherId(student.getTeacherId());
|
|
|
+ activityUserMapper.setVipFlag(1);
|
|
|
+ activityUserMapperService.insert(activityUserMapper);
|
|
|
+ //是否指定满足赠送会员的条件
|
|
|
+ //是否赠送过会员
|
|
|
+ String memberKey = "2021_double_eleven" + order.getUserId();
|
|
|
+ Boolean aBoolean = redisTemplate.hasKey(memberKey);
|
|
|
+ if(!aBoolean){
|
|
|
+ String startTimeStr = sysConfigDao.findConfigValue("2021_double_eleven_start_time");
|
|
|
+ Date startTime = DateUtil.stringToDate(startTimeStr);
|
|
|
+ String endTimeStr = sysConfigDao.findConfigValue("2021_double_eleven_end_time");
|
|
|
+ Date endTime = DateUtil.stringToDate(endTimeStr);
|
|
|
+ if (order.getCreateTime().compareTo(startTime) >= 0 && order.getCreateTime().compareTo(endTime) <= 0 ) {
|
|
|
+ //赠送会员
|
|
|
+ CloudTeacherOrder cloudTeacherOrder = new CloudTeacherOrder();
|
|
|
+ Date addDate = now;
|
|
|
+ if (student.getMemberRankSettingId() == null || now.after(student.getMembershipEndTime())) {
|
|
|
+ cloudTeacherOrder.setStartTime(now);
|
|
|
+ } else {
|
|
|
+ addDate = student.getMembershipEndTime();
|
|
|
+ cloudTeacherOrder.setStartTime(DateUtil.addDays(addDate, 1));
|
|
|
+ }
|
|
|
+ cloudTeacherOrder.setEndTime(DateUtil.addMonths(addDate, 1));
|
|
|
+ cloudTeacherOrder.setRemark("双十一活动赠送会员");
|
|
|
+ cloudTeacherOrder.setStatus(2);
|
|
|
+ cloudTeacherOrder.setOrderId(order.getId());
|
|
|
+ cloudTeacherOrder.setType(2);
|
|
|
+ cloudTeacherOrder.setAmount(BigDecimal.ZERO);
|
|
|
+ cloudTeacherOrder.setLevel(1);
|
|
|
+ cloudTeacherOrder.setStudentId(userId);
|
|
|
+ cloudTeacherOrder.setOrganId(order.getOrganId());
|
|
|
+ cloudTeacherOrder.setTime(1);
|
|
|
+ cloudTeacherOrderDao.insert(cloudTeacherOrder);
|
|
|
+ studentService.updateMemberRank(cloudTeacherOrder,PeriodEnum.MONTH);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(userId);
|
|
|
+ //插入缴费明细
|
|
|
+ //收入
|
|
|
+ SysUserCashAccountDetail sysUserIncomeCashAccountDetail = new SysUserCashAccountDetail();
|
|
|
+ sysUserIncomeCashAccountDetail.setUserId(order.getUserId());
|
|
|
+ sysUserIncomeCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.RECHARGE);
|
|
|
+ sysUserIncomeCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
|
|
|
+ sysUserIncomeCashAccountDetail.setAmount(order.getActualAmount());
|
|
|
+ sysUserIncomeCashAccountDetail.setBalance(sysUserCashAccount.getBalance().add(order.getActualAmount()));
|
|
|
+ sysUserIncomeCashAccountDetail.setAttribute(order.getTransNo());
|
|
|
+ sysUserIncomeCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
|
|
|
+ sysUserIncomeCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount());
|
|
|
+ sysUserIncomeCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount());
|
|
|
+ //支出
|
|
|
+ SysUserCashAccountDetail sysUserExpendCashAccountDetail = new SysUserCashAccountDetail();
|
|
|
+ sysUserExpendCashAccountDetail.setUserId(order.getUserId());
|
|
|
+ sysUserExpendCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.PAY_FEE);
|
|
|
+ sysUserExpendCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
|
|
|
+ sysUserExpendCashAccountDetail.setAmount(order.getActualAmount().negate());
|
|
|
+ sysUserExpendCashAccountDetail.setBalance(sysUserCashAccount.getBalance());
|
|
|
+ sysUserExpendCashAccountDetail.setAttribute(order.getTransNo());
|
|
|
+ sysUserExpendCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
|
|
|
+
|
|
|
+ if (studentPaymentOrder.getComAmount() != null) {
|
|
|
+ sysUserIncomeCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
|
|
|
+ }
|
|
|
+ if (studentPaymentOrder.getPerAmount() != null) {
|
|
|
+ sysUserExpendCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
|
|
|
+ }
|
|
|
+
|
|
|
+ sysUserCashAccountDetailService.insert(sysUserIncomeCashAccountDetail);
|
|
|
+ sysUserCashAccountDetailService.insert(sysUserExpendCashAccountDetail);
|
|
|
+
|
|
|
+// try {
|
|
|
+// contractService.transferPracticeCoursesContract(order.getUserId(), classGroup.getTotalClassTimes(), practiceGroup.getCoursesStartDate(), practiceGroup.getCoursesExpireDate(), order.getExpectAmount());
|
|
|
+// } catch (Exception e) {
|
|
|
+// LOGGER.error(MessageFormatter.arrayFormat("网管课[{}]购买协议错误:{}", order.getMusicGroupId(), e.getMessage()), e);
|
|
|
+// }
|
|
|
+ studentDao.updateStudentServiceTag(userId, null, YesOrNoEnum.YES.getCode());
|
|
|
+ }
|
|
|
+ if (studentPaymentOrder.getStatus().equals(DealStatusEnum.FAILED)) {
|
|
|
+ if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "报名缴费失败");
|
|
|
+ }
|
|
|
+ sysCouponCodeService.quit(studentPaymentOrder.getCouponCodeId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public List<PracticeCourseDto> findUserHistoryBuyPracticeGroups(Integer userId, Long groupId, PracticeGroupType type) {
|
|
|
List<PracticeCourseDto> userPracticeGroups;
|
|
|
if (Objects.nonNull(groupId)) {
|
|
|
@@ -4164,7 +4273,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
if (CollectionUtils.isEmpty(userPracticeGroups)) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
- SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
Integer practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
for (PracticeCourseDto userPracticeGroup : userPracticeGroups) {
|
|
|
JSONArray coursesArry = new JSONArray();
|
|
|
@@ -4221,7 +4330,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
if (order.getStatus().equals(DealStatusEnum.FAILED) || order.getGroupType().equals(GroupType.REPAIR)||Objects.isNull(order.getMusicGroupId())) {
|
|
|
return practiceBuyResult;
|
|
|
}
|
|
|
- SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
Integer practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
PracticeGroup practiceGroup = practiceGroupDao.get(Long.valueOf(order.getMusicGroupId()));
|
|
|
if(Objects.nonNull(practiceGroup.getType())&&(PracticeGroupType.CARE_PACKAGE.equals(practiceGroup.getType())||PracticeGroupType.COME_ON_PACKAGE.equals(practiceGroup.getType()))){
|
|
|
@@ -4611,7 +4720,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
if(Objects.isNull(teacherId)){
|
|
|
throw new BizException("请指定教师");
|
|
|
}
|
|
|
- SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
Integer practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
TeacherDefaultPracticeGroupSalary teacherDefaultPracticeGroupSalary = teacherDefaultPracticeGroupSalaryDao.findByTeacherAndCourseMinutes(teacherId,practiceCourseMinutes);
|
|
|
|
|
|
@@ -5049,7 +5158,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
userRoleMap.put(applyBaseInfo.getEducationalTeacherId(),"乐团主管");
|
|
|
}
|
|
|
userRoleMap.put(applyBaseInfo.getUserId(),"指导老师");
|
|
|
- SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigDao.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
Integer practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
TeacherDefaultPracticeGroupSalary teacherDefaultPracticeGroupSalary = teacherDefaultPracticeGroupSalaryDao.findByTeacherAndCourseMinutes(applyBaseInfo.getUserId(),practiceCourseMinutes);
|
|
|
|
|
|
@@ -5170,7 +5279,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
studentPaymentOrder.setClassGroupId(classGroup.getId());
|
|
|
studentPaymentOrder.setOrganId(practiceGroup.getOrganId());
|
|
|
studentPaymentOrder.setVersion(0);
|
|
|
- studentPaymentOrder.setActivityId(practiceGroup.getVipGroupActivityId());
|
|
|
+ studentPaymentOrder.setActivityId(practiceGroup.getVipGroupActivityId().toString());
|
|
|
studentPaymentOrder.setActivityBuyNum(practiceGroup.getAllCourseNum());
|
|
|
studentPaymentOrderDao.insert(studentPaymentOrder);
|
|
|
|
|
|
@@ -5375,7 +5484,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
studentPaymentOrder.setRoutingOrganId(practiceGroupBuyParams.getOrganId());
|
|
|
studentPaymentOrder.setCreateTime(nowDate);
|
|
|
studentPaymentOrder.setUpdateTime(nowDate);
|
|
|
- studentPaymentOrder.setActivityId(activityId);
|
|
|
+ studentPaymentOrder.setActivityId(activityId.toString());
|
|
|
studentPaymentOrder.setActivityBuyNum(buyNum);
|
|
|
studentPaymentOrderService.insert(studentPaymentOrder);
|
|
|
|
|
|
@@ -5443,4 +5552,138 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
vipGroupPayInfo.setBalance(sysUserCashAccount.getBalance());
|
|
|
return vipGroupPayInfo;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED)
|
|
|
+ public Object buyDoubleEleven2021(BuyDoubleEleven2021Dto buyDoubleEleven2021Dto) throws Exception {
|
|
|
+ String activityIdList = buyDoubleEleven2021Dto.getActivityIdList();
|
|
|
+ List<VipGroupActivity> vipGroupActivities = vipGroupActivityDao.queryByIds(activityIdList);
|
|
|
+ Date now = new Date();
|
|
|
+ Student student = studentDao.getLocked(buyDoubleEleven2021Dto.getUserId());
|
|
|
+ BigDecimal activityFee = ZERO;
|
|
|
+ for (int i = 0; i < vipGroupActivities.size(); i++) {
|
|
|
+ VipGroupActivity activity = vipGroupActivities.get(i);
|
|
|
+ Date startTime = activity.getStartTime();
|
|
|
+ Date endTime = activity.getEndTime();
|
|
|
+ if(startTime != null && startTime.compareTo(now) > 0){
|
|
|
+ throw new BizException("活动尚未开始,感谢您的关注");
|
|
|
+ }
|
|
|
+ if(endTime != null && endTime.compareTo(now) <= 0){
|
|
|
+ throw new BizException("活动已结束,感谢您的参与");
|
|
|
+ }
|
|
|
+ Integer studentMaxUsedTimes = activity.getStudentMaxUsedTimes();
|
|
|
+ if(studentMaxUsedTimes != -1){
|
|
|
+ //获取活动购买次数
|
|
|
+ int activityBuyNum = activityUserMapperService.countActivityBuyNum(activity.getId(), buyDoubleEleven2021Dto.getUserId());
|
|
|
+ if(activityBuyNum >= studentMaxUsedTimes){
|
|
|
+ throw new BizException("{}活动最多课购买{}次,感谢您的参与",activity.getName(),studentMaxUsedTimes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ activityFee = activityFee.add(activity.getMarketPrice());
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断用户是否已存在订单
|
|
|
+ // 判断是否存在支付中的记录
|
|
|
+ List<StudentPaymentOrder> list = studentPaymentOrderService.queryByCondition(GroupType.VIP,null,student.getUserId(),DealStatusEnum.ING,OrderTypeEnum.DOUBLE_ELEVEN2021);
|
|
|
+ if (list.size() > 0) {
|
|
|
+ StudentPaymentOrder order = list.get(0);
|
|
|
+ // 查询订单状态
|
|
|
+ PayStatus payStatus = studentPaymentOrderService.queryPayStatus(order.getPaymentChannel(), order.getOrderNo(), order.getTransNo());
|
|
|
+ if(payStatus == PayStatus.SUCCESSED){
|
|
|
+ throw new BizException("订单已支付成功,请勿重复支付");
|
|
|
+ }else if(payStatus == PayStatus.PAYING){
|
|
|
+ throw new BizException("订单还在交易中,请稍后重试");
|
|
|
+ }
|
|
|
+ if(buyDoubleEleven2021Dto.isRepeatPay()){
|
|
|
+ //处理关闭订单
|
|
|
+ order.setStatus(DealStatusEnum.CLOSE);
|
|
|
+ order.setMemo("关闭2021双十一活动订单");
|
|
|
+ if (order.getBalancePaymentAmount() != null && order.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ sysUserCashAccountService.updateBalance(order.getUserId(), order.getBalancePaymentAmount(),
|
|
|
+ PlatformCashAccountDetailTypeEnum.REFUNDS, "2021双十一活动支付失败");
|
|
|
+ }
|
|
|
+ studentPaymentOrderService.update(order);
|
|
|
+ sysCouponCodeService.quit(order.getCouponCodeId());
|
|
|
+ }else {
|
|
|
+ return BaseController.failed(HttpStatus.CONTINUE,"您有待支付的订单");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //计算订单金额
|
|
|
+ StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(buyDoubleEleven2021Dto.getCouponIdList(), activityFee, true);
|
|
|
+ activityFee = studentPaymentOrder.getActualAmount();
|
|
|
+ if(buyDoubleEleven2021Dto.getAmount().compareTo(activityFee) != 0){
|
|
|
+ throw new BizException("非法访问");
|
|
|
+ }
|
|
|
+
|
|
|
+ String channelType = "";
|
|
|
+ Date nowDate = new Date();
|
|
|
+
|
|
|
+ BigDecimal balance = BigDecimal.ZERO;
|
|
|
+ if (buyDoubleEleven2021Dto.isUseBalancePayment() && activityFee.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(student.getUserId());
|
|
|
+ if (userCashAccount == null) {
|
|
|
+ throw new BizException("用户账户找不到");
|
|
|
+ }
|
|
|
+ if (userCashAccount.getBalance() != null && userCashAccount.getBalance().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ balance = activityFee.compareTo(userCashAccount.getBalance()) >= 0 ? userCashAccount.getBalance() : activityFee;
|
|
|
+ activityFee = activityFee.subtract(balance);
|
|
|
+ studentPaymentOrder.setActualAmount(activityFee);
|
|
|
+ studentPaymentOrder.setBalancePaymentAmount(balance);
|
|
|
+ sysUserCashAccountService.updateBalance(student.getUserId(), balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "2021双十一活动购买");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String orderNo = idGeneratorService.generatorId("payment") + "";
|
|
|
+
|
|
|
+ studentPaymentOrder.setPaymentChannel("BALANCE");
|
|
|
+ studentPaymentOrder.setUserId(student.getUserId());
|
|
|
+ studentPaymentOrder.setGroupType(GroupType.VIP);
|
|
|
+ studentPaymentOrder.setOrderNo(orderNo);
|
|
|
+ studentPaymentOrder.setType(OrderTypeEnum.DOUBLE_ELEVEN2021);
|
|
|
+ studentPaymentOrder.setStatus(DealStatusEnum.ING);
|
|
|
+ studentPaymentOrder.setRemitFee(BigDecimal.ZERO);
|
|
|
+ studentPaymentOrder.setCourseRemitFee(BigDecimal.ZERO);
|
|
|
+ studentPaymentOrder.setOrganId(buyDoubleEleven2021Dto.getOrganId());
|
|
|
+ studentPaymentOrder.setRoutingOrganId(buyDoubleEleven2021Dto.getOrganId());
|
|
|
+ studentPaymentOrder.setActivityId(activityIdList);
|
|
|
+ studentPaymentOrder.setCreateTime(nowDate);
|
|
|
+ studentPaymentOrder.setUpdateTime(nowDate);
|
|
|
+ studentPaymentOrderService.insert(studentPaymentOrder);
|
|
|
+
|
|
|
+ studentPaymentOrder.setVersion(0);
|
|
|
+ if (activityFee.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ studentPaymentRouteOrderService.addRouteOrder(orderNo, buyDoubleEleven2021Dto.getOrganId(), balance);
|
|
|
+ Map<String, String> notifyMap = new HashMap<>();
|
|
|
+ notifyMap.put("tradeState", "1");
|
|
|
+ notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
|
|
|
+ notifyMap.put("channelType", channelType);
|
|
|
+ notifyMap.put("orderNo", "");
|
|
|
+ studentPaymentOrderService.updateOrder(notifyMap);
|
|
|
+ return notifyMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ String orderSubject = "2021双十一活动";
|
|
|
+ String receiver = "vip";
|
|
|
+
|
|
|
+ String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
|
|
|
+
|
|
|
+ Map payMap = payService.getPayMap(
|
|
|
+ activityFee,
|
|
|
+ balance,
|
|
|
+ orderNo,
|
|
|
+ baseApiUrl + "/api-student/studentOrder/notify",
|
|
|
+ baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
|
|
|
+ orderSubject,
|
|
|
+ orderSubject,
|
|
|
+ studentPaymentOrder.getOrganId(),
|
|
|
+ receiver
|
|
|
+ );
|
|
|
+
|
|
|
+ studentPaymentOrder.setOrganId(studentPaymentOrder.getOrganId());
|
|
|
+ studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
|
|
|
+ studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
|
|
|
+ studentPaymentOrder.setUpdateTime(nowDate);
|
|
|
+ studentPaymentOrderService.update(studentPaymentOrder);
|
|
|
+ return payMap;
|
|
|
+ }
|
|
|
}
|