From 56d6af7c8b64c8b477296c591364559c2d8b9a0c Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期三, 02 七月 2025 18:58:55 +0800
Subject: [PATCH] 修改bug

---
 DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java |   37 ++++++++++++++++++++-----------------
 1 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java
index 26a2353..95694af 100644
--- a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java
+++ b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java
@@ -3,6 +3,7 @@
 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.qianyuntong.model.*;
@@ -24,12 +25,11 @@
 	/**
 	 * 根据手机号码获取人员信息
 	 *
-	 * @param mobile   手机号码
-	 * @param enterNum 企业编号
+	 * @param mobile 手机号码
 	 */
-	public static List<QYTUserInfo> getUserInfoByPhone(String mobile, String enterNum) {
+	public static List<QYTUserInfo> getUserInfoByPhone(String mobile) {
 		//请求路径
-		String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/getUserInfoByPhone";
+		String url = QianYunTongProperties.apiUrl + "/openapi/rest/2.0/queryUserinfoByMobilev2";
 		//私钥文件
 		String skprivateKeyFile = QianYunTongProperties.privateKeyPath;
 		//注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
@@ -46,27 +46,26 @@
 		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));
+		contentMap.put("content", "{\"list\":[{\"mobile\":\"" + mobile + "\"}]}");
+		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");
+		JSONArray data = object.getJSONObject("data").getJSONArray("list");
 		List<QYTUserInfo> list = new ArrayList<>();
 		for (int i = 0; i < data.size(); i++) {
-			data.getJSONObject(i).getString("enter_code");
 			QYTUserInfo userInfo = data.getObject(i, QYTUserInfo.class);
 			list.add(userInfo);
 		}
@@ -99,7 +98,7 @@
 		contentMap.put(SystemParameterNames.getMessage_id(), messageId);
 		contentMap.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
 		contentMap.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
-		contentMap.put("content", JSON.toJSONString(request));
+		contentMap.put("content", new Gson().toJson(request));
 		log.info("【根据手机号注册用户】请求地址:" + url);
 		log.info("【根据手机号注册用户】请求参数:" + JSON.toJSONString(contentMap));
 		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, contentMap);
@@ -145,7 +144,7 @@
 		contentMap.put(SystemParameterNames.getMessage_id(), messageId);
 		contentMap.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
 		contentMap.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
-		contentMap.put("content", JSON.toJSONString(request));
+		contentMap.put("content", new Gson().toJson(request));
 		log.info("【易信用户修改密码】请求地址:" + url);
 		log.info("【易信用户修改密码】请求参数:" + JSON.toJSONString(contentMap));
 		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, contentMap);
@@ -191,7 +190,7 @@
 		contentMap.put(SystemParameterNames.getMessage_id(), messageId);
 		contentMap.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
 		contentMap.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
-		contentMap.put("content", JSON.toJSONString(request));
+		contentMap.put("content", new Gson().toJson(request));
 		log.info("【易信重置密码】请求地址:" + url);
 		log.info("【易信重置密码】请求参数:" + JSON.toJSONString(contentMap));
 		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, contentMap);
@@ -210,4 +209,8 @@
 		}
 		return true;
 	}
+	
+	
+
+	
 }

--
Gitblit v1.7.1