|  | @@ -1,6 +1,8 @@
 | 
	
		
			
				|  |  |  package com.ym.mec.biz.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import com.ym.mec.auth.api.client.SysUserFeignService;
 | 
	
		
			
				|  |  |  import com.ym.mec.auth.api.entity.SysUser;
 | 
	
		
			
				|  |  | +import com.ym.mec.auth.api.enums.SysUserType;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dao.*;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dto.*;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.entity.MusicGroup;
 | 
	
	
		
			
				|  | @@ -8,9 +10,12 @@ import com.ym.mec.biz.dal.entity.StudentRegistration;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.entity.SysUserCashAccount;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.page.*;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.service.StudentManageService;
 | 
	
		
			
				|  |  | +import com.ym.mec.common.entity.ImResult;
 | 
	
		
			
				|  |  | +import com.ym.mec.common.entity.ImUserModel;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.exception.BizException;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.page.PageInfo;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.page.QueryInfo;
 | 
	
		
			
				|  |  | +import com.ym.mec.im.ImFeignService;
 | 
	
		
			
				|  |  |  import com.ym.mec.util.collection.MapUtil;
 | 
	
		
			
				|  |  |  import com.ym.mec.util.http.HttpUtil;
 | 
	
		
			
				|  |  |  import org.apache.commons.collections.MapUtils;
 | 
	
	
		
			
				|  | @@ -38,6 +43,10 @@ public class StudentManageServiceImpl implements StudentManageService {
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private StudentRegistrationDao studentRegistrationDao;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  | +    private ImFeignService imFeignService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private SysUserFeignService sysUserFeignService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  |      private ClassGroupDao classGroupDao;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private StudentPaymentOrderDao studentPaymentOrderDao;
 | 
	
	
		
			
				|  | @@ -275,4 +284,42 @@ public class StudentManageServiceImpl implements StudentManageService {
 | 
	
		
			
				|  |  |          pageInfo.setRows(dataList);
 | 
	
		
			
				|  |  |          return pageInfo;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | +    public int studentRegister(SysUser sysUser) {
 | 
	
		
			
				|  |  | +        if(sysUser == null || StringUtils.isEmpty(sysUser.getPhone())){
 | 
	
		
			
				|  |  | +            throw new BizException("参数校验失败");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        SysUser sysUser1 = sysUserFeignService.queryUserByMobile(sysUser.getPhone());
 | 
	
		
			
				|  |  | +        if(sysUser1 != null){
 | 
	
		
			
				|  |  | +            throw new BizException("手机号已被占用");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        sysUser.setUserType(SysUserType.STUDENT);
 | 
	
		
			
				|  |  | +        teacherDao.addSysUser(sysUser);
 | 
	
		
			
				|  |  | +        Integer userId = sysUser.getId();
 | 
	
		
			
				|  |  | +        ImResult register = imFeignService.register(new ImUserModel(userId.toString(), sysUser.getPhone(), null));
 | 
	
		
			
				|  |  | +        sysUser.setImToken(register.getToken());
 | 
	
		
			
				|  |  | +        teacherDao.updateUser(sysUser);
 | 
	
		
			
				|  |  | +        sysUserCashAccountDao.insert(new SysUserCashAccount(userId, "CNY"));
 | 
	
		
			
				|  |  | +        return userId;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | +    public int studentUpdate(SysUser sysUser) {
 | 
	
		
			
				|  |  | +        Integer userId = sysUser.getId();
 | 
	
		
			
				|  |  | +        if(userId == null || StringUtils.isEmpty(sysUser.getPhone())){
 | 
	
		
			
				|  |  | +            throw new BizException("参数校验失败");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        SysUser sysUser1 = sysUserFeignService.queryUserByMobile(sysUser.getPhone());
 | 
	
		
			
				|  |  | +        if(sysUser1 == null){
 | 
	
		
			
				|  |  | +            throw new BizException("用户不存在");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if(!userId.equals(sysUser1.getId())){
 | 
	
		
			
				|  |  | +            throw new BizException("手机号已被占用");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        teacherDao.updateUser(sysUser);
 | 
	
		
			
				|  |  | +        return userId;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |