|
@@ -1,29 +1,48 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
-import com.ym.mec.biz.dal.dao.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.UUID;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupBuildLogDao;
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentEntitiesDao;
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupSubjectGoodsGroupDao;
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupSubjectPlanDao;
|
|
|
import com.ym.mec.biz.dal.dto.BasicUserDto;
|
|
|
import com.ym.mec.biz.dal.dto.MusicCardDto;
|
|
|
import com.ym.mec.biz.dal.dto.SubFeeSettingDto;
|
|
|
-import com.ym.mec.biz.dal.entity.*;
|
|
|
+import com.ym.mec.biz.dal.entity.MusicGroup;
|
|
|
+import com.ym.mec.biz.dal.entity.MusicGroupBuildLog;
|
|
|
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
|
|
|
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentEntities;
|
|
|
+import com.ym.mec.biz.dal.entity.MusicGroupSubjectGoodsGroup;
|
|
|
+import com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan;
|
|
|
+import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
|
|
|
import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
|
|
|
+import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
|
|
|
import com.ym.mec.biz.service.MusicGroupService;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.entity.ImGroupMember;
|
|
|
import com.ym.mec.common.entity.ImGroupModel;
|
|
|
+import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.im.ImFeignService;
|
|
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.UUID;
|
|
|
-
|
|
|
@Service
|
|
|
-public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> implements MusicGroupService {
|
|
|
-
|
|
|
+public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> implements MusicGroupService {
|
|
|
+
|
|
|
@Autowired
|
|
|
private MusicGroupDao musicGroupDao;
|
|
|
@Autowired
|
|
@@ -39,6 +58,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup>
|
|
|
@Autowired
|
|
|
private MusicGroupBuildLogDao musicGroupBuildLogDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ClassGroupStudentMapperDao classGroupStudentMapperDao;
|
|
|
+
|
|
|
@Override
|
|
|
public BaseDAO<String, MusicGroup> getDAO() {
|
|
|
return musicGroupDao;
|
|
@@ -46,57 +71,57 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup>
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void createGroup(SubFeeSettingDto subFeeSettingDto,Integer userId) {
|
|
|
+ public void createGroup(SubFeeSettingDto subFeeSettingDto, Integer userId) {
|
|
|
MusicGroup musicGroup = subFeeSettingDto.getMusicGroup();
|
|
|
List<MusicGroupPaymentEntities> musicGroupPaymentEntities = subFeeSettingDto.getMusicGroupPaymentEntities();
|
|
|
List<MusicGroupSubjectGoodsGroup> musicGroupSubjectGoodsGroups = subFeeSettingDto.getMusicGroupSubjectGoodsGroups();
|
|
|
List<MusicGroupSubjectPlan> musicGroupSubjectPlans = subFeeSettingDto.getMusicGroupSubjectPlans();
|
|
|
- if(musicGroup == null || musicGroupPaymentEntities == null || musicGroupSubjectGoodsGroups == null || musicGroupSubjectPlans == null){
|
|
|
+ if (musicGroup == null || musicGroupPaymentEntities == null || musicGroupSubjectGoodsGroups == null || musicGroupSubjectPlans == null) {
|
|
|
String musicGroupId = UUID.randomUUID().toString();
|
|
|
musicGroup.setId(musicGroupId);
|
|
|
- //保存乐团基本信息
|
|
|
+ // 保存乐团基本信息
|
|
|
musicGroupDao.insert(musicGroup);
|
|
|
- //保存乐团付费主体列表
|
|
|
- musicGroupPaymentEntities.forEach(e ->{
|
|
|
+ // 保存乐团付费主体列表
|
|
|
+ musicGroupPaymentEntities.forEach(e -> {
|
|
|
e.setMusicGroupId(musicGroupId);
|
|
|
musicGroupPaymentEntitiesDao.insert(e);
|
|
|
});
|
|
|
- //保存学员付费周期
|
|
|
+ // 保存学员付费周期
|
|
|
List<Integer> months = subFeeSettingDto.getMonths();
|
|
|
- if(months != null && months.size() > 0){
|
|
|
+ if (months != null && months.size() > 0) {
|
|
|
MusicGroupPaymentCalender mg;
|
|
|
- for (Integer month:months) {
|
|
|
+ for (Integer month : months) {
|
|
|
mg = new MusicGroupPaymentCalender();
|
|
|
mg.setMusicGroupId(musicGroupId);
|
|
|
mg.setPaymentMonth(month);
|
|
|
musicGroupPaymentCalenderDao.insert(mg);
|
|
|
}
|
|
|
}
|
|
|
- //保存乐团声部规划
|
|
|
+ // 保存乐团声部规划
|
|
|
if (musicGroupSubjectPlans == null) {
|
|
|
musicGroupSubjectPlans = new ArrayList<MusicGroupSubjectPlan>();
|
|
|
}
|
|
|
- musicGroupSubjectPlans.forEach(e ->{
|
|
|
+ musicGroupSubjectPlans.forEach(e -> {
|
|
|
e.setMusicGroupId(musicGroupId);
|
|
|
musicGroupSubjectPlanDao.insert(e);
|
|
|
});
|
|
|
- //保存乐团声部商品规划
|
|
|
+ // 保存乐团声部商品规划
|
|
|
if (musicGroupSubjectGoodsGroups == null) {
|
|
|
musicGroupSubjectGoodsGroups = new ArrayList<MusicGroupSubjectGoodsGroup>();
|
|
|
}
|
|
|
- musicGroupSubjectGoodsGroups.forEach(e->{
|
|
|
+ musicGroupSubjectGoodsGroups.forEach(e -> {
|
|
|
e.setMusicGroupId(musicGroupId);
|
|
|
musicGroupSubjectGoodsGroupDao.insert(e);
|
|
|
});
|
|
|
- //新增聊天群
|
|
|
+ // 新增聊天群
|
|
|
ImGroupModel imGroupModel = new ImGroupModel(musicGroupId, musicGroup.getName());
|
|
|
- //教务老师和运营主管加入群组
|
|
|
- ImGroupMember[] imGroupMembers = {new ImGroupMember(musicGroup.getTeamTeacherId().toString()),
|
|
|
- new ImGroupMember(musicGroup.getEducationalTeacherId().toString())};
|
|
|
- //创建群组
|
|
|
- imFeignService.groupCreate(new ImGroupModel(musicGroupId,imGroupMembers,musicGroup.getName()));
|
|
|
- //记录创建日志
|
|
|
- musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId,"提交建团申请",userId,""));
|
|
|
+ // 教务老师和运营主管加入群组
|
|
|
+ ImGroupMember[] imGroupMembers = { new ImGroupMember(musicGroup.getTeamTeacherId().toString()),
|
|
|
+ new ImGroupMember(musicGroup.getEducationalTeacherId().toString()) };
|
|
|
+ // 创建群组
|
|
|
+ imFeignService.groupCreate(new ImGroupModel(musicGroupId, imGroupMembers, musicGroup.getName()));
|
|
|
+ // 记录创建日志
|
|
|
+ musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "提交建团申请", userId, ""));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -109,7 +134,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup>
|
|
|
public MusicCardDto queryPersonalMusicGroups(Integer id) {
|
|
|
MusicCardDto musicCardDto = musicGroupDao.queryPersonalMusicGroups(id);
|
|
|
musicCardDto.setMusicGroupNum(musicGroupDao.countUserMusicGroups(id));
|
|
|
- musicCardDto.setVipClassNum(musicGroupDao.countCourseByType(id,ClassGroupTypeEnum.VIP));
|
|
|
+ musicCardDto.setVipClassNum(musicGroupDao.countCourseByType(id, ClassGroupTypeEnum.VIP));
|
|
|
return musicGroupDao.queryPersonalMusicGroups(id);
|
|
|
}
|
|
|
|
|
@@ -119,7 +144,127 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup>
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void cancelMusicGroup(String musicGroupId) {
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
+ public boolean cancelMusicGroup(String musicGroupId) {
|
|
|
+ MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
|
|
|
+ if (musicGroup == null) {
|
|
|
+ throw new BizException("乐团找不到");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (musicGroup.getStatus() == MusicGroupStatusEnum.APPLY || musicGroup.getStatus() == MusicGroupStatusEnum.PAY) {
|
|
|
+ musicGroup.setStatus(MusicGroupStatusEnum.CANCELED);
|
|
|
+ musicGroup.setUpdateTime(new Date());
|
|
|
+ musicGroupDao.update(musicGroup);
|
|
|
+ } else {
|
|
|
+ throw new BizException("乐团当前状态是{},不能取消", musicGroup.getStatus().getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 退费
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
+ public boolean pauseMusicGroup(String musicGroupId) {
|
|
|
+ MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
|
|
|
+ if (musicGroup == null) {
|
|
|
+ throw new BizException("乐团找不到");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (musicGroup.getStatus() != MusicGroupStatusEnum.PROGRESS) {
|
|
|
+ throw new BizException("乐团当前状态是{},不能暂停", musicGroup.getStatus().getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ musicGroup.setStatus(MusicGroupStatusEnum.PAUSE);
|
|
|
+ musicGroup.setUpdateTime(new Date());
|
|
|
+ musicGroupDao.update(musicGroup);
|
|
|
+
|
|
|
+ // 清除下次缴费时间
|
|
|
+ musicGroupStudentFeeDao.updateNextPaymentDate(musicGroupId, null);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
+ public boolean resumeMusicGroup(String musicGroupId) {
|
|
|
+ MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
|
|
|
+ if (musicGroup == null) {
|
|
|
+ throw new BizException("乐团找不到");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (musicGroup.getStatus() != MusicGroupStatusEnum.PAUSE) {
|
|
|
+ throw new BizException("乐团当前状态是{},不能恢复", musicGroup.getStatus().getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ musicGroup.setStatus(MusicGroupStatusEnum.PROGRESS);
|
|
|
+ musicGroup.setUpdateTime(new Date());
|
|
|
+ musicGroupDao.update(musicGroup);
|
|
|
+
|
|
|
+ // 查询下次缴费时间
|
|
|
+ List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
|
|
|
+ if (musicGroupPaymentCalenderList != null && musicGroupPaymentCalenderList.size() > 0) {
|
|
|
+
|
|
|
+ Collections.sort(musicGroupPaymentCalenderList);
|
|
|
+
|
|
|
+ Calendar cale = Calendar.getInstance();
|
|
|
+ int month = cale.get(Calendar.MONTH) + 1;
|
|
|
+
|
|
|
+ MusicGroupPaymentCalender calender = null;
|
|
|
+
|
|
|
+ for (MusicGroupPaymentCalender cal : musicGroupPaymentCalenderList) {
|
|
|
+ if (cal.getPaymentMonth() >= month) {
|
|
|
+ calender = cal;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 重新设置下次缴费时间
|
|
|
+ musicGroupStudentFeeDao.updateNextPaymentDate(musicGroupId, calender.getStartPaymentDate());
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean extensionPayment(String musicGroupId, Date expireDate) {
|
|
|
+ MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
|
|
|
+ if (musicGroup == null) {
|
|
|
+ throw new BizException("乐团找不到");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (musicGroup.getStatus() != MusicGroupStatusEnum.PAY) {
|
|
|
+ throw new BizException("乐团当前状态是{},延长缴费", musicGroup.getStatus().getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ Date date = new Date();
|
|
|
+
|
|
|
+ if (date.after(expireDate)) {
|
|
|
+ throw new BizException("日期设置错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ musicGroup.setPaymentExpireDate(expireDate);
|
|
|
+ musicGroup.setUpdateTime(date);
|
|
|
+ musicGroupDao.update(musicGroup);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean quitMusicGroup(String musicGroupId, Integer userId) {
|
|
|
+ MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
|
|
|
+ if (musicGroup == null) {
|
|
|
+ throw new BizException("乐团找不到");
|
|
|
+ }
|
|
|
|
|
|
+ classGroupStudentMapperDao.updateUserStatusByMusicGroupId(musicGroupId, userId, ClassGroupStudentStatusEnum.QUIT);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean renew(String musicGroupId, Integer userId, double amount) {
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|