/// <summary> /// 最近三个月订单统计数据 /// </summary> /// <param name="userId">会员编号</param> /// <returns></returns> public static OrderBasicStatistics GetLastThreeMonthOrderStatisticsByUser(long userId) { var now = DateTime.Now; var threeMonth = new DateTime(now.Year, now.Month, 1).AddMonths(-2); var query = new OrderCountStatisticsQuery { UserId = userId, OrderDateBegin = threeMonth, IsPayed = true,//已支付订单 Fields = new List <OrderCountStatisticsFields> { OrderCountStatisticsFields.ActualPayAmount, OrderCountStatisticsFields.OrderCount } }; //统计订单数 var orderStatistics = StatisticApplication.GetOrderCount(query); var sleep = _iOrderAndSaleStatisticsService.GetUserSleepDays(userId); return(new OrderBasicStatistics { TradeAmount = orderStatistics.TotalActualPayAmount, TradeCount = orderStatistics.OrderCount, SleepDays = sleep }); }
public object GetShopHome() { CheckUserLogin(); var now = DateTime.Now; var orderQuery = new OrderCountStatisticsQuery() { ShopId = CurrentUser.ShopId, Fields = new List <OrderCountStatisticsFields> { OrderCountStatisticsFields.ActualPayAmount } }; //三月内 orderQuery.OrderDateBegin = new DateTime(now.Year, now.Month, 1).AddMonths(-2); var threeMonthAmount = StatisticApplication.GetOrderCount(orderQuery).TotalActualPayAmount; //本周 orderQuery.OrderDateBegin = now.Date.AddDays(-(int)now.DayOfWeek); var weekAmount = StatisticApplication.GetOrderCount(orderQuery).TotalActualPayAmount; //今天 orderQuery.OrderDateBegin = now.Date; var todayAmount = StatisticApplication.GetOrderCount(orderQuery).TotalActualPayAmount; //近三天发布商品数 var productCount = ProductManagerApplication.GetProductCount(new ProductQuery { ShopId = CurrentUser.ShopId, AuditStatus = new[] { Entities.ProductInfo.ProductAuditStatus.Audited }, StartDate = now.Date.AddDays(-2) }); //待审核退货/退款 var refundCount = RefundApplication.GetOrderRefundsCount(new RefundQuery() { ShopId = CurrentUser.ShopId, AuditStatus = Entities.OrderRefundInfo.OrderRefundAuditStatus.WaitAudit, }); return(new { success = true, data = new { shopName = CurrentShopBranch.ShopBranchName, todayAmount = todayAmount, weekAmount = weekAmount, threeMonthAmounht = threeMonthAmount, createProductCount = productCount, refundCount = refundCount } }); }
public object GetShopBranchHome() { try { CheckUserLogin(); var now = DateTime.Now; var orderQuery = new OrderCountStatisticsQuery() { ShopBranchId = CurrentShopBranch.Id, Fields = new List <OrderCountStatisticsFields> { OrderCountStatisticsFields.ActualPayAmount } }; //三月内 orderQuery.OrderDateBegin = new DateTime(now.Year, now.Month, 1).AddMonths(-2); var threeMonthAmount = StatisticApplication.GetOrderCount(orderQuery).TotalActualPayAmount; //本周 orderQuery.OrderDateBegin = now.Date.AddDays(-(int)now.DayOfWeek); var weekAmount = StatisticApplication.GetOrderCount(orderQuery).TotalActualPayAmount; //今天 orderQuery.OrderDateBegin = now.Date; var todayAmount = StatisticApplication.GetOrderCount(orderQuery).TotalActualPayAmount; //待自提订单数 orderQuery = new OrderCountStatisticsQuery() { ShopBranchId = CurrentShopBranch.Id, OrderOperateStatus = Entities.OrderInfo.OrderOperateStatus.WaitSelfPickUp, Fields = new List <OrderCountStatisticsFields> { OrderCountStatisticsFields.OrderCount } }; var pickUpOrderCount = StatisticApplication.GetOrderCount(orderQuery).OrderCount; //近三天发布商品数 var productCount = ProductManagerApplication.GetProductCount(new ProductQuery { ShopBranchId = CurrentShopBranch.Id, AuditStatus = new[] { Entities.ProductInfo.ProductAuditStatus.Audited }, StartDate = now.Date.AddDays(-2) }); var vshop = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(CurrentShopBranch.ShopId); var logo = "/Images/branchapp.jpg"; if (vshop != null && vshop.State == Entities.VShopInfo.VShopStates.Normal && !string.IsNullOrEmpty(vshop.WXLogo)) { logo = vshop.WXLogo; } var shopBranch = ShopBranchApplication.GetShopBranchById(CurrentShopBranch.Id); var isShelvesProduct = false; if (shopBranch != null && shopBranch.Status == ShopBranchStatus.Normal) { isShelvesProduct = shopBranch.IsShelvesProduct; } return(new { success = true, data = new { shopName = CurrentShopBranch.ShopBranchName, todayAmount = todayAmount, weekAmount = weekAmount, threeMonthAmounht = threeMonthAmount, createProductCount = productCount, pickUpOrderCount = pickUpOrderCount, logo = logo, shopBranchId = CurrentShopBranch.Id, IsShelvesProduct = isShelvesProduct } }); } catch (Exception ex) { Log.Error(ex.ToString()); return(new { success = false, data = new { } }); } }