View Javadoc
1   package com.foxinmy.weixin4j.model.card;
2   
3   /**
4    * 卡券构造器
5    *
6    * @className CardCoupons
7    * @author jinyu(foxinmy@gmail.com)
8    * @date 2016年6月1日
9    * @since JDK 1.6
10   * @see CashCoupon
11   * @see DiscountCoupon
12   * @see GeneralCoupon
13   * @see GiftCoupon
14   * @see GrouponCoupon
15   */
16  public final class CardCoupons {
17  	private CardCoupons() {
18  	}
19  
20  	/**
21  	 * 卡券基础信息构造器
22  	 * 
23  	 * @return
24  	 */
25  	public static CouponBaseInfo.Builder customBase() {
26  		return new CouponBaseInfo.Builder();
27  	}
28  
29  	/**
30  	 * 卡券高级信息构造器
31  	 * 
32  	 * @return
33  	 */
34  	public static CouponAdvanceInfo.Builder customAdvance() {
35  		return new CouponAdvanceInfo.Builder();
36  	}
37  
38  	public static MemberCard.Builder customMemberCard(){
39  		return  new MemberCard.Builder();
40  	}
41  
42  	/**
43  	 * 礼品卡信息构造器
44  	 *
45  	 * @return
46  	 */
47  	public static GiftCard.Builder customGiftCard() {
48  		return new GiftCard.Builder();
49  	}
50  
51  	/**
52  	 * 礼品卡货架主题信息构造器
53  	 *
54  	 * @return
55  	 */
56  	public static PageTheme.Builder customCardPageTheme(){ return new PageTheme.Builder(); }
57  
58  	/**
59  	 * 礼品卡货架信息构造器
60  	 *
61  	 * @return
62  	 */
63  	public static GiftCardPage.Builder customCardPage(){ return new GiftCardPage.Builder(); }
64  
65  	/**
66  	 * 创建代金券
67  	 * 
68  	 * @param builder
69  	 *            卡券基础信息构造器 必填
70  	 * @param reduceCost
71  	 *            减免金额 (单位为元) 必填
72  	 * @param leastCost
73  	 *            起用金额(单位为元),如果无起用门槛则填0
74  	 */
75  	public static CardCoupon createCashCoupon(CouponBaseInfo.Builder builder,
76  			double reduceCost, double leastCost) {
77  		CouponBaseInfo couponBaseInfo = builder.build();
78  		CashCoupon coupon = new CashCoupon(couponBaseInfo, reduceCost);
79  		coupon.setLeastCost(leastCost);
80  		return coupon;
81  	}
82  
83  	/**
84  	 * 创建折扣券
85  	 * 
86  	 * @param builder
87  	 *            卡券基础信息构造器 必填
88  	 * @param discount
89  	 *            打折额度百分百,如:传入30就是七折 必填
90  	 */
91  	public static CardCoupon createDiscountCoupon(
92  			CouponBaseInfo.Builder builder, int discount) {
93  		CouponBaseInfo couponBaseInfo = builder.build();
94  		DiscountCoupon coupon = new DiscountCoupon(couponBaseInfo, discount);
95  		return coupon;
96  	}
97  
98  	/**
99  	 * 创建普通优惠券
100 	 * 
101 	 * @param builder
102 	 *            卡券基础信息构造器 必填
103 	 * @param explain
104 	 *            优惠详情 如:音乐木盒 必填
105 	 */
106 	public static CardCoupon createGeneralCoupon(
107 			CouponBaseInfo.Builder builder, String explain) {
108 		CouponBaseInfo couponBaseInfo = builder.build();
109 		GeneralCoupon coupon = new GeneralCoupon(couponBaseInfo, explain);
110 		return coupon;
111 	}
112 
113 	/**
114 	 * 创建普通优惠券
115 	 * 
116 	 * @param builder
117 	 *            卡券基础信息构造器 必填
118 	 * @param explain
119 	 *            兑换说明 如:可兑换音乐木盒一个 必填
120 	 */
121 	public static CardCoupon createGiftCoupon(CouponBaseInfo.Builder builder,
122 			String explain) {
123 		CouponBaseInfo couponBaseInfo = builder.build();
124 		GiftCoupon coupon = new GiftCoupon(couponBaseInfo, explain);
125 		return coupon;
126 	}
127 
128 	/**
129 	 * 创建团购券
130 	 * 
131 	 * @param builder
132 	 *            卡券基础信息构造器 必填
133 	 * @param explain
134 	 *            团购详情 如:双人套餐\n -进口红酒一支。\n孜然牛肉一份 必填
135 	 */
136 	public static CardCoupon createGrouponCoupon(
137 			CouponBaseInfo.Builder builder, String explain) {
138 		CouponBaseInfo couponBaseInfo = builder.build();
139 		GrouponCoupon coupon = new GrouponCoupon(couponBaseInfo, explain);
140 		return coupon;
141 	}
142 
143 
144 	public static MemberCard createMemberCard(CouponBaseInfo.Builder baseBuilder, MemberCard.Builder memberCardBudiler) {
145 		baseBuilder.build();
146 		MemberCard memberCard = new MemberCard(baseBuilder.build(), memberCardBudiler);
147 		return memberCard;
148 	}
149 
150 	/**
151 	 * 创建单品类礼品卡
152 	 *
153 	 * @param baseBuilder
154 	 *              卡券基础信息构造器 必填
155 	 * @param giftCardBuilder
156 	 *              礼品卡自身参数构造器 必填
157 	 * @return
158 	 */
159 	public static VoucherCard createVoucherCard(CouponBaseInfo.Builder baseBuilder, GiftCard.Builder giftCardBuilder){
160 		baseBuilder.build();
161 		VoucherCard voucherCard = new VoucherCard(baseBuilder.build(), giftCardBuilder);
162 		return voucherCard;
163 	}
164 
165 	/**
166 	 * 创建储值类礼品卡
167 	 *
168 	 * @param baseBuilder
169 	 * @param giftCardBuilder
170 	 * @return
171 	 */
172 	public static GiftCard createGiftCard(CouponBaseInfo.Builder baseBuilder, GiftCard.Builder giftCardBuilder){
173 		baseBuilder.build();
174 		GiftCard giftCard = new GiftCard(baseBuilder.build(), giftCardBuilder);
175 		return giftCard;
176 	}
177 }