From bc472feefdfc4afbcb0fcd35a8fb8d047edf6a9f Mon Sep 17 00:00:00 2001
From: “djh” <“3298565835@qq.com”>
Date: Tue, 18 Feb 2025 16:50:30 +0800
Subject: [PATCH] 煤矿缴费修改
---
exam-system/src/main/java/com/gkhy/exam/pay/utils/DemoUtils.java | 178 +++++++++++++++++++++++++++++++++++++----------------------
1 files changed, 111 insertions(+), 67 deletions(-)
diff --git a/exam-system/src/main/java/com/gkhy/exam/pay/utils/DemoUtils.java b/exam-system/src/main/java/com/gkhy/exam/pay/utils/DemoUtils.java
index 66612af..aac0545 100644
--- a/exam-system/src/main/java/com/gkhy/exam/pay/utils/DemoUtils.java
+++ b/exam-system/src/main/java/com/gkhy/exam/pay/utils/DemoUtils.java
@@ -1,12 +1,18 @@
package com.gkhy.exam.pay.utils;
+import cn.com.jit.mof.MOFClient;
+import cn.com.jit.mof.bean.MOFSignResult;
+import cn.com.jit.mof.bean.MOFVerifyResult;
+import cn.com.jit.new_vstk.exception.NewCSSException;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject;
+import com.gkhy.exam.pay.entity.PayReqData;
import org.apache.commons.codec.binary.Base64;
import sun.misc.BASE64Encoder;
import java.io.*;
import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
@@ -72,7 +78,7 @@
e.printStackTrace();
}
- String jmsignfile = signFilejdnew(trr2);
+ String jmsignfile = signFilejdnew(trr2, null);
String zuizhongpath = montageXmlV3(xmlFilePath, jmsignfile);
String zzsignfile = convertFileToBase64(zuizhongpath);
@@ -82,6 +88,44 @@
File file1 = new File(zuizhongpath);
file1.delete();
return result;
+ }
+
+
+ public void faqiV3(PayReqData payReqData) throws Exception {
+
+ PayUtils payUtils = new PayUtils();
+ ResultVo resultVo = payUtils.sendApiPost(payReqData);
+ String fileData = resultVo.getRespdata().getFileData();
+ String orderNo = resultVo.getRespdata().getOrderNo();
+
+ String xmlFilePath = "D:/files/" + orderNo + ".xml";
+ generateBase64StringToFile(fileData, xmlFilePath);
+ String trr2 = "";
+ try {
+ File file2 = new File(xmlFilePath);
+ FileReader reader1 = new FileReader(file2);
+ BufferedReader bReader = new BufferedReader(reader1);
+ StringBuilder sb = new StringBuilder();
+ String s = "";
+ while ((s = bReader.readLine()) != null) {
+ sb.append(s);
+ }
+ bReader.close();
+ trr2 = sb.toString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ JSONObject jsonObject = signFileV2(fileData);
+ String jmsignfile = signFilejdnew(trr2, jsonObject);
+ String zuizhongpath = montageXmlV3(xmlFilePath, jmsignfile);
+ String zzsignfile = convertFileToBase64(zuizhongpath);
+
+ uploadXml(orderNo, zzsignfile);
+ File file = new File(xmlFilePath);
+ file.delete();
+ File file1 = new File(zuizhongpath);
+ file1.delete();
+
}
public String getMD5(String input) {
@@ -129,11 +173,11 @@
}
}
- public String signFilejdnew(String plain) {
- BillSign sign = new BillSign((ISignCommond) new Object());
+ public String signFilejdnew(String plain, JSONObject job) {
+
try {
- String xx = sign.signBill(plain);
- return xx;
+ String s = BillSignUtils.signBill(plain, job);
+ return s;
} catch (BillSignException e) {
e.printStackTrace();
return null;
@@ -159,68 +203,68 @@
return null;
}
-// public JSONObject signFileV2(JSONObject job) throws Exception {
-// JSONObject xysfResult = new JSONObject();
-// String certId = "11650000MB1957293J";
-// String plain = job.getString("data").trim();
-// MOFSignResult result = null;
-// Map<String, Object> mmp = new HashMap<>();
-//
-// try {
-// String filePath = "F:/cssconfig.properties";
-// System.out.println("配置文件路径:" + filePath);
-//
-// MOFClient client = new MOFClient(filePath);
-// System.out.println("证书标识为:" + certId);
-// System.out.println("待签名数据:" + plain);
-//
-//
-// result = client.sign(certId, plain.getBytes(StandardCharsets.UTF_8));
-// /* 323 */
-// System.out.println("签名返回结果:" + JSONObject.toJSONString(result));
-//
-// /* 325 */
-// byte[] signData = result.getSignData();
-//
-// /* 327 */
-// String base64Str = new String(Base64.encode(signData));
-// /* 328 */
-// mmp.put("signResult", base64Str);
-//
-// /* 330 */
-// MOFVerifyResult resultVer = client.verifySign(signData, plain.getBytes(StandardCharsets.UTF_8));
-// /* 331 */
-// System.out.println("验签结果为:" + JSONObject.toJSONString(resultVer));
-//
-// /* 333 */
-// mmp.put("issure", resultVer.getIssure());
-// /* 334 */
-// mmp.put("sn", resultVer.getSn());
-// /* 335 */
-// mmp.put("signTime", resultVer.getSignTime());
-//
-// /* 337 */
-// xysfResult.put("success", Boolean.valueOf(true));
-// /* 338 */
-// xysfResult.put("content", mmp);
-// /* 339 */
-// return xysfResult;
-// }
-// /* 341 */ catch (NewCSSException e) {
-// /* 342 */
-// System.out.println("****签名失败****");
-// /* 343 */
-// System.out.println("错误号为:" + e.getCode());
-// /* 344 */
-// System.out.println("错误描述为:" + e.getDescription());
-// /* 345 */
-// xysfResult.put("success", Boolean.valueOf(false));
-// /* 346 */
-// xysfResult.put("msg", "系统错误");
-// /* 347 */
-// return xysfResult;
-// }
-// }
+ public JSONObject signFileV2(String plain) throws Exception {
+ JSONObject xysfResult = new JSONObject();
+ String certId = "11650000MB1957293J";
+
+ MOFSignResult result = null;
+ Map<String, Object> mmp = new HashMap<>();
+
+ try {
+ String filePath = "F:/cssconfig.properties";
+ System.out.println("配置文件路径:" + filePath);
+
+ MOFClient client = new MOFClient(filePath);
+ System.out.println("证书标识为:" + certId);
+ System.out.println("待签名数据:" + plain);
+
+
+ result = client.sign(certId, plain.getBytes(StandardCharsets.UTF_8));
+ /* 323 */
+ System.out.println("签名返回结果:" + JSONObject.toJSONString(result));
+
+ /* 325 */
+ byte[] signData = result.getSignData();
+
+ /* 327 */
+ String base64Str = new String(Base64.decodeBase64(signData));
+ /* 328 */
+ mmp.put("signResult", base64Str);
+
+ /* 330 */
+ MOFVerifyResult resultVer = client.verifySign(signData, plain.getBytes(StandardCharsets.UTF_8));
+ /* 331 */
+ System.out.println("验签结果为:" + JSONObject.toJSONString(resultVer));
+
+ /* 333 */
+ mmp.put("issure", resultVer.getIssure());
+ /* 334 */
+ mmp.put("sn", resultVer.getSn());
+ /* 335 */
+ mmp.put("signTime", resultVer.getSignTime());
+
+ /* 337 */
+ xysfResult.put("success", Boolean.valueOf(true));
+ /* 338 */
+ xysfResult.put("content", mmp);
+ /* 339 */
+ return xysfResult;
+ }
+ /* 341 */ catch (NewCSSException e) {
+ /* 342 */
+ System.out.println("****签名失败****");
+ /* 343 */
+ System.out.println("错误号为:" + e.getCode());
+ /* 344 */
+ System.out.println("错误描述为:" + e.getDescription());
+ /* 345 */
+ xysfResult.put("success", Boolean.valueOf(false));
+ /* 346 */
+ xysfResult.put("msg", "系统错误");
+ /* 347 */
+ return xysfResult;
+ }
+ }
public static String montageXmlV3(String ywfilePath, String xmlStr) {
--
Gitblit v1.9.2