From 74f8b8074a2fb391b5363b4dca5f99bf31993430 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期一, 11 八月 2025 22:22:07 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/QYTDriving

---
 driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/qianyuntong/UserUtil.java |  324 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 324 insertions(+), 0 deletions(-)

diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/qianyuntong/UserUtil.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/qianyuntong/UserUtil.java
new file mode 100644
index 0000000..b1966c6
--- /dev/null
+++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/qianyuntong/UserUtil.java
@@ -0,0 +1,324 @@
+package com.supersavedriving.driver.modular.system.util.qianyuntong;
+
+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.supersavedriving.driver.modular.system.util.SpringContextsUtil;
+import com.supersavedriving.driver.modular.system.util.qianyuntong.model.*;
+import lombok.extern.slf4j.Slf4j;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * 用户工具类
+ *
+ * @author zhibing.pu
+ * @Date 2025/6/6 14:47
+ */
+@Slf4j
+public class UserUtil {
+	
+	private static QianYunTongConfig qianYunTongConfig = SpringContextsUtil.getBean(QianYunTongConfig.class).getQianYunTongConfig();
+	
+	
+	public static void main(String[] args) {
+//		List<QYTUserInfo> userInfoByPhone = getUserInfoByPhone("15828353127");
+//		System.out.println(userInfoByPhone);
+	}
+	
+	
+	/**
+	 * 根据手机号码获取人员信息
+	 *
+	 * @param mobile 手机号码
+	 */
+	public static List<QYTUserInfo> getUserInfoByPhone(String mobile) {
+		//请求路径
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/2.0/queryUserinfoByMobilev2";
+		//私钥文件
+		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());
+		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);
+		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.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<>();
+		for (int i = 0; i < data.size(); i++) {
+			data.getJSONObject(i).getString("enter_code");
+			QYTUserInfo userInfo = data.getObject(i, QYTUserInfo.class);
+			list.add(userInfo);
+		}
+		return list;
+	}
+	
+	
+	/**
+	 * 根据手机号注册用户
+	 *
+	 * @param request
+	 * @return
+	 */
+	public static RegisterViaMobile registerViaMobile(RegisterViaMobileRequest request) {
+		//请求路径
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/m1_register_via_mobile";
+		//私钥文件
+		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());
+		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);
+		log.info("【根据手机号注册用户】请求结果:" + result);
+		JSONObject jsonObject = JSON.parseObject(result);
+		String retCode = jsonObject.getString("retCode");
+		if (!"0".equals(retCode)) {
+			log.error("【根据手机号注册用户】请求失败:" + result);
+			throw new RuntimeException("【根据手机号注册用户】请求失败:" + result);
+		}
+		JSONObject object = jsonObject.getJSONObject("object");
+		String status = object.getString("status");
+		if (!"0".equals(status)) {
+			log.error("【根据手机号注册用户】失败:" + object.toJSONString());
+			throw new RuntimeException("【根据手机号注册用户】失败:" + object.toJSONString());
+		}
+		return jsonObject.getObject("object", RegisterViaMobile.class);
+	}
+	
+	
+	/**
+	 * 易信用户修改密码
+	 *
+	 * @param request
+	 * @return
+	 */
+	public static Boolean modifyPwd(ModifyPwdRequest request) {
+		//请求路径
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/modifyPwd";
+		//私钥文件
+		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());
+		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);
+		log.info("【易信用户修改密码】请求结果:" + result);
+		JSONObject jsonObject = JSON.parseObject(result);
+		String retCode = jsonObject.getString("retCode");
+		if (!"0".equals(retCode)) {
+			log.error("【易信用户修改密码】请求失败:" + result);
+			throw new RuntimeException("【易信用户修改密码】请求失败:" + result);
+		}
+		JSONObject object = jsonObject.getJSONObject("object");
+		String status = object.getString("status");
+		if (!"0".equals(status)) {
+			log.error("【易信用户修改密码】失败:" + object.toJSONString());
+			throw new RuntimeException("【易信用户】失败:" + object.toJSONString());
+		}
+		return true;
+	}
+	
+	
+	/**
+	 * 易信重置密码
+	 *
+	 * @param request
+	 * @return
+	 */
+	public static Boolean resetPwd(ResetPwdRequest request) {
+		//请求路径
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/resetPwd";
+		//私钥文件
+		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());
+		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);
+		log.info("【易信重置密码】请求结果:" + result);
+		JSONObject jsonObject = JSON.parseObject(result);
+		String retCode = jsonObject.getString("retCode");
+		if (!"0".equals(retCode)) {
+			log.error("【易信重置密码】请求失败:" + result);
+			throw new RuntimeException("【易信重置密码】请求失败:" + result);
+		}
+		JSONObject object = jsonObject.getJSONObject("object");
+		String status = object.getString("status");
+		if (!"0".equals(status)) {
+			log.error("【易信重置密码】失败:" + object.toJSONString());
+			throw new RuntimeException("【易信重置密码】失败:" + object.toJSONString());
+		}
+		return true;
+	}
+	
+	
+	
+	/**
+	 * 实名认证
+	 * @param realName
+	 * @param cardNo
+	 * @return
+	 */
+	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);
+		}
+		JSONObject object = jsonObject.getJSONObject("object");
+		return object.getBoolean("isok");
+	}
+	
+}

--
Gitblit v1.7.1