卡券類字段

卡券字段極其複雜繁多,爲了好管理和分類,基於5個基礎卡券種類:通用,折扣,團購,代金,禮品券。json

定義了3張表和N個枚舉類,若要方便調用枚舉字段,.net枚舉已有舉例能夠查閱。微信

先貼3張基礎字段ide

 1     [TableDisplay("卡券")]
 2     public class wxCard:Base
 3     {
 4         [Display(Name = "卡券惟一編號")]
 5         public String CardId { get; set; }
 6         [Display(Name = "卡券種類")]
 7         public CardType cardType { get; set; }
 8         [Display(Name = "卡券特殊字段")]
 9         public String CardField { get; set; }
10     }
View Code
 1     [TableDisplay("卡券基本信息")]
 2     public class wxCardBaseInfo : Base
 3     {
 4         [Display(Name = "卡券編號")]
 5         public Int32 WxCardId { get; set; }
 6         [Display(Name = "卡券")]
 7         [ForeignKey("WxCardId")]
 8         public virtual wxCard WxCard { get; set; }
 9         [Display(Name = "卡券的商戶logoId")]
10         public String logo_url { get; set; }
11         [Display(Name = "CodeType展現類型")]
12         public String code_type { get; set; }
13         [Display(Name = "商戶名字")]
14         public String brand_name { get; set; }
15         [Display(Name = "券名")]
16         public String title { get; set; }
17         [Display(Name = "券名的副標題")]
18         public String sub_title { get; set; }
19         [Display(Name = "券顏色")]
20         public String color { get; set; }
21         [Display(Name = "使用提醒")]
22         public String notice { get; set; }
23         [Display(Name = "客服電話")]
24         public String service_phone { get; set; }
25         [Display(Name = "第三方來源名")]
26         public String source { get; set; }
27         [Display(Name = "使用說明")]
28         public String description { get; set; }
29         [Display(Name = "每人最大領取次數")]
30         public int get_limit { get; set; }
31         [Display(Name = "自定義code碼")]
32         public bool use_custom_code { get; set; }
33         [Display(Name = "指定用戶領取")]
34         public bool bind_openid { get; set; }
35         [Display(Name = "是否可分享")]
36         public bool can_share { get; set; }
37         [Display(Name = "是否可轉贈")]
38         public bool can_give_friend { get; set; }
39         [Display(Name = "門店位置ID")]
40         public List<String> location_id_list { get; set; }
41         [Display(Name = "使用日期,有效期的信息")]
42         public Card_BaseInfo_DateInfo date_info { get; set; }
43         [Display(Name = "商品信息")]
44         public Card_BaseInfo_Sku sku { get; set; }
45         [Display(Name = "商戶自定義cell名稱")]
46         public String url_name_type { get; set; }
47         [Display(Name = "商戶自定義url 地址")]
48         public String custom_url { get; set; }
49         [Display(Name = "自定義跳轉外鏈的入口名字")]
50         public String custom_url_name { get; set; }
51         [Display(Name = "顯示在入口右側的提示語")]
52         public String custom_url_sub_title { get; set; }
53         [Display(Name = "營銷場景的自定義入口名稱")]
54         public String promotion_url_name { get; set; }
55         [Display(Name = "入口跳轉外鏈的地址連接")]
56         public String promotion_url { get; set; }
57         [Display(Name = "顯示在營銷入口右側的提示語")]
58         public String promotion_url_sub_title { get; set; }
View Code
基本字段擴展
 1     /// <summary>
 2     /// 使用日期,有效期的信息
 3     /// </summary>
 4     public class Card_BaseInfo_DateInfo
 5     {
 6         /// <summary>
 7         /// 使用時間的類型 1:固定日期區間,2:固定時長(自領取後按天算)
 8         /// 必填
 9         /// </summary>
10         public string type { get; set; }
11         /// <summary>
12         /// 固定日期區間專用,表示起用時間。從1970 年1 月1 日00:00:00 至起用時間的秒數,最終需轉換爲字符串形態傳入,下同。(單位爲秒)
13         /// 必填
14         /// </summary>
15         public string begin_timestamp { get; set; }
16         /// <summary>
17         /// 固定日期區間專用,表示結束時間。(單位爲秒)
18         /// 必填
19         /// </summary>
20         public string end_timestamp { get; set; }
21         /// <summary>
22         /// 固定時長專用,表示自領取後多少天內有效。(單位爲天)
23         /// 必填
24         /// </summary>
25         public int? fixed_term { get; set; }
26         /// <summary>
27         /// 固定時長專用,表示自領取後多少天開始生效。(單位爲天)
28         /// 必填
29         /// </summary>
30         public int? fixed_begin_term { get; set; }
31     }
32 
33     /// <summary>
34     /// 商品信息
35     /// </summary>
36     public class Card_BaseInfo_Sku
37     {
38         /// <summary>
39         /// 上架的數量。(不支持填寫0或無限大)
40         /// 必填
41         /// </summary>
42         public int quantity { get; set; }
43     }
44 
45     public class Card_CodeBaseInfoBase : Card_BaseInfoBase
46     {
47         public string get_custom_code_mode
48         {
49             get { return "GET_CUSTOM_CODE_MODE_DEPOSIT"; }
50         }
51     }
View Code
    [TableDisplay("卡券code編號")]
    public class wxCardCodeList:Base
    {
        [Display(Name = "卡券編號")]
        public Int32 WxCardId { get; set; }
        [Display(Name = "卡券")]
        [ForeignKey("WxCardId")]
        public virtual wxCard WxCard { get; set; }
        [Display(Name = "卡券編號")]
        public String CodeNum { get; set; }
        [Display(Name = "單張描述")]
        public String Description { get; set; }
        [Display(Name = "微信導入")]
        public Boolean WxPlay { get; set; }
        [Display(Name = "本地導入")]
        public Boolean DisPlay { get; set; }
        [Display(Name = "是否已覈銷")]
        public Boolean Vilid { get; set; }
    }
View Code

一下列舉卡券所用的枚舉函數

  1     /// <summary>
  2     /// 卡券使用時間的類型
  3     /// </summary>
  4     public enum Card_DateInfo_Type
  5     {
  6         [Description("固定日期區間")]
  7         DATE_TYPE_FIX_TIME_RANGE = 0,
  8         [Description("固定時長(自領取後按天算)")]
  9         DATE_TYPE_FIX_TERM = 1,
 10         [Description("永久有效")]
 11         DATE_TYPE_PERMANENT = 2
 12     }
 13     /// <summary>
 14     /// 卡券種類
 15     /// </summary>
 16     public enum CardType
 17     {
 18         [Description("通用券")]
 19         GENERAL_COUPON = 0,
 20         [Description("團購券")]
 21         GROUPON = 1,
 22         [Description("折扣券")]
 23         DISCOUNT = 2,
 24         [Description("禮品券")]
 25         GIFT = 3,
 26         [Description("代金券")]
 27         CASH = 4,
 28         [Description("會員卡")]
 29         MEMBER_CARD = 5,
 30         [Description("門票")]
 31         SCENIC_TICKET = 6,
 32         [Description("電影票")]
 33         MOVIE_TICKET = 7,
 34         [Description("飛機票")]
 35         BOARDING_PASS = 8,
 36         [Description("紅包")]
 37         LUCKY_MONEY = 9,
 38         [Description("會議門票")]
 39         MEETING_TICKET = 10,
 40     }
 41     /// <summary>
 42     /// 卡券code碼展現類型
 43     /// </summary>
 44     public enum Card_CodeType
 45     {
 46         [Description("文本")]
 47         CODE_TYPE_TEXT = 0,
 48         [Description("一維碼")]
 49         CODE_TYPE_BARCODE = 1,
 50         [Description("二維碼")]
 51         CODE_TYPE_QRCODE = 2,
 52         [Description("二維碼不顯示code")]
 53         CODE_TYPE_ONLY_QRCODE = 3,
 54         [Description("無code類型")]
 55         CODE_TYPE_NONE =4
 56     }
 57     /// <summary>
 58     /// 卡券 商戶自定義cell 名稱
 59     /// </summary>
 60     public enum Card_UrlNameType
 61     {
 62         [Description("外賣")]
 63         URL_NAME_TYPE_TAKE_AWAY = 0,
 64         [Description("在線預訂")]
 65         URL_NAME_TYPE_RESERVATION = 1,
 66         [Description("當即使用")]
 67         URL_NAME_TYPE_USE_IMMEDIATELY = 2,
 68         [Description("在線預定")]
 69         URL_NAME_TYPE_APPOINTMENT = 3,
 70         [Description("在線兌換")]
 71         URL_NAME_TYPE_EXCHANGE = 4,
 72         [Description("車輛信息")]
 73         URL_NAME_TYPE_VEHICLE_INFORMATION = 5,
 74     }
 75 
 76     public enum MemberCard_CustomField_NameType
 77     {
 78         /// <summary>
 79         /// 等級
 80         /// </summary>
 81         FIELD_NAME_TYPE_LEVEL = 0,
 82         /// <summary>
 83         /// 優惠券
 84         /// </summary>
 85         FIELD_NAME_TYPE_COUPON = 1,
 86         /// <summary>
 87         /// 印花
 88         /// </summary>
 89         FIELD_NAME_TYPE_STAMP = 2,
 90         /// <summary>
 91         /// 折扣
 92         /// </summary>
 93         FIELD_NAME_TYPE_DISCOUNT = 3,
 94         /// <summary>
 95         /// 成就
 96         /// </summary>
 97         FIELD_NAME_TYPE_ACHIEVEMEN = 4,
 98         /// <summary>
 99         /// 里程
100         /// </summary>
101         FIELD_NAME_TYPE_MILEAGE = 5,
102     }
103 
104     public enum CardColor
105     {
106         [Description("淡綠色")]
107         Color010 = 0,
108         [Description("綠色")]
109         Color020 = 1,
110         [Description("淡藍色")]
111         Color030 = 2,
112         [Description("藍色")]
113         Color040 = 3,
114         [Description("紫色")]
115         Color050 = 4,
116         [Description("土黃色")]
117         Color060 = 5,
118         [Description("黃色")]
119         Color070 = 6,
120         [Description("橘黃色")]
121         Color080 = 7,
122         [Description("橙色")]
123         Color081 = 8,
124         [Description("銀光綠")]
125         Color082 = 9,
126         [Description("淡紅色")]
127         Color090 = 10,
128         [Description("深紅")]
129         Color100 = 11,
130         [Description("紅色")]
131         Color101 = 12,
132         [Description("灰色")]
133         Color102 = 13,
134     }
135 
136     /// <summary>
137     /// 卡券code查詢狀態
138     /// </summary>
139     public enum UserCardStatus
140     {
141         [Description("正常")]
142         NORMAL = 0,
143         [Description("已覈銷")]
144         CONSUMED = 1,
145         [Description("已過時")]
146         EXPIRE = 2,
147         [Description("轉贈中")]
148         GIFTING = 3,
149         [Description("轉贈超時")]
150         GIFT_TIMEOUT = 4,
151         [Description("已刪除")]
152         DELETE = 5,
153         [Description("已失效")]
154         UNAVAILABLE = 6
155     }
View Code

 而微信又提供了自定義code模式post

因此多出一個繼承類測試

1     public class Card_CodeBaseInfoBase : Card_BaseInfoBase
2     {
3         public string get_custom_code_mode
4         {
5             get { return "GET_CUSTOM_CODE_MODE_DEPOSIT"; }
6         }
7     }

關係類構造post須要的Json請看以下code,若不須要的看官請勿打開,比較長ui

  1     /// <summary>
  2     /// 卡券信息數據中的card字段
  3     /// </summary>
  4     public class CardCreateInfo_Card
  5     {
  6         
  7     }
  8 
  9 
 10     #region 不一樣卡券類型對應的信息
 11 
 12     /// <summary>
 13     /// 通用券
 14     /// </summary>
 15     public class Card_GeneralCoupon : CardCreateInfo_Card
 16     {
 17         public string card_type { get; set; }
 18         public Card_GeneralCouponData general_coupon { get; set; }
 19     }
 20 
 21     /// <summary>
 22     /// 團購券
 23     /// </summary>
 24     public class Card_Groupon : CardCreateInfo_Card
 25     {
 26         public string card_type { get; set; }
 27         public Card_GrouponData groupon { get; set; }
 28     }
 29 
 30     /// <summary>
 31     /// 禮品券
 32     /// </summary>
 33     public class Card_Gift : CardCreateInfo_Card
 34     {
 35         public string card_type { get; set; }
 36         public Card_GiftData gift { get; set; }
 37     }
 38 
 39     /// <summary>
 40     /// 代金券
 41     /// </summary>
 42     public class Card_Cash : CardCreateInfo_Card
 43     {
 44         public string card_type { get; set; }
 45         public Card_CashData cash { get; set; }
 46     }
 47 
 48     /// <summary>
 49     /// 折扣券
 50     /// </summary>
 51     public class Card_DisCount : CardCreateInfo_Card
 52     {
 53         public string card_type { get; set; }
 54         public Card_DisCountData discount { get; set; }
 55     }
 56 
 57     /// <summary>
 58     /// 會員卡
 59     /// </summary>
 60     public class Card_MemberCard : CardCreateInfo_Card
 61     {
 62         public string card_type { get; set; }
 63         public Card_MemberCardData member_card { get; set; }
 64     }
 65 
 66     /// <summary>
 67     /// 門票
 68     /// </summary>
 69     public class Card_ScenicTicket : CardCreateInfo_Card
 70     {
 71         public string card_type { get; set; }
 72         public Card_ScenicTicketData scenic_ticket { get; set; }
 73     }
 74 
 75     /// <summary>
 76     /// 電影票
 77     /// </summary>
 78     public class Card_MovieTicket : CardCreateInfo_Card
 79     {
 80         public string card_type { get; set; }
 81         public Card_MovieTicketData movie_ticket { get; set; }
 82     }
 83 
 84     /// <summary>
 85     /// 飛機票
 86     /// </summary>
 87     public class Card_BoardingPass : CardCreateInfo_Card
 88     {
 89         public string card_type { get; set; }
 90         public Card_BoardingPassData boarding_pass { get; set; }
 91     }
 92 
 93     /// <summary>
 94     /// 紅包
 95     /// </summary>
 96     public class Card_LuckyMoney : CardCreateInfo_Card
 97     {
 98         public string card_type { get; set; }
 99         public Card_LuckyMoneyData lucky_money { get; set; }
100     }
101 
102     /// <summary>
103     /// 會議門票
104     /// </summary>
105     public class Card_MeetingTicket : CardCreateInfo_Card
106     {
107         public string card_type { get; set; }
108         public Card_MeetingTicketData meeting_ticket { get; set; }
109     }
110     #endregion
111 
112 
113     public abstract class BaseCardInfo
114     {
115         /// <summary>
116         /// 基本的卡券數據
117         /// </summary>
118         public Card_BaseInfoBase base_info { get; set; }
119         /// <summary>
120         /// 卡類型(不在Json數據中)
121         /// </summary>
122         protected CardType CardType { get; set; }
123 
124         public CardType GetCardType()
125         {
126             return CardType;
127         }
128 
129         public BaseCardInfo(CardType cardType)
130         {
131             CardType = cardType;
132         }
133     }
134 
135     /* 全部類型的卡券數據 */
136 
137 
138     /// <summary>
139     /// 通用券數據
140     /// </summary>
141     public class Card_GeneralCouponData : BaseCardInfo
142     {
143         [Display(Name = "描述文本")]
144         public string default_detail { get; set; }
145 
146         public Card_GeneralCouponData()
147             : base(CardType.GENERAL_COUPON)
148         {
149         }
150     }
151 
152     /// <summary>
153     /// 團購券數據
154     /// </summary>
155     public class Card_GrouponData : BaseCardInfo
156     {
157         [Display(Name = "團購詳情")]
158         public string deal_detail { get; set; }
159 
160         public Card_GrouponData()
161             : base(CardType.GROUPON)
162         {
163         }
164     }
165 
166     /// <summary>
167     /// 禮品券數據
168     /// </summary>
169     public class Card_GiftData : BaseCardInfo
170     {
171         [Display(Name = "禮品名字")]
172         public string gift { get; set; }
173 
174         public Card_GiftData()
175             : base(CardType.GIFT)
176         {
177         }
178     }
179 
180     /// <summary>
181     /// 代金券數據
182     /// </summary>
183     public class Card_CashData : BaseCardInfo
184     {
185         [Display(Name = "起用金額")]
186         public int least_cost { get; set; }
187         [Display(Name = "減免金額")]
188         public int reduce_cost { get; set; }
189 
190         public Card_CashData()
191             : base(CardType.CASH)
192         {
193         }
194     }
195 
196     /// <summary>
197     /// 折扣券數據
198     /// </summary>
199     public class Card_DisCountData : BaseCardInfo
200     {
201         [Display(Name = "打折額度(百分比).填30 就是七折")]
202         public float discount { get; set; }
203 
204         public Card_DisCountData()
205             : base(CardType.DISCOUNT)
206         {
207         }
208     }
209 
210     /// <summary>
211     /// 會員卡數據
212     /// </summary>
213     public class Card_MemberCardData : BaseCardInfo
214     {
215         [Display(Name = "支持積分")]
216         /// <summary>
217         /// 是否支持積分,填寫true 或false,如填寫true,積分相關字段均爲必填。填寫false,積分字段無需填寫。儲值字段處理方式相同。
218         /// 必填
219         /// </summary>
220         public bool supply_bonus { get; set; }
221         [Display(Name = "支持儲值")]
222         /// <summary>
223         /// 是否支持儲值,填寫true 或false。
224         /// 必填
225         /// </summary>
226         public bool supply_balance { get; set; }
227         /// <summary>
228         /// 設置爲true時用戶領取會員卡後系統自動將其激活,無需調用激活接口。
229         /// 非必填
230         /// </summary>
231         public bool auto_activate { get; set; }
232         /// <summary>
233         /// 設置爲true時會員卡支持一鍵激活,不容許同時傳入activate_url字段,不然設置wx_activate失效。
234         /// 非必填
235         /// </summary>
236         public bool wx_activate { get; set; }
237         /// <summary>
238         /// 積分清零規則
239         /// 非必填
240         /// </summary>
241         public string bonus_cleared { get; set; }
242         /// <summary>
243         /// 積分規則
244         /// 非必填
245         /// </summary>
246         public string bonus_rules { get; set; }
247         /// <summary>
248         /// 儲值說明
249         /// 非必填
250         /// </summary>
251         public string balance_rules { get; set; }
252         /// <summary>
253         /// 特權說明
254         /// 必填
255         /// </summary>
256         public string prerogative { get; set; }
257         /// <summary>
258         /// 綁定舊卡的url,與「activate_url」字段二選一必填。
259         /// </summary>
260         public string bind_old_card_url { get; set; }
261         /// <summary>
262         /// 激活會員卡的url,與「bind_old_card_url」字段二選一必填。
263         /// </summary>
264         public string activate_url { get; set; }
265         /// <summary>
266         /// 設置跳轉外鏈查看積分詳情。僅適用於積分沒法經過激活接口同步的狀況下使用該字段。
267         /// 非必填
268         /// </summary>
269         public string bonus_url { get; set; }
270         /// <summary>
271         /// 設置跳轉外鏈查看餘額詳情。僅適用於餘額沒法經過激活接口同步的狀況下使用該字段。
272         /// 非必填
273         /// </summary>
274         public string balance_url { get; set; }
275         /// <summary>
276         /// 自定義會員信息類目,會員卡激活後顯示。
277         /// 非必填
278         /// </summary>
279         public CustomField custom_field1 { get; set; }
280         /// <summary>
281         /// 自定義會員信息類目,會員卡激活後顯示。
282         /// 非必填
283         /// </summary>
284         public CustomField custom_field2 { get; set; }
285         /// <summary>
286         /// 自定義會員信息類目,會員卡激活後顯示。
287         /// 非必填
288         /// </summary>
289         public CustomField custom_field3 { get; set; }
290         /// <summary>
291         /// 自定義會員信息類目,會員卡激活後顯示
292         /// 非必填
293         /// </summary>
294         public CustomCell custom_cell1 { get; set; }
295         /// <summary>
296         /// 會員卡背景圖片,非必填
297         /// </summary>
298         public string background_pic_url { get; set; }
299 
300         public Card_MemberCardData()
301             : base(CardType.MEMBER_CARD)
302         {
303         }
304     }
305 
306     public class CustomField
307     {
308         /// <summary>
309         /// 會員信息類目名稱。FIELD_NAME_TYPE_LEVEL等級;FIELD_NAME_TYPE_COUPON優惠券;FIELD_NAME_TYPE_STAMP印花;FIELD_NAME_TYPE_DISCOUNT折扣;FIELD_NAME_TYPE_ACHIEVEMEN成就;FIELD_NAME_TYPE_MILEAGE里程。
310         /// </summary>
311         public MemberCard_CustomField_NameType name_type { get; set; }
312         /// <summary>
313         /// 點擊類目跳轉外鏈url
314         /// </summary>
315         public string url { get; set; }
316     }
317 
318     public class CustomCell
319     {
320         /// <summary>
321         /// 入口名稱
322         /// 必填
323         /// </summary>
324         public string name { get; set; }
325         /// <summary>
326         /// 入口右側提示語,6個漢字內
327         /// 必填
328         /// </summary>
329         public string tips { get; set; }
330         /// <summary>
331         /// 入口跳轉連接
332         /// 必填
333         /// </summary>
334         public string url { get; set; }
335     }
336 
337     /// <summary>
338     /// 門票數據
339     /// </summary>
340     public class Card_ScenicTicketData : BaseCardInfo
341     {
342         /// <summary>
343         /// 票類型,例如平日全票,套票等
344         /// 非必填
345         /// </summary>
346         public string ticket_class { get; set; }
347         /// <summary>
348         /// 導覽圖url
349         /// 非必填
350         /// </summary>
351         public string guide_url { get; set; }
352 
353         public Card_ScenicTicketData()
354             : base(CardType.SCENIC_TICKET)
355         {
356         }
357     }
358 
359     /// <summary>
360     /// 電影票數據
361     /// </summary>
362     public class Card_MovieTicketData : BaseCardInfo
363     {
364         /// <summary>
365         /// 電影票詳請
366         /// 非必填
367         /// </summary>
368         public string detail { get; set; }
369 
370         public Card_MovieTicketData()
371             : base(CardType.MOVIE_TICKET)
372         {
373         }
374     }
375 
376     /// <summary>
377     /// 飛機票數據
378     /// </summary>
379     public class Card_BoardingPassData : BaseCardInfo
380     {
381         /// <summary>
382         /// 起點,上限爲18 個漢字
383         /// 必填
384         /// </summary>
385         public string from { get; set; }
386         /// <summary>
387         /// 終點,上限爲18 個漢字
388         /// 必填
389         /// </summary>
390         public string to { get; set; }
391         /// <summary>
392         /// 航班
393         /// 必填
394         /// </summary>
395         public string flight { get; set; }
396         /// <summary>
397         /// 起飛時間,上限爲17 個漢字
398         /// 非必填
399         /// </summary>
400         public string departure_time { get; set; }
401         /// <summary>
402         /// 降落時間,上限爲17 個漢字
403         /// 非必填
404         /// </summary>
405         public string landing_time { get; set; }
406         /// <summary>
407         /// 在線值機的連接
408         /// 非必填
409         /// </summary>
410         public string check_in_url { get; set; }
411         /// <summary>
412         /// 登機口。如發生登機口變動,建議商家實時調用該接口變動
413         /// </summary>
414         public string gate { get; set; }
415         /// <summary>
416         /// 登機時間,只顯示「時分」不顯示日期,按時間戳格式填寫。如發生登機時間變動,建議商家實時調用該接口變動
417         /// </summary>
418         public string boarding_time { get; set; }
419         /// <summary>
420         /// 機型,上限爲8 個漢字
421         /// 非必填
422         /// </summary>
423         public string air_model { get; set; }
424 
425         public Card_BoardingPassData()
426             : base(CardType.BOARDING_PASS)
427         {
428         }
429     }
430 
431     /// <summary>
432     /// 紅包數據
433     /// </summary>
434     public class Card_LuckyMoneyData : BaseCardInfo
435     {
436         public Card_LuckyMoneyData()
437             : base(CardType.LUCKY_MONEY)
438         {
439         }
440     }
441 
442     /// <summary>
443     /// 會議門票數據
444     /// </summary>
445     public class Card_MeetingTicketData : BaseCardInfo
446     {
447         /// <summary>
448         /// 會議詳情
449         /// </summary>
450         public string meeting_detail { get; set; }
451 
452         /// <summary>
453         /// 會場導覽圖
454         /// </summary>
455         public string map_url { get; set; }
456 
457         public Card_MeetingTicketData()
458             : base(CardType.MEETING_TICKET)
459         {
460         }
461     }
462 
463 
464     public class CardCreateInfo
465     {
466         /// <summary>
467         /// 卡券信息部分
468         /// </summary>
469         public CardCreateInfo_Card card { get; set; }
470     }
View Code

 

最後隨便拿出個地方編譯下構造函數,已基礎字段數據爲準建立個BaseCardInfo便可url

  1         public CardCreateInfo CreateCard(BaseCardInfo cardInfo)
  2         {
  3             CardCreateInfo cardData = null;
  4             CardType cardType = cardInfo.GetCardType();
  5             switch (cardType)
  6             {
  7                 case CardType.GENERAL_COUPON:
  8                     cardData = new CardCreateInfo()
  9                     {
 10                         card = new Card_GeneralCoupon()
 11                         {
 12                             card_type = cardType.ToString(),
 13                             general_coupon = cardInfo as Card_GeneralCouponData
 14                         }
 15                     };
 16                     break;
 17                 case CardType.GROUPON:
 18                     cardData = new CardCreateInfo()
 19                     {
 20                         card = new Card_Groupon()
 21                         {
 22                             card_type = cardType.ToString(),
 23                             groupon = cardInfo as Card_GrouponData
 24                         }
 25                     };
 26                     break;
 27                 case CardType.GIFT:
 28                     cardData = new CardCreateInfo()
 29                     {
 30                         card = new Card_Gift()
 31                         {
 32                             card_type = cardType.ToString(),
 33                             gift = cardInfo as Card_GiftData
 34                         }
 35                     };
 36                     break;
 37                 case CardType.CASH:
 38                     cardData = new CardCreateInfo()
 39                     {
 40                         card = new Card_Cash()
 41                         {
 42                             card_type = cardType.ToString(),
 43                             cash = cardInfo as Card_CashData
 44                         }
 45                     };
 46                     break;
 47                 case CardType.DISCOUNT:
 48                     cardData = new CardCreateInfo()
 49                     {
 50                         card = new Card_DisCount()
 51                         {
 52                             card_type = cardType.ToString(),
 53                             discount = cardInfo as Card_DisCountData
 54                         }
 55                     };
 56                     break;
 57                 case CardType.MEMBER_CARD:
 58                     cardData = new CardCreateInfo()
 59                     {
 60                         card = new Card_MemberCard()
 61                         {
 62                             card_type = cardType.ToString(),
 63                             member_card = cardInfo as Card_MemberCardData
 64                         }
 65                     };
 66                     break;
 67                 case CardType.SCENIC_TICKET:
 68                     cardData = new CardCreateInfo()
 69                     {
 70                         card = new Card_ScenicTicket()
 71                         {
 72                             card_type = cardType.ToString(),
 73                             scenic_ticket = cardInfo as Card_ScenicTicketData
 74                         }
 75                     };
 76                     break;
 77                 case CardType.MOVIE_TICKET:
 78                     cardData = new CardCreateInfo()
 79                     {
 80                         card = new Card_MovieTicket()
 81                         {
 82                             card_type = cardType.ToString(),
 83 
 84                             movie_ticket = cardInfo as Card_MovieTicketData
 85                         }
 86                     };
 87                     break;
 88                 case CardType.BOARDING_PASS:
 89                     cardData = new CardCreateInfo()
 90                     {
 91                         card = new Card_BoardingPass()
 92                         {
 93                             card_type = cardType.ToString(),
 94                             boarding_pass = cardInfo as Card_BoardingPassData
 95                         }
 96                     };
 97                     break;
 98                 case CardType.LUCKY_MONEY:
 99                     cardData = new CardCreateInfo()
100                     {
101                         card = new Card_LuckyMoney()
102                         {
103                             card_type = cardType.ToString(),
104                             lucky_money = cardInfo as Card_LuckyMoneyData
105                         }
106                     };
107                     break;
108                 case CardType.MEETING_TICKET:
109                     cardData = new CardCreateInfo()
110                     {
111                         card = new Card_MeetingTicket()
112                         {
113                             card_type = cardType.ToString(),
114                             meeting_ticket = cardInfo as Card_MeetingTicketData
115                         }
116                     };
117                     break;
118                 default:
119                     break;
120             }
121             return cardData;
122         }
View Code

 

以下來個案例吧!spa

        /// <summary>
        /// Card_CodeBaseInfoBase 自定義code
        /// Card_BaseInfoBase 非自定義code
        /// </summary>
        protected Card_BaseInfoBase _BaseInfo = new Card_BaseInfoBase()
        {
            logo_url = "http://mmbiz.qpic.cn/mmbiz/miaI74XjeZqtQsnpfib61eTC0dx1cxar5KZ7pGYm6wNVkSX78WRBKYQFVDzDfwWNiaEAuDbAftBrMuvN6bFY5o2qw/0?wx_fmt=jpeg",
            brand_name = "海底撈",
            code_type = Card_CodeType.CODE_TYPE_BARCODE.ToString(),
            title = "132 元雙人火鍋套餐",
            sub_title = "週末狂歡必備",
            color = "Color010",
            notice = "使用時向服務員出示此券",
            service_phone = "020-88888888",
            description = @"不可與其餘優惠同享\n 如需團購券發票,請在消費時向商戶提出\n 店內都可
使用,僅限堂食\n 餐前不可打包,餐後未吃完,可打包\n 本團購券不限人數,建議2 人使用,超過建議人
數須另收醬料費5 元/位\n 本單謝絕自帶酒水飲料",
            date_info = new Card_BaseInfo_DateInfo()
            {
                type = Card_DateInfo_Type.DATE_TYPE_FIX_TIME_RANGE.ToString(),
                begin_timestamp = DateTime.Now.ToUnixTimestamp().ToString(),
                end_timestamp = DateTime.Now.AddDays(10).ToUnixTimestamp().ToString(),
            },
            sku = new Card_BaseInfo_Sku()
            {
                quantity = 5
            },
            use_limit = 1,
            get_limit = 3,
            use_custom_code = false,
            bind_openid = false,
            can_share = true,
            can_give_friend = true,
            url_name_type = Card_UrlNameType.URL_NAME_TYPE_RESERVATION.ToString(),
            custom_url = "http://www.weiweihi.com",
            source = "大衆點評",
            custom_url_name = "當即使用",
            custom_url_sub_title = "6個漢字tips",
            promotion_url_name = "更多優惠",
            promotion_url = "http://www.qq.com",
            //location_id_list = { "123","321"},
        };

 運用這個類變成所需的品種:.net

            var data = new Card_GrouponData
            {
                base_info = _BaseInfo as Card_BaseInfoBase,
                deal_detail = "測試"
            };
            var card = new CardHelper(「Accestoken」);
            var result = card.CreateCard(data);

            JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
            var jsonString = jsSerializer.Serialize(result);我定義了新的類CardHelper 已添加對應的屬性,並調用一下所寫的類CreateCard就是剛剛所用到的建立類
相關文章
相關標籤/搜索