记得上下班打卡 | git大法好,push需谨慎

Commit e56d8f2f authored by anjiabin's avatar anjiabin

提交支付查询

parent 91ecf13e
......@@ -5,10 +5,10 @@ import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.dragon.channel.strategy.IPayChannelStrategy;
import com.liquidnet.service.dragon.channel.strategy.annotation.StrategyPayChannelHandler;
import com.liquidnet.service.dragon.channel.wepay.strategy.WepayStrategyContext;
import com.liquidnet.service.dragon.channel.wepay.util.WepayUtil;
import com.liquidnet.service.dragon.constant.DragonConstant;
import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import com.liquidnet.service.dragon.utils.PayWepayUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -46,7 +46,7 @@ public class PayChannelStrategyWepayImpl implements IPayChannelStrategy {
InputStream inputStream = request.getInputStream();// 从request中取得输入流
Map<String, String> notifyMap = new HashMap<String, String>();
try {
notifyMap = WepayUtil.parseXml(inputStream);
notifyMap = PayWepayUtils.parseXml(inputStream);
log.info("dragonNotify-->wepay json : {}", JSON.toJSONString(notifyMap));
} catch (Exception e) {
e.printStackTrace();
......
......@@ -4,7 +4,6 @@ import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.dragon.channel.wepay.resp.WepayPayRespDto;
import com.liquidnet.service.dragon.channel.wepay.strategy.IWepayStrategy;
import com.liquidnet.service.dragon.channel.wepay.util.WepayUtil;
import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import com.liquidnet.service.dragon.utils.PayWepayUtils;
......@@ -44,10 +43,11 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy {
//追加请求参数
SortedMap<String, Object> parameters = appendRequestParam(commonParams);
//生成签名
String sign = WepayUtil.getSign(parameters,parentKey);
String sign = PayWepayUtils.getInstance().createSign(parameters);
parameters.put("sign", sign);
//构造支付请求xml
String data = WepayUtil.mapToXml(parameters);
String data = PayWepayUtils.getInstance().getRequestXml(parameters);
HttpPost httpost = new HttpPost(this.getRequestUrl());
httpost.setEntity(new StringEntity(data, "UTF-8"));
......
......@@ -129,7 +129,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
DragonRefundChannelDto channelDto = new DragonRefundChannelDto();
RefundContentDto contentDto = new RefundContentDto();
String nonceStr = PayWepayUtils.getInstance().getNonceStr();
SortedMap<Object, Object> parameters = new TreeMap<>();
SortedMap<String, Object> parameters = new TreeMap<>();
parameters.put("mch_id", PayWepayUtils.getInstance().getMerchantId());
if (paymentType.equalsIgnoreCase(DragonConstant.PayTypeEnum.PAYMENT_TYPE_JS_WEPAY.getCode())) {
parameters.put("appid", PayWepayUtils.getInstance().getJS_APP_ID());
......
......@@ -2,13 +2,14 @@ package com.liquidnet.service.dragon.utils;
import com.alipay.api.internal.util.file.IOUtils;
import com.liquidnet.commons.lang.util.MD5Utils;
import com.liquidnet.service.dragon.channel.wepay.resp.WePayRefundReturnDto;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContexts;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.dom4j.DocumentException;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
......@@ -107,7 +108,7 @@ public class PayWepayUtils {
return sb.toString();
}
public String createSign(SortedMap<Object, Object> parameters) {
public String createSign(SortedMap<String, Object> parameters) {
StringBuffer sb = new StringBuffer();
Set es = parameters.entrySet();//所有参与传参的参数按照accsii排序(升序)
Iterator it = es.iterator();
......@@ -124,7 +125,7 @@ public class PayWepayUtils {
return MD5Utils.md5(sb.toString()).toUpperCase();
}
public String getRequestXml(SortedMap<Object, Object> parameters) {
public String getRequestXml(SortedMap<String, Object> parameters) {
StringBuffer sb = new StringBuffer();
sb.append("<xml>");
Set es = parameters.entrySet();
......@@ -162,4 +163,26 @@ public class PayWepayUtils {
return "";
}
}
@SuppressWarnings("unchecked")
public static Map<String, String> parseXml(InputStream inputStream) throws Exception {
if (inputStream == null) {
return null;
}
Map<String, String> map = new HashMap<String, String>();// 将解析结果存储在HashMap中
SAXReader reader = new SAXReader();// 读取输入流
Document document = reader.read(inputStream);
Element root = document.getRootElement();// 得到xml根元素
List<Element> elementList = root.elements();// 得到根元素的所有子节点
for (Element e : elementList) { // 遍历所有子节点
map.put(e.getName(), e.getText());
}
inputStream.close(); // 释放资源
inputStream = null;
return map;
}
}
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