|  | @@ -1,6 +1,8 @@
 | 
	
		
			
				|  |  |  package com.yonge.cooleshow.auth.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import com.google.common.collect.Lists;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.api.feign.AdminFeignService;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.api.feign.dto.UserFriendInfoVO;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.auth.api.dto.QRLoginDto;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.auth.api.dto.SysUserInfo;
 | 
	
	
		
			
				|  | @@ -23,16 +25,22 @@ import com.yonge.toolset.base.exception.BizException;
 | 
	
		
			
				|  |  |  import com.yonge.toolset.mybatis.dal.BaseDAO;
 | 
	
		
			
				|  |  |  import com.yonge.toolset.mybatis.service.impl.BaseServiceImpl;
 | 
	
		
			
				|  |  |  import io.rong.models.user.UserModel;
 | 
	
		
			
				|  |  | +import lombok.extern.slf4j.Slf4j;
 | 
	
		
			
				|  |  |  import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  |  import org.redisson.api.RedissonClient;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | +import org.springframework.beans.factory.annotation.Value;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  import org.springframework.util.CollectionUtils;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import javax.annotation.Resource;
 | 
	
		
			
				|  |  | +import java.util.Arrays;
 | 
	
		
			
				|  |  |  import java.util.List;
 | 
	
		
			
				|  |  | +import java.util.Random;
 | 
	
		
			
				|  |  | +import java.util.stream.Collectors;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +@Slf4j
 | 
	
		
			
				|  |  |  @Service
 | 
	
		
			
				|  |  |  public class SysUserServiceImpl extends BaseServiceImpl<Long, SysUser> implements SysUserService {
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -49,6 +57,10 @@ public class SysUserServiceImpl extends BaseServiceImpl<Long, SysUser> implement
 | 
	
		
			
				|  |  |      @Resource
 | 
	
		
			
				|  |  |      private AdminFeignService adminFeignService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    // 新用户注册,默认添加官方客服联系人配置
 | 
	
		
			
				|  |  | +    @Value("${app.customer.service:17740683946}")
 | 
	
		
			
				|  |  | +    private String customerService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public BaseDAO<Long, SysUser> getDAO() {
 | 
	
		
			
				|  |  |          return sysUserDao;
 | 
	
	
		
			
				|  | @@ -163,7 +175,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<Long, SysUser> implement
 | 
	
		
			
				|  |  |          sysUserDao.update(sysUser);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          // 自动添加系统默认IM帐号为好友,并自动发送通知消息
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +        sendSysCustomerServiceFriendMessage(sysUser);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          return queryUserInfoByPhone(phone);
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -183,10 +195,42 @@ public class SysUserServiceImpl extends BaseServiceImpl<Long, SysUser> implement
 | 
	
		
			
				|  |  |          sysUserDao.update(sysUser);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          // 自动添加系统默认IM帐号为好友,并自动发送通知消息
 | 
	
		
			
				|  |  | +        sendSysCustomerServiceFriendMessage(sysUser);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          return queryUserInfoByPhone(phone);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 添加系统客服好友消息
 | 
	
		
			
				|  |  | +     * @param sysUser SysUser
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private void sendSysCustomerServiceFriendMessage(SysUser sysUser) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (StringUtils.isNotEmpty(customerService)) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                List<String> collect = Arrays.stream(customerService.split(",")).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                Random rand = new Random();
 | 
	
		
			
				|  |  | +                String mobile = collect.get(rand.nextInt(collect.size()));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                // 系统客服好友
 | 
	
		
			
				|  |  | +                SysUser friend = sysUserDao.queryByPhone(mobile);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                // 发送添加系统客服好友消息
 | 
	
		
			
				|  |  | +                adminFeignService.customerService(UserFriendInfoVO.builder()
 | 
	
		
			
				|  |  | +                        .userId(sysUser.getId())
 | 
	
		
			
				|  |  | +                        .friendIds(Lists.newArrayList(friend.getId()))
 | 
	
		
			
				|  |  | +                        .build());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            log.error("sendSysCustomerServiceFriendMessage userId={}", sysUser.getId(), e);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |      public void refreshImToken(SysUser sysUser) {
 |