|
@@ -66,10 +66,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
@Autowired
|
|
|
private MusicGroupPaymentCalenderCourseSettingsServiceImpl musicGroupPaymentCalenderCourseSettingsService;
|
|
|
@Autowired
|
|
|
- private MusicGroupOrganizationCourseSettingsDetailDao musicGroupOrganizationCourseSettingsDetailDao;
|
|
|
- @Autowired
|
|
|
- private OrganizationCourseUnitPriceSettingsDao organizationCourseUnitPriceSettingsDao;
|
|
|
- @Autowired
|
|
|
private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
|
|
|
@Autowired
|
|
|
private MusicGroupSchoolTermCourseDetailDao musicGroupSchoolTermCourseDetailDao;
|
|
@@ -120,8 +116,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
@Autowired
|
|
|
private StudentPaymentOrderDao studentPaymentOrderDao;
|
|
|
@Autowired
|
|
|
- private MemberFeeSettingDao memberFeeSettingDao;
|
|
|
- @Autowired
|
|
|
private MemberRankPrivilegesService memberRankPrivilegesService;
|
|
|
@Autowired
|
|
|
private CloudTeacherOrderDao cloudTeacherOrderDao;
|
|
@@ -144,58 +138,19 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String create(MusicGroupPaymentCalenderDto musicGroupPaymentCalenderDto) {
|
|
|
-
|
|
|
- String musicGroupId = musicGroupPaymentCalenderDto.getMusicGroupId();
|
|
|
-
|
|
|
PaymentType paymentType = musicGroupPaymentCalenderDto.getPaymentType();
|
|
|
- if(paymentType == ADD_COURSE || paymentType == MUSIC_APPLY || paymentType == MUSIC_RENEW){
|
|
|
+ if(paymentType != SPAN_GROUP_CLASS_ADJUST){
|
|
|
throw new BizException("操作失败:该入口不支持{}",paymentType.getDesc());
|
|
|
}
|
|
|
-
|
|
|
- PayUserType payUserType = musicGroupPaymentCalenderDto.getPayUserType();
|
|
|
-
|
|
|
List<MusicGroupPaymentDateRange> musicGroupPaymentDateRangeList = musicGroupPaymentCalenderDto.getMusicGroupPaymentDateRangeList();
|
|
|
-
|
|
|
- if(musicGroupPaymentCalenderDto.getMemberRankSettingId() != null){
|
|
|
- if(paymentType != ADD_STUDENT && paymentType != MUSIC_APPLY && paymentType != MUSIC_RENEW){
|
|
|
- throw new BizException("操作失败:{} 不支持会员收费",paymentType.getDesc());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
if(musicGroupPaymentDateRangeList.size() > 1){
|
|
|
throw new BizException("创建缴费失败:不支持多周期缴费");
|
|
|
}
|
|
|
+ String musicGroupId = musicGroupPaymentCalenderDto.getMusicGroupId();
|
|
|
MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
|
|
|
if (musicGroup == null) {
|
|
|
throw new BizException("乐团查询失败,请检查参数");
|
|
|
}
|
|
|
- if (paymentType == PaymentType.ADD_STUDENT) {
|
|
|
- //获取缴费状态在审核中或者已拒绝的缴费项目的学员
|
|
|
- Integer userId = Integer.parseInt(musicGroupPaymentCalenderDto.getStudentIds());
|
|
|
- if(musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE){
|
|
|
- //该学员是否在其他的会员团
|
|
|
- boolean hasMemberGroup = studentRegistrationDao.checkHasMemberGroup(musicGroupId,userId);
|
|
|
- if(hasMemberGroup){
|
|
|
- throw new BizException("操作失败:学员已在其他系统收费乐团中,不可报名该乐团请联系教务老师");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- String studentIds = musicGroupPaymentCalenderDao.queryCalenderStudentIds(musicGroupId,null);
|
|
|
- if(StringUtils.isNotEmpty(studentIds)){
|
|
|
- if(studentIds.contains(userId.toString())){
|
|
|
- throw new BizException("创建缴费失败:所选学员有待审核或已拒绝的缴费项目");
|
|
|
- }
|
|
|
- }
|
|
|
- List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = musicGroupPaymentCalenderDetailDao.queryNotPaymentStudentByUserIdAndMusicGroupId(userId, musicGroupId);
|
|
|
- if(musicGroupPaymentCalenderDetailList != null && musicGroupPaymentCalenderDetailList.size() > 0){
|
|
|
- throw new BizException("创建缴费失败:已存在缴费项目");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (musicGroup.getStatus() != MusicGroupStatusEnum.PROGRESS && musicGroup.getStatus() != MusicGroupStatusEnum.PRE_BUILD_FEE) {
|
|
|
- throw new BizException("创建缴费失败:已存在缴费项目");
|
|
|
- }
|
|
|
-
|
|
|
SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
if (sysUser == null) {
|
|
|
throw new BizException("请登录");
|
|
@@ -208,285 +163,55 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 不是进行中,只能创建一次缴费
|
|
|
- if (musicGroup.getStatus() != MusicGroupStatusEnum.PROGRESS) {
|
|
|
- List<MusicGroupPaymentCalender> list = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
|
|
|
- if (list.size() > 0) {
|
|
|
- throw new BizException("创建失败,已经存在缴费信息");
|
|
|
- }
|
|
|
- }
|
|
|
+ List<MusicGroupPaymentCalenderStudentDetail> calenderStudentDetails = musicGroupPaymentCalenderDto.getMusicGroupPaymentCalenderStudentDetails();
|
|
|
|
|
|
- PaymentCalenderStatusEnum status = PaymentCalenderStatusEnum.NO;
|
|
|
+ PaymentCalenderStatusEnum status = musicGroupPaymentCalenderDto.getStatus();
|
|
|
|
|
|
Date date = new Date();
|
|
|
String batchNo = idGeneratorService.generatorId() + "";
|
|
|
|
|
|
- // 获取设置的课程收费标准
|
|
|
- List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalenderDto
|
|
|
- .getMusicGroupPaymentCalenderCourseSettingsList();
|
|
|
-
|
|
|
- if(musicGroupPaymentCalenderCourseSettingsList != null){
|
|
|
- // 必须课程缴费金额为0时,报名、续费不能建多期
|
|
|
- if(paymentType == MUSIC_APPLY || paymentType == MUSIC_RENEW){
|
|
|
- BigDecimal noOptionalCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream()
|
|
|
- .filter(e -> !e.getIsStudentOptional()).map(MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- if(noOptionalCoursePrice.compareTo(BigDecimal.ZERO) <= 0 && musicGroupPaymentDateRangeList.size() > 1){
|
|
|
- throw new BizException("必选课程缴费金额为0时不支持多周期缴费");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //会员原价
|
|
|
- BigDecimal memberPaymentAmount = BigDecimal.ZERO;
|
|
|
- BigDecimal originalMemberPaymentAmount = BigDecimal.ZERO;
|
|
|
- if (payUserType == SCHOOL) {
|
|
|
- status = AUDITING;
|
|
|
- } else {
|
|
|
- if(musicGroupPaymentCalenderCourseSettingsList != null){
|
|
|
- if (paymentType == MUSIC_APPLY || paymentType == MUSIC_RENEW) {
|
|
|
- // 当前缴费的课程费用
|
|
|
- Map<CourseScheduleType, BigDecimal> currentCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream().collect(
|
|
|
- Collectors
|
|
|
- .toMap(MusicGroupPaymentCalenderCourseSettings::getCourseType, MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice));
|
|
|
-
|
|
|
- // 查询默认课程费用
|
|
|
- Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId();
|
|
|
- Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao
|
|
|
- .queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId)
|
|
|
- .stream()
|
|
|
- .collect(
|
|
|
- Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail::getCourseType,
|
|
|
- MusicGroupOrganizationCourseSettingsDetail::getCourseCurrentPrice));
|
|
|
-
|
|
|
- // 相同类型的课程如果修改了课程费用,需要走审批
|
|
|
- for (Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()) {
|
|
|
- if (defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0) {
|
|
|
- status = AUDITING;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (paymentType == PaymentType.ADD_COURSE || paymentType == PaymentType.ADD_STUDENT) {
|
|
|
- PaymentCalenderStatusEnum dtoStatus = musicGroupPaymentCalenderDto.getStatus();
|
|
|
- if(dtoStatus != null && dtoStatus == AUDITING){
|
|
|
- status = AUDITING;
|
|
|
- }else {
|
|
|
- // 如果是课程收费,判断是否审核
|
|
|
- for (MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList) {
|
|
|
- OrganizationCourseUnitPriceSettings defaultUnitPrice = organizationCourseUnitPriceSettingsDao.queryByOrganIdAndCourseTypeAndChargeType(
|
|
|
- musicGroup.getOrganId(), courseSettings.getCourseType(), musicGroup.getChargeTypeId());
|
|
|
- if (defaultUnitPrice == null) {
|
|
|
- throw new BizException("请先设置分部课程类型单价");
|
|
|
- }
|
|
|
- if (courseSettings.getCourseTotalMinuties() != 0) {
|
|
|
-
|
|
|
- if (defaultUnitPrice.getUnitPrice().multiply(new BigDecimal(courseSettings.getCourseTotalMinuties())).setScale(0, BigDecimal.ROUND_HALF_UP)
|
|
|
- .compareTo(courseSettings.getCourseCurrentPrice()) != 0) {
|
|
|
-
|
|
|
- status = AUDITING;
|
|
|
- break;
|
|
|
- }
|
|
|
- } else {
|
|
|
- status = AUDITING;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }else if(paymentType == SPAN_GROUP_CLASS_ADJUST){
|
|
|
- status = musicGroupPaymentCalenderDto.getStatus();
|
|
|
- }
|
|
|
- }
|
|
|
- if(musicGroupPaymentCalenderDto.getMemberRankSettingId() != null){
|
|
|
- //会员价格是否变动
|
|
|
- MemberFeeSetting memberFee = memberFeeSettingDao.findByRankIdAndOrganId(musicGroup.getOrganId(), musicGroupPaymentCalenderDto.getMemberRankSettingId());
|
|
|
- if(memberFee == null){
|
|
|
- throw new BizException("操作失败:请配置当前分部会员收费标准");
|
|
|
- }
|
|
|
- switch (musicGroupPaymentCalenderDto.getMemberValidDate()){
|
|
|
- case 1 :
|
|
|
- memberPaymentAmount = memberFee.getGroupPurchaseMonthFee().setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
- originalMemberPaymentAmount = memberFee.getOriginalMonthFee().setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
- break;
|
|
|
- case 6 :
|
|
|
- memberPaymentAmount = memberFee.getGroupPurchaseHalfYearFee().setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
- originalMemberPaymentAmount = memberFee.getOriginalHalfYearFee().setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
- break;
|
|
|
- case 12 :
|
|
|
- memberPaymentAmount = memberFee.getGroupPurchaseYearFee().setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
- originalMemberPaymentAmount = memberFee.getOriginalYearFee().setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
- break;
|
|
|
- default:
|
|
|
- throw new BizException("请选择正确的会员有效期");
|
|
|
- }
|
|
|
- if(memberPaymentAmount.compareTo(musicGroupPaymentCalenderDto.getMemberPaymentAmount()) != 0){
|
|
|
- status = AUDITING;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- int times = musicGroupPaymentDateRangeList.size();
|
|
|
-
|
|
|
- // 排序
|
|
|
- Collections.sort(musicGroupPaymentDateRangeList, new Comparator<MusicGroupPaymentDateRange>() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public int compare(MusicGroupPaymentDateRange o1, MusicGroupPaymentDateRange o2) {
|
|
|
- return o1.getPaymentValidStartDate().compareTo(o2.getPaymentValidStartDate());
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- for (int i = 0; i < musicGroupPaymentDateRangeList.size(); i++) {
|
|
|
-
|
|
|
- MusicGroupPaymentDateRange musicGroupPaymentDateRange = musicGroupPaymentDateRangeList.get(i);
|
|
|
-
|
|
|
- MusicGroupPaymentCalender musicGroupPaymentCalender = new MusicGroupPaymentCalender();
|
|
|
- musicGroupPaymentCalender.setAttribute1(musicGroupPaymentCalenderDto.getAttribute1());
|
|
|
- musicGroupPaymentCalender.setOriginalMemberPaymentAmount(originalMemberPaymentAmount);
|
|
|
- musicGroupPaymentCalender.setAttribute2(musicGroupPaymentCalenderDto.getAttribute2());
|
|
|
- musicGroupPaymentCalender.setDeadlinePaymentDate(musicGroupPaymentDateRange.getDeadlinePaymentDate());
|
|
|
-// musicGroupPaymentCalender.setIsGiveMusicNetwork(musicGroupPaymentCalenderDto.getIsGiveMusicNetwork());
|
|
|
- musicGroupPaymentCalender.setMemo(musicGroupPaymentCalenderDto.getMemo());
|
|
|
- musicGroupPaymentCalender.setMusicGroupId(musicGroupId);
|
|
|
- musicGroupPaymentCalender.setMusicGroupOrganizationCourseSettingId(musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId());
|
|
|
-
|
|
|
- BigDecimal totalPaymentAmount = musicGroupPaymentCalenderDto.getMasterTotalPrice();
|
|
|
- if(musicGroupPaymentCalenderCourseSettingsList != null){
|
|
|
- List<MusicGroupPaymentCalenderCourseSettings> newCSList = new ArrayList<MusicGroupPaymentCalenderCourseSettings>(
|
|
|
- musicGroupPaymentCalenderCourseSettingsList.size());
|
|
|
- for (MusicGroupPaymentCalenderCourseSettings pccs : musicGroupPaymentCalenderCourseSettingsList) {
|
|
|
-
|
|
|
- MusicGroupPaymentCalenderCourseSettings tempPccs = new MusicGroupPaymentCalenderCourseSettings();
|
|
|
- try {
|
|
|
- BeanUtils.copyProperties(tempPccs, pccs);
|
|
|
- } catch (Exception e) {
|
|
|
- throw new BizException("克隆对象出错", e);
|
|
|
- }
|
|
|
- if (i == 0) {
|
|
|
- if (pccs.getIsStudentOptional()) {
|
|
|
- tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice());
|
|
|
- tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice());
|
|
|
- tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties());
|
|
|
- } else {
|
|
|
- tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().subtract(
|
|
|
- pccs.getCourseCurrentPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
|
|
|
- .setScale(0, BigDecimal.ROUND_DOWN)));
|
|
|
- tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().subtract(
|
|
|
- pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
|
|
|
- .setScale(0, BigDecimal.ROUND_DOWN)));
|
|
|
- tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() - pccs.getCourseTotalMinuties() / times * (times - 1));
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (!pccs.getIsStudentOptional()) {
|
|
|
- tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN));
|
|
|
- tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN));
|
|
|
- tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() / times);
|
|
|
- } else {
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- totalPaymentAmount = totalPaymentAmount.add(tempPccs.getCourseCurrentPrice());
|
|
|
- newCSList.add(tempPccs);
|
|
|
- }
|
|
|
- musicGroupPaymentCalender.setMusicGroupPaymentCalenderCourseSettingsList(newCSList);
|
|
|
- musicGroupPaymentCalender.setCurrentTotalAmount(musicGroupPaymentCalenderCourseSettingsList.stream().map(e->e.getCourseCurrentPrice()).reduce(BigDecimal.ZERO,BigDecimal::add));
|
|
|
- }
|
|
|
- musicGroupPaymentCalender.setOriginalTotalAmount(musicGroupPaymentCalenderDto.getOriginalAmount());
|
|
|
-
|
|
|
- if (paymentType == PaymentType.MUSIC_APPLY) {
|
|
|
- if (i == 0) {
|
|
|
- musicGroupPaymentCalender.setPaymentType(paymentType);
|
|
|
- } else {
|
|
|
- musicGroupPaymentCalender.setPaymentType(PaymentType.MUSIC_RENEW);
|
|
|
- }
|
|
|
+ MusicGroupPaymentDateRange musicGroupPaymentDateRange = musicGroupPaymentDateRangeList.get(0);
|
|
|
+ MusicGroupPaymentCalender musicGroupPaymentCalender = new MusicGroupPaymentCalender();
|
|
|
+ musicGroupPaymentCalender.setAttribute1(musicGroupPaymentCalenderDto.getAttribute1());
|
|
|
+ musicGroupPaymentCalender.setAttribute2(musicGroupPaymentCalenderDto.getAttribute2());
|
|
|
+ musicGroupPaymentCalender.setDeadlinePaymentDate(musicGroupPaymentDateRange.getDeadlinePaymentDate());
|
|
|
+ musicGroupPaymentCalender.setMemo(musicGroupPaymentCalenderDto.getMemo());
|
|
|
+ musicGroupPaymentCalender.setMusicGroupId(musicGroupId);
|
|
|
+ musicGroupPaymentCalender.setMusicGroupOrganizationCourseSettingId(musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId());
|
|
|
+
|
|
|
+ musicGroupPaymentCalender.setOriginalTotalAmount(calenderStudentDetails.stream().map(e->e.getCourseOriginalPrice()).reduce(BigDecimal.ZERO,BigDecimal::add));
|
|
|
+ musicGroupPaymentCalender.setCurrentTotalAmount(calenderStudentDetails.stream().map(e->e.getCourseCurrentPrice()).reduce(BigDecimal.ZERO,BigDecimal::add));
|
|
|
+ musicGroupPaymentCalender.setPaymentType(paymentType);
|
|
|
+ musicGroupPaymentCalender.setPayUserType(musicGroupPaymentCalenderDto.getPayUserType());
|
|
|
+ musicGroupPaymentCalender.setStartPaymentDate(musicGroupPaymentDateRange.getStartPaymentDate());
|
|
|
+ musicGroupPaymentCalender.setStudentIds(musicGroupPaymentCalenderDto.getStudentIds());
|
|
|
+ musicGroupPaymentCalender.setOperator(sysUser.getId());
|
|
|
+ musicGroupPaymentCalender.setCreateTime(date);
|
|
|
+ musicGroupPaymentCalender.setUpdateTime(date);
|
|
|
+ musicGroupPaymentCalender.setStatus(status);
|
|
|
+ musicGroupPaymentCalender.setOrganId(musicGroup.getOrganId());
|
|
|
+ if (musicGroupPaymentCalender.getStatus() != AUDITING) {
|
|
|
+ if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
|
|
|
+ musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
|
|
|
+ } else if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
|
|
|
+ musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
|
|
|
} else {
|
|
|
- musicGroupPaymentCalender.setPaymentType(paymentType);
|
|
|
- }
|
|
|
- musicGroupPaymentCalender.setPayUserType(musicGroupPaymentCalenderDto.getPayUserType());
|
|
|
- musicGroupPaymentCalender.setStartPaymentDate(musicGroupPaymentDateRange.getStartPaymentDate());
|
|
|
- musicGroupPaymentCalender.setStudentIds(musicGroupPaymentCalenderDto.getStudentIds());
|
|
|
- musicGroupPaymentCalender.setOperator(sysUser.getId());
|
|
|
- musicGroupPaymentCalender.setCreateTime(date);
|
|
|
- musicGroupPaymentCalender.setUpdateTime(date);
|
|
|
- musicGroupPaymentCalender.setStatus(status);
|
|
|
- musicGroupPaymentCalender.setOrganId(musicGroup.getOrganId());
|
|
|
-
|
|
|
- //缴费截止日期默认三天后
|
|
|
- if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null && payUserType == PayUserType.STUDENT) {
|
|
|
- musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
|
|
|
- }
|
|
|
-
|
|
|
- if (paymentType == PaymentType.ADD_STUDENT) {
|
|
|
- musicGroupPaymentCalender.setPayUserType(STUDENT);
|
|
|
- if (musicGroupPaymentCalender.getStatus() != AUDITING) {
|
|
|
- musicGroupPaymentCalender.setExpectNum(1);
|
|
|
- }
|
|
|
- }
|
|
|
- if (musicGroupPaymentCalender.getStatus() != AUDITING) {
|
|
|
- if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
|
|
|
- musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
|
|
|
- } else if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
|
|
|
- musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
|
|
|
- } else {
|
|
|
- musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 设置批次号
|
|
|
- musicGroupPaymentCalender.setBatchNo(batchNo);
|
|
|
- musicGroupPaymentCalenderDto.setBatchNo(batchNo);
|
|
|
- musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
|
|
|
-
|
|
|
- //课程费用列表
|
|
|
- musicGroupPaymentCalenderCourseSettingsService.batchInsert(musicGroupPaymentCalender);
|
|
|
-
|
|
|
- //如果是跨团班级合并,保存用户缴费详情
|
|
|
- List<MusicGroupPaymentCalenderStudentDetail> musicGroupPaymentCalenderStudentDetails = null;
|
|
|
- if (musicGroupPaymentCalender.getPaymentType() == SPAN_GROUP_CLASS_ADJUST){
|
|
|
- musicGroupPaymentCalenderStudentDetails = musicGroupPaymentCalenderDto.getMusicGroupPaymentCalenderStudentDetails();
|
|
|
- //记录学员缴费详情
|
|
|
- musicGroupPaymentCalenderStudentDetailDao.batchInsert(musicGroupPaymentCalenderStudentDetails,musicGroupPaymentCalender.getBatchNo());
|
|
|
- }
|
|
|
-
|
|
|
- if (musicGroupPaymentCalender.getStatus() != AUDITING) {
|
|
|
- // 如果是进行中加学生
|
|
|
- if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
|
|
|
- addStudent(musicGroupPaymentCalender, musicGroupPaymentCalender
|
|
|
- .getMusicGroupPaymentCalenderCourseSettingsList(),musicGroup);
|
|
|
- }else if(musicGroupPaymentCalender.getPaymentType() == SPAN_GROUP_CLASS_ADJUST){
|
|
|
- //如果是跨团班级合并,添加学员
|
|
|
- musicGroupPaymentCalenderDetailService.batchAdd(musicGroupPaymentCalender,musicGroupPaymentCalenderStudentDetails);
|
|
|
- }else if(musicGroupPaymentCalenderDto.getMergeClassFlag()){
|
|
|
- //缴费项目添加学员
|
|
|
- int[] ints = Arrays.stream(musicGroupPaymentCalenderDto.getStudentIds().split(",")).mapToInt(Integer::parseInt).toArray();
|
|
|
- Set<Integer> list2 = Arrays.stream(ints).boxed().collect(Collectors.toSet());
|
|
|
- musicGroupPaymentCalenderDetailService.batchAdd(musicGroupPaymentCalender.getId(),list2,musicGroup,false);
|
|
|
- }
|
|
|
- //将0元未缴费学员缴费状态更新为已缴费
|
|
|
- this.updateNoPaymentAndZeroPaymentStatus(musicGroupPaymentCalender,true);
|
|
|
+ musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // 如果是报名,需要修改乐团状态
|
|
|
- if (paymentType == MUSIC_APPLY) {
|
|
|
- if (status != AUDITING) {
|
|
|
- musicGroup.setStatus(MusicGroupStatusEnum.APPLY);
|
|
|
- // 记录操作日志
|
|
|
- musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功(创建缴费 -> 报名中)", sysUser.getId(), ""));
|
|
|
- } else {
|
|
|
- musicGroup.setStatus(MusicGroupStatusEnum.FEE_AUDIT);
|
|
|
- // 记录操作日志
|
|
|
- musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功(创建缴费 -> 费用审核中)", sysUser.getId(), ""));
|
|
|
- }
|
|
|
- musicGroup.setUpdateTime(date);
|
|
|
- musicGroupDao.update(musicGroup);
|
|
|
- } else if (paymentType == ADD_STUDENT) {
|
|
|
- if (status != AUDITING) {
|
|
|
- // 学生加到班级
|
|
|
- String classGroupIdStr = musicGroupPaymentCalenderDto.getAttribute1();
|
|
|
- classGroupService.addStudentToClassGroupAndCourseArranging(Integer.parseInt(musicGroupPaymentCalenderDto.getStudentIds()), classGroupIdStr,
|
|
|
- batchNo, musicGroupPaymentCalenderCourseSettingsList,musicGroup);
|
|
|
- }
|
|
|
+ // 设置批次号
|
|
|
+ musicGroupPaymentCalender.setBatchNo(batchNo);
|
|
|
+ musicGroupPaymentCalenderDto.setBatchNo(batchNo);
|
|
|
+ musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
|
|
|
+ //如果是跨团班级合并,保存用户缴费详情
|
|
|
+ //记录学员缴费详情
|
|
|
+ musicGroupPaymentCalenderStudentDetailDao.batchInsert(musicGroupPaymentCalenderDto.getMusicGroupPaymentCalenderStudentDetails(),musicGroupPaymentCalender.getBatchNo());
|
|
|
+ if (musicGroupPaymentCalender.getStatus() != AUDITING) {
|
|
|
+ //如果是跨团班级合并,添加学员
|
|
|
+ musicGroupPaymentCalenderDetailService.batchAdd(musicGroupPaymentCalender,musicGroupPaymentCalenderDto.getMusicGroupPaymentCalenderStudentDetails());
|
|
|
+ //将0元未缴费学员缴费状态更新为已缴费
|
|
|
+ this.updateNoPaymentAndZeroPaymentStatus(musicGroupPaymentCalender,true);
|
|
|
}
|
|
|
-
|
|
|
if (status == AUDITING) {
|
|
|
// 如果是审核中
|
|
|
Organization organization = organizationDao.get(musicGroup.getOrganId());
|
|
@@ -495,7 +220,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
}else {
|
|
|
imUserFriendService.refreshGroupImUserFriend(musicGroupId, GroupType.MUSIC);
|
|
|
}
|
|
|
-
|
|
|
return batchNo;
|
|
|
}
|
|
|
|
|
@@ -795,31 +519,21 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
if(musicGroupPaymentCalenderList == null || musicGroupPaymentCalenderList.size() == 0){
|
|
|
throw new BizException("[批次号]参数错误");
|
|
|
}
|
|
|
-
|
|
|
PaymentCalenderStatusEnum status = musicGroupPaymentCalenderList.get(0).getStatus();
|
|
|
if(status != PaymentCalenderStatusEnum.REJECT && status != PaymentCalenderStatusEnum.DRAFT){
|
|
|
throw new BizException("{}的缴费状态不允许修改",status.getDesc());
|
|
|
}
|
|
|
- String musicGroupId = musicGroupPaymentCalenderDto.getMusicGroupId();
|
|
|
-
|
|
|
PaymentType paymentType = musicGroupPaymentCalenderDto.getPaymentType();
|
|
|
-
|
|
|
- PayUserType payUserType = musicGroupPaymentCalenderDto.getPayUserType();
|
|
|
-
|
|
|
- List<MusicGroupPaymentDateRange> musicGroupPaymentDateRangeList = musicGroupPaymentCalenderDto.getMusicGroupPaymentDateRangeList();
|
|
|
-
|
|
|
- if(musicGroupPaymentCalenderDto.getMemberRankSettingId() != null){
|
|
|
- if(paymentType != ADD_STUDENT && paymentType != MUSIC_APPLY && paymentType != MUSIC_RENEW){
|
|
|
- throw new BizException("操作失败:{} 不支持会员收费",paymentType.getDesc());
|
|
|
- }
|
|
|
+ if(paymentType != SPAN_GROUP_CLASS_ADJUST){
|
|
|
+ throw new BizException("操作失败:该入口不支持{}",paymentType.getDesc());
|
|
|
}
|
|
|
-
|
|
|
- if ((paymentType == PaymentType.ADD_COURSE) && musicGroupPaymentDateRangeList.size() > 1) {
|
|
|
- throw new BizException("[临时加课]不支持多周期缴费");
|
|
|
+ List<MusicGroupPaymentDateRange> musicGroupPaymentDateRangeList = musicGroupPaymentCalenderDto.getMusicGroupPaymentDateRangeList();
|
|
|
+ if(musicGroupPaymentDateRangeList.size() > 1){
|
|
|
+ throw new BizException("创建缴费失败:不支持多周期缴费");
|
|
|
}
|
|
|
+ String musicGroupId = musicGroupPaymentCalenderDto.getMusicGroupId();
|
|
|
|
|
|
MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
|
|
|
-
|
|
|
if (musicGroup == null) {
|
|
|
throw new BizException("乐团查询失败,请检查参数");
|
|
|
}
|
|
@@ -827,9 +541,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
if (sysUser == null) {
|
|
|
throw new BizException("请登录");
|
|
|
}
|
|
|
- if (musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE && musicGroupPaymentDateRangeList.size() > 1) {
|
|
|
- throw new BizException("创建缴费失败:会员收费乐团不支持多周期缴费");
|
|
|
- }
|
|
|
|
|
|
List<Long> calenderIds = musicGroupPaymentCalenderList.stream().map(MusicGroupPaymentCalender :: getId).collect(Collectors.toList());
|
|
|
//删除原来数据
|
|
@@ -840,281 +551,82 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
|
- // 获取设置的课程
|
|
|
- List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalenderDto
|
|
|
- .getMusicGroupPaymentCalenderCourseSettingsList();
|
|
|
-
|
|
|
- //会员原价
|
|
|
- BigDecimal memberPaymentAmount = BigDecimal.ZERO;
|
|
|
- BigDecimal originalMemberPaymentAmount = BigDecimal.ZERO;
|
|
|
- if (payUserType == SCHOOL) {
|
|
|
- status = AUDITING;
|
|
|
- } else {
|
|
|
- if(musicGroupPaymentCalenderCourseSettingsList != null){
|
|
|
- if (paymentType == MUSIC_APPLY || paymentType == MUSIC_RENEW) {
|
|
|
- // 当前缴费的课程费用
|
|
|
- Map<CourseScheduleType, BigDecimal> currentCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream().collect(
|
|
|
- Collectors
|
|
|
- .toMap(MusicGroupPaymentCalenderCourseSettings::getCourseType, MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice));
|
|
|
-
|
|
|
- // 查询默认课程费用
|
|
|
- Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId();
|
|
|
- Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao
|
|
|
- .queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId)
|
|
|
- .stream()
|
|
|
- .collect(
|
|
|
- Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail::getCourseType,
|
|
|
- MusicGroupOrganizationCourseSettingsDetail::getCourseCurrentPrice));
|
|
|
-
|
|
|
- // 相同类型的课程如果修改了课程费用,需要走审批
|
|
|
- for (Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()) {
|
|
|
- if (defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0) {
|
|
|
- status = AUDITING;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (paymentType == PaymentType.ADD_COURSE || paymentType == PaymentType.ADD_STUDENT) {
|
|
|
- // 如果是临时加课,判断是否审核
|
|
|
- for (MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList) {
|
|
|
- OrganizationCourseUnitPriceSettings defaultUnitPrice = organizationCourseUnitPriceSettingsDao.queryByOrganIdAndCourseTypeAndChargeType(
|
|
|
- musicGroup.getOrganId(), courseSettings.getCourseType(), musicGroup.getChargeTypeId());
|
|
|
- if (defaultUnitPrice == null) {
|
|
|
- throw new BizException("请先设置分部课程类型单价");
|
|
|
- }
|
|
|
- if (courseSettings.getCourseTotalMinuties() != 0) {
|
|
|
- if (defaultUnitPrice.getUnitPrice().multiply(new BigDecimal(courseSettings.getCourseTotalMinuties())).setScale(0, BigDecimal.ROUND_HALF_UP)
|
|
|
- .compareTo(courseSettings.getCourseCurrentPrice()) != 0) {
|
|
|
-
|
|
|
- status = AUDITING;
|
|
|
- break;
|
|
|
- }
|
|
|
- } else {
|
|
|
- status = AUDITING;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }else if(paymentType == SPAN_GROUP_CLASS_ADJUST){
|
|
|
- MusicGroupStudentClassAdjust adjust = musicGroupStudentClassAdjustDao.findByBatchNo(batchNo);
|
|
|
- //获取默认的学员缴费详情
|
|
|
- List<Integer> studentIdList = JSON.parseArray(adjust.getStudentIds(), Integer.class);
|
|
|
- //获取欠费学员列表
|
|
|
- List<Integer> noPaymentUserIds = musicGroupPaymentCalenderDetailDao.queryNoPaymentUserIds(musicGroup.getId(), studentIdList);
|
|
|
- if(noPaymentUserIds.size() > 0){
|
|
|
- throw new BizException("操作失败:有欠费的学员不允许创建缴费");
|
|
|
- }
|
|
|
- //获取缴费状态在审核中或者已拒绝的缴费项目的学员
|
|
|
- String studentIds = musicGroupPaymentCalenderDao.queryCalenderStudentIds(musicGroupId,batchNo);
|
|
|
- if(StringUtils.isNotEmpty(studentIds)){
|
|
|
- for (Integer integer : studentIdList) {
|
|
|
- if(studentIds.contains(integer.toString())){
|
|
|
- throw new BizException("操作失败:所选学员有待审核或已拒绝的缴费项目");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- List<MusicGroupPaymentCalenderStudentDetail> musicGroupPaymentCalenderStudentDetails = classGroupService.queryStudentPaymentCalenders(adjust.getMasterClassGroupId(),
|
|
|
- adjust.getClassGroupStudents(),studentIdList);
|
|
|
- List<MusicGroupPaymentCalenderStudentDetail> calenderStudentDetails = musicGroupPaymentCalenderDto.getMusicGroupPaymentCalenderStudentDetails();
|
|
|
-
|
|
|
- boolean containsAll = musicGroupPaymentCalenderStudentDetails.containsAll(calenderStudentDetails);
|
|
|
- if(!containsAll){
|
|
|
- status = AUDITING;
|
|
|
- //保存新的学员详情
|
|
|
- }
|
|
|
- //删除之前的记录
|
|
|
- musicGroupPaymentCalenderStudentDetailDao.delByBatchNo(batchNo);
|
|
|
- //保存现有记录
|
|
|
- musicGroupPaymentCalenderStudentDetailDao.batchInsert(calenderStudentDetails,batchNo);
|
|
|
- }
|
|
|
- }
|
|
|
- if(musicGroupPaymentCalenderDto.getMemberRankSettingId() != null){
|
|
|
- //会员价格是否变动
|
|
|
- MemberFeeSetting memberFee = memberFeeSettingDao.findByRankIdAndOrganId(musicGroup.getOrganId(), musicGroupPaymentCalenderDto.getMemberRankSettingId());
|
|
|
- if(memberFee == null){
|
|
|
- throw new BizException("操作失败:请配置当前分部会员收费标准");
|
|
|
- }
|
|
|
- switch (musicGroupPaymentCalenderDto.getMemberValidDate()){
|
|
|
- case 1 :
|
|
|
- memberPaymentAmount = memberFee.getGroupPurchaseMonthFee().setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
- originalMemberPaymentAmount = memberFee.getOriginalMonthFee().setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
- break;
|
|
|
- case 6 :
|
|
|
- memberPaymentAmount = memberFee.getGroupPurchaseHalfYearFee().setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
- originalMemberPaymentAmount = memberFee.getOriginalHalfYearFee().setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
- break;
|
|
|
- case 12 :
|
|
|
- memberPaymentAmount = memberFee.getGroupPurchaseYearFee().setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
- originalMemberPaymentAmount = memberFee.getOriginalYearFee().setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
- break;
|
|
|
- default:
|
|
|
- throw new BizException("请选择正确的会员有效期");
|
|
|
- }
|
|
|
- if(memberPaymentAmount.compareTo(musicGroupPaymentCalenderDto.getMemberPaymentAmount()) != 0){
|
|
|
- status = AUDITING;
|
|
|
+ MusicGroupStudentClassAdjust adjust = musicGroupStudentClassAdjustDao.findByBatchNo(batchNo);
|
|
|
+ //获取默认的学员缴费详情
|
|
|
+ List<Integer> studentIdList = JSON.parseArray(adjust.getStudentIds(), Integer.class);
|
|
|
+ //获取欠费学员列表
|
|
|
+ List<Integer> noPaymentUserIds = musicGroupPaymentCalenderDetailDao.queryNoPaymentUserIds(musicGroup.getId(), studentIdList);
|
|
|
+ if(noPaymentUserIds.size() > 0){
|
|
|
+ throw new BizException("操作失败:有欠费的学员不允许创建缴费");
|
|
|
+ }
|
|
|
+ //获取缴费状态在审核中或者已拒绝的缴费项目的学员
|
|
|
+ String studentIds = musicGroupPaymentCalenderDao.queryCalenderStudentIds(musicGroupId,batchNo);
|
|
|
+ if(StringUtils.isNotEmpty(studentIds)){
|
|
|
+ for (Integer integer : studentIdList) {
|
|
|
+ if(studentIds.contains(integer.toString())){
|
|
|
+ throw new BizException("操作失败:所选学员有待审核或已拒绝的缴费项目");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- int times = musicGroupPaymentDateRangeList.size();
|
|
|
-
|
|
|
- // 排序
|
|
|
- Collections.sort(musicGroupPaymentDateRangeList, new Comparator<MusicGroupPaymentDateRange>() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public int compare(MusicGroupPaymentDateRange o1, MusicGroupPaymentDateRange o2) {
|
|
|
- return o1.getPaymentValidStartDate().compareTo(o2.getPaymentValidStartDate());
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- for (int i = 0; i < musicGroupPaymentDateRangeList.size(); i++) {
|
|
|
-
|
|
|
- MusicGroupPaymentDateRange musicGroupPaymentDateRange = musicGroupPaymentDateRangeList.get(i);
|
|
|
-
|
|
|
- MusicGroupPaymentCalender musicGroupPaymentCalender = new MusicGroupPaymentCalender();
|
|
|
- musicGroupPaymentCalender.setAttribute1(musicGroupPaymentCalenderDto.getAttribute1());
|
|
|
- musicGroupPaymentCalender.setAttribute2(musicGroupPaymentCalenderDto.getAttribute2());
|
|
|
- musicGroupPaymentCalender.setOriginalMemberPaymentAmount(originalMemberPaymentAmount);
|
|
|
- musicGroupPaymentCalender.setDeadlinePaymentDate(musicGroupPaymentDateRange.getDeadlinePaymentDate());
|
|
|
-// musicGroupPaymentCalender.setIsGiveMusicNetwork(musicGroupPaymentCalenderDto.getIsGiveMusicNetwork());
|
|
|
- musicGroupPaymentCalender.setMemo(musicGroupPaymentCalenderDto.getMemo());
|
|
|
- musicGroupPaymentCalender.setMusicGroupId(musicGroupId);
|
|
|
- musicGroupPaymentCalender.setMusicGroupOrganizationCourseSettingId(musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId());
|
|
|
- BigDecimal totalPaymentAmount = BigDecimal.ZERO;
|
|
|
- if(musicGroupPaymentCalenderCourseSettingsList != null){
|
|
|
- List<MusicGroupPaymentCalenderCourseSettings> newCSList = new ArrayList<MusicGroupPaymentCalenderCourseSettings>(
|
|
|
- musicGroupPaymentCalenderCourseSettingsList.size());
|
|
|
-
|
|
|
- if(musicGroupPaymentCalenderDto.getPaymentType() == SPAN_GROUP_CLASS_ADJUST){
|
|
|
- totalPaymentAmount = musicGroupPaymentDateRange.getPaymentAmount();
|
|
|
- }
|
|
|
- for (MusicGroupPaymentCalenderCourseSettings pccs : musicGroupPaymentCalenderCourseSettingsList) {
|
|
|
+ List<MusicGroupPaymentCalenderStudentDetail> musicGroupPaymentCalenderStudentDetails = classGroupService.queryStudentPaymentCalenders(adjust.getMasterClassGroupId(),
|
|
|
+ adjust.getClassGroupStudents(),studentIdList);
|
|
|
+ List<MusicGroupPaymentCalenderStudentDetail> calenderStudentDetails = musicGroupPaymentCalenderDto.getMusicGroupPaymentCalenderStudentDetails();
|
|
|
|
|
|
- MusicGroupPaymentCalenderCourseSettings tempPccs = new MusicGroupPaymentCalenderCourseSettings();
|
|
|
- try {
|
|
|
- BeanUtils.copyProperties(tempPccs, pccs);
|
|
|
- } catch (Exception e) {
|
|
|
- throw new BizException("克隆对象出错", e);
|
|
|
- }
|
|
|
- if (i == 0) {
|
|
|
- if (pccs.getIsStudentOptional()) {
|
|
|
- tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice());
|
|
|
- tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice());
|
|
|
- tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties());
|
|
|
- } else {
|
|
|
- tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().subtract(
|
|
|
- pccs.getCourseCurrentPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
|
|
|
- .setScale(0, BigDecimal.ROUND_DOWN)));
|
|
|
- tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().subtract(
|
|
|
- pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
|
|
|
- .setScale(0, BigDecimal.ROUND_DOWN)));
|
|
|
- tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() - pccs.getCourseTotalMinuties() / times * (times - 1));
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (!pccs.getIsStudentOptional()) {
|
|
|
- tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN));
|
|
|
- tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN));
|
|
|
- tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() / times);
|
|
|
- } else {
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- totalPaymentAmount = totalPaymentAmount.add(tempPccs.getCourseCurrentPrice());
|
|
|
- newCSList.add(tempPccs);
|
|
|
- }
|
|
|
- musicGroupPaymentCalender.setMusicGroupPaymentCalenderCourseSettingsList(newCSList);
|
|
|
- }
|
|
|
-
|
|
|
- musicGroupPaymentCalender.setCurrentTotalAmount(totalPaymentAmount);
|
|
|
+ boolean containsAll = musicGroupPaymentCalenderStudentDetails.containsAll(calenderStudentDetails);
|
|
|
+ if(!containsAll){
|
|
|
+ status = AUDITING;
|
|
|
+ }
|
|
|
+ //删除之前的记录
|
|
|
+ musicGroupPaymentCalenderStudentDetailDao.delByBatchNo(batchNo);
|
|
|
+ //保存现有记录
|
|
|
+ musicGroupPaymentCalenderStudentDetailDao.batchInsert(calenderStudentDetails,batchNo);
|
|
|
|
|
|
- if (paymentType == PaymentType.MUSIC_APPLY) {
|
|
|
- if (i == 0) {
|
|
|
- musicGroupPaymentCalender.setPaymentType(paymentType);
|
|
|
- } else {
|
|
|
- musicGroupPaymentCalender.setPaymentType(PaymentType.MUSIC_RENEW);
|
|
|
- }
|
|
|
+ MusicGroupPaymentDateRange musicGroupPaymentDateRange = musicGroupPaymentDateRangeList.get(0);
|
|
|
+ MusicGroupPaymentCalender musicGroupPaymentCalender = new MusicGroupPaymentCalender();
|
|
|
+ musicGroupPaymentCalender.setAttribute1(musicGroupPaymentCalenderDto.getAttribute1());
|
|
|
+ musicGroupPaymentCalender.setAttribute2(musicGroupPaymentCalenderDto.getAttribute2());
|
|
|
+ musicGroupPaymentCalender.setDeadlinePaymentDate(musicGroupPaymentDateRange.getDeadlinePaymentDate());
|
|
|
+ musicGroupPaymentCalender.setMemo(musicGroupPaymentCalenderDto.getMemo());
|
|
|
+ musicGroupPaymentCalender.setMusicGroupId(musicGroupId);
|
|
|
+ musicGroupPaymentCalender.setMusicGroupOrganizationCourseSettingId(musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId());
|
|
|
+ musicGroupPaymentCalender.setOriginalTotalAmount(calenderStudentDetails.stream().map(e->e.getCourseOriginalPrice()).reduce(BigDecimal.ZERO,BigDecimal::add));
|
|
|
+ musicGroupPaymentCalender.setCurrentTotalAmount(calenderStudentDetails.stream().map(e->e.getCourseCurrentPrice()).reduce(BigDecimal.ZERO,BigDecimal::add));
|
|
|
+ musicGroupPaymentCalender.setPaymentType(paymentType);
|
|
|
+ musicGroupPaymentCalender.setPayUserType(musicGroupPaymentCalenderDto.getPayUserType());
|
|
|
+ musicGroupPaymentCalender.setStartPaymentDate(musicGroupPaymentDateRange.getStartPaymentDate());
|
|
|
+ musicGroupPaymentCalender.setStudentIds(musicGroupPaymentCalenderDto.getStudentIds());
|
|
|
+ musicGroupPaymentCalender.setOperator(sysUser.getId());
|
|
|
+ musicGroupPaymentCalender.setCreateTime(date);
|
|
|
+ musicGroupPaymentCalender.setUpdateTime(date);
|
|
|
+ musicGroupPaymentCalender.setStatus(status);
|
|
|
+ musicGroupPaymentCalender.setOrganId(musicGroup.getOrganId());
|
|
|
+ if (musicGroupPaymentCalender.getStatus() != AUDITING) {
|
|
|
+ if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
|
|
|
+ musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
|
|
|
+ } else if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
|
|
|
+ musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
|
|
|
} else {
|
|
|
- musicGroupPaymentCalender.setPaymentType(paymentType);
|
|
|
- }
|
|
|
- musicGroupPaymentCalender.setPayUserType(musicGroupPaymentCalenderDto.getPayUserType());
|
|
|
- musicGroupPaymentCalender.setStartPaymentDate(musicGroupPaymentDateRange.getStartPaymentDate());
|
|
|
- if(StringUtils.isNotEmpty(musicGroupPaymentCalenderDto.getStudentIds())){
|
|
|
- musicGroupPaymentCalender.setStudentIds(musicGroupPaymentCalenderDto.getStudentIds());
|
|
|
- }
|
|
|
- musicGroupPaymentCalender.setOperator(sysUser.getId());
|
|
|
- musicGroupPaymentCalender.setCreateTime(date);
|
|
|
- musicGroupPaymentCalender.setUpdateTime(date);
|
|
|
- musicGroupPaymentCalender.setStatus(status);
|
|
|
-
|
|
|
- if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null && payUserType == PayUserType.STUDENT) {
|
|
|
- musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
|
|
|
- }
|
|
|
-
|
|
|
- if (paymentType == PaymentType.ADD_STUDENT) {
|
|
|
- musicGroupPaymentCalender.setPayUserType(STUDENT);
|
|
|
-// musicGroupPaymentCalender.setIsGiveMusicNetwork(false);
|
|
|
- if (musicGroupPaymentCalender.getStatus() != AUDITING) {
|
|
|
- musicGroupPaymentCalender.setExpectNum(1);
|
|
|
- }
|
|
|
- }
|
|
|
- if (musicGroupPaymentCalender.getStatus() != AUDITING) {
|
|
|
- if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
|
|
|
- musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
|
|
|
- } else if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
|
|
|
- musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
|
|
|
- } else {
|
|
|
- musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 设置批次号
|
|
|
- musicGroupPaymentCalender.setBatchNo(batchNo);
|
|
|
- //设置会员缴费金额、级别以及有效期
|
|
|
-// musicGroupPaymentCalender.setMemberPaymentAmount(musicGroupPaymentCalenderDto.getMemberPaymentAmount());
|
|
|
-// musicGroupPaymentCalender.setMemberRankSettingId(musicGroupPaymentCalenderDto.getMemberRankSettingId());
|
|
|
-// musicGroupPaymentCalender.setMemberValidDate(musicGroupPaymentCalenderDto.getMemberValidDate());
|
|
|
- musicGroupPaymentCalenderDto.setBatchNo(batchNo);
|
|
|
- musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
|
|
|
- List<MusicGroupPaymentCalenderCourseSettings> currentMusicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalender
|
|
|
- .getMusicGroupPaymentCalenderCourseSettingsList();
|
|
|
-
|
|
|
- if (musicGroupPaymentCalender.getStatus() != AUDITING) {
|
|
|
- // 如果是进行中加学生
|
|
|
- if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
|
|
|
- addStudent(musicGroupPaymentCalender, currentMusicGroupPaymentCalenderCourseSettings,musicGroup);
|
|
|
- }else if(musicGroupPaymentCalender.getPaymentType() == SPAN_GROUP_CLASS_ADJUST){
|
|
|
- //如果是跨团班级合并,添加学员
|
|
|
- musicGroupPaymentCalenderDetailService.batchAdd(musicGroupPaymentCalender,musicGroupPaymentCalenderDto.getMusicGroupPaymentCalenderStudentDetails());
|
|
|
- }
|
|
|
- //将0元未缴费学员缴费状态更新为已缴费
|
|
|
- this.updateNoPaymentAndZeroPaymentStatus(musicGroupPaymentCalender,true);
|
|
|
+ musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
|
|
|
}
|
|
|
-
|
|
|
- //课程费用列表
|
|
|
- musicGroupPaymentCalenderCourseSettingsService.batchInsert(musicGroupPaymentCalender);
|
|
|
}
|
|
|
+ // 设置批次号
|
|
|
+ musicGroupPaymentCalender.setBatchNo(batchNo);
|
|
|
+ musicGroupPaymentCalenderDto.setBatchNo(batchNo);
|
|
|
+ musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
|
|
|
+ List<MusicGroupPaymentCalenderCourseSettings> currentMusicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalender
|
|
|
+ .getMusicGroupPaymentCalenderCourseSettingsList();
|
|
|
|
|
|
- // 如果是报名,需要修改乐团状态
|
|
|
- if (paymentType == MUSIC_APPLY) {
|
|
|
- if (status != AUDITING) {
|
|
|
- musicGroup.setStatus(MusicGroupStatusEnum.APPLY);
|
|
|
- // 记录操作日志
|
|
|
- musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功(创建缴费 -> 报名中)", sysUser.getId(), ""));
|
|
|
- } else {
|
|
|
- musicGroup.setStatus(MusicGroupStatusEnum.FEE_AUDIT);
|
|
|
- // 记录操作日志
|
|
|
- musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功(创建缴费 -> 费用审核中)", sysUser.getId(), ""));
|
|
|
- }
|
|
|
- musicGroup.setUpdateTime(date);
|
|
|
- musicGroupDao.update(musicGroup);
|
|
|
- } else if (paymentType == ADD_STUDENT) {
|
|
|
- if (status != AUDITING) {
|
|
|
- // 学生加到班级
|
|
|
- String classGroupIdStr = musicGroupPaymentCalenderDto.getAttribute1();
|
|
|
- if (StringUtils.isNotBlank(classGroupIdStr)) {
|
|
|
- classGroupService.addStudentToClassGroupAndCourseArranging(Integer.parseInt(musicGroupPaymentCalenderDto.getStudentIds()), classGroupIdStr,
|
|
|
- batchNo, musicGroupPaymentCalenderCourseSettingsList,musicGroup);
|
|
|
- }
|
|
|
+ if (musicGroupPaymentCalender.getStatus() != AUDITING) {
|
|
|
+ // 如果是进行中加学生
|
|
|
+ if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
|
|
|
+ addStudent(musicGroupPaymentCalender, currentMusicGroupPaymentCalenderCourseSettings,musicGroup);
|
|
|
+ }else if(musicGroupPaymentCalender.getPaymentType() == SPAN_GROUP_CLASS_ADJUST){
|
|
|
+ //如果是跨团班级合并,添加学员
|
|
|
+ musicGroupPaymentCalenderDetailService.batchAdd(musicGroupPaymentCalender,musicGroupPaymentCalenderDto.getMusicGroupPaymentCalenderStudentDetails());
|
|
|
}
|
|
|
+ //将0元未缴费学员缴费状态更新为已缴费
|
|
|
+ this.updateNoPaymentAndZeroPaymentStatus(musicGroupPaymentCalender,true);
|
|
|
}
|
|
|
|
|
|
if (status == AUDITING) {
|
|
@@ -1123,29 +635,13 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
sendSeoMessageSource.sendSeoMessage(musicGroup.getOrganId(),new SysUserRoleEnum[]{ORGAN_MANAGER},
|
|
|
null,null,MessageTypeEnum.BACKSTAGE_PAYMENT_CALENDER_AUDIT,organization.getName(), musicGroup.getName());
|
|
|
}else {
|
|
|
- if(paymentType == ADD_STUDENT){
|
|
|
- MusicGroupStudentClassAdjust musicGroupStudentClassAdjust = musicGroupStudentClassAdjustDao.findByBatchNo(batchNo);
|
|
|
- if(musicGroupStudentClassAdjust != null){
|
|
|
- //如果是合班缴费
|
|
|
- autoClassGroupAdjust(musicGroupStudentClassAdjust);
|
|
|
- }else {
|
|
|
- imUserFriendService.refreshGroupImUserFriend(musicGroupId,GroupType.MUSIC);
|
|
|
- }
|
|
|
- }else if(paymentType == SPAN_GROUP_CLASS_ADJUST){
|
|
|
- //删除和解冻班级,课程信息
|
|
|
- MusicGroupStudentClassAdjust adjust = musicGroupStudentClassAdjustDao.findByBatchNo(batchNo);
|
|
|
- List<Map> classGroupStudents = JSON.parseArray(adjust.getClassGroupStudents(),Map.class);
|
|
|
- List<Integer> studentIds = JSON.parseArray(adjust.getStudentIds(), Integer.class);
|
|
|
- List<Long> courseIds = JSON.parseArray(adjust.getSubLockCourseIds(), Long.class);
|
|
|
- List<Long> allLockCourseIds = JSON.parseArray(adjust.getAllLockCourseIds(), Long.class);
|
|
|
- classGroupService.spanGroupClassAdjustPass(adjust.getMasterClassGroupId()
|
|
|
- ,studentIds,courseIds,classGroupStudents,allLockCourseIds,batchNo,adjust.getMasterTotalPrice());
|
|
|
- }
|
|
|
+ //删除和解冻班级,课程信息
|
|
|
+ List<Map> classGroupStudents = JSON.parseArray(adjust.getClassGroupStudents(),Map.class);
|
|
|
+ List<Long> courseIds = JSON.parseArray(adjust.getSubLockCourseIds(), Long.class);
|
|
|
+ List<Long> allLockCourseIds = JSON.parseArray(adjust.getAllLockCourseIds(), Long.class);
|
|
|
+ classGroupService.spanGroupClassAdjustPass(adjust.getMasterClassGroupId()
|
|
|
+ ,studentIdList,courseIds,classGroupStudents,allLockCourseIds,batchNo,adjust.getMasterTotalPrice());
|
|
|
}
|
|
|
-
|
|
|
- //统计变更学员数
|
|
|
- groupEventSource.musicGroupStudentChangeEvent(musicGroupId, StudentMusicGroupStatusEnum.NORMAL, null);
|
|
|
-
|
|
|
return batchNo;
|
|
|
}
|
|
|
|