View Javadoc
1   package com.foxinmy.weixin4j.payment.mch;
2   
3   import java.util.Date;
4   import java.util.List;
5   
6   import javax.xml.bind.annotation.XmlAccessType;
7   import javax.xml.bind.annotation.XmlAccessorType;
8   import javax.xml.bind.annotation.XmlElement;
9   import javax.xml.bind.annotation.XmlRootElement;
10  
11  import com.alibaba.fastjson.annotation.JSONField;
12  import com.foxinmy.weixin4j.payment.coupon.OrderCouponInfo;
13  import com.foxinmy.weixin4j.type.BankType;
14  import com.foxinmy.weixin4j.type.CurrencyType;
15  import com.foxinmy.weixin4j.type.TradeState;
16  import com.foxinmy.weixin4j.type.TradeType;
17  import com.foxinmy.weixin4j.util.DateUtil;
18  import com.foxinmy.weixin4j.xml.ListsuffixResult;
19  
20  /**
21   * 订单信息
22   * 
23   * @className Order
24   * @author jinyu(foxinmy@gmail.com)
25   * @date 2014年11月2日
26   * @since JDK 1.6
27   * @see
28   * @deprecated 迁移到子模块weixin4j-pay
29   */
30  @Deprecated
31  @XmlRootElement
32  @XmlAccessorType(XmlAccessType.FIELD)
33  public class Order extends MerchantTradeResult {
34  
35  	private static final long serialVersionUID = 5636828325595317079L;
36  	/**
37  	 * 交易状态
38  	 * 
39  	 * @see com.foxinmy.weixin4j.type.TradeState
40  	 */
41  	@XmlElement(name = "trade_state")
42  	@JSONField(name = "trade_state")
43  	private String tradeState;
44  	/**
45  	 * 用户的openid
46  	 */
47  	@XmlElement(name = "openid")
48  	@JSONField(name = "openid")
49  	private String openId;
50  	/**
51  	 * 用户是否关注公众账号,Y- 关注,N-未关注,仅在公众 账号类型支付有效
52  	 */
53  	@XmlElement(name = "is_subscribe")
54  	@JSONField(name = "is_subscribe")
55  	private String isSubscribe;
56  	/**
57  	 * 交易类型
58  	 * 
59  	 * @see com.foxinmy.weixin4j.type.TradeType
60  	 */
61  	@XmlElement(name = "trade_type")
62  	@JSONField(name = "trade_type")
63  	private String tradeType;
64  	/**
65  	 * 银行类型
66  	 */
67  	@XmlElement(name = "bank_type")
68  	@JSONField(name = "bank_type")
69  	private String bankType;
70  
71  	/**
72  	 * 现金支付货币类型,符合 ISO 4217 标准的三位字母代码,默认人民币:CNY
73  	 * 
74  	 * @see com.foxinmy.weixin4j.mp.type.CurrencyType
75  	 */
76  	@XmlElement(name = "cash_fee_type")
77  	@JSONField(name = "cash_fee_type")
78  	private String cashFeeType;
79  	/**
80  	 * 代金券金额:“代金券”金额<=订单金额,订单金额-“代金券”金额=现金支付金额
81  	 */
82  	@XmlElement(name = "coupon_fee")
83  	@JSONField(name = "coupon_fee")
84  	private Integer couponFee;
85  	/**
86  	 * 代金券或立减优惠使用数量
87  	 */
88  	@XmlElement(name = "coupon_count")
89  	@JSONField(name = "coupon_count")
90  	private Integer couponCount;
91  	/**
92  	 * 代金券信息 验证签名有点麻烦
93  	 */
94  	@ListsuffixResult
95  	private List<OrderCouponInfo> couponList;
96  	/**
97  	 * 商家数据包
98  	 */
99  	private String attach;
100 	/**
101 	 * 支付完成时间,格式为 yyyyMMddhhmmss
102 	 */
103 	@XmlElement(name = "time_end")
104 	@JSONField(name = "time_end")
105 	private String timeEnd;
106 	/**
107 	 * 交易状态描述
108 	 */
109 	@XmlElement(name = "trade_state_desc")
110 	@JSONField(name = "trade_state_desc")
111 	private String tradeStateDesc;
112 
113 	/**
114 	 * 用户在子商户下的openid
115 	 */
116 	@XmlElement(name = "sub_openid")
117 	@JSONField(name = "sub_openid")
118 	private String subOpenId;
119 	/**
120 	 * 是否关注子公众账号,Y- 关注,N-未关注,仅在公众 账号类型支付有效
121 	 */
122 	@XmlElement(name = "sub_is_subscribe")
123 	@JSONField(name = "sub_is_subscribe")
124 	private String subIsSubscribe;
125 
126 	protected Order() {
127 		// jaxb required
128 	}
129 
130 	@JSONField(serialize = false)
131 	public TradeState getFormatTradeState() {
132 		return tradeState != null ? TradeState
133 				.valueOf(tradeState.toUpperCase()) : null;
134 	}
135 
136 	public String getOpenId() {
137 		return openId;
138 	}
139 
140 	public String getIsSubscribe() {
141 		return isSubscribe;
142 	}
143 
144 	@JSONField(serialize = false)
145 	public boolean getFormatIsSubscribe() {
146 		return isSubscribe != null && isSubscribe.equalsIgnoreCase("y");
147 	}
148 
149 	@JSONField(serialize = false)
150 	public TradeType getFormatTradeType() {
151 		return tradeType != null ? TradeType.valueOf(tradeType.toUpperCase())
152 				: null;
153 	}
154 
155 	public String getBankType() {
156 		return bankType;
157 	}
158 
159 	@JSONField(serialize = false)
160 	public BankType getFormatBankType() {
161 		return bankType != null ? BankType.valueOf(bankType.toUpperCase())
162 				: null;
163 	}
164 
165 	public Integer getCouponFee() {
166 		return couponFee;
167 	}
168 
169 	/**
170 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
171 	 * 
172 	 * @return 元单位
173 	 */
174 	@JSONField(serialize = false)
175 	public double getFormatCouponFee() {
176 		return couponFee != null ? couponFee / 100d : 0d;
177 	}
178 
179 	public Integer getCouponCount() {
180 		return couponCount;
181 	}
182 
183 	public String getTradeState() {
184 		return tradeState;
185 	}
186 
187 	public String getTradeType() {
188 		return tradeType;
189 	}
190 
191 	public String getAttach() {
192 		return attach;
193 	}
194 
195 	public String getTimeEnd() {
196 		return timeEnd;
197 	}
198 
199 	@JSONField(serialize = false)
200 	public Date getFormatTimeEnd() {
201 		return timeEnd != null ? DateUtil.parse2yyyyMMddHHmmss(timeEnd) : null;
202 	}
203 
204 	public String getTradeStateDesc() {
205 		return tradeStateDesc;
206 	}
207 
208 	public List<OrderCouponInfo> getCouponList() {
209 		return couponList;
210 	}
211 
212 	public void setCouponList(List<OrderCouponInfo> couponList) {
213 		this.couponList = couponList;
214 	}
215 
216 	public String getSubOpenId() {
217 		return subOpenId;
218 	}
219 
220 	public String getSubIsSubscribe() {
221 		return subIsSubscribe;
222 	}
223 
224 	@JSONField(serialize = false)
225 	public boolean getFormatSubIsSubscribe() {
226 		return subIsSubscribe != null && subIsSubscribe.equalsIgnoreCase("y");
227 	}
228 
229 	public String getCashFeeType() {
230 		return cashFeeType;
231 	}
232 
233 	@JSONField(serialize = false)
234 	public CurrencyType getFormatCashFeeType() {
235 		return cashFeeType != null ? CurrencyType.valueOf(cashFeeType
236 				.toUpperCase()) : null;
237 	}
238 
239 	@Override
240 	public String toString() {
241 		return "Order [tradeState=" + tradeState + ", openId=" + openId
242 				+ ", isSubscribe=" + isSubscribe + ", tradeType=" + tradeType
243 				+ ", bankType=" + bankType + ", cashFeeType=" + cashFeeType
244 				+ ", couponFee=" + couponFee + ", couponCount=" + couponCount
245 				+ ", couponList=" + couponList + ", attach=" + attach
246 				+ ", timeEnd=" + timeEnd + ", tradeStateDesc=" + tradeStateDesc
247 				+ ", subOpenId=" + subOpenId + ", subIsSubscribe="
248 				+ subIsSubscribe + ", " + super.toString() + "]";
249 	}
250 }