From 6a78f6662534214f836dfb7ffa7d6b55dc0353ab Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期二, 05 八月 2025 18:40:16 +0800
Subject: [PATCH] update

---
 DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EnterpriseUtil.java |  213 +++++++++++++++++++++++++++++++++--------------------
 1 files changed, 132 insertions(+), 81 deletions(-)

diff --git a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EnterpriseUtil.java b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EnterpriseUtil.java
index 23c09f0..19540ad 100644
--- a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EnterpriseUtil.java
+++ b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EnterpriseUtil.java
@@ -2,16 +2,12 @@
 
 import com.alibaba.fastjson.JSON;
 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.CheckEnterExist;
-import com.stylefeng.guns.modular.system.util.qianyuntong.model.CreateEnterpriseRequest;
-import com.stylefeng.guns.modular.system.util.qianyuntong.model.EnterpriseInfo;
-import com.stylefeng.guns.modular.system.util.qianyuntong.model.ModifyEnterpriseInfoRequest;
+import com.stylefeng.guns.modular.system.util.qianyuntong.model.*;
 import lombok.extern.slf4j.Slf4j;
 
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
@@ -41,31 +37,36 @@
 		String skprivateKeyFile = QianYunTongProperties.privateKeyPath;
 		//注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
 		String appKey = QianYunTongProperties.appkey;//appkey
-		String content = "";//业务参数
 		Map<String, String> headers = new HashMap<>();
 		headers.put("Content-Type", "application/json");
-		Map<String, Object> request = new HashMap<String, Object>();
+		Map<String, Object> map = new HashMap<>();
 		Date nowdate = new Date();
 		SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss");
 		
 		String timeStamp = date.format(nowdate);
 		String messageId = UUID.randomUUID().toString().replaceAll("-", "");
-		request.put(SystemParameterNames.getAppKey(), appKey);
-		request.put(SystemParameterNames.getMessage_id(), messageId);
-		request.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
-		request.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
-		request.put("content", content);
-		request.put("uscc", uscc);
-		log.info("【根据社会信用代码判断企业是否已存在】请求参数:" + JSON.toJSONString(request));
-		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, request);
+		map.put(SystemParameterNames.getAppKey(), appKey);
+		map.put(SystemParameterNames.getMessage_id(), messageId);
+		map.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
+		map.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
+		map.put("content", "{\"uscc\":\"" + uscc + "\"}");
+		log.info("【根据社会信用代码判断企业是否已存在】请求地址:" + url);
+		log.info("【根据社会信用代码判断企业是否已存在】请求参数:" + JSON.toJSONString(map));
+		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, map);
 		log.info("【根据社会信用代码判断企业是否已存在】请求结果:" + result);
 		JSONObject jsonObject = JSON.parseObject(result);
-		String status = jsonObject.getString("status");
-		if (!"0".equals(status)) {
+		String retCode = jsonObject.getString("retCode");
+		if (!"0".equals(retCode)) {
 			log.error("【根据社会信用代码判断企业是否已存在】请求失败:" + result);
 			return null;
 		}
-		return jsonObject.getObject("data", CheckEnterExist.class);
+		JSONObject object = jsonObject.getJSONObject("object");
+		String status = object.getString("status");
+		if (!"0".equals(status)) {
+			log.error("【根据社会信用代码判断企业是否已存在】失败:" + object.toJSONString());
+			return null;
+		}
+		return jsonObject.getObject("object", CheckEnterExist.class);
 	}
 	
 	
@@ -82,31 +83,36 @@
 		String skprivateKeyFile = QianYunTongProperties.privateKeyPath;
 		//注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
 		String appKey = QianYunTongProperties.appkey;//appkey
-		String content = "";//业务参数
 		Map<String, String> headers = new HashMap<>();
 		headers.put("Content-Type", "application/json");
-		Map<String, Object> request = new HashMap<String, Object>();
+		Map<String, Object> map = new HashMap<>();
 		Date nowdate = new Date();
 		SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss");
 		
 		String timeStamp = date.format(nowdate);
 		String messageId = UUID.randomUUID().toString().replaceAll("-", "");
-		request.put(SystemParameterNames.getAppKey(), appKey);
-		request.put(SystemParameterNames.getMessage_id(), messageId);
-		request.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
-		request.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
-		request.put("content", content);
-		request.put("enterName", enterName);
-		log.info("【根据企业名称判断企业是否已存在】请求参数:" + JSON.toJSONString(request));
-		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, request);
+		map.put(SystemParameterNames.getAppKey(), appKey);
+		map.put(SystemParameterNames.getMessage_id(), messageId);
+		map.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
+		map.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
+		map.put("content", "{\"enterName\":\"" + enterName + "\"}");
+		log.info("【根据企业名称判断企业是否已存在】请求地址:" + url);
+		log.info("【根据企业名称判断企业是否已存在】请求参数:" + JSON.toJSONString(map));
+		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, map);
 		log.info("【根据企业名称判断企业是否已存在】请求结果:" + result);
 		JSONObject jsonObject = JSON.parseObject(result);
