Exemplo n.º 1
0
 public string CreateGeneralCouponCard()
 {
     var model = new GeneralCouponCardModel()
     {
         LogoUrl = "http://mmbiz.qpic.cn/mmbiz/47BVHoK4A4kMQbicSLdYUciaI6rqWEv9x2MKOmZXPQYbWMFrDvXRny9LiaEtcVicoqFfbfJrgr7PUicS2DMHucmJZ1w/0",
         CodeType = "CODE_TYPE_QRCODE",
         BrandName = "睿桃",
         Title = "30元通用优惠券",
         SubTitle = "使用优惠券",
         Color = "Color010",
         Notice = "购买时出示此券",
         Description = "不可与其他优惠同享",
         Quantity = 2,
         Type = 2,
         FixedTerm = 15,
         FixedBeginTerm = 0,
         UseCustomCode = false,
         BindOpenId = false,
         ServicePhone = "0371-86097133",
         LocationIdList = new int[] { 123, 256 },
         Source = "大众点皮",
         CustomUrlName = "外链名字",
         CustomUrl = "http://www.liblog.cn",
         CustomUrlSubTitle = "",
         PromotionUrlName = "营销入口",
         PromotionUrl = "http://www.liblog.cn",
         PromotionUrlSubTitle = "",
         GetLimit = 1,
         CanShare = true,
         CanGiveFriend = true,
         DefaultDetail = "优惠30元"
     };
     return JsonConvert.SerializeObject(Card.CreateGeneralCouponCard(ApiModel.AppID, ApiModel.AppSecret, model));
 }
Exemplo n.º 2
0
        /// <summary>
        /// 创建优惠券
        /// </summary>
        /// <param name="appId">公众号appID</param>
        /// <param name="appSecret">公众号appSecret</param>
        /// <param name="model">优惠券model</param>
        /// <returns>ResultModels.CreateCardResult</returns>
        public static ResultModels.CardResult CreateGeneralCouponCard(string appId, string appSecret, Models.GeneralCouponCardModel 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      = "GENERAL_COUPON",
                    general_coupon = 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,        //卡券是否可转赠。
                        },
                        default_detail = model.DefaultDetail
                    }
                }
            };

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