Commit b2f31831 authored by BlackJokerCJ's avatar BlackJokerCJ

Merge remote-tracking branch 'origin/master'

parents 05817bcb c534b21e
......@@ -3,6 +3,7 @@ package com.jqtx.windows.command;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.IdcardUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
......@@ -167,15 +168,16 @@ public class CreditSubmitCommand extends AbstractCommand {
infoModel.setIdentifyInfo(idModel);
infoModel.setBasicInfo(basicModel);
infoModel.setContinuedLoan(false);
ClientFeignModel clientFeignModel = new ClientFeignModel(infoModel.getBasicInfo().getIdCard(), infoModel.getBasicInfo().getName());
JsonResult<String> clientResult = iClientFeignService.getClientNo(clientFeignModel);
if (!clientResult.isSuccess()) {
throw new BizException(ExceptionCodeEnum.SYSTEM_REMOTE_ERROR);
}
infoModel.setClientNo(clientResult.getResult());
// ClientFeignModel clientFeignModel = new ClientFeignModel(infoModel.getBasicInfo().getIdCard(), infoModel.getBasicInfo().getName());
// JsonResult<String> clientResult = iClientFeignService.getClientNo(clientFeignModel);
// if (!clientResult.isSuccess()) {
// throw new BizException(ExceptionCodeEnum.SYSTEM_REMOTE_ERROR);
// }
String clientId = IdUtil.simpleUUID().toString();
infoModel.setClientNo(clientId);
infoModel.setOrderNo(request.getOrderNo());
model.setClientNo(clientResult.getResult());
model.setClientNo(clientId);
model.setOrderNo(request.getOrderNo());
ossUtils.upStringObject(model.getCreditDetailUrl(), JSON.toJSONString(infoModel));
model.setClientCell(basicModel.getPhone());
......
......@@ -5,9 +5,9 @@ import lombok.Data;
@Data
public class ZyHttpBaseRquest {
private String clientld;
private String clientId;
private String serviceld;
private String serviceId;
private String segNo;
......
package com.jqtx.windows.utils;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.UUID;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jqtx.windows.component.model.ZyHttpBaseResponse;
......@@ -14,7 +16,12 @@ import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@Component
......@@ -25,10 +32,8 @@ public class AbcHttpClient {
private String posetUrl;
@Value("${zhenong.yyPrivateKey}")
private String privateKey;
@Value("${zhenong.publicKey}")
private String ypdPublicKey;
@Value("${zhenong.clientId}")
private String clientId;
......@@ -37,8 +42,8 @@ public class AbcHttpClient {
try {
final String url = posetUrl;
ZyHttpBaseRquest zyHttpBaseRquest = new ZyHttpBaseRquest();
zyHttpBaseRquest.setClientld(clientId);
zyHttpBaseRquest.setServiceld(method);
zyHttpBaseRquest.setClientId(clientId);
zyHttpBaseRquest.setServiceId(method);
zyHttpBaseRquest.setSegNo(UUID.fastUUID().toString());
zyHttpBaseRquest.setTransDateTime(LocalDateTime.now().toString());
String responseParam = EncryptUtil.encrypt(paramJson, AbcRsaUtil.getPublicKey(ypdPublicKey));
......@@ -72,4 +77,58 @@ public class AbcHttpClient {
}
return null;
}
public static void main(String[] args) {
try {
//授信查询接口demo
String param = "{\"approvalAmount\":\"10000.0000\",\"remark\":\"授信通过\",\"status\":\"1\",\"transNo\":\"b75e1cafbbcd44229a61e5aeb3b514b2\",\"orderNo\":\"202310237010\"}";
String ypdPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmjHH4WCuyKPDDY4gp6DJatkCdhyScKQLytmug5ITGQBlUaWINosmx9PhBU+B4YNrrZ/XvQb7AWKz5jX2ZxTlGJ4FuAsE1lNg4FPpQe/v/MjQCnE/tWqrB41apFeTMXaDSH3ceDusOxU2fsgrltzcgjMT6NCLNv1nVpFaO7UwRlidQHXGxP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KCwKBgQCnshuazZAq3ERbpekIV1mA4Eb+dFwGR4Gg+lXw+OkqPbP5WFL2QDUNSSPKCop794OTguiUboB98DIti3Ace7ImbhFf7jwC2GsuYh4r9HguXUgRBwhpAFNRjg6qiePeWu6rDMZKa6fUKzuhY27yvAxGoJ5035TEd895NqNOQAZWiQKBgQCCYR90NcaNVFwdnEEqKghw6+2eeEPYV4eiINjfTU2MDF/bj3Vbob42fARSvurZ4dxCNIJjuRZIHNjwEI2ZT3jXb2UYrzHWGRURDcuyC2e7947/JRN38wlqAf1wL4p1XH0l4o0KDga3Bxnrd0FJ1jZEaDlnrgVTJaQQlBUE6s/rtQKBgEsHa0Zltp0WlBcVMiAjRM5eiiUK1qmQkLT/jDgWhev6U226UNQQgiwBj1u0P6WbZmk3ZuwSTLcMIscx3eVAisKa+HcdVghH4ByOlcVAygyke7vyk5a3KJASqQkwTJ2Nvb8WJhnh9OL+vN1Gabt821k2P+82oY8Ns+wdwA8gojVRAoGAXWhArH0ACZ04QcajvnMH6Nay3m3au2ndLUdShPQEMeCpoQGhmdpoPHHCQxPL8nBZoRjoDBZ0m91CVjxwFmyM2dfIXglvYAhR9LfSr8vWnhuTxtBf6V67fX/Xt8Q1EKBUL6FN5XA75+i6j5nHX3m9O0XRbgnU8fcnawmerzrMhMo=\n";
String result = send(param, "http://115.238.89.106:8888" + "/openapi", ypdPublicKey, privateKey);
JSONObject jsonObject = JSONObject.parseObject(result);
String sign = jsonObject.getString("sign");
String data = jsonObject.getString("data");
/*验签*/
boolean f = SignUtil.veriSign(data, sign, AbcRsaUtil.getPublicKey(ypdPublicKey));
if (f) {
String dec = EncryptUtil.decrypt(data, AbcRsaUtil.getPrivateKey(privateKey));
System.out.println("解密后返回数据:" + dec);
} else {
System.out.println("验签异常");
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private static String send(String param, String url, String ypdPublicKey, String privateKey) throws Exception {
ZyHttpBaseRquest zyHttpBaseRquest = new ZyHttpBaseRquest();
zyHttpBaseRquest.setClientId("yingyxh_danbao_test");
zyHttpBaseRquest.setServiceId("creditNotify");
zyHttpBaseRquest.setSegNo(UUID.fastUUID().toString());
zyHttpBaseRquest.setTransDateTime(DateUtil.now());
String responseParam = EncryptUtil.encrypt(param, AbcRsaUtil.getPublicKey(ypdPublicKey));
System.out.println("加密后数据:" + responseParam);
zyHttpBaseRquest.setData(responseParam);
/*签名*/
String responseSign = SignUtil.sign(responseParam, AbcRsaUtil.getPrivateKey(privateKey));
System.out.println("签名后数据:" + responseSign);
zyHttpBaseRquest.setSign(responseSign);
// 请求认证头
System.out.println("整理参数:" + JSON.toJSONString(zyHttpBaseRquest));
System.out.println("url:" + url);
HashMap<String, String> headers = new HashMap<>();//存放请求头,可以存放多个请求头
headers.put("Content-Type", "application/json;charset=UTF-8");
HttpResponse response = HttpRequest.post(url)
.header("Content-Type", "application/json;charset=UTF-8")
.body(JSON.toJSONString(zyHttpBaseRquest))
.setConnectionTimeout(5000).execute();
System.out.println("接口返回结果:" + response);
return response.body();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment