|  | @@ -20,6 +20,7 @@ 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.dao.StudentPaymentOrderDao;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dto.BasicUserDto;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dto.MusicCardDto;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dto.SubFeeSettingDto;
 | 
	
	
		
			
				|  | @@ -29,10 +30,14 @@ 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.entity.StudentPaymentOrder;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.DealStatusEnum;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.service.MusicGroupService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.SysUserCashAccountService;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.dal.BaseDAO;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.entity.ImGroupMember;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.entity.ImGroupModel;
 | 
	
	
		
			
				|  | @@ -63,7 +68,13 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	@Autowired
 | 
	
		
			
				|  |  |  	private ClassGroupStudentMapperDao classGroupStudentMapperDao;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	@Autowired
 | 
	
		
			
				|  |  | +	private StudentPaymentOrderDao studentPaymentOrderDao;
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	@Autowired
 | 
	
		
			
				|  |  | +	private SysUserCashAccountService sysUserCashAccountService;
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  |  	@Override
 | 
	
		
			
				|  |  |  	public BaseDAO<String, MusicGroup> getDAO() {
 | 
	
		
			
				|  |  |  		return musicGroupDao;
 | 
	
	
		
			
				|  | @@ -114,7 +125,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |  				musicGroupSubjectGoodsGroupDao.insert(e);
 | 
	
		
			
				|  |  |  			});
 | 
	
		
			
				|  |  |  			// 新增聊天群
 | 
	
		
			
				|  |  | -			ImGroupModel imGroupModel = new ImGroupModel(musicGroupId, musicGroup.getName());
 | 
	
		
			
				|  |  | +//			ImGroupModel imGroupModel = new ImGroupModel(musicGroupId, musicGroup.getName());
 | 
	
		
			
				|  |  |  			// 教务老师和运营主管加入群组
 | 
	
		
			
				|  |  |  			ImGroupMember[] imGroupMembers = { new ImGroupMember(musicGroup.getTeamTeacherId().toString()),
 | 
	
		
			
				|  |  |  					new ImGroupMember(musicGroup.getEducationalTeacherId().toString()) };
 | 
	
	
		
			
				|  | @@ -146,7 +157,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |  	@Override
 | 
	
		
			
				|  |  |  	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |  	public boolean cancelMusicGroup(String musicGroupId) {
 | 
	
		
			
				|  |  | -		MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
 | 
	
		
			
				|  |  | +		MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
 | 
	
		
			
				|  |  |  		if (musicGroup == null) {
 | 
	
		
			
				|  |  |  			throw new BizException("乐团找不到");
 | 
	
		
			
				|  |  |  		}
 | 
	
	
		
			
				|  | @@ -158,9 +169,22 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |  		} 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());
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  |  		return true;
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 |