Pu Zhibing
2025-07-08 91fcd48801ad1120651027824f7a60a14deadf87
ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EnterpriseUtil.java
@@ -5,6 +5,8 @@
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;
@@ -23,6 +25,7 @@
@Slf4j
public class EnterpriseUtil {
   
   private static QianYunTongConfig qianYunTongConfig = SpringContextsUtil.getBean(QianYunTongConfig.class).getQianYunTongConfig();
   
   /**
    * 根据社会信用代码判断企业是否已存在
@@ -32,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<>();
@@ -47,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));
@@ -78,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<>();
@@ -93,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));
@@ -124,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<>();
@@ -139,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));
@@ -171,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<>();
@@ -186,8 +189,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));
@@ -211,11 +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 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,8 +229,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);
@@ -257,13 +260,13 @@
    * @param operator 管理员手机号码
    * @return
    */
   public static boolean delEnterprise(String enterNum, String operator) {
   public static ResultUtil delEnterprise(String enterNum, String operator) {
      //请求路径
      String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/delCompany";
      String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/delCompany";
      //私钥文件
      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<String, Object>();
@@ -274,8 +277,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", "{\"enterNum\":\"" + enterNum + "\",\"operator\":\"" + operator + "\"}");
      
      log.info("【删除企业信息】请求地址:" + url);
@@ -286,15 +289,15 @@
      String retCode = jsonObject.getString("retCode");
      if (!"0".equals(retCode)) {
         log.error("【删除企业信息】请求失败:" + result);
         throw new RuntimeException("【删除企业信息】请求失败:" + result);
         return ResultUtil.error("【删除企业信息】请求失败:" + 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 ResultUtil.error("【删除企业信息】请求失败:" + object.getString("desc"));
      }
      return true;
      return ResultUtil.success();
   }