You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.9 KiB
36 lines
1.9 KiB
3 years ago
|
using BBWY.Common.Models;
|
||
|
using BBWY.Server.Model.Db;
|
||
|
using BBWY.Server.Model.Dto;
|
||
|
using System;
|
||
|
using Yitter.IdGenerator;
|
||
|
|
||
|
namespace BBWY.Server.Business
|
||
|
{
|
||
|
public class StatisticsBusiness : BaseBusiness, IDenpendency
|
||
|
{
|
||
|
public StatisticsBusiness(IFreeSql fsql, NLog.ILogger logger, IIdGenerator idGenerator) : base(fsql, logger, idGenerator)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
public ToDayOrderAchievementResponse GetTodayAchievementStatistics(ToDayOrderAchievementRequest request)
|
||
|
{
|
||
|
var today = DateTime.Now.Date;
|
||
|
var response = fsql.Select<Order, OrderCost>().InnerJoin((o, oc) => o.Id == oc.OrderId)
|
||
|
.Where((o, oc) => o.ShopId == request.ShopId &&
|
||
|
o.OrderState == Model.Enums.OrderState.已完成 &&
|
||
|
o.EndTime >= today)
|
||
|
.ToAggregate((o, oc) => new ToDayOrderAchievementResponse()
|
||
|
{
|
||
|
OrderCount = o.Count(),
|
||
|
Profit = oc.Sum(oc.Key.Profit),
|
||
|
SaleAmount = o.Sum(o.Key.OrderPayment),
|
||
|
DeliveryExpressFreight = oc.Sum(oc.Key.DeliveryExpressFreight),
|
||
|
PlatformCommissionAmount = oc.Sum(oc.Key.PlatformCommissionAmount),
|
||
|
PurchaseAmount = oc.Sum(oc.Key.PurchaseAmount)
|
||
|
});
|
||
|
return response;
|
||
|
}
|
||
|
}
|
||
|
}
|