1 package com.foxinmy.weixin4j.pay.payment.mch;
2
3 import com.alibaba.fastjson.annotation.JSONField;
4 import com.foxinmy.weixin4j.pay.type.mch.RedpacketSceneType;
5 import com.foxinmy.weixin4j.util.DateUtil;
6
7 import javax.xml.bind.annotation.XmlAccessType;
8 import javax.xml.bind.annotation.XmlAccessorType;
9 import javax.xml.bind.annotation.XmlElement;
10 import javax.xml.bind.annotation.XmlRootElement;
11
12
13
14
15
16
17
18
19
20
21
22
23
24 @XmlRootElement
25 @XmlAccessorType(XmlAccessType.FIELD)
26 public class Redpacket extends MerchantResult {
27
28 private static final long serialVersionUID = -7021352305575714281L;
29
30
31
32
33 @XmlElement(name = "mch_billno")
34 @JSONField(name = "mch_billno")
35 private String outTradeNo;
36
37
38
39 @XmlElement(name = "re_openid")
40 @JSONField(name = "re_openid")
41 private String openId;
42
43
44
45 @XmlElement(name = "send_name")
46 @JSONField(name = "send_name")
47 private String sendName;
48
49
50
51 @XmlElement(name = "total_amount")
52 @JSONField(name = "total_amount")
53 private int totalAmount;
54
55
56
57 @XmlElement(name = "total_num")
58 @JSONField(name = "total_num")
59 private int totalNum;
60
61
62
63 @XmlElement(name = "amt_type")
64 @JSONField(name = "amt_type")
65 private String amtType;
66
67
68
69 private String wishing;
70
71
72
73 @XmlElement(name = "client_ip")
74 @JSONField(name = "client_ip")
75 private String clientIp;
76
77
78
79 @XmlElement(name = "act_name")
80 @JSONField(name = "act_name")
81 private String actName;
82
83
84
85 private String remark;
86
87
88
89
90
91 @XmlElement(name = "msgappid")
92 @JSONField(name = "msgappid")
93 private String msgAppId;
94
95
96
97 @XmlElement(name = "consume_mch_id")
98 @JSONField(name = "consume_mch_id")
99 private String consumeMchId;
100
101
102
103 @XmlElement(name = "scene_id")
104 @JSONField(name = "scene_id")
105 private RedpacketSceneType sceneType;
106
107
108
109 @XmlElement(name = "risk_info")
110 @JSONField(name = "risk_info")
111 private String risk;
112
113 protected Redpacket() {
114
115 }
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139 public Redpacket(String outTradeNo, String openId, String sendName,
140 double totalAmount, int totalNum, String wishing, String clientIp,
141 String actName, String remark) {
142 this.outTradeNo = outTradeNo;
143 this.openId = openId;
144 this.sendName = sendName;
145 this.totalAmount = DateUtil.formatYuan2Fen(totalAmount);
146 this.totalNum = totalNum;
147 this.wishing = wishing;
148 this.clientIp = clientIp;
149 this.actName = actName;
150 this.remark = remark;
151 this.amtType = totalNum > 1 ? "ALL_RAND" : null;
152 }
153
154
155
156
157
158
159
160
161
162
163 public Redpacket copy(String outTradeNo, String openId) {
164 Redpacket readpacket = new Redpacket(outTradeNo, openId, sendName,
165 totalAmount, totalNum, wishing, clientIp, actName, remark);
166 readpacket.setMsgAppId(msgAppId);
167 readpacket.setConsumeMchId(consumeMchId);
168 readpacket.setSceneType(sceneType);
169 readpacket.setRisk(risk);
170 return readpacket;
171 }
172
173 public String getOutTradeNo() {
174 return outTradeNo;
175 }
176
177 public void setOutTradeNo(String outTradeNo) {
178 this.outTradeNo = outTradeNo;
179 }
180
181 public String getOpenId() {
182 return openId;
183 }
184
185 public void setOpenId(String openId) {
186 this.openId = openId;
187 }
188
189 public String getSendName() {
190 return sendName;
191 }
192
193 public void setSendName(String sendName) {
194 this.sendName = sendName;
195 }
196
197 public int getTotalAmount() {
198 return totalAmount;
199 }
200
201 public void setTotalAmount(int totalAmount) {
202 this.totalAmount = totalAmount;
203 }
204
205
206
207
208
209
210 @JSONField(serialize = false)
211 public double getFormatTotalAmount() {
212 return totalAmount / 100d;
213 }
214
215 public int getTotalNum() {
216 return totalNum;
217 }
218
219 public void setTotalNum(int totalNum) {
220 this.totalNum = totalNum;
221 }
222
223 public String getWishing() {
224 return wishing;
225 }
226
227 public void setWishing(String wishing) {
228 this.wishing = wishing;
229 }
230
231 public String getAmtType() {
232 return amtType;
233 }
234
235 public void setAmtType(String amtType) {
236 this.amtType = amtType;
237 }
238
239 public String getClientIp() {
240 return clientIp;
241 }
242
243 public void setClientIp(String clientIp) {
244 this.clientIp = clientIp;
245 }
246
247 public String getActName() {
248 return actName;
249 }
250
251 public void setActName(String actName) {
252 this.actName = actName;
253 }
254
255 public String getRemark() {
256 return remark;
257 }
258
259 public void setRemark(String remark) {
260 this.remark = remark;
261 }
262
263 public String getMsgAppId() {
264 return msgAppId;
265 }
266
267 public void setMsgAppId(String msgAppId) {
268 this.msgAppId = msgAppId;
269 }
270
271 public String getConsumeMchId() {
272 return consumeMchId;
273 }
274
275 public void setConsumeMchId(String consumeMchId) {
276 this.consumeMchId = consumeMchId;
277 }
278
279 public RedpacketSceneType getSceneType() {
280 return sceneType;
281 }
282
283 public void setSceneType(RedpacketSceneType sceneType) {
284 this.sceneType = sceneType;
285 }
286
287 public String getRisk() {
288 return risk;
289 }
290
291 public void setRisk(String risk) {
292 this.risk = risk;
293 }
294
295 public void setRisk(RedpacketRisk risk) {
296 this.risk = risk.toContent();
297 }
298
299 @Override
300 public String toString() {
301 return "Redpacket [outTradeNo=" + outTradeNo + ", openId=" + openId
302 + ", sendName=" + sendName + ", totalAmount=" + totalAmount
303 + ", totalNum=" + totalNum + ", amtType=" + amtType
304 + ", wishing=" + wishing + ", clientIp=" + clientIp
305 + ", actName=" + actName + ", remark=" + remark + ", msgAppId="
306 + msgAppId + ", consumeMchId=" + consumeMchId + ", sceneType="
307 + sceneType + ", risk=" + risk + ", " + super.toString() + "]";
308 }
309 }