diff --git a/service/src/main/java/com/hfkj/channel/tianque/service/TianQueMerService.java b/service/src/main/java/com/hfkj/channel/tianque/service/TianQueMerService.java index 4fe30a8..94f82ea 100644 --- a/service/src/main/java/com/hfkj/channel/tianque/service/TianQueMerService.java +++ b/service/src/main/java/com/hfkj/channel/tianque/service/TianQueMerService.java @@ -225,12 +225,22 @@ public class TianQueMerService { param.put("settlePersonIdcardOpposite", RequestUtil.requestUpload("07", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getMerSettleAcct().getSettleIdCardNationalEmblemImg())).getString("PhotoUrl")); param.put("bankCardPositivePic", RequestUtil.requestUpload("05", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getMerSettleAcct().getBankCardImg())).getString("PhotoUrl")); } - if (basisModel.getMerSettleAcct().getSettleType().equals(MerSettleType.status3.getNumber())) { + if (basisModel.getMerSettleAcct().getSettleType().equals(MerSettleType.status3.getNumber + ())) { param.put("letterOfAuthPic", RequestUtil.requestUpload("26", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getMerSettleAcct().getCommissionImg())).getString("PhotoUrl")); } /********* 图片信息 ***********/ - JSONObject response = RequestUtil.request(TianQueConfig.requestUrl + "/merchant/income", param); + // Todo 临时判断 + JSONObject response; + if (basisModel.getOrgNo().equals("22206482")) { + // 惠付科技 + response = RequestUtil.request(TianQueConfig.requestUrl + "/merchant/income", param); + } else { + // 其他机构 + response = RequestUtil.request(basisModel.getOrgNo(), TianQueConfig.requestUrl + "/merchant/income", param); + } + reqStr = JSONObject.toJSONString(param); resStr = response.toJSONString(); if (!"0000".equals(response.getString("bizCode"))) { diff --git a/service/src/main/java/com/hfkj/channel/tianque/utils/RequestUtil.java b/service/src/main/java/com/hfkj/channel/tianque/utils/RequestUtil.java index 3f80f1b..e0aec42 100644 --- a/service/src/main/java/com/hfkj/channel/tianque/utils/RequestUtil.java +++ b/service/src/main/java/com/hfkj/channel/tianque/utils/RequestUtil.java @@ -55,6 +55,54 @@ public class RequestUtil { return response.getJSONObject("respData"); } + public static JSONObject request(String orgId,String url,Map reqData) { + Map header = new HashMap<>(); + header.put("Content-Type", "application/json"); + + TreeMap treeMap = new TreeMap(); + treeMap.putAll(reqData); + + Map param = new LinkedHashMap<>(); + param.put("orgId", orgId); + param.put("reqData", JSONObject.toJSON(reqData)); + param.put("reqId", IdentifyUtil.getGuid()); + param.put("signType", "RSA"); + param.put("timestamp", DateUtil.date2String(new Date(), "yyyyMMddHHmmss")); + param.put("version", "1.0"); + param.put("sign", RSASignature.encryptBASE64(RSASignature.sign(RSASignature.getContent(param), TianQueConfig.priKey))); + + JSONObject response = HttpsUtils.doPost(url, param, header); + System.out.println("请求参数:" + JSONObject.toJSONString(param)); + System.out.println("响应参数:" + response); + if (response != null && !"0000".equals(response.getString("code"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getString("msg")); + } + // 验证签名 + String resSign = response.getString("sign"); + response.remove("sign"); + if (!RSASignature.doCheck(RSASignature.getContent(JSONObject.toJavaObject(response, Map.class)), resSign, TianQueConfig.pubKey)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "响应参数签名失败"); + } + return response.getJSONObject("respData"); + } + + /** + * 文件上传请求 + * @param file + * @return + */ + public static JSONObject requestUpload(String orgId,String pictureType,File file) { + Map param = new HashMap<>(); + param.put("orgId", orgId); + param.put("reqId", IdentifyUtil.Guid); + param.put("pictureType", pictureType); + JSONObject response = HttpsUtils.doPostUpload(TianQueConfig.requestUrl + "/merchant/uploadPicture", file, param); + if (response != null && !"0000".equals(response.getString("code"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getString("msg")); + } + return response.getJSONObject("respData"); + } + /** * 文件上传请求 * @param file