From dc3cfaa745eb7303e312ce7ba61a7019e5f12e4b Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 21 八月 2025 00:22:42 +0800
Subject: [PATCH] 修改bug

---
 UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java |  239 +++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 175 insertions(+), 64 deletions(-)

diff --git a/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java b/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java
index d824a8d..f686686 100644
--- a/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java
+++ b/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java
@@ -1,15 +1,12 @@
 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.SpringContextsUtil;
 import com.stylefeng.guns.modular.system.util.qianyuntong.model.*;
 import lombok.extern.slf4j.Slf4j;
 
@@ -25,20 +22,24 @@
 @Slf4j
 public class UserUtil {
 	
+	private static QianYunTongConfig qianYunTongConfig = SpringContextsUtil.getBean(QianYunTongConfig.class).getQianYunTongConfig();
+	
+	
+	
+	
 	
 	/**
 	 * 根据手机号码获取人员信息
 	 *
-	 * @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 = qianYunTongConfig.getApiUrl() + "/openapi/rest/2.0/queryUserinfoByMobilev2";
 		//私钥文件
-		String skprivateKeyFile = QianYunTongProperties.privateKeyPath;
+		String skprivateKeyFile = qianYunTongConfig.getPrivateKeyPath();
 		//注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
-		String appKey = QianYunTongProperties.appkey;//appkey
+		String appKey = qianYunTongConfig.getAppkey();//appkey
 		Map<String, String> headers = new HashMap<>();
 		headers.put("Content-Type", "application/json");
 		Map<String, Object> contentMap = new HashMap<String, Object>();
@@ -49,24 +50,80 @@
 		String messageId = UUID.randomUUID().toString().replaceAll("-", "");
 		contentMap.put(SystemParameterNames.getAppKey(), appKey);
 		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(SystemParameterNames.getUserName(), qianYunTongConfig.getUserName());
+		contentMap.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus());
+		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.getJSONObject("data").getJSONArray("list");
+		List<QYTUserInfo> list = new ArrayList<>();
+		for (int i = 0; i < data.size(); i++) {
+			QYTUserInfo userInfo = data.getObject(i, QYTUserInfo.class);
+			list.add(userInfo);
+		}
+		return list;
+	}
+	
+	/**
+	 * 根据手机号码获取人员信息
+	 *
+	 * @param mobile   手机号码
+	 * @param enterNum 企业编号
+	 */
+	public static List<QYTUserInfo> getUserInfoByPhone(String mobile, String enterNum) {
+		//请求路径
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/getUserInfoByPhone";
+		//私钥文件
+		String skprivateKeyFile = qianYunTongConfig.getPrivateKeyPath();
+		//注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
+		String appKey = qianYunTongConfig.getAppkey();//appkey
+		Map<String, String> headers = new HashMap<>();
+		headers.put("Content-Type", "application/json");
+		Map<String, Object> contentMap = new HashMap<String, Object>();
+		Date nowdate = new Date();
+		SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss");
+		
+		String timeStamp = date.format(nowdate);
+		String messageId = UUID.randomUUID().toString().replaceAll("-", "");
+		contentMap.put(SystemParameterNames.getAppKey(), appKey);
+		contentMap.put(SystemParameterNames.getMessage_id(), messageId);
+		contentMap.put(SystemParameterNames.getUserName(), qianYunTongConfig.getUserName());
+		contentMap.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus());
+		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);
+		JSONObject jsonObject = JSON.parseObject(result);
+		String retCode = jsonObject.getString("retCode");
+		if (!"0".equals(retCode)) {
+			log.error("【根据手机号码获取人员信息】请求失败:" + result);
+			return null;
+		}
+		JSONObject object = jsonObject.getJSONObject("object");
+		String status = object.getString("status");
+		if (!"0".equals(status)) {
+			log.error("【根据手机号码获取人员信息】失败:" + object.toJSONString());
+			return null;
 		}
 		JSONArray data = object.getJSONArray("data");
 		List<QYTUserInfo> list = new ArrayList<>();
