对裂变红包的支持 & 去除废弃的字段
This commit is contained in:
parent
efa08c3bf4
commit
2a6e5eec70
@ -72,8 +72,9 @@ public class CashApi {
|
|||||||
try {
|
try {
|
||||||
WeixinRequestExecutor weixinExecutor = new WeixinSSLRequestExecutor(
|
WeixinRequestExecutor weixinExecutor = new WeixinSSLRequestExecutor(
|
||||||
weixinAccount.getMchId(), ca);
|
weixinAccount.getMchId(), ca);
|
||||||
response = weixinExecutor.post(PayURLConsts.MCH_REDPACKSEND_URL,
|
response = weixinExecutor
|
||||||
param);
|
.post(redpacket.getTotalNum() > 1 ? PayURLConsts.MCH_REDPACK_GROUPSEND_URL
|
||||||
|
: PayURLConsts.MCH_REDPACKSEND_URL, param);
|
||||||
} finally {
|
} finally {
|
||||||
if (ca != null) {
|
if (ca != null) {
|
||||||
try {
|
try {
|
||||||
@ -108,7 +109,8 @@ public class CashApi {
|
|||||||
para.put("bill_type", "MCHT");
|
para.put("bill_type", "MCHT");
|
||||||
para.put("appid", weixinAccount.getId());
|
para.put("appid", weixinAccount.getId());
|
||||||
para.put("mch_billno", outTradeNo);
|
para.put("mch_billno", outTradeNo);
|
||||||
String sign = DigestUtil.paysignMd5(para, weixinAccount.getPaySignKey());
|
String sign = DigestUtil
|
||||||
|
.paysignMd5(para, weixinAccount.getPaySignKey());
|
||||||
para.put("sign", sign);
|
para.put("sign", sign);
|
||||||
String param = XmlStream.map2xml(para);
|
String param = XmlStream.map2xml(para);
|
||||||
WeixinResponse response = null;
|
WeixinResponse response = null;
|
||||||
|
|||||||
@ -69,10 +69,15 @@ public final class PayURLConsts {
|
|||||||
public static final String MCH_PAYREPORT_URL = MCH_BASE_URL
|
public static final String MCH_PAYREPORT_URL = MCH_BASE_URL
|
||||||
+ "/payitil/report";
|
+ "/payitil/report";
|
||||||
/**
|
/**
|
||||||
* 发送现金红包(商户平台)
|
* 发送现金红包-普通红包(商户平台)
|
||||||
*/
|
*/
|
||||||
public static final String MCH_REDPACKSEND_URL = MCH_BASE_URL
|
public static final String MCH_REDPACKSEND_URL = MCH_BASE_URL
|
||||||
+ "/mmpaymkttransfers/sendredpack";
|
+ "/mmpaymkttransfers/sendredpack";
|
||||||
|
/**
|
||||||
|
* 发送现金红包-裂变红包(商户平台)
|
||||||
|
*/
|
||||||
|
public static final String MCH_REDPACK_GROUPSEND_URL = MCH_BASE_URL
|
||||||
|
+ "/mmpaymkttransfers/sendgroupredpack";
|
||||||
/**
|
/**
|
||||||
* 查询现金红包(商户平台)
|
* 查询现金红包(商户平台)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -18,7 +18,9 @@ import com.foxinmy.weixin4j.util.DateUtil;
|
|||||||
* @date 2015年3月28日
|
* @date 2015年3月28日
|
||||||
* @since JDK 1.6
|
* @since JDK 1.6
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://pay.weixin.qq.com/wiki/doc/api/cash_coupon.php?chapter=13_1">红包简介</a>
|
* href="http://pay.weixin.qq.com/wiki/doc/api/cash_coupon.php?chapter=13_1">普通红包</a>
|
||||||
|
* @see <a
|
||||||
|
* href="https://pay.weixin.qq.com/wiki/doc/api/cash_coupon.php?chapter=16_1">裂变红包</a>
|
||||||
*/
|
*/
|
||||||
@XmlRootElement
|
@XmlRootElement
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
@ -31,12 +33,6 @@ public class Redpacket implements Serializable {
|
|||||||
@XmlElement(name = "mch_billno")
|
@XmlElement(name = "mch_billno")
|
||||||
@JSONField(name = "mch_billno")
|
@JSONField(name = "mch_billno")
|
||||||
private String outTradeNo;
|
private String outTradeNo;
|
||||||
/**
|
|
||||||
* 提供方名称 必填
|
|
||||||
*/
|
|
||||||
@XmlElement(name = "nick_name")
|
|
||||||
@JSONField(name = "nick_name")
|
|
||||||
private String nickName;
|
|
||||||
/**
|
/**
|
||||||
* 红包发送者名称 必填
|
* 红包发送者名称 必填
|
||||||
*/
|
*/
|
||||||
@ -55,24 +51,18 @@ public class Redpacket implements Serializable {
|
|||||||
@XmlElement(name = "total_amount")
|
@XmlElement(name = "total_amount")
|
||||||
@JSONField(name = "total_amount")
|
@JSONField(name = "total_amount")
|
||||||
private String totalAmount;
|
private String totalAmount;
|
||||||
/**
|
|
||||||
* 最小红包金额,单位分
|
|
||||||
*/
|
|
||||||
@XmlElement(name = "min_value")
|
|
||||||
@JSONField(name = "min_value")
|
|
||||||
private String minValue;
|
|
||||||
/**
|
|
||||||
* 最大红包金额,单位分( 最小金额等于最大金额: min_value=max_value =total_amount)
|
|
||||||
*/
|
|
||||||
@XmlElement(name = "max_value")
|
|
||||||
@JSONField(name = "max_value")
|
|
||||||
private String maxValue;
|
|
||||||
/**
|
/**
|
||||||
* 红包发放总人数
|
* 红包发放总人数
|
||||||
*/
|
*/
|
||||||
@XmlElement(name = "total_num")
|
@XmlElement(name = "total_num")
|
||||||
@JSONField(name = "total_num")
|
@JSONField(name = "total_num")
|
||||||
private int totalNum;
|
private int totalNum;
|
||||||
|
/**
|
||||||
|
* 红包金额设置方式(裂变红包) ALL_RAND—全部随机,商户指定总金额和红包发放总人数,由微信支付随机计算出各红包金额
|
||||||
|
*/
|
||||||
|
@XmlElement(name = "amt_type")
|
||||||
|
@JSONField(name = "amt_type")
|
||||||
|
private String amtType;
|
||||||
/**
|
/**
|
||||||
* 红包祝福语
|
* 红包祝福语
|
||||||
*/
|
*/
|
||||||
@ -93,30 +83,6 @@ public class Redpacket implements Serializable {
|
|||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
/**
|
|
||||||
* 商户logo的url 非必填
|
|
||||||
*/
|
|
||||||
@XmlElement(name = "logo_imgurl")
|
|
||||||
@JSONField(name = "logo_imgurl")
|
|
||||||
private String logoUrl;
|
|
||||||
/**
|
|
||||||
* 分享文案 非必填
|
|
||||||
*/
|
|
||||||
@XmlElement(name = "share_content")
|
|
||||||
@JSONField(name = "share_content")
|
|
||||||
private String shareContent;
|
|
||||||
/**
|
|
||||||
* 分享链接 非必填
|
|
||||||
*/
|
|
||||||
@XmlElement(name = "share_url")
|
|
||||||
@JSONField(name = "share_url")
|
|
||||||
private String shareUrl;
|
|
||||||
/**
|
|
||||||
* 分享的图片 非必填
|
|
||||||
*/
|
|
||||||
@XmlElement(name = "share_imgurl")
|
|
||||||
@JSONField(name = "share_imgurl")
|
|
||||||
private String shareImageUrl;
|
|
||||||
|
|
||||||
protected Redpacket() {
|
protected Redpacket() {
|
||||||
// jaxb required
|
// jaxb required
|
||||||
@ -127,32 +93,29 @@ public class Redpacket implements Serializable {
|
|||||||
*
|
*
|
||||||
* @param outTradeNo
|
* @param outTradeNo
|
||||||
* 商户侧一天内不可重复的订单号 接口根据商户订单号支持重入 如出现超时可再调用
|
* 商户侧一天内不可重复的订单号 接口根据商户订单号支持重入 如出现超时可再调用
|
||||||
* @param nickName
|
|
||||||
* 提供方名称
|
|
||||||
* @param sendName
|
* @param sendName
|
||||||
* 红包发送者名称
|
* 红包发送者名称
|
||||||
* @param openid
|
* @param openid
|
||||||
* 接受收红包的用户的openid
|
* 接受收红包的用户的openid
|
||||||
* @param totalAmount
|
* @param totalAmount
|
||||||
* 付款金额 <font color="red">单位为元,自动格式化为分</font>
|
* 付款金额 <font color="red">单位为元,自动格式化为分</font>
|
||||||
|
* @param totalNum
|
||||||
|
* 红包发放总人数 大于1视为裂变红包
|
||||||
*/
|
*/
|
||||||
public Redpacket(String outTradeNo, String nickName, String sendName,
|
public Redpacket(String outTradeNo, String sendName, String openid,
|
||||||
String openid, double totalAmount) {
|
double totalAmount, int totalNum) {
|
||||||
this.outTradeNo = outTradeNo;
|
this.outTradeNo = outTradeNo;
|
||||||
this.nickName = nickName;
|
|
||||||
this.sendName = sendName;
|
this.sendName = sendName;
|
||||||
this.openid = openid;
|
this.openid = openid;
|
||||||
this.totalAmount = DateUtil.formaFee2Fen(totalAmount);
|
this.totalAmount = DateUtil.formaFee2Fen(totalAmount);
|
||||||
|
this.totalNum = totalNum;
|
||||||
|
this.amtType = totalNum > 1 ? "ALL_RAND" : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOutTradeNo() {
|
public String getOutTradeNo() {
|
||||||
return outTradeNo;
|
return outTradeNo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNickName() {
|
|
||||||
return nickName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSendName() {
|
public String getSendName() {
|
||||||
return sendName;
|
return sendName;
|
||||||
}
|
}
|
||||||
@ -165,42 +128,10 @@ public class Redpacket implements Serializable {
|
|||||||
return totalAmount;
|
return totalAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMinValue() {
|
|
||||||
return minValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <font color="red">单位为元,自动格式化为分</font>
|
|
||||||
*
|
|
||||||
* @param minValue
|
|
||||||
* 最小红包 单位为元
|
|
||||||
*/
|
|
||||||
public void setMinValue(double minValue) {
|
|
||||||
this.minValue = DateUtil.formaFee2Fen(minValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMaxValue() {
|
|
||||||
return maxValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <font color="red">单位为元,自动格式化为分</font>
|
|
||||||
*
|
|
||||||
* @param minValue
|
|
||||||
* 最大红包 单位为元
|
|
||||||
*/
|
|
||||||
public void setMaxValue(double maxValue) {
|
|
||||||
this.maxValue = DateUtil.formaFee2Fen(maxValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTotalNum() {
|
public int getTotalNum() {
|
||||||
return totalNum;
|
return totalNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTotalNum(int totalNum) {
|
|
||||||
this.totalNum = totalNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWishing() {
|
public String getWishing() {
|
||||||
return wishing;
|
return wishing;
|
||||||
}
|
}
|
||||||
@ -209,6 +140,14 @@ public class Redpacket implements Serializable {
|
|||||||
this.wishing = wishing;
|
this.wishing = wishing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAmtType() {
|
||||||
|
return amtType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAmtType(String amtType) {
|
||||||
|
this.amtType = amtType;
|
||||||
|
}
|
||||||
|
|
||||||
public String getClientIp() {
|
public String getClientIp() {
|
||||||
return clientIp;
|
return clientIp;
|
||||||
}
|
}
|
||||||
@ -233,47 +172,12 @@ public class Redpacket implements Serializable {
|
|||||||
this.remark = remark;
|
this.remark = remark;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLogoUrl() {
|
|
||||||
return logoUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLogoUrl(String logoUrl) {
|
|
||||||
this.logoUrl = logoUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getShareContent() {
|
|
||||||
return shareContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShareContent(String shareContent) {
|
|
||||||
this.shareContent = shareContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getShareUrl() {
|
|
||||||
return shareUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShareUrl(String shareUrl) {
|
|
||||||
this.shareUrl = shareUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getShareImageUrl() {
|
|
||||||
return shareImageUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShareImageUrl(String shareImageUrl) {
|
|
||||||
this.shareImageUrl = shareImageUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Redpacket [ nickName=" + nickName + ", sendName=" + sendName
|
return "Redpacket [ sendName=" + sendName + ", openid=" + openid
|
||||||
+ ", openid=" + openid + ", totalAmount=" + totalAmount
|
+ ", amtType=" + amtType + ", totalAmount=" + totalAmount
|
||||||
+ ", minValue=" + minValue + ", maxValue=" + maxValue
|
|
||||||
+ ", totalNum=" + totalNum + ", wishing=" + wishing
|
+ ", totalNum=" + totalNum + ", wishing=" + wishing
|
||||||
+ ", clientIp=" + clientIp + ", actName=" + actName
|
+ ", clientIp=" + clientIp + ", actName=" + actName
|
||||||
+ ", remark=" + remark + ", logoUrl=" + logoUrl
|
+ ", remark=" + remark + "]";
|
||||||
+ ", shareContent=" + shareContent + ", shareUrl=" + shareUrl
|
|
||||||
+ ", shareImageUrl=" + shareImageUrl + "]";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,7 +44,6 @@ public class RedpacketRecord extends XmlResult {
|
|||||||
@XmlElement(name = "mch_id")
|
@XmlElement(name = "mch_id")
|
||||||
@JSONField(name = "mch_id")
|
@JSONField(name = "mch_id")
|
||||||
private String mchId;
|
private String mchId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 红包单号
|
* 红包单号
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package com.foxinmy.weixin4j.payment.mch;
|
package com.foxinmy.weixin4j.payment.mch;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
@ -7,6 +9,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.foxinmy.weixin4j.http.weixin.XmlResult;
|
import com.foxinmy.weixin4j.http.weixin.XmlResult;
|
||||||
|
import com.foxinmy.weixin4j.util.DateUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送红包结果
|
* 发送红包结果
|
||||||
@ -52,6 +55,18 @@ public class RedpacketSendResult extends XmlResult {
|
|||||||
@XmlElement(name = "total_amount")
|
@XmlElement(name = "total_amount")
|
||||||
@JSONField(name = "total_amount")
|
@JSONField(name = "total_amount")
|
||||||
private int totalAmount;
|
private int totalAmount;
|
||||||
|
/**
|
||||||
|
* 发放成功时间
|
||||||
|
*/
|
||||||
|
@XmlElement(name = "send_time")
|
||||||
|
@JSONField(name = "send_time")
|
||||||
|
private String sendTime;
|
||||||
|
/**
|
||||||
|
* 微信单号
|
||||||
|
*/
|
||||||
|
@XmlElement(name = "send_listid")
|
||||||
|
@JSONField(name = "send_listid")
|
||||||
|
private String sendListid;
|
||||||
|
|
||||||
protected RedpacketSendResult() {
|
protected RedpacketSendResult() {
|
||||||
// jaxb required
|
// jaxb required
|
||||||
@ -87,6 +102,19 @@ public class RedpacketSendResult extends XmlResult {
|
|||||||
return totalAmount / 100d;
|
return totalAmount / 100d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSendTime() {
|
||||||
|
return sendTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSONField(serialize = false)
|
||||||
|
public Date getFormatSendTime() {
|
||||||
|
return DateUtil.parse2yyyyMMddHHmmss(sendTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSendListid() {
|
||||||
|
return sendListid;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "RedpacketSendResult [appId=" + appId + ", mchId=" + mchId
|
return "RedpacketSendResult [appId=" + appId + ", mchId=" + mchId
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user