View Javadoc
1   package com.foxinmy.weixin4j.model.card;
2   
3   import com.alibaba.fastjson.annotation.JSONField;
4   import com.foxinmy.weixin4j.type.card.CardType;
5   import com.foxinmy.weixin4j.util.DateUtil;
6   
7   /**
8    * 代金券
9    * 
10   * @className CashCoupon
11   * @author jinyu(foxinmy@gmail.com)
12   * @date 2016年8月4日
13   * @since JDK 1.6
14   */
15  public class CashCoupon extends CardCoupon {
16  	/**
17  	 * 起用金额(单位为分),如果无起用门槛则填0
18  	 */
19  	@JSONField(name = "least_cost")
20  	private int leastCost;
21  	/**
22  	 * 减免金额(单位为分)
23  	 */
24  	@JSONField(name = "reduce_cost")
25  	private final int reduceCost;
26  
27  	/**
28  	 * 构造代金券
29  	 * 
30  	 * @param couponBaseInfo
31  	 *            基础信息
32  	 * @param reduceCost
33  	 *            减免金额 单位元
34  	 */
35  	public CashCoupon(CouponBaseInfo couponBaseInfo, double reduceCost) {
36  		super(couponBaseInfo);
37  		this.reduceCost = DateUtil.formatYuan2Fen(reduceCost);
38  	}
39  
40  	public int getLeastCost() {
41  		return leastCost;
42  	}
43  
44  	/**
45  	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
46  	 * 
47  	 * @return 元单位
48  	 */
49  	@JSONField(serialize = false)
50  	public double getFormatLeastCost() {
51  		return leastCost / 100d;
52  	}
53  
54  	public void setLeastCost(double leastCost) {
55  		this.leastCost = DateUtil.formatYuan2Fen(reduceCost);
56  	}
57  
58  	public int getReduceCost() {
59  		return reduceCost;
60  	}
61  
62  	/**
63  	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
64  	 * 
65  	 * @return 元单位
66  	 */
67  	@JSONField(serialize = false)
68  	public double getFormatReduceCost() {
69  		return reduceCost / 100d;
70  	}
71  
72  	@JSONField(serialize = false)
73  	@Override
74  	public CardType getCardType() {
75  		return CardType.CASH;
76  	}
77  
78  	@Override
79  	public String toString() {
80  		return "CashCoupon [leastCost=" + leastCost + ", reduceCost="
81  				+ reduceCost + ", " + super.toString() + "]";
82  	}
83  }