| 
														
															@@ -1,8 +1,10 @@ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 package com.fs.course.service.impl; 
														 | 
														
														 | 
														
															 package com.fs.course.service.impl; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import cn.binarywang.wx.miniapp.api.WxMaService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import cn.hutool.core.util.IdUtil; 
														 | 
														
														 | 
														
															 import cn.hutool.core.util.IdUtil; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import cn.hutool.json.JSONUtil; 
														 | 
														
														 | 
														
															 import cn.hutool.json.JSONUtil; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.alibaba.fastjson.JSON; 
														 | 
														
														 | 
														
															 import com.alibaba.fastjson.JSON; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.alibaba.fastjson.JSONObject; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.fs.common.core.domain.R; 
														 | 
														
														 | 
														
															 import com.fs.common.core.domain.R; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.fs.common.utils.DateUtils; 
														 | 
														
														 | 
														
															 import com.fs.common.utils.DateUtils; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.fs.common.utils.StringUtils; 
														 | 
														
														 | 
														
															 import com.fs.common.utils.StringUtils; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -23,17 +25,29 @@ import com.fs.course.service.IFsCourseLinkService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.fs.qw.domain.QwUser; 
														 | 
														
														 | 
														
															 import com.fs.qw.domain.QwUser; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.fs.qw.mapper.QwUserMapper; 
														 | 
														
														 | 
														
															 import com.fs.qw.mapper.QwUserMapper; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.fs.system.service.ISysConfigService; 
														 | 
														
														 | 
														
															 import com.fs.system.service.ISysConfigService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.fs.wx.miniapp.config.WxMaConfiguration; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import lombok.Synchronized; 
														 | 
														
														 | 
														
															 import lombok.Synchronized; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import lombok.extern.slf4j.Slf4j; 
														 | 
														
														 | 
														
															 import lombok.extern.slf4j.Slf4j; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import me.chanjar.weixin.common.error.WxErrorException; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import org.apache.http.HttpEntity; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import org.apache.http.client.ClientProtocolException; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import org.apache.http.client.methods.HttpPost; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import org.apache.http.entity.StringEntity; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import org.apache.http.impl.client.CloseableHttpClient; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import org.apache.http.impl.client.HttpClients; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import org.apache.http.util.EntityUtils; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.checkerframework.checker.units.qual.A; 
														 | 
														
														 | 
														
															 import org.checkerframework.checker.units.qual.A; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.beans.BeanUtils; 
														 | 
														
														 | 
														
															 import org.springframework.beans.BeanUtils; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.beans.factory.annotation.Autowired; 
														 | 
														
														 | 
														
															 import org.springframework.beans.factory.annotation.Autowired; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.stereotype.Service; 
														 | 
														
														 | 
														
															 import org.springframework.stereotype.Service; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.transaction.annotation.Transactional; 
														 | 
														
														 | 
														
															 import org.springframework.transaction.annotation.Transactional; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import java.io.IOException; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import java.io.UnsupportedEncodingException; 
														 | 
														
														 | 
														
															 import java.io.UnsupportedEncodingException; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import java.net.URI; 
														 | 
														
														 | 
														
															 import java.net.URI; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import java.net.URLDecoder; 
														 | 
														
														 | 
														
															 import java.net.URLDecoder; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import java.net.URLEncoder; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import java.nio.charset.StandardCharsets; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import java.security.SecureRandom; 
														 | 
														
														 | 
														
															 import java.security.SecureRandom; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import java.time.LocalDateTime; 
														 | 
														
														 | 
														
															 import java.time.LocalDateTime; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import java.time.ZoneId; 
														 | 
														
														 | 
														
															 import java.time.ZoneId; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -289,6 +303,93 @@ public class FsCourseLinkServiceImpl implements IFsCourseLinkService 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    /** 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * 获取跳转微信小程序的链接地址 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * @param linkStr 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * @return 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    @Override 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    public String getGotoWxAppLink(String linkStr,String appId) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        CloseableHttpClient client = null; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        try { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            client = HttpClients.createDefault(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            String[] split = linkStr.split("\\?"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if (split.length == 2 && split[0].length() > 0 && split[1].length() > 0) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                //处理页面路径 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                String pageUrl = split[0]; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                if (pageUrl.startsWith("/")) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    pageUrl = pageUrl.substring(1); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                //处理参数 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                String query = split[1]; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                query = URLEncoder.encode(query, StandardCharsets.UTF_8.toString()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                String json = configService.selectConfigByKey("course.config"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                CourseConfig config = JSON.parseObject(json, CourseConfig.class); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                String miniprogramAppid = config.getMiniprogramAppid(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                if (StringUtils.isBlank(miniprogramAppid)) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    return "未配置点播小程序id"; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                if(StringUtils.isBlank(code)){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                    return "参数错误,请传入code"; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                //获取微信token 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                final WxMaService wxService = WxMaConfiguration.getMaService(appId); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                String token = wxService.getAccessToken(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                HttpPost httpPost = new HttpPost("https://api.weixin.qq.com/wxa/generate_urllink?access_token=" + token); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                JSONObject bodyObj = new JSONObject(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                bodyObj.put("path", pageUrl); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                bodyObj.put("query", query); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                log.info("微信小程序请求参数打印:{}", bodyObj.toJSONString()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                StringEntity entity = new StringEntity(bodyObj.toJSONString(),"UTF-8"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                httpPost.setEntity(entity); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                httpPost.setHeader("Content-type", "application/json"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                HttpEntity response = client.execute(httpPost).getEntity(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                String responseString = EntityUtils.toString(response); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                log.info("微信小程序接口响应数据:{}", responseString); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                JSONObject jsonObject = JSONObject.parseObject(responseString); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                if(null != jsonObject && !jsonObject.isEmpty() && jsonObject.containsKey("url_link")){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    return jsonObject.getString("url_link"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                return "页面链接错误,获取失败"; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } catch (WxErrorException e) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            throw new RuntimeException(e); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } catch (ClientProtocolException e) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            throw new RuntimeException(e); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } catch (IOException e) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            throw new RuntimeException(e); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//        String json = configService.selectConfigByKey("course.config"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//        CourseConfig config = JSON.parseObject(json, CourseConfig.class); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//        String miniprogramAppid = config.getMiniprogramAppid(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//        if (StringUtils.isBlank(miniprogramAppid)) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                    return "未配置点播小程序id"; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+////        String envVersion = "trial"; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+////        String envVersion = version; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//        if (StringUtils.isNotBlank(linkStr)) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            //解析pageLink 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            String[] split = linkStr.split("\\?"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            if (split.length == 2 && split[0].length() > 0 && split[1].length() > 0) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                //处理页面路径 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                String pageUrl =split[0]; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                if(pageUrl.startsWith("/")){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                    pageUrl = pageUrl.substring(1); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                //处理参数 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                String query = split[1]; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+////                query = query.replace("\\u003d", "="); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                String wxAppLink = getWxAppLink(miniprogramAppid, pageUrl, query); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                return wxAppLink; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            } else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                return "页面链接错误,获取失败"; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        return ""; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     @Override 
														 | 
														
														 | 
														
															     @Override 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public R createLinkUrlWc(FsCourseLinkCreateParam param) { 
														 | 
														
														 | 
														
															     public R createLinkUrlWc(FsCourseLinkCreateParam param) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 |