public ActionResult Edit(ExchangeCenterConfig model) { Version sVersion = new Version(); if (Version.TryParse(model.StartVersion, out sVersion)) { model.StartVersion = sVersion.ToString(); } else { return(Json(false)); } Version eVersion = new Version(); if (Version.TryParse(model.EndVersion, out eVersion)) { model.EndVersion = eVersion.ToString(); } else { return(Json(false)); } if (model.Id != 0 && model.Edit.ToLower() == "update") { return(Json(ExchangeCenterConfigManager.UpdateExchangeCenterConfig(model))); } else { return(Json(ExchangeCenterConfigManager.InsertExchangeCenterConfig(model))); } }
/// <summary> /// 编辑界面数据绑定 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Edit(int id = 0, string type = "") { var memberBll = new MemberService(); var memberGradeList = memberBll.GetMembershipsGradeList(); ViewBag.MemberGrade = memberGradeList; ViewBag.PostionData = GetPostionData(); ExchangeCenterConfig model = new ExchangeCenterConfig(); if (id <= 0) { model.EndTime = DateTime.Now.AddDays(7); model.Status = true;//新增默认启动 } else { model = ExchangeCenterConfigManager.GetExchangeCenterConfig(id); } if (!string.IsNullOrWhiteSpace(type) && type == "copy") { model.Id = 0; } return(View(model)); }
public static bool UpdateExchangeCenterConfig(ExchangeCenterConfig model) { const string sql = @"UPDATE Configuration..ExchangeCenterConfig SET CouponId=@CouponId , -- CouponId - int CouponName=@CouponName , -- CouponName - nvarchar(50) --CouponSum=@CouponSum , -- CouponSum - int --CouponSurplus=@CouponSurplus , -- CouponSurplus - int Period=@Period , -- Period - int PointsValue=@PointsValue , -- PointsValue - int Status=@Status , -- Status - bit Image=@Image , -- Image - nvarchar(1000) PointsRules=@PointsRules , -- PointsRules - text Description=@Description , -- Description - nvarchar(1000) SmallImage=@SmallImage , -- SmallImage - nvarchar(1000) CreateTime= GETDATE(), Sort=@Sort, CouponEndTime=@CouponEndTime, EndTime=@EndTime, CouponDuration=@CouponDuration, GetRuleGUID=@GetRuleGUID, Postion=@Postion, PID=@PID, UserRank=@UserRank, EndCouponPrice=@EndCouponPrice, ExchangeCenterType=@ExchangeCenterType, Chance=@Chance, EndVersion=@EndVersion, StartVersion=@StartVersion WHERE Id=@Id"; var sqlParameter = new SqlParameter[] { new SqlParameter("@CouponId", model.CouponId), new SqlParameter("@CouponName", model.CouponName ?? string.Empty), new SqlParameter("@Status", model.Status), new SqlParameter("@CouponSum", model.CouponSum), new SqlParameter("@CouponSurplus", model.CouponSurplus), new SqlParameter("@Description", model.Description ?? string.Empty), new SqlParameter("@Image", model.Image ?? string.Empty), new SqlParameter("@PointsValue", model.PointsValue), new SqlParameter("@Period", model.Period), new SqlParameter("@PointsRules", model.PointsRules), new SqlParameter("@SmallImage", model.SmallImage), new SqlParameter("@Sort", model.Sort), new SqlParameter("@Id", model.Id), new SqlParameter("@CouponEndTime", model.CouponEndTime ?? null), new SqlParameter("@CouponDuration", model.CouponDuration ?? null), new SqlParameter("@EndTime", model.EndTime), new SqlParameter("@GetRuleGUID", model.GetRuleGUID), new SqlParameter("@Postion", model.Postion), new SqlParameter("@PID", model.PID), new SqlParameter("@UserRank", model.UserRank), new SqlParameter("@EndCouponPrice", model.EndCouponPrice), new SqlParameter("@ExchangeCenterType", model.ExchangeCenterType), new SqlParameter("@Chance", model.Chance), new SqlParameter("@EndVersion", model.EndVersion), new SqlParameter("@StartVersion", model.StartVersion) }; return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, sqlParameter) > 0); }
/// <summary> /// 添加积分兑换 /// </summary> /// <param name="model"></param> /// <returns></returns> public int InsertExchangeCenterConfig(ExchangeCenterConfig model) { try { return(DALExchangeCenterConfig.InsertExchangeCenterConfig(model)); } catch (TuhuBizException) { throw; } catch (Exception ex) { var exception = new ExchangeCenterConfigException(1, "InsertExchangeCenterConfig", ex); Logger.Log(Level.Error, exception, "InsertExchangeCenterConfig"); throw ex; } }
public ActionResult Edit(int id = 0) { ExchangeCenterConfig model = new ExchangeCenterConfig(); if (id == 0) { model.EndTime = DateTime.Now.AddDays(7); model.Edit = "add"; model.Postion = ""; model.UserRank = ""; return(View(model)); } else { model = ExchangeCenterConfigManager.GetExchangeCenterConfig(id); return(View(model)); } }
/// <summary> /// 积分兑换配置详情页面展示数据列表 /// </summary> /// <param name="SearchWord"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public ActionResult List(ExchangeCenterConfigRequest request) { int count = 0; var searchModel = new ExchangeCenterConfig() { PostionCode = request.PostionCode, UserRank = request.UserRank, CouponName = request.CouponName, SearchStatus = request.Status }; var lists = DALExchangeCenterConfig.GetExchangeCenterConfigList(searchModel, request.PageSize, request.PageIndex, out count); var memberBll = new MemberService(); var memberGradeList = memberBll.GetMembershipsGradeList(); var positionList = GetPostionData(); foreach (var item in lists) { if (string.IsNullOrWhiteSpace(item.UserRank)) { continue; } foreach (var np in positionList) { if (np.Key == item.PostionCode) { item.Postion = np.Value; break; } } item.GradeName = memberGradeList.Find(t => t.GradeCode.ToLower() == item.UserRank.ToLower())?.GradeName; } var list = new OutData <List <ExchangeCenterConfig>, int>(lists, count); var pager = new PagerModel(request.PageIndex, request.PageSize) { TotalItem = count }; return(View(new ListModel <ExchangeCenterConfig>(list.ReturnValue, pager))); }
public ActionResult Edit(ExchangeCenterConfig model) { //Version sVersion = new Version(); //if (Version.TryParse(model.StartVersion, out sVersion)) //{ // model.StartVersion = sVersion.ToString(); //} //else //{ // return Json(false); //} //Version eVersion = new Version(); //if (Version.TryParse(model.EndVersion, out eVersion)) //{ // model.EndVersion = eVersion.ToString(); //} //else //{ // return Json(false); //} #region 向后兼容处理 switch (model.PostionCode.Trim()) { //换好物 case "2": model.Postion = "会员商城"; model.ExchangeCenterType = false; break; //拼手气 case "3": model.Postion = "会员商城"; model.ExchangeCenterType = true; break; //兑神券 case "4": model.Postion = "精品通用券"; model.ExchangeCenterType = false; break; } #endregion var result = 0; if (model.Id > 0) { result = ExchangeCenterConfigManager.UpdateExchangeCenterConfig(model); } else { result = ExchangeCenterConfigManager.InsertExchangeCenterConfig(model); } #region 记录操作日志 var oprLog = new DataAccess.Entity.CommonConfigLogModel { ObjectId = (model.Id > 0 ? model.Id : result).ToString(), //新增时候存储新增的Id值 ObjectType = "ExchangeCenterConfig", Creator = HttpContext.User.Identity.Name, Remark = (model.Id > 0 ? "更新" : "新增") + "积分兑换配置", }; new Tuhu.Provisioning.Business.ConfigLog.CommonConfigLogManager().AddCommonConfigLogInfo(oprLog); #endregion return(Json(result > 0)); }
/// <summary> /// 积分兑换配置后台界面查询 /// </summary> /// <param name="model">查询判断脚本</param> /// <param name="pageSize">分页大小</param> /// <param name="pageIndex">起始页</param> /// <param name="recordCount">返回总数量</param> /// <returns></returns> public static List <ExchangeCenterConfig> GetExchangeCenterConfigList(ExchangeCenterConfig model, int pageSize, int pageIndex, out int recordCount) { var strSql = new StringBuilder(); var strCondition = new StringBuilder(); List <SqlParameter> parameters = new List <SqlParameter>(); #region 查询条件 if (!string.IsNullOrWhiteSpace(model.PostionCode)) { strCondition.Append(" And PostionCode=@PostionCode"); parameters.Add(new SqlParameter("@PostionCode", model.PostionCode)); } if (!string.IsNullOrWhiteSpace(model.UserRank)) { strCondition.Append(" And UserRank=@UserRank"); parameters.Add(new SqlParameter("@UserRank", model.UserRank)); } if (!string.IsNullOrWhiteSpace(model.CouponName)) { strCondition.Append(" And CouponName LIKE @CouponName"); parameters.Add(new SqlParameter("@CouponName", "%" + model.CouponName + "%")); } if (model.SearchStatus.HasValue) { strCondition.Append(" And Status=@Status"); parameters.Add(new SqlParameter("@Status", model.SearchStatus.Value ? 1 : 0)); } #endregion #region 查询脚本 strSql.AppendFormat(@" SELECT * FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY Id DESC ) AS ROWNUMBER , E.[Id] , E.[CouponId] , E.[CouponName] , E.[CouponSum] , E.[CouponSurplus] , E.[Period] , E.[PointsValue] , E.[EndTime] , E.[Status] , E.[Image] , E.[PointsRules] , E.[Description] , E.[CreateTime] , E.[SmallImage] , E.[Sort] , E.[CouponEndTime] , E.[CouponDuration] , E.[Postion] , E.[PID] , E.[UserRank] , E.[GetRuleGUID] , E.[EndCouponPrice] , E.[ExchangeCenterType] , E.[Chance] , E.[StartVersion] , E.[EndVersion] , E.[HDImage] , E.[PostionCode] , E.[DescriptionTitle], G.Quantity, G.GetQuantity FROM [Configuration].[dbo].[ExchangeCenterConfig] AS E WITH ( NOLOCK ) INNER JOIN Activity..tbl_GetCouponRules AS G WITH ( NOLOCK ) ON E.CouponId = G.PKID AND E.IsDeleted=0 "); strSql.Append(strCondition); strSql.Append(@" ) AS PG WHERE PG.ROWNUMBER BETWEEN STR(( @PageIndex - 1 ) * @PageSize + 1) AND STR(@PageIndex * @PageSize)"); #endregion parameters.Add(new SqlParameter("@PageSize", pageSize)); parameters.Add(new SqlParameter("@PageIndex", pageIndex)); string sqlCount = @"SELECT COUNT(1) FROM [Configuration].[dbo].[ExchangeCenterConfig] WITH (NOLOCK) WHERE 1=1 " + strCondition.ToString(); recordCount = (int)SqlHelper.ExecuteScalar(connOnRead, CommandType.Text, sqlCount, parameters.ToArray()); var result = SqlHelper.ExecuteDataTable(connOnRead, CommandType.Text, strSql.ToString(), parameters.ToArray()); return(result.ConvertTo <ExchangeCenterConfig>().ToList()); }
/// <summary> /// 添加积分兑换 /// </summary> /// <param name="model"></param> /// <returns></returns> public static int InsertExchangeCenterConfig(ExchangeCenterConfig model) { #region sql脚本 const string sql = @"INSERT INTO Configuration..ExchangeCenterConfig ( CouponId , CouponName , CouponSum , CouponSurplus , Period , PointsValue , EndTime , Status , Image , PointsRules , Description , CreateTime , SmallImage , Sort , CouponEndTime , CouponDuration , GetRuleGUID , Postion , PID , UserRank , EndCouponPrice , ExchangeCenterType , Chance , StartVersion , EndVersion , HDImage , [PostionCode] , [DescriptionTitle] ) VALUES ( @CouponId , -- CouponId - int @CouponName , -- CouponName - nvarchar(50) @CouponSum , -- CouponSum - int @CouponSurplus , -- CouponSurplus - int @Period , -- Period - int @PointsValue , -- PointsValue - int @EndTime , -- EndTime - datetime @Status , -- Status - bit @Image , -- Image - nvarchar(1000) @PointsRules , -- PointsRules - text @Description , -- Description - nvarchar(1000) GETDATE() , -- CreateTime - datetime @SmallImage , -- SmallImage - nvarchar(1000) @Sort, @CouponEndTime , @CouponDuration , @GetRuleGUID , @Postion , @PID , @UserRank , @EndCouponPrice , @ExchangeCenterType , @Chance , @StartVersion , @EndVersion , @HDImage , @PostionCode , @DescriptionTitle );select @@IDENTITY"; #endregion var sqlParameter = new SqlParameter[] { new SqlParameter("@CouponId", model.CouponId), new SqlParameter("@CouponName", model.CouponName ?? string.Empty), new SqlParameter("@Status", model.Status), new SqlParameter("@CouponSum", model.CouponSum), new SqlParameter("@CouponSurplus", model.CouponSum), new SqlParameter("@Description", model.Description ?? string.Empty), new SqlParameter("@Image", model.Image ?? string.Empty), new SqlParameter("@PointsValue", model.PointsValue), new SqlParameter("@Period", model.Period), new SqlParameter("@PointsRules", model.PointsRules), new SqlParameter("@SmallImage", model.SmallImage), new SqlParameter("@Sort", model.Sort), new SqlParameter("@CouponEndTime", model.CouponEndTime ?? null), new SqlParameter("@CouponDuration", model.CouponDuration ?? null), new SqlParameter("@EndTime", model.EndTime), new SqlParameter("@GetRuleGUID", model.GetRuleGUID), new SqlParameter("@Postion", model.Postion), new SqlParameter("@PID", model.PID), new SqlParameter("@UserRank", model.UserRank), new SqlParameter("@EndCouponPrice", model.EndCouponPrice), new SqlParameter("@ExchangeCenterType", model.ExchangeCenterType), new SqlParameter("@Chance", model.Chance), new SqlParameter("@StartVersion", model.StartVersion), new SqlParameter("@EndVersion", model.EndVersion), new SqlParameter("@HDImage", model.HDImage), new SqlParameter("@PostionCode", model.PostionCode), new SqlParameter("@DescriptionTitle", model.DescriptionTitle), }; var objectValue = SqlHelper.ExecuteScalar(conn, CommandType.Text, sql, sqlParameter); if (objectValue != null) { return(Convert.ToInt32(objectValue)); } return(0); }
public static bool InsertExchangeCenterConfig(ExchangeCenterConfig model) { const string sql = @" INSERT INTO Configuration..ExchangeCenterConfig ( CouponId , CouponName , CouponSum , CouponSurplus , Period , PointsValue , EndTime , Status , Image , PointsRules , Description , CreateTime , SmallImage, Sort, CouponEndTime, CouponDuration, GetRuleGUID, Postion,PID,UserRank,EndCouponPrice,ExchangeCenterType,Chance,StartVersion,EndVersion ) VALUES ( @CouponId , -- CouponId - int @CouponName , -- CouponName - nvarchar(50) @CouponSum , -- CouponSum - int @CouponSurplus , -- CouponSurplus - int @Period , -- Period - int @PointsValue , -- PointsValue - int @EndTime , -- EndTime - datetime @Status , -- Status - bit @Image , -- Image - nvarchar(1000) @PointsRules , -- PointsRules - text @Description , -- Description - nvarchar(1000) GETDATE() , -- CreateTime - datetime @SmallImage , -- SmallImage - nvarchar(1000) @Sort, @CouponEndTime, @CouponDuration, @GetRuleGUID, @Postion,@PID,@UserRank,@EndCouponPrice,@ExchangeCenterType,@Chance,@StartVersion,@EndVersion )"; var sqlParameter = new SqlParameter[] { new SqlParameter("@CouponId", model.CouponId), new SqlParameter("@CouponName", model.CouponName ?? string.Empty), new SqlParameter("@Status", model.Status), new SqlParameter("@CouponSum", model.CouponSum), new SqlParameter("@CouponSurplus", model.CouponSum), new SqlParameter("@Description", model.Description ?? string.Empty), new SqlParameter("@Image", model.Image ?? string.Empty), new SqlParameter("@PointsValue", model.PointsValue), new SqlParameter("@Period", model.Period), new SqlParameter("@PointsRules", model.PointsRules), new SqlParameter("@SmallImage", model.SmallImage), new SqlParameter("@Sort", model.Sort), new SqlParameter("@CouponEndTime", model.CouponEndTime ?? null), new SqlParameter("@CouponDuration", model.CouponDuration ?? null), new SqlParameter("@EndTime", model.EndTime), new SqlParameter("@GetRuleGUID", model.GetRuleGUID), new SqlParameter("@Postion", model.Postion), new SqlParameter("@PID", model.PID), new SqlParameter("@UserRank", model.UserRank), new SqlParameter("@EndCouponPrice", model.EndCouponPrice), new SqlParameter("@ExchangeCenterType", model.ExchangeCenterType), new SqlParameter("@Chance", model.Chance), new SqlParameter("@StartVersion", model.StartVersion), new SqlParameter("@EndVersion", model.EndVersion) }; return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, sqlParameter) > 0); }