Browse Source

新建乐团中增加乐团调整逻辑

周箭河 5 years ago
parent
commit
5fedb66147

+ 39 - 23
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentRegistrationDao.java

@@ -31,22 +31,22 @@ public interface StudentRegistrationDao extends BaseDAO<Long, StudentRegistratio
      */
     int queryStudentDetailCount(Map<String, Object> params);
 
-	/**
-	 * 根据乐团编号和声部获取缴费学员人数
-	 *
-	 * @param musicGroupId
-	 * @return
-	 */
-	List<Map<Integer, Long>> countPayNum(@Param("musicGroupId") String musicGroupId);
-
-	/**
-	 * 学生报名缴费金额详情
-	 *
-	 * @param studentId
-	 * @param musicGroupId
-	 * @return
-	 */
-	StudentFeeDetailDto queryFeeDetail(@Param("studentId") Integer studentId, @Param("musicGroupId") String musicGroupId);
+    /**
+     * 根据乐团编号和声部获取缴费学员人数
+     *
+     * @param musicGroupId
+     * @return
+     */
+    List<Map<Integer, Long>> countPayNum(@Param("musicGroupId") String musicGroupId);
+
+    /**
+     * 学生报名缴费金额详情
+     *
+     * @param studentId
+     * @param musicGroupId
+     * @return
+     */
+    StudentFeeDetailDto queryFeeDetail(@Param("studentId") Integer studentId, @Param("musicGroupId") String musicGroupId);
 
     /**
      * 获取乐团声部未分配的班级的学生
@@ -126,11 +126,27 @@ public interface StudentRegistrationDao extends BaseDAO<Long, StudentRegistratio
      */
     List<StudentRegistration> findMusicGroupStudent(@Param("musicGroupId") String musicGroupId, @Param("actualSubjectId") Integer actualSubjectId);
 
-	/**
-	 * 批量调剂学生专业
-	 * @param userIds
-	 * @param subId
-	 * @return
-	 */
-	int batchUpdateSubject(@Param("userIds")String userIds, @Param("subId") Integer subId,@Param("musicGroupId") String musicGroupId);
+    /**
+     * 批量调剂学生专业
+     *
+     * @param userIds
+     * @param subId
+     * @return
+     */
+    int batchUpdateSubject(@Param("userIds") String userIds, @Param("subId") Integer subId, @Param("musicGroupId") String musicGroupId);
+
+    /**
+     * 根据id list 查询报名学生
+     *
+     * @param idList
+     * @return
+     */
+    List<StudentRegistration> findStudentListByIdList(@Param("idList") List<Long> idList);
+
+    /**
+     * 批量插入
+     * @param studentRegistrationList
+     * @return
+     */
+    int batchInsert(@Param("studentRegistrationList") List<StudentRegistration> studentRegistrationList);
 }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SubFeeSettingDto.java

@@ -22,6 +22,9 @@ public class SubFeeSettingDto {
     @ApiModelProperty(value = "学员的付费方式月份列表",required = false)
     private List<Integer> months;
 
+    @ApiModelProperty(value = "科目关联注册学员",required = false)
+    private List<SubjectRegisterDto> subjectRegisters;
+
     public MusicGroup getMusicGroup() {
         return musicGroup;
     }
@@ -61,4 +64,12 @@ public class SubFeeSettingDto {
     public void setMonths(List<Integer> months) {
         this.months = months;
     }
+
+    public List<SubjectRegisterDto> getSubjectRegisters() {
+        return subjectRegisters;
+    }
+
+    public void setSubjectRegisters(List<SubjectRegisterDto> subjectRegisters) {
+        this.subjectRegisters = subjectRegisters;
+    }
 }

+ 30 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SubjectRegisterDto.java

@@ -0,0 +1,30 @@
+package com.ym.mec.biz.dal.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+public class SubjectRegisterDto {
+
+    @ApiModelProperty(value = "科目编号",required = true)
+    private Integer subjectId;
+
+    @ApiModelProperty(value = "注册ids",required = true)
+    private List<Long> registerIdList;
+
+    public Integer getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Integer subjectId) {
+        this.subjectId = subjectId;
+    }
+
+    public List<Long> getRegisterIdList() {
+        return registerIdList;
+    }
+
+    public void setRegisterIdList(List<Long> registerIdList) {
+        this.registerIdList = registerIdList;
+    }
+}

+ 0 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupSubjectPlan.java

@@ -55,7 +55,6 @@ public class MusicGroupSubjectPlan {
 	/** 保证金(只有租赁才有) */
 	@ApiModelProperty(value = "保证金(只有租赁才有)",required = false)
 	private BigDecimal depositFee = new BigDecimal(0);
-	
 	/**  */
 	private java.util.Date createTime;
 	

+ 14 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentRegistrationService.java

@@ -158,4 +158,18 @@ public interface StudentRegistrationService extends BaseService<Long, StudentReg
 	 */
 	List<StudentRegistration> getMusicGroupStu(String musicGroupId, Integer actualSubjectId);
 
+	/**
+	 * 根据id list 查询报名学生
+	 * @param idList
+	 * @return
+	 */
+	List<StudentRegistration> findStudentListByIdList(List<Long> idList);
+
+	/**
+	 * 批量插入
+	 * @param studentRegistrationList
+	 * @return
+	 */
+	int batchInsert(List<StudentRegistration> studentRegistrationList);
+
 }

+ 547 - 526
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -6,6 +6,7 @@ import com.ym.mec.biz.dal.dao.*;
 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.dto.SubjectRegisterDto;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
 import com.ym.mec.biz.dal.enums.*;
