Ejemplo n.º 1
0
        public async Task <IActionResult> GetStoreUserList(Input_SUSearch model, [FromServices] ContextString dbContext)
        {
            QianMuResult _Result = new QianMuResult();
            Stream       stream  = HttpContext.Request.Body;

            byte[] buffer = new byte[HttpContext.Request.ContentLength.Value];
            stream.Read(buffer, 0, buffer.Length);
            string inputStr = Encoding.UTF8.GetString(buffer);

            model = (Input_SUSearch)Newtonsoft.Json.JsonConvert.DeserializeObject(inputStr, model.GetType());
            if (string.IsNullOrEmpty(model.MallCode))
            {
                //检测用户登录情况
                var uol = Method.GetLoginUserName(dbContext, this.HttpContext);
                if (string.IsNullOrEmpty(uol.UserName))
                {
                    _Result.Code = "401";
                    _Result.Msg  = "请登陆后再进行操作";
                    _Result.Data = "";
                    return(Json(_Result));
                }
                else
                {
                    model.MallCode = uol.MallCode;
                    //   model.UserName = uol.UserName;
                }
            }
            var list = await dbContext.MallShop.Where(i => i.MallCode == model.MallCode).Join(dbContext.Shops.Where(i => !i.IsDel), ms => ms.ShopCode, sh => sh.Code, (ms, sh) => new
            {
                sh.HouseNum,
                sh.Name,
                sh.Code
            }).Join(dbContext.ShopAccount, sh => sh.Code, sa => sa.ShopCode, (sh, sa) => new
            {
                sa.Code,
                sh.HouseNum,
                sh.Name,
                sa.Phone,
                OrerTime = sa.AddTime,
                AddTime  = sa.AddTime.ToString("yyyy-MM-dd")
            }).OrderByDescending(i => i.OrerTime).ToListAsync();

            if (!string.IsNullOrEmpty(model.SearchName))
            {
                list = list.Where(i => i.HouseNum.Contains(model.SearchName) || i.Name.Contains(model.SearchName) || i.Phone.Contains(model.SearchName)).ToList();
            }

            if (model.Paging == null)
            {
                model.Paging = 0;
            }

            if (model.PageIndex == null)
            {
                model.PageIndex = 1;
            }

            if (model.PageSize == null)
            {
                model.PageSize = 10;
            }

            if (model.Paging == 0)
            {
                _Result.Code = "200";
                _Result.Msg  = "获取成功";
                _Result.Data = list;
            }
            else
            {
                int allPage  = 1;
                int allCount = list.Count();
                allPage = (int)(allCount / model.PageSize);
                if (allCount % model.PageSize > 0)
                {
                    allPage = allPage + 1;
                }

                list = list.Skip(((int)model.PageIndex - 1) * (int)model.PageSize).Take((int)model.PageSize).ToList();

                _Result.Code = "200";
                _Result.Msg  = "获取成功";
                _Result.Data = new { List = list, AllPage = allPage, AllCount = allCount };
            }


            return(Json(_Result));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetStoreUserListByManage(Input_SUSearch model, [FromServices] ContextString dbContext)
        {
            QianMuResult _Result = new QianMuResult();
            Stream       stream  = HttpContext.Request.Body;

            byte[] buffer = new byte[HttpContext.Request.ContentLength.Value];
            stream.Read(buffer, 0, buffer.Length);
            string inputStr = Encoding.UTF8.GetString(buffer);

            model = (Input_SUSearch)Newtonsoft.Json.JsonConvert.DeserializeObject(inputStr, model.GetType());

            /*
             * var list = await dbContext.MallShop.Where(i => i.MallCode == model.MallCode || string.IsNullOrEmpty(model.MallCode)).Join(dbContext.Shops.Where(i => !i.IsDel), ms => ms.ShopCode, sh => sh.Code, (ms, sh) => new
             * {
             *  sh.HouseNum,
             *  sh.Name,
             *  sh.Code,
             *  ms.MallCode
             * }).Join(dbContext.ShopAccount, sh => sh.Code, sa => sa.ShopCode, (sh, sa) => new
             * {
             *  sa.Code,
             *  sh.HouseNum,
             *  sh.Name,
             *  sa.Phone,
             *  OrerTime = sa.AddTime,
             *  AddTime = sa.AddTime.ToString("yyyy-MM-dd"),
             *  sh.MallCode
             * }).Join(dbContext.Mall,ms=> ms.MallCode,m=>m.Code,(ms,m)=>new {
             *  ms.Code,
             *  ms.HouseNum,
             *  ms.Name,
             *  ms.Phone,
             *  ms.OrerTime,
             *  ms.AddTime,
             *  MallName=m.Name
             * }).OrderByDescending(i => i.OrerTime).ToListAsync();
             */

            var list = await dbContext.Mall.Where(i => (string.IsNullOrEmpty(model.ProvinceID) || i.ProvinceID == model.ProvinceID) &&
                                                  (string.IsNullOrEmpty(model.CityID) || i.CityID == model.CityID)).Join(dbContext.MallShop.Where(i => i.MallCode == model.MallCode || string.IsNullOrEmpty(model.MallCode)), m => m.Code, ms => ms.MallCode, (m, ms) => ms).Join(dbContext.Shops.Where(i => !i.IsDel), ms => ms.ShopCode, sh => sh.Code, (ms, sh) => new
            {
                sh.HouseNum,
                sh.Name,
                sh.Code,
                ms.MallCode
            }).Join(dbContext.ShopAccount, sh => sh.Code, sa => sa.ShopCode, (sh, sa) => new
            {
                sa.Code,
                sh.HouseNum,
                sh.Name,
                sa.Phone,
                OrerTime = sa.AddTime,
                AddTime  = sa.AddTime.ToString("yyyy-MM-dd"),
                sh.MallCode
            }).Join(dbContext.Mall, ms => ms.MallCode, m => m.Code, (ms, m) => new {
                ms.Code,
                ms.HouseNum,
                ms.Name,
                ms.Phone,
                ms.OrerTime,
                ms.AddTime,
                MallName = m.Name
            }).OrderByDescending(i => i.OrerTime).ToListAsync();

            if (!string.IsNullOrEmpty(model.SearchName))
            {
                list = list.Where(i => i.HouseNum.Contains(model.SearchName) || i.Name.Contains(model.SearchName) || i.Phone.Contains(model.SearchName)).ToList();
            }

            if (model.Paging == null)
            {
                model.Paging = 0;
            }

            if (model.PageIndex == null)
            {
                model.PageIndex = 1;
            }

            if (model.PageSize == null)
            {
                model.PageSize = 10;
            }

            if (model.Paging == 0)
            {
                _Result.Code = "200";
                _Result.Msg  = "获取成功";
                _Result.Data = list;
            }
            else
            {
                int allPage  = 1;
                int allCount = list.Count();
                allPage = (int)(allCount / model.PageSize);
                if (allCount % model.PageSize > 0)
                {
                    allPage = allPage + 1;
                }

                list = list.Skip(((int)model.PageIndex - 1) * (int)model.PageSize).Take((int)model.PageSize).ToList();

                _Result.Code = "200";
                _Result.Msg  = "获取成功";
                _Result.Data = new { List = list, AllPage = allPage, AllCount = allCount };
            }


            return(Json(_Result));
        }