|
@@ -21,7 +21,9 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType;
|
|
|
import com.ym.mec.biz.dal.enums.*;
|
|
|
+
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -207,6 +209,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
private StudentVisitDao studentVisitDao;
|
|
|
@Autowired
|
|
|
private SubjectDao subjectDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StudentPreRegistrationDao studentPreRegistrationDao;
|
|
|
|
|
|
private SimpleDateFormat sdf_ymd = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
@@ -336,6 +341,34 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public boolean preRegister(StudentPreRegistration studentPreRegistration) {
|
|
|
+ Integer userId = studentPreRegistration.getUserId();
|
|
|
+
|
|
|
+ String musicGroupId = studentPreRegistration.getMusicGroupId();
|
|
|
+
|
|
|
+ //查询乐团状态
|
|
|
+ MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
|
|
|
+ if(musicGroup == null){
|
|
|
+ throw new BizException("乐团信息查询失败");
|
|
|
+ }
|
|
|
+ if(musicGroup.getStatus() != MusicGroupStatusEnum.PRE_APPLY){
|
|
|
+ throw new BizException("乐团当前状态不能预报名");
|
|
|
+ }
|
|
|
+
|
|
|
+ StudentPreRegistration originRegistration = studentPreRegistrationDao.queryByUserId(userId, musicGroupId);
|
|
|
+ if(originRegistration != null){
|
|
|
+ throw new BizException("您已预报名成功,请勿重复提交资料");
|
|
|
+ }
|
|
|
+ Date date = new Date();
|
|
|
+
|
|
|
+ studentPreRegistration.setCreateTime(date);
|
|
|
+
|
|
|
+ studentPreRegistrationDao.update(studentPreRegistration);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Map sporadicPay(SporadicPayDto sporadicPayDto) throws Exception {
|
|
|
//获取收费项价格
|
|
@@ -1123,8 +1156,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
}
|
|
|
MusicGroup musicGroup = saveLog(musicGroupId, MusicGroupStatusEnum.AUDIT);
|
|
|
//记录操作日志
|
|
|
- musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "审核通过(审核中 -> 报名中)", sysUser.getId(), ""));
|
|
|
- musicGroup.setStatus(MusicGroupStatusEnum.APPLY);
|
|
|
+ musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "审核通过(审核中 -> 预报名)", sysUser.getId(), ""));
|
|
|
+ musicGroup.setStatus(MusicGroupStatusEnum.PRE_APPLY);
|
|
|
musicGroupDao.update(musicGroup);
|
|
|
//获取报名缴费项目
|
|
|
MusicGroupPaymentCalender regCalender = musicGroupPaymentCalenderDao.findByMusicGroupRegCalender(musicGroupId);
|
|
@@ -1447,7 +1480,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
}
|
|
|
|
|
|
if (musicGroup.getStatus() != MusicGroupStatusEnum.PAY) {
|
|
|
- throw new BizException("乐团当前状态是{},不能延长缴费", musicGroup.getStatus().getMsg());
|
|
|
+ throw new BizException("乐团当前状态是[{}],不能延长缴费", musicGroup.getStatus().getMsg());
|
|
|
}
|
|
|
|
|
|
Date date = new Date();
|
|
@@ -1490,8 +1523,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
throw new BizException("乐团找不到");
|
|
|
}
|
|
|
|
|
|
- if (musicGroup.getStatus() != MusicGroupStatusEnum.APPLY && musicGroup.getStatus() != MusicGroupStatusEnum.PAY) {
|
|
|
- throw new BizException("乐团当前状态是{},不能延长报名", musicGroup.getStatus().getMsg());
|
|
|
+ if (musicGroup.getStatus() != MusicGroupStatusEnum.APPLY || musicGroup.getStatus() != MusicGroupStatusEnum.PAY) {
|
|
|
+ throw new BizException("乐团当前状态是[{}],不能延长报名", musicGroup.getStatus().getMsg());
|
|
|
}
|
|
|
|
|
|
Date date = new Date();
|
|
@@ -1508,6 +1541,34 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public boolean extensionPreApplyExpireDate(String musicGroupId, Date expireDate) {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null) {
|
|
|
+ throw new BizException("用户信息获取失败");
|
|
|
+ }
|
|
|
+ MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
|
|
|
+ if (musicGroup == null) {
|
|
|
+ throw new BizException("乐团找不到");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (musicGroup.getStatus() != MusicGroupStatusEnum.PRE_APPLY) {
|
|
|
+ throw new BizException("乐团当前状态是[{}],不能延长预报名", musicGroup.getStatus().getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ Date date = new Date();
|
|
|
+
|
|
|
+ if (date.after(expireDate)) {
|
|
|
+ throw new BizException("日期设置错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ musicGroup.setPreApplyExpireDate(expireDate);
|
|
|
+ musicGroup.setUpdateTime(date);
|
|
|
+ musicGroupDao.update(musicGroup);
|
|
|
+ musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "延长预报名时间", sysUser.getId(), ""));
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
public boolean applyQuitMusicGroup(String musicGroupId, String reason) {
|
|
|
SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
@@ -1663,15 +1724,32 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
studentDao.update(student);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ //删除进行中加学生,且在审批中或拒绝的缴费
|
|
|
+ List<Long> paymentCalenderIdList = musicGroupPaymentCalenderDao.findStudentNoPaymentCalender(userId, musicGroupId);
|
|
|
+ if(paymentCalenderIdList != null && paymentCalenderIdList.size() > 0){
|
|
|
+ musicGroupPaymentCalenderDao.delByIds(paymentCalenderIdList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询未交费的项目
|
|
|
+ List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = musicGroupPaymentCalenderDetailDao.queryNotPaymentStudentByUserIdAndMusicGroupId(userId, musicGroupId);
|
|
|
+
|
|
|
+ for (MusicGroupPaymentCalenderDetail mgpcd : musicGroupPaymentCalenderDetailList) {
|
|
|
+ MusicGroupPaymentCalender mgpc = musicGroupPaymentCalenderDao.get(mgpcd.getMusicGroupPaymentCalenderId());
|
|
|
+ if (mgpc != null) {
|
|
|
+ if (mgpc.getPaymentType() == PaymentType.ADD_STUDENT) {
|
|
|
+ musicGroupPaymentCalenderDao.delete(mgpc.getId());
|
|
|
+ } else {
|
|
|
+ // 缴费项目预计人数减一
|
|
|
+ mgpc.setExpectNum(mgpc.getExpectNum() - 1);
|
|
|
+ mgpc.setUpdateTime(date);
|
|
|
+ musicGroupPaymentCalenderDao.update(mgpc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ musicGroupPaymentCalenderDetailDao.delete(mgpcd.getId());
|
|
|
+ }
|
|
|
//删除用户购买的课程记录
|
|
|
musicGroupPaymentStudentCourseDetailDao.deleteByUserIdAndMusicGroupId(userId, musicGroupId);
|
|
|
|
|
|
- //缴费项目预计人数减一
|
|
|
- musicGroupPaymentCalenderDao.cutCalenderExpectNum(userId, musicGroupId);
|
|
|
- //删除缴费项目详情
|
|
|
- musicGroupPaymentCalenderDetailDao.deleteByUserIdAndMusicGroupId(userId, musicGroupId);
|
|
|
-
|
|
|
//操作人
|
|
|
SysUser operator = sysUserFeignService.queryUserInfo();
|
|
|
|
|
@@ -1694,53 +1772,52 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
musicGroupSubjectPlan.setUpdateTime(date);
|
|
|
musicGroupSubjectPlanDao.update(musicGroupSubjectPlan);
|
|
|
}
|
|
|
-
|
|
|
- StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, SUCCESS);
|
|
|
-
|
|
|
- if (studentPaymentOrder == null) {
|
|
|
- //兼容历史数据
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
|
|
|
-
|
|
|
+
|
|
|
if (isRefundCourseFee) {
|
|
|
// 退课程费用
|
|
|
amount = amount.add(studentRegistration.getSurplusCourseFee());
|
|
|
}
|
|
|
|
|
|
- SubjectChange studentLastChange = null;
|
|
|
- if (isRefundInstrumentFee || isRefundTeachingAssistantsFee) {
|
|
|
- studentLastChange = subjectChangeDao.getStudentLastChange(userId, musicGroupId);
|
|
|
- }
|
|
|
+ StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, SUCCESS);
|
|
|
|
|
|
- BigDecimal remitFee = studentPaymentOrder.getRemitFee() == null ? BigDecimal.ZERO : studentPaymentOrder.getRemitFee();
|
|
|
- for (StudentPaymentOrderDetail detail : orderDetailList) {
|
|
|
- if (remitFee.compareTo(detail.getPrice()) >= 0) {
|
|
|
- remitFee = remitFee.subtract(detail.getPrice());
|
|
|
- detail.setPrice(BigDecimal.ZERO);
|
|
|
- } else {
|
|
|
- detail.setPrice(detail.getPrice().subtract(remitFee));
|
|
|
- remitFee = BigDecimal.ZERO;
|
|
|
+ if (studentPaymentOrder != null) {
|
|
|
+ List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
|
|
|
+
|
|
|
+ SubjectChange studentLastChange = null;
|
|
|
+ if (isRefundInstrumentFee || isRefundTeachingAssistantsFee) {
|
|
|
+ studentLastChange = subjectChangeDao.getStudentLastChange(userId, musicGroupId);
|
|
|
}
|
|
|
|
|
|
- if (isRefundInstrumentFee && studentLastChange == null) {
|
|
|
- // 退乐器费用
|
|
|
- if (detail.getType() == OrderDetailTypeEnum.MUSICAL) {
|
|
|
- amount = amount.add(detail.getPrice());
|
|
|
+ BigDecimal remitFee = studentPaymentOrder.getRemitFee() == null ? BigDecimal.ZERO : studentPaymentOrder.getRemitFee();
|
|
|
+ for (StudentPaymentOrderDetail detail : orderDetailList) {
|
|
|
+ if (remitFee.compareTo(detail.getPrice()) >= 0) {
|
|
|
+ remitFee = remitFee.subtract(detail.getPrice());
|
|
|
+ detail.setPrice(BigDecimal.ZERO);
|
|
|
+ } else {
|
|
|
+ detail.setPrice(detail.getPrice().subtract(remitFee));
|
|
|
+ remitFee = BigDecimal.ZERO;
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
- if (isRefundTeachingAssistantsFee && studentLastChange == null) {
|
|
|
- // 退教辅费用
|
|
|
- if (detail.getType() == OrderDetailTypeEnum.ACCESSORIES || detail.getType() == OrderDetailTypeEnum.TEACHING) {
|
|
|
- amount = amount.add(detail.getPrice());
|
|
|
+ if (isRefundInstrumentFee && studentLastChange == null) {
|
|
|
+ // 退乐器费用
|
|
|
+ if (detail.getType() == OrderDetailTypeEnum.MUSICAL) {
|
|
|
+ amount = amount.add(detail.getPrice());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (isRefundTeachingAssistantsFee && studentLastChange == null) {
|
|
|
+ // 退教辅费用
|
|
|
+ if (detail.getType() == OrderDetailTypeEnum.ACCESSORIES || detail.getType() == OrderDetailTypeEnum.TEACHING) {
|
|
|
+ amount = amount.add(detail.getPrice());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ if (studentLastChange != null) {
|
|
|
+ amount = amount.add(studentLastChange.getChangeMusicalPrice()).add(studentLastChange.getChangeAccessoriesPrice());
|
|
|
+ }
|
|
|
}
|
|
|
- if (studentLastChange != null) {
|
|
|
- amount = amount.add(studentLastChange.getChangeMusicalPrice()).add(studentLastChange.getChangeAccessoriesPrice());
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
if (amount.doubleValue() > 0) {
|
|
|
// 增加交易流水
|
|
|
sysUserCashAccountDetailService.addCashAccountDetail(userId, amount, SysUserCashAccountDetailService.MUSIC_GROUP + musicGroupId, "",
|
|
@@ -1829,14 +1906,32 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
studentDao.update(student);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ //删除进行中加学生,且在审批中或拒绝的缴费
|
|
|
+ List<Long> paymentCalenderIdList = musicGroupPaymentCalenderDao.findStudentNoPaymentCalender(userId, musicGroupId);
|
|
|
+ if(paymentCalenderIdList != null && paymentCalenderIdList.size() > 0){
|
|
|
+ musicGroupPaymentCalenderDao.delByIds(paymentCalenderIdList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询未交费的项目
|
|
|
+ List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = musicGroupPaymentCalenderDetailDao.queryNotPaymentStudentByUserIdAndMusicGroupId(userId, musicGroupId);
|
|
|
+
|
|
|
+ for (MusicGroupPaymentCalenderDetail mgpcd : musicGroupPaymentCalenderDetailList) {
|
|
|
+ MusicGroupPaymentCalender mgpc = musicGroupPaymentCalenderDao.get(mgpcd.getMusicGroupPaymentCalenderId());
|
|
|
+ if (mgpc != null) {
|
|
|
+ if (mgpc.getPaymentType() == PaymentType.ADD_STUDENT) {
|
|
|
+ musicGroupPaymentCalenderDao.delete(mgpc.getId());
|
|
|
+ } else {
|
|
|
+ // 缴费项目预计人数减一
|
|
|
+ mgpc.setExpectNum(mgpc.getExpectNum() - 1);
|
|
|
+ mgpc.setUpdateTime(date);
|
|
|
+ musicGroupPaymentCalenderDao.update(mgpc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ musicGroupPaymentCalenderDetailDao.delete(mgpcd.getId());
|
|
|
+ }
|
|
|
//删除用户购买的课程记录
|
|
|
musicGroupPaymentStudentCourseDetailDao.deleteByUserIdAndMusicGroupId(userId, musicGroupId);
|
|
|
-
|
|
|
- //缴费项目预计人数减一
|
|
|
- musicGroupPaymentCalenderDao.cutCalenderExpectNum(userId, musicGroupId);
|
|
|
- //删除缴费项目详情
|
|
|
- musicGroupPaymentCalenderDetailDao.deleteByUserIdAndMusicGroupId(userId, musicGroupId);
|
|
|
+
|
|
|
|
|
|
//操作人
|
|
|
SysUser operator = sysUserFeignService.queryUserInfo();
|
|
@@ -1860,52 +1955,52 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
musicGroupSubjectPlan.setUpdateTime(date);
|
|
|
musicGroupSubjectPlanDao.update(musicGroupSubjectPlan);
|
|
|
}
|
|
|
-
|
|
|
- StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, SUCCESS);
|
|
|
-
|
|
|
- if (studentPaymentOrder == null) {
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
|
|
|
-
|
|
|
+
|
|
|
if (isRefundCourseFee) {
|
|
|
// 退课程费用
|
|
|
amount = amount.add(studentRegistration.getSurplusCourseFee());
|
|
|
}
|
|
|
|
|
|
- SubjectChange studentLastChange = null;
|
|
|
- if (isRefundInstrumentFee || isRefundTeachingAssistantsFee) {
|
|
|
- studentLastChange = subjectChangeDao.getStudentLastChange(userId, musicGroupId);
|
|
|
- }
|
|
|
+ StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, SUCCESS);
|
|
|
|
|
|
- BigDecimal remitFee = studentPaymentOrder.getRemitFee() == null ? BigDecimal.ZERO : studentPaymentOrder.getRemitFee();
|
|
|
+ if (studentPaymentOrder != null) {
|
|
|
+ List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
|
|
|
|
|
|
- for (StudentPaymentOrderDetail detail : orderDetailList) {
|
|
|
- if (remitFee.compareTo(detail.getPrice()) >= 0) {
|
|
|
- remitFee = remitFee.subtract(detail.getPrice());
|
|
|
- detail.setPrice(BigDecimal.ZERO);
|
|
|
- } else {
|
|
|
- detail.setPrice(detail.getPrice().subtract(remitFee));
|
|
|
- remitFee = BigDecimal.ZERO;
|
|
|
+ SubjectChange studentLastChange = null;
|
|
|
+ if (isRefundInstrumentFee || isRefundTeachingAssistantsFee) {
|
|
|
+ studentLastChange = subjectChangeDao.getStudentLastChange(userId, musicGroupId);
|
|
|
}
|
|
|
- if (isRefundInstrumentFee && studentLastChange == null) {
|
|
|
- // 退乐器费用
|
|
|
- if (detail.getType() == OrderDetailTypeEnum.MUSICAL) {
|
|
|
- amount = amount.add(detail.getPrice());
|
|
|
+
|
|
|
+ BigDecimal remitFee = studentPaymentOrder.getRemitFee() == null ? BigDecimal.ZERO : studentPaymentOrder.getRemitFee();
|
|
|
+
|
|
|
+ for (StudentPaymentOrderDetail detail : orderDetailList) {
|
|
|
+ if (remitFee.compareTo(detail.getPrice()) >= 0) {
|
|
|
+ remitFee = remitFee.subtract(detail.getPrice());
|
|
|
+ detail.setPrice(BigDecimal.ZERO);
|
|
|
+ } else {
|
|
|
+ detail.setPrice(detail.getPrice().subtract(remitFee));
|
|
|
+ remitFee = BigDecimal.ZERO;
|
|
|
}
|
|
|
+ if (isRefundInstrumentFee && studentLastChange == null) {
|
|
|
+ // 退乐器费用
|
|
|
+ if (detail.getType() == OrderDetailTypeEnum.MUSICAL) {
|
|
|
+ amount = amount.add(detail.getPrice());
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
- if (isRefundTeachingAssistantsFee && studentLastChange == null) {
|
|
|
- // 退教辅费用
|
|
|
- if (detail.getType() == OrderDetailTypeEnum.ACCESSORIES || detail.getType() == OrderDetailTypeEnum.TEACHING) {
|
|
|
- amount = amount.add(detail.getPrice());
|
|
|
+ }
|
|
|
+ if (isRefundTeachingAssistantsFee && studentLastChange == null) {
|
|
|
+ // 退教辅费用
|
|
|
+ if (detail.getType() == OrderDetailTypeEnum.ACCESSORIES || detail.getType() == OrderDetailTypeEnum.TEACHING) {
|
|
|
+ amount = amount.add(detail.getPrice());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ if (studentLastChange != null) {
|
|
|
+ amount = amount.add(studentLastChange.getChangeMusicalPrice()).add(studentLastChange.getChangeAccessoriesPrice());
|
|
|
+ }
|
|
|
}
|
|
|
- if (studentLastChange != null) {
|
|
|
- amount = amount.add(studentLastChange.getChangeMusicalPrice()).add(studentLastChange.getChangeAccessoriesPrice());
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
if (amount.doubleValue() > 0) {
|
|
|
// 增加交易流水
|
|
|
sysUserCashAccountDetailService.addCashAccountDetail(userId, amount, SysUserCashAccountDetailService.MUSIC_GROUP + musicGroupId, "",
|