From 2ab5f166d0fad4b1a860fde3bab1adb46d062c3f Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期三, 23 七月 2025 21:18:42 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EnterpriseUtil.java |  152 ++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 114 insertions(+), 38 deletions(-)

diff --git a/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EnterpriseUtil.java b/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EnterpriseUtil.java
index c22ba80..f5ac4ae 100644
--- a/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EnterpriseUtil.java
+++ b/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EnterpriseUtil.java
@@ -2,8 +2,11 @@
 
 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.ResultUtil;
+import com.stylefeng.guns.modular.system.util.SpringContextsUtil;
 import com.stylefeng.guns.modular.system.util.qianyuntong.model.*;
 import lombok.extern.slf4j.Slf4j;
 
@@ -22,6 +25,7 @@
 @Slf4j
 public class EnterpriseUtil {
 	
+	private static QianYunTongConfig qianYunTongConfig = SpringContextsUtil.getBean(QianYunTongConfig.class).getQianYunTongConfig();
 	
 	/**
 	 * 根据社会信用代码判断企业是否已存在
@@ -31,11 +35,11 @@
 	 */
 	public static CheckEnterExist checkEnterExistByEnterIdCardNo(String uscc) {
 		//请求路径
-		String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/check_enter_exist_by_enterIdCardNo";
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/check_enter_exist_by_enterIdCardNo";
 		//私钥文件
-		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> map = new HashMap<>();
@@ -46,8 +50,8 @@
 		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(SystemParameterNames.getUserName(), qianYunTongConfig.getUserName());
+		map.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus());
 		map.put("content", "{\"uscc\":\"" + uscc + "\"}");
 		log.info("【根据社会信用代码判断企业是否已存在】请求地址:" + url);
 		log.info("【根据社会信用代码判断企业是否已存在】请求参数:" + JSON.toJSONString(map));
@@ -57,13 +61,13 @@
 		String retCode = jsonObject.getString("retCode");
 		if (!"0".equals(retCode)) {
 			log.error("【根据社会信用代码判断企业是否已存在】请求失败:" + result);
-			throw new RuntimeException("【根据社会信用代码判断企业是否已存在】请求失败:" + 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());
+			return null;
 		}
 		return jsonObject.getObject("object", CheckEnterExist.class);
 	}
@@ -77,11 +81,11 @@
 	 */
 	public static CheckEnterExist checkEnterNameExist(String enterName) {
 		//请求路径
-		String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/checkEnterNameExist";
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/checkEnterNameExist";
 		//私钥文件
-		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> map = new HashMap<>();
@@ -92,8 +96,8 @@
 		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(SystemParameterNames.getUserName(), qianYunTongConfig.getUserName());
+		map.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus());
 		map.put("content", "{\"enterName\":\"" + enterName + "\"}");
 		log.info("【根据企业名称判断企业是否已存在】请求地址:" + url);
 		log.info("【根据企业名称判断企业是否已存在】请求参数:" + JSON.toJSONString(map));
@@ -103,13 +107,13 @@
 		String retCode = jsonObject.getString("retCode");
 		if (!"0".equals(retCode)) {
 			log.error("【根据企业名称判断企业是否已存在】请求失败:" + result);
-			throw new RuntimeException("【根据企业名称判断企业是否已存在】请求失败:" + 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());
+			return null;
 		}
 		return jsonObject.getObject("object", CheckEnterExist.class);
 	}
@@ -123,11 +127,11 @@
 	 */
 	public static EnterpriseInfo getEnterpriseDetail(String enter_code) {
 		//请求路径
-		String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/getEnterpriseDetail";
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/getEnterpriseDetail";
 		//私钥文件
-		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> map = new HashMap<>();
@@ -138,8 +142,8 @@
 		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(SystemParameterNames.getUserName(), qianYunTongConfig.getUserName());
+		map.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus());
 		map.put("content", "{\"enter_code\":\"" + enter_code + "\"}");
 		log.info("【查询企业详情】请求地址:" + url);
 		log.info("【查询企业详情】请求参数:" + JSON.toJSONString(map));
@@ -149,13 +153,13 @@
 		String retCode = jsonObject.getString("retCode");
 		if (!"0".equals(retCode)) {
 			log.error("【查询企业详情】请求失败:" + result);
-			throw new RuntimeException("【查询企业详情】请求失败:" + 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());
+			return null;
 		}
 		EnterpriseInfo enterpriseInfo = jsonObject.getObject("object", EnterpriseInfo.class);
 		return enterpriseInfo;
