public JsonResult AddMeetAmount(
            PromoteMeetAmountModel promoteMeetAmountModel,
            PromoteMeetAmountScopeModel meetAmountScopeModel,
            List<PromoteMeetAmountRuleModel> contents)
        {
            try
            {
                // 验证相同商品是否参与其他促销
                var products = this.VerifyPromote(meetAmountScopeModel.Scope, 0, 0);
                if (!string.IsNullOrEmpty(products))
                {
                    return this.Json(new AjaxResponse(0, "以下商品已参加其他促销活动:" + products));
                }

                this.promoteMeetAmountService = new PromoteMeetAmountService();

                promoteMeetAmountModel.EmployeeID = this.SystemUserSession.EmployeeID;
                promoteMeetAmountModel.Status = 1;

                var promoteMeetAmount = DataTransfer.Transfer<Promote_MeetAmount>(
                    promoteMeetAmountModel,
                    typeof(PromoteMeetAmountModel));

                promoteMeetAmount.MeetAmountScope = DataTransfer.Transfer<Promote_MeetAmount_Scope>(
                    meetAmountScopeModel,
                    typeof(PromoteMeetAmountScopeModel));

                var promoteMeetAmountRuleList = new List<Promote_MeetAmount_Rule>();
                foreach (var promoteMeetAmountRuleModel in contents)
                {
                    promoteMeetAmountRuleList.Add(DataTransfer.Transfer<Promote_MeetAmount_Rule>(
                    promoteMeetAmountRuleModel,
                    typeof(PromoteMeetAmountRuleModel)));
                }

                promoteMeetAmount.MeetAmountRules = promoteMeetAmountRuleList;
                this.promoteMeetAmountService.Add(promoteMeetAmount);
                return this.Json(new AjaxResponse(1, "设置成功!"));
            }
            catch (Exception exception)
            {
                return this.Json(new AjaxResponse(0, exception.Message));
            }
        }
 public JsonResult RemoveMeetAmount(string meetAmountID)
 {
     try
     {
         this.promoteMeetAmountService = new PromoteMeetAmountService();
         this.promoteMeetAmountService.Remove(int.Parse(meetAmountID));
         return this.Json(new AjaxResponse(1, "删除成功!"));
     }
     catch (Exception exception)
     {
         return this.Json(new AjaxResponse(0, exception.Message));
     }
 }
        public JsonResult QueryMeetAmountByID(int promoteID)
        {
            PromoteMeetAmountModel promoteMeetAmountModel = null;
            try
            {
                this.promoteMeetAmountService = new PromoteMeetAmountService();
                var promoteMeetAmount = this.promoteMeetAmountService.QueryByID(promoteID);

                if (promoteMeetAmount != null)
                {
                    promoteMeetAmountModel = DataTransfer.Transfer<PromoteMeetAmountModel>(
                    promoteMeetAmount,
                    typeof(Promote_MeetAmount));
                }
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }

            return this.Json(promoteMeetAmountModel, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 查询满件优惠列表.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <param name="amountName">
        /// 活动名称.
        /// </param>
        /// <param name="amountStatus">
        /// 活动状态.
        /// </param>
        /// <param name="startStartTime">
        /// 活动开始时间范围起点时间.
        /// </param>
        /// <param name="startEndTime">
        /// 活动开始时间范围结点时间.
        /// </param>
        /// <param name="endStartTime">
        /// 活动结束时间范围起点时间.
        /// </param>
        /// <param name="endEndTime">
        /// 活动结束时间范围结点时间.
        /// </param>
        /// <returns>
        /// The <see cref="JsonResult"/>.
        /// </returns>
        public JsonResult QueryMeetAmount(
            [DataSourceRequest] DataSourceRequest request,
            string amountName,
            string amountStatus,
            string startStartTime,
            string startEndTime,
            string endStartTime,
            string endEndTime)
        {
            if (request.Page <= 0)
            {
                request.Page = 1;
            }

            if (request.PageSize == 0)
            {
                request.PageSize = 10;
            }

            int totalCount;
            var stringBuilder = new StringBuilder();

            if (!string.IsNullOrEmpty(amountName))
            {
                CheckCondition(stringBuilder);
                stringBuilder.Append("[Name] like '%" + amountName + "%'");
            }

            if (!string.IsNullOrEmpty(startStartTime))
            {
                CheckCondition(stringBuilder);
                stringBuilder.Append("[StartTime] >= '" + startStartTime + "'");
            }

            if (!string.IsNullOrEmpty(startEndTime))
            {
                CheckCondition(stringBuilder);
                stringBuilder.Append("[StartTime] <= '" + startEndTime + "'");
            }

            if (!string.IsNullOrEmpty(endStartTime))
            {
                CheckCondition(stringBuilder);
                stringBuilder.Append("[EndTime] >= '" + endStartTime + "'");
            }

            if (!string.IsNullOrEmpty(endEndTime))
            {
                CheckCondition(stringBuilder);
                stringBuilder.Append("[EndTime] <= '" + endEndTime + "'");
            }

            switch (amountStatus)
            {
                case "1":
                    CheckCondition(stringBuilder);
                    stringBuilder.Append("[StartTime] > '" + DateTime.Now + "'");
                    break;
                case "2":
                    CheckCondition(stringBuilder);
                    stringBuilder.Append("'" + DateTime.Now + "' Between [StartTime] And [EndTime]");
                    break;
                case "3":
                    CheckCondition(stringBuilder);
                    stringBuilder.Append("([EndTime] < '" + DateTime.Now + "' or [Status] = 3)");
                    break;
            }

            CheckCondition(stringBuilder);
            stringBuilder.Append("[IsDelete] = 0");
            var condition = stringBuilder.ToString();
            List<Promote_MeetAmount> list;
            try
            {
                this.promoteMeetAmountService = new PromoteMeetAmountService();
                var paging = new Paging(
                    "[Promote_MeetAmount]",
                    null,
                    "[ID]",
                    condition,
                    request.Page,
                    request.PageSize,
                    "[CreateTime]",
                    1);
                int pageCount;
                list = this.promoteMeetAmountService.Query(paging, out pageCount, out totalCount);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }

            if (list != null)
            {
                var modelList = new List<PromoteMeetAmountModel>();
                foreach (var limitedDiscount in list)
                {
                    modelList.Add(
                        DataTransfer.Transfer<PromoteMeetAmountModel>(limitedDiscount, typeof(Promote_MeetAmount)));
                }

               foreach (var model in modelList)
                {
                    switch (model.Status)
                    {
                        case 1:
                            model.StatusName = "正常";
                            break;
                        case 2:
                            model.StatusName = "暂停";
                            break;
                        case 3:
                            model.StatusName = "停止";
                            break;
                    }

                    model.StatusText = this.GetAmountOperationHtml(
                        model.ID,
                        model.Status,
                        model.StartTime,
                        model.EndTime);
                }

                var data = new DataSource { Data = modelList, Total = totalCount };
                return this.Json(data, JsonRequestBehavior.AllowGet);
            }

            return this.Json(string.Empty);
        }
        public JsonResult ModifyMeetAmountShow(string meetAmountID)
        {
            PromoteMeetAmountModel promoteMeetAmountModel;
            try
            {
                this.promoteMeetAmountService = new PromoteMeetAmountService();
                var promoteMeetAmount = this.promoteMeetAmountService.QueryByID(int.Parse(meetAmountID));
                promoteMeetAmountModel = DataTransfer.Transfer<PromoteMeetAmountModel>(
                    promoteMeetAmount,
                    typeof(Promote_MeetAmount));
                if (promoteMeetAmount != null)
                {
                    this.promoteMeetAmountScopeService = new PromoteMeetAmountScopeService();
                    var meetAmountScope = this.promoteMeetAmountScopeService.QueryByMeetAmountID(int.Parse(meetAmountID));
                    this.promoteMeetAmountRuleService = new PromoteMeetAmountRuleService();
                    var list = this.promoteMeetAmountRuleService.QueryByMeetAmountID(promoteMeetAmount.ID);
                    var promoteMeetAmountList = new List<PromoteMeetAmountRuleModel>();
                    foreach (var moneyRule in list)
                    {
                        promoteMeetAmountList.Add(
                            DataTransfer.Transfer<PromoteMeetAmountRuleModel>(moneyRule, typeof(Promote_MeetAmount_Rule)));
                    }

                    promoteMeetAmountModel.MeetAmountScopeModel =
                        DataTransfer.Transfer<PromoteMeetAmountScopeModel>(
                            meetAmountScope,
                            typeof(Promote_MeetAmount_Scope));
                    promoteMeetAmountModel.MeetAmountRuleModels = promoteMeetAmountList;
                }
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }

            return this.Json(promoteMeetAmountModel, JsonRequestBehavior.AllowGet);
        }
 public JsonResult ChangesMeetAmountStatus(string meetAmountID, string status)
 {
     try
     {
         this.promoteMeetAmountService = new PromoteMeetAmountService();
         this.promoteMeetAmountService.ModifyStatus(int.Parse(meetAmountID), int.Parse(status));
         return this.Json(new AjaxResponse(1, "操作成功!"));
     }
     catch (Exception exception)
     {
         return this.Json(new AjaxResponse(0, "操作失败:" + exception.Message));
     }
 }