|
@@ -21,6 +21,7 @@ import com.ym.mec.thirdparty.message.MessageSenderPluginContext.MessageSender;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import com.ym.mec.util.http.HttpUtil;
|
|
|
+
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -115,6 +116,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
|
|
|
@Autowired
|
|
|
private SysConfigDao sysConfigDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<String, MusicGroup> getDAO() {
|
|
@@ -562,100 +566,158 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
- public boolean approveQuitMusicGroup(Long id, ApprovalStatus status, String reason){
|
|
|
- MusicGroupQuit musicGroupQuit = musicGroupQuitDao.get(id);
|
|
|
- if(musicGroupQuit == null){
|
|
|
- throw new BizException("数据不存在");
|
|
|
- }
|
|
|
- Date date = new Date();
|
|
|
-
|
|
|
- String musicGroupId = musicGroupQuit.getMusicGroupId();
|
|
|
- Integer userId = musicGroupQuit.getUserId();
|
|
|
-
|
|
|
- musicGroupQuit.setStatus(status);
|
|
|
- musicGroupQuit.setReason(reason);
|
|
|
- musicGroupQuit.setQuitDate(date);
|
|
|
- musicGroupQuitDao.update(musicGroupQuit);
|
|
|
+ @Override
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
+ public boolean approveQuitMusicGroup(Long id, ApprovalStatus status, String reason, boolean isRefundCourseFee, boolean isRefundInstrumentFee,
|
|
|
+ boolean isRefundTeachingAssistantsFee) {
|
|
|
+ MusicGroupQuit musicGroupQuit = musicGroupQuitDao.get(id);
|
|
|
+ if (musicGroupQuit == null) {
|
|
|
+ throw new BizException("数据不存在");
|
|
|
+ }
|
|
|
+ Date date = new Date();
|
|
|
+
|
|
|
+ String musicGroupId = musicGroupQuit.getMusicGroupId();
|
|
|
+ Integer userId = musicGroupQuit.getUserId();
|
|
|
+
|
|
|
+ musicGroupQuit.setStatus(status);
|
|
|
+ musicGroupQuit.setReason(reason);
|
|
|
+ musicGroupQuit.setQuitDate(date);
|
|
|
+ musicGroupQuitDao.update(musicGroupQuit);
|
|
|
+
|
|
|
+ if (status == ApprovalStatus.APPROVED) {
|
|
|
+ classGroupStudentMapperDao.deleteStudentByMusicGroupId(musicGroupId, userId);
|
|
|
+
|
|
|
+ StudentRegistration studentRegistration = studentRegistrationDao.queryByUserIdAndMusicGroupId(userId, musicGroupId);
|
|
|
+ if (studentRegistration == null) {
|
|
|
+ throw new BizException("用户注册信息不存在");
|
|
|
+ }
|
|
|
+ // 退团
|
|
|
+ studentRegistration.setMusicGroupStatus(ClassGroupStudentStatusEnum.QUIT);
|
|
|
+ studentRegistration.setUpdateTime(date);
|
|
|
+
|
|
|
+ studentRegistrationDao.update(studentRegistration);
|
|
|
+
|
|
|
+ BigDecimal amount = new BigDecimal(0);
|
|
|
+
|
|
|
+ // 判断乐器是否是租赁
|
|
|
+ // MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, subjectId);
|
|
|
+
|
|
|
+ StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, DealStatusEnum.SUCCESS);
|
|
|
+
|
|
|
+ if (studentPaymentOrder == null) {
|
|
|
+ throw new BizException("报名订单找不到");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
|
|
|
+
|
|
|
+ for (StudentPaymentOrderDetail detail : orderDetailList) {
|
|
|
+ if (isRefundCourseFee) {
|
|
|
+ // 退课程费用
|
|
|
+ if (detail.getType() == OrderDetailTypeEnum.COURSE) {
|
|
|
+ amount = amount.add(detail.getPrice());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isRefundInstrumentFee) {
|
|
|
+ // 退乐器费用
|
|
|
+ if (detail.getType() == OrderDetailTypeEnum.MUSICAL) {
|
|
|
+ amount = amount.add(detail.getPrice());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (isRefundTeachingAssistantsFee) {
|
|
|
+ // 退教辅费用
|
|
|
+ if (detail.getType() == OrderDetailTypeEnum.ACCESSORIES || detail.getType() == OrderDetailTypeEnum.TEACHING) {
|
|
|
+ amount = amount.add(detail.getPrice());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (amount.doubleValue() > 0) {
|
|
|
+ // 增加交易流水
|
|
|
+ sysUserCashAccountDetailService.addCashAccountDetail(userId, amount, SysUserCashAccountDetailService.MUSIC_GROUP + musicGroupId, "",
|
|
|
+ PlatformCashAccountDetailTypeEnum.REFUNDS, null, DealStatusEnum.SUCCESS, "退出乐团");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
- if (status == ApprovalStatus.APPROVED) {
|
|
|
- classGroupStudentMapperDao.deleteStudentByMusicGroupId(musicGroupId, userId);
|
|
|
+ @Override
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
+ public boolean directQuitMusicGroup(String musicGroupId, Integer userId, String reason, boolean isRefundCourseFee, boolean isRefundInstrumentFee,
|
|
|
+ boolean isRefundTeachingAssistantsFee) {
|
|
|
|
|
|
- // 判断乐器是否是租赁
|
|
|
- StudentRegistration studentRegistration = studentRegistrationDao.queryByUserIdAndMusicGroupId(userId, musicGroupId);
|
|
|
- if (studentRegistration == null) {
|
|
|
- throw new BizException("用户注册信息不存在");
|
|
|
- }
|
|
|
- // 退团
|
|
|
- studentRegistration.setMusicGroupStatus(ClassGroupStudentStatusEnum.QUIT);
|
|
|
- studentRegistration.setUpdateTime(date);
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserById(userId);
|
|
|
+ if (sysUser == null) {
|
|
|
+ throw new BizException("获取用户信息失败");
|
|
|
+ }
|
|
|
|
|
|
- studentRegistrationDao.update(studentRegistration);
|
|
|
+ Date date = new Date();
|
|
|
|
|
|
- Integer subjectId = studentRegistration.getActualSubjectId();
|
|
|
- MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, subjectId);
|
|
|
- if (musicGroupSubjectPlan == null) {
|
|
|
- throw new BizException("乐团声部费用设置不存在");
|
|
|
- }
|
|
|
- if (musicGroupSubjectPlan.getDepositFee().doubleValue() > 0) {
|
|
|
- // 增加交易流水
|
|
|
- sysUserCashAccountDetailService.addCashAccountDetail(userId, musicGroupSubjectPlan.getDepositFee(),
|
|
|
- SysUserCashAccountDetailService.MUSIC_GROUP + musicGroupId, "", PlatformCashAccountDetailTypeEnum.REFUNDS, null,
|
|
|
- DealStatusEnum.SUCCESS, "退出乐团");
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
+ MusicGroupQuit musicGroupQuit = new MusicGroupQuit();
|
|
|
+ musicGroupQuit.setCreateTime(date);
|
|
|
+ musicGroupQuit.setJoinDate(sysUser.getCreateTime());
|
|
|
+ musicGroupQuit.setMusicGroupId(musicGroupId);
|
|
|
+ musicGroupQuit.setUserId(sysUser.getId());
|
|
|
+ musicGroupQuit.setStatus(ApprovalStatus.APPROVED);
|
|
|
+ musicGroupQuit.setReason(reason);
|
|
|
+ musicGroupQuit.setQuitDate(date);
|
|
|
|
|
|
- @Override
|
|
|
- @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
- public boolean directQuitMusicGroup(String musicGroupId, Integer userId, String reason) {
|
|
|
+ musicGroupQuitDao.insert(musicGroupQuit);
|
|
|
|
|
|
- SysUser sysUser = sysUserFeignService.queryUserById(userId);
|
|
|
- if (sysUser == null) {
|
|
|
- throw new BizException("获取用户信息失败");
|
|
|
- }
|
|
|
+ classGroupStudentMapperDao.deleteStudentByMusicGroupId(musicGroupId, userId);
|
|
|
|
|
|
- Date date = new Date();
|
|
|
+ // 判断乐器是否是租赁
|
|
|
+ StudentRegistration studentRegistration = studentRegistrationDao.queryByUserIdAndMusicGroupId(userId, musicGroupId);
|
|
|
+ if (studentRegistration == null) {
|
|
|
+ throw new BizException("用户注册信息不存在");
|
|
|
+ }
|
|
|
+ // 退团
|
|
|
+ studentRegistration.setMusicGroupStatus(ClassGroupStudentStatusEnum.QUIT);
|
|
|
+ studentRegistration.setUpdateTime(date);
|
|
|
|
|
|
- MusicGroupQuit musicGroupQuit = new MusicGroupQuit();
|
|
|
- musicGroupQuit.setCreateTime(date);
|
|
|
- musicGroupQuit.setJoinDate(sysUser.getCreateTime());
|
|
|
- musicGroupQuit.setMusicGroupId(musicGroupId);
|
|
|
- musicGroupQuit.setUserId(sysUser.getId());
|
|
|
- musicGroupQuit.setStatus(ApprovalStatus.APPROVED);
|
|
|
- musicGroupQuit.setReason(reason);
|
|
|
- musicGroupQuit.setQuitDate(date);
|
|
|
+ studentRegistrationDao.update(studentRegistration);
|
|
|
|
|
|
- musicGroupQuitDao.insert(musicGroupQuit);
|
|
|
+ BigDecimal amount = new BigDecimal(0);
|
|
|
|
|
|
- classGroupStudentMapperDao.deleteStudentByMusicGroupId(musicGroupId, userId);
|
|
|
+ // 判断乐器是否是租赁
|
|
|
+ // MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, subjectId);
|
|
|
|
|
|
- // 判断乐器是否是租赁
|
|
|
- StudentRegistration studentRegistration = studentRegistrationDao.queryByUserIdAndMusicGroupId(userId, musicGroupId);
|
|
|
- if (studentRegistration == null) {
|
|
|
- throw new BizException("用户注册信息不存在");
|
|
|
- }
|
|
|
- // 退团
|
|
|
- studentRegistration.setMusicGroupStatus(ClassGroupStudentStatusEnum.QUIT);
|
|
|
- studentRegistration.setUpdateTime(date);
|
|
|
+ StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, DealStatusEnum.SUCCESS);
|
|
|
|
|
|
- studentRegistrationDao.update(studentRegistration);
|
|
|
+ if (studentPaymentOrder == null) {
|
|
|
+ throw new BizException("报名订单找不到");
|
|
|
+ }
|
|
|
|
|
|
- Integer subjectId = studentRegistration.getActualSubjectId();
|
|
|
- MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, subjectId);
|
|
|
- if (musicGroupSubjectPlan == null) {
|
|
|
- throw new BizException("乐团声部费用设置不存在");
|
|
|
- }
|
|
|
- if (musicGroupSubjectPlan.getDepositFee().doubleValue() > 0) {
|
|
|
- // 增加交易流水
|
|
|
- sysUserCashAccountDetailService.addCashAccountDetail(userId, musicGroupSubjectPlan.getDepositFee(), SysUserCashAccountDetailService.MUSIC_GROUP
|
|
|
- + musicGroupId, "", PlatformCashAccountDetailTypeEnum.REFUNDS, null, DealStatusEnum.SUCCESS, "退出乐团");
|
|
|
- }
|
|
|
+ List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
|
|
|
+
|
|
|
+ for (StudentPaymentOrderDetail detail : orderDetailList) {
|
|
|
+ if (isRefundCourseFee) {
|
|
|
+ // 退课程费用
|
|
|
+ if (detail.getType() == OrderDetailTypeEnum.COURSE) {
|
|
|
+ amount = amount.add(detail.getPrice());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isRefundInstrumentFee) {
|
|
|
+ // 退乐器费用
|
|
|
+ if (detail.getType() == OrderDetailTypeEnum.MUSICAL) {
|
|
|
+ amount = amount.add(detail.getPrice());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (isRefundTeachingAssistantsFee) {
|
|
|
+ // 退教辅费用
|
|
|
+ if (detail.getType() == OrderDetailTypeEnum.ACCESSORIES || detail.getType() == OrderDetailTypeEnum.TEACHING) {
|
|
|
+ amount = amount.add(detail.getPrice());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (amount.doubleValue() > 0) {
|
|
|
+ // 增加交易流水
|
|
|
+ sysUserCashAccountDetailService.addCashAccountDetail(userId, amount, SysUserCashAccountDetailService.MUSIC_GROUP + musicGroupId, "",
|
|
|
+ PlatformCashAccountDetailTypeEnum.REFUNDS, null, DealStatusEnum.SUCCESS, "退出乐团");
|
|
|
+ }
|
|
|
|
|
|
- return true;
|
|
|
- }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|