From c9a54c9bd9aa9225f6137bcccaff5654429e738b Mon Sep 17 00:00:00 2001 From: gxwebsoft Date: Tue, 4 Jun 2024 17:48:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E7=94=9F=E6=88=90?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=A0=B8=E9=94=80=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/controller/WxLoginController.java | 34 ++++++++++++++++--- src/main/resources/application.yml | 2 +- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gxwebsoft/common/system/controller/WxLoginController.java b/src/main/java/com/gxwebsoft/common/system/controller/WxLoginController.java index be911a5..52744e0 100644 --- a/src/main/java/com/gxwebsoft/common/system/controller/WxLoginController.java +++ b/src/main/java/com/gxwebsoft/common/system/controller/WxLoginController.java @@ -280,12 +280,12 @@ public class WxLoginController extends BaseController { return success("获取成功",jsonObject); } - @ApiOperation("获取微信小程序码") - @GetMapping("/getQRCode") + @ApiOperation("获取微信小程序码-用户ID") + @GetMapping("/getUserQRCode") public ApiResult getQRCode() { String apiUrl = "https://api.weixin.qq.com/wxa/getwxacode?access_token=" + getAccessToken(); final HashMap map = new HashMap<>(); - map.put("path","pages/flash/index?user_id="+getLoginUserId()); + map.put("path","/package/user/qrcode?user_id="+getLoginUserId()); // map.put("env_version","trial"); // 获取图片 Buffer byte[] qrCode = HttpRequest.post(apiUrl) @@ -321,12 +321,38 @@ public class WxLoginController extends BaseController { String filePath = getUploadDir().concat("qrcode/") + fileName; File file = FileUtil.writeBytes(qrCode, filePath); if(file != null){ - config.setFileServer("https://file.gxwebsoft.com"); return success(config.getFileServer().concat("/qrcode/").concat(fileName)); } return fail("获取失败",null); } + @ApiOperation("获取微信小程序码-订单核销码-数量极多的业务场景") + @GetMapping("/getOrderQRCodeUnlimited/{orderNo}") + public ApiResult getOrderQRCodeUnlimited(@PathVariable("orderNo") String orderNo) { + String apiUrl = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + getAccessToken(); + final HashMap map = new HashMap<>(); + map.put("scene","orderNo=".concat(orderNo)); + map.put("page","package/admin/order-scan"); + map.put("env_version","trial"); + // 获取图片 Buffer + byte[] qrCode = HttpRequest.post(apiUrl) + .body(JSON.toJSONString(map)) + .execute().bodyBytes(); + System.out.println("qrCode = " + qrCode); + + // 保存的文件名称 + final String fileName = CommonUtil.randomUUID8().concat(".png"); + // 保存路径 + String filePath = getUploadDir().concat("qrcode/") + fileName; + File file = FileUtil.writeBytes(qrCode, filePath); + if(file != null){ + return success(config.getFileServer().concat("/qrcode/").concat(fileName)); + } + return fail("获取失败",null); + } + + + /** * 文件上传位置(服务器) */ diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 12ad5e6..ed77cf1 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -88,7 +88,7 @@ config: swagger-version: 1.0 token-key: WLgNsWJ8rPjRtnjzX/Gx2RGS80Kwnm/ZeLbvIL+NrBs= server-url: https://server.gxwebsoft.com/api - file-server: https://file.wsdns.cn + file-server: https://file.gxwebsoft.com upload-path: /Users/gxwebsoft/Documents/uploads/ local-upload-path: /Users/gxwebsoft/Documents/uploads/