View Javadoc
1   package com.foxinmy.weixin4j.pay.payment.mch;
2   
3   import com.alibaba.fastjson.annotation.JSONField;
4   import com.foxinmy.weixin4j.http.weixin.XmlResult;
5   import com.foxinmy.weixin4j.pay.type.mch.RedpacketSendType;
6   import com.foxinmy.weixin4j.pay.type.mch.RedpacketStatus;
7   import com.foxinmy.weixin4j.pay.type.mch.RedpacketType;
8   import com.foxinmy.weixin4j.util.DateUtil;
9   
10  import javax.xml.bind.annotation.*;
11  import java.io.Serializable;
12  import java.util.Date;
13  import java.util.List;
14  
15  /**
16   * 红包记录
17   *
18   * @className RedpacketRecord
19   * @author jinyu(foxinmy@gmail.com)
20   * @date 2015年6月4日
21   * @since JDK 1.6
22   * @see
23   */
24  @XmlRootElement
25  @XmlAccessorType(XmlAccessType.FIELD)
26  public class RedpacketRecord extends XmlResult {
27  
28  	private static final long serialVersionUID = 929959747323918458L;
29  
30  	/**
31  	 * 商户订单号(每个订单号必须唯一) 组成: mch_id+yyyymmdd+10位一天内不能重复的数字。
32  	 */
33  	@XmlElement(name = "mch_billno")
34  	@JSONField(name = "mch_billno")
35  	private String outTradeNo;
36  	/**
37  	 * 微信支付分配的商户号
38  	 */
39  	@XmlElement(name = "mch_id")
40  	@JSONField(name = "mch_id")
41  	private String mchId;
42  	/**
43  	 * 红包单号
44  	 */
45  	@XmlElement(name = "detail_id")
46  	@JSONField(name = "detail_id")
47  	private String repacketId;
48  	/**
49  	 * 红包状态
50  	 */
51  	@XmlElement(name = "status")
52  	private String status;
53  	/**
54  	 * 发放类型
55  	 */
56  	@XmlElement(name = "send_type")
57  	@JSONField(name = "send_type")
58  	private String sendType;
59  	/**
60  	 * 红包类型
61  	 */
62  	@XmlElement(name = "hb_type")
63  	@JSONField(name = "hb_type")
64  	private String hbType;
65  	/**
66  	 * 红包个数
67  	 */
68  	@XmlElement(name = "total_num")
69  	@JSONField(name = "total_num")
70  	private int totalNum;
71  	/**
72  	 * 红包总金额(单位分)
73  	 */
74  	@XmlElement(name = "total_amount")
75  	@JSONField(name = "total_amount")
76  	private int totalAmount;
77  	/**
78  	 * 发送失败原因
79  	 */
80  	@XmlElement(name = "reason")
81  	private String reason;
82  	/**
83  	 * 发放时间
84  	 */
85  	@XmlElement(name = "send_time")
86  	@JSONField(name = "send_time")
87  	private String sendTime;
88  	/**
89  	 * 红包退款时间
90  	 */
91  	@XmlElement(name = "refund_time")
92  	@JSONField(name = "refund_time")
93  	private String refundTime;
94  	/**
95  	 * 红包退款金额
96  	 */
97  	@XmlElement(name = "refund_amount")
98  	@JSONField(name = "refund_amount")
99  	private Integer refundAmount;
100 	/**
101 	 * 祝福语
102 	 */
103 	@XmlElement(name = "wishing")
104 	private String wishing;
105 	/**
106 	 * 活动描述
107 	 */
108 	@XmlElement(name = "remark")
109 	private String remark;
110 	/**
111 	 * 活动名称
112 	 */
113 	@XmlElement(name = "act_name")
114 	@JSONField(name = "act_name")
115 	private String actName;
116 	/**
117 	 * 裂变红包领取列表
118 	 */
119 	@XmlElement(name = "hbinfo")
120 	@XmlElementWrapper(name = "hblist")
121 	@JSONField(name = "hblist")
122 	private List<RedpacketReceiver> receivers;
123 
124 	public String getOutTradeNo() {
125 		return outTradeNo;
126 	}
127 
128 	public String getMchId() {
129 		return mchId;
130 	}
131 
132 	public String getRepacketId() {
133 		return repacketId;
134 	}
135 
136 	@JSONField(serialize = false)
137 	public RedpacketStatus getFormatStatus() {
138 		return status != null ? RedpacketStatus.valueOf(status.toUpperCase())
139 				: null;
140 	}
141 
142 	@JSONField(serialize = false)
143 	public RedpacketSendType getFormatSendType() {
144 		return sendType != null ? RedpacketSendType.valueOf(sendType) : null;
145 	}
146 
147 	@JSONField(serialize = false)
148 	public RedpacketType getFomatHbType() {
149 		return hbType != null ? RedpacketType.valueOf(hbType) : null;
150 	}
151 
152 	public String getStatus() {
153 		return status;
154 	}
155 
156 	public String getSendType() {
157 		return sendType;
158 	}
159 
160 	public String getHbType() {
161 		return hbType;
162 	}
163 
164 	public int getTotalNum() {
165 		return totalNum;
166 	}
167 
168 	public int getTotalAmount() {
169 		return totalAmount;
170 	}
171 
172 	/**
173 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
174 	 *
175 	 * @return 元单位
176 	 */
177 	@JSONField(serialize = false)
178 	public double getFormatTotalAmount() {
179 		return totalAmount / 100d;
180 	}
181 
182 	public String getReason() {
183 		return reason;
184 	}
185 
186 	public String getSendTime() {
187 		return sendTime;
188 	}
189 
190 	@JSONField(serialize = false)
191 	public Date getFormatSendTime() {
192 		return sendTime != null ? DateUtil.parse2yyyyMMddHHmmss(sendTime)
193 				: null;
194 	}
195 
196 	public String getRefundTime() {
197 		return refundTime;
198 	}
199 
200 	@JSONField(serialize = false)
201 	public Date getFormatRefundTime() {
202 		return refundTime != null ? DateUtil.parse2yyyyMMddHHmmss(refundTime)
203 				: null;
204 	}
205 
206 	public Integer getRefundAmount() {
207 		return refundAmount;
208 	}
209 
210 	/**
211 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
212 	 *
213 	 * @return 元单位
214 	 */
215 	@JSONField(serialize = false)
216 	public double getFormatRefundAmount() {
217 		return refundAmount != null ? refundAmount.intValue() / 100d : 0d;
218 	}
219 
220 	public String getWishing() {
221 		return wishing;
222 	}
223 
224 	public String getRemark() {
225 		return remark;
226 	}
227 
228 	public String getActName() {
229 		return actName;
230 	}
231 
232 	public List<RedpacketReceiver> getReceivers() {
233 		return receivers;
234 	}
235 
236 	@XmlRootElement
237 	@XmlAccessorType(XmlAccessType.FIELD)
238 	public static class RedpacketReceiver implements Serializable {
239 
240 		private static final long serialVersionUID = 1L;
241 
242 		/**
243 		 * 领取红包的Openid
244 		 */
245 		@XmlElement(name = "openid")
246 		private String openId;
247 		/**
248 		 * 领取状态
249 		 */
250 		@XmlElement(name = "status")
251 		private RedpacketStatus status;
252 		/**
253 		 * 领取金额
254 		 */
255 		private int amount;
256 		/**
257 		 * 领取时间
258 		 */
259 		@XmlElement(name = "rcv_time")
260 		@JSONField(name = "rcv_time")
261 		private String receiveTime;
262 
263 		public String getOpenId() {
264 			return openId;
265 		}
266 
267 		public RedpacketStatus getStatus() {
268 			return status;
269 		}
270 
271 		public int getAmount() {
272 			return amount;
273 		}
274 
275 		public String getReceiveTime() {
276 			return receiveTime;
277 		}
278 
279 		/**
280 		 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
281 		 *
282 		 * @return 元单位
283 		 */
284 		@JSONField(serialize = false)
285 		public double getFormatAmount() {
286 			return amount / 100d;
287 		}
288 
289 		@JSONField(serialize = false)
290 		public Date getFormatReceiveTime() {
291 			return receiveTime != null ? DateUtil
292 					.parse2yyyyMMddHHmmss(receiveTime) : null;
293 		}
294 
295 		@Override
296 		public String toString() {
297 			return "RedpacketReceiver [openId=" + openId + ", status=" + status
298 					+ ", amount=" + getFormatAmount() + ", receiveTime="
299 					+ receiveTime + "]";
300 		}
301 	}
302 
303 	@Override
304 	public String toString() {
305 		return "RedpacketRecord [outTradeNo=" + outTradeNo + ", mchId=" + mchId
306 				+ ", repacketId=" + repacketId + ", status=" + status
307 				+ ", sendType=" + sendType + ", hbType=" + hbType
308 				+ ", totalNum=" + totalNum + ", totalAmount="
309 				+ getFormatTotalAmount() + ", reason=" + reason + ", sendTime="
310 				+ sendTime + ", refundTime=" + refundTime + ", refundAmount="
311 				+ getFormatRefundAmount() + ", wishing=" + wishing
312 				+ ", remark=" + remark + ", actName=" + actName
313 				+ ", receivers=" + receivers + "]";
314 	}
315 }