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 Info() { var currentAccount = _contextService.GetCurrentAccount(HttpContext); var storeInfo = _storeQueryService.InfoByUserId(currentAccount.UserId.ToGuid()); if (storeInfo == null) { return(new BaseApiResponse { Code = 400, Message = "没有店铺" }); } //获取未发货订单 var placedStoreOrderes = _storeOrderQueryService.StoreStoreOrderDetails(storeInfo.Id, StoreOrderStatus.Placed); return(new StoreInfoResponse { 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 }, StatisticsInfo = new StatisticsInfo { TodaySale = storeInfo.TodaySale, TodayOrder = storeInfo.TodayOrder, TotalSale = storeInfo.TotalSale, TotalOrder = storeInfo.TotalOrder }, StoreOrders = placedStoreOrderes.Select(x => new Api.Models.Response.StoreOrders.StoreOrder { Id = x.Id, StoreId = x.StoreId, Region = x.Region, Number = x.Number, Remark = x.Remark, ExpressAddress = x.ExpressAddress, ExpressRegion = x.ExpressRegion, ExpressMobile = x.ExpressMobile, ExpressName = x.ExpressName, ExpressZip = x.ExpressZip, CreatedOn = x.CreatedOn, Total = x.Total, StoreTotal = x.StoreTotal, Status = x.Status.ToDescription(), StoreOrderGoodses = x.StoreOrderGoodses.Select(z => new Api.Models.Response.StoreOrders.StoreOrderGoods { Id = z.Id, GoodsId = z.GoodsId, SpecificationId = z.SpecificationId, SpecificationName = z.SpecificationName, GoodsName = z.GoodsName, GoodsPic = z.GoodsPic, Quantity = z.Quantity, Price = z.Price, OriginalPrice = z.OriginalPrice, Total = z.Total, StoreTotal = z.StoreTotal, }).ToList() }).ToList() }); }
public async Task <BaseApiResponse> Login([FromBody] LoginRequest request) { request.CheckNotNull(nameof(request)); if (!request.Mobile.IsMobileNumber()) {//是否手机号 return(new BaseApiResponse { Code = 400, Message = "手机号格式不正确" }); } var userinfo = _userQueryService.FindUser(request.Mobile); //验证用户 if (userinfo == null) { return(new BaseApiResponse { Code = 400, Message = "没找到该账号" }); } //验证账号 if (userinfo.IsLocked == UserLock.Locked) { return(new BaseApiResponse { Code = 400, Message = "账号锁定" }); } //验证密码 if (!PasswordHash.ValidatePassword(request.Password, userinfo.Password)) { return(new BaseApiResponse { Code = 400, Message = "登录密码错误" }); } try { //获取钱包信息 var walletinfo = _walletQueryService.Info(userinfo.WalletId); if (walletinfo == null) { return(new BaseApiResponse { Code = 400, Message = "获取钱包信息失败" }); } //购物车信息 var cart = _cartQueryService.Info(userinfo.CartId); if (cart == null) { return(new BaseApiResponse { Code = 400, Message = "获取购物车信息失败" }); } //店铺信息 var storeId = ""; var storeinfo = _storeQueryService.InfoByUserId(userinfo.Id); if (storeinfo != null) { storeId = storeinfo.Id.ToString(); } await SignInAsync(userinfo.Id.ToString(), userinfo.WalletId.ToString(), userinfo.Mobile, true); return(new LoginResponse { UserInfo = new UserInfo { Id = userinfo.Id, ParentId = userinfo.ParentId, NickName = userinfo.NickName, Portrait = userinfo.Portrait.ToOssStyleUrl(OssImageStyles.UserPortrait.ToDescription()), Mobile = userinfo.Mobile, Gender = userinfo.Gender, Region = userinfo.Region, Role = userinfo.Role.ToDescription(), StoreId = storeId, CartId = userinfo.CartId.ToString(), CartGoodsCount = cart.GoodsCount, IsLocked = userinfo.IsLocked, Token = userinfo.Id.ToString() }, WalletInfo = new WalletInfo { Id = walletinfo.Id, AccessCode = walletinfo.AccessCode, Cash = walletinfo.Cash, Benevolence = walletinfo.Benevolence, Earnings = walletinfo.Earnings, YesterdayEarnings = walletinfo.YesterdayEarnings, IsFreeze = walletinfo.IsFreeze } }); } catch (Exception e) { return(new BaseApiResponse { Code = 400, Message = e.Message }); } }