Esempio n. 1
0
        public ActionResult AddSinglePromotion(SinglePromotionModel model)
        {
            PartProductInfo partProductInfo = AdminProducts.AdminGetPartProductById(model.Pid);
            if (partProductInfo == null)
            {
                ModelState.AddModelError("Pid", "商品不存在");
            }
            else
            {
                if (AdminPromotions.AdminIsExistSinglePromotion(model.Pid, model.StartTime1, model.EndTime1) > 0)
                    ModelState.AddModelError("EndTime1", "此时间段内已经存在单品促销活动");

                if (model.StartTime2 != null && model.EndTime2 != null && AdminPromotions.AdminIsExistSinglePromotion(model.Pid, model.StartTime2.Value, model.EndTime2.Value) > 0)
                    ModelState.AddModelError("EndTime2", "此时间段内已经存在单品促销活动");

                if (model.StartTime3 != null && model.EndTime3 != null && AdminPromotions.AdminIsExistSinglePromotion(model.Pid, model.StartTime3.Value, model.EndTime3.Value) > 0)
                    ModelState.AddModelError("EndTime3", "此时间段内已经存在单品促销活动");
            }

            if (ModelState.IsValid)
            {
                DateTime noTime = new DateTime(1900, 1, 1);

                SinglePromotionInfo singlePromotionInfo = new SinglePromotionInfo()
                {
                    Pid = model.Pid,
                    StartTime1 = model.StartTime1,
                    EndTime1 = model.EndTime1,
                    StartTime2 = model.StartTime2.HasValue ? model.StartTime2.Value : noTime,
                    EndTime2 = model.EndTime2.HasValue ? model.EndTime2.Value : noTime,
                    StartTime3 = model.StartTime3.HasValue ? model.StartTime3.Value : noTime,
                    EndTime3 = model.EndTime3.HasValue ? model.EndTime3.Value : noTime,
                    UserRankLower = model.UserRankLower,
                    State = model.State,
                    Name = model.PromotionName,
                    Slogan = model.Slogan == null ? "" : model.Slogan,
                    DiscountType = model.DiscountType,
                    DiscountValue = model.DiscountValue,
                    CouponTypeId = model.CouponTypeId,
                    PayCredits = model.PayCredits,
                    IsStock = model.IsStock,
                    Stock = model.Stock,
                    QuotaLower = model.QuotaLower,
                    QuotaUpper = model.QuotaUpper,
                    AllowBuyCount = model.AllowBuyCount
                };

                AdminPromotions.CreateSinglePromotion(singlePromotionInfo);
                AddAdminOperateLog("添加单品促销", "添加单品促销,单品促销为:" + model.Pid + "_" + model.PromotionName);
                return PromptView("单品促销添加成功");
            }

            LoadSinglePromotion();
            return View(model);
        }
