mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
增加查询红包记录的接口 for #73
This commit is contained in:
@@ -121,7 +121,9 @@ public interface WxMpPayService {
|
||||
* <pre>
|
||||
* 文档详见:
|
||||
* 发送普通红包 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_4&index=3
|
||||
* 接口地址:https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack
|
||||
* 发送裂变红包 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5&index=4
|
||||
* 接口地址:https://api.mch.weixin.qq.com/mmpaymkttransfers/sendgroupredpack
|
||||
* </pre>
|
||||
*
|
||||
* @param request 请求对象
|
||||
@@ -129,6 +131,19 @@ public interface WxMpPayService {
|
||||
*/
|
||||
WxPaySendRedpackResult sendRedpack(WxPaySendRedpackRequest request, File keyFile) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 查询红包记录
|
||||
* 用于商户对已发放的红包进行查询红包的具体信息,可支持普通红包和裂变包。
|
||||
* 请求Url https://api.mch.weixin.qq.com/mmpaymkttransfers/gethbinfo
|
||||
* 是否需要证书 是(证书及使用说明详见商户证书)
|
||||
* 请求方式 POST
|
||||
* </pre>
|
||||
* @param mchBillNo 商户发放红包的商户订单号,比如10000098201411111234567890
|
||||
* @param keyFile 证书文件对象
|
||||
*/
|
||||
WxPayRedpackQueryResult queryRedpack(String mchBillNo, File keyFile) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 企业付款业务是基于微信支付商户平台的资金管理能力,为了协助商户方便地实现企业向个人付款,针对部分有开发能力的商户,提供通过API完成企业付款的功能。
|
||||
|
||||
@@ -183,6 +183,32 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxPayRedpackQueryResult queryRedpack(String mchBillNo, File keyFile) throws WxErrorException {
|
||||
XStream xstream = XStreamInitializer.getInstance();
|
||||
xstream.processAnnotations(WxPayRedpackQueryRequest.class);
|
||||
xstream.processAnnotations(WxPayRedpackQueryResult.class);
|
||||
|
||||
WxPayRedpackQueryRequest request = new WxPayRedpackQueryRequest();
|
||||
request.setMchBillNo(mchBillNo);
|
||||
request.setBillType("MCHT");
|
||||
|
||||
request.setAppid(this.wxMpService.getWxMpConfigStorage().getAppId());
|
||||
String mchId = this.wxMpService.getWxMpConfigStorage().getPartnerId();
|
||||
request.setMchId(mchId);
|
||||
request.setNonceStr(System.currentTimeMillis() + "");
|
||||
|
||||
String sign = this.createSign(BeanUtils.xmlBean2Map(request),
|
||||
this.wxMpService.getWxMpConfigStorage().getPartnerKey());
|
||||
request.setSign(sign);
|
||||
|
||||
String url = PAY_BASE_URL + "/mmpaymkttransfers/gethbinfo";
|
||||
String responseContent = this.executeRequestWithKeyFile(url, keyFile, xstream.toXML(request), mchId);
|
||||
WxPayRedpackQueryResult result = (WxPayRedpackQueryResult) xstream.fromXML(responseContent);
|
||||
this.checkResult(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信公众号支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3)
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user