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