Esempio n. 2
0
        public ActionResult EditSinglePromotion(SinglePromotionModel model, int pmId = -1)
        {
            SinglePromotionInfo singlePromotionInfo = AdminPromotions.AdminGetSinglePromotionById(pmId);
            if (singlePromotionInfo == null)
                return PromptView("单品促销不存在");

            int temp1 = AdminPromotions.AdminIsExistSinglePromotion(model.Pid, model.StartTime1, model.EndTime1);
            if (temp1 > 0 && temp1 != pmId)
                ModelState.AddModelError("EndTime1", "此时间段内已经存在单品促销活动");

            if (model.StartTime2 != null && model.EndTime2 != null)
            {
                temp1 = AdminPromotions.AdminIsExistSinglePromotion(model.Pid, model.StartTime2.Value, model.EndTime2.Value);
                if (temp1 > 0 && temp1 != pmId)
                    ModelState.AddModelError("EndTime2", "此时间段内已经存在单品促销活动");
            }

            if (model.StartTime3 != null && model.EndTime3 != null)
            {
                temp1 = AdminPromotions.AdminIsExistSinglePromotion(model.Pid, model.StartTime3.Value, model.EndTime3.Value);
                if (temp1 > 0 && temp1 != pmId)
                    ModelState.AddModelError("EndTime3", "此时间段内已经存在单品促销活动");
            }

            if (ModelState.IsValid)
            {
                DateTime noTime = new DateTime(1900, 1, 1);

                singlePromotionInfo.StartTime1 = model.StartTime1;
                singlePromotionInfo.EndTime1 = model.EndTime1;
                singlePromotionInfo.StartTime2 = model.StartTime2.HasValue ? model.StartTime2.Value : noTime;
                singlePromotionInfo.EndTime2 = model.EndTime2.HasValue ? model.EndTime2.Value : noTime;
                singlePromotionInfo.StartTime3 = model.StartTime3.HasValue ? model.StartTime3.Value : noTime;
                singlePromotionInfo.EndTime3 = model.EndTime3.HasValue ? model.EndTime3.Value : noTime;
                singlePromotionInfo.UserRankLower = model.UserRankLower;
                singlePromotionInfo.State = model.State;
                singlePromotionInfo.Name = model.PromotionName;
                singlePromotionInfo.Slogan = model.Slogan == null ? "" : model.Slogan;
                singlePromotionInfo.DiscountType = model.DiscountType;
                singlePromotionInfo.DiscountValue = model.DiscountValue;
                singlePromotionInfo.CouponTypeId = model.CouponTypeId;
                singlePromotionInfo.PayCredits = model.PayCredits;
                singlePromotionInfo.IsStock = model.IsStock;
                singlePromotionInfo.Stock = model.Stock;
                singlePromotionInfo.QuotaLower = model.QuotaLower;
                singlePromotionInfo.QuotaUpper = model.QuotaUpper;
                singlePromotionInfo.AllowBuyCount = model.AllowBuyCount;

                AdminPromotions.UpdateSinglePromotion(singlePromotionInfo);
                AddAdminOperateLog("修改单品促销", "修改单品促销,单品促销ID为:" + pmId);
                return PromptView("单品促销修改成功");
            }

            LoadSinglePromotion();
            return View(model);
        }
Esempio n. 3
0
 public ActionResult AddSinglePromotion()
 {
     SinglePromotionModel model = new SinglePromotionModel();
     LoadSinglePromotion();
     return View(model);
 }
Esempio n. 4
0
        public ActionResult EditSinglePromotion(int pmId = -1)
        {
            SinglePromotionInfo singlePromotionInfo = AdminPromotions.AdminGetSinglePromotionById(pmId);
            if (singlePromotionInfo == null)
                return PromptView("单品促销不存在");

            DateTime? nullTime = null;
            DateTime noTime = new DateTime(1900, 1, 1);

            SinglePromotionModel model = new SinglePromotionModel();
            model.Pid = singlePromotionInfo.Pid;
            model.ProductName = AdminProducts.AdminGetPartProductById(singlePromotionInfo.Pid).Name;
            model.StartTime1 = singlePromotionInfo.StartTime1;
            model.EndTime1 = singlePromotionInfo.EndTime1;
            model.StartTime2 = singlePromotionInfo.StartTime2 == noTime ? nullTime : singlePromotionInfo.StartTime2;
            model.EndTime2 = singlePromotionInfo.EndTime2 == noTime ? nullTime : singlePromotionInfo.EndTime2;
            model.StartTime3 = singlePromotionInfo.StartTime3 == noTime ? nullTime : singlePromotionInfo.StartTime3;
            model.EndTime3 = singlePromotionInfo.EndTime3 == noTime ? nullTime : singlePromotionInfo.EndTime3;
            model.UserRankLower = singlePromotionInfo.UserRankLower;
            model.State = singlePromotionInfo.State;
            model.PromotionName = singlePromotionInfo.Name;
            model.Slogan = singlePromotionInfo.Slogan;
            model.DiscountType = singlePromotionInfo.DiscountType;
            model.DiscountValue = singlePromotionInfo.DiscountValue;
            model.CouponTypeId = singlePromotionInfo.CouponTypeId;
            model.PayCredits = singlePromotionInfo.PayCredits;
            model.IsStock = singlePromotionInfo.IsStock;
            model.Stock = singlePromotionInfo.Stock;
            model.QuotaLower = singlePromotionInfo.QuotaLower;
            model.QuotaUpper = singlePromotionInfo.QuotaUpper;
            model.AllowBuyCount = singlePromotionInfo.AllowBuyCount;

            LoadSinglePromotion();

            return View(model);
        }