public BaseApiResponse AllGoodses(ListPageRequest request) { request.CheckNotNull(nameof(request)); var currentAccount = _contextService.GetCurrentAccount(HttpContext.Current); var storeInfo = _storeQueryService.InfoByUserId(currentAccount.UserId.ToGuid()); var goodses = _goodsQueryService.GetStoreGoodses(storeInfo.Id); var pageSize = 20; var total = 0; //筛选 if (request.Status != GoodsStatus.All) { goodses = goodses.Where(x => x.Status == request.Status); } if (!request.Name.IsNullOrEmpty()) { goodses = goodses.Where(x => x.Name.Contains(request.Name)); } if (request.IsPublished != "All") { bool isPublished = Convert.ToBoolean(request.IsPublished); goodses = goodses.Where(x => x.IsPublished == isPublished); } total = goodses.Count(); //分页 goodses = goodses.OrderByDescending(x => x.CreatedOn).Skip(pageSize * (request.Page - 1)).Take(pageSize); return(new AllGoodsResponse { Total = total, Goodses = goodses.Select(x => new GoodsDetails { Id = x.Id, StoreId = x.StoreId, Pics = x.Pics.Split("|", true).ToList(), Name = x.Name, Description = x.Description, Price = x.Price, Stock = x.Stock, OriginalPrice = x.OriginalPrice, Benevolence = x.Benevolence, Is7SalesReturn = x.Is7SalesReturn, IsInvoice = x.IsInvoice, IsPayOnDelivery = x.IsPayOnDelivery, CreatedOn = x.CreatedOn, Sort = x.Sort, SellOut = x.SellOut, IsPublished = x.IsPublished, Status = x.Status.ToString(), RefusedReason = x.RefusedReason }).ToList() }); }
public BaseApiResponse HomeInfo([FromBody] InfoRequest request) { request.CheckNotNull(nameof(request)); var storeInfo = _storeQueryService.Info(request.Id); if (storeInfo == null) { return(new BaseApiResponse()); } var goodses = _goodsQueryService.GetStoreGoodses(request.Id).Where(x => x.IsPublished && x.Status == GoodsStatus.Verifyed).OrderByDescending(x => x.CreatedOn).Take(60); if (storeInfo != null) { return(new HomeInfoResponse { StoreInfo = new StoreInfo { Id = storeInfo.Id, AccessCode = storeInfo.AccessCode, Name = storeInfo.Name, Description = storeInfo.Description, Region = storeInfo.Region, Address = storeInfo.Address, Type = storeInfo.Type.ToDescription(), Status = storeInfo.Status.ToDescription() }, SubjectInfo = new SubjectInfo { SubjectName = storeInfo.SubjectName, SubjectNumber = storeInfo.SubjectNumber, SubjectPic = storeInfo.SubjectPic }, Goodses = goodses.Select(x => new Goods { Id = x.Id, Pics = x.Pics.Split("|", true).Select(img => img.ToOssStyleUrl(OssImageStyles.GoodsMainPic.ToDescription())).ToList(), Name = x.Name, Price = x.Price, OriginalPrice = x.OriginalPrice, Benevolence = x.Benevolence, SellOut = x.SellOut }).ToList() }); } else { return(new BaseApiResponse { Code = 400, Message = "没找到店铺" }); } }