@@ -87,11 +144,11 @@
 	 */
 	public static RegisterViaMobile registerViaMobile(RegisterViaMobileRequest request) {
 		//请求路径
-		String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/m1_register_via_mobile";
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/m1_register_via_mobile";
 		//私钥文件
-		String skprivateKeyFile = QianYunTongProperties.privateKeyPath;
+		String skprivateKeyFile = qianYunTongConfig.getPrivateKeyPath();
 		//注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
-		String appKey = QianYunTongProperties.appkey;//appkey
+		String appKey = qianYunTongConfig.getAppkey();//appkey
 		Map<String, String> headers = new HashMap<>();
 		headers.put("Content-Type", "application/json");
 		Map<String, Object> contentMap = new HashMap<String, Object>();
@@ -102,8 +159,8 @@
 		String messageId = UUID.randomUUID().toString().replaceAll("-", "");
 		contentMap.put(SystemParameterNames.getAppKey(), appKey);
 		contentMap.put(SystemParameterNames.getMessage_id(), messageId);
-		contentMap.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
-		contentMap.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
+		contentMap.put(SystemParameterNames.getUserName(), qianYunTongConfig.getUserName());
+		contentMap.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus());
 		contentMap.put("content", new Gson().toJson(request));
 		log.info("【根据手机号注册用户】请求地址:" + url);
 		log.info("【根据手机号注册用户】请求参数:" + JSON.toJSONString(contentMap));
@@ -133,11 +190,11 @@
 	 */
 	public static Boolean modifyPwd(ModifyPwdRequest request) {
 		//请求路径
-		String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/modifyPwd";
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/modifyPwd";
 		//私钥文件
-		String skprivateKeyFile = QianYunTongProperties.privateKeyPath;
+		String skprivateKeyFile = qianYunTongConfig.getPrivateKeyPath();
 		//注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
-		String appKey = QianYunTongProperties.appkey;//appkey
+		String appKey = qianYunTongConfig.getAppkey();//appkey
 		Map<String, String> headers = new HashMap<>();
 		headers.put("Content-Type", "application/json");
 		Map<String, Object> contentMap = new HashMap<String, Object>();
@@ -148,8 +205,8 @@
 		String messageId = UUID.randomUUID().toString().replaceAll("-", "");
 		contentMap.put(SystemParameterNames.getAppKey(), appKey);
 		contentMap.put(SystemParameterNames.getMessage_id(), messageId);
-		contentMap.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
-		contentMap.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
+		contentMap.put(SystemParameterNames.getUserName(), qianYunTongConfig.getUserName());
+		contentMap.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus());
 		contentMap.put("content", new Gson().toJson(request));
 		log.info("【易信用户修改密码】请求地址:" + url);
 		log.info("【易信用户修改密码】请求参数:" + JSON.toJSONString(contentMap));
@@ -179,11 +236,11 @@
 	 */
 	public static Boolean resetPwd(ResetPwdRequest request) {
 		//请求路径
-		String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/resetPwd";
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/resetPwd";
 		//私钥文件
-		String skprivateKeyFile = QianYunTongProperties.privateKeyPath;
+		String skprivateKeyFile = qianYunTongConfig.getPrivateKeyPath();
 		//注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
-		String appKey = QianYunTongProperties.appkey;//appkey
+		String appKey = qianYunTongConfig.getAppkey();//appkey
 		Map<String, String> headers = new HashMap<>();
 		headers.put("Content-Type", "application/json");
 		Map<String, Object> contentMap = new HashMap<String, Object>();
@@ -194,8 +251,8 @@
 		String messageId = UUID.randomUUID().toString().replaceAll("-", "");
 		contentMap.put(SystemParameterNames.getAppKey(), appKey);
 		contentMap.put(SystemParameterNames.getMessage_id(), messageId);
-		contentMap.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
-		contentMap.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
+		contentMap.put(SystemParameterNames.getUserName(), qianYunTongConfig.getUserName());
+		contentMap.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus());
 		contentMap.put("content", new Gson().toJson(request));
 		log.info("【易信重置密码】请求地址:" + url);
 		log.info("【易信重置密码】请求参数:" + JSON.toJSONString(contentMap));
@@ -217,41 +274,95 @@
 	}
 	
 	
