diff --git a/SBF.API/Controllers/TrusteeshipController.cs b/SBF.API/Controllers/TrusteeshipController.cs index b92f16e..b58bc17 100644 --- a/SBF.API/Controllers/TrusteeshipController.cs +++ b/SBF.API/Controllers/TrusteeshipController.cs @@ -55,5 +55,16 @@ namespace SBF.API.Controllers { trusteeshipBusiness.StopTrusteeship(id); } + + /// + /// 查询托管任务曲线图详情 + /// + /// + /// + [HttpGet("{id}")] + public TrusteeshipTaskResponse GetTrusteeshipTaskCurveResponse([FromRoute] long id) + { + return trusteeshipBusiness.GetTrusteeshipTaskCurveResponse(id); + } } } diff --git a/SBF.Business/TrusteeshipBusiness.cs b/SBF.Business/TrusteeshipBusiness.cs index 7733013..ec4f3d6 100644 --- a/SBF.Business/TrusteeshipBusiness.cs +++ b/SBF.Business/TrusteeshipBusiness.cs @@ -85,7 +85,10 @@ namespace SBF.Business /// 查询托管任务 /// /// + /// + /// /// + /// public ListResponse QueryTrusteeship(QueryTrusteeshipRequest request) { if (request.ShopId == null || request.ShopId == 0) @@ -116,8 +119,8 @@ namespace SBF.Business AdId = t.AdId, AdName = t.AdName, BidPrice = t.BidPrice, - OldBudget = t.OldBudget, - NewBudget = t.NewBudget, + AnchorBudget = t.AnchorBudget, + ActualBudget = t.ActualBudget, BusinessType = t.BusinessType, CampaginName = t.CampaginName, CampaignId = t.CampaignId, @@ -152,7 +155,6 @@ namespace SBF.Business var skuIdList = list.Select(x => x.SkuId).Distinct().ToList(); //var spuIdList = list.Select(x => x.SpuId).Distinct().ToList(); - #region 推广花费 var costList = fsql.Select() .Where(x => x.ShopId == request.ShopId && @@ -168,7 +170,7 @@ namespace SBF.Business }); #endregion - #region 商品营业额 + #region SKU商品营业额 var actualAmountList = fsql.Select() .Where(x => x.ShopId == request.ShopId && x.Date >= startDate && x.Date <= endDate && @@ -243,8 +245,8 @@ namespace SBF.Business AdId = x.AdId, AdName = x.AdName, BidPrice = 0M, - OldBudget = 0M, - NewBudget = 0M, + AnchorBudget = 0M, + ActualBudget = 0M, BusinessType = x.BusinessType, CampaginName = x.CampaignName, CampaignId = x.CampaignId, @@ -277,5 +279,134 @@ namespace SBF.Business .Set(t => t.EndTime, DateTime.Now) .ExecuteAffrows(); } + + public TrusteeshipTaskResponse GetTrusteeshipTaskCurveResponse(long Id) + { + + var task = fsql.Select() + .InnerJoin((t, p, ps) => t.SpuId == p.Id) + .InnerJoin((t, p, ps) => t.SkuId == ps.Id) + .Where((t, p, ps) => t.Id == Id) + .OrderByDescending((t, p, ps) => t.CreateTime) + .ToOne((t, p, ps) => new Sbf_TrusteeshipTask() + { + Id = t.Id, + ShopId = t.ShopId, + SpuId = t.SpuId, + SkuId = t.SkuId, + ActualAmountInTrusteeship = t.ActualAmountInTrusteeship, + AdGroupId = t.AdGroupId, + AdGroupName = t.AdGroupName, + AdId = t.AdId, + AdName = t.AdName, + BidPrice = t.BidPrice, + AnchorBudget = t.AnchorBudget, + ActualBudget = t.ActualBudget, + BusinessType = t.BusinessType, + CampaginName = t.CampaginName, + CampaignId = t.CampaignId, + CostInTrusteeship = t.CostInTrusteeship, + CreateTime = t.CreateTime, + EndTime = t.EndTime, + IsEnd = t.IsEnd, + StartTrusteeshipDate = t.StartTrusteeshipDate, + PolicyType = t.PolicyType, + + Logo = ps.Logo, + Price = ps.Price, + SkuTitle = ps.Title, + SkuState = ps.State, + SkuCreateTime = ps.CreateTime, + CategoryId = ps.CategoryId, + CategoryName = ps.CategoryName, + + MainSkuId = p.MainSkuId, + ProductCreateTime = p.CreateTime, + ProductItemNum = p.ProductItemNum, + ProductState = p.State, + ProductTitle = p.Title, + Stage = p.Stage, + Platform = p.Platform + }) + .Map(); + + var startDate = DateTime.Now.Date.AddDays(-30); + var endDate = DateTime.Now.Date.AddDays(-1); + + //var spuIdList = list.Select(x => x.SpuId).Distinct().ToList(); + + #region 推广花费/推广盈利 + var costList = fsql.Select() + .Where(x => x.ShopId == task.ShopId && + x.Date >= startDate && x.Date <= endDate && + x.BusinessType == task.BusinessType && + x.CampaignId == task.CampaignId && + x.SkuId == task.SkuId) + .ToList(x => new + { + x.Date, + x.SkuId, + x.CampaignId, + x.BusinessType, + x.Cost, + x.PopularizeLevelProfit + }); + #endregion + + #region SKU商品营业额 + var actualAmountList = fsql.Select() + .Where(x => x.ShopId == task.ShopId && + x.Date >= startDate && x.Date <= endDate && + x.SkuId == task.SkuId) + .ToList(x => new + { + x.Date, + x.SkuId, + x.Cost, + x.ActualAmount + }); + + #endregion + + #region 免费访客量 + var shopIdStr = task.ShopId.ToString(); + var uvList = _freeSqlMultiDBManager.XXfsql.Select().Where(s => s.ShopId == shopIdStr && + s.CreateTime >= startDate && + s.CreateTime <= endDate && + s.Sku == task.SkuId) + .ToList(s => new { s.Uv, s.Sku, Date = s.CreateTime }); + #endregion + + + task.CostByDateList = costList.OrderBy(x => x.Date) + .Select(x => new NumberByDate() + { + Date = x.Date, + Value = x.Cost + }).ToList(); + + task.PopluarizeProfitByDateList = costList.OrderBy(x => x.Date) + .Select(x => new NumberByDate() + { + Date = x.Date, + Value = x.PopularizeLevelProfit - x.Cost + }).ToList(); + + task.ActualAmountByDateList = actualAmountList.OrderBy(x => x.Date) + .Select(x => new NumberByDate() + { + Date = x.Date, + Value = x.ActualAmount + }).ToList(); + + task.UVByDateList = uvList.OrderBy(x => x.Date) + .Select(x => new NumberByDate() + { + Date = x.Date, + Value = x.Uv + }).ToList(); + + return task; + } } } diff --git a/SBF.Model/Db/Trusteeship/Sbf_TrusteeshipTask.cs b/SBF.Model/Db/Trusteeship/Sbf_TrusteeshipTask.cs index 7aa92ba..c093870 100644 --- a/SBF.Model/Db/Trusteeship/Sbf_TrusteeshipTask.cs +++ b/SBF.Model/Db/Trusteeship/Sbf_TrusteeshipTask.cs @@ -47,16 +47,16 @@ namespace SBF.Model.Db public decimal? BidPrice { get; set; } = 0.00M; /// - /// 原预算 + /// 锚定预算 /// [Column(DbType = "decimal(18,2)")] - public decimal? OldBudget { get; set; } = 0.00M; + public decimal? AnchorBudget { get; set; } = 0.00M; /// - /// 最新预算 + /// 实际预算 /// [Column(DbType = "decimal(18,2)")] - public decimal? NewBudget { get; set; } = 0.00M; + public decimal? ActualBudget { get; set; } = 0.00M; /// /// 业务类型/渠道 快车=2,智能投放=134217728 diff --git a/SBF.Model/Dto/Response/TrusteeshipTaskResponse.cs b/SBF.Model/Dto/Response/TrusteeshipTaskResponse.cs index ba029f2..fd4891e 100644 --- a/SBF.Model/Dto/Response/TrusteeshipTaskResponse.cs +++ b/SBF.Model/Dto/Response/TrusteeshipTaskResponse.cs @@ -10,6 +10,8 @@ namespace SBF.Model.Dto public string SkuId { get; set; } + public long? ShopId { get; set; } + #region public ProductSku ProductSku { get; set; } @@ -49,14 +51,14 @@ namespace SBF.Model.Dto public string AdName { get; set; } /// - /// 原预算 + /// 锚定预算 /// - public decimal? OldBudget { get; set; } = 0.00M; + public decimal? AnchorBudget { get; set; } = 0.00M; /// - /// 最新预算 + /// 实际预算 /// - public decimal? NewBudget { get; set; } = 0.00M; + public decimal? ActualBudget { get; set; } = 0.00M; /// /// 出价 @@ -88,6 +90,11 @@ namespace SBF.Model.Dto /// public IList UVByDateList { get; set; } + /// + /// 按日期分组的推广盈利 + /// + public IList PopluarizeProfitByDateList { get; set; } + /// /// 托管开始时间 /// diff --git a/SBF.Model/Dto/Response/TruststeeshipTaskCurveResponse.cs b/SBF.Model/Dto/Response/TruststeeshipTaskCurveResponse.cs new file mode 100644 index 0000000..e8fc04a --- /dev/null +++ b/SBF.Model/Dto/Response/TruststeeshipTaskCurveResponse.cs @@ -0,0 +1,6 @@ +namespace SBF.Model.Dto.Response +{ + public class TruststeeshipTaskCurveResponse + { + } +}