|
@@ -8,6 +8,7 @@ import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDetailDto;
|
|
|
import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDto;
|
|
|
import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType;
|
|
|
import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
|
|
|
import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
|
|
|
import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
@@ -25,6 +26,7 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
+
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -36,6 +38,9 @@ import java.util.*;
|
|
|
import java.util.Map.Entry;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.MUSIC_APPLY;
|
|
|
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.MUSIC_RENEW;
|
|
|
+
|
|
|
@Service
|
|
|
public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalender> implements MusicGroupPaymentCalenderService {
|
|
|
|
|
@@ -93,8 +98,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
musicGroupPaymentCalender.setOperator(sysUser.getId());
|
|
|
musicGroupPaymentCalender.setCreateTime(date);
|
|
|
musicGroupPaymentCalender.setUpdateTime(date);
|
|
|
-
|
|
|
- if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null) {
|
|
|
+ musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
|
|
|
+
|
|
|
+ if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null && musicGroupPaymentCalender.getPayUserType() == PayUserType.STUDENT) {
|
|
|
musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
|
|
|
}
|
|
|
int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPaymentValidStartDate(),
|
|
@@ -102,29 +108,40 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
if (count > 0) {
|
|
|
throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
|
|
|
}
|
|
|
-
|
|
|
//获取设置的课程
|
|
|
List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalender.getMusicGroupPaymentCalenderCourseSettingsList();
|
|
|
if(musicGroupPaymentCalenderCourseSettingsList == null){
|
|
|
musicGroupPaymentCalenderCourseSettingsList = new ArrayList<>();
|
|
|
}
|
|
|
-
|
|
|
- //查询默认课程费用
|
|
|
- Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalender.getMusicGroupOrganizationCourseSettingId();
|
|
|
- Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId).stream().collect(Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail :: getCourseType, MusicGroupOrganizationCourseSettingsDetail :: getCourseCurrentPrice));
|
|
|
-
|
|
|
//当前缴费的课程费用
|
|
|
- Map<CourseScheduleType,BigDecimal> currentCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream().collect(Collectors.toMap(MusicGroupPaymentCalenderCourseSettings :: getCourseType, MusicGroupPaymentCalenderCourseSettings :: getCourseCurrentPrice));
|
|
|
-
|
|
|
- BigDecimal totalPrice = new BigDecimal(0);
|
|
|
- //相同类型的课程如果修改了课程费用,需要走审批
|
|
|
- for(Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()){
|
|
|
- if(defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0){
|
|
|
- musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
|
|
|
+ Map<CourseScheduleType,BigDecimal> currentCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream().
|
|
|
+ collect(Collectors.toMap(MusicGroupPaymentCalenderCourseSettings :: getCourseType, MusicGroupPaymentCalenderCourseSettings :: getCourseCurrentPrice));
|
|
|
+
|
|
|
+ if(musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY || musicGroupPaymentCalender.getPaymentType() == MUSIC_RENEW){
|
|
|
+ //查询默认课程费用
|
|
|
+ Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalender.getMusicGroupOrganizationCourseSettingId();
|
|
|
+ Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId).stream().
|
|
|
+ collect(Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail :: getCourseType, MusicGroupOrganizationCourseSettingsDetail :: getCourseCurrentPrice));
|
|
|
+
|
|
|
+ //相同类型的课程如果修改了课程费用,需要走审批
|
|
|
+ for(Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()){
|
|
|
+ if(defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0){
|
|
|
+ musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
|
|
|
+ }
|
|
|
}
|
|
|
- totalPrice.add(entry.getValue());
|
|
|
+ for(MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings : musicGroupPaymentCalenderCourseSettingsList){
|
|
|
+ musicGroupPaymentCalenderCourseSettings.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
|
|
|
+ musicGroupPaymentCalenderCourseSettings.setCreateTime(date);
|
|
|
+ musicGroupPaymentCalenderCourseSettings.setUpdateTime(date);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(musicGroupPaymentCalenderCourseSettingsList.size() > 0){
|
|
|
+ musicGroupPaymentCalenderCourseSettingsDao.batchInsert(musicGroupPaymentCalenderCourseSettingsList);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
|
|
|
if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
|
|
|
musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
|
|
@@ -135,7 +152,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
}
|
|
|
|
|
|
//如果是报名,需要修改乐团状态
|
|
|
- if (musicGroupPaymentCalender.getPaymentType() == MusicGroupPaymentCalender.PaymentType.MUSIC_APPLY) {
|
|
|
+ if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY) {
|
|
|
if(musicGroup.getStatus() != MusicGroupStatusEnum.DRAFT){
|
|
|
throw new BizException("创建失败:缴费项目类型不匹配");
|
|
|
}
|
|
@@ -157,7 +174,12 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
pushUserMap.put(Integer.parseInt(studentId), studentId);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ BigDecimal totalPrice = new BigDecimal(0);
|
|
|
+ //相同类型的课程如果修改了课程费用,需要走审批
|
|
|
+ for(Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()){
|
|
|
+ totalPrice.add(entry.getValue());
|
|
|
+ }
|
|
|
//创建缴费明细
|
|
|
for(String studentId : sutdentIdList){
|
|
|
musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
|
|
@@ -176,16 +198,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
//设置批次号
|
|
|
musicGroupPaymentCalender.setBatchNo(idGeneratorService.generatorId()+"");
|
|
|
musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
|
|
|
-
|
|
|
- for(MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings : musicGroupPaymentCalenderCourseSettingsList){
|
|
|
- musicGroupPaymentCalenderCourseSettings.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
|
|
|
- musicGroupPaymentCalenderCourseSettings.setCreateTime(date);
|
|
|
- musicGroupPaymentCalenderCourseSettings.setUpdateTime(date);
|
|
|
- }
|
|
|
-
|
|
|
- if(musicGroupPaymentCalenderCourseSettingsList.size() > 0){
|
|
|
- musicGroupPaymentCalenderCourseSettingsDao.batchInsert(musicGroupPaymentCalenderCourseSettingsList);
|
|
|
- }
|
|
|
|
|
|
if (musicGroupPaymentCalenderDetailList.size() > 0) {
|
|
|
musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
|
|
@@ -205,6 +217,20 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public Object getDetail(Long id) {
|
|
|
+ MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(id);
|
|
|
+ Map<Long, Long> expectNumMap = MapUtil.convertIntegerMap(musicGroupPaymentCalenderDao.countExpectNum(id));
|
|
|
+ Map<Long, Long> actualNumMap = MapUtil.convertIntegerMap(musicGroupPaymentCalenderDao.countActualNum(id));
|
|
|
+ calender.setActualNum(actualNumMap.get(id) == null ? 0 : actualNumMap.get(id).intValue());
|
|
|
+ calender.setExpectNum(expectNumMap.get(id) == null ? 0 : expectNumMap.get(id).intValue());
|
|
|
+ BigDecimal sumActualAmount = musicGroupPaymentCalenderDetailDao.sumActualAmount(id);
|
|
|
+ Map<String, Object> result = new HashMap<>(2);
|
|
|
+ result.put("calender", calender);
|
|
|
+ result.put("sumActualAmount", sumActualAmount);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public int update(MusicGroupPaymentCalender musicGroupPaymentCalender) {
|
|
|
|
|
@@ -269,7 +295,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
}
|
|
|
|
|
|
//如果是报名,需要修改乐团状态
|
|
|
- if (musicGroupPaymentCalender.getPaymentType() == MusicGroupPaymentCalender.PaymentType.MUSIC_APPLY) {
|
|
|
+ if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY) {
|
|
|
musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
|
|
|
musicGroup.setUpdateTime(date);
|
|
|
musicGroupDao.update(musicGroup);
|
|
@@ -434,7 +460,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
|
|
|
musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
|
|
|
}
|
|
|
//如果是报名,需要修改乐团状态
|
|
|
- if (musicGroupPaymentCalender.getPaymentType() == MusicGroupPaymentCalender.PaymentType.MUSIC_APPLY) {
|
|
|
+ if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY) {
|
|
|
MusicGroup musicGroup = musicGroupDao.get(musicGroupPaymentCalender.getMusicGroupId());
|
|
|
musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
|
|
|
musicGroup.setUpdateTime(date);
|