/// <summary> /// 获取所有的batch /// </summary> /// <returns></returns> public Dictionary <string, string> GetTs() { string str = "select distinct batch,name from coupon where isdeleted=0"; var dt = SqlHelperHere.ExecuteGetDt(str); return(dt.ConvertToList <Coupon>().Select(p => new { p.batch, p.name }).ToDictionary(p => p.batch, p => p.name)); }
/// <summary> /// 获取最后一个公告 /// </summary> /// <returns></returns> public ArticleInfo GetLastNotice() { string str = "select top 1 * from articleInfo where isarticle=0 and status=1 and isdeleted=0 order by id desc"; var dt = SqlHelperHere.ExecuteGetDt(str); return(dt.ConvertToList <ArticleInfo>().FirstOrDefault()); }
/// <summary> /// 获取同批次第一个记录 /// </summary> /// <param name="ts"></param> /// <returns></returns> public Coupon GetFirstByTs(string ts) { string str = "select top 1 * from coupon where batch=@ts"; var dict = new Dictionary <string, string>(); dict.Add("@ts", ts); var dt = SqlHelperHere.ExecuteGetDt(str, dict); return(dt.ConvertToList <Coupon>().FirstOrDefault()); }
/// <summary> /// 获取某用户使用app的最后一条记录 /// </summary> /// <param name="userId"></param> /// <returns></returns> public UserOpenInfo GetLastByUserId(int userId) { string str = "select top 1 * from UserOpenInfo where userid=@userId order by id desc"; var dict = new Dictionary <string, string>(); dict.Add("@userId", userId.ToString()); var dt = SqlHelperHere.ExecuteGetDt(str, dict); return(dt.ConvertToList <UserOpenInfo>().FirstOrDefault()); }
public string Get(webReq req) { ResultForWeb r = new ResultForWeb(); r.HttpCode = 200; r.Message = ""; r.data = "{}"; if (Session["pfId"] == null) { r.HttpCode = 300; return(JsonConvert.SerializeObject(r)); } string search = req.search ?? ""; //搜索内容 int index = Convert.ToInt32(req.index); //页码 int pages = 0; //总页数 int size = 12; //一页size条数据 var condition = " type = 99 and status = 0 "; condition += " and (takeTypeName like '%" + search + "%' or username like '%" + search + "%' or userphone like '%" + search + "%' ) order by createTime desc "; string str = "select distinct id,createTime from userpayview where 1=1 and " + condition; var dt = SqlHelperHere.ExecuteGetDt(str); var listAll = dt.ConvertToList <UserPayView>(); var ids = listAll.Skip((index - 1) * size).Take(size).Select(p => p.id).ToArray(); var idsStr = string.Join(",", ids); var viewList = CacheHelper.GetByCondition <UserPayView>("UserPayView", " id in (" + idsStr + ")"); var count = listAll.Count; pages = count / size; pages = pages * size == count ? pages : pages + 1;//总页数 var listR = new List <UserPayViewRes>(); foreach (var item in viewList) { UserPayViewRes temp = new UserPayViewRes(item); listR.Add(temp); } r.data = JsonHelperHere.JsonAddPage(pages, JsonConvert.SerializeObject(listR.OrderByDescending(p => p.id)), index); return(JsonConvert.SerializeObject(r)); }
public string Get(webReq req) { ResultForWeb r = new ResultForWeb { HttpCode = 200, Message = "", data = "{}" }; FoodInfoOper.Instance.ClearWeekFood(); var isOn = req.isOn; var orderStr = req.orderStr; var desc = req.desc; var isDeleted = req.isDeleted; Dictionary <int, string> dict = FoodTagInfoOper.Instance.GetFoodTypeDict(); string search = req.search == null ? "" : req.search;//搜索内容 string isWeekTemp = req.isWeek; var isMainTemp = req.isMain; var weekTag = req.weekTag; var isDeposit = req.isDeposit; int index = req.index; //页码 int pages = 0; //总页数 int size = 12; //一页size条数据 //查询条件 var condition = " 1=1 and (foodname like '%" + search + "%' or foodText like '%" + search + "%' or foodTagName like '%" + search + "%') "; if (!string.IsNullOrEmpty(isMainTemp)) { var isMain = 0; if (isMainTemp == "true") { isMain = 1; } condition += " and ismain=" + isMain; } if (!string.IsNullOrEmpty(isWeekTemp) && isWeekTemp != "2") { condition += " and isweek=" + isWeekTemp; if (isWeekTemp == "1" && isOn != 2) { condition += " and isOn=" + isOn; } } //else condition += " and isdeleted=0 "; if (!string.IsNullOrEmpty(isWeekTemp) && isWeekTemp != "0") { if (weekTag != 0) { condition += " and foodTagId=" + weekTag; } } if (isDeposit == 1) { condition += " and deposit>0"; } else if (isDeposit == 0) { condition += " and deposit=0"; } string str = "select id,isdeleted from foodview where " + condition; string order = " order by isdeleted,id desc"; if (string.IsNullOrEmpty(orderStr)) { str += order; } else { order = " order by " + orderStr; if (desc == 1) { order += " desc"; } order += " ,isdeleted,id desc"; str += order; } var dt = SqlHelperHere.ExecuteGetDt(str); var listAll = dt.ConvertToList <FoodView>(); if (listAll.Count < 1) { r.data = JsonHelperHere.EmptyJson(); return(JsonConvert.SerializeObject(r)); } //分页 var ids = listAll.Skip((index - 1) * size).Take(size).Select(p => p.id).ToArray(); var idsStr = string.Join(",", ids); var viewList = CacheHelper.GetByCondition <FoodView>("FoodView", " id in (" + idsStr + ") " + order); var count = listAll.Count; pages = count / size; //总页数 pages = pages * size == count ? pages : pages + 1; r.data = JsonHelperHere.JsonAddPage(pages, JsonConvert.SerializeObject(viewList), index); return(JsonConvert.SerializeObject(r)); }