public string CreateGroupon()
 {
     var model = new GrouponCardModel()
     {
         LogoUrl = "http://mmbiz.qpic.cn/mmbiz/47BVHoK4A4kMQbicSLdYUciaI6rqWEv9x2MKOmZXPQYbWMFrDvXRny9LiaEtcVicoqFfbfJrgr7PUicS2DMHucmJZ1w/0",
         CodeType = "CODE_TYPE_BARCODE",
         BrandName = "睿桃",
         Title = "20元团购券",
         SubTitle = "副标题",
         Color = "Color010",
         Notice = "购买时出示此券",
         Description = "不可与其他优惠同享",
         Quantity = 2,
         Type = 2,
         FixedTerm = 15,
         FixedBeginTerm = 0,
         UseCustomCode = false,
         BindOpenId = false,
         ServicePhone = "0371-86097133",
         LocationIdList = new int[] { 123, 12321 },
         Source = "",
         CustomUrlName = "",
         CustomUrl = "",
         CustomUrlSubTitle = "",
         PromotionUrlName = "",
         PromotionUrl = "",
         PromotionUrlSubTitle = "",
         GetLimit = 1,
         CanShare = true,
         CanGiveFriend = true,
         DealDetail = "团购券",
     };
     return JsonConvert.SerializeObject(Card.CreateGrouponCard(ApiModel.AppID, ApiModel.AppSecret, model));
 }
Exemple #2
0
        /// <summary>
        /// 创建团购券
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="model">团购券model</param>
        /// <returns>ResultModels.CardResult</returns>
        public static ResultModels.CardResult CreateGrouponCard(string appId, string appSecret, Models.GrouponCardModel model)
        {
            object date_info = null;

            if (model.Type == 1)
            {
                date_info = new { type = "DATE_TYPE_FIX_TIME_RANGE", begin_timestamp = model.BeginTimestamp, end_timestamp = model.EndTimestamp }
            }
            ;
            else if (model.Type == 2)
            {
                date_info = new { type = "DATE_TYPE_FIX_TERM", fixed_term = model.FixedTerm, fixed_begin_term = model.FixedBeginTerm }
            }
            ;

            var obj = new
            {
                card = new
                {
                    card_type = "GROUPON",
                    groupon   = new
                    {
                        base_info = new
                        {
                            logo_url    = model.LogoUrl,  //卡券的商户logo
                            code_type   = model.CodeType, //code展示类
                            brand_name  = model.BrandName,
                            title       = model.Title,
                            sub_title   = model.SubTitle,
                            color       = model.Color,
                            notice      = model.Notice,
                            description = model.Description,
                            sku         = new
                            {
                                quantity = model.Quantity
                            },
                            date_info = date_info,

                            //以下是不必填信息
                            use_custom_code         = model.UseCustomCode,        //是否自定义Code码。填写true或false,默认为false。通常自有优惠码系统的开发者选择自定义Code码,并在卡券投放时带入Code码,详情见是否自定义Code码。
                            bind_openid             = model.BindOpenId,           //是否指定用户领取,填写true或false。默认为false。通常指定特殊用户群体投放卡券或防止刷券时选择指定用户领取。
                            service_phone           = model.ServicePhone,         //客服电话。
                            location_id_list        = model.LocationIdList,       //门店位置poiid。调用POI门店管理接口获取门店位置poiid。具备线下门店的商户为必填。
                            source                  = model.Source,               //第三方来源名,例如同程旅游、大众点评。
                            custom_url_name         = model.CustomUrlName,        //自定义跳转外链的入口名字。
                            custom_url              = model.CustomUrl,            //自定义跳转的URL。
                            custom_url_sub_title    = model.CustomUrlSubTitle,    //显示在入口右侧的提示语。
                            promotion_url_name      = model.PromotionUrlName,     //营销场景的自定义入口名称。
                            promotion_url           = model.PromotionUrl,         //入口跳转外链的地址链接。
                            promotion_url_sub_title = model.PromotionUrlSubTitle, //显示在营销入口右侧的提示语
                            get_limit               = model.GetLimit,             //每人可领券的数量限制,不填写默认为50。
                            can_share               = model.CanShare,             //卡券领取页面是否可分享。
                            can_give_friend         = model.CanGiveFriend,        //卡券是否可转赠。
                        },
                        deal_detail = model.DealDetail
                    }
                }
            };

            return(CreateCard(appId, appSecret, JsonConvert.SerializeObject(obj)));
        }