|
@@ -8,6 +8,7 @@ import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
+import java.util.Map.Entry;
|
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -17,26 +18,30 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import com.ym.mec.biz.dal.dao.MusicGroupDao;
|
|
import com.ym.mec.biz.dal.dao.MusicGroupDao;
|
|
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupOrganizationCourseSettingsDetailDao;
|
|
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderCourseSettingsDao;
|
|
|
import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
|
|
import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
|
|
|
import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
|
|
import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
|
|
|
import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
|
|
import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
|
|
|
import com.ym.mec.biz.dal.dao.SysConfigDao;
|
|
import com.ym.mec.biz.dal.dao.SysConfigDao;
|
|
|
import com.ym.mec.biz.dal.dto.CalenderPushDto;
|
|
import com.ym.mec.biz.dal.dto.CalenderPushDto;
|
|
|
|
|
+import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
|
|
|
import com.ym.mec.biz.dal.entity.MusicGroup;
|
|
import com.ym.mec.biz.dal.entity.MusicGroup;
|
|
|
|
|
+import com.ym.mec.biz.dal.entity.MusicGroupOrganizationCourseSettingsDetail;
|
|
|
import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
|
|
import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
|
|
|
import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
|
|
import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
|
|
|
|
|
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
|
|
|
import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
|
|
import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
|
|
|
import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
|
|
import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
|
|
|
import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
|
|
import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
|
|
|
import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
|
|
|
+import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
|
|
|
import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
|
|
import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
|
|
|
-import com.ym.mec.biz.dal.page.MusicCalenderQueryInfo;
|
|
|
|
|
import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
|
|
import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
|
|
|
import com.ym.mec.biz.service.SysConfigService;
|
|
import com.ym.mec.biz.service.SysConfigService;
|
|
|
import com.ym.mec.biz.service.SysMessageService;
|
|
import com.ym.mec.biz.service.SysMessageService;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
-import com.ym.mec.common.page.PageInfo;
|
|
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
@@ -51,6 +56,13 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
|
|
private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
|
|
private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MusicGroupOrganizationCourseSettingsDetailDao musicGroupOrganizationCourseSettingsDetailDao;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private MusicGroupDao musicGroupDao;
|
|
private MusicGroupDao musicGroupDao;
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -64,120 +76,219 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public PageInfo<MusicGroupPaymentCalender> queryDetailPage(MusicCalenderQueryInfo queryInfo) {
|
|
|
|
|
- PageInfo<MusicGroupPaymentCalender> pageInfo = queryPage(queryInfo);
|
|
|
|
|
- List<MusicGroupPaymentCalender> rows = pageInfo.getRows();
|
|
|
|
|
- if (rows.size() == 0) {
|
|
|
|
|
- return pageInfo;
|
|
|
|
|
- }
|
|
|
|
|
- Set<Long> collect = rows.stream().map(e -> e.getId()).collect(Collectors.toSet());
|
|
|
|
|
- Map<Long, Long> expectNumMap = MapUtil.convertIntegerMap(musicGroupPaymentCalenderDao.countExpectNum(collect));
|
|
|
|
|
- Map<Long, Long> actualNumMap = MapUtil.convertIntegerMap(musicGroupPaymentCalenderDao.countActualNum(collect));
|
|
|
|
|
- rows.forEach(e -> {
|
|
|
|
|
- e.setActualNum(actualNumMap.get(e.getId()) == null ? 0 : actualNumMap.get(e.getId()).intValue());
|
|
|
|
|
- e.setExpectNum(expectNumMap.get(e.getId()) == null ? 0 : expectNumMap.get(e.getId()).intValue());
|
|
|
|
|
- });
|
|
|
|
|
- return pageInfo;
|
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public boolean create(List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList) {
|
|
|
|
|
+ if(musicGroupPaymentCalenderList == null || musicGroupPaymentCalenderList.size() == 0){
|
|
|
|
|
+ throw new BizException("请重新创建缴费记录");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String musicGroupId = musicGroupPaymentCalenderList.get(0).getMusicGroupId();
|
|
|
|
|
+
|
|
|
|
|
+ MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
|
|
|
|
|
+
|
|
|
|
|
+ if(musicGroup == null){
|
|
|
|
|
+ throw new BizException("乐团查询失败,请检查参数");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Date date = new Date();
|
|
|
|
|
+ Map<Integer, String> pushUserMap = new HashMap<Integer, String>();
|
|
|
|
|
+ MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
|
|
|
|
|
+ List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
|
|
|
|
|
+
|
|
|
|
|
+ for(MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenderList){
|
|
|
|
|
+ musicGroupPaymentCalender.setCreateTime(date);
|
|
|
|
|
+ musicGroupPaymentCalender.setUpdateTime(date);
|
|
|
|
|
+ if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null) {
|
|
|
|
|
+ musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
|
|
|
|
|
+ }
|
|
|
|
|
+ int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPaymentValidStartDate(),
|
|
|
|
|
+ musicGroupPaymentCalender.getPaymentValidEndDate(), null);
|
|
|
|
|
+ if (count > 0) {
|
|
|
|
|
+ throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //查询默认课程费用
|
|
|
|
|
+ Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalender.getMusicGroupOrganizationCourseSettingId();
|
|
|
|
|
+ Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId).stream().collect(Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail :: getCourseType, MusicGroupOrganizationCourseSettingsDetail :: getCourseCurrentPrice));
|
|
|
|
|
+
|
|
|
|
|
+ //当前缴费的课程费用
|
|
|
|
|
+ Map<CourseScheduleType,BigDecimal> currentCoursePrice = musicGroupPaymentCalender.getMusicGroupPaymentCalenderCourseSettingsList().stream().collect(Collectors.toMap(MusicGroupPaymentCalenderCourseSettings :: getCourseType, MusicGroupPaymentCalenderCourseSettings :: getCourseCurrentPrice));
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal totalPrice = new BigDecimal(0);
|
|
|
|
|
+ //相同类型的课程如果修改了课程费用,需要走审批
|
|
|
|
|
+ for(Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()){
|
|
|
|
|
+ if(defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0){
|
|
|
|
|
+ musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
|
|
|
|
|
+ }
|
|
|
|
|
+ totalPrice.add(entry.getValue());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
|
|
|
|
|
+ if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
|
|
|
|
|
+ musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
|
|
|
|
|
+ } else if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
|
|
|
|
|
+ musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //如果是报名,需要修改乐团状态
|
|
|
|
|
+ if (musicGroupPaymentCalender.getPaymentType() == 1) {
|
|
|
|
|
+ musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
|
|
|
|
|
+ musicGroup.setUpdateTime(date);
|
|
|
|
|
+ musicGroupDao.update(musicGroup);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ musicGroupPaymentCalender.setExpectNum(0);
|
|
|
|
|
+ if(StringUtils.isNoneBlank(musicGroupPaymentCalender.getStudentIds())){
|
|
|
|
|
+ String[] sutdentIdList = musicGroupPaymentCalender.getStudentIds().split(",");
|
|
|
|
|
+ musicGroupPaymentCalender.setExpectNum(sutdentIdList.length);
|
|
|
|
|
+
|
|
|
|
|
+ if (musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.OPEN) {
|
|
|
|
|
+ for(String studentId : sutdentIdList){
|
|
|
|
|
+ pushUserMap.put(Integer.parseInt(studentId), studentId);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //创建缴费明细
|
|
|
|
|
+ for(String studentId : sutdentIdList){
|
|
|
|
|
+ musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
|
|
|
|
|
+ musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
|
|
|
|
|
+ musicGroupPaymentCalenderDetail.setCreateTime(date);
|
|
|
|
|
+ musicGroupPaymentCalenderDetail.setExpectAmount(totalPrice);
|
|
|
|
|
+ musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
|
|
|
|
|
+ musicGroupPaymentCalenderDetail.setUpdateTime(date);
|
|
|
|
|
+ musicGroupPaymentCalenderDetail.setUserId(Integer.parseInt(studentId));
|
|
|
|
|
+
|
|
|
|
|
+ musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (musicGroupPaymentCalenderDetailList.size() > 0) {
|
|
|
|
|
+ musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(musicGroupPaymentCalenderList.size() > 0){
|
|
|
|
|
+ musicGroupPaymentCalenderDao.batchInsert(musicGroupPaymentCalenderList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 发送续费通知
|
|
|
|
|
+ if (pushUserMap.size() > 0) {
|
|
|
|
|
+ String configValue = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
|
|
|
|
|
+ String memo = "4?" + configValue + "/#/renew?musicGroupId=" + musicGroup.getId();
|
|
|
|
|
+
|
|
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_WAIT_RENEW_MESSAGE,
|
|
|
|
|
+ pushUserMap, null, 0, memo, "STUDENT", musicGroup.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public boolean create(MusicGroupPaymentCalender musicGroupPaymentCalender) {
|
|
|
|
|
|
|
+ public int update(MusicGroupPaymentCalender musicGroupPaymentCalender) {
|
|
|
String musicGroupId = musicGroupPaymentCalender.getMusicGroupId();
|
|
String musicGroupId = musicGroupPaymentCalender.getMusicGroupId();
|
|
|
|
|
|
|
|
- musicGroupDao.getLocked(musicGroupId);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
|
|
|
|
|
+
|
|
|
|
|
+ if(musicGroup == null){
|
|
|
|
|
+ throw new BizException("乐团查询失败,请检查参数");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
|
- List<MusicGroupStudentFee> musicGroupStudentFeeList = null;
|
|
|
|
|
-
|
|
|
|
|
- musicGroupPaymentCalender.setCreateTime(date);
|
|
|
|
|
|
|
+
|
|
|
musicGroupPaymentCalender.setUpdateTime(date);
|
|
musicGroupPaymentCalender.setUpdateTime(date);
|
|
|
if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null) {
|
|
if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null) {
|
|
|
musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
|
|
musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
|
|
|
}
|
|
}
|
|
|
- // 判断缴费开始时间、结束时间是否被其他缴费记录占用
|
|
|
|
|
- int count = musicGroupPaymentCalenderDao.queryIntersectionByPaymentDate(musicGroupId, musicGroupPaymentCalender.getStartPaymentDate(),
|
|
|
|
|
- musicGroupPaymentCalender.getDeadlinePaymentDate(), null);
|
|
|
|
|
-
|
|
|
|
|
- // String format = DateUtil.format(musicGroupPaymentCalender.getStartPaymentDate(), DateUtil.DEFAULT_PATTERN);
|
|
|
|
|
- // String format1 = DateUtil.format(musicGroupPaymentCalender.getDeadlinePaymentDate(), DateUtil.DEFAULT_PATTERN);
|
|
|
|
|
- // int count = musicGroupPaymentCalenderDao.queryIntersectionByDate(musicGroupId, format,format1);
|
|
|
|
|
- if (count > 0) {
|
|
|
|
|
- throw new BizException("缴费日期存在冲突,请修改缴费日期");
|
|
|
|
|
- }
|
|
|
|
|
- count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPaymentValidStartDate(),
|
|
|
|
|
|
|
+ int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPaymentValidStartDate(),
|
|
|
musicGroupPaymentCalender.getPaymentValidEndDate(), null);
|
|
musicGroupPaymentCalender.getPaymentValidEndDate(), null);
|
|
|
if (count > 0) {
|
|
if (count > 0) {
|
|
|
throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
|
|
throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
|
|
|
}
|
|
}
|
|
|
- if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
|
|
|
|
|
- musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
|
|
|
|
|
- } else if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
|
|
|
|
|
- musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
|
|
|
|
|
- } else {
|
|
|
|
|
- musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //查询默认课程费用
|
|
|
|
|
+ Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalender.getMusicGroupOrganizationCourseSettingId();
|
|
|
|
|
+ Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId).stream().collect(Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail :: getCourseType, MusicGroupOrganizationCourseSettingsDetail :: getCourseCurrentPrice));
|
|
|
|
|
+
|
|
|
|
|
+ //当前缴费的课程费用
|
|
|
|
|
+ Map<CourseScheduleType,BigDecimal> currentCoursePrice = musicGroupPaymentCalender.getMusicGroupPaymentCalenderCourseSettingsList().stream().collect(Collectors.toMap(MusicGroupPaymentCalenderCourseSettings :: getCourseType, MusicGroupPaymentCalenderCourseSettings :: getCourseCurrentPrice));
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal totalPrice = new BigDecimal(0);
|
|
|
|
|
+ //相同类型的课程如果修改了课程费用,需要走审批
|
|
|
|
|
+ for(Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()){
|
|
|
|
|
+ if(defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0){
|
|
|
|
|
+ musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
|
|
|
|
|
+ }
|
|
|
|
|
+ totalPrice.add(entry.getValue());
|
|
|
}
|
|
}
|
|
|
- // 统计缴费人数
|
|
|
|
|
- musicGroupStudentFeeList = musicGroupStudentFeeDao.queryByMusicGroupId(musicGroupId, musicGroupPaymentCalender.getStudentIds());
|
|
|
|
|
- if (musicGroupStudentFeeList == null) {
|
|
|
|
|
- musicGroupStudentFeeList = new ArrayList<>();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
|
|
|
|
|
+ if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
|
|
|
|
|
+ musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
|
|
|
|
|
+ } else if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
|
|
|
|
|
+ musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //如果是报名,需要修改乐团状态
|
|
|
|
|
+ if (musicGroupPaymentCalender.getPaymentType() == 1) {
|
|
|
|
|
+ musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
|
|
|
|
|
+ musicGroup.setUpdateTime(date);
|
|
|
|
|
+ musicGroupDao.update(musicGroup);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- musicGroupPaymentCalender.setExpectNum(musicGroupStudentFeeList.size());
|
|
|
|
|
-
|
|
|
|
|
- this.insert(musicGroupPaymentCalender);
|
|
|
|
|
-
|
|
|
|
|
- List<MusicGroupStudentFee> updateMusicGroupStudentFeeList = new ArrayList<MusicGroupStudentFee>();
|
|
|
|
|
-
|
|
|
|
|
List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
|
|
List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
|
|
|
|
|
+ Map<Integer, String> pushUserMap = new HashMap<Integer, String>();
|
|
|
|
|
|
|
|
- if (musicGroupStudentFeeList != null && musicGroupStudentFeeList.size() > 0) {
|
|
|
|
|
- Set<Integer> studentIds = new HashSet<>();
|
|
|
|
|
|
|
+ musicGroupPaymentCalender.setExpectNum(0);
|
|
|
|
|
+ if(StringUtils.isNoneBlank(musicGroupPaymentCalender.getStudentIds())){
|
|
|
|
|
+ String[] sutdentIdList = musicGroupPaymentCalender.getStudentIds().split(",");
|
|
|
|
|
+ musicGroupPaymentCalender.setExpectNum(sutdentIdList.length);
|
|
|
|
|
+
|
|
|
|
|
+ if (musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.OPEN) {
|
|
|
|
|
+ for(String studentId : sutdentIdList){
|
|
|
|
|
+ pushUserMap.put(Integer.parseInt(studentId), studentId);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //删除历史数据
|
|
|
|
|
+ musicGroupPaymentCalenderDetailDao.deleteByCalenderId(musicGroupPaymentCalender.getId());
|
|
|
|
|
+
|
|
|
|
|
+ //创建缴费明细
|
|
|
MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
|
|
MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
|
|
|
- // 创建缴费明细
|
|
|
|
|
- for (MusicGroupStudentFee mgsf : musicGroupStudentFeeList) {
|
|
|
|
|
|
|
+ for(String studentId : sutdentIdList){
|
|
|
musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
|
|
musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
|
|
|
musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
|
|
musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
|
|
|
musicGroupPaymentCalenderDetail.setCreateTime(date);
|
|
musicGroupPaymentCalenderDetail.setCreateTime(date);
|
|
|
- musicGroupPaymentCalenderDetail.setExpectAmount(mgsf.getCourseFee());
|
|
|
|
|
|
|
+ musicGroupPaymentCalenderDetail.setExpectAmount(totalPrice);
|
|
|
musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
|
|
musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
|
|
|
- if (mgsf.getCourseFee().doubleValue() != 0) {
|
|
|
|
|
- studentIds.add(mgsf.getUserId());
|
|
|
|
|
- }
|
|
|
|
|
musicGroupPaymentCalenderDetail.setUpdateTime(date);
|
|
musicGroupPaymentCalenderDetail.setUpdateTime(date);
|
|
|
- musicGroupPaymentCalenderDetail.setUserId(mgsf.getUserId());
|
|
|
|
|
|
|
+ musicGroupPaymentCalenderDetail.setUserId(Integer.parseInt(studentId));
|
|
|
|
|
+
|
|
|
musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
|
|
musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
|
|
|
}
|
|
}
|
|
|
- if (musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.OPEN) {
|
|
|
|
|
- // 更新学员缴费状态
|
|
|
|
|
- for (MusicGroupStudentFee mgsf : musicGroupStudentFeeList) {
|
|
|
|
|
- mgsf.setPaymentStatus(PaymentStatus.NON_PAYMENT);
|
|
|
|
|
- mgsf.setUpdateTime(date);
|
|
|
|
|
- updateMusicGroupStudentFeeList.add(mgsf);
|
|
|
|
|
- }
|
|
|
|
|
- if (studentIds.size() > 0) {
|
|
|
|
|
- Map<Integer, String> push = new HashMap<>();
|
|
|
|
|
- for (Integer userId : studentIds) {
|
|
|
|
|
- push.put(userId, userId + "");
|
|
|
|
|
- }
|
|
|
|
|
- MusicGroup musicGroup = musicGroupDao.get(musicGroupPaymentCalender.getMusicGroupId());
|
|
|
|
|
- String configValue = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
|
|
|
|
|
- String memo = "4?" + configValue + "/#/renew?musicGroupId=" + musicGroup.getId();
|
|
|
|
|
- // 发送续费通知
|
|
|
|
|
- sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_WAIT_RENEW_MESSAGE, push,
|
|
|
|
|
- null, 0, memo, "STUDENT", musicGroup.getName());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);
|
|
|
|
|
|
|
|
if (musicGroupPaymentCalenderDetailList.size() > 0) {
|
|
if (musicGroupPaymentCalenderDetailList.size() > 0) {
|
|
|
musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
|
|
musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- if (updateMusicGroupStudentFeeList.size() > 0) {
|
|
|
|
|
- musicGroupStudentFeeDao.batchUpdate(updateMusicGroupStudentFeeList);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 发送续费通知
|
|
|
|
|
+ if (pushUserMap.size() > 0) {
|
|
|
|
|
+ String configValue = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
|
|
|
|
|
+ String memo = "4?" + configValue + "/#/renew?musicGroupId=" + musicGroup.getId();
|
|
|
|
|
+
|
|
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_WAIT_RENEW_MESSAGE,
|
|
|
|
|
+ pushUserMap, null, 0, memo, "STUDENT", musicGroup.getName());
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- return true;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ return 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -439,27 +550,23 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
if (calender == null) {
|
|
if (calender == null) {
|
|
|
throw new BizException("缴费信息不存在");
|
|
throw new BizException("缴费信息不存在");
|
|
|
}
|
|
}
|
|
|
- if (calender.getStatus() == null || calender.getStatus() != PaymentCalenderStatusEnum.NO) {
|
|
|
|
|
- throw new BizException("删除失败,缴费状态不匹配");
|
|
|
|
|
|
|
+ if (calender.getStatus() != PaymentCalenderStatusEnum.NO || calender.getStatus() != PaymentCalenderStatusEnum.REJECT) {
|
|
|
|
|
+ throw new BizException("删除失败,只有“拒绝”或“未开启缴费”状态才能删除");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = musicGroupPaymentCalenderDetailDao.queryByCalenderId(id);
|
|
|
|
|
+ if (musicGroupPaymentCalenderDetailList != null && musicGroupPaymentCalenderDetailList.size() > 0) {
|
|
|
|
|
+ List<MusicGroupPaymentCalenderDetail> paidList = musicGroupPaymentCalenderDetailList.stream()
|
|
|
|
|
+ .filter(MusicGroupPaymentCalenderDetail -> MusicGroupPaymentCalenderDetail.getPaymentStatus() != PaymentStatus.NON_PAYMENT)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ if (paidList.size() > 0) {
|
|
|
|
|
+ throw new BizException("存在已缴费的学生不能删除");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
musicGroupPaymentCalenderDao.delete(id);
|
|
musicGroupPaymentCalenderDao.delete(id);
|
|
|
musicGroupPaymentCalenderDetailDao.deleteByCalenderId(id);
|
|
musicGroupPaymentCalenderDetailDao.deleteByCalenderId(id);
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public Object getDetail(Long id) {
|
|
|
|
|
- MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(id);
|
|
|
|
|
- Set<Long> set = new HashSet<>();
|
|
|
|
|
- set.add(id);
|
|
|
|
|
- Map<Long, Long> expectNumMap = MapUtil.convertIntegerMap(musicGroupPaymentCalenderDao.countExpectNum(set));
|
|
|
|
|
- Map<Long, Long> actualNumMap = MapUtil.convertIntegerMap(musicGroupPaymentCalenderDao.countActualNum(set));
|
|
|
|
|
- calender.setActualNum(actualNumMap.get(id) == null ? 0 : actualNumMap.get(id).intValue());
|
|
|
|
|
- calender.setExpectNum(expectNumMap.get(id) == null ? 0 : expectNumMap.get(id).intValue());
|
|
|
|
|
- BigDecimal sumActualAmount = musicGroupPaymentCalenderDetailDao.sumActualAmount(id);
|
|
|
|
|
- Map<String, Object> result = new HashMap<>(2);
|
|
|
|
|
- result.put("calender", calender);
|
|
|
|
|
- result.put("sumActualAmount", sumActualAmount);
|
|
|
|
|
- return result;
|
|
|
|
|
|
|
+ musicGroupPaymentCalenderCourseSettingsDao.deleteByMusicGroupPaymentCalenderId(id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|