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