Пример #1
0
        public ActionResult Save(CommodityPromotion obj)
        {
            obj.StoreId = Request["StoreId"];
            var re = CommodityPromotionService.DanPingSaveOrUpdate(obj, Request["Times"]);

            return(Content(re.ToJson()));
        }
        /// <summary>
        /// 获取促销规则的主表信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        private ActiveMarketingRule GetMarketingRule(CommodityPromotion entity)
        {
            var marketingRules = new ActiveMarketingRule()
            {
                Id = entity.Id,
                RestrictionBuyCount = entity.RestrictionBuyNum,
                MarketingQuotaMode  = entity.RestrictionBuyNum == 0 ? MarketingQuotaMode.NotLimit : MarketingQuotaMode.EveryDay,
                CreateRuleDate      = entity.CreateDT,
                Enable            = true,
                IsRepeatMarketing = false
            };

            switch (entity.CustomerObj)
            {
            case 0:
                marketingRules.CustomerType = Pharos.ObjectModels.DTOs.CustomerType.Whole;
                break;

            case 1:
                marketingRules.CustomerType = Pharos.ObjectModels.DTOs.CustomerType.Insider;
                break;

            case 2:
                marketingRules.CustomerType = Pharos.ObjectModels.DTOs.CustomerType.VIP;
                break;

            default:
                marketingRules.CustomerType = Pharos.ObjectModels.DTOs.CustomerType.Whole;
                break;
            }
            return(marketingRules);
        }
Пример #3
0
        public ActionResult Save(int?id)
        {
            ViewBag.customers = EnumToSelect(typeof(CustomerType), selectValue: 0);
            ViewBag.ways      = EnumToSelect(typeof(DiscountWay), selectValue: 1).ToJson();
            ViewBag.shops     = ListToSelect(WarehouseService.GetList().Select(o => new SelectListItem()
            {
                Value = o.StoreId, Text = o.Title
            }), emptyTitle: "全部", emptyValue: "-1");
            ViewBag.times = CommonRules.TimeLines;
            var obj = new CommodityPromotion();

            if (id.HasValue)
            {
                var detail = BaseService <CommodityDiscount> .FindById(id);

                obj = CommodityPromotionService.FindById(detail.CommodityId);
                if (obj.Timeliness == 1)
                {
                    ViewBag.times = new List <string>()
                    {
                        obj.StartAging1, obj.EndAging1, obj.StartAging2, obj.EndAging2, obj.StartAging3, obj.EndAging3
                    }
                }
                ;
            }
            return(View(obj.IsNullThrow()));
        }
Пример #4
0
        /// <summary>
        /// 获取时效信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        private MarketingTimelinessLimit GetMarketingTimelinessLimit(CommodityPromotion entity)
        {
            //时效限制参数
            var timeRanges = new List <KeyValuePair <string, string> >();

            if (entity.Timeliness == 1)
            {
                timeRanges = ParseTimeRange(timeRanges, entity.StartAging1, entity.EndAging1);
                timeRanges = ParseTimeRange(timeRanges, entity.StartAging2, entity.EndAging2);
                timeRanges = ParseTimeRange(timeRanges, entity.StartAging3, entity.EndAging3);
            }
            var timelinessLimit = new MarketingTimelinessLimit()
            {
                StartTime  = entity.StartDate ?? default(DateTime),
                OverTime   = (entity.EndDate ?? default(DateTime)).AddDays(1),
                TimeRanges = timeRanges
            };

            return(timelinessLimit);
        }