卡管对接加密算法修改
diff --git a/payapi/src/main/java/com/supwisdom/dlpay/util/DesUtil.java b/payapi/src/main/java/com/supwisdom/dlpay/util/DesUtil.java
new file mode 100644
index 0000000..912006f
--- /dev/null
+++ b/payapi/src/main/java/com/supwisdom/dlpay/util/DesUtil.java
@@ -0,0 +1,51 @@
+package com.supwisdom.dlpay.util;
+
+import javax.crypto.*;
+import javax.crypto.spec.DESKeySpec;
+import javax.crypto.spec.IvParameterSpec;
+
+public class DesUtil {
+
+ public static String decode(String message, String key) throws Exception {
+ DESKeySpec desKeySpec = new DESKeySpec(key.getBytes("UTF-8"));
+ SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
+ SecretKey secretKey = keyFactory.generateSecret(desKeySpec);
+
+ Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
+ cipher.init(Cipher.DECRYPT_MODE, secretKey);
+ byte[] retByte = cipher.doFinal(convertHexString(message));
+ return new String(retByte, "UTF-8");
+ }
+
+ public static String encode(String message, String key) throws Exception {
+ DESKeySpec desKeySpec = new DESKeySpec(key.getBytes("UTF-8"));
+ SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
+ SecretKey secretKey = keyFactory.generateSecret(desKeySpec);
+
+ Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
+ cipher.init(Cipher.ENCRYPT_MODE, secretKey);
+ byte[] retByte = cipher.doFinal(message.getBytes("UTF-8"));
+ return toHexString(retByte);
+ }
+
+ public static byte[] convertHexString(String ss) {
+ byte digest[] = new byte[ss.length() / 2];
+ for (int i = 0; i < digest.length; i++) {
+ String byteString = ss.substring(2 * i, 2 * i + 2);
+ int byteValue = Integer.parseInt(byteString, 16);
+ digest[i] = (byte) byteValue;
+ }
+ return digest;
+ }
+
+ public static String toHexString(byte b[]) {
+ StringBuffer hexString = new StringBuffer();
+ for (int i = 0; i < b.length; i++) {
+ String plainText = Integer.toHexString(0xff & b[i]);
+ if (plainText.length() < 2)
+ plainText = "0" + plainText;
+ hexString.append(plainText);
+ }
+ return hexString.toString();
+ }
+}
diff --git a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt
index ecc5f3b..1fda9f0 100644
--- a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt
+++ b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt
@@ -126,9 +126,10 @@
SecurityContextHolder.getContext().authentication.name))) {
throw RequestParamCheckException("参数签名错误")
}
- } else {
- throw TransactionCheckException(TradeErrorCode.REQUEST_PARAM_EEROR, "请求参数实体位置错误")
}
+// else {
+// throw TransactionCheckException(TradeErrorCode.REQUEST_PARAM_EEROR, "请求参数实体位置错误")
+// }
val result = joinPoint.proceed()
logger.debug(result.toString())
diff --git a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/bean/api_request_param.kt b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/bean/api_request_param.kt
index 739b2c3..2b19d6f 100644
--- a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/bean/api_request_param.kt
+++ b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/bean/api_request_param.kt
@@ -4,7 +4,7 @@
import com.google.gson.reflect.TypeToken
import com.supwisdom.dlpay.api.exception.RequestParamCheckException
import com.supwisdom.dlpay.framework.util.*
-import com.supwisdom.dlpay.util.DESedeUtil
+import com.supwisdom.dlpay.util.DesUtil
class DaliDatasyncParam {
var app_id: String = ""
@@ -44,7 +44,7 @@
fun decData(deskey: String): ArrayList<DaliDatasyncDetail> {
try {
val listType = object : TypeToken<ArrayList<DaliDatasyncDetail>>() {}.type
- val decstr = DESedeUtil.getInstance(deskey).decode(data)
+ val decstr = DesUtil.decode(data, deskey)
return Gson().fromJson(decstr, listType)
} catch (e: Exception) {
throw RequestParamCheckException("数据解密失败!")
@@ -72,10 +72,10 @@
}
}
-class DaliDatasyncErrorDetail{
- var cardno:String=""
- var errcode:String=""
- var errmsg:String=""
+class DaliDatasyncErrorDetail {
+ var cardno: String = ""
+ var errcode: String = ""
+ var errmsg: String = ""
}
diff --git a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/controller/dali_datasync_api_controller.kt b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/controller/dali_datasync_api_controller.kt
index 5f08635..248c831 100644
--- a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/controller/dali_datasync_api_controller.kt
+++ b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/controller/dali_datasync_api_controller.kt
@@ -14,6 +14,7 @@
import org.springframework.web.bind.annotation.*
@RequestMapping("/api/common")
+@RestController
class DaliDatasyncApiController {
@Autowired
lateinit var systemUtilService: SystemUtilService
@@ -26,7 +27,6 @@
* ============================================================================
* */
@PostMapping("/datasync")
- @ResponseBody
fun daliDatasync(@RequestBody param: DaliDatasyncParam): ResponseEntity<Any> {
try {
param.checkParam()
diff --git a/payapi/src/main/resources/templates/system/param/sourcetypeconfig.html b/payapi/src/main/resources/templates/system/param/sourcetypeconfig.html
index 4058462..2924cdb 100644
--- a/payapi/src/main/resources/templates/system/param/sourcetypeconfig.html
+++ b/payapi/src/main/resources/templates/system/param/sourcetypeconfig.html
@@ -8,10 +8,10 @@
</div>
<div class="layui-form-item" th:if="${configlist.size()} gt 0" th:each="config:${configlist}">
- <div class="layui-input-block" style="margin:0;display: inline;float: left;width: 20%;">
+ <div class="layui-input-block" style="margin:0;display: inline;float: left;width: 25%;">
<label class="layui-form-label" style="float: right;width: 100%;" th:text="${config.configid}">参数名</label>
</div>
- <div class="layui-input-block" style="margin:0;display: inline;float: right;width: 80%;">
+ <div class="layui-input-block" style="margin:0;display: inline;float: right;width: 75%;">
<input type="text" th:name="${config.configid}" class="layui-input" th:value="${config.configValue}" th:placeholder="${config.configName}" autocomplete="off"/>
</div>
</div>
diff --git a/payapi/src/main/resources/templates/system/shop/configpara.html b/payapi/src/main/resources/templates/system/shop/configpara.html
index 762778c..70dc1b5 100644
--- a/payapi/src/main/resources/templates/system/shop/configpara.html
+++ b/payapi/src/main/resources/templates/system/shop/configpara.html
@@ -10,10 +10,10 @@
</div>
<div class="layui-form-item" th:if="${configlist.size()} gt 0" th:each="config:${configlist}">
- <div class="layui-input-block" style="margin:0;display: inline;float: left;width: 20%;">
+ <div class="layui-input-block" style="margin:0;display: inline;float: left;width: 25%;">
<label class="layui-form-label" style="float: right;width: 100%;" th:text="${config.configid}">参数名</label>
</div>
- <div class="layui-input-block" style="margin:0;display: inline;float: right;width: 80%;">
+ <div class="layui-input-block" style="margin:0;display: inline;float: right;width: 75%;">
<input type="text" th:name="${config.configid}" class="layui-input" th:value="${config.configValue}" th:placeholder="${config.configName}" autocomplete="off"/>
</div>
</div>
diff --git a/ynrcc-agent/src/main/java/com/supwisdom/agent/api/bean/CheckFileHeader.java b/ynrcc-agent/src/main/java/com/supwisdom/agent/api/bean/CheckFileHeader.java
new file mode 100644
index 0000000..d29bc09
--- /dev/null
+++ b/ynrcc-agent/src/main/java/com/supwisdom/agent/api/bean/CheckFileHeader.java
@@ -0,0 +1,73 @@
+package com.supwisdom.agent.api.bean;
+
+/**
+ * 第一行:总笔数|总金额|代扣总笔数|代扣总金额|退款总笔数|退款总金额|
+ */
+public class CheckFileHeader {
+ public static final String[] chkFileHeaderColumnList = new String[]{"totalCount", "totalAmount", "payCount",
+ "payAmount", "refundCount", "refundAmount"};
+
+ private int totalCount;
+ private int totalAmount;
+ private int payCount;
+ private int payAmount;
+ private int refundCount;
+ private int refundAmount;
+
+ public static String[] getChkFileHeaderColumnList() {
+ return chkFileHeaderColumnList;
+ }
+
+ public int getTotalCount() {
+ return totalCount;
+ }
+
+ public void setTotalCount(int totalCount) {
+ this.totalCount = totalCount;
+ }
+
+ public int getTotalAmount() {
+ return totalAmount;
+ }
+
+ public void setTotalAmount(int totalAmount) {
+ this.totalAmount = totalAmount;
+ }
+
+ public int getPayCount() {
+ return payCount;
+ }
+
+ public void setPayCount(int payCount) {
+ this.payCount = payCount;
+ }
+
+ public int getPayAmount() {
+ return payAmount;
+ }
+
+ public void setPayAmount(int payAmount) {
+ this.payAmount = payAmount;
+ }
+
+ public int getRefundCount() {
+ return refundCount;
+ }
+
+ public void setRefundCount(int refundCount) {
+ this.refundCount = refundCount;
+ }
+
+ public int getRefundAmount() {
+ return refundAmount;
+ }
+
+ public void setRefundAmount(int refundAmount) {
+ this.refundAmount = refundAmount;
+ }
+
+ public boolean isZero() {
+ return (totalAmount == 0 && totalCount == 0
+ && payAmount == 0 && payCount == 0 && refundAmount == 0 && refundCount == 0);
+ }
+}
diff --git a/ynrcc-agent/src/main/java/com/supwisdom/agent/api/controller/YnrccApiController.java b/ynrcc-agent/src/main/java/com/supwisdom/agent/api/controller/YnrccApiController.java
index af77687..b0a6e76 100644
--- a/ynrcc-agent/src/main/java/com/supwisdom/agent/api/controller/YnrccApiController.java
+++ b/ynrcc-agent/src/main/java/com/supwisdom/agent/api/controller/YnrccApiController.java
@@ -4,6 +4,7 @@
import com.supwisdom.agent.Util.DlpayUtil;
import com.supwisdom.agent.Util.ErrorCode;
import com.supwisdom.agent.Util.StringUtil;
+import com.supwisdom.agent.api.bean.CheckFileHeader;
import com.supwisdom.agent.api.bean.CheckFileLine;
import com.supwisdom.agent.api.bean.DlpayReq;
import com.supwisdom.agent.api.bean.DlpayResp;
@@ -42,7 +43,7 @@
Constant.COL_REFNO, Constant.COL_AGENT_REFNO, Constant.COL_PAYERID, Constant.COL_PAYEEID,
Constant.COL_AGENT_DATE, Constant.COL_AMOUNT, Constant.COL_SUMMARY};
- private static final String chkFileDelimiter = "|";
+ private static final String chkFileDelimiter = "\\|";
private static final String FLAG_WITHHOLD = "BC5512";
private static final String FLAG_REFUND = "BC5513";
@@ -404,6 +405,7 @@
data.put(column[col], fields[col]);
}
BeanUtils.populate(bean, data);
+ return;
} catch (InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
@@ -500,72 +502,4 @@
}
}
-
- /**
- * 第一行:总笔数|总金额|代扣总笔数|代扣总金额|退款总笔数|退款总金额|
- */
- private static class CheckFileHeader {
- static final String[] chkFileHeaderColumnList = new String[]{"totalCount", "totalAmount", "payCount",
- "payAmount", "refundCount", "refundAmount"};
-
- private int totalCount;
- private int totalAmount;
- private int payCount;
- private int payAmount;
- private int refundCount;
- private int refundAmount;
-
- int getTotalCount() {
- return totalCount;
- }
-
- void setTotalCount(int totalCount) {
- this.totalCount = totalCount;
- }
-
- int getTotalAmount() {
- return totalAmount;
- }
-
- void setTotalAmount(int totalAmount) {
- this.totalAmount = totalAmount;
- }
-
- int getPayCount() {
- return payCount;
- }
-
- void setPayCount(int payCount) {
- this.payCount = payCount;
- }
-
- int getPayAmount() {
- return payAmount;
- }
-
- void setPayAmount(int payAmount) {
- this.payAmount = payAmount;
- }
-
- int getRefundCount() {
- return refundCount;
- }
-
- void setRefundCount(int refundCount) {
- this.refundCount = refundCount;
- }
-
- int getRefundAmount() {
- return refundAmount;
- }
-
- void setRefundAmount(int refundAmount) {
- this.refundAmount = refundAmount;
- }
-
- boolean isZero() {
- return (totalAmount == 0 && totalCount == 0
- && payAmount == 0 && payCount == 0 && refundAmount == 0 && refundCount == 0);
- }
- }
}