public ActionResult AddCouponType(CouponTypeModel model)
        {
            if (ModelState.IsValid)
            {
                DateTime nullTime = new DateTime(1970, 1, 1);

                if (model.SendModel == 1 || model.SendModel == 2)
                {
                    model.GetModel = 0;
                    model.SendStartTime = nullTime;
                    model.SendEndTime = nullTime;
                }

                if (model.UseTimeType == 1)
                {
                    model.UseStartTime = nullTime;
                    model.UseEndTime = nullTime;
                }
                else
                {
                    model.UseExpireTime = 0;
                }

                CouponTypeInfo couponTypeInfo = new CouponTypeInfo()
                {
                    Name = model.CouponTypeName,
                    Money = model.Money,
                    Count = model.Count,
                    SendMode = model.SendModel,
                    GetMode = model.GetModel,
                    UseMode = model.UseModel,
                    UserRankLower = model.UserRankLower,
                    OrderAmountLower = model.OrderAmountLower,
                    LimitCateId = model.LimitCateId,
                    LimitBrandId = model.LimitBrandId,
                    LimitProduct = model.LimitProduct,
                    SendStartTime = model.SendStartTime.Value,
                    SendEndTime = model.SendEndTime.Value,
                    UseExpireTime = model.UseExpireTime,
                    UseStartTime = model.UseStartTime.Value,
                    UseEndTime = model.UseEndTime.Value,
                    State = model.State
                };
                AdminCoupons.CreateCouponType(couponTypeInfo);
                AddAdminOperateLog("添加优惠劵类型", "添加优惠劵类型,优惠劵类型为:" + model.CouponTypeName);
                return PromptView("优惠劵类型添加成功");
            }
            LoadCouponType();
            return View(model);
        }
 public ActionResult AddCouponType()
 {
     CouponTypeModel model = new CouponTypeModel();
     LoadCouponType();
     return View(model);
 }
        /// <summary>
        /// 展示优惠劵类型
        /// </summary>
        /// <param name="couponTypeId">优惠劵类型id</param>
        public ActionResult ShowCouponType(int couponTypeId = -1)
        {
            CouponTypeInfo couponTypeInfo = AdminCoupons.AdminGetCouponTypeById(couponTypeId);
            if (couponTypeInfo == null)
                return PromptView("优惠劵类型不存在");

            CouponTypeModel model = new CouponTypeModel();
            model.CouponTypeName = couponTypeInfo.Name;
            model.Money = couponTypeInfo.Money;
            model.Count = couponTypeInfo.Count;
            model.SendModel = couponTypeInfo.SendMode;
            model.GetModel = couponTypeInfo.GetMode;
            model.UseModel = couponTypeInfo.UseMode;
            model.UserRankLower = couponTypeInfo.UserRankLower;
            model.OrderAmountLower = couponTypeInfo.OrderAmountLower;
            model.LimitCateId = couponTypeInfo.LimitCateId;
            model.LimitBrandId = couponTypeInfo.LimitBrandId;
            model.LimitProduct = couponTypeInfo.LimitProduct;
            model.UseExpireTime = couponTypeInfo.UseExpireTime;
            model.SendStartTime = couponTypeInfo.SendStartTime;
            model.SendEndTime = couponTypeInfo.SendEndTime;
            model.UseStartTime = couponTypeInfo.UseStartTime;
            model.UseEndTime = couponTypeInfo.UseEndTime;
            model.State = couponTypeInfo.State;

            CategoryInfo categoryInfo = AdminCategories.GetCategoryById(model.LimitCateId);
            if (categoryInfo != null)
                model.LimitCateName = categoryInfo.Name;
            else
                model.LimitCateName = "未限制分类";

            BrandInfo brandInfo = AdminBrands.GetBrandById(model.LimitBrandId);
            if (brandInfo != null)
                model.LimitBrandName = brandInfo.Name;
            else
                model.LimitBrandName = "未限制品牌";

            LoadCouponType();
            return View(model);
        }