-		String status = jsonObject.getString("status");
-		if (!"0".equals(status)) {
+		String retCode = jsonObject.getString("retCode");
+		if (!"0".equals(retCode)) {
 			log.error("【根据企业名称判断企业是否已存在】请求失败:" + result);
 			return null;
 		}
-		return jsonObject.getObject("data", CheckEnterExist.class);
+		JSONObject object = jsonObject.getJSONObject("object");
+		String status = object.getString("status");
+		if (!"0".equals(status)) {
+			log.error("【根据企业名称判断企业是否已存在】失败:" + object.toJSONString());
+			return null;
+		}
+		return jsonObject.getObject("object", CheckEnterExist.class);
 	}
 	
 	
@@ -123,31 +129,36 @@
 		String skprivateKeyFile = QianYunTongProperties.privateKeyPath;
 		//注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
 		String appKey = QianYunTongProperties.appkey;//appkey
-		String content = "";//业务参数
 		Map<String, String> headers = new HashMap<>();
 		headers.put("Content-Type", "application/json");
-		Map<String, Object> request = new HashMap<String, Object>();
+		Map<String, Object> map = new HashMap<>();
 		Date nowdate = new Date();
 		SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss");
 		
 		String timeStamp = date.format(nowdate);
 		String messageId = UUID.randomUUID().toString().replaceAll("-", "");
-		request.put(SystemParameterNames.getAppKey(), appKey);
-		request.put(SystemParameterNames.getMessage_id(), messageId);
-		request.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
-		request.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
-		request.put("content", content);
-		request.put("enter_code", enter_code);
-		log.info("【查询企业详情】请求参数:" + JSON.toJSONString(request));
-		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "GET", skprivateKeyFile, timeStamp, request);
+		map.put(SystemParameterNames.getAppKey(), appKey);
+		map.put(SystemParameterNames.getMessage_id(), messageId);
+		map.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
+		map.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
+		map.put("content", "{\"enter_code\":\"" + enter_code + "\"}");
+		log.info("【查询企业详情】请求地址:" + url);
+		log.info("【查询企业详情】请求参数:" + JSON.toJSONString(map));
+		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, map);
 		log.info("【查询企业详情】请求结果:" + result);
 		JSONObject jsonObject = JSON.parseObject(result);
-		String status = jsonObject.getString("status");
-		if (!"0".equals(status)) {
+		String retCode = jsonObject.getString("retCode");
+		if (!"0".equals(retCode)) {
 			log.error("【查询企业详情】请求失败:" + result);
 			return null;
 		}
-		EnterpriseInfo enterpriseInfo = jsonObject.getObject("data", EnterpriseInfo.class);
+		JSONObject object = jsonObject.getJSONObject("object");
+		String status = object.getString("status");
+		if (!"0".equals(status)) {
+			log.error("【查询企业详情】失败:" + object.toJSONString());
+			return null;
+		}
+		EnterpriseInfo enterpriseInfo = jsonObject.getObject("object", EnterpriseInfo.class);
 		return enterpriseInfo;
 	}
 	
@@ -165,46 +176,46 @@
 		String skprivateKeyFile = QianYunTongProperties.privateKeyPath;
 		//注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
 		String appKey = QianYunTongProperties.appkey;//appkey
-		String content = "";//业务参数
 		Map<String, String> headers = new HashMap<>();
 		headers.put("Content-Type", "application/json");
+		Map<String, Object> map = new HashMap<>();
 		Date nowdate = new Date();
 		SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss");
 		
 		String timeStamp = date.format(nowdate);
 		String messageId = UUID.randomUUID().toString().replaceAll("-", "");
-		request.put(SystemParameterNames.getAppKey(), appKey);
-		request.put(SystemParameterNames.getMessage_id(), messageId);
-		request.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
-		request.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
-		request.put("content", content);
-		log.info("【修改企业基本信息】请求参数:" + JSON.toJSONString(request));
-		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "GET", skprivateKeyFile, timeStamp, request);
+		map.put(SystemParameterNames.getAppKey(), appKey);
+		map.put(SystemParameterNames.getMessage_id(), messageId);
+		map.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
+		map.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
+		map.put("content", new Gson().toJson(request));
+		log.info("【修改企业基本信息】请求地址:" + url);
+		log.info("【修改企业基本信息】请求参数:" + JSON.toJSONString(map));
+		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "GET", skprivateKeyFile, timeStamp, map);
 		log.info("【修改企业基本信息】请求结果:" + result);
 		JSONObject jsonObject = JSON.parseObject(result);
 		String status = jsonObject.getString("status");
 		if (!"0".equals(status)) {
 			log.error("【修改企业基本信息】请求失败:" + result);
-			return false;
+			throw new RuntimeException("【修改企业基本信息】请求失败:" + result);
 		}
 		return true;
 	}
 	
