Exemple #1
0
        /// <summary>
        /// 创建卡券时间字段
        /// </summary>
        /// <param name="date_info"></param>
        /// <returns></returns>
        private static PubCardDateInfo CreateDateInfoFunc(PubCardDateInfo date_info)
        {
            var dateInfo = new PubCardDateInfo();

            if (date_info.type == PubCardDateType.DATE_TYPE_FIX_TIME_RANGE.ToString())
            {
                dateInfo.type            = PubCardDateType.DATE_TYPE_FIX_TIME_RANGE.ToString();
                dateInfo.begin_timestamp = date_info.begin_timestamp;
                dateInfo.end_timestamp   = date_info.end_timestamp;
            }
            else if (date_info.type == PubCardDateType.DATE_TYPE_FIX_TERM.ToString())
            {
                dateInfo.type             = PubCardDateType.DATE_TYPE_FIX_TERM.ToString();
                dateInfo.fixed_begin_term = date_info.fixed_begin_term;
                dateInfo.fixed_term       = date_info.fixed_term;
            }

            return(dateInfo);
        }
Exemple #2
0
        /// <summary>
        /// 创建卡券入口
        /// </summary>
        /// <param name="cardType"></param>
        /// <param name="deal_detail"></param>
        /// <param name="least_cost"></param>
        /// <param name="reduce_cost"></param>
        /// <param name="discount"></param>
        /// <param name="gift"></param>
        /// <param name="default_detail"></param>
        /// <param name="logo_url"></param>
        /// <param name="code_type"></param>
        /// <param name="brand_name"></param>
        /// <param name="title"></param>
        /// <param name="sub_title"></param>
        /// <param name="color"></param>
        /// <param name="notice"></param>
        /// <param name="description"></param>
        /// <param name="quantity"></param>
        /// <param name="date_info"></param>
        /// <returns></returns>
        public static PubCardCreateResult CreateCard(PubCardType cardType, string deal_detail, int?least_cost, int?reduce_cost, int?discount, string gift, string default_detail,
                                                     string logo_url, PubCardCodeType code_type, string brand_name, string title, string sub_title, PubCardColorType color, string notice, string description, int quantity, PubCardDateInfo date_info)
        {
            // 基本卡券信息
            PubCardBaseInfo baseInfo = CreateBaseInfoFunc(logo_url, code_type, brand_name, title, sub_title, color, notice, description, quantity);
            // 时间
            PubCardDateInfo dateInfo = CreateDateInfoFunc(date_info);

            baseInfo.date_info = dateInfo;

            // 组装
            dynamic cardInfo = new ExpandoObject();

            cardInfo.card_type = cardType.ToString();
            switch (cardType)
            {
            case PubCardType.GROUPON:
                cardInfo.groupon = new
                {
                    base_info   = baseInfo,
                    deal_detail = deal_detail
                };
                break;

            case PubCardType.CASH:
                cardInfo.cash = new
                {
                    base_info   = baseInfo,
                    least_cost  = least_cost,
                    reduce_cost = reduce_cost
                };
                break;

            case PubCardType.DISCOUNT:
                cardInfo.discount = new
                {
                    base_info = baseInfo,
                    discount  = discount
                };
                break;

            case PubCardType.GIFT:
                cardInfo.gift = new
                {
                    base_info = baseInfo,
                    gift      = gift
                };
                break;

            case PubCardType.GENERAL_COUPON:
                cardInfo.general_coupon = new
                {
                    base_info      = baseInfo,
                    default_detail = default_detail
                };
                break;

            default:
                break;
            }

            // 创建卡券
            var card = new { card = cardInfo };
            var res  = CreateCardBase(card);

            return(res);
        }