微信后端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.5 KiB

package com.ynxbd.wx.wxfactory.base.refund;
import com.ynxbd.wx.wxfactory.bean.refund.WxRefundQueryRoot;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.message.BasicHeader;
import weixin.popular.bean.paymch.Refundquery;
import weixin.popular.client.LocalHttpClient;
import weixin.popular.util.MapUtil;
import weixin.popular.util.SignatureUtil;
import weixin.popular.util.XMLConverUtil;
import java.nio.charset.StandardCharsets;
import java.util.Map;
@Slf4j
@NoArgsConstructor
public class Client {
public WxRefundQueryRoot refundQuery(Refundquery refundquery, String mchKey) {
Map<String, String> map = MapUtil.objectToMap(refundquery);
String sign = SignatureUtil.generateSign(map, refundquery.getSign_type(), mchKey);
refundquery.setSign(sign);
String reqXml = XMLConverUtil.convertToXML(refundquery);
HttpUriRequest httpUriRequest = RequestBuilder.post().setHeader(new BasicHeader("Content-Type", ContentType.APPLICATION_XML.toString())).setUri("https://api.mch.weixin.qq.com" + "/pay/refundquery").setEntity(new StringEntity(reqXml, StandardCharsets.UTF_8)).build();
return LocalHttpClient.executeXmlResult(httpUriRequest, WxRefundQueryRoot.class, refundquery.getSign_type(), mchKey);
}
}