Skip to content

Commit c8c51a9

Browse files
committed
#178 实现发送代金券接口
1 parent 3a2efdd commit c8c51a9

File tree

6 files changed

+589
-44
lines changed

6 files changed

+589
-44
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,311 @@
1+
package com.github.binarywang.wxpay.bean.coupon;
2+
3+
import com.github.binarywang.wxpay.bean.request.WxPayBaseRequest;
4+
import com.thoughtworks.xstream.annotations.XStreamAlias;
5+
import me.chanjar.weixin.common.annotation.Required;
6+
7+
/**
8+
* <pre>
9+
* 发送代金券请求对象类
10+
* Created by Binary Wang on 2017-7-15.
11+
* </pre>
12+
*
13+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
14+
*/
15+
@XStreamAlias("xml")
16+
public class WxPayCouponSendRequest extends WxPayBaseRequest {
17+
/**
18+
* <pre>
19+
* 字段名:代金券批次id
20+
* 变量名:coupon_stock_id
21+
* 是否必填:是
22+
* 示例值:1757
23+
* 类型:String
24+
* 说明:代金券批次id
25+
* </pre>
26+
*/
27+
@Required
28+
@XStreamAlias("coupon_stock_id")
29+
private String couponStockId;
30+
31+
/**
32+
* <pre>
33+
* 字段名:openid记录数
34+
* 变量名:openid_count
35+
* 是否必填:是
36+
* 示例值:1
37+
* 类型:int
38+
* 说明:openid记录数(目前支持num=1)
39+
* </pre>
40+
*/
41+
@Required
42+
@XStreamAlias("openid_count")
43+
private Integer openidCount;
44+
45+
/**
46+
* <pre>
47+
* 字段名:商户单据号
48+
* 变量名:partner_trade_no
49+
* 是否必填:是
50+
* 示例值:1000009820141203515766
51+
* 类型:String
52+
* 说明:商户此次发放凭据号(格式:商户id+日期+流水号),商户侧需保持唯一性
53+
* </pre>
54+
*/
55+
@Required
56+
@XStreamAlias("partner_trade_no")
57+
private String partnerTradeNo;
58+
59+
/**
60+
* <pre>
61+
* 字段名:用户openid
62+
* 变量名:openid
63+
* 是否必填:是
64+
* 示例值:onqOjjrXT-776SpHnfexGm1_P7iE
65+
* 类型:String
66+
* 说明:Openid信息,用户在appid下的openid。
67+
* </pre>
68+
*/
69+
@Required
70+
@XStreamAlias("openid")
71+
private String openid;
72+
73+
/**
74+
* <pre>
75+
* 字段名:操作员
76+
* 变量名:op_user_id
77+
* 是否必填:否
78+
* 示例值:10000098
79+
* 类型:String(32)
80+
* 说明:操作员帐号, 默认为商户号,可在商户平台配置操作员对应的api权限
81+
* </pre>
82+
*/
83+
@XStreamAlias("op_user_id")
84+
private String opUserId;
85+
86+
/**
87+
* <pre>
88+
* 字段名:设备号
89+
* 变量名:device_info
90+
* 是否必填:否
91+
* 示例值:
92+
* 类型:String(32)
93+
* 说明:微信支付分配的终端设备号
94+
* </pre>
95+
*/
96+
@XStreamAlias("device_info")
97+
private String deviceInfo;
98+
99+
/**
100+
* <pre>
101+
* 字段名:协议版本
102+
* 变量名:version
103+
* 是否必填:否
104+
* 示例值:1.0
105+
* 类型:String(32)
106+
* 说明:默认1.0
107+
* </pre>
108+
*/
109+
@XStreamAlias("version")
110+
private String version;
111+
112+
/**
113+
* <pre>
114+
* 字段名:协议类型
115+
* 变量名:type
116+
* 是否必填:否
117+
* 示例值:XML
118+
* 类型:String(32)
119+
* 说明:XML【目前仅支持默认XML】
120+
* </pre>
121+
*/
122+
@XStreamAlias("type")
123+
private String type;
124+
125+
public WxPayCouponSendRequest() {
126+
}
127+
128+
private WxPayCouponSendRequest(Builder builder) {
129+
setAppid(builder.appid);
130+
setMchId(builder.mchId);
131+
setSubAppId(builder.subAppId);
132+
setSubMchId(builder.subMchId);
133+
setNonceStr(builder.nonceStr);
134+
setSign(builder.sign);
135+
setCouponStockId(builder.couponStockId);
136+
setOpenidCount(builder.openidCount);
137+
setPartnerTradeNo(builder.partnerTradeNo);
138+
setOpenid(builder.openid);
139+
setOpUserId(builder.opUserId);
140+
setDeviceInfo(builder.deviceInfo);
141+
setVersion(builder.version);
142+
setType(builder.type);
143+
}
144+
145+
public static Builder newBuilder() {
146+
return new Builder();
147+
}
148+
149+
public String getCouponStockId() {
150+
return this.couponStockId;
151+
}
152+
153+
public void setCouponStockId(String couponStockId) {
154+
this.couponStockId = couponStockId;
155+
}
156+
157+
public Integer getOpenidCount() {
158+
return this.openidCount;
159+
}
160+
161+
public void setOpenidCount(Integer openidCount) {
162+
this.openidCount = openidCount;
163+
}
164+
165+
public String getPartnerTradeNo() {
166+
return this.partnerTradeNo;
167+
}
168+
169+
public void setPartnerTradeNo(String partnerTradeNo) {
170+
this.partnerTradeNo = partnerTradeNo;
171+
}
172+
173+
public String getOpenid() {
174+
return this.openid;
175+
}
176+
177+
public void setOpenid(String openid) {
178+
this.openid = openid;
179+
}
180+
181+
public String getOpUserId() {
182+
return this.opUserId;
183+
}
184+
185+
public void setOpUserId(String opUserId) {
186+
this.opUserId = opUserId;
187+
}
188+
189+
public String getDeviceInfo() {
190+
return this.deviceInfo;
191+
}
192+
193+
public void setDeviceInfo(String deviceInfo) {
194+
this.deviceInfo = deviceInfo;
195+
}
196+
197+
public String getVersion() {
198+
return this.version;
199+
}
200+
201+
public void setVersion(String version) {
202+
this.version = version;
203+
}
204+
205+
public String getType() {
206+
return this.type;
207+
}
208+
209+
public void setType(String type) {
210+
this.type = type;
211+
}
212+
213+
@Override
214+
protected void checkConstraints() {
215+
//do nothing
216+
}
217+
218+
public static final class Builder {
219+
private String appid;
220+
private String mchId;
221+
private String subAppId;
222+
private String subMchId;
223+
private String nonceStr;
224+
private String sign;
225+
private String couponStockId;
226+
private Integer openidCount;
227+
private String partnerTradeNo;
228+
private String openid;
229+
private String opUserId;
230+
private String deviceInfo;
231+
private String version;
232+
private String type;
233+
234+
private Builder() {
235+
}
236+
237+
public Builder appid(String appid) {
238+
this.appid = appid;
239+
return this;
240+
}
241+
242+
public Builder mchId(String mchId) {
243+
this.mchId = mchId;
244+
return this;
245+
}
246+
247+
public Builder subAppId(String subAppId) {
248+
this.subAppId = subAppId;
249+
return this;
250+
}
251+
252+
public Builder subMchId(String subMchId) {
253+
this.subMchId = subMchId;
254+
return this;
255+
}
256+
257+
public Builder nonceStr(String nonceStr) {
258+
this.nonceStr = nonceStr;
259+
return this;
260+
}
261+
262+
public Builder sign(String sign) {
263+
this.sign = sign;
264+
return this;
265+
}
266+
267+
public Builder couponStockId(String couponStockId) {
268+
this.couponStockId = couponStockId;
269+
return this;
270+
}
271+
272+
public Builder openidCount(Integer openidCount) {
273+
this.openidCount = openidCount;
274+
return this;
275+
}
276+
277+
public Builder partnerTradeNo(String partnerTradeNo) {
278+
this.partnerTradeNo = partnerTradeNo;
279+
return this;
280+
}
281+
282+
public Builder openid(String openid) {
283+
this.openid = openid;
284+
return this;
285+
}
286+
287+
public Builder opUserId(String opUserId) {
288+
this.opUserId = opUserId;
289+
return this;
290+
}
291+
292+
public Builder deviceInfo(String deviceInfo) {
293+
this.deviceInfo = deviceInfo;
294+
return this;
295+
}
296+
297+
public Builder version(String version) {
298+
this.version = version;
299+
return this;
300+
}
301+
302+
public Builder type(String type) {
303+
this.type = type;
304+
return this;
305+
}
306+
307+
public WxPayCouponSendRequest build() {
308+
return new WxPayCouponSendRequest(this);
309+
}
310+
}
311+
}

0 commit comments

Comments
 (0)