|
@@ -1,10 +1,39 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
-import com.ym.mec.biz.dal.dao.*;
|
|
|
+import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.NON_PAYMENT;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderCourseSettingsDao;
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentStudentCourseDetailDao;
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
|
|
|
+import com.ym.mec.biz.dal.dao.SysConfigDao;
|
|
|
import com.ym.mec.biz.dal.dto.FeeStudentDto;
|
|
|
import com.ym.mec.biz.dal.dto.SimpleUserDto;
|
|
|
-import com.ym.mec.biz.dal.entity.*;
|
|
|
+import com.ym.mec.biz.dal.entity.MusicGroup;
|
|
|
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
|
|
|
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.MusicGroupPaymentStudentCourseDetail;
|
|
|
+import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
|
|
|
import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
|
|
|
import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
|
import com.ym.mec.biz.service.MusicGroupPaymentCalenderDetailService;
|
|
@@ -16,18 +45,6 @@ import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
|
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.NON_PAYMENT;
|
|
|
-import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED;
|
|
|
-
|
|
|
@Service
|
|
|
public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalenderDetail> implements MusicGroupPaymentCalenderDetailService {
|
|
|
|
|
@@ -428,15 +445,39 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void batchDel(String musicGroupPaymentCalenderIds) {
|
|
|
- List<MusicGroupPaymentCalenderDetail> details = musicGroupPaymentCalenderDetailDao.queryListByIds(musicGroupPaymentCalenderIds);
|
|
|
+ public void batchDel(String musicGroupPaymentCalenderDetailIds) {
|
|
|
+ List<MusicGroupPaymentCalenderDetail> details = musicGroupPaymentCalenderDetailDao.queryListByIds(musicGroupPaymentCalenderDetailIds);
|
|
|
if(details == null || details.size() == 0){
|
|
|
throw new BizException("删除失败: 数据不可为空");
|
|
|
}
|
|
|
- long count = details.stream().filter(e -> e.getPaymentStatus() == PAID_COMPLETED).count();
|
|
|
+ //是否已缴费
|
|
|
+ long count = details.stream().filter(e -> e.getPaymentStatus() != NON_PAYMENT).count();
|
|
|
if(count > 0){
|
|
|
throw new BizException("删除失败: 存在已缴费的学员");
|
|
|
}
|
|
|
- musicGroupPaymentCalenderDetailDao.batchDel(musicGroupPaymentCalenderIds);
|
|
|
+ List<Long> musicGroupPaymentCalenderDetailIdList = new ArrayList<Long>();
|
|
|
+ for(String s : musicGroupPaymentCalenderDetailIds.split(",")){
|
|
|
+ musicGroupPaymentCalenderDetailIdList.add(Long.parseLong(s));
|
|
|
+ }
|
|
|
+ //是否已排课
|
|
|
+ List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = musicGroupPaymentStudentCourseDetailDao.queryByMusicGroupPaymentStudentCourseDetailId(musicGroupPaymentCalenderDetailIdList);
|
|
|
+ count = musicGroupPaymentStudentCourseDetailList.stream().filter(e -> e.getUsedCourseMinutes() > 0).count();
|
|
|
+ if(count > 0){
|
|
|
+ throw new BizException("删除失败:存在已排课的学员");
|
|
|
+ }
|
|
|
+
|
|
|
+ Long musicGroupPaymentCalenderId = details.get(0).getMusicGroupPaymentCalenderId();
|
|
|
+ MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(musicGroupPaymentCalenderId);
|
|
|
+
|
|
|
+ if(musicGroupPaymentCalender == null){
|
|
|
+ throw new BizException("查询缴费项目失败[{}]", musicGroupPaymentCalender);
|
|
|
+ }
|
|
|
+ int currentNum = musicGroupPaymentCalender.getExpectNum() - details.size();
|
|
|
+ musicGroupPaymentCalender.setExpectNum(currentNum < 0 ? 0 : currentNum);
|
|
|
+ musicGroupPaymentCalender.setUpdateTime(new Date());
|
|
|
+ musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);
|
|
|
+
|
|
|
+ musicGroupPaymentCalenderDetailDao.batchDel(musicGroupPaymentCalenderDetailIds);
|
|
|
+ musicGroupPaymentStudentCourseDetailDao.deleteByMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetailIdList);
|
|
|
}
|
|
|
}
|