From bf5af2776e8cc2e5bb4fa6087cd4778f666fd464 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期四, 21 八月 2025 01:12:05 +0800
Subject: [PATCH] update
---
UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EnterpriseUtil.java | 136 +++++++++++++++++++++++++++++++++------------
1 files changed, 100 insertions(+), 36 deletions(-)
diff --git a/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EnterpriseUtil.java b/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EnterpriseUtil.java
index bdc9694..520d248 100644
--- a/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EnterpriseUtil.java
+++ b/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EnterpriseUtil.java
@@ -5,6 +5,7 @@
import com.google.gson.Gson;
import com.open.common.util.OpenApiClient;
import com.open.common.util.SystemParameterNames;
+import com.stylefeng.guns.modular.system.util.SpringContextsUtil;
import com.stylefeng.guns.modular.system.util.qianyuntong.model.*;
import lombok.extern.slf4j.Slf4j;
@@ -23,6 +24,22 @@
@Slf4j
public class EnterpriseUtil {
+ private static QianYunTongConfig qianYunTongConfig = SpringContextsUtil.getBean(QianYunTongConfig.class).getQianYunTongConfig();
+
+
+ public static void main(String[] args) {
+// CheckEnterExist checkEnterNameExist = checkEnterNameExist("黔南云码通数字产业运营有限公司");
+// System.err.println(checkEnterNameExist);
+
+ CreateEnterpriseRequest request = new CreateEnterpriseRequest();
+ request.setName("成都喜望科技有限公司");
+ request.setNickName("成都喜望");
+ request.setIndustry_code("123456");
+ request.setMobile("15828353127");
+ CreateEnterprise enterprise = EnterpriseUtil.createEnterprise(request);
+ System.out.println(enterprise);
+
+ }
/**
* 根据社会信用代码判断企业是否已存在
@@ -32,11 +49,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<>();
@@ -47,8 +64,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));
@@ -58,13 +75,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);
}
@@ -78,11 +95,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<>();
@@ -93,8 +110,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));
@@ -104,13 +121,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);
}
@@ -124,11 +141,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<>();
@@ -139,8 +156,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));
@@ -150,13 +167,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;
@@ -171,11 +188,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<>();
@@ -186,8 +203,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", new Gson().toJson(request));
log.info("【修改企业基本信息】请求地址:" + url);
log.info("【修改企业基本信息】请求参数:" + JSON.toJSONString(map));
@@ -197,7 +214,7 @@
String status = jsonObject.getString("status");
if (!"0".equals(status)) {
log.error("【修改企业基本信息】请求失败:" + result);
- return false;
+ throw new RuntimeException("【修改企业基本信息】请求失败:" + result);
}
return true;
}
@@ -211,12 +228,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>();
@@ -227,8 +243,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", new Gson().toJson(request));
log.info("【创建企业】请求地址:" + url);
@@ -239,14 +255,62 @@
String retCode = jsonObject.getString("retCode");
if (!"0".equals(retCode)) {
log.error("【创建企业】请求失败:" + result);
- return null;
+ throw new RuntimeException("【创建企业】请求失败:" + result);
}
JSONObject object = jsonObject.getJSONObject("object");
String status = object.getString("status");
if (!"0".equals(status)) {
- log.error("【创建企业】请求失败:" + result);
- return null;
+ log.error("【创建企业】请求失败:" + object.toJSONString());
+ throw new RuntimeException("【创建企业】请求失败:" + object.toJSONString());
}
return object.getObject("data", CreateEnterprise.class);
}
+
+
+ /**
+ * 删除企业信息
+ *
+ * @param enterNum 企业编号
+ * @param operator 管理员手机号码
+ * @return
+ */
+ public static boolean 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);
+ 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;
+ }
}
--
Gitblit v1.7.1