|
| 1 | +package com.github.binarywang.wxpay.bean.request; |
| 2 | + |
| 3 | +import com.thoughtworks.xstream.annotations.XStreamAlias; |
| 4 | +import org.apache.commons.lang3.StringUtils; |
| 5 | + |
| 6 | +/** |
| 7 | + * <pre> |
| 8 | + * 撤销订单请求类 |
| 9 | + * Created by Binary Wang on 2017-3-23. |
| 10 | + * @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a> |
| 11 | + * </pre> |
| 12 | + */ |
| 13 | +@XStreamAlias("xml") |
| 14 | +public class WxPayOrderReverseRequest extends WxPayBaseRequest { |
| 15 | + |
| 16 | + /** |
| 17 | + * <pre> |
| 18 | + * 微信订单号 |
| 19 | + * transaction_id |
| 20 | + * String(28) |
| 21 | + * 1217752501201400000000000000 |
| 22 | + * 微信的订单号,优先使用 |
| 23 | + * </pre> |
| 24 | + */ |
| 25 | + @XStreamAlias("transaction_id") |
| 26 | + private String transactionId; |
| 27 | + |
| 28 | + /** |
| 29 | + * <pre> |
| 30 | + * 商户订单号 |
| 31 | + * out_trade_no |
| 32 | + * String(32) |
| 33 | + * 1217752501201400000000000000 |
| 34 | + * 商户系统内部的订单号 |
| 35 | + * transaction_id、out_trade_no二选一,如果同时存在优先级:transaction_id> out_trade_no |
| 36 | + * </pre> |
| 37 | + */ |
| 38 | + @XStreamAlias("out_trade_no") |
| 39 | + private String outTradeNo; |
| 40 | + |
| 41 | + /** |
| 42 | + * <pre> |
| 43 | + * 签名类型 |
| 44 | + * sign_type |
| 45 | + * 否 |
| 46 | + * String(32) |
| 47 | + * HMAC-SHA256 |
| 48 | + * 签名类型,目前支持HMAC-SHA256和MD5,默认为MD5 |
| 49 | + **/ |
| 50 | + @XStreamAlias("sign_type") |
| 51 | + private String signType; |
| 52 | + |
| 53 | + private WxPayOrderReverseRequest(Builder builder) { |
| 54 | + setTransactionId(builder.transactionId); |
| 55 | + setAppid(builder.appid); |
| 56 | + setOutTradeNo(builder.outTradeNo); |
| 57 | + setMchId(builder.mchId); |
| 58 | + setSignType(builder.signType); |
| 59 | + setSubAppId(builder.subAppId); |
| 60 | + setSubMchId(builder.subMchId); |
| 61 | + setNonceStr(builder.nonceStr); |
| 62 | + setSign(builder.sign); |
| 63 | + } |
| 64 | + |
| 65 | + public static Builder newBuilder() { |
| 66 | + return new Builder(); |
| 67 | + } |
| 68 | + |
| 69 | + public String getTransactionId() { |
| 70 | + return this.transactionId; |
| 71 | + } |
| 72 | + |
| 73 | + public void setTransactionId(String transactionId) { |
| 74 | + this.transactionId = transactionId; |
| 75 | + } |
| 76 | + |
| 77 | + public String getOutTradeNo() { |
| 78 | + return this.outTradeNo; |
| 79 | + } |
| 80 | + |
| 81 | + public void setOutTradeNo(String outTradeNo) { |
| 82 | + this.outTradeNo = outTradeNo; |
| 83 | + } |
| 84 | + |
| 85 | + public String getSignType() { |
| 86 | + return this.signType; |
| 87 | + } |
| 88 | + |
| 89 | + public void setSignType(String signType) { |
| 90 | + this.signType = signType; |
| 91 | + } |
| 92 | + |
| 93 | + @Override |
| 94 | + protected void checkConstraints() { |
| 95 | + if (StringUtils.isBlank(transactionId) && StringUtils.isBlank(outTradeNo)) { |
| 96 | + throw new IllegalArgumentException("transaction_id 和 out_trade_no不能同时为空!"); |
| 97 | + } |
| 98 | + } |
| 99 | + |
| 100 | + public static final class Builder { |
| 101 | + private String transactionId; |
| 102 | + private String appid; |
| 103 | + private String outTradeNo; |
| 104 | + private String mchId; |
| 105 | + private String signType; |
| 106 | + private String subAppId; |
| 107 | + private String subMchId; |
| 108 | + private String nonceStr; |
| 109 | + private String sign; |
| 110 | + |
| 111 | + private Builder() { |
| 112 | + } |
| 113 | + |
| 114 | + public Builder transactionId(String transactionId) { |
| 115 | + this.transactionId = transactionId; |
| 116 | + return this; |
| 117 | + } |
| 118 | + |
| 119 | + public Builder appid(String appid) { |
| 120 | + this.appid = appid; |
| 121 | + return this; |
| 122 | + } |
| 123 | + |
| 124 | + public Builder outTradeNo(String outTradeNo) { |
| 125 | + this.outTradeNo = outTradeNo; |
| 126 | + return this; |
| 127 | + } |
| 128 | + |
| 129 | + public Builder mchId(String mchId) { |
| 130 | + this.mchId = mchId; |
| 131 | + return this; |
| 132 | + } |
| 133 | + |
| 134 | + public Builder signType(String signType) { |
| 135 | + this.signType = signType; |
| 136 | + return this; |
| 137 | + } |
| 138 | + |
| 139 | + public Builder subAppId(String subAppId) { |
| 140 | + this.subAppId = subAppId; |
| 141 | + return this; |
| 142 | + } |
| 143 | + |
| 144 | + public Builder subMchId(String subMchId) { |
| 145 | + this.subMchId = subMchId; |
| 146 | + return this; |
| 147 | + } |
| 148 | + |
| 149 | + public Builder nonceStr(String nonceStr) { |
| 150 | + this.nonceStr = nonceStr; |
| 151 | + return this; |
| 152 | + } |
| 153 | + |
| 154 | + public Builder sign(String sign) { |
| 155 | + this.sign = sign; |
| 156 | + return this; |
| 157 | + } |
| 158 | + |
| 159 | + public WxPayOrderReverseRequest build() { |
| 160 | + return new WxPayOrderReverseRequest(this); |
| 161 | + } |
| 162 | + } |
| 163 | +} |
0 commit comments