|  | @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
	
		
			
				|  |  |  import com.fasterxml.jackson.annotation.JsonFormat;
 | 
	
		
			
				|  |  |  import com.google.common.collect.Lists;
 | 
	
		
			
				|  |  | +import com.microsvc.toolkit.common.json.ali.AliJSONMap;
 | 
	
		
			
				|  |  |  import com.microsvc.toolkit.middleware.live.LivePluginContext;
 | 
	
		
			
				|  |  |  import com.microsvc.toolkit.middleware.live.LivePluginService;
 | 
	
		
			
				|  |  |  import com.microsvc.toolkit.middleware.live.impl.RongCloudLivePlugin;
 | 
	
	
		
			
				|  | @@ -56,7 +57,10 @@ import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 | 
	
		
			
				|  |  |  import com.ym.mec.util.collection.MapUtil;
 | 
	
		
			
				|  |  |  import com.ym.mec.util.date.DateUtil;
 | 
	
		
			
				|  |  |  import com.ym.mec.util.excel.POIUtil;
 | 
	
		
			
				|  |  | +import com.ym.mec.util.http.HttpUtil;
 | 
	
		
			
				|  |  |  import org.apache.commons.collections.CollectionUtils;
 | 
	
		
			
				|  |  | +import org.apache.commons.collections.MapUtils;
 | 
	
		
			
				|  |  | +import org.apache.commons.lang3.RandomStringUtils;
 | 
	
		
			
				|  |  |  import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  |  import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 | 
	
		
			
				|  |  |  import org.jetbrains.annotations.NotNull;
 | 
	
	
		
			
				|  | @@ -1656,6 +1660,53 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  | +     * 游客微信身份
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param code 授权码
 | 
	
		
			
				|  |  | +     * @return 用户openId
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public String visitorFingerprint(String code) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 微信公众号appId
 | 
	
		
			
				|  |  | +        String appId = sysConfigDao.findConfigValue(SysConfigService.WECHAT_APPID);
 | 
	
		
			
				|  |  | +        // 微信公众号secret
 | 
	
		
			
				|  |  | +        String secret = sysConfigDao.findConfigValue(SysConfigService.WECHAT_SECRET);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (StringUtils.isAnyBlank(appId, secret, code)) {
 | 
	
		
			
				|  |  | +            // 若微信未配置,产生64位随机数
 | 
	
		
			
				|  |  | +            return RandomStringUtils.random(64);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            // 获取用户OpenId接口
 | 
	
		
			
				|  |  | +            String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            // 封装请求参数
 | 
	
		
			
				|  |  | +            url = MessageFormat.format(url, appId, secret, code);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            String wxMpOAuth2AccessTokenUrl = HttpUtil.get(url, null);
 | 
	
		
			
				|  |  | +            log.info("请求微信授权接口的参数:{}", wxMpOAuth2AccessTokenUrl);
 | 
	
		
			
				|  |  | +            if (StringUtils.isEmpty(wxMpOAuth2AccessTokenUrl)) {
 | 
	
		
			
				|  |  | +                throw new BizException("授权失败,请重新授权");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            Map<String, Object> weChatRes = AliJSONMap.tomap(wxMpOAuth2AccessTokenUrl);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (!weChatRes.containsKey("openid")) {
 | 
	
		
			
				|  |  | +                log.error("获取微信openId失败:[{}]", JSON.toJSONString(weChatRes));
 | 
	
		
			
				|  |  | +                throw new BizException("授权失败,请重新授权");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            return MapUtils.getString(weChatRes, "openid", "");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            log.error("获取微信openId失败:[{}]", e.getMessage(), e);
 | 
	
		
			
				|  |  | +            throw new BizException("授权失败,请重新授权");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  |       * 获取直播间游客信息
 | 
	
		
			
				|  |  |       * @param userId 游客编号
 | 
	
		
			
				|  |  |       * @param imLiveBroadcastRoomVo ImLiveBroadcastRoomVo
 |