|
@@ -1,5 +1,6 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Collections;
|
|
|
import java.util.Date;
|
|
@@ -12,8 +13,10 @@ 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.MusicGroupStudentFeeDao;
|
|
|
import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
|
|
|
import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
|
|
|
+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.service.impl.BaseServiceImpl;
|
|
@@ -24,6 +27,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
|
|
|
@Autowired
|
|
|
private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, MusicGroupPaymentCalender> getDAO() {
|
|
@@ -32,6 +38,34 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean create(MusicGroupPaymentCalender musicGroupPaymentCalender) {
|
|
|
+ Date date = new Date();
|
|
|
+ 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<MusicGroupStudentFee> list = musicGroupStudentFeeDao.queryByMusicGroupId(musicGroupPaymentCalender.getMusicGroupId());
|
|
|
+ if(list == null){
|
|
|
+ list = new ArrayList<MusicGroupStudentFee>();
|
|
|
+ }
|
|
|
+ musicGroupPaymentCalender.setExpectNum(list.size());
|
|
|
+ } else {
|
|
|
+ musicGroupPaymentCalender.setPaymentStatus(PaymentStatusEnum.NO);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.insert(musicGroupPaymentCalender);
|
|
|
+
|
|
|
+ //创建缴费明细
|
|
|
+
|
|
|
+ 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 +78,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());
|