mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
✨ #1309 增加发送和查询企业微信红包的接口
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package com.github.binarywang.wxpay.bean.entpay;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 红包发送记录查询请求
|
||||
* @author wuyong
|
||||
* @date 2019-12-01 17:19
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Builder(builderMethodName = "newBuilder")
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@XStreamAlias("xml")
|
||||
public class EntPayRedpackQueryRequest extends BaseWxPayRequest {
|
||||
|
||||
|
||||
/**
|
||||
* 商户订单号
|
||||
*/
|
||||
@XStreamAlias("mch_billno")
|
||||
private String mchBillNo;
|
||||
|
||||
|
||||
@Override
|
||||
protected void checkConstraints() throws WxPayException {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.github.binarywang.wxpay.bean.entpay;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 红包发送记录查询返回
|
||||
*
|
||||
* @author wuyong
|
||||
* @date 2019-12-01 17:23
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@XStreamAlias("xml")
|
||||
public class EntPayRedpackQueryResult extends BaseWxPayResult {
|
||||
|
||||
/**
|
||||
* 商户订单号
|
||||
* 商户使用查询API填写的商户单号的原路返回
|
||||
*/
|
||||
@XStreamAlias("mch_billno")
|
||||
protected String mchBillNo;
|
||||
|
||||
/**
|
||||
* 红包单号
|
||||
* 使用API发放现金红包时返回的红包单号
|
||||
*/
|
||||
@XStreamAlias("detailId")
|
||||
private String detailId;
|
||||
/**
|
||||
* 红包状态
|
||||
* SENDING:发放
|
||||
* SENT:
|
||||
* 已发放待领取
|
||||
* FAILED:发放失败
|
||||
* RECEIVED:已领取
|
||||
* RFUND_ING:退款中 REFUND:已退款
|
||||
*/
|
||||
@XStreamAlias("status")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 发放类型
|
||||
* API:通过API接口发放
|
||||
*/
|
||||
@XStreamAlias("send_type")
|
||||
private String sendType;
|
||||
|
||||
/**
|
||||
* 红包金额
|
||||
* 红包总金额(单位分)
|
||||
*/
|
||||
@XStreamAlias("total_amount")
|
||||
private Integer totalAmount;
|
||||
|
||||
/**
|
||||
* 失败原因
|
||||
* 发送失败原因
|
||||
*/
|
||||
@XStreamAlias("reason")
|
||||
private Integer reason;
|
||||
|
||||
/**
|
||||
* 红包发送时间
|
||||
*/
|
||||
@XStreamAlias("send_time")
|
||||
private String sendTime;
|
||||
/**
|
||||
* 红包的退款时间
|
||||
*/
|
||||
@XStreamAlias("refund_time")
|
||||
private String refundTime;
|
||||
|
||||
/**
|
||||
* 红包退款金额
|
||||
*/
|
||||
@XStreamAlias("refund_amount")
|
||||
private Integer refundAmount;
|
||||
|
||||
/**
|
||||
* 祝福语
|
||||
*/
|
||||
@XStreamAlias("wishing")
|
||||
private String wishing;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@XStreamAlias("remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 活动名称
|
||||
*/
|
||||
@XStreamAlias("act_name")
|
||||
private String actName;
|
||||
|
||||
/**
|
||||
* 领取红包的Openid
|
||||
*/
|
||||
@XStreamAlias("openid")
|
||||
private String openid;
|
||||
|
||||
/**
|
||||
* 金额
|
||||
*/
|
||||
@XStreamAlias("amount")
|
||||
private Integer amount;
|
||||
|
||||
/**
|
||||
* 接收时间
|
||||
*/
|
||||
@XStreamAlias("rcv_time")
|
||||
private Integer rcvTime;
|
||||
|
||||
/**
|
||||
* 发送者名称
|
||||
*/
|
||||
@XStreamAlias("sender_name")
|
||||
private Integer senderName;
|
||||
|
||||
/**
|
||||
* 发送者头像
|
||||
* 通过企业微信开放接口上传获取
|
||||
*/
|
||||
@XStreamAlias("sender_header_media_id")
|
||||
private Integer senderHeaderMediaId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package com.github.binarywang.wxpay.bean.entpay;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import lombok.*;
|
||||
import me.chanjar.weixin.common.annotation.Required;
|
||||
|
||||
/**
|
||||
* 发送企业红包
|
||||
* @author wuyong
|
||||
* @date 2019-12-1
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Builder(builderMethodName = "newBuilder")
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@XStreamAlias("xml")
|
||||
public class EntPayRedpackRequest extends BaseWxPayRequest {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void checkConstraints() throws WxPayException {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 商户订单号(每个订单号必须唯一)
|
||||
* 组成:mch_id+yyyymmdd+10位一天内不能重复的数字。 接口根据商户订单号支持重入,如出现超时可再调用。
|
||||
* 必填:是
|
||||
*/
|
||||
@Required
|
||||
@XStreamAlias("mch_billno")
|
||||
private String mchBillNo;
|
||||
|
||||
/**
|
||||
* 微信分配的公众账号ID(企业微信corpid即为此appId)
|
||||
* 必填:是
|
||||
*/
|
||||
@Required
|
||||
@XStreamAlias("wxappid")
|
||||
private String wxAppId;
|
||||
|
||||
/**
|
||||
* 发送者名称
|
||||
* 以个人名义发红包,红包发送者名称(需要utf-8格式)。与agentid互斥,二者只能填一个。
|
||||
* 必填:否
|
||||
*/
|
||||
@XStreamAlias("sender_name")
|
||||
private String senderName;
|
||||
|
||||
/**
|
||||
* 发送红包的应用id
|
||||
* 以企业应用的名义发红包,企业应用id,整型,可在企业微信管理端应用的设置页面查看。与sender_name互斥,二者只能填一个。
|
||||
* 必填:否
|
||||
*/
|
||||
@XStreamAlias("agentid")
|
||||
private String agentId;
|
||||
|
||||
/**
|
||||
* 发送者头像
|
||||
* 发送者头像素材id,通过企业微信开放上传素材接口获取
|
||||
* 必填:否
|
||||
*/
|
||||
@XStreamAlias("sender_header_media_id")
|
||||
private String senderHeaderMediaId;
|
||||
|
||||
/**
|
||||
* 用户openid
|
||||
* 接受红包的用户.用户在wxappid下的openid。
|
||||
* 必填:是
|
||||
*/
|
||||
@Required
|
||||
@XStreamAlias("re_openid")
|
||||
private String reOpenid;
|
||||
|
||||
/**
|
||||
* 金额
|
||||
* 单位分,单笔最小金额默认为1元
|
||||
* 必填:是
|
||||
*/
|
||||
@Required
|
||||
@XStreamAlias("total_amount")
|
||||
private Integer totalAmount;
|
||||
|
||||
/**
|
||||
* 红包祝福语
|
||||
* 必填:是
|
||||
*/
|
||||
@Required
|
||||
@XStreamAlias("wishing")
|
||||
private String wishing;
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
* 必填:是
|
||||
*/
|
||||
@Required
|
||||
@XStreamAlias("act_name")
|
||||
private String actName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
* 必填:是
|
||||
*/
|
||||
@Required
|
||||
@XStreamAlias("remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 场景
|
||||
* 发放红包使用场景,红包金额大于200时必传
|
||||
* PRODUCT_1:商品促销
|
||||
* PRODUCT_2:抽奖
|
||||
* PRODUCT_3:虚拟物品兑奖
|
||||
* PRODUCT_4:企业内部福利
|
||||
* PRODUCT_5:渠道分润
|
||||
* PRODUCT_6:保险回馈
|
||||
* PRODUCT_7:彩票派奖
|
||||
* PRODUCT_8:税务刮奖
|
||||
*/
|
||||
@XStreamAlias("scene_id")
|
||||
private String sceneId;
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean ignoreAppid() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean ignoreSubAppId() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean ignoreSubMchId() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isWxWorkSign() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.github.binarywang.wxpay.bean.entpay;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 企业微信红包返回
|
||||
* @author wuyong
|
||||
* @date 2019-12-01 11:31
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@XStreamAlias("xml")
|
||||
public class EntPayRedpackResult extends BaseWxPayResult implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 商户订单号
|
||||
* 商户订单号(每个订单号必须唯一)组成:mch_id+yyyymmdd+10位一天内不能重复的数字
|
||||
*/
|
||||
@XStreamAlias("mch_billno")
|
||||
private String mchBillNo;
|
||||
|
||||
/**
|
||||
* 商户号
|
||||
* 微信支付分配的商户号
|
||||
*/
|
||||
@XStreamAlias("mch_id")
|
||||
private String mchId;
|
||||
|
||||
/**
|
||||
* 公众账号appid
|
||||
* 商户appid,接口传入的所有appid应该为公众号的appid,不能为APP的appid
|
||||
*/
|
||||
@XStreamAlias("wxappid")
|
||||
private String wxAppId;
|
||||
|
||||
/**
|
||||
* 用户openid
|
||||
* 接受收红包的用户在wxappid下的openid
|
||||
*/
|
||||
@XStreamAlias("re_openid")
|
||||
private String reOpenid;
|
||||
|
||||
/**
|
||||
* 付款金额
|
||||
* 付款金额,单位分
|
||||
*/
|
||||
@XStreamAlias("totalAmount")
|
||||
private String totalAmount;
|
||||
|
||||
/**
|
||||
* 微信单号
|
||||
* 红包订单的微信单号
|
||||
*/
|
||||
@XStreamAlias("sendListid")
|
||||
private String sendListId;
|
||||
|
||||
/**
|
||||
* 发送者名称
|
||||
* 红包发送者名称(需要utf-8格式)
|
||||
*/
|
||||
@XStreamAlias("sender_name")
|
||||
private String senderName;
|
||||
|
||||
/**
|
||||
* 发送者头像
|
||||
* 发送者头像素材id,通过企业微信开放上传素材接口获取
|
||||
*/
|
||||
@XStreamAlias("sender_header_media_id")
|
||||
private String senderHeaderMediaId;
|
||||
|
||||
}
|
||||
@@ -1,21 +1,20 @@
|
||||
package com.github.binarywang.wxpay.bean.request;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.github.binarywang.wxpay.config.WxPayConfig;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.github.binarywang.wxpay.util.SignUtils;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.BeanUtils;
|
||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
|
||||
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import static com.github.binarywang.wxpay.constant.WxPayConstants.SignType.ALL_SIGN_TYPES;
|
||||
|
||||
@@ -118,6 +117,21 @@ public abstract class BaseWxPayRequest implements Serializable {
|
||||
@XStreamAlias("sign_type")
|
||||
private String signType;
|
||||
|
||||
|
||||
/**
|
||||
* 企业微信签名
|
||||
*/
|
||||
@XStreamAlias("workwx_sign")
|
||||
private String workWxSign;
|
||||
|
||||
public String getWorkWxSign() {
|
||||
return workWxSign;
|
||||
}
|
||||
|
||||
public void setWorkWxSign(String workWxSign) {
|
||||
this.workWxSign = workWxSign;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将单位为元转换为单位为分.
|
||||
*
|
||||
@@ -205,6 +219,26 @@ public abstract class BaseWxPayRequest implements Serializable {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 签名时,是否忽略sub_appid.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
protected boolean ignoreSubAppId() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean ignoreSubMchId(){
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是企业微信字段
|
||||
*/
|
||||
protected boolean isWxWorkSign(){
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 签名时,忽略的参数.
|
||||
*
|
||||
@@ -238,12 +272,16 @@ public abstract class BaseWxPayRequest implements Serializable {
|
||||
this.setMchId(config.getMchId());
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(getSubAppId())) {
|
||||
this.setSubAppId(config.getSubAppId());
|
||||
if (!ignoreSubAppId()) {
|
||||
if (StringUtils.isBlank(getSubAppId())) {
|
||||
this.setSubAppId(config.getSubAppId());
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(getSubMchId())) {
|
||||
this.setSubMchId(config.getSubMchId());
|
||||
if (!ignoreSubMchId()) {
|
||||
if (StringUtils.isBlank(getSubMchId())) {
|
||||
this.setSubMchId(config.getSubMchId());
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(getSignType())) {
|
||||
|
||||
Reference in New Issue
Block a user