Example #1
0
        public JsonResult List(ShopQuery query, string type = "")
        {
            if (type == "Auditing")
            {
                query.Status = ShopInfo.ShopAuditStatus.WaitAudit;
                query.MoreStatus.Add(ShopInfo.ShopAuditStatus.WaitConfirm);
            }
            var shops        = ShopApplication.GetShops(query);
            var shopGrades   = ShopApplication.GetShopGrades();
            var shopAccounts = ShopApplication.GetShopAccounts(shops.Models.Select(p => p.Id).ToList());
            var models       = shops.Models.Select(item =>
            {
                var shopGrade        = shopGrades.FirstOrDefault(p => p.Id == item.GradeId);
                var shopAccountModel = shopAccounts.FirstOrDefault(p => p.ShopId == item.Id);
                var shopbranchs      = ShopBranchApplication.GetShopBranchByShopId(item.Id);
                return(new ShopModel()
                {
                    Id = item.Id,
                    Account = item.ShopAccount,
                    EndDate = type == "Auditing" ? "--" : item.EndDate.HasValue ? item.EndDate.Value.ToString("yyyy-MM-dd") : "",
                    Name = item.ShopName,
                    ShopGrade = shopGrade != null ? shopGrade.Name : "",
                    Status = (item.EndDate < DateTime.Now && item.ShowShopAuditStatus == ShopInfo.ShopAuditStatus.Open) ? "已过期" : item.ShowShopAuditStatus.ToDescription(),
                    IsSelf = item.IsSelf,
                    BusinessType = item.BusinessType == null ? CommonModel.ShopBusinessType.Enterprise : item.BusinessType.Value,
                    Balance = shopAccountModel != null ? shopAccountModel.Balance : 0,
                    ShopBranchCount = shopbranchs.Count()
                });
            });

            var dataGrid = new DataGridModel <ShopModel>()
            {
                rows = models, total = shops.Total
            };

            return(Json(dataGrid));
        }