From 59e3a93e27627653dd049bb9653716f421e027a3 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期二, 24 十二月 2024 19:00:53 +0800
Subject: [PATCH] 修改bug

---
 DriverAHTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/WeChatUtil.java |   50 ++++++++++++++++++++++++++++----------------------
 1 files changed, 28 insertions(+), 22 deletions(-)

diff --git a/DriverAHTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/WeChatUtil.java b/DriverAHTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/WeChatUtil.java
index c28ca3a..8112738 100644
--- a/DriverAHTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/WeChatUtil.java
+++ b/DriverAHTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/WeChatUtil.java
@@ -18,8 +18,10 @@
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.ByteArrayInputStream;
+import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
+import java.nio.charset.Charset;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
@@ -201,30 +203,34 @@
     }
 
     public String rid(String path, Integer driverId) throws Exception{
-        // 获取access_token
-        String accessToken = getWxAppletsAccessToken();
-        // 替换CREATE_CODE_URL
-        String url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token="+accessToken;
-        // 发送请求
-        String stringApiResult = null;
+        InputStream release = getwxacodeunlimit(path, "driverId=" + driverId, EnvVersion.RELEASE.getVersion());
+        String png = ObsUploadUtil.obsUpload("png", release);
+        return png;
+    }
+    
+    
+    
+    public InputStream getwxacodeunlimit(String page, String scene, String envVersion) throws Exception{
         try {
-            HashMap<String, String> map = new HashMap<>();
-            map.put("path", path+"?driverId="+driverId);
-            HttpHeaders headers = new HttpHeaders();
-            headers.setContentType(MediaType.APPLICATION_JSON);
-            HttpEntity requestEntity = new HttpEntity(map, headers);
-            ResponseEntity<byte[]> rep = restTemplate.exchange(url, HttpMethod.POST, requestEntity, byte[].class);
-            byte[] bytes = rep.getBody();
-            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
-            MultipartFile file = new MockMultipartFile(ContentType.APPLICATION_OCTET_STREAM.toString(), byteArrayInputStream);
-            String s = ObsUploadUtil.obsUpload(file);
-            System.err.println("===url"+s);
-            System.err.println(Base64.encodeBase64String(bytes));
-            return s;
-
-        } catch (Exception e) {
+            String wxAppletsAccessToken = getWxAppletsAccessToken();
+            String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + wxAppletsAccessToken;
+            Map<String, Object> param = new HashMap<>();
+            param.put("scene", scene);
+            param.put("page", page);
+            param.put("env_version", envVersion);
+            HttpHeaders httpHeaders = new HttpHeaders();
+            MediaType type=MediaType.parseMediaType("application/json;charset=UTF-8");
+            httpHeaders.setContentType(type);
+            HttpEntity<Map<String, Object>> requestEntity = new HttpEntity<>(param, httpHeaders);
+            ResponseEntity<byte[]> entity  = restTemplate.exchange(url, HttpMethod.POST, requestEntity, byte[].class, new Object[0]);
+            byte[] body = entity.getBody();
+            String s = new String(body, Charset.defaultCharset());
+            System.err.println(s);
+            return new ByteArrayInputStream(body);
+        }catch (Exception e){
+            e.printStackTrace();
         }
-        return stringApiResult;
+        return null;
     }
 
 }

--
Gitblit v1.7.1