public ActionResult List(string bigProdNum)
        {
            if (string.IsNullOrEmpty(bigProdNum) || bigProdNum.Length > 7)
            {
                return(Json(OperationResult.Error("参数错误")));
            }
            GridRequest gr = new GridRequest(Request);

            var managedStoreIds = _storeContract.QueryManageStoreId(AuthorityHelper.OperatorId.Value);

            if (managedStoreIds == null || !managedStoreIds.Any())
            {
                return(Json(OperationResult.Error("权限不足")));
            }


            //获取权限之外且不是独立库存的店铺
            var outPermissionAndNotIndependentStoreIds = _storeContract.Stores
                                                         .Where(s => !s.IsDeleted && s.IsEnabled)
                                                         .Where(s => !managedStoreIds.Contains(s.Id))
                                                         .Where(s => !s.StoreType.IndependentStorage)
                                                         .Select(s => s.Id).ToList();


            var list = _productContract.Products.Where(c => !c.IsDeleted && c.IsEnabled)
                       .Where(c => c.BigProdNum.StartsWith(bigProdNum))
                       .Select(c => new SearchEnry
            {
                Id            = c.Id,
                ProductNumber = c.ProductNumber,
                ThumbnailPath = c.ThumbnailPath ?? c.ProductOriginNumber.ThumbnailPath,
                IconPath      = c.Color.IconPath,
                BrandName     = c.ProductOriginNumber.Brand.BrandName,
                SizeName      = c.Size.SizeName,
                CategoryName  = c.ProductOriginNumber.Category.CategoryName,
                ColorName     = c.Color.ColorName,
                SeasonName    = c.ProductOriginNumber.Season.SeasonName,
                TagPrice      = c.ProductOriginNumber.TagPrice,
                Cou           = _inventoryContract.Inventorys.Where(i => i.IsEnabled && !i.IsDeleted)
                                .Where(i => i.ProductId == c.Id)
                                .Where(i => i.Status == (int)InventoryStatus.Default && !i.IsLock)
                                .Where(i => managedStoreIds.Contains(i.StoreId) || outPermissionAndNotIndependentStoreIds.Contains(i.StoreId))
                                .Count()
            }).ToList();



            GridData <object> grdat = new GridData <object>(list, list.Count, Request);

            return(Json(grdat));
        }
