From b70606bda176c711c1f2893764711611d12096b7 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期四, 14 八月 2025 23:58:43 +0800 Subject: [PATCH] 修改bug --- DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EmployeeUtil.java | 211 ++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 145 insertions(+), 66 deletions(-) diff --git a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EmployeeUtil.java b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EmployeeUtil.java index d4a6672..25dea7d 100644 --- a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EmployeeUtil.java +++ b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EmployeeUtil.java @@ -2,8 +2,10 @@ 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.SpringContextsUtil; import com.stylefeng.guns.modular.system.util.qianyuntong.model.*; import lombok.extern.slf4j.Slf4j; @@ -21,42 +23,52 @@ @Slf4j public class EmployeeUtil { + private static QianYunTongConfig qianYunTongConfig = SpringContextsUtil.getBean(QianYunTongConfig.class).getQianYunTongConfig(); + /** * 企业增加员工 * @param request * @return */ - public static Boolean saveStaffNode(SaveStaffNodeRequest request){ + public static SaveStaffNode saveStaffNode(SaveStaffNodeRequest request){ //请求路径 - String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/saveStaffNode"; + String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/saveStaffNode"; //私钥文件 - 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> contentMap = new HashMap<String, Object>(); Date nowdate = new Date(); - SimpleDateFormat date=new SimpleDateFormat("yyyyMMddHHmmss"); + 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,"POST",skprivateKeyFile,timeStamp,request); + 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 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()); + } + SaveStaffNode saveStaffNode = object.getObject("data", SaveStaffNode.class); + return saveStaffNode; } @@ -67,32 +79,39 @@ */ public static Boolean editStaffNode(EditStaffNodeRequest request){ //请求路径 - String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/editStaffNode"; + String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/editStaffNode"; //私钥文件 - 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> contentMap = new HashMap<String, Object>(); Date nowdate = new Date(); - SimpleDateFormat date=new SimpleDateFormat("yyyyMMddHHmmss"); + 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,"POST",skprivateKeyFile,timeStamp,request); + 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 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); + } + 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; } @@ -105,32 +124,40 @@ */ public static Boolean ecrmDeleteStafNode(DeleteStafNodeRequest request){ //请求路径 - String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/ecrmDeleteStafNode"; + String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/ecrmDeleteStafNode"; //私钥文件 - String skprivateKeyFile = QianYunTongProperties.privateKeyPath; + String skprivateKeyFile = qianYunTongConfig.getPrivateKeyPath(); //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 - String appKey = QianYunTongProperties.appkey;//appkey - String content="";//业务参数 + String appKey = qianYunTongConfig.getAppkey();//appkey + String content = "";//业务参数 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"); + 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,"POST",skprivateKeyFile,timeStamp,request); + 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 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); + } + 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; } @@ -143,34 +170,86 @@ */ public static StaffNodeInfo getStaffNode(GetStaffNodeRequest request){ //请求路径 - String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/getStaffNode"; + String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/getStaffNode"; //私钥文件 - 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> contentMap = new HashMap<String, Object>(); Date nowdate = new Date(); - SimpleDateFormat date=new SimpleDateFormat("yyyyMMddHHmmss"); + 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("【根据员工ID获取人员信息】请求参数:" + JSON.toJSONString(request)); - String result = OpenApiClient.sendCommonHttpRequst(url,headers,"GET",skprivateKeyFile,timeStamp,request); + 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("【根据员工ID获取人员信息】请求地址:" + url); + log.info("【根据员工ID获取人员信息】请求参数:" + JSON.toJSONString(contentMap)); + String result = OpenApiClient.sendCommonHttpRequst(url, headers, "GET", skprivateKeyFile, timeStamp, contentMap); log.info("【根据员工ID获取人员信息】请求结果:" + 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("【根据员工ID获取人员信息】请求失败:" + result); return null; } - StaffNodeInfo staffNodeInfo = jsonObject.getObject("data", StaffNodeInfo.class); + JSONObject object = jsonObject.getJSONObject("object"); + String status = object.getString("status"); + if (!"0".equals(status)) { + log.error("【根据员工ID获取人员信息】失败:" + object.toJSONString()); + return null; + } + StaffNodeInfo staffNodeInfo = object.getObject("data", StaffNodeInfo.class); return staffNodeInfo; } + + + /** + * 创建账号-同步证联开户信息 + * @param request + * @return 状态 0 成功 其他失败 + */ + public static Integer addAccountInfo(AddAccountInfoRequest request){ + request.setPartnerId("522700"); + request.setIndustryCode("100"); + request.setPayModeId("501101"); + request.setAccessMode("APP"); + + //请求路径 + String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/addAccountInfo"; + //私钥文件 + 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("【创建账号-同步证联开户信息】请求失败:" + jsonObject.getString("retMsg")); + return -1; + } + JSONObject object = jsonObject.getJSONObject("object"); + return object.getInteger("status"); + } } -- Gitblit v1.7.1