+	
 	/**
-	 * 微信小程序登录
-	 *
-	 * @param code
+	 * 实名认证
+	 * @param realName
+	 * @param cardNo
 	 * @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);
+	public static Boolean idCardAuth(String realName, String cardNo) {
+		//请求路径
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/idCardAuth";
+		//私钥文件
+		String skprivateKeyFile = qianYunTongConfig.getPrivateKeyPath();
+		//注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
+		String appKey = qianYunTongConfig.getAppkey();//appkey
+		Map<String, String> headers = new HashMap<>();
+		headers.put("Content-Type", "application/json");
+		Map<String, Object> contentMap = new HashMap<String, Object>();
+		Date nowdate = new Date();
+		SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss");
+		
+		String timeStamp = date.format(nowdate);
+		String messageId = UUID.randomUUID().toString().replaceAll("-", "");
+		contentMap.put(SystemParameterNames.getAppKey(), appKey);
+		contentMap.put(SystemParameterNames.getMessage_id(), messageId);
+		contentMap.put(SystemParameterNames.getUserName(), qianYunTongConfig.getUserName());
+		contentMap.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus());
+		Map<String, String> map = new HashMap<>();
+		map.put("realName", realName);
+		map.put("cardNo", cardNo);
+		contentMap.put("content", JSON.toJSONString(map));
+		log.info("【身份证实名认证】请求地址:" + url);
+		log.info("【身份证实名认证】请求参数:" + JSON.toJSONString(contentMap));
+		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, contentMap);
+		log.info("【身份证实名认证】请求结果:" + result);
+		JSONObject jsonObject = JSON.parseObject(result);
+		String retCode = jsonObject.getString("retCode");
+		if (!"0".equals(retCode)) {
+			log.error("【身份证实名认证】请求失败:" + result);
+			throw new RuntimeException("【身份证实名认证】请求失败:" + result);
 		}
-		body.put("type", "loginWeChatXiao");
-		body.put("action", "request");
-		body.put("code", code);
-		body.put("appId", "");
-		post.body(body.toJSONString());
-		HttpResponse execute = post.execute();
-		if (200 != execute.getStatus()) {
-			log.error("微信登录失败");
-			return null;
+		JSONObject object = jsonObject.getJSONObject("object");
+		return object.getBoolean("isok");
+	}
+	
+	
+	/**
+	 * 根据手机号码获取易信uuid
+	 * @param mobile
+	 * @return
+	 */
+	public static String getOnconUUIDByMobile(String mobile) {
+		//请求路径
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/getOnconUUIDByMobile";
+		//私钥文件
+		String skprivateKeyFile = qianYunTongConfig.getPrivateKeyPath();
+		//注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
+		String appKey = qianYunTongConfig.getAppkey();//appkey
+		Map<String, String> headers = new HashMap<>();
+		headers.put("Content-Type", "application/json");
+		Map<String, Object> contentMap = new HashMap<String, Object>();
+		Date nowdate = new Date();
+		SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss");
+		
+		String timeStamp = date.format(nowdate);
+		String messageId = UUID.randomUUID().toString().replaceAll("-", "");
+		contentMap.put(SystemParameterNames.getAppKey(), appKey);
+		contentMap.put(SystemParameterNames.getMessage_id(), messageId);
+		contentMap.put(SystemParameterNames.getUserName(), qianYunTongConfig.getUserName());
+		contentMap.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus());
+		Map<String, String> map = new HashMap<>();
+		map.put("mobile", mobile);
+		contentMap.put("content", JSON.toJSONString(map));
+		log.info("【根据手机号码获取易信uuid】请求地址:" + url);
+		log.info("【根据手机号码获取易信uuid】请求参数:" + JSON.toJSONString(contentMap));
+		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, contentMap);
+		log.info("【根据手机号码获取易信uuid】请求结果:" + result);
+		JSONObject jsonObject = JSON.parseObject(result);
+		String retCode = jsonObject.getString("retCode");
+		if (!"0".equals(retCode)) {
+			log.error("【根据手机号码获取易信uuid】请求失败:" + result);
+			throw new RuntimeException("【根据手机号码获取易信uuid】请求失败:" + result);
 		}
-		JSONObject jsonObject = JSON.parseObject(execute.body());
-		Integer status = jsonObject.getInteger("status");
-		if (0 != status) {
-			log.error("微信登录失败:" + jsonObject.getString("desc"));
-			return null;
+		JSONObject object = jsonObject.getJSONObject("object");
+		Integer status = object.getInteger("status");
+		if(0 != status){
+			log.error("【身份证实名认证】请求失败:" + object.getString("desc"));
+			throw new RuntimeException("【身份证实名认证】请求失败:" + object.getString("desc"));
 		}
-		LoginWeChatXiao loginWeChatXiao = jsonObject.getObject("data", LoginWeChatXiao.class);
-		return loginWeChatXiao;
+		return object.getString("onconUUID");
 	}
 	
 }

--
Gitblit v1.7.1