|
@@ -1,5 +1,7 @@
|
|
|
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;
|
|
@@ -7,15 +9,13 @@ import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
|
|
|
-import com.ym.mec.common.exception.BizException;
|
|
|
-
|
|
|
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.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;
|
|
@@ -24,17 +24,19 @@ 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;
|
|
|
|
|
|
-import static com.ym.mec.biz.dal.enums.PaymentStatusEnum.NO;
|
|
|
-
|
|
|
@Service
|
|
|
public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalender> implements MusicGroupPaymentCalenderService {
|
|
|
|
|
|
@Autowired
|
|
|
private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
|
|
|
-
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
|
|
|
+
|
|
|
@Autowired
|
|
|
private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
|
|
|
|
|
@@ -48,7 +50,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
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));
|
|
@@ -56,23 +58,24 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
musicGroupPaymentCalender.setPaymentStatus(PaymentStatusEnum.YES);
|
|
|
} else if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
|
|
|
musicGroupPaymentCalender.setPaymentStatus(PaymentStatusEnum.OPEN);
|
|
|
- //统计缴费人数
|
|
|
+ // 统计缴费人数
|
|
|
list = musicGroupStudentFeeDao.queryByMusicGroupId(musicGroupPaymentCalender.getMusicGroupId());
|
|
|
- if(list == null){
|
|
|
+ if (list == null) {
|
|
|
list = new ArrayList<MusicGroupStudentFee>();
|
|
|
}
|
|
|
musicGroupPaymentCalender.setExpectNum(list.size());
|
|
|
} else {
|
|
|
musicGroupPaymentCalender.setPaymentStatus(PaymentStatusEnum.NO);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
this.insert(musicGroupPaymentCalender);
|
|
|
-
|
|
|
- if(musicGroupPaymentCalender.getPaymentStatus() == PaymentStatusEnum.OPEN){
|
|
|
- if(list != null && list.size() > 0){
|
|
|
+
|
|
|
+ List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
|
|
|
+ if (musicGroupPaymentCalender.getPaymentStatus() == PaymentStatusEnum.OPEN) {
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
|
|
|
- //创建缴费明细
|
|
|
- for(MusicGroupStudentFee mgsf : list){
|
|
|
+ // 创建缴费明细
|
|
|
+ for (MusicGroupStudentFee mgsf : list) {
|
|
|
musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
|
|
|
musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
|
|
|
musicGroupPaymentCalenderDetail.setCreateTime(date);
|
|
@@ -80,10 +83,16 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
|
|
|
musicGroupPaymentCalenderDetail.setUpdateTime(date);
|
|
|
musicGroupPaymentCalenderDetail.setUserId(mgsf.getUserId());
|
|
|
+
|
|
|
+ musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (musicGroupPaymentCalenderDetailList.size() > 0) {
|
|
|
+ musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
|
|
|
+ }
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -146,14 +155,14 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void updateStartTime(Date startTime, Long id) {
|
|
|
- if(startTime == null || id == null){
|
|
|
+ if (startTime == null || id == null) {
|
|
|
throw new BizException("参数校验失败");
|
|
|
}
|
|
|
MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(id);
|
|
|
- if(calender == null){
|
|
|
+ if (calender == null) {
|
|
|
throw new BizException("缴费信息不存在");
|
|
|
}
|
|
|
- if(calender.getPaymentStatus() == null || calender.getPaymentStatus() != NO){
|
|
|
+ if (calender.getPaymentStatus() == null || calender.getPaymentStatus() != NO) {
|
|
|
throw new BizException("修改失败,缴费状态不匹配");
|
|
|
}
|
|
|
calender.setStartPaymentDate(startTime);
|
|
@@ -164,14 +173,14 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void del(Long id) {
|
|
|
- if(id == null){
|
|
|
+ if (id == null) {
|
|
|
throw new BizException("参数校验失败");
|
|
|
}
|
|
|
MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(id);
|
|
|
- if(calender == null){
|
|
|
+ if (calender == null) {
|
|
|
throw new BizException("缴费信息不存在");
|
|
|
}
|
|
|
- if(calender.getPaymentStatus() == null || calender.getPaymentStatus() != NO){
|
|
|
+ if (calender.getPaymentStatus() == null || calender.getPaymentStatus() != NO) {
|
|
|
throw new BizException("删除失败,缴费状态不匹配");
|
|
|
}
|
|
|
musicGroupPaymentCalenderDao.delete(id);
|