-	
 	/**
-	 * 创建企业
+	 * 删除企业信息
 	 *
-	 * @param request
+	 * @param enterNum 企业编号
+	 * @param operator 管理员手机号码
 	 * @return
 	 */
-	public static Boolean createEnterprise(CreateEnterpriseRequest request) {
+	public static boolean delEnterprise(String enterNum, String operator) {
 		//请求路径
-		String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.1/createEnterprise";
+		String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/delCompany";
 		//私钥文件
 		String skprivateKeyFile = QianYunTongProperties.privateKeyPath;
 		//注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
 		String appKey = QianYunTongProperties.appkey;//appkey
-		String content = "";//业务参数
 		Map<String, String> headers = new HashMap<>();
 		headers.put("Content-Type", "application/json");
 		Map<String, Object> map = new HashMap<String, Object>();
@@ -217,35 +228,75 @@
 		map.put(SystemParameterNames.getMessage_id(), messageId);
 		map.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
 		map.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
-		map.put("content", content);
-		Class<? extends CreateEnterpriseRequest> clazz = request.getClass();
-		Field[] declaredFields = clazz.getDeclaredFields();
-		for (Field declaredField : declaredFields) {
-			String name = declaredField.getName();
-			Object invoke = null;
-			try {
-				invoke = clazz.getMethod("get" + name.substring(0, 1).toUpperCase() + name.substring(1)).invoke(request);
-			} catch (IllegalAccessException e) {
-				throw new RuntimeException(e);
-			} catch (InvocationTargetException e) {
-				throw new RuntimeException(e);
-			} catch (NoSuchMethodException e) {
-				throw new RuntimeException(e);
-			}
-			map.put(name, invoke);
+		map.put("content", "{\"enterNum\":\"" + enterNum + "\",\"operator\":\"" + operator + "\"}");
+		
+		log.info("【删除企业信息】请求地址:" + url);
+		log.info("【删除企业信息】请求参数:" + JSON.toJSONString(map));
+		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, map);
+		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;
+	}
+	
+	public static void main(String[] args) {
+		CheckEnterExist checkEnterExist = EnterpriseUtil.checkEnterNameExist("成都喜望科技有限公司");
+		System.out.println(checkEnterExist);
+	}
+	
+	/**
+	 * 创建企业
+	 *
+	 * @param request
+	 * @return
+	 */
+	public static CreateEnterprise createEnterprise(CreateEnterpriseRequest request) {
+		//请求路径
+		String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/createEnterprise";
+		//私钥文件
+		String skprivateKeyFile = QianYunTongProperties.privateKeyPath;
+		//注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
+		String appKey = QianYunTongProperties.appkey;//appkey
+		Map<String, String> headers = new HashMap<>();
+		headers.put("Content-Type", "application/json");
+		Map<String, Object> map = new HashMap<String, Object>();
+		Date nowdate = new Date();
+		SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss");
+		
+		String timeStamp = date.format(nowdate);
+		String messageId = UUID.randomUUID().toString().replaceAll("-", "");
+		map.put(SystemParameterNames.getAppKey(), appKey);
+		map.put(SystemParameterNames.getMessage_id(), messageId);
+		map.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
+		map.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
+		map.put("content", new Gson().toJson(request));
 		
 		log.info("【创建企业】请求地址:" + url);
 		log.info("【创建企业】请求参数:" + JSON.toJSONString(map));
 		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, map);
 		log.info("【创建企业】请求结果:" + result);
 		JSONObject jsonObject = JSON.parseObject(result);
-		String resCode = jsonObject.getString("resCode");
-		String status = jsonObject.getString("status");
-		if (!"0".equals(status)) {
+		String retCode = jsonObject.getString("retCode");
+		if (!"0".equals(retCode)) {
 			log.error("【创建企业】请求失败:" + result);
-			return false;
+			throw new RuntimeException("【创建企业】请求失败:" + result);
 		}
-		return true;
+		JSONObject object = jsonObject.getJSONObject("object");
+		String status = object.getString("status");
+		if (!"0".equals(status)) {
+			log.error("【创建企业】请求失败:" + object.toJSONString());
+			throw new RuntimeException("【创建企业】请求失败:" + object.toJSONString());
+		}
+		return object.getObject("data", CreateEnterprise.class);
 	}
 }

--
Gitblit v1.7.1