コード例 #1
0
ファイル: CardController.cs プロジェクト: yanlipingyan/wechat
 public string CreateDiscountCard()
 {
     var model = new DiscountCardModel()
     {
         LogoUrl = "http://mmbiz.qpic.cn/mmbiz/47BVHoK4A4kMQbicSLdYUciaI6rqWEv9x2MKOmZXPQYbWMFrDvXRny9LiaEtcVicoqFfbfJrgr7PUicS2DMHucmJZ1w/0",
         CodeType = "CODE_TYPE_BARCODE",
         BrandName = "睿桃",
         Title = "三折折扣券",
         SubTitle = "副标题",
         Color = "Color010",
         Notice = "购买时出示此券",
         Description = "不可与其他优惠同享",
         Quantity = 2,
         Type = 2,
         FixedTerm = 15,
         FixedBeginTerm = 0,
         UseCustomCode = false,
         BindOpenId = false,
         ServicePhone = "0371-86097133",
         LocationIdList = new int[] { },
         Source = "",
         CustomUrlName = "",
         CustomUrl = "",
         CustomUrlSubTitle = "",
         PromotionUrlName = "",
         PromotionUrl = "",
         PromotionUrlSubTitle = "",
         GetLimit = 1,
         CanShare = true,
         CanGiveFriend = true,
         Discount = 70
     };
     return JsonConvert.SerializeObject(Card.CreateDiscountCard(ApiModel.AppID, ApiModel.AppSecret, model));
 }
コード例 #2
0
ファイル: Card.cs プロジェクト: yanlipingyan/wechat
        /// <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 CreateDiscountCard(string appId, string appSecret, Models.DiscountCardModel 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 = "DISCOUNT",
                    discount  = 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,        //卡券是否可转赠。
                        },
                        discount = model.Discount
                    }
                }
            };

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