7 changed files with 432 additions and 1 deletions
@ -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; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 清理历史数据
|
|||
/// </summary>
|
|||
[HttpPost] |
|||
public void ClearHistoryData() |
|||
{ |
|||
autoTaskBusiness.ClearHistoryData(); |
|||
} |
|||
} |
|||
} |
@ -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<JDPopularizeCampaign>().Where(c => c.Date <= timeOutDate).ToList<HistoryJDPopularizeCampaign>(); |
|||
var adGroupList = fsql.Select<JDPopularizeAdGroup>().Where(adg => adg.Date <= timeOutDate).ToList<HistoryJDPopularizeAdGroup>(); |
|||
var adSkuList = fsql.Select<JDPopularizeAdSku>().Where(ads => ads.Date <= timeOutDate).ToList<HistoryJDPopularizeAdSku>(); |
|||
var orderPopRelationList = fsql.Select<JDOrderPopularizeRelation>().Where(x => x.CreateTime <= timeOutDate).ToList<HistoryJDOrderPopularizeRelation>(); |
|||
|
|||
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<JDPopularizeCampaign>(deleteCampaignIdList).ExecuteAffrows(); |
|||
fsql.Delete<JDPopularizeAdGroup>(deleteAdGroupIdList).ExecuteAffrows(); |
|||
fsql.Delete<JDPopularizeAdSku>(deleteAdSkuIdList).ExecuteAffrows(); |
|||
fsql.Delete<JDOrderPopularizeRelation>(deleteOrderPopRelationIdList).ExecuteAffrows(); |
|||
}); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,75 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace SiNan.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 京东订单推广归属关系表
|
|||
/// </summary>
|
|||
[Table(Name = "historyjdorderpopularizerelation", DisableSyncStructure = true)] |
|||
public partial class HistoryJDOrderPopularizeRelation |
|||
{ |
|||
|
|||
[Column(DbType = "bigint", IsPrimary = true)] |
|||
public long Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 单元Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? AdGroupId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创意Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? AdId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 业务线(快车:2 京速推:134217728)
|
|||
/// </summary>
|
|||
[Column(DbType = "int")] |
|||
public int? BusinessType { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 计划Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? CampaignId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 点击时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CookieTime { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 订单Id
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string OrderId { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? OrderTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 下单Sku
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string PlaceOrderSku { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 推广Sku
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string PopularizeSku { get; set; } |
|||
|
|||
[Column(DbType = "bigint")] |
|||
public long? ShopId { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,90 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace SiNan.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 京东推广单元表
|
|||
/// </summary>
|
|||
[Table(Name = "historyjdpopularizeadgroup", DisableSyncStructure = true)] |
|||
public partial class HistoryJDPopularizeAdGroup |
|||
{ |
|||
|
|||
[Column(DbType = "bigint", IsPrimary = true)] |
|||
public long Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 单元Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? AdGroupId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 单元名称
|
|||
/// </summary>
|
|||
[Column(StringLength = 100)] |
|||
public string AdGroupName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 业务线(快车:2 京速推:134217728)
|
|||
/// </summary>
|
|||
[Column(DbType = "int")] |
|||
public int? BusinessType { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 计划Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? CampaignId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 点击数
|
|||
/// </summary>
|
|||
[Column(Name = "clicks", DbType = "int")] |
|||
public int? Clicks { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 总花费
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? Cost { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 计费日期
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? Date { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 展现次数
|
|||
/// </summary>
|
|||
[Column(Name = "impressions", DbType = "int")] |
|||
public int? Impressions { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 账号归属
|
|||
/// </summary>
|
|||
[Column(Name = "pin")] |
|||
public string Pin { get; set; } |
|||
|
|||
[Column(DbType = "bigint")] |
|||
public long? ShopId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 总加购人数
|
|||
/// </summary>
|
|||
[Column(Name = "totalCartCnt", DbType = "int")] |
|||
public int? TotalCartCnt { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 总订单数
|
|||
/// </summary>
|
|||
[Column(Name = "totalOrderCnt", DbType = "int")] |
|||
public int? TotalOrderCnt { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,114 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace SiNan.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 京东推广SKU创意表
|
|||
/// </summary>
|
|||
[Table(Name = "historyjdpopularizeadsku", DisableSyncStructure = true)] |
|||
public partial class HistoryJDPopularizeAdSku |
|||
{ |
|||
|
|||
[Column(DbType = "bigint", IsPrimary = true)] |
|||
public long Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 单元Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? AdGroupId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创意Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? AdId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创意名称
|
|||
/// </summary>
|
|||
[Column(StringLength = 100)] |
|||
public string AdName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 业务线(快车:2 京速推:134217728)
|
|||
/// </summary>
|
|||
[Column(DbType = "int")] |
|||
public int? BusinessType { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 计划Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? CampaignId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 点击数
|
|||
/// </summary>
|
|||
[Column(Name = "clicks", DbType = "int")] |
|||
public int? Clicks { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 总花费
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? Cost { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 计费日期
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? Date { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 展现次数
|
|||
/// </summary>
|
|||
[Column(Name = "impressions", DbType = "int")] |
|||
public int? Impressions { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 账号归属
|
|||
/// </summary>
|
|||
[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; } |
|||
|
|||
/// <summary>
|
|||
/// 总加购人数
|
|||
/// </summary>
|
|||
[Column(Name = "totalCartCnt", DbType = "int")] |
|||
public int? TotalCartCnt { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 总订单数
|
|||
/// </summary>
|
|||
[Column(Name = "totalOrderCnt", DbType = "int")] |
|||
public int? TotalOrderCnt { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 总订单金额
|
|||
/// </summary>
|
|||
[Column(Name = "totalOrderSum", DbType = "decimal(11,2)")] |
|||
public decimal? TotalOrderSum { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 访客数
|
|||
/// </summary>
|
|||
[Column(Name = "visitorCnt", DbType = "int")] |
|||
public int? VisitorCnt { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,84 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace SiNan.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 京东推广计划表
|
|||
/// </summary>
|
|||
[Table(Name = "historyjdpopularizecampaign", DisableSyncStructure = true)] |
|||
public partial class HistoryJDPopularizeCampaign |
|||
{ |
|||
|
|||
[Column(DbType = "bigint", IsPrimary = true)] |
|||
public long Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 业务线(快车:2 京速推:134217728)
|
|||
/// </summary>
|
|||
[Column(DbType = "int")] |
|||
public int? BusinessType { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 计划Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? CampaignId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 计划名称
|
|||
/// </summary>
|
|||
[Column(StringLength = 100)] |
|||
public string CampaignName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 点击数
|
|||
/// </summary>
|
|||
[Column(Name = "clicks", DbType = "int")] |
|||
public int? Clicks { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 总花费
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? Cost { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 计费日期
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? Date { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 展现次数
|
|||
/// </summary>
|
|||
[Column(Name = "impressions", DbType = "int")] |
|||
public int? Impressions { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 账号归属
|
|||
/// </summary>
|
|||
[Column(Name = "pin")] |
|||
public string Pin { get; set; } |
|||
|
|||
[Column(DbType = "bigint")] |
|||
public long? ShopId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 总加购人数
|
|||
/// </summary>
|
|||
[Column(Name = "totalCartCnt", DbType = "int")] |
|||
public int? TotalCartCnt { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 总订单数
|
|||
/// </summary>
|
|||
[Column(Name = "totalOrderCnt", DbType = "int")] |
|||
public int? TotalOrderCnt { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -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" |
|||
|
Loading…
Reference in new issue