From e2689c0cdbac1ce50bbf93554b690fd1259abe71 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sun, 5 Nov 2023 00:56:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8E=86=E5=8F=B2=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=88=A0=E9=99=A4=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SiNan.API/Controllers/AutoTaskController.cs | 25 ++++ SiNan.Business/AutoTaskBusiness.cs | 43 +++++++ .../GOI/HistoryJDOrderPopularizeRelation.cs | 75 ++++++++++++ .../Db/GOI/HistoryJDPopularizeAdGroup.cs | 90 ++++++++++++++ .../Db/GOI/HistoryJDPopularizeAdSku.cs | 114 ++++++++++++++++++ .../Db/GOI/HistoryJDPopularizeCampaign.cs | 84 +++++++++++++ SiNan.Model/__重新生成.bat | 2 +- 7 files changed, 432 insertions(+), 1 deletion(-) create mode 100644 SiNan.API/Controllers/AutoTaskController.cs create mode 100644 SiNan.Business/AutoTaskBusiness.cs create mode 100644 SiNan.Model/Db/GOI/HistoryJDOrderPopularizeRelation.cs create mode 100644 SiNan.Model/Db/GOI/HistoryJDPopularizeAdGroup.cs create mode 100644 SiNan.Model/Db/GOI/HistoryJDPopularizeAdSku.cs create mode 100644 SiNan.Model/Db/GOI/HistoryJDPopularizeCampaign.cs diff --git a/SiNan.API/Controllers/AutoTaskController.cs b/SiNan.API/Controllers/AutoTaskController.cs new file mode 100644 index 0000000..bdf3bc2 --- /dev/null +++ b/SiNan.API/Controllers/AutoTaskController.cs @@ -0,0 +1,25 @@ +using Microsoft.AspNetCore.Mvc; +using SiNan.Business; + +namespace SiNan.API.Controllers +{ + + public class AutoTaskController : BaseApiController + { + private AutoTaskBusiness autoTaskBusiness; + + public AutoTaskController(IHttpContextAccessor httpContextAccessor, AutoTaskBusiness autoTaskBusiness) : base(httpContextAccessor) + { + this.autoTaskBusiness = autoTaskBusiness; + } + + /// + /// 清理历史数据 + /// + [HttpPost] + public void ClearHistoryData() + { + autoTaskBusiness.ClearHistoryData(); + } + } +} diff --git a/SiNan.Business/AutoTaskBusiness.cs b/SiNan.Business/AutoTaskBusiness.cs new file mode 100644 index 0000000..e48ca13 --- /dev/null +++ b/SiNan.Business/AutoTaskBusiness.cs @@ -0,0 +1,43 @@ +using SiNan.Common.Log; +using SiNan.Common.Models; +using SiNan.Model.Db; +using Yitter.IdGenerator; + +namespace SiNan.Business +{ + public class AutoTaskBusiness : BaseBusiness, IDenpendency + { + public AutoTaskBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator) : base(fsql, nLogManager, idGenerator) + { + + } + + public void ClearHistoryData() + { + var timeOutDate = DateTime.Now.Date.AddDays(-60); + + var campaignList = fsql.Select().Where(c => c.Date <= timeOutDate).ToList(); + var adGroupList = fsql.Select().Where(adg => adg.Date <= timeOutDate).ToList(); + var adSkuList = fsql.Select().Where(ads => ads.Date <= timeOutDate).ToList(); + var orderPopRelationList = fsql.Select().Where(x => x.CreateTime <= timeOutDate).ToList(); + + var deleteCampaignIdList = campaignList.Select(x => x.Id).ToList(); + var deleteAdGroupIdList = adGroupList.Select(x => x.Id).ToList(); + var deleteAdSkuIdList = adSkuList.Select(x => x.Id).ToList(); + var deleteOrderPopRelationIdList = orderPopRelationList.Select(x => x.Id).ToList(); + + fsql.Transaction(() => + { + fsql.Insert(campaignList).ExecuteAffrows(); + fsql.Insert(adGroupList).ExecuteAffrows(); + fsql.Insert(adSkuList).ExecuteAffrows(); + fsql.Insert(orderPopRelationList).ExecuteAffrows(); + + fsql.Delete(deleteCampaignIdList).ExecuteAffrows(); + fsql.Delete(deleteAdGroupIdList).ExecuteAffrows(); + fsql.Delete(deleteAdSkuIdList).ExecuteAffrows(); + fsql.Delete(deleteOrderPopRelationIdList).ExecuteAffrows(); + }); + } + } +} diff --git a/SiNan.Model/Db/GOI/HistoryJDOrderPopularizeRelation.cs b/SiNan.Model/Db/GOI/HistoryJDOrderPopularizeRelation.cs new file mode 100644 index 0000000..43c1d0a --- /dev/null +++ b/SiNan.Model/Db/GOI/HistoryJDOrderPopularizeRelation.cs @@ -0,0 +1,75 @@ +using FreeSql.DataAnnotations; + +namespace SiNan.Model.Db +{ + + /// + /// 京东订单推广归属关系表 + /// + [Table(Name = "historyjdorderpopularizerelation", DisableSyncStructure = true)] + public partial class HistoryJDOrderPopularizeRelation + { + + [Column(DbType = "bigint", IsPrimary = true)] + public long Id { get; set; } + + /// + /// 单元Id + /// + [Column(DbType = "bigint")] + public long? AdGroupId { get; set; } + + /// + /// 创意Id + /// + [Column(DbType = "bigint")] + public long? AdId { get; set; } + + /// + /// 业务线(快车:2 京速推:134217728) + /// + [Column(DbType = "int")] + public int? BusinessType { get; set; } + + /// + /// 计划Id + /// + [Column(DbType = "bigint")] + public long? CampaignId { get; set; } + + /// + /// 点击时间 + /// + [Column(DbType = "datetime")] + public DateTime? CookieTime { get; set; } + + [Column(DbType = "datetime")] + public DateTime? CreateTime { get; set; } + + /// + /// 订单Id + /// + [Column(StringLength = 50)] + public string OrderId { get; set; } + + [Column(DbType = "datetime")] + public DateTime? OrderTime { get; set; } + + /// + /// 下单Sku + /// + [Column(StringLength = 50)] + public string PlaceOrderSku { get; set; } + + /// + /// 推广Sku + /// + [Column(StringLength = 50)] + public string PopularizeSku { get; set; } + + [Column(DbType = "bigint")] + public long? ShopId { get; set; } + + } + +} diff --git a/SiNan.Model/Db/GOI/HistoryJDPopularizeAdGroup.cs b/SiNan.Model/Db/GOI/HistoryJDPopularizeAdGroup.cs new file mode 100644 index 0000000..cc35727 --- /dev/null +++ b/SiNan.Model/Db/GOI/HistoryJDPopularizeAdGroup.cs @@ -0,0 +1,90 @@ +using FreeSql.DataAnnotations; + +namespace SiNan.Model.Db +{ + + /// + /// 京东推广单元表 + /// + [Table(Name = "historyjdpopularizeadgroup", DisableSyncStructure = true)] + public partial class HistoryJDPopularizeAdGroup + { + + [Column(DbType = "bigint", IsPrimary = true)] + public long Id { get; set; } + + /// + /// 单元Id + /// + [Column(DbType = "bigint")] + public long? AdGroupId { get; set; } + + /// + /// 单元名称 + /// + [Column(StringLength = 100)] + public string AdGroupName { get; set; } + + /// + /// 业务线(快车:2 京速推:134217728) + /// + [Column(DbType = "int")] + public int? BusinessType { get; set; } + + /// + /// 计划Id + /// + [Column(DbType = "bigint")] + public long? CampaignId { get; set; } + + /// + /// 点击数 + /// + [Column(Name = "clicks", DbType = "int")] + public int? Clicks { get; set; } + + /// + /// 总花费 + /// + [Column(DbType = "decimal(18,2)")] + public decimal? Cost { get; set; } + + [Column(DbType = "datetime")] + public DateTime? CreateTime { get; set; } + + /// + /// 计费日期 + /// + [Column(DbType = "datetime")] + public DateTime? Date { get; set; } + + /// + /// 展现次数 + /// + [Column(Name = "impressions", DbType = "int")] + public int? Impressions { get; set; } + + /// + /// 账号归属 + /// + [Column(Name = "pin")] + public string Pin { get; set; } + + [Column(DbType = "bigint")] + public long? ShopId { get; set; } + + /// + /// 总加购人数 + /// + [Column(Name = "totalCartCnt", DbType = "int")] + public int? TotalCartCnt { get; set; } + + /// + /// 总订单数 + /// + [Column(Name = "totalOrderCnt", DbType = "int")] + public int? TotalOrderCnt { get; set; } + + } + +} diff --git a/SiNan.Model/Db/GOI/HistoryJDPopularizeAdSku.cs b/SiNan.Model/Db/GOI/HistoryJDPopularizeAdSku.cs new file mode 100644 index 0000000..049dbd2 --- /dev/null +++ b/SiNan.Model/Db/GOI/HistoryJDPopularizeAdSku.cs @@ -0,0 +1,114 @@ +using FreeSql.DataAnnotations; + +namespace SiNan.Model.Db +{ + + /// + /// 京东推广SKU创意表 + /// + [Table(Name = "historyjdpopularizeadsku", DisableSyncStructure = true)] + public partial class HistoryJDPopularizeAdSku + { + + [Column(DbType = "bigint", IsPrimary = true)] + public long Id { get; set; } + + /// + /// 单元Id + /// + [Column(DbType = "bigint")] + public long? AdGroupId { get; set; } + + /// + /// 创意Id + /// + [Column(DbType = "bigint")] + public long? AdId { get; set; } + + /// + /// 创意名称 + /// + [Column(StringLength = 100)] + public string AdName { get; set; } + + /// + /// 业务线(快车:2 京速推:134217728) + /// + [Column(DbType = "int")] + public int? BusinessType { get; set; } + + /// + /// 计划Id + /// + [Column(DbType = "bigint")] + public long? CampaignId { get; set; } + + /// + /// 点击数 + /// + [Column(Name = "clicks", DbType = "int")] + public int? Clicks { get; set; } + + /// + /// 总花费 + /// + [Column(DbType = "decimal(18,2)")] + public decimal? Cost { get; set; } + + [Column(DbType = "datetime")] + public DateTime? CreateTime { get; set; } + + /// + /// 计费日期 + /// + [Column(DbType = "datetime")] + public DateTime? Date { get; set; } + + /// + /// 展现次数 + /// + [Column(Name = "impressions", DbType = "int")] + public int? Impressions { get; set; } + + /// + /// 账号归属 + /// + [Column(Name = "pin")] + public string Pin { get; set; } + + [Column(StringLength = 50)] + public string ProductId { get; set; } + + [Column(DbType = "bigint")] + public long? ShopId { get; set; } + + [Column(StringLength = 50)] + public string Sku { get; set; } + + /// + /// 总加购人数 + /// + [Column(Name = "totalCartCnt", DbType = "int")] + public int? TotalCartCnt { get; set; } + + /// + /// 总订单数 + /// + [Column(Name = "totalOrderCnt", DbType = "int")] + public int? TotalOrderCnt { get; set; } + + /// + /// 总订单金额 + /// + [Column(Name = "totalOrderSum", DbType = "decimal(11,2)")] + public decimal? TotalOrderSum { get; set; } + + /// + /// 访客数 + /// + [Column(Name = "visitorCnt", DbType = "int")] + public int? VisitorCnt { get; set; } + + } + +} diff --git a/SiNan.Model/Db/GOI/HistoryJDPopularizeCampaign.cs b/SiNan.Model/Db/GOI/HistoryJDPopularizeCampaign.cs new file mode 100644 index 0000000..815aa63 --- /dev/null +++ b/SiNan.Model/Db/GOI/HistoryJDPopularizeCampaign.cs @@ -0,0 +1,84 @@ +using FreeSql.DataAnnotations; + +namespace SiNan.Model.Db +{ + + /// + /// 京东推广计划表 + /// + [Table(Name = "historyjdpopularizecampaign", DisableSyncStructure = true)] + public partial class HistoryJDPopularizeCampaign + { + + [Column(DbType = "bigint", IsPrimary = true)] + public long Id { get; set; } + + /// + /// 业务线(快车:2 京速推:134217728) + /// + [Column(DbType = "int")] + public int? BusinessType { get; set; } + + /// + /// 计划Id + /// + [Column(DbType = "bigint")] + public long? CampaignId { get; set; } + + /// + /// 计划名称 + /// + [Column(StringLength = 100)] + public string CampaignName { get; set; } + + /// + /// 点击数 + /// + [Column(Name = "clicks", DbType = "int")] + public int? Clicks { get; set; } + + /// + /// 总花费 + /// + [Column(DbType = "decimal(18,2)")] + public decimal? Cost { get; set; } + + [Column(DbType = "datetime")] + public DateTime? CreateTime { get; set; } + + /// + /// 计费日期 + /// + [Column(DbType = "datetime")] + public DateTime? Date { get; set; } + + /// + /// 展现次数 + /// + [Column(Name = "impressions", DbType = "int")] + public int? Impressions { get; set; } + + /// + /// 账号归属 + /// + [Column(Name = "pin")] + public string Pin { get; set; } + + [Column(DbType = "bigint")] + public long? ShopId { get; set; } + + /// + /// 总加购人数 + /// + [Column(Name = "totalCartCnt", DbType = "int")] + public int? TotalCartCnt { get; set; } + + /// + /// 总订单数 + /// + [Column(Name = "totalOrderCnt", DbType = "int")] + public int? TotalOrderCnt { get; set; } + + } + +} diff --git a/SiNan.Model/__重新生成.bat b/SiNan.Model/__重新生成.bat index a570f90..f4465c7 100644 --- a/SiNan.Model/__重新生成.bat +++ b/SiNan.Model/__重新生成.bat @@ -1,2 +1,2 @@ -FreeSql.Generator -Razor 1 -NameOptions 1,0,0,0 -NameSpace SiNan.Model.Db -DB "MySql,data source=rm-bp1508okrh23710yfao.mysql.rds.aliyuncs.com;port=3306;user id=qyroot;password=kaicn1132+-;initial catalog=bbwyb;charset=utf8;sslmode=none;" -FileName "{name}.cs" +FreeSql.Generator -Razor 1 -NameOptions 1,0,0,0 -NameSpace SiNan.Model.Db -DB "MySql,data source=rm-bp1508okrh23710yfao.mysql.rds.aliyuncs.com;port=3306;user id=qyroot;password=kaicn1132+-;initial catalog=bbwy_test;charset=utf8;sslmode=none;" -FileName "{name}.cs"