Beispiel #2
0
        public async Task <ActionResult> GetHistoryApply(string number, int pageIndex = 1, int pageSize = 10)
        {
            try
            {
                var storeIds = _storeContract.QueryManageStoreId(AuthorityHelper.OperatorId.Value);

                var departmentIds = _storeContract.QueryAllStore().Where(s => storeIds.Contains(s.Id)).Select(s => s.DepartmentId.Value).ToList();

                var query = _timeoutRequestContract.Entities.Where(r => !r.IsDeleted && r.IsEnabled && departmentIds.Contains(r.DepartmentId));
                if (!string.IsNullOrWhiteSpace(number))
                {
                    query = query.Where(r => r.Number.StartsWith(number));
                }
                var data = await query.OrderByDescending(r => r.UpdatedTime)
                           .Select(r => new { r.Number, r.CreatedTime, State = r.State.ToString(), TimeoutType = r.TimeoutType.Name, DepartmentName = r.Department.DepartmentName })
                           .Skip((pageIndex - 1) * pageSize).Take(pageSize)
                           .ToListAsync();

                var res = data.Select(r => new
                {
                    CreatedTime = r.CreatedTime.ToUnixTime(),
                    r.DepartmentName,
                    r.Number,
                    r.State,
                    r.TimeoutType
                });
                return(Json(OperationResult.OK(res), JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(OperationResult.Error(e.Message)));
            }
        }
Beispiel #3
0
        public ActionResult List()
        {
            List <int>    s_List     = _storeContract.QueryManageStoreId(AuthorityHelper.OperatorId.Value);
            List <object> list       = new List <object>();
            var           datasource = _videoEquipmentContract.VideoEquipments.Where(x => x.IsDeleted == false && x.IsEnabled == true &&
                                                                                     s_List.Contains(x.StoreId)).Select(x => new
            {
                x.snNumber,
                x.VideoName,
                x.Store.StoreName
            });

            foreach (var item in datasource)
            {
                var da = new
                {
                    item.VideoName,
                    item.StoreName,
                    item.snNumber,
                    isOnline      = CheckIsOnline(item.snNumber),
                    channelPicUrl = GetChannelPicUrl(item.snNumber)
                };
                list.Add(da);
            }
            return(Json(list));
        }
        /// <summary>
        /// 获取充值活动
        /// </summary>
        /// <param name="MemberType">会员类型</param>
        /// <returns></returns>
        public JsonResult GetRechargeActivity(int MemberTypeId)
        {
            // 店铺权限
            var      storeIds = _storeContract.QueryManageStoreId(AuthorityHelper.OperatorId.Value);
            DateTime dateNow  = Convert.ToDateTime(DateTime.Now.ToString("yy/MM/dd"));
            IQueryable <MemberActivity> listMemberActs = _memberActivityContract.MemberActivitys
                                                         .Where(x => !x.IsDeleted && x.IsEnabled)
                                                         .Where(x => x.IsForever == true || (dateNow.CompareTo(x.StartDate) >= 0) && dateNow.CompareTo(x.EndDate) <= 0) //有效期
                                                         .Where(x => x.MemberTypes.Any(k => k.Id == MemberTypeId));                                                     //会员类型


            var memberActs = listMemberActs.Select(x => new
            {
                x.Id,
                x.ActivityName,
                x.Score,
                x.Price,
                x.ActivityType,
                x.RewardMoney,
                x.StoreIds,
                x.IsAllStore
            }).ToList()
                             .Select(x => new
            {
                x.Id,
                x.ActivityName,
                x.Score,
                x.Price,
                x.ActivityType,
                x.RewardMoney,
                StoreIds = string.IsNullOrEmpty(x.StoreIds) ? new List <int>() :
                           x.StoreIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                           .Select(i => int.Parse(i)).ToList(),
                x.IsAllStore
            }).ToList();

            //  过滤掉非全部店铺且参与店铺不在权限店铺范围的活动
            memberActs.RemoveAll(x => !x.IsAllStore && !x.StoreIds.Intersect(storeIds).Any());


            return(Json(memberActs, JsonRequestBehavior.AllowGet));
        }
        public ActionResult List()
        {
            var             count   = 0;
            OperationResult resul   = new OperationResult(OperationResultType.Error);
            GridRequest     request = new GridRequest(Request);
            Expression <Func <VideoEquipment, bool> > predicate = FilterHelper.GetExpression <VideoEquipment>(request.FilterGroup);

            List <int> s_List    = _storeContract.QueryManageStoreId(AuthorityHelper.OperatorId.Value);
            int        PageIndex = request.PageCondition.PageIndex + 1;
            var        allVideo  = _videoEquipmentContract.VideoEquipments.Where(x => s_List.Contains(x.StoreId));
            var        da        = allVideo
                                   .Where <VideoEquipment, int>(predicate, request.PageCondition, out count)
                                   //.Skip(request.PageCondition.PageIndex * request.PageCondition.PageSize).Take(PageIndex * request.PageCondition.PageSize)
                                   .Select(c => new
            {
                c.VideoName,
                c.snNumber,
                c.Store.StoreName,
                c.Id,
                c.CreatedTime,
                c.Operator.Member.MemberName,
                c.IsDeleted,
                c.IsEnabled
            }).ToList();
            List <object> list = new List <object>();

            foreach (var item in da)
            {
                //int useCount = GetUseVideoCount(item.Id);
                var datasource = new
                {
                    VideoName = item.VideoName,
                    snNumber  = item.snNumber,
                    StoreName = item.StoreName,
                    useCount  = 0,
                    item.Id,
                    channelPicUrl = GetChannelPicUrl(item.snNumber),
                    CreatedTime   = item.CreatedTime,
                    MemberName    = item.MemberName,
                    isOnline      = CheckIsOnline(item.snNumber),
                    item.IsEnabled,
                    item.IsDeleted
                };
                list.Add(datasource);
            }
            GridData <object> data = new GridData <object>(list, count, request.RequestInfo);

            return(Json(data));
        }
Beispiel #6
0
        public ActionResult Index()
        {
            string cheitenid = Request["chitnum"];

            if (!string.IsNullOrEmpty(cheitenid))
            {
                //int _id = int.Parse(cheitenid);
                var checkiem = _checkerItemContract.CheckerItems.Where(c => c.CheckGuid == cheitenid).FirstOrDefault();
                if (checkiem != null)
                {
                    var check = _checkerContract.Checkers.Where(c => c.CheckGuid == checkiem.CheckGuid).FirstOrDefault();
                    ViewBag.CheckItemId = cheitenid;
                    if (check != null)
                    {
                        ViewBag.Stores = check.StoreId;

                        ViewBag.Storages = new List <SelectListItem>()
                        {
                            new SelectListItem()
                            {
                                Text  = check.Storage.StorageName,
                                Value = check.StorageId.ToString()
                            }
                        };
                        ViewBag.CheckNum  = check.CheckGuid;
                        ViewBag.CheckName = check.CheckerName;
                        ViewBag.StartDate = check.CreatedTime.ToString("yyyy/MM/dd HH:mm:ss");
                        ViewBag.EndDate   = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                    }
                }
            }
            else
            {
                ViewBag.Stores      = string.Empty;
                ViewBag.CheckItemId = -1;
                var stores = _storeContract.QueryManageStoreId(AuthorityHelper.OperatorId.Value);
                if (!stores.Any())
                {
                    ViewBag.Storages = new List <SelectListItem>();
                }
                else
                {
                    var firStore = stores.FirstOrDefault();
                    ViewBag.Storages = CacheAccess.GetManagedStorageByStoreId(_storageContract, _adminContract, firStore, true);
                }
            }

            return(View());
        }
Beispiel #7
0
        public async Task <ActionResult> GetBoxToAccept(AppointmentState filter = AppointmentState.已装箱)
        {
            try
            {
                var storeId = _storeContract.QueryManageStoreId(AuthorityHelper.OperatorId.Value)?.FirstOrDefault();
                if (!storeId.HasValue)
                {
                    return(Json(OperationResult.Error("店铺权限不足"), JsonRequestBehavior.AllowGet));
                }
                var res = await _appointmentContract.GetBoxToAccept(storeId.Value, filter);

                return(Json(res, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(OperationResult.Error("系统错误"), JsonRequestBehavior.AllowGet));
            }
        }
        /// <summary>
        /// 查询数据
        /// </summary>
        /// <returns></returns>
        public ActionResult List(string number, DateTime?startDate, DateTime?endDate, string ids, bool isEnabled = true, int pageIndex = 1, int pageSize = 10)
        {
            var storeIds = _storeContract.QueryManageStoreId(AuthorityHelper.OperatorId.Value);

            var query = _contract.Entities;

            query = query.Where(e => e.IsEnabled == isEnabled && storeIds.Contains(e.Appointment.StoreId));


            if (startDate.HasValue)
            {
                query = query.Where(e => e.CreatedTime >= startDate.Value);
            }
            if (endDate.HasValue)
            {
                query = query.Where(e => e.CreatedTime <= endDate.Value);
            }


            if (!string.IsNullOrEmpty(number) && number.Length > 0)
            {
                query = query.Where(e => e.Appointment.Number.StartsWith(number));
            }



            if (!string.IsNullOrEmpty(ids) && ids.Length > 0)
            {
                var idArr = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(i => int.Parse(i));
                query = query.Where(e => idArr.Contains(e.Id));
            }

            var list = query.OrderByDescending(e => e.UpdatedTime)
                       .Skip((pageIndex - 1) * pageSize)
                       .Take(pageSize)
                       .Select(e => new
            {
                e.ProductNumber,
                e.Appointment.Number,
                ProductCollocationImg = e.Product.ProductCollocationImg ?? e.Product.ProductOriginNumber.ProductCollocationImg,
                e.Feedbacks,
                e.Id,
                e.Appointment.Store.StoreName,
                e.Appointment.Member.RealName,
                e.IsDeleted,
                e.IsEnabled,
                e.CreatedTime,
                e.UpdatedTime,
                e.Operator.Member.MemberName
            }).ToList();


            var res = new OperationResult(OperationResultType.Success, string.Empty, new
            {
                pageData = list,
                pageInfo = new PageDto
                {
                    pageIndex  = pageIndex,
                    pageSize   = pageSize,
                    totalCount = query.Count(),
                }
            });

            return(Json(res, JsonRequestBehavior.AllowGet));
        }
Beispiel #9
0
        public ActionResult List(DateTime startDate, DateTime endDate)
        {
            var rq        = new GridRequest(Request);
            var startTime = startDate.Date;
            var endTime   = endDate.Date.AddDays(1).AddSeconds(-1);
            var pred      = FilterHelper.GetExpression <StoreStatistics>(rq.FilterGroup);
            var spendpred = FilterHelper.GetExpression <StoreSpendStatistics>(rq.FilterGroup);
            var storeids  = _storeContract.QueryManageStoreId(AuthorityHelper.OperatorId.Value);

            var alldat = _storeStatisticsContract.StoreStatistics
                         .Where(pred)
                         .Where(c => c.CreatedTime >= startTime && c.CreatedTime <= endTime)
                         .Where(c => storeids.Contains(c.StoreId))
                         .GroupBy(c => c.StoreId)
                         .OrderBy(c => c.Key);
            var storeStatData = alldat.Skip(rq.PageCondition.PageIndex).Take(rq.PageCondition.PageSize).ToList().Select(c => new
            {
                c.FirstOrDefault().Store.Id,
                c.FirstOrDefault().Store.StoreName,
                Gain = c.Sum(g => g.Gain),
                Cost = c.Sum(g => g.Cost),
            }).ToList();

            var allspenddata = _storeSpendStatisticsContract.StoreStatistics
                               .Where(spendpred)
                               .Where(c => c.CreatedTime >= startTime && c.CreatedTime <= endTime)
                               .Where(c => storeids.Contains(c.StoreId))
                               .GroupBy(c => c.StoreId)
                               .OrderBy(c => c.Key);
            var spenddat =
                allspenddata.Skip(rq.PageCondition.PageIndex)
                .Take(rq.PageCondition.PageSize)
                .ToList()
                .Select(c => new
            {
                StoreId = c.Key,
                Amount  = c.GroupBy(g => g.SpendType).Select(g => new
                {
                    SpendType = g.Key,
                    Amount    = g.Sum(t => t.Amount),
                })
            }).ToList();

            List <Dictionary <string, string> > dicList = new List <Dictionary <string, string> >();

            foreach (var statItem in storeStatData)
            {
                Dictionary <string, string> dic = new Dictionary <string, string>();
                var storeid = statItem.Id;
                dic.Add("StoreId", storeid.ToString());
                dic.Add("StoreName", statItem.StoreName);
                dic.Add("Gain", statItem.Gain.ToString());
                dic.Add("Cost", statItem.Cost.ToString());
                var   spendStat = spenddat.Find(c => c.StoreId == storeid);
                float spendAoun = 0;
                if (spendStat != null)
                {
                    spendAoun = spendStat.Amount.Sum(c => c.Amount);
                    foreach (var amount in spendStat.Amount)
                    {
                        dic.Add(Enum.GetName(typeof(SpendType), amount.SpendType), amount.Amount.ToString());
                    }
                }
                else
                {
                    dic["WaterRate"]      = "";
                    dic["ElectricCharge"] = "";
                    dic["Chummage"]       = "";
                    dic["Incidentals"]    = "";
                    dic["Taxes"]          = "";
                    dic["SalaryCoun"]     = "";
                    dic["Tending"]        = "";
                    dic["Other"]          = "";
                }

                var profit = (float)statItem.Gain - spendAoun;
                dic.Add("Profit", profit.ToString());
                dicList.Add(dic);
            }
            List <object> li = new List <object>();
            var           te = "";

            foreach (var dic in dicList)
            {
                li.Add(new
                {
                    Id             = dic["StoreId"],
                    StoreName      = dic["StoreName"],
                    Gain           = dic["Gain"],
                    Cost           = dic["Cost"],
                    Profit         = dic["Profit"],
                    WaterRate      = dic.TryGetValue("WaterRate", out te) ? te : "",
                    ElectricCharge = dic.TryGetValue("ElectricCharge", out te) ? te : "",
                    Chummage       = dic.TryGetValue("Chummage", out te) ? te : "",
                    Incidentals    = dic.TryGetValue("Incidentals", out te) ? te : "",
                    Taxes          = dic.TryGetValue("Taxes", out te) ? te : "",
                    SalaryCoun     = dic.TryGetValue("SalaryCoun", out te) ? te : "",
                    Tending        = dic.TryGetValue("Tending", out te) ? te : "",
                    Other          = dic.TryGetValue("Other", out te) ? te : "",
                });
            }

            int cou = alldat.Count();
            GridData <object> data = new GridData <object>(li, cou, Request);

            return(Json(data));
        }
        /// <summary>
        /// 查询数据
        /// </summary>
        /// <returns></returns>
        public async Task <ActionResult> ListAsync(string number, int?storeId, int?categoryId, int?brandId, int?colorId, string realName, string mobilePhone, AppointmentState?state, DateTime?startDate, DateTime?endDate, bool isEnabled = true, int pageIndex = 1, int pageSize = 10)
        {
            var storeIds = _storeContract.QueryManageStoreId(AuthorityHelper.OperatorId.Value);

            var query = _appointmentContract.Entities.Where(p => storeIds.Contains(p.StoreId));

            if (storeId.HasValue)
            {
                query = query.Where(p => p.StoreId == storeId.Value);
            }

            if (!string.IsNullOrEmpty(number) && number.Length > 0)
            {
                query = query.Where(e => e.Number.StartsWith(number));
            }


            if (!string.IsNullOrEmpty(realName) && realName.Length > 0)
            {
                query = query.Where(p => p.Member.RealName.StartsWith(realName));
            }
            if (!string.IsNullOrEmpty(mobilePhone) && mobilePhone.Length > 0)
            {
                query = query.Where(p => p.Member.MobilePhone.StartsWith(mobilePhone));
            }

            if (startDate.HasValue)
            {
                query = query.Where(e => e.CreatedTime >= startDate.Value);
            }
            if (endDate.HasValue)
            {
                query = query.Where(e => e.CreatedTime <= endDate.Value);
            }
            if (state.HasValue)
            {
                query = query.Where(p => p.State == state.Value);
            }
            var list = await query.OrderByDescending(a => a.UpdatedTime)
                       .Skip((pageIndex - 1) * pageSize)
                       .Take(pageSize)
                       .Select(s => new
            {
                s.Id,
                s.Number,
                s.MemberId,
                s.Member.RealName,
                s.Member.UniquelyIdentifies,
                s.Member.UserPhoto,
                s.Member.MobilePhone,
                s.Store.StoreName,
                s.ProductNumber,
                s.CreatedTime,
                s.UpdatedTime,
                s.State,
                s.SelectedPlanId,
                s.DislikeProductNumbers,
                s.StartTime,
                s.EndTime,
                Quantity = s.AppointmentPacking.AppointmentPackingItem.Count,
                s.AppointmentType,
            }).ToListAsync();

            var data = list.Select(s => new
            {
                s.Id,
                s.SelectedPlanId,
                s.MemberId,
                RealName = s.AppointmentType == AppointmentType.自助 ? s.RealName : s.UniquelyIdentifies,
                s.StoreName,
                ProductNumber         = s.ProductNumber ?? string.Empty,
                DislikeProductNumbers = s.DislikeProductNumbers ?? string.Empty,
                Number = s.Number ?? string.Empty,
                s.MobilePhone,
                s.UserPhoto,
                s.UpdatedTime,
                s.CreatedTime,
                StartTime = s.StartTime.HasValue ? s.StartTime.Value.ToString("MM-dd HH:mm") : string.Empty,
                EndTime   = s.EndTime.HasValue ? s.EndTime.Value.ToString("MM-dd HH:mm") : string.Empty,
                State     = s.State.ToString(),
                s.Quantity,
                AppointmentTypeName = s.AppointmentType + ""
            }).ToList();

            var res = new OperationResult(OperationResultType.Success, string.Empty, new
            {
                pageData = data,
                pageInfo = new PageDto
                {
                    pageIndex  = pageIndex,
                    pageSize   = pageSize,
                    totalCount = query.Count(),
                }
            });

            return(Json(res, JsonRequestBehavior.AllowGet));
        }
        public ActionResult List(int?storeId, int?startDate, int?endDate)
        {
            var rq          = new GridRequest(Request);
            var pred        = FilterHelper.GetExpression <StoreStatistics>(rq.FilterGroup);
            var storeids    = new List <int>();
            var currentDate = int.Parse(DateTime.Now.ToString(DATE_FORMAT));

            if (storeId.HasValue)
            {
                storeids.Add(storeId.Value);
            }
            else
            {
                storeids.AddRange(_storeContract.QueryManageStoreId(AuthorityHelper.OperatorId.Value));
            }

            var query = _storeStatisticsContract.StoreStatistics
                        .Where(c => storeids.Contains(c.StoreId) && (!c.Store.IsDeleted && c.Store.IsEnabled));

            if (startDate.HasValue && endDate.HasValue)
            {
                query = query.Where(c => c.StatDate >= startDate.Value && c.StatDate <= endDate.Value);
            }

            //根据店铺分组
            var groupedStatList = query.GroupBy(c => c.StoreId).OrderBy(c => c.Key);
            Func <int, int, string> getInventory = (sid, date) =>
            {
                var entity = _storeStatisticsContract.StoreStatistics.FirstOrDefault(s => s.StatDate == date && s.StoreId == sid);

                return(entity.InventoryCount.HasValue ? entity.InventoryCount.Value.ToString() : "无信息");
            };
            var resd = groupedStatList.Skip(rq.PageCondition.PageIndex).Take(rq.PageCondition.PageSize).ToList().Select(c => new
            {
                // 基础信息
                c.Key,
                c.FirstOrDefault().Store.Id,
                c.FirstOrDefault().StoreName,
                c.FirstOrDefault().Store.IsClosed,
                // 销售
                RetailOrderCount = c.Sum(g => g.RetailOrderCount),
                RetailCount      = c.Sum(g => g.RetailCount),
                RetailAmount     = c.Sum(g => g.RetailAmount),
                RealRetailAmount = c.Sum(g => g.RealRetailAmount),
                // 退货
                ReturnedCount      = c.Sum(g => g.ReturnedCount),
                ReturnedAmount     = c.Sum(g => g.ReturnedAmount),
                ReturnedOrderCount = c.Sum(g => g.ReturnedOrderCount),
                RealReturnedAmount = (float)Math.Round(c.Sum(g => g.RealReturnedAmount), 2),
                EmployeeCoun       = c.SelectMany(g => g.EmployeeIdsFromOrder.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)).Distinct().Count(),
                AddMembCoun        = c.Sum(g => g.AddMemberCount),

                // 换货
                ExchangeOrderNewProductQuantity    = c.Sum(g => g.ExchangeOrderNewProductQuantity),
                ExchangeOrderOriginProductQuantity = c.Sum(g => g.ExchangeOrderOriginProductQuantity),
                ExchangeOrderPayAmount             = c.Sum(g => g.ExchangeOrderPayAmount),

                // 储值,积分
                RechargeBalanceCoun         = c.Sum(g => g.MemberCountFromRechargeBalance),
                RechargeScoreCoun           = c.Sum(g => g.MemberCountFromRechargeScore),
                MemberRechargeBalanceAmount = c.Sum(g => g.MemberRechargeBalanceAmount),
                MemberRechargeScoreAmount   = c.Sum(g => g.MemberRechargeScoreAmount),

                // 盈利成本
                Cost = c.Sum(g => g.Cost),
                Gain = c.Sum(g => g.Gain),

                // 配货单发货,收货
                OrderblankDeliverCount = c.Sum(g => g.OrderblankDeliverCount),
                OrderblankAcceptCount  = c.Sum(g => g.OrderblankAcceptCount),


                // 库存
                InventoryCount = (startDate.HasValue && endDate.HasValue && startDate == endDate) ? getInventory(storeId.HasValue ? storeId.Value : c.FirstOrDefault().Store.Id, startDate.Value) : "无信息",
            }).ToList();


            int cou = groupedStatList.Count();
            GridData <object> data = new GridData <object>(resd, cou, Request);

            return(Json(data));
        }
        /// <summary>
        /// 查询数据
        /// </summary>
        /// <returns></returns>
        //public async Task<ActionResult> List()
        //{
        //    GridRequest request = new GridRequest(Request);
        //    try
        //    {
        //        Expression<Func<Checker, bool>> predicate = FilterHelper.GetExpression<Checker>(request.FilterGroup);
        //        List<CheckedDto_t> li = new List<CheckedDto_t>();
        //        var data = await Task.Run(() =>
        //        {
        //            var count = 0;
        //            var list = _checkerContract.Checkers.Where<Checker, int>(predicate, request.PageCondition, out count).Select(m => new CheckedDto_t()
        //            {
        //                Id = m.CheckGuid,
        //                ParentId = "",
        //                StoreName = m.Store.StoreName,
        //                StorageName = m.Storage.StorageName,
        //                CheckerName = m.CheckerName,
        //                CheckCount = m.CheckCount,
        //                CheckedCount = m.CheckedCount,
        //                ValidCount = m.ValidCount,
        //                InvalidCount = m.InvalidCount,
        //                ResidueCount = m.ResidueCount,
        //                MissingCount = m.MissingCount,
        //                Notes = m.Notes,
        //                CreatedTime = m.UpdatedTime,
        //                CheckerState = m.CheckerState,
        //                AdminName = m.Operator.AdminName
        //            }).OrderByDescending(c=>c.CreatedTime).ToList();
        //            foreach (var item in list)
        //            {
        //                string checkGuid = item.Id;
        //                var chil = _checkerItemContract.CheckerItems.Where(c => c.CheckGuid == checkGuid).ToList().Select(c => new CheckedDto_t()
        //                {
        //                    Id = c.Id.ToString(),
        //                    ParentId = c.CheckGuid,
        //                    StoreName = item.StoreName,
        //                    StorageName = item.StorageName,
        //                    CheckerName = item.CheckerName,
        //                    CheckCount = GetCheckItemCou(c.CheckCount),
        //                    CheckedCount = GetCheckItemCou(c.CheckedCount),
        //                    ValidCount = GetCheckItemCou(c.ValidCount),
        //                    InvalidCount = GetCheckItemCou(c.InvalidCount),
        //                    ResidueCount = GetCheckItemCou(c.ResidueCount),
        //                    MissingCount = GetCheckItemCou(c.MissingCount),
        //                    Notes = c.Notes,
        //                    CreatedTime = c.CreatedTime,
        //                    CheckerState = c.CheckerState,
        //                    AdminName = item.AdminName
        //                }).OrderByDescending(c=>c.CreatedTime).ToList();
        //               // chil.Remove(chil[0]);
        //                li.Add(item);
        //                li.AddRange(chil);

        //            }
        //            return new GridData<object>(li, count, request.RequestInfo);
        //        });
        //        return Json(data, JsonRequestBehavior.AllowGet);
        //    }
        //    catch (Exception)
        //    {

        //        return Json(new GridData<object>(new List<object>(), 0, request.RequestInfo));
        //    }

        //}
        #endregion

        #region 获取数据列表
        public ActionResult List()
        {
            GridRequest request = new GridRequest(Request);

            try
            {
                var optId = AuthorityHelper.OperatorId;
                if (!optId.HasValue)
                {
                    throw new Exception("optId is null");
                }
                Expression <Func <Checker, bool> > predicate = FilterHelper.GetExpression <Checker>(request.FilterGroup);



                List <CheckedDto_t> li = new List <CheckedDto_t>();

                var count = 0;
                IQueryable <Checker> listChecker = _checkerContract.Checkers.OrderByDescending(c => c.CreatedTime)
                                                   .Where(x => x.IsEnabled == true && x.IsDeleted == false);
                Dictionary <string, Checker> dic = new Dictionary <string, Checker>();
                foreach (Checker checker in listChecker)
                {
                    int index = dic.Where(x => x.Value.StoreId == checker.StoreId && x.Value.StorageId == checker.StorageId).Count();
                    if (index > 0)
                    {
                        continue;
                    }
                    else
                    {
                        if (!dic.ContainsKey(checker.CheckGuid))
                        {
                            dic.Add(checker.CheckGuid, new Checker()
                            {
                                StoreId = checker.StoreId, StorageId = checker.StorageId
                            });
                        }
                    }
                }

                IQueryable <Brand>    listBrand    = _brandContract.Brands.Where(x => x.IsDeleted == false && x.IsEnabled == true);
                IQueryable <Category> listCategory = _categoryContract.Categorys.Where(x => x.IsDeleted == false && x.IsEnabled == true);
                var query = _checkerContract.Checkers;
                if (request.FilterGroup.Rules.Count(i => i.Field == "StorageId") <= 0)
                {
                    var enableStoreIds = _storeContract.QueryManageStoreId(AuthorityHelper.OperatorId.Value);
                    query = query.Where(c => enableStoreIds.Contains(c.StoreId));
                }
                var list = query.OrderByDescending(c => c.CreatedTime).Where <Checker, int>(predicate, request.PageCondition, out count).Select(m => new CheckedDto_t()
                {
                    Id           = m.CheckGuid,
                    ParentId     = "",
                    StoreName    = m.Store.StoreName,
                    StorageName  = m.Storage.StorageName,
                    BrandName    = listBrand.FirstOrDefault(x => x.Id == m.BrandId) == null ? "全部" : listBrand.FirstOrDefault(x => x.Id == m.BrandId).BrandName,
                    CategoryName = listCategory.FirstOrDefault(x => x.Id == m.CategoryId) == null ? "全部" : listCategory.FirstOrDefault(x => x.Id == m.CategoryId).CategoryName,
                    //Quantity=m.Quantity,
                    CheckerName = m.CheckerName,
                    //CheckCount = m.CheckQuantity,
                    BeforeCheckQuantity = m.BeforeCheckQuantity,
                    CheckedQuantity     = m.CheckedQuantity,
                    CheckedCount        = m.ValidQuantity + m.ResidueQuantity + m.MissingQuantity,
                    ValidCount          = m.ValidQuantity,
                    //InvalidCount = m.InvalidQuantity,
                    ResidueCount = m.ResidueQuantity,
                    MissingCount = m.MissingQuantity,
                    Notes        = m.Notes,
                    CreatedTime  = m.UpdatedTime,
                    CheckerState = m.CheckerState,
                    AdminName    = m.Operator.Member.MemberName,
                }).ToList();
                foreach (var item in list)
                {
                    item.IsIndex = dic.ContainsKey(item.Id);
                }

                var data = new GridData <object>(list, count, request.RequestInfo);
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new GridData <object>(new List <object>(), 0, request.RequestInfo)));
            }
        }