|
@@ -1,6 +1,9 @@
|
|
|
package com.zhongshu.payment.server.core.service.pay.impl.unionFrictionlessPay;
|
|
package com.zhongshu.payment.server.core.service.pay.impl.unionFrictionlessPay;
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.github.microservice.core.util.net.apache.HttpClientUtil;
|
|
import com.github.microservice.core.util.net.apache.HttpClientUtil;
|
|
|
import com.github.microservice.core.util.net.apache.HttpModel;
|
|
import com.github.microservice.core.util.net.apache.HttpModel;
|
|
|
import com.github.microservice.core.util.net.apache.MethodType;
|
|
import com.github.microservice.core.util.net.apache.MethodType;
|
|
@@ -10,12 +13,20 @@ import com.zhongshu.card.client.model.payment.RequestInfoSaveParam;
|
|
|
import com.zhongshu.card.client.service.feign.RequestInfoFeignService;
|
|
import com.zhongshu.card.client.service.feign.RequestInfoFeignService;
|
|
|
import com.zhongshu.card.client.type.payment.RequestType;
|
|
import com.zhongshu.card.client.type.payment.RequestType;
|
|
|
import com.zhongshu.payment.client.payModel.unionFrictionlessPay.model.ApiConfParam;
|
|
import com.zhongshu.payment.client.payModel.unionFrictionlessPay.model.ApiConfParam;
|
|
|
|
|
+import com.zhongshu.payment.client.payModel.unionFrictionlessPay.model.UnionSuperParam;
|
|
|
import com.zhongshu.payment.server.core.service.base.SuperService;
|
|
import com.zhongshu.payment.server.core.service.base.SuperService;
|
|
|
|
|
+import com.zhongshu.payment.server.core.service.pay.impl.unionFrictionlessPay.config.UnionPaymentConfig;
|
|
|
|
|
+import com.zhongshu.payment.server.core.utils.AesUtils;
|
|
|
|
|
+import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StopWatch;
|
|
import org.springframework.util.StopWatch;
|
|
|
|
|
|
|
|
|
|
+import java.net.URLEncoder;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.TreeMap;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 银联无感支付的请求
|
|
* 银联无感支付的请求
|
|
|
*
|
|
*
|
|
@@ -74,5 +85,45 @@ public class UnionRequestService extends SuperService {
|
|
|
return responseModel;
|
|
return responseModel;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @SneakyThrows
|
|
|
|
|
+ public String signParam(UnionSuperParam param) {
|
|
|
|
|
+ JSONObject entries = JSONUtil.parseObj(param);
|
|
|
|
|
+ return signByJSONObject(entries);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @SneakyThrows
|
|
|
|
|
+ public String signByJSONObject(JSONObject entries) {
|
|
|
|
|
+ TreeMap<String, Object> map = new TreeMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ for (String key : entries.keySet()) {
|
|
|
|
|
+ if (!ObjectUtil.isEmpty(entries.get(key)) && !"sign".equals(key)) {
|
|
|
|
|
+ map.put(key, String.valueOf(entries.get(key)));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ StringBuffer signPara = new StringBuffer();//代签名的字符串
|
|
|
|
|
+ StringBuffer reqPara = new StringBuffer();// 组织请求参数
|
|
|
|
|
+
|
|
|
|
|
+ for (String key : map.keySet()) {
|
|
|
|
|
+ if (signPara.length() == 0) {
|
|
|
|
|
+ signPara.append(key + "=" + map.get(key));
|
|
|
|
|
+ reqPara.append(key + "=" + URLEncoder.encode(String.valueOf(map.get(key)), "UTF-8"));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Object o = map.get(key);
|
|
|
|
|
+ if (o instanceof ArrayList) {
|
|
|
|
|
+ String jsonStr = JSONUtil.toJsonStr(o);
|
|
|
|
|
+ signPara.append("&" + key + "=" + jsonStr);
|
|
|
|
|
+ reqPara.append("&" + key + "=" + URLEncoder.encode(jsonStr, "UTF-8"));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ signPara.append("&" + key + "=" + map.get(key));
|
|
|
|
|
+ reqPara.append("&" + key + "=" + URLEncoder.encode(String.valueOf(map.get(key)), "UTF-8"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ String sign = AesUtils.signData(signPara.toString() + UnionPaymentConfig.payKey);
|
|
|
|
|
+ StringBuffer append = reqPara.append("&sign=" + URLEncoder.encode(sign, "UTF-8"));
|
|
|
|
|
+ return append.toString();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|