|
@@ -26,9 +26,11 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
@@ -95,11 +97,11 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
- public void createCourseGroup(CourseGroupCreateDto courseGroupCreateInfo) {
|
|
|
+ public HttpResponseResult createCourseGroup(CourseGroupCreateDto courseGroupCreateInfo) {
|
|
|
CoursesGroup courseGroup = courseGroupCreateInfo.getCoursesGroup();
|
|
|
CourseGenerateDto courseCycleInfo = courseGroupCreateInfo.getCourseCycleInfo();
|
|
|
if(Objects.isNull(courseGroup.getName())|| StringUtils.isBlank(courseGroup.getName())){
|
|
|
- throw new BizException("请填写课程班名称");
|
|
|
+ throw new BizException("请填写课程名称");
|
|
|
}
|
|
|
if(Objects.isNull(courseGroup.getSubjectId())){
|
|
|
throw new BizException("请选择科目");
|
|
@@ -121,7 +123,13 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
|
|
|
|
|
|
//总课程时长
|
|
|
Integer totalCourseTime=courseCycleInfo.getCourseCount()*courseCycleInfo.getSingleClassMinutes();
|
|
|
- sysTenantAccountService.update(courseGroup.getTeacherId(), -totalCourseTime, "", SysTenantAccountDetail.TransType.CONSUME, "",BigDecimal.ZERO,"课程组创建");
|
|
|
+
|
|
|
+ try {
|
|
|
+ sysTenantAccountService.update(courseGroup.getTeacherId(), -totalCourseTime, "", SysTenantAccountDetail.TransType.CONSUME, "",BigDecimal.ZERO,"课程组创建");
|
|
|
+ } catch (Exception e) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return BaseController.failed("余额不足,请充值。");
|
|
|
+ }
|
|
|
|
|
|
Teacher teacher = teacherDao.get(courseGroup.getTeacherId());
|
|
|
|
|
@@ -140,7 +148,21 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
|
|
|
newCourse.setStatus(CourseStatusEnum.NOT_START);
|
|
|
newCourse.setName(courseGroup.getName());
|
|
|
}
|
|
|
- courseScheduleService.checkNewCourseSchedules(newCourses,false);
|
|
|
+ try {
|
|
|
+ courseScheduleService.checkNewCourseSchedules(newCourses,false);
|
|
|
+ } catch (Exception e) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ String errMessage;
|
|
|
+ String courseName=e.getMessage().substring(e.getMessage().indexOf(")-")+2);
|
|
|
+ courseName = courseName.substring(0,courseName.indexOf("("));
|
|
|
+ String courseTime = e.getMessage().substring(e.getMessage().indexOf("在") + 1);
|
|
|
+ courseTime = courseTime.substring(0, courseTime.indexOf("至"));
|
|
|
+ errMessage="现在课程:xxx";
|
|
|
+ errMessage+=courseName;
|
|
|
+ errMessage+="<br/>冲突时间:";
|
|
|
+ errMessage+=courseTime;
|
|
|
+ return BaseController.failed(HttpStatus.FOUND, errMessage);
|
|
|
+ }
|
|
|
|
|
|
CourseSchedule firstCourseSchedule = newCourses.stream().min(Comparator.comparing(CourseSchedule::getStartClassTime)).get();
|
|
|
if(firstCourseSchedule.getStartClassTime().before(now)){
|
|
@@ -221,6 +243,7 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
|
|
|
}
|
|
|
courseScheduleTeacherSalaryDao.batchInsert(courseScheduleTeacherSalaries);
|
|
|
teacherAttendanceDao.batchInsert(teacherAttendances);
|
|
|
+ return BaseController.succeed();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -356,18 +379,18 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
|
|
|
throw new BizException("此课程组不存在");
|
|
|
}
|
|
|
if(coursesGroup.getStatus().equals(GroupStatusEnum.CANCEL)){
|
|
|
- throw new BizException("无法加入,此课程组已关闭");
|
|
|
+ throw new BizException("课程已关闭,请联系老师了解详细情况。");
|
|
|
}
|
|
|
List<ClassGroupStudentMapper> groupStudents = classGroupStudentMapperDao.findGroupStudents(courseGroupId.toString(), GroupType.COMM, userId, null);
|
|
|
if(!CollectionUtils.isEmpty(groupStudents)){
|
|
|
- throw new BizException("无法重复加入,您已在此课程组");
|
|
|
+ throw new BizException("您完成此课程组报名,无需重复报名。");
|
|
|
}
|
|
|
|
|
|
Date now=new Date();
|
|
|
|
|
|
ClassGroup classGroup = classGroupDao.findByMusicGroupAndType(courseGroupId.toString(), GroupType.COMM.getCode());
|
|
|
if(classGroup.getStudentNum()>=classGroup.getExpectStudentNum()){
|
|
|
- throw new BizException("无法加入,此课程组人数已达上限");
|
|
|
+ throw new BizException("课程人数已满");
|
|
|
}
|
|
|
|
|
|
BigDecimal amount = coursesGroup.getTotalCoursesPrice();
|
|
@@ -389,8 +412,7 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
|
|
|
studentPaymentOrder.setVersion(0);
|
|
|
|
|
|
if(amount.compareTo(BigDecimal.ZERO)<=0){
|
|
|
- this.orderCallback(studentPaymentOrder);
|
|
|
- return BaseController.succeed();
|
|
|
+ return this.orderCallback(studentPaymentOrder);
|
|
|
}else{
|
|
|
studentPaymentOrderService.insert(studentPaymentOrder);
|
|
|
|
|
@@ -465,11 +487,11 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED)
|
|
|
- public void orderCallback(StudentPaymentOrder order) {
|
|
|
+ public HttpResponseResult orderCallback(StudentPaymentOrder order) {
|
|
|
if(order.getExpectAmount().compareTo(BigDecimal.ZERO)>0){
|
|
|
StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.get(order.getId());
|
|
|
if(!studentPaymentOrder.getStatus().equals(DealStatusEnum.ING)){
|
|
|
- return;
|
|
|
+ return BaseController.succeed();
|
|
|
}
|
|
|
SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(order.getUserId());
|
|
|
List<StudentPaymentOrder> userGroupOrders = studentPaymentOrderDao.findUserGroupOrders(order.getUserId(), order.getMusicGroupId(), order.getGroupType(),null);
|
|
@@ -484,7 +506,7 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
|
|
|
order.setMemo("重复支付,进入余额");
|
|
|
}
|
|
|
studentPaymentOrderDao.update(order);
|
|
|
- return;
|
|
|
+ return BaseController.succeed();
|
|
|
}
|
|
|
|
|
|
Long ingOrderNum=statusOrderNumMap.get(DealStatusEnum.ING);
|
|
@@ -493,7 +515,7 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
|
|
|
sysUserCashAccountService.updateBalance(order.getUserId(), order.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "网管课支付失败,退还余额");
|
|
|
}
|
|
|
studentPaymentOrderDao.update(order);
|
|
|
- return;
|
|
|
+ return BaseController.succeed();
|
|
|
}
|
|
|
|
|
|
if(order.getStatus().equals(DealStatusEnum.SUCCESS)){
|
|
@@ -507,7 +529,7 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
|
|
|
coursesGroup.setStatus(GroupStatusEnum.CANCEL);
|
|
|
coursesGroupDao.update(coursesGroup);
|
|
|
groupService.deleteGroupOtherInfo(order.getMusicGroupId(),GroupType.PRACTICE);
|
|
|
- return;
|
|
|
+ return BaseController.succeed();
|
|
|
}
|
|
|
studentPaymentOrderDao.update(order);
|
|
|
|
|
@@ -552,7 +574,7 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
|
|
|
|
|
|
sysUserCashAccountService.updateBalance(order.getUserId(), order.getExpectAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "支付成功,但课程组不处于正常状态");
|
|
|
|
|
|
- return;
|
|
|
+ return BaseController.succeed();
|
|
|
}
|
|
|
}
|
|
|
CoursesGroup coursesGroup = coursesGroupDao.get(Long.valueOf(order.getMusicGroupId()));
|
|
@@ -579,7 +601,7 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
|
|
|
List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
|
|
|
List<CourseSchedule> groupNotStartCourses = courseScheduleDao.findGroupNotStartCourses(order.getMusicGroupId(), GroupType.COMM);
|
|
|
if(CollectionUtils.isEmpty(groupNotStartCourses)){
|
|
|
- throw new BizException("无法加入,此课程组已关闭");
|
|
|
+ throw new BizException("课程已关闭,请联系老师了解详细情况。");
|
|
|
}
|
|
|
BigDecimal singleCoursePrice = order.getExpectAmount().divide(new BigDecimal(groupNotStartCourses.size()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
for (CourseSchedule courseSchedule : groupNotStartCourses) {
|
|
@@ -596,9 +618,21 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
|
|
|
courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
|
|
|
|
|
|
try {
|
|
|
-// contractService.transferPracticeCoursesContract(order.getUserId(),classGroup.getTotalClassTimes(),practiceGroup.getCoursesStartDate(),practiceGroup.getCoursesExpireDate(),order.getExpectAmount());
|
|
|
+ courseScheduleService.checkNewCourseSchedules(groupNotStartCourses,false);
|
|
|
} catch (Exception e) {
|
|
|
- LOGGER.error("对外课程组[{}]购买协议错误:{}",order.getMusicGroupId(),e.getMessage(),e.getMessage());
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ String errMessage;
|
|
|
+
|
|
|
+ String courseName=e.getMessage().substring(e.getMessage().indexOf(")-")+2);
|
|
|
+ courseName = courseName.substring(0,courseName.indexOf("("));
|
|
|
+ String courseTime = e.getMessage().substring(e.getMessage().indexOf("在") + 1);
|
|
|
+ courseTime = courseTime.substring(0, courseTime.indexOf("至"));
|
|
|
+ errMessage="现在课程:xxx";
|
|
|
+ errMessage+=courseName;
|
|
|
+ errMessage+="<br/>冲突时间:";
|
|
|
+ errMessage+=courseTime;
|
|
|
+
|
|
|
+ return BaseController.failed(HttpStatus.FOUND, errMessage);
|
|
|
}
|
|
|
|
|
|
List<ImGroupMember> imGroupMemberList = new ArrayList<>();
|
|
@@ -607,11 +641,13 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
|
|
|
ImGroupMember[] imGroupMembers = imGroupMemberList.toArray(new ImGroupMember[imGroupMemberList.size()]);
|
|
|
// 创建群组
|
|
|
imFeignService.groupCreate(new ImGroupModel(classGroup.getId().toString(), imGroupMembers, classGroup.getName()));
|
|
|
+
|
|
|
+ return BaseController.succeed();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void noStudentsCourseGroupRemind() {
|
|
|
- Date startDate = DateUtil.addDays(new Date(), -1);
|
|
|
+ Date startDate = DateUtil.addDays(new Date(), 1);
|
|
|
List<CoursesGroup> noStudentsGroups = coursesGroupDao.findNoStudentsGroups(startDate);
|
|
|
if(CollectionUtils.isEmpty(noStudentsGroups)){
|
|
|
return;
|