|
@@ -27,6 +27,7 @@ import com.ym.mec.util.string.MessageFormatter;
|
|
|
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;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -183,6 +184,7 @@ public class EduPracticeGroupServiceImpl implements EduPracticeGroupService{
|
|
|
SysConfig practiceCourseMinutesConfig = sysConfigService.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);
|
|
|
Date practiceBuyActivityExpireDate= DateUtil.stringToDate(practiceBuyActivityExpireDateConfig.getParanValue(),"yyyy-MM-dd HH:mm:ss");
|
|
|
SysConfig practicePromotionActivityStartDateConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_PROMOTION_ACTIVITY_START_DATE);
|
|
@@ -495,6 +497,335 @@ public class EduPracticeGroupServiceImpl implements EduPracticeGroupService{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
+ public HttpResponseResult createPackagePracticeGroup(PracticeGroupBuyDto practiceGroupBuyParams, String operatorInfo) {
|
|
|
+ if (Objects.isNull(practiceGroupBuyParams.getUserId())) {
|
|
|
+ return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "请选择教师");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(practiceGroupBuyParams.getSubjectId())) {
|
|
|
+ return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "请选择声部");
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isEmpty(practiceGroupBuyParams.getDrillTimes())) {
|
|
|
+ return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "请选择训练时间");
|
|
|
+ }
|
|
|
+
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserById(practiceGroupBuyParams.getStudentId());
|
|
|
+
|
|
|
+ Student student = studentDao.get(practiceGroupBuyParams.getStudentId());
|
|
|
+ if(Objects.isNull(student)){
|
|
|
+ return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "学员信息异常");
|
|
|
+ }
|
|
|
+
|
|
|
+ int courseTimes = 0;
|
|
|
+
|
|
|
+ if(PracticeGroupType.CARE_PACKAGE.equals(practiceGroupBuyParams.getType())){
|
|
|
+ if(Objects.isNull(student.getCarePackage())||student.getCarePackage().equals(0)){
|
|
|
+ return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "该学员暂无关心包排课资格");
|
|
|
+ }else if(student.getCarePackage().equals(2)){
|
|
|
+ return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "该学员已使用关心包排课资格");
|
|
|
+ }
|
|
|
+ student.setCarePackage(2);
|
|
|
+ courseTimes = 4;
|
|
|
+ }else if(PracticeGroupType.COME_ON_PACKAGE.equals(practiceGroupBuyParams.getType())){
|
|
|
+ if(Objects.isNull(student.getComeOnPackage())||student.getComeOnPackage().equals(0)){
|
|
|
+ return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "该学员暂无加油包排课资格");
|
|
|
+ }else if(student.getComeOnPackage().equals(2)){
|
|
|
+ return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "该学员已使用加油包排课资格");
|
|
|
+ }
|
|
|
+ student.setComeOnPackage(2);
|
|
|
+ courseTimes = 8;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(courseTimes<=0){
|
|
|
+ return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "课程信息错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ Subject subject = subjectDao.get(practiceGroupBuyParams.getSubjectId());
|
|
|
+ if (Objects.isNull(subject)) {
|
|
|
+ return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "预约失败,声部选择错误,请重试。");
|
|
|
+ }
|
|
|
+
|
|
|
+ Teacher teacher = teacherService.getDetail(practiceGroupBuyParams.getUserId());
|
|
|
+ if (Objects.isNull(teacher)) {
|
|
|
+ throw new BizException("老师不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ //网管课课程时长
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ Integer practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
+ //网管课默认课酬
|
|
|
+ SysConfig practiceCourseSalaryConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_SALARY);
|
|
|
+
|
|
|
+ Date now=new Date();
|
|
|
+
|
|
|
+ LocalDate courseStartDay=LocalDate.now();
|
|
|
+
|
|
|
+ practiceGroupBuyParams.setName(subject.getName() + "•" + sysUser.getUsername());
|
|
|
+
|
|
|
+ List<CourseSchedule> practiceCourses = new ArrayList<>();
|
|
|
+
|
|
|
+ while (practiceCourses.size()<courseTimes){
|
|
|
+ courseStartDay=courseStartDay.plusDays(1);
|
|
|
+ int dayOfWeek = courseStartDay.get(DateUtil.weekFields.dayOfWeek());
|
|
|
+ for (PracticeDrillTimeDto drillTime : practiceGroupBuyParams.getDrillTimes()) {
|
|
|
+ if(practiceCourses.size()==courseTimes){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if(dayOfWeek==drillTime.getWeekNum()){
|
|
|
+ CourseSchedule courseSchedule=new CourseSchedule();
|
|
|
+ String courseStartDayStr = DateUtil.dateFormatter.format(courseStartDay);
|
|
|
+ String courseStartDateTimeStr = courseStartDayStr+" "+drillTime.getTimeStr();
|
|
|
+ LocalDateTime courseStartDateTime = LocalDateTime.parse(courseStartDateTimeStr,DateUtil.dateTimeFormatter);
|
|
|
+ LocalDateTime courseEndDateTime = courseStartDateTime.plusMinutes(practiceCourseMinutes);
|
|
|
+ courseSchedule.setStartClassTime(Date.from(courseStartDateTime.atZone(DateUtil.zoneId).toInstant()));
|
|
|
+ courseSchedule.setEndClassTime(Date.from(courseEndDateTime.atZone(DateUtil.zoneId).toInstant()));
|
|
|
+ courseSchedule.setClassDate(courseSchedule.getStartClassTime());
|
|
|
+ courseSchedule.setName(practiceGroupBuyParams.getName());
|
|
|
+ courseSchedule.setTeacherId(practiceGroupBuyParams.getUserId());
|
|
|
+ courseSchedule.setActualTeacherId(practiceGroupBuyParams.getUserId());
|
|
|
+ courseSchedule.setTeachMode(TeachModeEnum.ONLINE);
|
|
|
+ courseSchedule.setType(CourseSchedule.CourseScheduleType.PRACTICE);
|
|
|
+ courseSchedule.setStatus(CourseStatusEnum.NOT_START);
|
|
|
+ practiceCourses.add(courseSchedule);
|
|
|
+
|
|
|
+ if(practiceCourses.size()==courseTimes){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ CourseSchedule courseSchedule1=new CourseSchedule();
|
|
|
+ BeanUtils.copyProperties(courseSchedule, courseSchedule1);
|
|
|
+ courseSchedule1.setStartClassTime(courseSchedule.getEndClassTime());
|
|
|
+ courseSchedule1.setEndClassTime(Date.from(courseEndDateTime.plusMinutes(practiceCourseMinutes).atZone(DateUtil.zoneId).toInstant()));
|
|
|
+ courseSchedule1.setClassDate(courseSchedule1.getStartClassTime());
|
|
|
+ practiceCourses.add(courseSchedule1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CollectionUtils.isEmpty(practiceCourses)){
|
|
|
+ return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "课程信息错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ practiceCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
|
|
|
+
|
|
|
+ TeacherFreeTime teacherFreeTime = teacherFreeTimeDao.findTeacherFreeTime(practiceGroupBuyParams.getUserId());
|
|
|
+ if (Objects.isNull(teacherFreeTime)) {
|
|
|
+ return BaseController.failed(HttpStatus.MULTIPLE_CHOICES,"抱歉啦,当前所选时段组合,「" + teacher.getRealName() + "」老师已被预约,请重新选择时段或更换老师后重试。");
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject drillTimesObject=new JSONObject();
|
|
|
+ for (PracticeDrillTimeDto drillTime : practiceGroupBuyParams.getDrillTimes()) {
|
|
|
+ drillTimesObject.put(String.valueOf(drillTime.getWeekNum()),drillTime.getTimeStr());
|
|
|
+ }
|
|
|
+
|
|
|
+ PracticeGroupSellPrice practiceGroupSellPrice = practiceGroupSellPriceDao.get(sysUser.getOrganId());
|
|
|
+ if(Objects.isNull(practiceGroupSellPrice)){
|
|
|
+ throw new BizException("所在城市暂不参与此活动");
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal price = PracticeGroupType.CARE_PACKAGE.equals(practiceGroupBuyParams.getType())?practiceGroupSellPrice.getCarePackagePrice():practiceGroupSellPrice.getComeOnPackagePrice();
|
|
|
+ if(Objects.isNull(price)&&PracticeGroupType.COME_ON_PACKAGE.equals(practiceGroupBuyParams.getType())){
|
|
|
+ throw new BizException("请设置加油包价格");
|
|
|
+ }
|
|
|
+
|
|
|
+ practiceGroupBuyParams.setCoursesStartDate(practiceCourses.stream().min(Comparator.comparing(CourseSchedule::getStartClassTime)).get().getStartClassTime());
|
|
|
+ practiceGroupBuyParams.setCoursesExpireDate(practiceCourses.stream().max(Comparator.comparing(CourseSchedule::getEndClassTime)).get().getEndClassTime());
|
|
|
+ practiceGroupBuyParams.setDrillTimesJson(drillTimesObject.toJSONString());
|
|
|
+ practiceGroupBuyParams.setOrganId(sysUser.getOrganId());
|
|
|
+ practiceGroupBuyParams.setSingleClassMinutes(practiceCourseMinutes);
|
|
|
+ practiceGroupBuyParams.setGroupStatus(GroupStatusEnum.LOCK);
|
|
|
+ practiceGroupBuyParams.setMemo(operatorInfo+",教务代买");
|
|
|
+ practiceGroupDao.insert(practiceGroupBuyParams);
|
|
|
+
|
|
|
+ //创建班级信息
|
|
|
+ ClassGroup classGroup = new ClassGroup();
|
|
|
+ classGroup.setSubjectIdList(practiceGroupBuyParams.getSubjectId().toString());
|
|
|
+ classGroup.setExpectStudentNum(1);
|
|
|
+ classGroup.setStudentNum(1);
|
|
|
+ classGroup.setName(practiceGroupBuyParams.getName());
|
|
|
+ classGroup.setTotalClassTimes(practiceCourses.size());
|
|
|
+ classGroup.setType(ClassGroupTypeEnum.PRACTICE);
|
|
|
+ classGroup.setDelFlag(0);
|
|
|
+ classGroup.setGroupType(GroupType.PRACTICE);
|
|
|
+ classGroup.setMusicGroupId(practiceGroupBuyParams.getId().toString());
|
|
|
+ classGroup.setCreateTime(now);
|
|
|
+ classGroup.setUpdateTime(now);
|
|
|
+ classGroupDao.insert(classGroup);
|
|
|
+
|
|
|
+ //创建班级老师关联记录
|
|
|
+ ClassGroupTeacherMapper classGroupTeacherMapper = new ClassGroupTeacherMapper();
|
|
|
+ classGroupTeacherMapper.setMusicGroupId(practiceGroupBuyParams.getId().toString());
|
|
|
+ classGroupTeacherMapper.setClassGroupId(classGroup.getId());
|
|
|
+ classGroupTeacherMapper.setTeacherRole(TeachTypeEnum.BISHOP);
|
|
|
+ classGroupTeacherMapper.setUserId(practiceGroupBuyParams.getUserId());
|
|
|
+ classGroupTeacherMapper.setGroupType(GroupType.PRACTICE);
|
|
|
+ classGroupTeacherMapper.setCreateTime(now);
|
|
|
+ classGroupTeacherMapper.setUpdateTime(now);
|
|
|
+ classGroupTeacherMapperDao.insert(classGroupTeacherMapper);
|
|
|
+
|
|
|
+ //创建班级与老师课酬记录
|
|
|
+ ClassGroupTeacherSalary classGroupTeacherSalary = new ClassGroupTeacherSalary();
|
|
|
+ classGroupTeacherSalary.setMusicGroupId(practiceGroupBuyParams.getId().toString());
|
|
|
+ classGroupTeacherSalary.setClassGroupId(classGroup.getId());
|
|
|
+ classGroupTeacherSalary.setTeacherRole(TeachTypeEnum.BISHOP);
|
|
|
+ classGroupTeacherSalary.setUserId(practiceGroupBuyParams.getUserId());
|
|
|
+ classGroupTeacherSalary.setSalary(new BigDecimal(practiceCourseSalaryConfig.getParanValue()));
|
|
|
+ classGroupTeacherSalary.setOnlineClassesSalary(new BigDecimal(practiceCourseSalaryConfig.getParanValue()));
|
|
|
+ classGroupTeacherSalary.setGroupType(GroupType.PRACTICE);
|
|
|
+ classGroupTeacherSalary.setCreateTime(now);
|
|
|
+ classGroupTeacherSalary.setUpdateTime(now);
|
|
|
+ classGroupTeacherSalaryDao.insert(classGroupTeacherSalary);
|
|
|
+
|
|
|
+ //班级学生关联表
|
|
|
+ ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
|
+ classGroupStudentMapper.setMusicGroupId(practiceGroupBuyParams.getId().toString());
|
|
|
+ classGroupStudentMapper.setClassGroupId(classGroup.getId());
|
|
|
+ classGroupStudentMapper.setUserId(practiceGroupBuyParams.getStudentId());
|
|
|
+ classGroupStudentMapper.setCreateTime(now);
|
|
|
+ classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
|
+ classGroupStudentMapper.setGroupType(GroupType.PRACTICE);
|
|
|
+ classGroupStudentMapperDao.insert(classGroupStudentMapper);
|
|
|
+
|
|
|
+ List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaries = new ArrayList<>();
|
|
|
+ List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
|
|
|
+ List<TeacherAttendance> teacherAttendances = new ArrayList<>();
|
|
|
+
|
|
|
+ for (CourseSchedule courseSchedule : practiceCourses) {
|
|
|
+ //课表
|
|
|
+ courseSchedule.setMusicGroupId(practiceGroupBuyParams.getId().toString());
|
|
|
+ courseSchedule.setClassGroupId(classGroup.getId());
|
|
|
+ courseSchedule.setStatus(CourseStatusEnum.NOT_START);
|
|
|
+ courseSchedule.setCreateTime(now);
|
|
|
+ courseSchedule.setUpdateTime(now);
|
|
|
+ courseSchedule.setTeachMode(TeachModeEnum.ONLINE);
|
|
|
+ courseSchedule.setType(CourseSchedule.CourseScheduleType.PRACTICE);
|
|
|
+ courseSchedule.setGroupType(GroupType.PRACTICE);
|
|
|
+ courseSchedule.setIsLock(1);
|
|
|
+ courseSchedule.setOrganId(practiceGroupBuyParams.getOrganId());
|
|
|
+ }
|
|
|
+ courseScheduleDao.batchAddCourseSchedules(practiceCourses);
|
|
|
+ TeacherDefaultPracticeGroupSalary teacherDefaultPracticeGroupSalary = teacherDefaultPracticeGroupSalaryDao.findByTeacherAndCourseMinutes(practiceGroupBuyParams.getUserId(),practiceCourseMinutes);
|
|
|
+ BigDecimal teacherDefaultSalary=null;
|
|
|
+ if(Objects.nonNull(teacherDefaultPracticeGroupSalary)){
|
|
|
+ teacherDefaultSalary=teacherDefaultPracticeGroupSalary.getMainTeacherSalary();
|
|
|
+ }
|
|
|
+ if(teacherDefaultSalary == null){
|
|
|
+ throw new BizException("请设置老师课酬");
|
|
|
+ }
|
|
|
+ BigDecimal studentSingleCourseCost=price.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
+ BigDecimal studentSingleCourseOriginalCost=price.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
+ for (CourseSchedule courseSchedule : practiceCourses) {
|
|
|
+ //课程与老师薪水表
|
|
|
+ CourseScheduleTeacherSalary courseScheduleTeacherSalary = new CourseScheduleTeacherSalary();
|
|
|
+ courseScheduleTeacherSalary.setCourseScheduleId(courseSchedule.getId());
|
|
|
+ courseScheduleTeacherSalary.setGroupType(GroupType.PRACTICE);
|
|
|
+ courseScheduleTeacherSalary.setMusicGroupId(practiceGroupBuyParams.getId().toString());
|
|
|
+ courseScheduleTeacherSalary.setTeacherRole(classGroupTeacherMapper.getTeacherRole());
|
|
|
+ courseScheduleTeacherSalary.setUserId(practiceGroupBuyParams.getUserId());
|
|
|
+ courseScheduleTeacherSalary.setExpectSalary(teacherDefaultSalary);
|
|
|
+ courseScheduleTeacherSalary.setCreateTime(now);
|
|
|
+ courseScheduleTeacherSalary.setUpdateTime(now);
|
|
|
+ courseScheduleTeacherSalary.setClassGroupId(classGroup.getId());
|
|
|
+ courseScheduleTeacherSalaries.add(courseScheduleTeacherSalary);
|
|
|
+
|
|
|
+ //学生缴费记录
|
|
|
+ CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
|
|
|
+ courseScheduleStudentPayment.setGroupType(GroupType.PRACTICE);
|
|
|
+ courseScheduleStudentPayment.setMusicGroupId(practiceGroupBuyParams.getId().toString());
|
|
|
+ courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
|
|
|
+ courseScheduleStudentPayment.setUserId(practiceGroupBuyParams.getStudentId());
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(studentSingleCourseCost);
|
|
|
+ courseScheduleStudentPayment.setActualPrice(studentSingleCourseCost);
|
|
|
+ courseScheduleStudentPayment.setOriginalPrice(studentSingleCourseOriginalCost);
|
|
|
+ courseScheduleStudentPayment.setClassGroupId(classGroup.getId());
|
|
|
+ courseScheduleStudentPayment.setCreateTime(now);
|
|
|
+ courseScheduleStudentPayment.setUpdateTime(now);
|
|
|
+ courseScheduleStudentPayments.add(courseScheduleStudentPayment);
|
|
|
+
|
|
|
+ //教师签到记录
|
|
|
+ TeacherAttendance teacherAttendance = new TeacherAttendance();
|
|
|
+ teacherAttendance.setMusicGroupId(practiceGroupBuyParams.getId().toString());
|
|
|
+ teacherAttendance.setTeacherId(practiceGroupBuyParams.getUserId());
|
|
|
+ teacherAttendance.setClassGroupId(classGroup.getId());
|
|
|
+ teacherAttendance.setGroupType(GroupType.PRACTICE);
|
|
|
+ teacherAttendance.setCourseScheduleId(courseSchedule.getId());
|
|
|
+ teacherAttendance.setCreateTime(now);
|
|
|
+ teacherAttendances.add(teacherAttendance);
|
|
|
+ }
|
|
|
+ courseScheduleTeacherSalaryDao.batchInsert(courseScheduleTeacherSalaries);
|
|
|
+ courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
|
|
|
+ teacherAttendanceDao.batchInsert(teacherAttendances);
|
|
|
+ studentDao.update(student);
|
|
|
+
|
|
|
+ try {
|
|
|
+ courseScheduleService.checkNewCourseSchedules(practiceCourses,false,false);
|
|
|
+ } catch (Exception e) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ String errMessage=new String();
|
|
|
+ if(e.getMessage().indexOf("主教冲突")!=-1){
|
|
|
+ errMessage="抱歉啦,当前所选时段组合,「" + teacher.getRealName() + "」老师已被预约,请重新选择时段或更换老师后重试。";
|
|
|
+ }else{
|
|
|
+ String courseName=e.getMessage().substring(e.getMessage().indexOf(")-")+2);
|
|
|
+ courseName = courseName.substring(0,courseName.indexOf("("));
|
|
|
+ errMessage="抱歉啦,当前所选时段组合,与您现有课程「";
|
|
|
+ errMessage+=courseName;
|
|
|
+ errMessage+="」时段冲突,请选择其他时段重试。";
|
|
|
+ }
|
|
|
+ return BaseController.failed(HttpStatus.FOUND, errMessage);
|
|
|
+ }
|
|
|
+
|
|
|
+ StudentPaymentOrder studentPaymentOrder=new StudentPaymentOrder();
|
|
|
+ studentPaymentOrder.setUserId(practiceGroupBuyParams.getStudentId());
|
|
|
+ studentPaymentOrder.setGroupType(GroupType.PRACTICE);
|
|
|
+ String orderNo=idGeneratorService.generatorId("payment") + "";
|
|
|
+ studentPaymentOrder.setOrderNo(orderNo);
|
|
|
+ studentPaymentOrder.setStatus(DealStatusEnum.ING);
|
|
|
+ studentPaymentOrder.setType(OrderTypeEnum.PRACTICE_GROUP_BUY);
|
|
|
+
|
|
|
+ studentPaymentOrder.setExpectAmount(price);
|
|
|
+ studentPaymentOrder.setMusicGroupId(practiceGroupBuyParams.getId().toString());
|
|
|
+ studentPaymentOrder.setActualAmount(studentPaymentOrder.getExpectAmount());
|
|
|
+ studentPaymentOrder.setClassGroupId(classGroup.getId());
|
|
|
+ studentPaymentOrder.setMemo(operatorInfo+",教务代买");
|
|
|
+ studentPaymentOrder.setVersion(0);
|
|
|
+ studentPaymentOrderService.insert(studentPaymentOrder);
|
|
|
+
|
|
|
+ if(practiceGroupBuyParams.isUseBalancePayment() || studentPaymentOrder.getExpectAmount().doubleValue() == 0){
|
|
|
+ SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(practiceGroupBuyParams.getStudentId());
|
|
|
+ if(userCashAccount == null){
|
|
|
+ throw new BizException("用户账户找不到");
|
|
|
+ }
|
|
|
+ studentPaymentOrder.setPaymentChannel("BALANCE");
|
|
|
+ if(userCashAccount.getBalance().subtract(studentPaymentOrder.getExpectAmount()).doubleValue() >= 0){
|
|
|
+ studentPaymentRouteOrderService.addRouteOrder(orderNo, practiceGroupBuyParams.getOrganId(), studentPaymentOrder.getExpectAmount());
|
|
|
+ // 更新订单信息
|
|
|
+ studentPaymentOrder.setActualAmount(new BigDecimal(0));
|
|
|
+ studentPaymentOrder.setBalancePaymentAmount(studentPaymentOrder.getExpectAmount());
|
|
|
+ studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
|
|
|
+ studentPaymentOrder.setUpdateTime(now);
|
|
|
+ studentPaymentOrder.setOrganId(practiceGroupBuyParams.getOrganId());
|
|
|
+ studentPaymentOrder.setRoutingOrganId(practiceGroupBuyParams.getOrganId());
|
|
|
+
|
|
|
+ sysUserCashAccountService.updateBalance(practiceGroupBuyParams.getStudentId(), studentPaymentOrder.getExpectAmount().negate(),PlatformCashAccountDetailTypeEnum.PAY_FEE,operatorInfo+",教务代买");
|
|
|
+
|
|
|
+ studentPaymentOrder.setPayTime(now);
|
|
|
+ this.orderCallback(studentPaymentOrder);
|
|
|
+
|
|
|
+ Map<String,Object> result=new HashMap<>();
|
|
|
+ result.put("orderNo",studentPaymentOrder.getOrderNo());
|
|
|
+
|
|
|
+ return BaseController.succeed(result);
|
|
|
+ }else{
|
|
|
+ throw new BizException("该学员尚未缴纳加油包费用");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ throw new BizException("当前购买方式暂时只支持用户余额购买");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED)
|
|
|
public void orderCallback(StudentPaymentOrder order) {
|