@@ -33,539 +34,559 @@ import java.util.stream.Collectors;
 @Service
 public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> implements MusicGroupService {
 
-	@Autowired
-	private MusicGroupDao musicGroupDao;
-	@Autowired
-	private ChargeTypeDao chargeTypeDao;
-	@Autowired
-	private TeacherDao teacherDao;
-	@Autowired
-	private IdGeneratorService idGeneratorService;
-	@Autowired
-	private SchoolDao schoolDao;
-	@Autowired
-	private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
-	@Autowired
-	private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;
-	@Autowired
-	private MusicGroupPaymentEntitiesDao musicGroupPaymentEntitiesDao;
-	@Autowired
-	private MusicGroupSubjectGoodsGroupDao musicGroupSubjectGoodsGroupDao;
-	@Autowired
-	private MusicGroupSubjectPlanDao musicGroupSubjectPlanDao;
-	@Autowired
-	private ImFeignService imFeignService;
-	@Autowired
-	private MusicGroupBuildLogDao musicGroupBuildLogDao;
-
-	@Autowired
-	private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
-
-	@Autowired
-	private ClassGroupStudentMapperDao classGroupStudentMapperDao;
-
-	@Autowired
-	private StudentPaymentOrderDao studentPaymentOrderDao;
-
-	@Autowired
-	private SysUserCashAccountService sysUserCashAccountService;
-
-	@Autowired
-	private SysUserCashAccountDetailService sysUserCashAccountDetailService;
-
-	@Autowired
-	private MusicGroupQuitDao musicGroupQuitDao;
-
-	@Autowired
-	private StudentRegistrationService studentRegistrationService;
-	
-	@Autowired
-	private CourseScheduleDao courseScheduleDao;
-	
-	@Autowired
-	private CourseScheduleTeacherSalaryDao courseScheduleTeacherSalaryDao;
-	
+    @Autowired
+    private MusicGroupDao musicGroupDao;
+    @Autowired
+    private ChargeTypeDao chargeTypeDao;
+    @Autowired
+    private TeacherDao teacherDao;
+    @Autowired
+    private IdGeneratorService idGeneratorService;
+    @Autowired
+    private SchoolDao schoolDao;
+    @Autowired
+    private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
+    @Autowired
+    private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;
+    @Autowired
+    private MusicGroupPaymentEntitiesDao musicGroupPaymentEntitiesDao;
+    @Autowired
+    private MusicGroupSubjectGoodsGroupDao musicGroupSubjectGoodsGroupDao;
+    @Autowired
+    private MusicGroupSubjectPlanDao musicGroupSubjectPlanDao;
+    @Autowired
+    private ImFeignService imFeignService;
+    @Autowired
+    private MusicGroupBuildLogDao musicGroupBuildLogDao;
+
+    @Autowired
+    private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
+
+    @Autowired
+    private ClassGroupStudentMapperDao classGroupStudentMapperDao;
+
+    @Autowired
+    private StudentPaymentOrderDao studentPaymentOrderDao;
+
+    @Autowired
+    private SysUserCashAccountService sysUserCashAccountService;
+
+    @Autowired
+    private SysUserCashAccountDetailService sysUserCashAccountDetailService;
+
+    @Autowired
+    private MusicGroupQuitDao musicGroupQuitDao;
+
+    @Autowired
+    private StudentRegistrationService studentRegistrationService;
+
+    @Autowired
+    private CourseScheduleDao courseScheduleDao;
+
+    @Autowired
+    private CourseScheduleTeacherSalaryDao courseScheduleTeacherSalaryDao;
+
     @Autowired
     private StudentPaymentOrderService studentPaymentOrderService;
-    
+
     @Autowired
     private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
 
-	@Autowired
-	private PayService payService;
+    @Autowired
+    private PayService payService;
 
     @Autowired
     private SysUserFeignService sysUserFeignService;
 
-	@Override
-	public BaseDAO<String, MusicGroup> getDAO() {
-		return musicGroupDao;
-	}
-
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public String createGroup(SubFeeSettingDto subFeeSettingDto, Integer userId) {
-		MusicGroup musicGroup = subFeeSettingDto.getMusicGroup();
-		List<MusicGroupSubjectGoodsGroup> musicGroupSubjectGoodsGroups = subFeeSettingDto.getMusicGroupSubjectGoodsGroups();
-		List<MusicGroupSubjectPlan> musicGroupSubjectPlans = subFeeSettingDto.getMusicGroupSubjectPlans();
-		String musicGroupId = idGeneratorService.generatorId() + "";
-		musicGroup.setId(musicGroupId);
-		// 保存乐团基本信息
-		musicGroupDao.insert(musicGroup);
-		// 保存乐团付费主体列表
-		//批量新增
-		musicGroupPaymentEntitiesDao.batchAdd(subFeeSettingDto.getMusicGroupPaymentEntities(),musicGroupId);
-		// 保存学员付费周期
-		List<Integer> months = subFeeSettingDto.getMonths();
-		if (months != null && months.size() > 0) {
-			musicGroupPaymentCalenderDao.batchAdd(months,musicGroupId);
-		}
-		// 保存乐团声部规划
-		if (musicGroupSubjectPlans == null) {
-			musicGroupSubjectPlans = new ArrayList<>();
-		}
-		musicGroupSubjectPlans.forEach(e -> {
-			e.setMusicGroupId(musicGroupId);
-			musicGroupSubjectPlanDao.insert(e);
-		});
-		// 保存乐团声部商品规划
-		if (musicGroupSubjectGoodsGroups == null) {
-			musicGroupSubjectGoodsGroups = new ArrayList<>();
-		}
-		musicGroupSubjectGoodsGroupDao.batchInsert(musicGroupSubjectGoodsGroups,musicGroupId);
-		// 新增聊天群
-		// 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, ""));
-		return musicGroupId;
-	}
-
-	@Override
-	public List<MusicCardDto> queryUserMusicGroups(Integer userId) {
-		List<MusicCardDto> musicCardDtos = musicGroupDao.queryUserMusicGroups(userId);
-		// 获取学员在该乐团续费状态
-		musicCardDtos.forEach(e -> {
-			MusicGroupStudentFee groupStudentFee = musicGroupStudentFeeDao.findByUser(userId, e.getMusicGroupId());
-			if(groupStudentFee != null){
-				e.setPaymentStatus(musicGroupStudentFeeDao.findByUser(userId, e.getMusicGroupId()).getPaymentStatus());
-			}
-		});
-		return musicCardDtos;
-	}
-
-	@Override
-	public MusicCardDto queryPersonalMusicGroups(Integer id) {
-		MusicCardDto musicCardDto = musicGroupDao.queryPersonalMusicGroups(id);
-		musicCardDto.setMusicGroupNum(musicGroupDao.countUserMusicGroups(id));
-		musicCardDto.setVipClassNum(musicGroupDao.countCourseByType(id, ClassGroupTypeEnum.VIP));
-		return musicGroupDao.queryPersonalMusicGroups(id);
-	}
-
-	@Override
-	public List<BasicUserDto> findTeachersByStuId(Integer studentId) {
-		return musicGroupDao.findTeachersByStuId(studentId);
-	}
-
-	@Override
-	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-	public boolean cancelMusicGroup(String musicGroupId) {
-		MusicGroup musicGroup = musicGroupDao.getLocked(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());
-		}
-
-		// 查询是否有中间状态的缴费信息
-		List<StudentPaymentOrder> studentPaymentOrders = studentPaymentOrderDao.queryByDealStatus(musicGroupId, OrderTypeEnum.APPLY, DealStatusEnum.ING);
-
-		if (studentPaymentOrders != null && studentPaymentOrders.size() > 0) {
-			throw new BizException("缴费存在交易中的数据,不能取消乐团");
-		}
-
-		// 查询已缴费信息
-		studentPaymentOrders = studentPaymentOrderDao.queryByDealStatus(musicGroupId, OrderTypeEnum.APPLY, DealStatusEnum.SUCCESS);
-
-		// 退费
-		for (StudentPaymentOrder order : studentPaymentOrders) {
-			sysUserCashAccountService.updateBalance(order.getUserId(), order.getActualAmount());
-			// 增加交易流水
-			sysUserCashAccountDetailService.addCashAccountDetail(order.getUserId(), order.getActualAmount(), SysUserCashAccountDetailService.MUSIC_GROUP
-					+ musicGroupId, "", PlatformCashAccountDetailTypeEnum.REFUNDS, null, DealStatusEnum.SUCCESS, "取消乐团");
-		}
-
-		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);
-
-		// 重新设置下次缴费时间
-		musicGroupStudentFeeDao.updateNextPaymentDate(musicGroupId, musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId));
-
-		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
-	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-	public boolean applyQuitMusicGroup(String musicGroupId, SysUser sysUser) {
-		MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
-		if (musicGroup == null) {
-			throw new BizException("乐团不存在");
-		}
-
-		MusicGroupQuit musicGroupQuit = new MusicGroupQuit();
-		musicGroupQuit.setCreateTime(new Date());
-		musicGroupQuit.setJoinDate(sysUser.getCreateTime());
-		musicGroupQuit.setMusicGroupId(musicGroupId);
-		musicGroupQuit.setUserId(sysUser.getId());
-		musicGroupQuit.setStatus(ApprovalStatus.PROCESSING);
-
-		musicGroupQuitDao.insert(musicGroupQuit);
-		return true;
-	}
-
-	@Override
-	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-	public boolean approveQuitMusicGroup(Long id, ApprovalStatus status, String reason) {
-		MusicGroupQuit musicGroupQuit = musicGroupQuitDao.get(id);
-		if (musicGroupQuit != null) {
-
-			Date date = new Date();
-
-			String musicGroupId = musicGroupQuit.getMusicGroupId();
-			Integer userId = musicGroupQuit.getUserId();
-
-			musicGroupQuit.setStatus(status);
-			musicGroupQuit.setReason(reason);
-			musicGroupQuit.setQuitDate(date);
-			musicGroupQuitDao.update(musicGroupQuit);
-
-			if (status == ApprovalStatus.APPROVED) {
-				classGroupStudentMapperDao.deleteStudentByMusicGroupId(musicGroupId, userId);
-
-				// 判断乐器是否是租赁
-				StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(userId, musicGroupId);
-				if (studentRegistration == null) {
-					throw new BizException("用户注册信息不存在");
-				}
-				// 退团
-				studentRegistration.setMusicGroupStatus(ClassGroupStudentStatusEnum.QUIT);
-				studentRegistration.setUpdateTime(date);
-
-				Integer subjectId = studentRegistration.getActualSubjectId();
-				MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, subjectId);
-				if (musicGroupSubjectPlan == null) {
-					throw new BizException("乐团声部费用设置不存在");
-				}
-				if (musicGroupSubjectPlan.getDepositFee().doubleValue() > 0) {
-					// 增加交易流水
-					sysUserCashAccountDetailService.addCashAccountDetail(userId, musicGroupSubjectPlan.getDepositFee(),
-							SysUserCashAccountDetailService.MUSIC_GROUP + musicGroupId, "", PlatformCashAccountDetailTypeEnum.REFUNDS, null,
-							DealStatusEnum.SUCCESS, "退出乐团");
-				}
-			}
-		}
-		return true;
-	}
-
-	@Override
-	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-	public boolean directQuitMusicGroup(String musicGroupId, Integer userId, String reason) {
-
-		SysUser sysUser = sysUserFeignService.queryUserById(userId);
-		if (sysUser == null) {
-			throw new BizException("获取用户信息失败");
-		}
-
-		Date date = new Date();
-
-		MusicGroupQuit musicGroupQuit = new MusicGroupQuit();
-		musicGroupQuit.setCreateTime(date);
-		musicGroupQuit.setJoinDate(sysUser.getCreateTime());
-		musicGroupQuit.setMusicGroupId(musicGroupId);
-		musicGroupQuit.setUserId(sysUser.getId());
-		musicGroupQuit.setStatus(ApprovalStatus.APPROVED);
-		musicGroupQuit.setReason(reason);
-		musicGroupQuit.setQuitDate(date);
-
-		musicGroupQuitDao.insert(musicGroupQuit);
-
-		classGroupStudentMapperDao.deleteStudentByMusicGroupId(musicGroupId, userId);
-
-		// 判断乐器是否是租赁
-		StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(userId, musicGroupId);
-		if (studentRegistration == null) {
-			throw new BizException("用户注册信息不存在");
-		}
-		// 退团
-		studentRegistration.setMusicGroupStatus(ClassGroupStudentStatusEnum.QUIT);
-		studentRegistration.setUpdateTime(date);
-
-		Integer subjectId = studentRegistration.getActualSubjectId();
-		MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, subjectId);
-		if (musicGroupSubjectPlan == null) {
-			throw new BizException("乐团声部费用设置不存在");
-		}
-		if (musicGroupSubjectPlan.getDepositFee().doubleValue() > 0) {
-			// 增加交易流水
-			sysUserCashAccountDetailService.addCashAccountDetail(userId, musicGroupSubjectPlan.getDepositFee(), SysUserCashAccountDetailService.MUSIC_GROUP
-					+ musicGroupId, "", PlatformCashAccountDetailTypeEnum.REFUNDS, null, DealStatusEnum.SUCCESS, "退出乐团");
-		}
-
-		return true;
-	}
-
-	@Override
-	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-	public Map renew(String musicGroupId, Integer userId) {
-
-		MusicGroup musicGroup = this.get(musicGroupId);
-		if (musicGroup == null) {
-			throw new BizException("乐团不存在");
-		}
-
-		MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(userId, musicGroupId);
-
-		if (musicGroupStudentFee == null) {
-			throw new BizException("个人信息不存在");
-		}
-		// 判断当前是否是续费状态
-		if (musicGroupStudentFee.getPaymentStatus() != PaymentStatus.NON_PAYMENT) {
-			throw new BizException("已缴费");
-		}
-
-		BigDecimal amount = musicGroupStudentFee.getTemporaryCourseFee();
-		if (amount == null || amount.doubleValue() == 0) {
-			amount = musicGroupStudentFee.getCourseFee();
-		}
-
-		Date date = new Date();
-		StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
-		studentPaymentOrder.setUserId(userId);
-		studentPaymentOrder.setOrderNo(idGeneratorService.generatorId("RENEW") + "");
-		studentPaymentOrder.setType(OrderTypeEnum.RENEW);
-		studentPaymentOrder.setExpectAmount(amount);
-		studentPaymentOrder.setActualAmount(amount);
-		studentPaymentOrder.setStatus(DealStatusEnum.ING);
-		studentPaymentOrder.setPaymentChannel("银联");
-		studentPaymentOrder.setMusicGroupId(musicGroupId);
-		studentPaymentOrderService.insert(studentPaymentOrder);
-
-		ArrayList<StudentPaymentOrderDetail> studentPaymentOrderDetailList = new ArrayList<>();
-		StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
-		studentPaymentOrderDetail.setType(OrderDetailTypeEnum.COURSE);
-		studentPaymentOrderDetail.setPrice(amount);
-		studentPaymentOrderDetail.setCreateTime(date);
-		studentPaymentOrderDetail.setUpdateTime(date);
-		studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
-		studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
-
-		studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);
-
-		try {
-			return payService.getPayMap(amount, idGeneratorService.generatorId("payment") + "", "https://pay.dayaedu.com/api/yqpay/notify",
-					"http://dev.dayaedu.com", "测试订单", "测试订单");
-		} catch (Exception e) {
-			throw new BizException("调用支付接口出错", e);
-		}
-	}
-
-	@Override
-	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-	public boolean renewForCallback(StudentPaymentOrder studentPaymentOrder) {
-		
-		studentPaymentOrderDao.update(studentPaymentOrder);
-		
-		Integer userId = studentPaymentOrder.getUserId();
-		String musicGroupId = studentPaymentOrder.getMusicGroupId();
-		
-		//更新下次续费时间
-		MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(userId, musicGroupId);
-		
-		if(musicGroupStudentFee == null){
-			throw new BizException("系统数据异常,找不到学员预缴费信息");
-		}
-		
-		Date date = new Date();
-		
-		musicGroupStudentFee.setUpdateTime(date);
-		musicGroupStudentFee.setLatestPaidTime(date);
-		musicGroupStudentFee.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
-		musicGroupStudentFee.setTemporaryCourseFee(new BigDecimal(0));
-		musicGroupStudentFee.setNextPaymentDate(musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId));
-		
-		musicGroupStudentFeeDao.update(musicGroupStudentFee);
-		
-		return true;
-	}
-
-	@Override
-	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-	public boolean updateTeacherCoursesSalary(Long courseScheduleId, Integer teacherId, BigDecimal salary, BigDecimal subsidy, String scope) {
-
-		CourseSchedule courseSchedule = courseScheduleDao.get(courseScheduleId);
-		if (courseSchedule == null) {
-			throw new BizException("课程信息不存在");
-		}
-
-		if ("all".equals(scope)) {
-			Integer classGrpupId = courseSchedule.getClassGroupId();
-			// 未结算的课酬都修改
-			courseScheduleTeacherSalaryDao.batchUpdateWages(classGrpupId, teacherId, salary, subsidy);
-		} else {
-			CourseScheduleTeacherSalary courseScheduleTeacherSalary = courseScheduleTeacherSalaryDao.queryByCourseScheduleIdAndUserId(courseScheduleId,
-					teacherId);
-			if (courseScheduleTeacherSalary == null) {
-				throw new BizException("课程结算信息不存在");
-			}
-			// 判断当前课程是否结算
-			if (courseScheduleTeacherSalary.getSettlementTime() != null) {
-				throw new BizException("课程已结算");
-			}
-			courseScheduleTeacherSalary.setExpectSalary(salary);
-			courseScheduleTeacherSalary.setSubsidy(subsidy);
-			courseScheduleTeacherSalary.setUpdateTime(new Date());
-			courseScheduleTeacherSalaryDao.update(courseScheduleTeacherSalary);
-		}
-		return true;
-	}
-
-	@Override
-	public PageInfo<MusicGroup> queryMusicGroupPage(QueryInfo queryInfo) {
-		PageInfo<MusicGroup> musicGroupPageInfo = queryPage(queryInfo);
-		List<MusicGroup> musicGroupList = musicGroupPageInfo.getRows();
-		// 获取学校编号列表
-		Set<Integer> schoolIds = musicGroupList.stream().map(e -> e.getSchoolId()).collect(Collectors.toSet());
-		List<Map<Integer, String>> schoolNames = schoolDao.queryNameByIds(schoolIds);
-		// 获取相关学校名称map
-		Map<Integer, String> schoolNameMap = MapUtil.convertMybatisMap(schoolNames);
-
-		// 获取教务老师编号列表
-		Set<Integer> educationalTeacherIds = musicGroupList.stream().map(e -> e.getEducationalTeacherId()).collect(Collectors.toSet());
-		// 获取相关老师的名字
-		List<Map<Integer, String>> educationalTeacherNames = teacherDao.queryNameByIds(educationalTeacherIds);
-		Map<Integer, String> educationalTeacherNameMap = MapUtil.convertMybatisMap(educationalTeacherNames);
-
-		// 获取运营主管编号列表
-		Set<Integer> teamTeacherIds = musicGroupList.stream().map(e -> e.getTeamTeacherId()).collect(Collectors.toSet());
-		List<Map<Integer, String>> teamTeacherNames = teacherDao.queryNameByIds(teamTeacherIds);
-		Map<Integer, String> teamTeacherNameMap = MapUtil.convertMybatisMap(teamTeacherNames);
-
-		// 获取乐团编号列表
-		Set<String> musicGroupIds = musicGroupList.stream().map(e -> e.getId()).collect(Collectors.toSet());
-		// 统计乐团在读人数
-		List<Map<String, Long>> payNums = musicGroupDao.countPayNum(musicGroupIds);
-		Map<String, Long> payNumMap = MapUtil.convertMybatisMap(payNums);
-
-		// 获取收费类型编号列表
-		Set<Integer> chargeTypeIds = musicGroupList.stream().map(e -> e.getChargeTypeId()).collect(Collectors.toSet());
-		List<Map<Integer, String>> chargeTypeNames = chargeTypeDao.queryNameByIds(chargeTypeIds);
-		Map<Integer, String> chargeTypeNameMap = MapUtil.convertMybatisMap(chargeTypeNames);
-
-		musicGroupList.forEach(e -> {
-			e.setSchoolName(schoolNameMap.get(e.getSchoolId()));
-			e.setEducationalTeacherName(educationalTeacherNameMap.get(e.getEducationalTeacherId()));
-			e.setTeamTeacherName(teamTeacherNameMap.get(e.getTeamTeacherId()));
-			e.setPayNum(payNumMap.get(e.getId()) == null ? 0 : payNumMap.get(e.getId()).intValue());
-			e.setChargeTypeName(chargeTypeNameMap.get(e.getChargeTypeId()));
-		});
-		return musicGroupPageInfo;
-	}
-
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public void updateBaseInfo(SubFeeSettingDto subFeeSettingDto) {
-		MusicGroup musicGroup = subFeeSettingDto.getMusicGroup();
-		String musicGroupId = musicGroup.getId();
-		MusicGroup group = musicGroupDao.get(musicGroupId);
-		if(group != null){
-			musicGroupDao.update(musicGroup);
-			//修改课程里面的教学点
-			if(!group.getSchoolId().equals(musicGroup.getSchoolId())){
-				courseScheduleDao.updateByMusicGroupId(musicGroupId,musicGroup.getSchoolId());
-			}
-			// 删除乐团付费主体列表
-			musicGroupPaymentEntitiesDao.delByGroupId(musicGroupId);
-			//批量新增
-			musicGroupPaymentEntitiesDao.batchAdd(subFeeSettingDto.getMusicGroupPaymentEntities(),musicGroupId);
-
-			// 修改学员付费周期
-			List<Integer> calender = subFeeSettingDto.getMonths();
-			//删除乐团相关付费周期
-			musicGroupPaymentCalenderDao.delByGroupId(musicGroupId);
-			//批量插入
-			musicGroupPaymentCalenderDao.batchAdd(calender,musicGroupId);
-		}
-	}
+    @Override
+    public BaseDAO<String, MusicGroup> getDAO() {
+        return musicGroupDao;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public String createGroup(SubFeeSettingDto subFeeSettingDto, Integer userId) {
+        MusicGroup musicGroup = subFeeSettingDto.getMusicGroup();
+        List<MusicGroupSubjectGoodsGroup> musicGroupSubjectGoodsGroups = subFeeSettingDto.getMusicGroupSubjectGoodsGroups();
+        List<MusicGroupSubjectPlan> musicGroupSubjectPlans = subFeeSettingDto.getMusicGroupSubjectPlans();
+        List<SubjectRegisterDto> subjectRegisters = subFeeSettingDto.getSubjectRegisters();
+        String musicGroupId = idGeneratorService.generatorId() + "";
+        musicGroup.setId(musicGroupId);
+        // 保存乐团基本信息
+        musicGroupDao.insert(musicGroup);
+        // 保存乐团付费主体列表
+        //批量新增
+        musicGroupPaymentEntitiesDao.batchAdd(subFeeSettingDto.getMusicGroupPaymentEntities(), musicGroupId);
+        // 保存学员付费周期
+        List<Integer> months = subFeeSettingDto.getMonths();
+        if (months != null && months.size() > 0) {
+            musicGroupPaymentCalenderDao.batchAdd(months, musicGroupId);
+        }
+        // 保存乐团声部规划
+        if (musicGroupSubjectPlans == null) {
+            musicGroupSubjectPlans = new ArrayList<>();
+        }
+        musicGroupSubjectPlans.forEach(e -> {
+            e.setMusicGroupId(musicGroupId);
+            musicGroupSubjectPlanDao.insert(e);
+        });
+
+        if (subjectRegisters != null) {
+            List<StudentRegistration> studentRegistrationList = new ArrayList<>();
+            subjectRegisters.forEach(e -> {
+                        //原来乐团的注册学生
+                        List<StudentRegistration> musicGroupStudentRegistrationList = studentRegistrationService.findStudentListByIdList(e.getRegisterIdList());
+                        for (StudentRegistration studentRegistration : musicGroupStudentRegistrationList) {
+                            studentRegistration.setMusicGroupStatus(ClassGroupStudentStatusEnum.NORMAL);
+                            studentRegistration.setPaymentStatus(YesOrNoEnum.NO);
+                            studentRegistration.setMusicGroupId(musicGroupId);
+                            studentRegistration.setSubjectId(e.getSubjectId());
+                            studentRegistration.setActualSubjectId(e.getSubjectId());
+                        }
+                        studentRegistrationList.addAll(musicGroupStudentRegistrationList);
+                    }
+            );
+            studentRegistrationService.batchInsert(studentRegistrationList);
+        }
+
+        // 保存乐团声部商品规划
+        if (musicGroupSubjectGoodsGroups == null) {
+            musicGroupSubjectGoodsGroups = new ArrayList<>();
+        }
+        musicGroupSubjectGoodsGroupDao.batchInsert(musicGroupSubjectGoodsGroups, musicGroupId);
+        // 新增聊天群
+        // 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, ""));
+        return musicGroupId;
+    }
+
+    @Override
+    public List<MusicCardDto> queryUserMusicGroups(Integer userId) {
+        List<MusicCardDto> musicCardDtos = musicGroupDao.queryUserMusicGroups(userId);
+        // 获取学员在该乐团续费状态
+        musicCardDtos.forEach(e -> {
+            MusicGroupStudentFee groupStudentFee = musicGroupStudentFeeDao.findByUser(userId, e.getMusicGroupId());
+            if (groupStudentFee != null) {
+                e.setPaymentStatus(musicGroupStudentFeeDao.findByUser(userId, e.getMusicGroupId()).getPaymentStatus());
+            }
+        });
+        return musicCardDtos;
+    }
+
+    @Override
+    public MusicCardDto queryPersonalMusicGroups(Integer id) {
+        MusicCardDto musicCardDto = musicGroupDao.queryPersonalMusicGroups(id);
+        musicCardDto.setMusicGroupNum(musicGroupDao.countUserMusicGroups(id));
+        musicCardDto.setVipClassNum(musicGroupDao.countCourseByType(id, ClassGroupTypeEnum.VIP));
+        return musicGroupDao.queryPersonalMusicGroups(id);
+    }
+
+    @Override
+    public List<BasicUserDto> findTeachersByStuId(Integer studentId) {
+        return musicGroupDao.findTeachersByStuId(studentId);
+    }
+
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public boolean cancelMusicGroup(String musicGroupId) {
+        MusicGroup musicGroup = musicGroupDao.getLocked(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());
+        }
+
+        // 查询是否有中间状态的缴费信息
+        List<StudentPaymentOrder> studentPaymentOrders = studentPaymentOrderDao.queryByDealStatus(musicGroupId, OrderTypeEnum.APPLY, DealStatusEnum.ING);
+
+        if (studentPaymentOrders != null && studentPaymentOrders.size() > 0) {
+            throw new BizException("缴费存在交易中的数据,不能取消乐团");
+        }
+
+        // 查询已缴费信息
+        studentPaymentOrders = studentPaymentOrderDao.queryByDealStatus(musicGroupId, OrderTypeEnum.APPLY, DealStatusEnum.SUCCESS);
+
+        // 退费
+        for (StudentPaymentOrder order : studentPaymentOrders) {
+            sysUserCashAccountService.updateBalance(order.getUserId(), order.getActualAmount());
+            // 增加交易流水
+            sysUserCashAccountDetailService.addCashAccountDetail(order.getUserId(), order.getActualAmount(), SysUserCashAccountDetailService.MUSIC_GROUP
+                    + musicGroupId, "", PlatformCashAccountDetailTypeEnum.REFUNDS, null, DealStatusEnum.SUCCESS, "取消乐团");
+        }
+
+        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);
+
+        // 重新设置下次缴费时间
+        musicGroupStudentFeeDao.updateNextPaymentDate(musicGroupId, musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId));
+
+        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
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public boolean applyQuitMusicGroup(String musicGroupId, SysUser sysUser) {
+        MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
+        if (musicGroup == null) {
+            throw new BizException("乐团不存在");
+        }
+
+        MusicGroupQuit musicGroupQuit = new MusicGroupQuit();
+        musicGroupQuit.setCreateTime(new Date());
+        musicGroupQuit.setJoinDate(sysUser.getCreateTime());
+        musicGroupQuit.setMusicGroupId(musicGroupId);
+        musicGroupQuit.setUserId(sysUser.getId());
+        musicGroupQuit.setStatus(ApprovalStatus.PROCESSING);
+
+        musicGroupQuitDao.insert(musicGroupQuit);
+        return true;
+    }
+
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public boolean approveQuitMusicGroup(Long id, ApprovalStatus status, String reason) {
+        MusicGroupQuit musicGroupQuit = musicGroupQuitDao.get(id);
+        if (musicGroupQuit != null) {
+
+            Date date = new Date();
+
+            String musicGroupId = musicGroupQuit.getMusicGroupId();
+            Integer userId = musicGroupQuit.getUserId();
+
+            musicGroupQuit.setStatus(status);
+            musicGroupQuit.setReason(reason);
+            musicGroupQuit.setQuitDate(date);
+            musicGroupQuitDao.update(musicGroupQuit);
+
+            if (status == ApprovalStatus.APPROVED) {
+                classGroupStudentMapperDao.deleteStudentByMusicGroupId(musicGroupId, userId);
+
+                // 判断乐器是否是租赁
+                StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(userId, musicGroupId);
+                if (studentRegistration == null) {
+                    throw new BizException("用户注册信息不存在");
+                }
+                // 退团
+                studentRegistration.setMusicGroupStatus(ClassGroupStudentStatusEnum.QUIT);
+                studentRegistration.setUpdateTime(date);
+
+                Integer subjectId = studentRegistration.getActualSubjectId();
+                MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, subjectId);
+                if (musicGroupSubjectPlan == null) {
+                    throw new BizException("乐团声部费用设置不存在");
+                }
+                if (musicGroupSubjectPlan.getDepositFee().doubleValue() > 0) {
+                    // 增加交易流水
+                    sysUserCashAccountDetailService.addCashAccountDetail(userId, musicGroupSubjectPlan.getDepositFee(),
+                            SysUserCashAccountDetailService.MUSIC_GROUP + musicGroupId, "", PlatformCashAccountDetailTypeEnum.REFUNDS, null,
+                            DealStatusEnum.SUCCESS, "退出乐团");
+                }
+            }
+        }
+        return true;
+    }
+
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public boolean directQuitMusicGroup(String musicGroupId, Integer userId, String reason) {
+
+        SysUser sysUser = sysUserFeignService.queryUserById(userId);
+        if (sysUser == null) {
+            throw new BizException("获取用户信息失败");
+        }
+
+        Date date = new Date();
+
+        MusicGroupQuit musicGroupQuit = new MusicGroupQuit();
+        musicGroupQuit.setCreateTime(date);
+        musicGroupQuit.setJoinDate(sysUser.getCreateTime());
+        musicGroupQuit.setMusicGroupId(musicGroupId);
+        musicGroupQuit.setUserId(sysUser.getId());
+        musicGroupQuit.setStatus(ApprovalStatus.APPROVED);
+        musicGroupQuit.setReason(reason);
+        musicGroupQuit.setQuitDate(date);
+
+        musicGroupQuitDao.insert(musicGroupQuit);
+
+        classGroupStudentMapperDao.deleteStudentByMusicGroupId(musicGroupId, userId);
+
+        // 判断乐器是否是租赁
+        StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(userId, musicGroupId);
+        if (studentRegistration == null) {
+            throw new BizException("用户注册信息不存在");
+        }
+        // 退团
+        studentRegistration.setMusicGroupStatus(ClassGroupStudentStatusEnum.QUIT);
+        studentRegistration.setUpdateTime(date);
+
+        Integer subjectId = studentRegistration.getActualSubjectId();
+        MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, subjectId);
+        if (musicGroupSubjectPlan == null) {
+            throw new BizException("乐团声部费用设置不存在");
+        }
+        if (musicGroupSubjectPlan.getDepositFee().doubleValue() > 0) {
+            // 增加交易流水
+            sysUserCashAccountDetailService.addCashAccountDetail(userId, musicGroupSubjectPlan.getDepositFee(), SysUserCashAccountDetailService.MUSIC_GROUP
+                    + musicGroupId, "", PlatformCashAccountDetailTypeEnum.REFUNDS, null, DealStatusEnum.SUCCESS, "退出乐团");
+        }
+
+        return true;
+    }
+
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public Map renew(String musicGroupId, Integer userId) {
+
+        MusicGroup musicGroup = this.get(musicGroupId);
+        if (musicGroup == null) {
+            throw new BizException("乐团不存在");
+        }
+
+        MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(userId, musicGroupId);
+
+        if (musicGroupStudentFee == null) {
+            throw new BizException("个人信息不存在");
+        }
+        // 判断当前是否是续费状态
+        if (musicGroupStudentFee.getPaymentStatus() != PaymentStatus.NON_PAYMENT) {
+            throw new BizException("已缴费");
+        }
+
+        BigDecimal amount = musicGroupStudentFee.getTemporaryCourseFee();
+        if (amount == null || amount.doubleValue() == 0) {
+            amount = musicGroupStudentFee.getCourseFee();
+        }
+
+        Date date = new Date();
+        StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
+        studentPaymentOrder.setUserId(userId);
+        studentPaymentOrder.setOrderNo(idGeneratorService.generatorId("RENEW") + "");
+        studentPaymentOrder.setType(OrderTypeEnum.RENEW);
+        studentPaymentOrder.setExpectAmount(amount);
+        studentPaymentOrder.setActualAmount(amount);
+        studentPaymentOrder.setStatus(DealStatusEnum.ING);
+        studentPaymentOrder.setPaymentChannel("银联");
+        studentPaymentOrder.setMusicGroupId(musicGroupId);
+        studentPaymentOrderService.insert(studentPaymentOrder);
+
+        ArrayList<StudentPaymentOrderDetail> studentPaymentOrderDetailList = new ArrayList<>();
+        StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
+        studentPaymentOrderDetail.setType(OrderDetailTypeEnum.COURSE);
+        studentPaymentOrderDetail.setPrice(amount);
+        studentPaymentOrderDetail.setCreateTime(date);
+        studentPaymentOrderDetail.setUpdateTime(date);
+        studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
+        studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
+
+        studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);
+
+        try {
+            return payService.getPayMap(amount, idGeneratorService.generatorId("payment") + "", "https://pay.dayaedu.com/api/yqpay/notify",
+                    "http://dev.dayaedu.com", "测试订单", "测试订单");
+        } catch (Exception e) {
+            throw new BizException("调用支付接口出错", e);
+        }
+    }
+
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public boolean renewForCallback(StudentPaymentOrder studentPaymentOrder) {
+
+        studentPaymentOrderDao.update(studentPaymentOrder);
+
+        Integer userId = studentPaymentOrder.getUserId();
+        String musicGroupId = studentPaymentOrder.getMusicGroupId();
+
+        //更新下次续费时间
+        MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(userId, musicGroupId);
+
+        if (musicGroupStudentFee == null) {
+            throw new BizException("系统数据异常,找不到学员预缴费信息");
+        }
+
+        Date date = new Date();
+
+        musicGroupStudentFee.setUpdateTime(date);
+        musicGroupStudentFee.setLatestPaidTime(date);
+        musicGroupStudentFee.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
+        musicGroupStudentFee.setTemporaryCourseFee(new BigDecimal(0));
+        musicGroupStudentFee.setNextPaymentDate(musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId));
+
+        musicGroupStudentFeeDao.update(musicGroupStudentFee);
+
+        return true;
+    }
+
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public boolean updateTeacherCoursesSalary(Long courseScheduleId, Integer teacherId, BigDecimal salary, BigDecimal subsidy, String scope) {
+
+        CourseSchedule courseSchedule = courseScheduleDao.get(courseScheduleId);
+        if (courseSchedule == null) {
+            throw new BizException("课程信息不存在");
+        }
+
+        if ("all".equals(scope)) {
+            Integer classGrpupId = courseSchedule.getClassGroupId();
+            // 未结算的课酬都修改
+            courseScheduleTeacherSalaryDao.batchUpdateWages(classGrpupId, teacherId, salary, subsidy);
+        } else {
+            CourseScheduleTeacherSalary courseScheduleTeacherSalary = courseScheduleTeacherSalaryDao.queryByCourseScheduleIdAndUserId(courseScheduleId,
+                    teacherId);
+            if (courseScheduleTeacherSalary == null) {
+                throw new BizException("课程结算信息不存在");
+            }
+            // 判断当前课程是否结算
+            if (courseScheduleTeacherSalary.getSettlementTime() != null) {
+                throw new BizException("课程已结算");
+            }
+            courseScheduleTeacherSalary.setExpectSalary(salary);
+            courseScheduleTeacherSalary.setSubsidy(subsidy);
+            courseScheduleTeacherSalary.setUpdateTime(new Date());
+            courseScheduleTeacherSalaryDao.update(courseScheduleTeacherSalary);
+        }
+        return true;
+    }
+
+    @Override
+    public PageInfo<MusicGroup> queryMusicGroupPage(QueryInfo queryInfo) {
+        PageInfo<MusicGroup> musicGroupPageInfo = queryPage(queryInfo);
+        List<MusicGroup> musicGroupList = musicGroupPageInfo.getRows();
+        // 获取学校编号列表
+        Set<Integer> schoolIds = musicGroupList.stream().map(e -> e.getSchoolId()).collect(Collectors.toSet());
+        List<Map<Integer, String>> schoolNames = schoolDao.queryNameByIds(schoolIds);
+        // 获取相关学校名称map
+        Map<Integer, String> schoolNameMap = MapUtil.convertMybatisMap(schoolNames);
+
+        // 获取教务老师编号列表
+        Set<Integer> educationalTeacherIds = musicGroupList.stream().map(e -> e.getEducationalTeacherId()).collect(Collectors.toSet());
+        // 获取相关老师的名字
+        List<Map<Integer, String>> educationalTeacherNames = teacherDao.queryNameByIds(educationalTeacherIds);
+        Map<Integer, String> educationalTeacherNameMap = MapUtil.convertMybatisMap(educationalTeacherNames);
+
+        // 获取运营主管编号列表
+        Set<Integer> teamTeacherIds = musicGroupList.stream().map(e -> e.getTeamTeacherId()).collect(Collectors.toSet());
+        List<Map<Integer, String>> teamTeacherNames = teacherDao.queryNameByIds(teamTeacherIds);
+        Map<Integer, String> teamTeacherNameMap = MapUtil.convertMybatisMap(teamTeacherNames);
+
+        // 获取乐团编号列表
+        Set<String> musicGroupIds = musicGroupList.stream().map(e -> e.getId()).collect(Collectors.toSet());
+        // 统计乐团在读人数
+        List<Map<String, Long>> payNums = musicGroupDao.countPayNum(musicGroupIds);
+        Map<String, Long> payNumMap = MapUtil.convertMybatisMap(payNums);
+
+        // 获取收费类型编号列表
+        Set<Integer> chargeTypeIds = musicGroupList.stream().map(e -> e.getChargeTypeId()).collect(Collectors.toSet());
+        List<Map<Integer, String>> chargeTypeNames = chargeTypeDao.queryNameByIds(chargeTypeIds);
+        Map<Integer, String> chargeTypeNameMap = MapUtil.convertMybatisMap(chargeTypeNames);
+
+        musicGroupList.forEach(e -> {
+            e.setSchoolName(schoolNameMap.get(e.getSchoolId()));
+            e.setEducationalTeacherName(educationalTeacherNameMap.get(e.getEducationalTeacherId()));
+            e.setTeamTeacherName(teamTeacherNameMap.get(e.getTeamTeacherId()));
+            e.setPayNum(payNumMap.get(e.getId()) == null ? 0 : payNumMap.get(e.getId()).intValue());
+            e.setChargeTypeName(chargeTypeNameMap.get(e.getChargeTypeId()));
+        });
+        return musicGroupPageInfo;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updateBaseInfo(SubFeeSettingDto subFeeSettingDto) {
+        MusicGroup musicGroup = subFeeSettingDto.getMusicGroup();
+        String musicGroupId = musicGroup.getId();
+        MusicGroup group = musicGroupDao.get(musicGroupId);
+        if (group != null) {
+            musicGroupDao.update(musicGroup);
+            //修改课程里面的教学点
+            if (!group.getSchoolId().equals(musicGroup.getSchoolId())) {
+                courseScheduleDao.updateByMusicGroupId(musicGroupId, musicGroup.getSchoolId());
+            }
+            // 删除乐团付费主体列表
+            musicGroupPaymentEntitiesDao.delByGroupId(musicGroupId);
+            //批量新增
+            musicGroupPaymentEntitiesDao.batchAdd(subFeeSettingDto.getMusicGroupPaymentEntities(), musicGroupId);
+
+            // 修改学员付费周期
+            List<Integer> calender = subFeeSettingDto.getMonths();
+            //删除乐团相关付费周期
+            musicGroupPaymentCalenderDao.delByGroupId(musicGroupId);
+            //批量插入
+            musicGroupPaymentCalenderDao.batchAdd(calender, musicGroupId);
+        }
+    }
 }

