mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-02-18 06:06:23 +08:00
✨ #1033 微信支付增加发送小程序红包的接口
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
package com.github.binarywang.wxpay.bean.request;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 发送小程序红包请求参数对象.
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@XStreamAlias("xml")
|
||||
@Accessors(chain = true)
|
||||
public class WxPaySendMiniProgramRedpackRequest extends BaseWxPayRequest {
|
||||
private static final long serialVersionUID = -2035425086824987567L;
|
||||
|
||||
@Override
|
||||
protected String[] getIgnoredParamsForSign() {
|
||||
return new String[]{"sign_type", "sub_appid"};
|
||||
}
|
||||
|
||||
/**
|
||||
* mch_billno.
|
||||
* 商户订单号(每个订单号必须唯一)
|
||||
* 组成:mch_id+yyyymmdd+10位一天内不能重复的数字。 接口根据商户订单号支持重入,如出现超时可再调用。
|
||||
*/
|
||||
@XStreamAlias("mch_billno")
|
||||
private String mchBillNo;
|
||||
|
||||
/**
|
||||
* send_name.
|
||||
* 商户名称
|
||||
* 红包发送者名称
|
||||
*/
|
||||
@XStreamAlias("send_name")
|
||||
private String sendName;
|
||||
|
||||
/**
|
||||
* re_openid.
|
||||
* 接受红包的用户 用户在wxappid下的openid
|
||||
*/
|
||||
@XStreamAlias("re_openid")
|
||||
private String reOpenid;
|
||||
|
||||
/**
|
||||
* total_amount.
|
||||
* 红包总额
|
||||
*/
|
||||
@XStreamAlias("total_amount")
|
||||
private Integer totalAmount;
|
||||
|
||||
/**
|
||||
* total_num
|
||||
* 红包发放总人数
|
||||
*/
|
||||
@XStreamAlias("total_num")
|
||||
private Integer totalNum;
|
||||
|
||||
/**
|
||||
* wishing.
|
||||
* 红包祝福语
|
||||
*/
|
||||
@XStreamAlias("wishing")
|
||||
private String wishing;
|
||||
|
||||
/**
|
||||
* act_name.
|
||||
* 活动名称
|
||||
*/
|
||||
@XStreamAlias("act_name")
|
||||
private String actName;
|
||||
|
||||
/**
|
||||
* remark.
|
||||
* 备注
|
||||
*/
|
||||
@XStreamAlias("remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 通知用户形式 .
|
||||
* 通过JSAPI方式领取红包,小程序红包固定传MINI_PROGRAM_JSAPI
|
||||
*/
|
||||
@XStreamAlias("notify_way")
|
||||
private String notifyWay = "MINI_PROGRAM_JSAPI";
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 发放红包使用场景,红包金额大于200时必传
|
||||
* PRODUCT_1:商品促销
|
||||
* PRODUCT_2:抽奖
|
||||
* PRODUCT_3:虚拟物品兑奖
|
||||
* PRODUCT_4:企业内部福利
|
||||
* PRODUCT_5:渠道分润
|
||||
* PRODUCT_6:保险回馈
|
||||
* PRODUCT_7:彩票派奖
|
||||
* PRODUCT_8:税务刮奖
|
||||
* </pre>
|
||||
*/
|
||||
@XStreamAlias("scene_id")
|
||||
private String sceneId;
|
||||
|
||||
@Override
|
||||
protected void checkConstraints() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.github.binarywang.wxpay.bean.result;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 发送小程序红包的返回结果
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@XStreamAlias("xml")
|
||||
public class WxPaySendMiniProgramRedpackResult extends BaseWxPayResult implements Serializable {
|
||||
/**
|
||||
* 商户订单号.
|
||||
*/
|
||||
@XStreamAlias("mch_billno")
|
||||
private String mchBillNo;
|
||||
|
||||
/**
|
||||
* 公众账号appid.
|
||||
*/
|
||||
@XStreamAlias("wxappid")
|
||||
private String wxAppid;
|
||||
|
||||
/**
|
||||
* 用户openid.
|
||||
*/
|
||||
@XStreamAlias("re_openid")
|
||||
private String reOpenid;
|
||||
|
||||
/**
|
||||
* 付款金额.
|
||||
*/
|
||||
@XStreamAlias("total_amount")
|
||||
private int totalAmount;
|
||||
|
||||
/**
|
||||
* 返回jaspi的入参package的值.
|
||||
*/
|
||||
@XStreamAlias("package")
|
||||
private String packageName;
|
||||
|
||||
/**
|
||||
* 微信单号.
|
||||
*/
|
||||
@XStreamAlias("send_listid")
|
||||
private String sendListId;
|
||||
|
||||
}
|
||||
@@ -1,16 +1,7 @@
|
||||
package com.github.binarywang.wxpay.service;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.WxPayApiData;
|
||||
import com.github.binarywang.wxpay.bean.coupon.WxPayCouponInfoQueryRequest;
|
||||
import com.github.binarywang.wxpay.bean.coupon.WxPayCouponInfoQueryResult;
|
||||
import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendRequest;
|
||||
import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendResult;
|
||||
import com.github.binarywang.wxpay.bean.coupon.WxPayCouponStockQueryRequest;
|
||||
import com.github.binarywang.wxpay.bean.coupon.WxPayCouponStockQueryResult;
|
||||
import com.github.binarywang.wxpay.bean.coupon.*;
|
||||
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
||||
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
|
||||
import com.github.binarywang.wxpay.bean.notify.WxScanPayNotifyResult;
|
||||
@@ -19,6 +10,10 @@ import com.github.binarywang.wxpay.bean.result.*;
|
||||
import com.github.binarywang.wxpay.config.WxPayConfig;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 微信支付相关接口.
|
||||
@@ -281,6 +276,19 @@ public interface WxPayService {
|
||||
*/
|
||||
WxScanPayNotifyResult parseScanPayNotifyResult(String xmlData) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 发送小程序红包.
|
||||
* 文档详见: https://pay.weixin.qq.com/wiki/doc/api/tools/miniprogram_hb.php?chapter=13_9&index=2
|
||||
* 接口地址:https://api.mch.weixin.qq.com/mmpaymkttransfers/sendminiprogramhb
|
||||
* </pre>
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @return the result
|
||||
* @throws WxPayException the exception
|
||||
*/
|
||||
WxPaySendMiniProgramRedpackResult sendMiniProgramRedpack(WxPaySendMiniProgramRedpackRequest request) throws WxPayException;
|
||||
|
||||
/**
|
||||
* 发送微信红包给个人用户.
|
||||
* <pre>
|
||||
|
||||
@@ -182,7 +182,19 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public WxPaySendMiniProgramRedpackResult sendMiniProgramRedpack(WxPaySendMiniProgramRedpackRequest request)
|
||||
throws WxPayException {
|
||||
request.checkAndSign(this.getConfig());
|
||||
String url = this.getPayBaseUrl() + "/mmpaymkttransfers/sendminiprogramhb";
|
||||
String responseContent = this.post(url, request.toXML(), true);
|
||||
|
||||
WxPaySendMiniProgramRedpackResult result = BaseWxPayResult.fromXML(responseContent, WxPaySendMiniProgramRedpackResult.class);
|
||||
result.checkResult(this, request.getSignType(), true);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxPaySendRedpackResult sendRedpack(WxPaySendRedpackRequest request) throws WxPayException {
|
||||
request.checkAndSign(this.getConfig());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user