From adc8542adeabbcbeff425d6471762c04e8f3cffe Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期三, 25 六月 2025 15:03:38 +0800 Subject: [PATCH] 修改功能和增加上传功能 --- ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java | 64 ++++++++++++++++++++++++++++---- 1 files changed, 56 insertions(+), 8 deletions(-) diff --git a/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java b/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java index 6dfe5af..245fb0c 100644 --- a/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java +++ b/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java @@ -1,11 +1,15 @@ package com.stylefeng.guns.modular.system.util.qianyuntong; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; import com.open.common.util.OpenApiClient; import com.open.common.util.SystemParameterNames; +import com.stylefeng.guns.modular.system.util.UUIDUtil; import com.stylefeng.guns.modular.system.util.qianyuntong.model.*; import lombok.extern.slf4j.Slf4j; @@ -47,22 +51,27 @@ contentMap.put(SystemParameterNames.getMessage_id(), messageId); contentMap.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); contentMap.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); - contentMap.put("content", "{\"mobile\":\"" + mobile + "\",\"enterNum\":\"" + enterNum + "\"}"); - log.info("【根据手机号和企业编号查询用户信息】请求地址:" + url); - log.info("【根据手机号和企业编号查询用户信息】请求参数:" + JSON.toJSONString(contentMap)); + Map<String, String> map = new HashMap<>(); + map.put("mobile", mobile); + if (null != enterNum) { + map.put("enterNum", enterNum); + } + contentMap.put("content", JSON.toJSONString(map)); + log.info("【根据手机号码获取人员信息】请求地址:" + url); + log.info("【根据手机号码获取人员信息】请求参数:" + JSON.toJSONString(contentMap)); String result = OpenApiClient.sendCommonHttpRequst(url, headers, "GET", skprivateKeyFile, timeStamp, contentMap); - log.info("【根据手机号和企业编号查询用户信息】请求结果:" + result); + log.info("【根据手机号码获取人员信息】请求结果:" + result); JSONObject jsonObject = JSON.parseObject(result); String retCode = jsonObject.getString("retCode"); if (!"0".equals(retCode)) { - log.error("【根据手机号和企业编号查询用户信息】请求失败:" + result); - throw new RuntimeException("【根据手机号和企业编号查询用户信息】请求失败:" + result); + log.error("【根据手机号码获取人员信息】请求失败:" + result); + return null; } JSONObject object = jsonObject.getJSONObject("object"); String status = object.getString("status"); if (!"0".equals(status)) { - log.error("【根据手机号和企业编号查询用户信息】失败:" + object.toJSONString()); - throw new RuntimeException("【根据手机号和企业编号查询用户信息】失败:" + object.toJSONString()); + log.error("【根据手机号码获取人员信息】失败:" + object.toJSONString()); + return null; } JSONArray data = object.getJSONArray("data"); List<QYTUserInfo> list = new ArrayList<>(); @@ -211,4 +220,43 @@ } return true; } + + + /** + * 微信小程序登录 + * + * @param code + * @return + */ + public static LoginWeChatXiao loginWeChatXiao(String code) { + HttpRequest post = HttpUtil.createPost("https://casme.teamshub.com/webapp-backstage/ajax/loginWeChatXiao/v1.0"); + post.header("Content-Type", "text/plain;charset=UTF-8"); + post.header("Accept-encodeing", "UTF-8"); + JSONObject body = new JSONObject(); + body.put("version", "1.0"); + try { + body.put("id", UUIDUtil.getRandomCode(6)); + } catch (Exception e) { + throw new RuntimeException(e); + } + body.put("type", "loginWeChatXiao"); + body.put("action", "request"); + body.put("code", code); + body.put("appId", QianYunTongProperties.appId); + post.body(body.toJSONString()); + HttpResponse execute = post.execute(); + if (200 != execute.getStatus()) { + log.error("微信登录失败"); + return null; + } + JSONObject jsonObject = JSON.parseObject(execute.body()); + Integer status = jsonObject.getInteger("status"); + if (0 != status) { + log.error("微信登录失败:" + jsonObject.getString("desc")); + return null; + } + LoginWeChatXiao loginWeChatXiao = jsonObject.getObject("data", LoginWeChatXiao.class); + return loginWeChatXiao; + } + } -- Gitblit v1.7.1