+ 14 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -90,14 +90,14 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     }
 
     @Override
-    public Integer batchUpdateSubject(String userIds, Integer subId,String musicGroupId) {
+    public Integer batchUpdateSubject(String userIds, Integer subId, String musicGroupId) {
         //批量调剂(未缴费学员)
-        return studentRegistrationDao.batchUpdateSubject(userIds,subId,musicGroupId);
+        return studentRegistrationDao.batchUpdateSubject(userIds, subId, musicGroupId);
     }
 
     @Override
     public StudentFeeDetailDto queryFeeDetail(Integer studentId, String musicGroupId) {
-		return studentRegistrationDao.queryFeeDetail(studentId,musicGroupId);
+        return studentRegistrationDao.queryFeeDetail(studentId, musicGroupId);
     }
 
     @Override
@@ -440,6 +440,16 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
     @Override
     public List<StudentRegistration> getMusicGroupStu(String musicGroupId, Integer actualSubjectId) {
-        return studentRegistrationDao.findMusicGroupStudent(musicGroupId,actualSubjectId);
+        return studentRegistrationDao.findMusicGroupStudent(musicGroupId, actualSubjectId);
+    }
+
+    @Override
+    public List<StudentRegistration> findStudentListByIdList(List<Long> idList) {
+        return studentRegistrationDao.findStudentListByIdList(idList);
+    }
+
+    @Override
+    public int batchInsert(List<StudentRegistration> studentRegistrationList) {
+        return studentRegistrationDao.batchInsert(studentRegistrationList);
     }
 }