@@ -170,11 +174,11 @@
 	 */
 	public static Boolean modifyEnterpriseInfo(ModifyEnterpriseInfoRequest request) {
 		//请求路径
-		String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/modifyEnterpriseInfo";
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/modifyEnterpriseInfo";
 		//私钥文件
-		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> map = new HashMap<>();
@@ -185,15 +189,15 @@
 		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", JSON.toJSONString(request));
+		map.put(SystemParameterNames.getUserName(), qianYunTongConfig.getUserName());
+		map.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus());
+		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");
+		String status = jsonObject.getString("retCode");
 		if (!"0".equals(status)) {
 			log.error("【修改企业基本信息】请求失败:" + result);
 			throw new RuntimeException("【修改企业基本信息】请求失败:" + result);
@@ -210,12 +214,11 @@
 	 */
 	public static CreateEnterprise createEnterprise(CreateEnterpriseRequest request) {
 		//请求路径
-		String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/createEnterprise";
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/createEnterprise";
 		//私钥文件
-		String skprivateKeyFile = QianYunTongProperties.privateKeyPath;
+		String skprivateKeyFile = qianYunTongConfig.getPrivateKeyPath();
 		//注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
-		String appKey = QianYunTongProperties.appkey;//appkey
-		String content = "";//业务参数
+		String appKey = qianYunTongConfig.getAppkey();//appkey
 		Map<String, String> headers = new HashMap<>();
 		headers.put("Content-Type", "application/json");
 		Map<String, Object> map = new HashMap<String, Object>();
@@ -226,9 +229,9 @@
 		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", JSON.toJSONString(request));
+		map.put(SystemParameterNames.getUserName(), qianYunTongConfig.getUserName());
+		map.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus());
+		map.put("content", new Gson().toJson(request));
 		
 		log.info("【创建企业】请求地址:" + url);
 		log.info("【创建企业】请求参数:" + JSON.toJSONString(map));
@@ -238,14 +241,87 @@
 		String retCode = jsonObject.getString("retCode");
 		if (!"0".equals(retCode)) {
 			log.error("【创建企业】请求失败:" + result);
-			throw new RuntimeException("【创建企业】请求失败:" + result);
+			String retMsg = jsonObject.getString("retMsg");
+			retMsg = retMsg.substring(retMsg.indexOf("{"));
+			jsonObject = JSON.parseObject(retMsg);
+			throw new RuntimeException("【创建企业】请求失败:" + jsonObject.getString("msg"));
 		}
 		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());
+			throw new RuntimeException("【创建企业】请求失败:" + object.toJSONString());
 		}
 		return object.getObject("data", CreateEnterprise.class);
 	}
+	
+	
+	/**
+	 * 删除企业信息
+	 *
+	 * @param enterNum 企业编号
+	 * @param operator 管理员手机号码
+	 * @return
+	 */
+	public static ResultUtil delEnterprise(String enterNum, String operator) {
+		//请求路径
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/delCompany";
+		//私钥文件
+		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> 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(), qianYunTongConfig.getUserName());
+		map.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus());
+		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);
+			String retMsg = jsonObject.getString("retMsg");
+			retMsg = retMsg.substring(retMsg.indexOf("{"));
+			jsonObject = JSON.parseObject(retMsg);
+			return ResultUtil.error("【删除企业信息】请求失败:" + jsonObject.getString("msg"));
+		}
+		JSONObject object = jsonObject.getJSONObject("object");
+		String status = object.getString("status");
+		if (!"0".equals(status)) {
+			log.error("【删除企业信息】请求失败:" + object.toJSONString());
+			return ResultUtil.error("【删除企业信息】请求失败:" + object.getString("desc"));
+		}
+		return ResultUtil.success();
+	}
+	
+	
+	public static void main(String[] args) {
+//		CreateEnterpriseRequest request = new CreateEnterpriseRequest();
+//		request.setName("黔南云码通数字产业运营有限公司");
+//		request.setNickName("黔南云码通");
+//		request.setIndustry_code("123456789");
+//		request.setMobile("15180824124");
+//		request.setMobileFlag("1");
+//		CreateEnterprise enterprise = EnterpriseUtil.createEnterprise(request);
+//		System.out.println(enterprise);
+//
+		
+//		CheckEnterExist checkEnterExist = EnterpriseUtil.checkEnterNameExist("黔南云码通数字产业运营有限公司");
+//		System.out.println(checkEnterExist);
+		
+		
+		EnterpriseUtil.delEnterprise("981100006318563", "13688394165");
+	}
 }

--
Gitblit v1.7.1