public void UpdateShopStatus(long shopId, ShopInfo.ShopAuditStatus status, string comments = "") { ShopInfo nullable = context.ShopInfo.FindById <ShopInfo>(shopId); nullable.ShopStatus = status; if (!string.IsNullOrWhiteSpace(comments)) { nullable.RefuseReason = comments; } if (nullable.IsSelf) { status = ShopInfo.ShopAuditStatus.Open; } if (status == ShopInfo.ShopAuditStatus.Open) { if (!nullable.IsSelf) { DateTime now = DateTime.Now; nullable.EndDate = new DateTime?(now.AddYears(1)); } else { nullable.ShopStatus = ShopInfo.ShopAuditStatus.Open; DateTime dateTime = DateTime.Now; nullable.EndDate = new DateTime?(dateTime.AddYears(10)); } MessageShopInfo messageShopInfo = new MessageShopInfo() { ShopId = shopId, ShopName = nullable.ShopName, SiteName = Instance <ISiteSettingService> .Create.GetSiteSettings().SiteName }; Task.Factory.StartNew(() => Instance <IMessageService> .Create.SendMessageOnShopAudited(shopId, messageShopInfo)); } if (status == ShopInfo.ShopAuditStatus.WaitPay) { MessageShopInfo messageShopInfo1 = new MessageShopInfo() { ShopId = shopId, ShopName = nullable.ShopName, SiteName = Instance <ISiteSettingService> .Create.GetSiteSettings().SiteName }; Task.Factory.StartNew(() => Instance <IMessageService> .Create.SendMessageOnShopSuccess(shopId, messageShopInfo1)); } if (status == ShopInfo.ShopAuditStatus.Refuse) { nullable.Stage = new ShopInfo.ShopStage?(ShopInfo.ShopStage.CompanyInfo); } nullable.CreateDate = DateTime.Now; context.SaveChanges(); }
public PageModel <ShopInfo> GetShops(ShopQuery shopQueryModel) { IQueryable <ShopInfo> gradeId = context.ShopInfo.AsQueryable <ShopInfo>(); long?shopGradeId = shopQueryModel.ShopGradeId; if ((shopGradeId.GetValueOrDefault() <= 0 ? false : shopGradeId.HasValue)) { gradeId = from item in gradeId where item.GradeId == shopQueryModel.ShopGradeId.Value select item; } if (shopQueryModel.BrandId > 0) { gradeId = from item in gradeId where item.Himall_ShopBrands.Any((ShopBrandsInfo a) => a.BrandId == shopQueryModel.BrandId) select item; } if (shopQueryModel.CategoryId > 0) { gradeId = from item in gradeId where item.Himall_Products.Any((ProductInfo a) => a.CategoryId == shopQueryModel.CategoryId) select item; } if (!string.IsNullOrWhiteSpace(shopQueryModel.ShopName)) { gradeId = from item in gradeId where item.ShopName.Contains(shopQueryModel.ShopName) select item; } if (!string.IsNullOrWhiteSpace(shopQueryModel.ShopAccount)) { gradeId = from item in gradeId where context.ManagerInfo.Any((ManagerInfo m) => m.UserName.Equals(shopQueryModel.ShopAccount) && m.ShopId != 0 && m.RoleId == 0) select item; } if (shopQueryModel.Status.HasValue && shopQueryModel.Status.Value != 0) { ShopInfo.ShopAuditStatus value = shopQueryModel.Status.Value; DateTime dateTime = DateTime.Now.Date.AddSeconds(-1); ShopInfo.ShopAuditStatus shopAuditStatu = value; if (shopAuditStatu == ShopInfo.ShopAuditStatus.HasExpired) { gradeId = from d in gradeId where (int)d.ShopStatus == 7 && (d.EndDate < dateTime) select d; } else { gradeId = (shopAuditStatu != ShopInfo.ShopAuditStatus.Open ? from d in gradeId where (int)d.ShopStatus == (int)value select d : from d in gradeId where (int)d.ShopStatus == 7 && (d.EndDate > dateTime) select d); } } Func <IQueryable <ShopInfo>, IOrderedQueryable <ShopInfo> > func = null; if (shopQueryModel.OrderBy == 1) { DbSet <OrderInfo> orderInfo = context.OrderInfo; func = (IQueryable <ShopInfo> d) => from o in d orderby orderInfo.Where((OrderInfo p) => p.ShopId == o.Id && (int)p.OrderStatus == 5).Count() descending select o; } else { func = (IQueryable <ShopInfo> d) => from o in d orderby o.ShopStatus descending select o; } int num = gradeId.Count(); gradeId = gradeId.GetPage(out num, shopQueryModel.PageNo, shopQueryModel.PageSize, func); foreach (ShopInfo list in gradeId.ToList()) { ManagerInfo managerInfo = context.ManagerInfo.FirstOrDefault((ManagerInfo m) => m.ShopId.Equals(list.Id)); list.ShopAccount = (managerInfo == null ? "" : managerInfo.UserName); } return(new PageModel <ShopInfo>() { Models = gradeId, Total = num }); }