+ 18 - 0
mec-biz/src/main/resources/config/mybatis/StudentRegistrationMapper.xml

@@ -323,4 +323,22 @@
         </if>
         AND payment_status_ = 1
     </select>
+
+    <!-- 根据注册id list查询报名学生的信息 -->
+    <select id="findStudentListByIdList" resultMap="StudentRegistration">
+        SELECT * FROM student_registration WHERE id_ IN
+        <foreach collection="idList" item="id" index="index" open="(" close=")" separator=",">
+            #{id}
+        </foreach>
+    </select>
+
+    <insert id="batchInsert">
+        INSERT INTO student_registration
+        (parents_phone_,id_,user_id_,name_,music_group_id_,current_grade_,current_class_,subject_id_,is_allow_adjust_,kit_purchase_method_,remark_,create_time_,update_time_,parents_name_,parents_company_,payment_status_,actual_subject_id_,music_group_status_)
+        VALUES
+        <foreach collection="studentRegistrationList" item="item" index="index" separator=",">
+            (#{item.parentsPhone},#{item.id},#{item.userId},#{item.name},#{item.musicGroupId},#{item.currentGrade},#{item.currentClass},#{item.subjectId},#{item.isAllowAdjust,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.kitPurchaseMethod,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+            #{item.remark},now(),now(),#{item.parentsName},#{item.parentsCompany},#{item.paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.subjectId},#{item.musicGroupStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
+        </foreach>
+    </insert>
 </mapper>

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/ClassGroupController.java

@@ -207,7 +207,7 @@ public class ClassGroupController extends BaseController {
     }
 
 
-    @ApiOperation(value = "调整班级")
+    @ApiOperation(value = "调整班级(添加班级)")
     @PostMapping("/revisionClassGroup")
     @PreAuthorize("@pcs.hasPermissions('classGroup/revisionClassGroup')")
     @ApiImplicitParams({@ApiImplicitParam(name = "classGroupIds", value = "班级编号,号分割", required = true, dataType = "String")})