|
@@ -1,22 +1,24 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
|
|
|
import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
|
|
|
import com.ym.mec.biz.dal.dto.SimpleUserDto;
|
|
|
+import com.ym.mec.biz.dal.entity.MusicGroup;
|
|
|
import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
|
|
|
+import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
|
import com.ym.mec.biz.service.MusicGroupPaymentCalenderDetailService;
|
|
|
+import com.ym.mec.biz.service.SysMessageService;
|
|
|
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.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.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.NON_PAYMENT;
|
|
@@ -27,6 +29,10 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
|
|
|
|
|
|
@Autowired
|
|
|
private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupDao musicGroupDao;
|
|
|
+ @Autowired
|
|
|
+ private SysMessageService sysMessageService;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, MusicGroupPaymentCalenderDetail> getDAO() {
|
|
@@ -62,22 +68,42 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
|
|
|
if(StringUtils.isEmpty(ids)){
|
|
|
throw new BizException("参数校验失败");
|
|
|
}
|
|
|
- //获取缴费列表
|
|
|
- List<MusicGroupPaymentCalenderDetail> calenderDetails = musicGroupPaymentCalenderDetailDao.queryListByIds(ids);
|
|
|
+ //获取可开启缴费列表
|
|
|
+ List<MusicGroupPaymentCalenderDetail> calenderDetails = musicGroupPaymentCalenderDetailDao.queryCanOpenList(ids);
|
|
|
if(calenderDetails.size() == 0){
|
|
|
- throw new BizException("缴费记录不存在");
|
|
|
+ return;
|
|
|
}
|
|
|
Date date = new Date();
|
|
|
- calenderDetails.forEach(e->{
|
|
|
- if(e.getPaymentStatus() == null || e.getPaymentStatus() != NON_PAYMENT){
|
|
|
- throw new BizException("修改失败,缴费状态不匹配");
|
|
|
+ /*Iterator<MusicGroupPaymentCalenderDetail> iterator = calenderDetails.iterator();
|
|
|
+ MusicGroupPaymentCalenderDetail next;
|
|
|
+ while(iterator.hasNext()){
|
|
|
+ next = iterator.next();
|
|
|
+ int count = musicGroupPaymentCalenderDetailDao.queryIntersectionByPaymentDate(next.getMusicGroupId(),next.getUserId());
|
|
|
+ if(count > 0){
|
|
|
+ iterator.remove();
|
|
|
}
|
|
|
+ }*/
|
|
|
+ String musicGroupId = calenderDetails.get(0).getMusicGroupId();
|
|
|
+ calenderDetails.forEach(e->{
|
|
|
e.setUpdateTime(date);
|
|
|
+ e.setOpen(1);
|
|
|
e.setPaymentStatus(PROCESSING);
|
|
|
+ e.setStartPaymentDate(date);
|
|
|
+ e.setDeadlinePaymentDate(date);
|
|
|
});
|
|
|
musicGroupPaymentCalenderDetailDao.batchUpdate(calenderDetails);
|
|
|
Set<Integer> studentIds = calenderDetails.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
|
|
|
//推送消息
|
|
|
+ if (studentIds.size() > 0) {
|
|
|
+ Map<Integer, String> push = new HashMap<>();
|
|
|
+ for (Integer userId : studentIds) {
|
|
|
+ push.put(userId, userId + "");
|
|
|
+ }
|
|
|
+ MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
|
|
|
+ String memo = "4?http://mstudev.dayaedu.com/#/renew?musicGroupId=" + musicGroupId;
|
|
|
+ // 发送续费通知
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_WAIT_RENEW_MESSAGE, push, null, 0, memo,"STUDENT",musicGroup.getName());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|