|
@@ -21,6 +21,8 @@ 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.enums.*;
|
|
|
+import com.ym.mec.biz.service.*;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -46,47 +48,8 @@ import com.ym.mec.biz.dal.dto.SubjectRegisterDto;
|
|
|
import com.ym.mec.biz.dal.dto.UpdateExpectedNumDto;
|
|
|
import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType;
|
|
|
import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
|
|
|
-import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.CourseStatusEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.DealStatusEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.FivePlusGradeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.GoodsType;
|
|
|
-import com.ym.mec.biz.dal.enums.GradeTypeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.GroupType;
|
|
|
-import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.OrderTypeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.SixPlusGradeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.SporadicChargeTypeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.YesOrNoEnum;
|
|
|
import com.ym.mec.biz.dal.page.MusicGroupQueryInfo;
|
|
|
import com.ym.mec.biz.event.source.GroupEventSource;
|
|
|
-import com.ym.mec.biz.service.ClassGroupService;
|
|
|
-import com.ym.mec.biz.service.ClassGroupStudentMapperService;
|
|
|
-import com.ym.mec.biz.service.ContractService;
|
|
|
-import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
|
|
|
-import com.ym.mec.biz.service.GoodsService;
|
|
|
-import com.ym.mec.biz.service.ImGroupMemberService;
|
|
|
-import com.ym.mec.biz.service.ImGroupService;
|
|
|
-import com.ym.mec.biz.service.ImUserFriendService;
|
|
|
-import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
|
|
|
-import com.ym.mec.biz.service.MusicGroupService;
|
|
|
-import com.ym.mec.biz.service.MusicGroupSubjectGoodsGroupService;
|
|
|
-import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
|
|
|
-import com.ym.mec.biz.service.PayService;
|
|
|
-import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
|
|
|
-import com.ym.mec.biz.service.StudentPaymentOrderService;
|
|
|
-import com.ym.mec.biz.service.StudentPaymentRouteOrderService;
|
|
|
-import com.ym.mec.biz.service.StudentRegistrationService;
|
|
|
-import com.ym.mec.biz.service.SysConfigService;
|
|
|
-import com.ym.mec.biz.service.SysMessageService;
|
|
|
-import com.ym.mec.biz.service.SysUserCashAccountDetailService;
|
|
|
-import com.ym.mec.biz.service.SysUserCashAccountService;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
import com.ym.mec.common.entity.ImGroupMember;
|
|
@@ -244,6 +207,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
|
|
|
@Autowired
|
|
|
private StudentPreRegistrationDao studentPreRegistrationDao;
|
|
|
+ @Autowired
|
|
|
+ private OrganizationCloudTeacherFeeDao organizationCloudTeacherFeeDao;
|
|
|
|
|
|
@Autowired
|
|
|
private GroupEventSource groupEventSource;
|
|
@@ -251,6 +216,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
@Autowired
|
|
|
private StudentInstrumentDao studentInstrumentDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CloudTeacherOrderService cloudTeacherOrderService;
|
|
|
+
|
|
|
private SimpleDateFormat sdf_ymd = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
private SimpleDateFormat sdf_hms = new SimpleDateFormat("HH:mm:ss");
|
|
@@ -714,6 +682,15 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
orderAmount = orderAmount.add(maintenancePrice);
|
|
|
}
|
|
|
|
|
|
+ //云教练
|
|
|
+ MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
|
|
|
+ studentRegistration.setOrganId(musicGroup.getOrganId());
|
|
|
+ if (registerPayDto.getBuyCloudTeacher()) {
|
|
|
+ OrganizationCloudTeacherFee cloudTeacher = organizationCloudTeacherFeeDao.getByOrganId(studentRegistration.getOrganId());
|
|
|
+ BigDecimal cloudTeacherPrice = cloudTeacher.getPrice();
|
|
|
+ orderAmount = orderAmount.add(cloudTeacherPrice);
|
|
|
+ }
|
|
|
+
|
|
|
if (amount.compareTo(orderAmount) != 0) {
|
|
|
throw new BizException("商品价格不符");
|
|
|
}
|
|
@@ -725,12 +702,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
|
|
|
String channelType = "";
|
|
|
|
|
|
- StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration, amount, orderNo, channelType, courseFee, goodsGroups, remitFee, courseRemitFee, newCourses, registerPayDto.getBuyMaintenance());
|
|
|
+ StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration, amount, orderNo, channelType, courseFee, goodsGroups, remitFee, courseRemitFee, newCourses, registerPayDto.getBuyMaintenance(), registerPayDto.getBuyCloudTeacher());
|
|
|
studentPaymentOrder.setVersion(0);
|
|
|
|
|
|
Date date = new Date();
|
|
|
BigDecimal balance = BigDecimal.ZERO;
|
|
|
- MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
|
|
|
if (registerPayDto.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
|
|
|
if (userCashAccount == null) {
|
|
@@ -865,6 +841,15 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
orderAmount = orderAmount.add(maintenancePrice);
|
|
|
}
|
|
|
|
|
|
+ MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
|
|
|
+ studentRegistration.setOrganId(musicGroup.getOrganId());
|
|
|
+ //云教练
|
|
|
+ if (registerPayDto.getBuyCloudTeacher()) {
|
|
|
+ OrganizationCloudTeacherFee cloudTeacher = organizationCloudTeacherFeeDao.getByOrganId(studentRegistration.getOrganId());
|
|
|
+ BigDecimal cloudTeacherPrice = cloudTeacher.getPrice();
|
|
|
+ orderAmount = orderAmount.add(cloudTeacherPrice);
|
|
|
+ }
|
|
|
+
|
|
|
if (amount.compareTo(orderAmount) != 0) {
|
|
|
throw new BizException("商品价格不符");
|
|
|
}
|
|
@@ -877,12 +862,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
|
|
|
String channelType = "";
|
|
|
|
|
|
- StudentPaymentOrder studentPaymentOrder = studentRegistrationService.reAddOrder(userId, amount, orderNo, channelType, courseFee, goodsGroups, studentRegistration.getMusicGroupId(), ApplyOrder, remitFee, courseRemitFee, newCourses, registerPayDto.getBuyMaintenance());
|
|
|
+ StudentPaymentOrder studentPaymentOrder = studentRegistrationService.reAddOrder(userId, amount, orderNo, channelType, courseFee, goodsGroups, studentRegistration.getMusicGroupId(), ApplyOrder, remitFee, courseRemitFee, newCourses, registerPayDto.getBuyMaintenance(), registerPayDto.getBuyCloudTeacher());
|
|
|
studentPaymentOrder.setVersion(0);
|
|
|
Date date = new Date();
|
|
|
|
|
|
BigDecimal balance = BigDecimal.ZERO;
|
|
|
- MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
|
|
|
if (registerPayDto.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
SysUserCashAccount userCashAccount = sysUserCashAccountService.get(userId);
|
|
|
if (userCashAccount == null) {
|
|
@@ -1678,7 +1662,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
@Override
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
public boolean approveQuitMusicGroup(Long id, ApprovalStatus status, String reason, boolean isRefundCourseFee, boolean isRefundInstrumentFee,
|
|
|
- boolean isRefundTeachingAssistantsFee, BigDecimal maintenanceFee) {
|
|
|
+ boolean isRefundTeachingAssistantsFee, BigDecimal maintenanceFee, BigDecimal cloudTeacherAmount) {
|
|
|
|
|
|
MusicGroupQuit musicGroupQuit = musicGroupQuitDao.get(id);
|
|
|
if (musicGroupQuit == null) {
|
|
@@ -1783,9 +1767,13 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
|
|
|
BigDecimal amount = new BigDecimal(0);
|
|
|
|
|
|
- // 判断乐器是否是租赁
|
|
|
+ StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, SUCCESS);
|
|
|
+ BigDecimal orderExpectAmount = studentPaymentOrder == null ? BigDecimal.ZERO : studentPaymentOrder.getExpectAmount();
|
|
|
+
|
|
|
+ boolean hasPaid = studentRegistration.getMusicGroupStatus().equals(StudentMusicGroupStatusEnum.NORMAL);
|
|
|
+ // 缴费人数更新
|
|
|
MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, studentRegistration.getActualSubjectId());
|
|
|
- if (musicGroupSubjectPlan != null) {
|
|
|
+ if (hasPaid && musicGroupSubjectPlan != null && (!musicGroup.getCourseViewType().equals(CourseViewTypeEnum.CLOUD_TEACHER) || orderExpectAmount.compareTo(BigDecimal.ZERO) > 0)) {
|
|
|
musicGroupSubjectPlan.setPaidStudentNum(musicGroupSubjectPlan.getPaidStudentNum() - 1);
|
|
|
musicGroupSubjectPlan.setUpdateTime(date);
|
|
|
musicGroupSubjectPlanDao.update(musicGroupSubjectPlan);
|
|
@@ -1805,8 +1793,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
amount = amount.add(surplusCourseFee);
|
|
|
}
|
|
|
|
|
|
- StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, SUCCESS);
|
|
|
-
|
|
|
if (studentPaymentOrder != null) {
|
|
|
List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
|
|
|
|
|
@@ -1853,12 +1839,30 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
}
|
|
|
}
|
|
|
amount = amount.add(maintenanceFee);
|
|
|
- if (studentMaintenance != null) {
|
|
|
+ if (maintenanceFee.compareTo(BigDecimal.ZERO) > 0 && studentMaintenance != null) {
|
|
|
studentMaintenance.setDelFlag(1);
|
|
|
studentInstrumentDao.update(studentMaintenance);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //退云教练费用
|
|
|
+ if (cloudTeacherAmount != null) {
|
|
|
+ Date nowDate = new Date();
|
|
|
+ CloudTeacherOrder studentCloudTeacherOrder = cloudTeacherOrderService.getStudentCloudTeacherOrder(userId, musicGroupId);
|
|
|
+ if (cloudTeacherAmount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ if (studentCloudTeacherOrder == null || (studentCloudTeacherOrder.getEndTime() != null && studentCloudTeacherOrder.getEndTime().compareTo(nowDate) <= 0)) {
|
|
|
+ throw new BizException("学生云教练已过有效期,不能退费");
|
|
|
+ }
|
|
|
+ if (cloudTeacherAmount.compareTo(studentCloudTeacherOrder.getAmount()) > 0) {
|
|
|
+ throw new BizException("云教练退费金额不能大于原始订单金额");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ amount = amount.add(cloudTeacherAmount);
|
|
|
+ if (cloudTeacherAmount.compareTo(BigDecimal.ZERO) > 0 && studentCloudTeacherOrder != null) {
|
|
|
+ cloudTeacherOrderService.quitCloudTeacherOrder(studentCloudTeacherOrder, cloudTeacherAmount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (amount.doubleValue() > 0) {
|
|
|
// 增加交易流水
|
|
|
sysUserCashAccountDetailService.addCashAccountDetail(userId, amount, SysUserCashAccountDetailService.MUSIC_GROUP + musicGroupId, "",
|
|
@@ -1871,7 +1875,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
@Override
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
public boolean directQuitMusicGroup(String musicGroupId, Integer userId, String reason, boolean isRefundCourseFee, boolean isRefundInstrumentFee,
|
|
|
- boolean isRefundTeachingAssistantsFee, BigDecimal maintenanceFee) {
|
|
|
+ boolean isRefundTeachingAssistantsFee, BigDecimal maintenanceFee, BigDecimal cloudTeacherAmount) {
|
|
|
|
|
|
SysUser sysUser = sysUserFeignService.queryUserById(userId);
|
|
|
if (sysUser == null) {
|
|
@@ -1899,6 +1903,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
if (studentRegistration == null) {
|
|
|
throw new BizException("用户注册信息不存在");
|
|
|
}
|
|
|
+ boolean hasPaid = studentRegistration.getMusicGroupStatus().equals(StudentMusicGroupStatusEnum.NORMAL);
|
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
@@ -1987,9 +1992,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
|
|
|
BigDecimal amount = new BigDecimal(0);
|
|
|
|
|
|
+ StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, SUCCESS);
|
|
|
+ BigDecimal orderExpectAmount = studentPaymentOrder == null ? BigDecimal.ZERO : studentPaymentOrder.getExpectAmount();
|
|
|
+
|
|
|
// 判断乐器是否是租赁
|
|
|
MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, studentRegistration.getActualSubjectId());
|
|
|
- if (musicGroupSubjectPlan != null) {
|
|
|
+ if (hasPaid && musicGroupSubjectPlan != null && (!musicGroup.getCourseViewType().equals(CourseViewTypeEnum.CLOUD_TEACHER) || orderExpectAmount.compareTo(BigDecimal.ZERO) > 0)) {
|
|
|
musicGroupSubjectPlan.setPaidStudentNum(musicGroupSubjectPlan.getPaidStudentNum() - 1);
|
|
|
musicGroupSubjectPlan.setUpdateTime(date);
|
|
|
musicGroupSubjectPlanDao.update(musicGroupSubjectPlan);
|
|
@@ -2009,8 +2017,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
amount = amount.add(surplusCourseFee);
|
|
|
}
|
|
|
|
|
|
- StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, SUCCESS);
|
|
|
-
|
|
|
if (studentPaymentOrder != null) {
|
|
|
List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
|
|
|
|
|
@@ -2057,12 +2063,30 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
|
|
|
}
|
|
|
}
|
|
|
amount = amount.add(maintenanceFee);
|
|
|
- if (studentMaintenance != null) {
|
|
|
+ if (maintenanceFee.compareTo(BigDecimal.ZERO) > 0 && studentMaintenance != null) {
|
|
|
studentMaintenance.setDelFlag(1);
|
|
|
studentInstrumentDao.update(studentMaintenance);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //退云教练费用
|
|
|
+ if (cloudTeacherAmount != null) {
|
|
|
+ Date nowDate = new Date();
|
|
|
+ CloudTeacherOrder studentCloudTeacherOrder = cloudTeacherOrderService.getStudentCloudTeacherOrder(userId, musicGroupId);
|
|
|
+ if (cloudTeacherAmount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ if (studentCloudTeacherOrder == null || (studentCloudTeacherOrder.getEndTime() != null && studentCloudTeacherOrder.getEndTime().compareTo(nowDate) <= 0)) {
|
|
|
+ throw new BizException("学生云教练已过有效期,不能退费");
|
|
|
+ }
|
|
|
+ if (cloudTeacherAmount.compareTo(studentCloudTeacherOrder.getAmount()) > 0) {
|
|
|
+ throw new BizException("云教练退费金额不能大于原始订单金额");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ amount = amount.add(cloudTeacherAmount);
|
|
|
+ if (cloudTeacherAmount.compareTo(BigDecimal.ZERO) > 0 && studentCloudTeacherOrder != null) {
|
|
|
+ cloudTeacherOrderService.quitCloudTeacherOrder(studentCloudTeacherOrder, cloudTeacherAmount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (amount.doubleValue() > 0) {
|
|
|
// 增加交易流水
|
|
|
sysUserCashAccountDetailService.addCashAccountDetail(userId, amount, SysUserCashAccountDetailService.MUSIC_GROUP + musicGroupId, "",
|