|
@@ -1,5 +1,8 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
+import static com.ym.mec.biz.dal.enums.PaymentStatusEnum.NO;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Collections;
|
|
|
import java.util.Date;
|
|
@@ -12,10 +15,16 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
|
|
|
import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
|
|
|
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
|
|
|
import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
|
|
|
+import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
|
|
|
+import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
|
|
|
import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
+import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
|
|
@@ -25,6 +34,12 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
@Autowired
|
|
|
private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
|
|
|
+
|
|
|
@Override
|
|
|
public BaseDAO<Long, MusicGroupPaymentCalender> getDAO() {
|
|
|
return musicGroupPaymentCalenderDao;
|
|
@@ -32,6 +47,57 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean create(MusicGroupPaymentCalender musicGroupPaymentCalender) {
|
|
|
+ Date date = new Date();
|
|
|
+ List<MusicGroupStudentFee> list = null;
|
|
|
+
|
|
|
+ musicGroupPaymentCalender.setCreateTime(date);
|
|
|
+ musicGroupPaymentCalender.setUpdateTime(date);
|
|
|
+ musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
|
|
|
+ if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
|
|
|
+ musicGroupPaymentCalender.setPaymentStatus(PaymentStatusEnum.YES);
|
|
|
+ } else if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
|
|
|
+ musicGroupPaymentCalender.setPaymentStatus(PaymentStatusEnum.OPEN);
|
|
|
+ // 统计缴费人数
|
|
|
+ list = musicGroupStudentFeeDao.queryByMusicGroupId(musicGroupPaymentCalender.getMusicGroupId());
|
|
|
+ if (list == null) {
|
|
|
+ list = new ArrayList<MusicGroupStudentFee>();
|
|
|
+ }
|
|
|
+ musicGroupPaymentCalender.setExpectNum(list.size());
|
|
|
+ } else {
|
|
|
+ musicGroupPaymentCalender.setPaymentStatus(PaymentStatusEnum.NO);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.insert(musicGroupPaymentCalender);
|
|
|
+
|
|
|
+ List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
|
|
|
+ if (musicGroupPaymentCalender.getPaymentStatus() == PaymentStatusEnum.OPEN) {
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
+ MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
|
|
|
+ // 创建缴费明细
|
|
|
+ for (MusicGroupStudentFee mgsf : list) {
|
|
|
+ musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
|
|
|
+ musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
|
|
|
+ musicGroupPaymentCalenderDetail.setCreateTime(date);
|
|
|
+ musicGroupPaymentCalenderDetail.setExpectAmount(mgsf.getCourseFee());
|
|
|
+ musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
|
|
|
+ musicGroupPaymentCalenderDetail.setUpdateTime(date);
|
|
|
+ musicGroupPaymentCalenderDetail.setUserId(mgsf.getUserId());
|
|
|
+
|
|
|
+ musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (musicGroupPaymentCalenderDetailList.size() > 0) {
|
|
|
+ musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void batchInsert(List<MusicGroupPaymentCalender> musicGroupPaymentCalenders) {
|
|
|
if (musicGroupPaymentCalenders != null && musicGroupPaymentCalenders.size() > 0) {
|
|
|
musicGroupPaymentCalenderDao.delByGroupId(musicGroupPaymentCalenders.get(0).getMusicGroupId());
|
|
@@ -44,15 +110,15 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
@Override
|
|
|
public Date getNextPaymentDate(String musicGroupId, Date latestPaidDate, MusicGroupStudentFee fee) {
|
|
|
List<Integer> months = null;
|
|
|
- if(fee != null){
|
|
|
+ if (fee != null) {
|
|
|
String paymentPeriodList = fee.getPaymentPeriodList();
|
|
|
- if(StringUtils.isEmpty(paymentPeriodList)){
|
|
|
+ if (StringUtils.isEmpty(paymentPeriodList)) {
|
|
|
return null;
|
|
|
} else {
|
|
|
months = Arrays.asList(paymentPeriodList.split(",")).stream().map(x -> Integer.parseInt(x)).collect(Collectors.toList());
|
|
|
Collections.sort(months);
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
|
|
|
if (musicGroupPaymentCalenderList != null && musicGroupPaymentCalenderList.size() > 0) {
|
|
|
months = musicGroupPaymentCalenderList.stream().map(e -> e.getPaymentMonth()).sorted().collect(Collectors.toList());
|
|
@@ -85,4 +151,38 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void updateStartTime(Date startTime, Long id) {
|
|
|
+ if (startTime == null || id == null) {
|
|
|
+ throw new BizException("参数校验失败");
|
|
|
+ }
|
|
|
+ MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(id);
|
|
|
+ if (calender == null) {
|
|
|
+ throw new BizException("缴费信息不存在");
|
|
|
+ }
|
|
|
+ if (calender.getPaymentStatus() == null || calender.getPaymentStatus() != NO) {
|
|
|
+ throw new BizException("修改失败,缴费状态不匹配");
|
|
|
+ }
|
|
|
+ calender.setStartPaymentDate(startTime);
|
|
|
+ calender.setUpdateTime(new Date());
|
|
|
+ musicGroupPaymentCalenderDao.update(calender);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void del(Long id) {
|
|
|
+ if (id == null) {
|
|
|
+ throw new BizException("参数校验失败");
|
|
|
+ }
|
|
|
+ MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(id);
|
|
|
+ if (calender == null) {
|
|
|
+ throw new BizException("缴费信息不存在");
|
|
|
+ }
|
|
|
+ if (calender.getPaymentStatus() == null || calender.getPaymentStatus() != NO) {
|
|
|
+ throw new BizException("删除失败,缴费状态不匹配");
|
|
|
+ }
|
|
|
+ musicGroupPaymentCalenderDao.delete(id);
|
|
|
+ }
|
|
|
}
|