Commit efb17e08 by 陶然

优化统计接口

parent 7f1c0692
...@@ -9,6 +9,22 @@ namespace Kivii.Finances.Entities ...@@ -9,6 +9,22 @@ namespace Kivii.Finances.Entities
[Api(Description = "分析")] [Api(Description = "分析")]
public class Analysis public class Analysis
{ {
public string Summary { get; set; }
public string Remark { get; set; }
public string OwnerName { get; set; }
public Guid OwnerKvid { get; set; }
public AnalysisType AnalysisType { get; set; }
public DateTime BeginTime { get; set; }
public DateTime EndTime { get; set; }
public string Type { get; set; }
public decimal AmountPlan { get; set; } public decimal AmountPlan { get; set; }
public decimal Amount { get; set; } public decimal Amount { get; set; }
...@@ -60,18 +76,6 @@ namespace Kivii.Finances.Entities ...@@ -60,18 +76,6 @@ namespace Kivii.Finances.Entities
public int QuantityUnpaid { get; set; } public int QuantityUnpaid { get; set; }
public int QuantityOffset { get; set; } public int QuantityOffset { get; set; }
public AnalysisType AnalysisType { get; set; }
public DateTime BeginTime { get; set; }
public DateTime EndTime { get; set; }
public string Type { get; set; }
public string Summary { get; set; }
public string Remark { get; set; }
} }
/// <summary> /// <summary>
......
...@@ -93,7 +93,7 @@ namespace Kivii.Finances.Transforms ...@@ -93,7 +93,7 @@ namespace Kivii.Finances.Transforms
var sqlExpress = conn.From<Payment>(); var sqlExpress = conn.From<Payment>();
sqlExpress.Where(o => o.OffsetKvid == Guid.Empty && Sql.In(o.Type, PaymentType.WeChat, PaymentType.Cash, PaymentType.AliPay, PaymentType.Pos, PaymentType.Split, PaymentType.Refund, PaymentType.UnBiz)); sqlExpress.Where(o => o.OffsetKvid == Guid.Empty && Sql.In(o.Type, PaymentType.WeChat, PaymentType.Cash, PaymentType.AliPay, PaymentType.Pos, PaymentType.Split, PaymentType.Refund, PaymentType.UnBiz));
sqlExpress.And(o => o.OperateTime >= beginTime && o.OperateTime < endTime); sqlExpress.And(o => o.CreateTime >= beginTime && o.CreateTime < endTime);
if (!OwnerKvids.IsNullOrEmpty()) sqlExpress.And(o => Sql.In(o.OwnerKvid, OwnerKvids)); if (!OwnerKvids.IsNullOrEmpty()) sqlExpress.And(o => Sql.In(o.OwnerKvid, OwnerKvids));
sqlExpress.And(o => (Sql.In(o.PayerAccountKvid, queryAccount))); sqlExpress.And(o => (Sql.In(o.PayerAccountKvid, queryAccount)));
sqlExpress.OrderBy(o => o.OwnerName); sqlExpress.OrderBy(o => o.OwnerName);
......
...@@ -45,9 +45,11 @@ namespace Kivii.Finances.Transforms ...@@ -45,9 +45,11 @@ namespace Kivii.Finances.Transforms
#region 如果是GroupByOwner的处理情况 #region 如果是GroupByOwner的处理情况
if (GroupByOwner) if (GroupByOwner)
{ {
sqlExpress.GroupBy(o => o.OwnerName); sqlExpress.GroupBy(o => new { o.OwnerName, o.OwnerKvid });
sqlExpress.Select(o => new sqlExpress.Select(o => new
{ {
OwnerKvid = o.OwnerKvid,
OwnerName = o.OwnerName,
Summary = o.OwnerName, Summary = o.OwnerName,
Quantity = Sql.Count(o.Kvid), Quantity = Sql.Count(o.Kvid),
Amount = Sql.Sum(o.Amount), Amount = Sql.Sum(o.Amount),
...@@ -60,13 +62,14 @@ namespace Kivii.Finances.Transforms ...@@ -60,13 +62,14 @@ namespace Kivii.Finances.Transforms
rtns.BeginTime = BeginTime; rtns.BeginTime = BeginTime;
rtns.EndTime = EndTime; rtns.EndTime = EndTime;
if (rtns.Results.IsNullOrEmpty()) return rtns; if (rtns.Results.IsNullOrEmpty()) return rtns;
rtns.Total = rtns.Results.Sum(o => o.Quantity); rtns.TotalQuantity = rtns.Results.Sum(o => o.Quantity);
rtns.TotalAmount = rtns.Results.Sum(o => o.Amount); rtns.TotalAmount = rtns.Results.Sum(o => o.Amount);
rtns.TotalAmountPayment = rtns.Results.Sum(o => o.AmountPayment); rtns.TotalAmountPayment = rtns.Results.Sum(o => o.AmountPayment);
rtns.TotalQuantityPayment = rtns.Results.Sum(o => o.QuantityPayment); rtns.TotalQuantityPayment = rtns.Results.Sum(o => o.QuantityPayment);
rtns.TotalAmountUnpaid = rtns.Results.Sum(o => o.AmountUnpaid); rtns.TotalAmountUnpaid = rtns.Results.Sum(o => o.AmountUnpaid);
rtns.TotalQuantityUnpaid = rtns.Results.Sum(o => o.QuantityUnpaid); rtns.TotalQuantityUnpaid = rtns.Results.Sum(o => o.QuantityUnpaid);
rtns.Total = rtns.Results.Count;
return rtns; return rtns;
} }
#endregion #endregion
...@@ -105,6 +108,7 @@ namespace Kivii.Finances.Transforms ...@@ -105,6 +108,7 @@ namespace Kivii.Finances.Transforms
} }
else rtns.Results.AddRange(results); else rtns.Results.AddRange(results);
rtns.Total = rtns.Results.Count;
return rtns; return rtns;
} }
} }
......
...@@ -14,6 +14,9 @@ namespace Kivii.Finances.Transforms ...@@ -14,6 +14,9 @@ namespace Kivii.Finances.Transforms
public DateTime BeginTime { get; set; } public DateTime BeginTime { get; set; }
public DateTime EndTime { get; set; } public DateTime EndTime { get; set; }
public string OwnerName { get; set; }
public Guid OwnerKvid { get; set; }
public string Description { get; set; } public string Description { get; set; }
public decimal TotalAmount { get; set; } public decimal TotalAmount { get; set; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment