|  | @@ -5,13 +5,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.dao.StudentDao;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.dto.search.StudentSearch;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.entity.*;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.enums.MessageTypeEnum;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.enums.SourceTypeEnum;
 | 
	
		
			
				|  |  | -import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.mapper.TenantActivationCodeMapper;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumPurchaseMapper;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.mapper.UserTenantAlbumRecordMapper;
 | 
	
	
		
			
				|  | @@ -51,7 +51,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
 | 
	
		
			
				|  |  |      private StudentDao studentDao;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  | -    private SysUserMapper sysUserMapper;
 | 
	
		
			
				|  |  | +    private SysUserService sysUserService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private TenantAlbumPurchaseMapper tenantAlbumPurchaseMapper;
 | 
	
	
		
			
				|  | @@ -150,7 +150,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          List<Long> studentIds = students.stream().map(Student::getUserId).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -        Map<Long, String> idPhoneMap = sysUserMapper.selectBatchIds(studentIds).stream()
 | 
	
		
			
				|  |  | +        Map<Long, String> idPhoneMap = sysUserService.getDao().selectBatchIds(studentIds).stream()
 | 
	
		
			
				|  |  |                  .collect(Collectors.toMap(SysUser::getId, SysUser::getPhone));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          for (int i = 0; i < studentIds.size(); i++) {
 | 
	
	
		
			
				|  | @@ -172,8 +172,8 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private void sendActivationCodeMessage(Long userId,String phone) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        Map<Long, String> receivers = new HashMap<>();
 | 
	
		
			
				|  |  | -        receivers.put(userId, userId.toString());
 | 
	
		
			
				|  |  | +        Map<Long, String> receivers = new HashMap<>(1);
 | 
	
		
			
				|  |  | +        receivers.put(userId, phone);
 | 
	
		
			
				|  |  |          try {
 | 
	
		
			
				|  |  |              String url = sysMessageService.selectConfigUrl(MessageTypeEnum.TENANT_SEND_CODE.getCode());
 | 
	
		
			
				|  |  |              sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.TENANT_SEND_CODE,
 | 
	
	
		
			
				|  | @@ -211,7 +211,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
 | 
	
		
			
				|  |  |          if (code == null) {
 | 
	
		
			
				|  |  |              throw new BizException("激活码不存在");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        SysUser sysUser = sysUserMapper.selectById(studentId);
 | 
	
		
			
				|  |  | +        SysUser sysUser = sysUserService.getDao().selectById(studentId);
 | 
	
		
			
				|  |  |          if (Boolean.TRUE.equals(code.getActivationStatus()) || (EActivationCode.SEND.equals(code.getSendStatus()) &&
 | 
	
		
			
				|  |  |                  !sysUser.getPhone().equals(code.getActivationPhone()))) {
 | 
	
		
			
				|  |  |              throw new BizException("激活码已经被使用");
 | 
	
	
		
			
				|  | @@ -263,7 +263,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
 | 
	
		
			
				|  |  |          if(code == null || !code.getTenantId().equals(tenantId)) {
 | 
	
		
			
				|  |  |              throw new BizException("激活码不存在");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        SysUser sysUser = sysUserMapper.selectById(student.getUserId());
 | 
	
		
			
				|  |  | +        SysUser sysUser = sysUserService.getDao().selectById(student.getUserId());
 | 
	
		
			
				|  |  |          if(!sysUser.getPhone().equals(code.getActivationPhone())) {
 | 
	
		
			
				|  |  |              // 该激活码未指定为当前学生使用
 | 
	
		
			
				|  |  |              throw new BizException("激活码不存在");
 | 
	
	
		
			
				|  | @@ -319,7 +319,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
 | 
	
		
			
				|  |  |              throw new BizException("激活码已经被使用");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        SysUser sysUser = sysUserMapper.selectById(userId);
 | 
	
		
			
				|  |  | +        SysUser sysUser = sysUserService.getDao().selectById(userId);
 | 
	
		
			
				|  |  |          if (sysUser == null) {
 | 
	
		
			
				|  |  |              throw new BizException("用户不存在");
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -327,13 +327,33 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
 | 
	
		
			
				|  |  |          this.updateById(one);
 | 
	
		
			
				|  |  |          TenantInfo tenantInfo = tenantInfoService.getById(tenantId);
 | 
	
		
			
				|  |  |          Map<Long, String> receivers = new HashMap<>(1);
 | 
	
		
			
				|  |  | -        receivers.put(userId, userId.toString());
 | 
	
		
			
				|  |  | +        receivers.put(userId, sysUser.getPhone());
 | 
	
		
			
				|  |  |          this.sendCancelActivationCodeMessage(receivers,tenantInfo.getName());
 | 
	
		
			
				|  |  |          this.sendActivationCodeMessage(userId,sysUser.getPhone());
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | +    public void sendCancel(TenantInfo tenantInfo, TenantActivationCode activationCode) {
 | 
	
		
			
				|  |  | +        boolean update = this.lambdaUpdate()
 | 
	
		
			
				|  |  | +                .set(TenantActivationCode::getSendStatus, EActivationCode.WAIT)
 | 
	
		
			
				|  |  | +                .set(TenantActivationCode::getActivationPhone, "")
 | 
	
		
			
				|  |  | +                .eq(TenantActivationCode::getId, activationCode.getId())
 | 
	
		
			
				|  |  | +                .eq(TenantActivationCode::getActivationStatus, false)
 | 
	
		
			
				|  |  | +                .eq(TenantActivationCode::getSendStatus, EActivationCode.SEND)
 | 
	
		
			
				|  |  | +                .update();
 | 
	
		
			
				|  |  | +        if (!update) {
 | 
	
		
			
				|  |  | +            throw new BizException("激活码已经激活");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        com.yonge.cooleshow.auth.api.entity.SysUser sysUser = sysUserService.findUserByPhone(activationCode.getActivationPhone());
 | 
	
		
			
				|  |  | +        if (sysUser != null) {
 | 
	
		
			
				|  |  | +            Map<Long, String> receivers = new HashMap<>(1);
 | 
	
		
			
				|  |  | +            receivers.put(sysUser.getId(), activationCode.getActivationPhone());
 | 
	
		
			
				|  |  | +            this.sendCancelActivationCodeMessage(receivers,tenantInfo.getName());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  |      public void batchSendCancel(TenantInfo tenantInfo, String ids) {
 | 
	
		
			
				|  |  |          List<Long> idList = Arrays.stream(ids.split(",")).map(Long::valueOf).distinct().collect(Collectors.toList());
 | 
	
		
			
				|  |  |          Collection<TenantActivationCode> tenantActivationCodes = this.listByIds(idList);
 | 
	
	
		
			
				|  | @@ -347,17 +367,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
 | 
	
		
			
				|  |  |              throw new BizException("无可撤回的激活码");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        this.lambdaUpdate()
 | 
	
		
			
				|  |  | -                .set(TenantActivationCode::getSendStatus, EActivationCode.WAIT)
 | 
	
		
			
				|  |  | -                .set(TenantActivationCode::getActivationPhone, "")
 | 
	
		
			
				|  |  | -                .in(TenantActivationCode::getId, idList)
 | 
	
		
			
				|  |  | -                .eq(TenantActivationCode::getActivationStatus, false)
 | 
	
		
			
				|  |  | -                .eq(TenantActivationCode::getSendStatus, EActivationCode.SEND)
 | 
	
		
			
				|  |  | -                .eq(TenantActivationCode::getTenantId,tenantInfo.getId())
 | 
	
		
			
				|  |  | -                .update();
 | 
	
		
			
				|  |  | -        //转换map
 | 
	
		
			
				|  |  | -        Map<Long, String> receivers = idList.stream().collect(Collectors.toMap(Function.identity(), String::valueOf));
 | 
	
		
			
				|  |  | -        this.sendCancelActivationCodeMessage(receivers,tenantInfo.getName());
 | 
	
		
			
				|  |  | +        this.sendCancel(tenantInfo, tenantActivationCodes.iterator().next());
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Transactional(rollbackFor = Exception.class)
 | 
	
	
		
			
				|  | @@ -384,7 +394,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
 | 
	
		
			
				|  |  |              throw new BizException("可发激活码的数量小于学生的数量");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        List<SysUser> sysUsers = sysUserMapper.selectBatchIds(studentIdList);
 | 
	
		
			
				|  |  | +        List<SysUser> sysUsers = sysUserService.getDao().selectBatchIds(studentIdList);
 | 
	
		
			
				|  |  |          Map<Long, String> mapPhoneById = sysUsers.stream().collect(Collectors.toMap(SysUser::getId, SysUser::getPhone));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          List<TenantActivationCode> updates = new ArrayList<>();
 |