/// <summary> /// Get order list for mobile /// </summary> /// <param name="orderInput"></param> public PagedList <MerchantOrderList> GetOrderList(MerchantOrderListInput orderInput) { //query express var query = new ExpressionQuery <MerchantOrder>(); if (orderInput.OrderStatus > 0) { query.And(e => e.OrderStatus == orderInput.OrderStatus); } if (!string.IsNullOrWhiteSpace(orderInput.MerchantStoreId)) { query.And(e => e.MerchantStoreId == orderInput.MerchantStoreId); } if (orderInput.UserId > 0) { query.And(e => e.UserId == orderInput.UserId); } query.PageIndex = (int)orderInput.PageIndex; query.PageSize = (int)orderInput.PageSize; query.EnablePaging = true; query.OrderByDescending(e => e.Id); var orders = Resolve <IMerchantOrderService>().GetPagedList(query); if (orders.Count < 0) { return(new PagedList <MerchantOrderList>()); } //all stores var merchantStores = Resolve <IMerchantStoreService>().GetList().ToList(); //query var result = new List <MerchantOrderList>(); var apiService = Resolve <IApiService>(); orders.ForEach(item => { var store = merchantStores.Find(s => s.Id == item.MerchantStoreId.ToObjectId()); if (store == null) { return; } var extension = item.Extension.DeserializeJson <MerchantOrderExtension>(); var temp = new MerchantOrderList(); temp = AutoMapping.SetValue(item, temp); temp.MerchantOrderStatus = item.OrderStatus; temp.MerchantStoreName = store.Name; temp.ThumbnailUrl = apiService.ApiImageUrl(store.Logo); temp.Products = extension?.MerchantProducts; temp.Products?.ForEach(product => { product.ThumbnailUrl = apiService.ApiImageUrl(product.ThumbnailUrl); }); result.Add(temp); }); return(PagedList <MerchantOrderList> .Create(result, orders.RecordCount, orders.PageSize, orders.PageIndex)); }
public PageResult <StoreApiOrderList> PageTable(object query, AutoBaseModel autoModel) { var dic = HttpWeb.HttpContext.ToDictionary(); dic = dic.RemoveKey("userId"); // 否则查出的订单都是同一个用户 var model = ToQuery <PlatformApiOrderList>(); var expressionQuery = new ExpressionQuery <Order>(); if (model.OrderStatus > 0) { expressionQuery.And(e => e.OrderStatus == model.OrderStatus); } var store = Resolve <IStoreService>().GetUserStore(model.UserId); if (store == null) { throw new ValidException("您无权查看其他店铺订单"); } expressionQuery.And(e => e.StoreId == store.Id.ToString()); model.UserId = 0; var list = Resolve <IOrderApiService>().GetPageList(dic.ToJson(), expressionQuery); return(ToPageResult <StoreApiOrderList, ApiOrderListOutput>(list)); }
/// <summary> /// 获取时间方式的表达式 /// </summary> /// <typeparam name="TEntity"></typeparam> /// <typeparam name="TKey"></typeparam> /// <param name="timeType"></param> /// <param name="dateTime"></param> /// <param name="predicate"></param> public static Expression <Func <TEntity, bool> > GetPredicate <TEntity, TKey>(this TimeType timeType, DateTime dateTime, Expression <Func <TEntity, bool> > predicate) where TEntity : class, IAggregateRoot <TEntity, TKey> { var query = new ExpressionQuery <TEntity>(); if (predicate != null) { query.And(predicate); } query.OrderByAscending(e => e.Id); switch (timeType) { case TimeType.Day: query.And(r => r.CreateTime.Day == dateTime.Day && r.CreateTime.Month == dateTime.Month && r.CreateTime.Year == dateTime.Year); break; case TimeType.Month: query.And(r => r.CreateTime.Month == dateTime.Month && r.CreateTime.Year == dateTime.Year); break; case TimeType.Year: query.And(r => r.CreateTime.Year == dateTime.Year); break; } var result = query.BuildExpression(); return(result); }
/// <summary> /// </summary> public PageResult <ViewBankCard> PageTable(object query, AutoBaseModel autoModel) { var userInput = ToQuery <ViewBankCardInput>(); var view = new PagedList <ViewBankCard>(); if (autoModel.Filter == FilterType.Admin) { var temp = new ExpressionQuery <BankCard> { EnablePaging = true, PageIndex = (int)userInput.PageIndex, PageSize = 15 }; if (!userInput.Name.IsNullOrEmpty()) { temp.And(u => u.Name.Contains(userInput.Name)); } if (!userInput.Number.IsNullOrEmpty()) { temp.And(u => u.Number.Contains(userInput.Number)); } var model = Resolve <IBankCardService>().GetPagedList(temp); foreach (var item in model) { var outPut = AutoMapping.SetValue <ViewBankCard>(item); outPut.BankCardTypeName = item.Type.GetDisplayName(); view.Add(outPut); } return(ToPageResult(view)); } if (autoModel.Filter == FilterType.User) { userInput.UserId = autoModel.BasicUser.Id; var model = Resolve <IBankCardService>().GetUserBankCardOutputs(userInput); foreach (var item in model) { var outPut = AutoMapping.SetValue <ViewBankCard>(item); outPut.BankCardTypeName = item.Type.GetDisplayName(); view.Add(outPut); } return(ToPageResult(view)); } throw new ValidException("类型权限不正确"); }
public ApiResult <PagedList <ProductBrief> > GetProductList([FromQuery] ProductListInput input) { var query = new ExpressionQuery <Product>(); query.And(e => e.StoreId == input.StoreId.ToString()); query.PageIndex = (int)input.PageIndex; query.PageSize = (int)input.PageSize; query.EnablePaging = true; query.OrderByDescending(e => e.Id); var list = Resolve <IProductService>().GetPagedList(query); if (list.Count < 0) { return(ApiResult.Success(new PagedList <ProductBrief>())); } var catDict = Resolve <ICategoryService>().GetList().ToDictionary(c => c.Id); var ret = list.Select(prd => { var brief = new ProductBrief(); AutoMapping.SetValue(prd, brief); brief.CategoryName = catDict.ContainsKey(prd.CategoryId) ? catDict[prd.CategoryId].Name : "未定义"; return(brief); }); return(ApiResult.Success(PagedList <ProductBrief> .Create(ret, list.RecordCount, list.PageSize, list.PageIndex))); }
public ServiceResult Save(object model, AutoBaseModel autoModel) { var condition = (StoreOrdersToExcel)model; var store = Resolve <IStoreService>().GetSingle(u => u.UserId == autoModel.BasicUser.Id); if (store == null) { return(ServiceResult.FailedWithMessage("非法操作")); } var query = new ExpressionQuery <Order> { PageIndex = 1, PageSize = 15 }; //query.And(u => u.StoreId == store.Id); query.And(u => u.OrderStatus == condition.Status); var view = Resolve <IOrderService>().GetPagedList(query); var orders = new List <Order>(); foreach (var item in view) { TimeSpan ts = DateTime.Now.Subtract(item.CreateTime); if (ts.Days < condition.Days) { orders.Add(item); } } view.Result = orders; var modelType = "Order".GetTypeByName(); var result = Resolve <IAdminTableService>().ToExcel(modelType, view); return(ServiceResult.Success); }
/// <summary> /// URL参数转换为 Linq表单式 /// </summary> /// <typeparam name="TEntity"></typeparam> /// <param name="dictionary">字典数据</param> public static IExpressionQuery <TEntity> DictionaryToLinq <TEntity>(Dictionary <string, string> dictionary) where TEntity : class, IEntity { var query = new ExpressionQuery <TEntity>(); foreach (var dic in dictionary) { var key = dic.Key; if (dic.Key == "loginUserId") { key = "UserId"; } if (key == "dataId" || key == "widgetId" || key == "sign") { continue; } var dicValue = dic.Value; // var _operator = SetOperator(ref dicValue); var _operator = Operator.Equal; try { var expression = Lambda.ParsePredicate <TEntity>(key, dicValue, _operator); if (expression != null) { query.And(expression); } } catch { } } return(query); }
public ApiResult <PageResult <Product> > ProductList([FromQuery] PagedInputDto parameter) { var query = new ExpressionQuery <Product> { PageIndex = (int)parameter.PageIndex, PageSize = (int)parameter.PageSize, EnablePaging = true }; //query.And(e => e.StoreId == parameter.StoreId); if (!parameter.StoreId.IsObjectIdNullOrEmpty()) { query.And(s => s.StoreId == parameter.StoreId.ToString()); } if (parameter.Bn != null) { query.And(s => s.Bn.Contains(parameter.Bn)); } if (parameter.Name != null) { query.And(s => s.Name.Contains(parameter.Name)); } query.OrderByDescending(e => e.Id); var list = Resolve <IProductService>().GetPagedList(query); var apiRusult = new PageResult <Product> { PageCount = list.PageCount, Result = list, RecordCount = list.RecordCount, CurrentSize = list.CurrentSize, PageIndex = list.PageIndex, PageSize = list.PageSize }; if (list.Count < 0) { return(ApiResult.Success(new PageResult <Product>())); } return(ApiResult.Success(apiRusult)); //return ApiResult.Success(list); }
/// <summary> /// Page table /// </summary> /// <param name="query"></param> /// <returns></returns> public PageResult <MerchantOrderList> PageTable(object query, AutoBaseModel autoModel) { var tenant = TenantContext.CurrentTenant; var dic = HttpWeb.HttpContext.ToDictionary(); dic = dic.RemoveKey("type"); //express var model = ToQuery <MerchantOrderList>(); var expressionQuery = new ExpressionQuery <MerchantOrder>(); if (model.MerchantOrderStatus > 0) { expressionQuery.And(e => e.OrderStatus == model.MerchantOrderStatus); } //all stores var merchantStores = Resolve <IMerchantStoreService>().GetList().ToList(); //query var result = new List <MerchantOrderList>(); var apiService = Resolve <IApiService>(); var orders = Resolve <IMerchantOrderService>() .GetPagedList <MerchantOrder>(dic.ToJson(), expressionQuery.BuildExpression()); orders.ForEach(item => { var store = merchantStores.Find(s => s.Id == item.MerchantStoreId.ToObjectId()); if (store == null) { return; } var extension = item.Extension.DeserializeJson <MerchantOrderExtension>(); var temp = new MerchantOrderList(); temp = AutoMapping.SetValue(item, temp); //user var user = Resolve <IUserService>().GetSingle(item.UserId); if (user != null) { temp.BuyUser = AutoMapping.SetValue <UserOutput>(user); } temp.MerchantOrderStatus = item.OrderStatus; temp.MerchantStoreName = store.Name; temp.ThumbnailUrl = apiService.ApiImageUrl(store.Logo); temp.Products = extension?.MerchantProducts; temp.Products?.ForEach(product => { product.ThumbnailUrl = apiService.ApiImageUrl(product.ThumbnailUrl); }); result.Add(temp); }); var pageList = PagedList <MerchantOrderList> .Create(result, orders.RecordCount, orders.PageSize, orders.PageIndex); return(ToPageResult(pageList)); }
public PageResult <AutoListItem> PageList(object query, AutoBaseModel autoModel) { var dic = query.ToObject <Dictionary <string, string> >(); dic.TryGetValue("loginUserId", out var userId); dic.TryGetValue("pageIndex", out var pageIndexStr); var pageIndex = pageIndexStr.ToInt64(); if (pageIndex <= 0) { pageIndex = 1; } var orderQuery = new ExpressionQuery <BookingSignupOrder> { EnablePaging = true, PageIndex = (int)pageIndex, PageSize = 15 }; orderQuery.And(e => e.UserId == userId.ToInt64()); orderQuery.And(e => e.IsPay); var model = Resolve <IBookingSignupOrderService>().GetPagedList(orderQuery); var list = new List <AutoListItem>(); foreach (var item in model.ToList()) { foreach (var temp in item.Contacts) { var apiData = new AutoListItem { Title = temp.Name, Intro = temp.Mobile, Image = "https://diyservice.5ug.com/wwwroot/uploads/api/2019-03-20/5c924388397d411c8c07de3e.png" }; list.Add(apiData); } } return(ToPageList(list, model)); }
public PageResult <BookingSignupOrderUser> PageTable(object query, AutoBaseModel autoModel) { var dic = query.ToObject <Dictionary <string, string> >(); long pageIndex = 1; dic.TryGetValue("pageIndex", out var pageIndexStr); if (!pageIndexStr.IsNullOrEmpty()) { pageIndex = pageIndexStr.ToInt64(); } var input = new ExpressionQuery <BookingSignupOrder> { EnablePaging = true, PageIndex = (int)pageIndex, PageSize = 15 }; input.And(u => u.IsPay); input.And(u => u.ParentName != "测试"); // var model = Resolve<IBookingSignupOrderService>().GetList(u => u.IsPay == true && u.ParentName != "测试").ToList(); var model = Resolve <IBookingSignupOrderService>().GetPagedList(input); var list = new List <BookingSignupOrderUser>(); model.ForEach(u => { u.Contacts.ForEach(z => { var view = AutoMapping.SetValue <BookingSignupOrderUser>(u); view.Mobile = z.Mobile; view.ContactName = z.Name; view.IsSign = z.IsSign; list.Add(view); }); }); return(ToPageResult(PagedList <BookingSignupOrderUser> .Create(list, model.RecordCount, 15, pageIndex))); }
/// <summary> /// 根据状态获取 /// </summary> /// <param name="input"></param> /// <returns></returns> public IList <SmsSend> GetAll(SendState input) { var query = new ExpressionQuery <SmsSend>(); if (input != SendState.All) { query.And(r => r.State == input); } var list = GetList(query); return(list); }
/// <summary> /// page table /// </summary> /// <param name="query"></param> /// <returns></returns> public PageResult <MerchantProductList> PageTable(object query, AutoBaseModel autoModel) { var dic = HttpWeb.HttpContext.ToDictionary(); dic = dic.RemoveKey("userId"); dic = dic.RemoveKey("type"); //express var allStores = Resolve <IMerchantStoreService>().GetList().ToList(); var allRelations = Resolve <IRelationService>().GetClass(typeof(MerchantProductClassRelation).FullName) .ToList(); var model = ToQuery <MerchantProductList>(); var expressionQuery = new ExpressionQuery <MerchantProduct>(); if (!string.IsNullOrWhiteSpace(model.ClassName)) { var relation = allRelations.Find(r => r.Name.Contains(model.ClassName)); if (relation != null) { expressionQuery.And(e => e.ClassId == relation.Id); } } //query var apiService = Resolve <IApiService>(); var list = Resolve <IMerchantProductService>() .GetPagedList <MerchantProductList>(dic.ToJson(), expressionQuery.BuildExpression()); list.ForEach(item => { //store var store = allStores.Find(s => s.Id == item.MerchantStoreId.ToObjectId()); item.MerchantStoreName = store?.Name; item.ThumbnailUrl = apiService.ApiImageUrl(item.ThumbnailUrl); //relation var relation = allRelations.Find(r => r.Id == item.ClassId); item.ClassName = relation?.Name; //item.sku var sku = item.Skus.FirstOrDefault(); if (sku != null) { item.SkuName = sku.Name; item.Price = sku.Price; } item.Stock = item.Skus.Sum(s => s.Stock); }); return(ToPageResult(list)); }
public PagedList <BankCard> GetUserBankCardOutputs(ViewBankCardInput parameter) { var query = new ExpressionQuery <BankCard> { PageIndex = (int)parameter.PageIndex, PageSize = (int)parameter.PageSize }; query.And(e => e.UserId == parameter.UserId); if (!parameter.Name.IsNullOrEmpty()) { query.And(u => u.Name.Contains(parameter.Name)); } if (!parameter.Number.IsNullOrEmpty()) { query.And(u => u.Number.Contains(parameter.Number)); } var model = Resolve <IBankCardService>().GetPagedList(query); return(model); }
public TEntity GetSingleOrderByDescending(Expression <Func <TEntity, TKey> > keySelector, Expression <Func <TEntity, bool> > predicate) { var queryCriteria = new ExpressionQuery <TEntity>(); queryCriteria.OrderByDescending(keySelector); if (predicate != null) { queryCriteria.And(predicate); } var find = queryCriteria.Execute(Set); return(find.FirstOrDefault()); }
public PageResult <AutoListItem> PageList(object query, AutoBaseModel autoModel) { var dic = query.ToObject <Dictionary <string, string> >(); dic.TryGetValue("loginUserId", out var userId); dic.TryGetValue("pageIndex", out var pageIndexStr); var pageIndex = pageIndexStr.ToInt64(); if (pageIndex <= 0) { pageIndex = 1; } var temp = new ExpressionQuery <Bill> { EnablePaging = true, PageIndex = (int)pageIndex, PageSize = 15 }; temp.And(e => e.UserId == userId.ToInt64()); var model = Resolve <IBillService>() .GetListByPageDesc(15, (int)pageIndex, u => u.UserId == userId.ToInt64()); var page = Resolve <IBillService>().GetPagedList(temp); page.Result = model.ToList(); var users = Resolve <IUserDetailService>().GetList(); var moneyTypes = Resolve <IAutoConfigService>().GetList <MoneyTypeConfig>(); var list = new List <AutoListItem>(); var apiStore = Resolve <IApiService>(); foreach (var item in model.ToList()) { var apiData = new AutoListItem { Title = moneyTypes.FirstOrDefault(u => u.Id == item.MoneyTypeId)?.Name + "账户 - " + item.Flow.GetDisplayName(), Intro = $"账后{item.AfterAmount}时间{item.CreateTime.ToString()}", Value = item.Amount, Image = apiStore.ApiUserAvator(item.UserId), Id = item.Id, Url = $"/pages/index?path=Asset_bill_view&id={item.Id}" }; list.Add(apiData); } return(ToPageList(list, page)); }
public PageResult <AutoListItem> PageList(object query, AutoBaseModel autoModel) { var dic = query.ToObject <Dictionary <string, string> >(); dic.TryGetValue("loginUserId", out var userId); dic.TryGetValue("pageIndex", out var pageIndexStr); var pageIndex = pageIndexStr.ToInt64(); if (pageIndex <= 0) { pageIndex = 1; } var temp = new ExpressionQuery <Reward> { EnablePaging = true, PageIndex = (int)pageIndex, PageSize = 15 }; temp.And(e => e.UserId == userId.ToInt64()); temp.OrderByDescending(s => s.CreateTime); //temp.And(u => u.Type == TradeType.Withraw); var moneyTypes = Resolve <IAutoConfigService>().GetList <MoneyTypeConfig>(); var model = Resolve <IRewardService>().GetPagedList(temp); var users = Resolve <IUserDetailService>().GetList(); var list = new List <AutoListItem>(); foreach (var item in model) { var apiData = new AutoListItem { Title = moneyTypes.FirstOrDefault(u => u.Id == item.MoneyTypeId) ?.Name, // + " - " + item.Type.GetDisplayName(), Intro = item.Intro, //$"{item.CreateTime}", Value = item.Amount, Image = users.FirstOrDefault(u => u.UserId == item.UserId)?.Avator, Id = item.Id, Url = $"/pages/index?path=share_show&id={item.Id}" }; list.Add(apiData); } return(ToPageList(list, model)); }
public PageResult <AutoListItem> PageList(object query, AutoBaseModel autoModel) { var dic = HttpWeb.HttpContext.ToDictionary(); dic = dic.RemoveKey("userId"); // 否则查出的订单都是同一个用户 var model = ToQuery <PlatformApiOrderList>(); var expressionQuery = new ExpressionQuery <Order>(); if (model.OrderStatus > 0) { expressionQuery.And(e => e.OrderStatus == model.OrderStatus); } //expressionQuery.And(e => e.OrderStatus != OrderStatus.WaitingBuyerPay); //var isAdmin = Resolve<IUserService>().IsAdmin(model.UserId); //if (!isAdmin) { // throw new ValidException("非管理员不能查看平台订单"); //} // expressionQuery.And(e => e.StoreId > 0); model.UserId = 0; var pageList = Resolve <IOrderApiService>().GetPageList(dic.ToJson(), expressionQuery); var list = new List <AutoListItem>(); foreach (var item in pageList) { var apiData = new AutoListItem { Title = $"金额{item.TotalAmount}元", Intro = item.UserName, Value = item.TotalAmount, Image = Resolve <IApiService>().ApiUserAvator(item.UserId), Id = item.Id, Url = $"/pages/user?path=Asset_recharge_view&id={item.Id}" }; list.Add(apiData); } return(ToPageList(list, pageList)); }
public PageResult <AutoListItem> PageList(object query, AutoBaseModel autoModel) { var dic = query.ToObject <Dictionary <string, string> >(); dic.TryGetValue("loginUserId", out var userId); dic.TryGetValue("pageIndex", out var pageIndexStr); var pageIndex = pageIndexStr.ToInt64(); if (pageIndex <= 0) { pageIndex = 1; } var temp = new ExpressionQuery <BankCard> { EnablePaging = true, PageIndex = (int)pageIndex, PageSize = 15 }; temp.And(e => e.UserId == userId.ToInt64()); var model = Resolve <IBankCardService>().GetPagedList(temp); var users = Resolve <IUserDetailService>().GetList(); var list = new List <AutoListItem>(); foreach (var item in model) { var apiData = new AutoListItem { Title = $"{item.Name}", Intro = item.Number, Value = item.Type.GetDisplayName(), Image = $@"http://s-test.qiniuniu99.com/wwwroot/uploads/bankcard/{item.Type.ToString()}.jpg", Id = item.Id, Url = $"/pages/index?path=Asset_BankCard_add&id={item.Id}" }; list.Add(apiData); } return(ToPageList(list, model)); }
public PageResult <AutoListItem> PageList(object query, AutoBaseModel autoModel) { var dic = query.ToObject <Dictionary <string, string> >(); dic.TryGetValue("loginUserId", out var userId); dic.TryGetValue("pageIndex", out var pageIndexStr); var pageIndex = pageIndexStr.ToInt64(); if (pageIndex <= 0) { pageIndex = 1; } var temp = new ExpressionQuery <Article> { EnablePaging = true, PageIndex = (int)pageIndex, PageSize = 15 }; temp.And(e => e.ChannelId == ObjectId.Parse("e02220001110000000000003")); var model = Resolve <IArticleService>().GetPagedList(temp); var users = Resolve <IUserDetailService>().GetList(); var list = new List <AutoListItem>(); foreach (var item in model) { var apiData = new AutoListItem { Title = item.Title, Intro = item.Intro, Value = item.Author, Image = "http://s-test.qiniuniu99.com" + item.ImageUrl, Id = item.Id, Url = $"/pages/index?path=articles_help_view&id={item.Id}" }; list.Add(apiData); } return(ToPageList(list, model)); }
public PageResult <UserApiOrderList> PageTable(object query, AutoBaseModel autoModel) { var model = ToQuery <PlatformApiOrderList>(); var user = Resolve <IUserService>().GetSingle(model.UserId); if (user == null) { throw new ValidException("您无权查看其他人订单"); } var expressionQuery = new ExpressionQuery <Order>(); if (model.UserId > 0) { expressionQuery.And(e => e.UserId == user.Id); } var list = Resolve <IOrderApiService>().GetPageList(query, expressionQuery); return(ToPageResult <UserApiOrderList, ApiOrderListOutput>(list)); }
public TEntity Prex(TEntity model) { var dynamic = (dynamic)model; var query = new ExpressionQuery <TEntity>(); var dynamicWhere = LinqHelper.GetExpression <TEntity, bool>($"entity.Id < {dynamic.Id}", "entity"); query.And(dynamicWhere); //排序方式 var orderExpression = LinqHelper.GetExpression <TEntity, long>("entity.Id", "entity"); query.OrderByDescending(orderExpression); var prex = GetSingle(query); if (prex == null) { prex = model; } return(prex); }
public PageResult <AutoListItem> PageList(object query, AutoBaseModel autoModel) { var dic = query.ToObject <Dictionary <string, string> >(); dic.TryGetValue("loginUserId", out var userId); dic.TryGetValue("pageIndex", out var pageIndexStr); var pageIndex = pageIndexStr.ToInt64(); if (pageIndex <= 0) { pageIndex = 1; } var orderQuery = new ExpressionQuery <HudongRecord> { EnablePaging = true, PageIndex = (int)pageIndex, PageSize = 15 }; orderQuery.And(e => e.UserId == userId.ToInt64()); var model = Resolve <IHudongRecordService>().GetPagedList(orderQuery); var list = new List <AutoListItem>(); foreach (var item in model.ToList()) { var apiData = new AutoListItem { Id = item.Id, Image = GetAvator(item.UserId), Title = item.Grade, Intro = "中奖时间:" + item.CreateTime, Value = item.HuDongStatus.Value() == 1 ? "已兑奖" : "未兑奖" //item.CreateTime.ToUniversalTime() }; list.Add(apiData); } return(ToPageList(list, model)); }
public PageResult <AutoListItem> PageList(object query, AutoBaseModel autoModel) { var dic = query.ToObject <Dictionary <string, string> >(); dic.TryGetValue("loginUserId", out var userId); dic.TryGetValue("pageIndex", out var pageIndexStr); var pageIndex = pageIndexStr.ToInt64(); if (pageIndex <= 0) { pageIndex = 1; } var orderQuery = new ExpressionQuery <Entities.FacePay> { EnablePaging = true, PageIndex = (int)pageIndex, PageSize = 15 }; orderQuery.And(e => e.UserId == userId.ToLong()); var model = Resolve <IFacePayService>().GetPagedList(orderQuery); var list = new List <AutoListItem>(); foreach (var item in model.ToList()) { var apiData = new AutoListItem { Image = GetAvator(item.UserId), Title = "当面付-" + item.Amount + "元", Intro = "付款时间:" + item.CreateTime, Value = item.UserName }; list.Add(apiData); } return(ToPageList(list, model)); }
/// <summary> /// 获取单条记录 /// </summary> /// <param name="guid"></param> public Category GetSingle(Guid guid) { var category = GetSingle(r => r.Id == guid); if (category != null) { //读取所有类目属性 var propertys = Resolve <ICategoryPropertyService>().GetList(r => r.CategoryId == category.Id) ?.OrderBy(r => r.SortOrder).ToList(); var propertyIds = propertys.Select(r => r.Id).ToList(); // 读取所有类目属性值 var query = new ExpressionQuery <CategoryPropertyValue>(); query.And(r => propertyIds.Contains(r.PropertyId)); query.OrderByAscending(e => e.SortOrder); var propertyValues = Resolve <ICategoryPropertyValueService>().GetList(query).ToList(); // 规格,销售用 var salePropertys = propertys.Where(r => r.IsSale).ToList(); category.SalePropertys = new List <CategoryProperty>(); foreach (var item in salePropertys) { item.PropertyValues = propertyValues.Where(r => r.PropertyId == item.Id).ToList(); category.SalePropertys.Add(item); } // 商品参数,显示用 var displayPropertys = propertys.Where(r => r.IsSale == false).ToList(); //规格,销售用 category.DisplayPropertys = new List <CategoryProperty>(); foreach (var item in displayPropertys) { item.PropertyValues = propertyValues.Where(r => r.PropertyId == item.Id).ToList(); category.DisplayPropertys.Add(item); } } return(category); }
public ApiResult GetStoreOrdersToExcel(StoreOrdersToExcel model) { var webSite = Resolve <IAutoConfigService>().GetValue <WebSiteConfig>(); var store = Resolve <IStoreService>().GetSingle(u => u.UserId == model.UserId); if (store == null) { return(ApiResult.Failure("非法操作")); } var query = new ExpressionQuery <Order> { PageIndex = 1, PageSize = 15 }; // query.And(u => u.StoreId == store.Id); query.And(u => u.OrderStatus == model.Status); var view = Resolve <IOrderService>().GetPagedList(query); var orders = new List <Order>(); foreach (var item in view) { TimeSpan ts = DateTime.Now.Subtract(item.CreateTime); if (ts.Days < model.Days) { orders.Add(item); } } view.Result = orders; var modelType = "Order".GetTypeByName(); var result = Resolve <IAdminTableService>().ToExcel(modelType, view); var url = webSite.ApiImagesUrl + "/wwwroot/excel/" + result.Item3; return(ApiResult.Success(url)); }
public List <ArticleItem> GetArticleList(ArticleInput articleInput) { var query = new ExpressionQuery <Article>(); query.OrderByAscending(e => e.CreateTime); if (!articleInput.ChannelId.IsNullOrEmpty()) { query.And(r => r.ChannelId == articleInput.ChannelId.ToObjectId()); } if (articleInput.OrderType == 0) { query.OrderByAscending(a => a.ViewCount); } else { query.OrderByDescending(a => a.ViewCount); } var list = GetList(query); var result = new List <ArticleItem>(); foreach (var item in list) { if (articleInput.TotalCount > 0 && result.Count >= articleInput.TotalCount) { break; } var articleItem = AutoMapping.SetValue <ArticleItem>(item); articleItem.RelationId = item.RelationId; result.Add(articleItem); } return(result); }
/// <summary> /// 获取订单列表,包括供应商订单,会员订单,后台订单 /// </summary> /// <param name="orderInput"></param> public PagedList <OrderListOutput> GetPageList(OrderListInput orderInput) { var query = new ExpressionQuery <Order>(); if (orderInput.OrderStatus > 0) { query.And(e => e.OrderStatus == orderInput.OrderStatus); } if (orderInput.OrderType.HasValue) { query.And(e => e.OrderType == orderInput.OrderType); } if (!orderInput.StoreId.IsObjectIdNullOrEmpty()) { query.And(e => e.StoreId == orderInput.StoreId.ToString()); } if (orderInput.DeliverUserId > 0) // 发货记录 { query.And(e => e.DeliverUserId == orderInput.DeliverUserId); } if (orderInput.UserId > 0) //订单记录 { query.And(e => e.UserId == orderInput.UserId); } else if (orderInput.UserId > 0) //订单记录 { query.And(e => e.UserId == orderInput.UserId); } if (orderInput.OrderType > 0) { query.And(e => e.OrderType == orderInput.OrderType); } query.PageIndex = (int)orderInput.PageIndex; query.PageSize = (int)orderInput.PageSize; query.EnablePaging = true; query.OrderByDescending(e => e.Id); var orders = Resolve <IOrderService>().GetPagedList(query); if (orders.Count < 0) { return(new PagedList <OrderListOutput>()); } var model = new List <OrderListOutput>(); foreach (var item in orders) { var listOutput = new OrderListOutput { CreateTime = item?.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), Id = item.Id, OrderStatuName = item?.OrderStatus.GetDisplayName(), User = item?.OrderExtension?.User, Address = item?.OrderExtension?.UserAddress?.Address }; if (item.OrderExtension != null) { if (item.OrderExtension.UserAddress != null) { listOutput.RegionName = Resolve <IRegionService>() .GetRegionNameById(item.OrderExtension.UserAddress.RegionId); } } else { listOutput.RegionName = null; } listOutput = AutoMapping.SetValue(item, listOutput); var orderExtension = item.Extension.DeserializeJson <OrderExtension>(); if (orderExtension != null && orderExtension.Store != null) { listOutput.StoreName = orderExtension.Store.Name; listOutput.ExpressAmount = orderExtension.OrderAmount.ExpressAmount; } if (item.OrderStatus == OrderStatus.WaitingBuyerPay) { var proids = orderExtension.ProductSkuItems.Select(s => s.ProductId); var productNotOnline = Resolve <IProductService>().GetList(s => s.ProductStatus != GoodsStatus.Online && proids.Contains(s.Id)); foreach (var product in productNotOnline) { var ext = orderExtension.ProductSkuItems.SingleOrDefault(s => s.ProductId == product.Id); if (ext != null) { ext.ProductStatus = product.ProductStatus; listOutput.OrderStatus = OrderStatus.UnderShelf; //标识为下架订单 } } } listOutput.OutOrderProducts = orderExtension.ProductSkuItems; listOutput.OutOrderProducts?.ToList().ForEach(c => { c.ThumbnailUrl = Resolve <IApiService>().ApiImageUrl(c.ThumbnailUrl); }); model.Add(listOutput); } return(PagedList <OrderListOutput> .Create(model, orders.RecordCount, orders.PageSize, orders.PageIndex)); }
public PagedList <RewardRuleTable> GetPageList(object query) { var expression = new ExpressionQuery <RewardRule>(); var dic = query.ToObject <Dictionary <string, string> >(); if (dic.GetValue("Name", out var name)) { if (!name.IsNullOrEmpty()) { expression.And(r => r.Base.Name.Contains(name, StringComparison.OrdinalIgnoreCase)); } } if (dic.GetValue("triggerType", out var triggerType)) { var trigger = Convert.ToInt32(triggerType); trigger.IntToEnum(out TriggerType type); expression.And(r => r.Limit.TriggerType == type); } var model = GetPagedList(query, expression.BuildExpression()); var result = new List <RewardRuleTable>(); var moneyTypes = Resolve <IAutoConfigService>().GetList <MoneyTypeConfig>(); var userTypes = Resolve <IAutoConfigService>().GetList <UserTypeConfig>(); foreach (var item in model) { var ruleTable = item.MapTo <RewardRuleTable>(); ruleTable.ModuleName = Resolve <IRuleModuleService>().GetRuleAttribute(item.ModuleId)?.Name; ruleTable.Name = item.Base.Name; ruleTable.IsEnable = item.Base.IsEnable; ruleTable.SmsNotification = item.Base.TemplateRule.SmsNotification; ruleTable.TriggerType = item.Limit.TriggerType; //资产分配 foreach (var rule in item.AssetsRules) { var moneyType = moneyTypes.FirstOrDefault(r => r.Id == rule.MoneyTypeId); ruleTable.RuleItemsIntro += $"{moneyType?.Name}({rule.Ratio})"; } ruleTable.RuleItemsIntro = $"<code>{ruleTable.RuleItemsIntro}</code><br/>"; //比例 //var radios = item.DistriRatio?.Split(","); //ruleTable.DistriRatio = string.Empty; //radios?.Foreach(r => { // ruleTable.DistriRatio += $"<span class='m-badge m-badge--focus '>{r}</span>"; //}); //用户类型限制 if (!item.UserRang.ShareUser.IsLimitShareUserType) { ruleTable.ShareUserIntro = "不限类型 不限等级"; } else { var userType = userTypes.FirstOrDefault(r => r.Id == item.UserRang.ShareUser.ShareUserTypeId); //等级限制 if (!item.UserRang.ShareUser.IsLimitShareUserGrade) { ruleTable.ShareUserIntro = $"限{userType?.Name} 不限等级"; } else { var grade = Resolve <IGradeService>().GetGradeByUserTypeIdAndGradeId(item.UserRang.ShareUser.ShareUserTypeId, item.UserRang.ShareUser.ShareUserGradeId); ruleTable.ShareUserIntro = $"限{userType?.Name} {grade?.Name}"; } } if (!item.UserRang.OrderUser.IsLimitOrderUserType) { ruleTable.OrderUserIntro = "不限类型 不限等级"; } else { var userType = userTypes.FirstOrDefault(r => r.Id == item.UserRang.OrderUser.OrderUserTypeId); //等级限制 if (!item.UserRang.OrderUser.IsLimitOrderUserGrade) { ruleTable.OrderUserIntro = $"限{userType?.Name} 不限等级"; } else { var grade = Resolve <IGradeService>().GetGradeByUserTypeIdAndGradeId(item.UserRang.OrderUser.OrderUserTypeId, item.UserRang.OrderUser.OrderUserGradeId); ruleTable.OrderUserIntro = $"限{userType?.Name} {grade?.Name}"; } } result.Add(ruleTable); } return(PagedList <RewardRuleTable> .Create(result, model.RecordCount, model.PageSize, model.PageIndex)); }
public PageResult <PlatformApiOrderList> PageTable(object query, AutoBaseModel autoModel) { var dic = HttpWeb.HttpContext.ToDictionary(); dic = dic.RemoveKey("userId"); // 否则查出的订单都是同一个用户 var model = ToQuery <PlatformApiOrderList>(); var expressionQuery = new ExpressionQuery <Order> { PageIndex = 1, EnablePaging = true }; if (model.OrderStatus > 0) { expressionQuery.And(e => e.OrderStatus == model.OrderStatus); } // expressionQuery.And(e => e.StoreId > 0); expressionQuery.And(e => e.UserId > 0); if (Enum.IsDefined(typeof(OrderType), model.OrderType)) { expressionQuery.And(e => e.OrderType == model.OrderType); } if (autoModel.Filter == FilterType.Admin) { var isAdmin = Resolve <IUserService>().IsAdmin(autoModel.BasicUser.Id); if (!isAdmin) { throw new ValidException("非管理员不能查看平台订单"); } } else if (autoModel.Filter == FilterType.Store) { var store = Resolve <IStoreService>().GetUserStore(autoModel.BasicUser.Id); if (store == null) { throw new ValidException("您不是供应商,暂无店铺"); } expressionQuery.And(e => e.StoreId == store.Id.ToString()); // 供应商 //expressionQuery.And(e => e.OrderExtension.IsSupplierView == true); expressionQuery.And(u => u.OrderStatus == OrderStatus.Remited); } //else if (autoModel.Filter == FilterType.User) { // expressionQuery.And(e => e.UserId == autoModel.BasicUser.Id); //} else { //其他用户查看自己的订单 expressionQuery.And(e => e.UserId == autoModel.BasicUser.Id); } var list = Resolve <IOrderApiService>().GetPageList(dic.ToJson(), expressionQuery); return(ToPageResult <PlatformApiOrderList, ApiOrderListOutput>(list)); }