diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..1a3dcd3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +[*.cs] + +# CS8601: 引用类型赋值可能为 null。 +dotnet_diagnostic.CS8601.severity = none diff --git a/SiNan.API.sln b/SiNan.API.sln index f680933..100e9c9 100644 --- a/SiNan.API.sln +++ b/SiNan.API.sln @@ -7,9 +7,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SiNan.API", "SiNan.API\SiNa EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SiNan.Business", "SiNan.Business\SiNan.Business.csproj", "{D936217A-5B0C-4E88-B9BD-F97A3C2EA1D9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiNan.Model", "SiNan.Model\SiNan.Model.csproj", "{8524A12A-FE6B-49BC-866B-52CB53C8BD1F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SiNan.Model", "SiNan.Model\SiNan.Model.csproj", "{8524A12A-FE6B-49BC-866B-52CB53C8BD1F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiNan.Common", "SiNan.Common\SiNan.Common.csproj", "{521CB52C-EA2F-482D-AE07-EEF966552094}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SiNan.Common", "SiNan.Common\SiNan.Common.csproj", "{521CB52C-EA2F-482D-AE07-EEF966552094}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{03E977B9-54D8-45AC-97CB-C1B4D89BE94B}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/SiNan.Business/GOIBusiness.cs b/SiNan.Business/GOIBusiness.cs index 36c9e90..ab97612 100644 --- a/SiNan.Business/GOIBusiness.cs +++ b/SiNan.Business/GOIBusiness.cs @@ -1,5 +1,12 @@ -using SiNan.Common.Log; +using AutoMapper; +using FreeSql; +using Google.Protobuf.Collections; +using SiNan.Common.Extensions; +using SiNan.Common.Log; using SiNan.Common.Models; +using SiNan.Model; +using SiNan.Model.Core; +using SiNan.Model.Db; using SiNan.Model.Dto; using Yitter.IdGenerator; @@ -13,9 +20,234 @@ namespace SiNan.Business this.freeSqlMultiDBManager = freeSqlMultiDBManager; } + private IList StatisticsProductLevelGOI(IList skuIdList, DateTime startDate, DateTime endDate) + { + var costs = fsql.Select() + .Where(jas => skuIdList.Contains(jas.Sku) && jas.Date >= startDate && jas.Date <= endDate) + .GroupBy(jas => jas.Sku) + .ToList(g => new + { + Cost = g.Sum(g.Value.Cost), + Sku = g.Key + }); + + var profits = fsql.Select() + .InnerJoin((ocd, o) => ocd.OrderId == o.Id) + .Where((ocd, o) => skuIdList.Contains(ocd.SkuId) && + ocd.IsEnabled && + ocd.CreateTime >= startDate && + ocd.CreateTime <= endDate && + o.OrderState != Enums.OrderState.已取消) + .GroupBy((ocd, o) => ocd.SkuId) + .ToList(g => new + { + Profit = g.Sum(g.Value.Item1.SkuGrossProfit), + Sku = g.Key + }); + IList list = new List(); + foreach (var c in costs) + { + var skugoi = list.FirstOrDefault(x => x.Sku == c.Sku); + if (skugoi == null) + { + skugoi = new GOIBySku() { Sku = c.Sku }; + list.Add(skugoi); + } + skugoi.Cost = c.Cost; + } + + foreach (var p in profits) + { + var skugoi = list.FirstOrDefault(x => x.Sku == p.Sku); + if (skugoi == null) + { + skugoi = new GOIBySku() { Sku = p.Sku }; + list.Add(skugoi); + } + skugoi.Profit = p.Profit; + } + return list; + } + + private IList StatisticsPopularizeLevelGOI(IList skuIdList, DateTime startDate, DateTime endDate) + { + IList list = new List(); + + var costs = fsql.Select() + .Where(jas => skuIdList.Contains(jas.Sku) && + jas.Date >= startDate && jas.Date <= endDate) + .GroupBy(jas => jas.Sku) + .ToList(g => new + { + Cost = g.Sum(g.Value.Cost), + Sku = g.Key + }); + + var profits = fsql.Select() + .InnerJoin((jr, ocd, o) => jr.OrderId == ocd.OrderId) + .InnerJoin((jr, ocd, o) => jr.OrderId == o.Id) + .Where((jr, ocd, o) => skuIdList.Contains(jr.PopularizeSku) && + jr.CookieTime >= startDate && jr.CookieTime <= endDate && + ocd.IsEnabled == true && + o.OrderState != Enums.OrderState.已取消) + .GroupBy((jr, ocd, o) => jr.PopularizeSku) + .ToList(g => new + { + Profit = g.Sum(g.Value.Item2.SkuGrossProfit), + Sku = g.Key + }); + + foreach (var c in costs) + { + var skugoi = list.FirstOrDefault(x => x.Sku == c.Sku); + if (skugoi == null) + { + skugoi = new GOIBySku() { Sku = c.Sku }; + list.Add(skugoi); + } + skugoi.Cost = c.Cost; + } + + foreach (var p in profits) + { + var skugoi = list.FirstOrDefault(x => x.Sku == p.Sku); + if (skugoi == null) + { + skugoi = new GOIBySku() { Sku = p.Sku }; + list.Add(skugoi); + } + skugoi.Profit = p.Profit; + } + + return list; + } + public ListResponse QueryProductGOI(QueryProductGOIRequest request) { - return new ListResponse(); + if (request.ShopId == 0) + throw new BusinessException("缺少店铺Id"); + + ISelect? skuChildSelect = string.IsNullOrEmpty(request.Sku) ? + null : + fsql.Select().As("ps").Where(ps => ps.ShopId == request.ShopId && ps.Id == request.Sku); + var productList = fsql.Select().Where(p => p.ShopId == request.ShopId) + .WhereIf(!string.IsNullOrEmpty(request.Spu), p => p.Id == request.Spu) + .WhereIf(skuChildSelect != null, p => skuChildSelect.Where(ps => ps.ProductId == p.Id).Any()) + .Page(request.PageIndex, request.PageSize) + .Count(out var productCount) + .ToList(); + if (productList.Count == 0) + return new ListResponse() { ItemList = new List() }; + + var productIdList = productList.Select(p => p.Id).ToList(); + var skuList = fsql.Select().Where(ps => productIdList.Contains(ps.Id)).ToList(); + var skuIdList = skuList.Select(s => s.Id).ToList(); + + var startDate_yestoday = DateTime.Now.Date.AddDays(-1); + var endDate_yestoday = DateTime.Now.Date.AddSeconds(-1); + + var startDate_Recent7day = DateTime.Now.Date.AddDays(-7); + var endDate_Recent7day = DateTime.Now.Date.AddSeconds(-1); + + var startDate_Recent30day = DateTime.Now.Date.AddDays(-30); + var endDate_Recent30day = DateTime.Now.Date.AddSeconds(-1); + + #region 商品维度 + + //昨天 + var yestodayProductLevelGOIList = StatisticsProductLevelGOI(skuIdList, startDate_yestoday, endDate_yestoday); + + //近7天 + var recent7dayProductLevelGOIList = StatisticsProductLevelGOI(skuIdList, startDate_Recent7day, endDate_Recent7day); + + //近30天 + var recent30dayProductLevelGOIList = StatisticsProductLevelGOI(skuIdList, startDate_Recent30day, endDate_Recent30day); + + #endregion + + #region 推广维度 + //昨天 + var yestodayPopularizeLevelGOIList = StatisticsPopularizeLevelGOI(skuIdList, startDate_yestoday, endDate_yestoday); + + //近7天 + var recent7dayPopularizeLevelGOIList = StatisticsPopularizeLevelGOI(skuIdList, startDate_Recent7day, endDate_Recent7day); + + //近30天 + var recent30dayPopularizeLevelGOIList = StatisticsPopularizeLevelGOI(skuIdList, startDate_Recent30day, endDate_Recent30day); + #endregion + + #region 累计花费 + var accumulatCosts = fsql.Select() + .Where(x => x.ShopId == request.ShopId && + skuIdList.Contains(x.Sku) && + x.Date >= request.StartDate && + x.Date <= request.EndDate) + .GroupBy(x => x.Sku) + .ToList(g => new + { + Cost = g.Sum(g.Value.Cost), + Sku = g.Key + }); + #endregion + + List productGOIList = new List(); + foreach (var product in productList) + { + var productGoi = product.Map(); + productGOIList.Add(productGoi); + + productGoi.ProductSkuGOIList = skuList.Where(ps => ps.ProductId == product.Id).Map>(); + foreach (var productSku in productGoi.ProductSkuGOIList) + { + productSku.ProductGOI_Yestoday = yestodayProductLevelGOIList.FirstOrDefault(x => x.Sku == productSku.Id); + productSku.ProductGOI_Recent7Day = recent7dayProductLevelGOIList.FirstOrDefault(x => x.Sku == productSku.Id); + productSku.ProductGOI_Recent30Day = recent30dayProductLevelGOIList.FirstOrDefault(x => x.Sku == productSku.Id); + productSku.PromotionGOI_Yestoday = yestodayPopularizeLevelGOIList.FirstOrDefault(x => x.Sku == productSku.Id); + productSku.PromotionGOI_Recent7Day = recent7dayPopularizeLevelGOIList.FirstOrDefault(x => x.Sku == productSku.Id); + productSku.PromotionGOI_Recent30Day = recent30dayPopularizeLevelGOIList.FirstOrDefault(x => x.Sku == productSku.Id); + productSku.TotalCost = accumulatCosts.FirstOrDefault(x => x.Sku == productSku.Id)?.Cost ?? 0M; + } + + productGoi.ProductGOI_Yestoday = new GOIResponse() + { + Cost = productGoi.ProductSkuGOIList.Sum(x => x.ProductGOI_Yestoday?.Cost ?? 0M), + Profit = productGoi.ProductSkuGOIList.Sum(x => x.ProductGOI_Yestoday?.Profit ?? 0M) + }; + productGoi.ProductGOI_Recent7Day = new GOIResponse() + { + Cost = productGoi.ProductSkuGOIList.Sum(x => x.ProductGOI_Recent7Day?.Cost ?? 0M), + Profit = productGoi.ProductSkuGOIList.Sum(x => x.ProductGOI_Recent7Day?.Profit ?? 0M) + }; + productGoi.ProductGOI_Recent30Day = new GOIResponse() + { + Cost = productGoi.ProductSkuGOIList.Sum(x => x.ProductGOI_Recent30Day?.Cost ?? 0M), + Profit = productGoi.ProductSkuGOIList.Sum(x => x.ProductGOI_Recent30Day?.Profit ?? 0M) + }; + + productGoi.PromotionGOI_Yestoday = new GOIResponse() + { + Cost = productGoi.ProductSkuGOIList.Sum(x => x.PromotionGOI_Yestoday?.Cost ?? 0M), + Profit = productGoi.ProductSkuGOIList.Sum(x => x.PromotionGOI_Yestoday?.Profit ?? 0M) + }; + productGoi.PromotionGOI_Recent7Day = new GOIResponse() + { + Cost = productGoi.ProductSkuGOIList.Sum(x => x.PromotionGOI_Recent7Day?.Cost ?? 0M), + Profit = productGoi.ProductSkuGOIList.Sum(x => x.PromotionGOI_Recent7Day?.Profit ?? 0M) + }; + productGoi.PromotionGOI_Recent30Day = new GOIResponse() + { + Cost = productGoi.ProductSkuGOIList.Sum(x => x.PromotionGOI_Recent30Day?.Cost ?? 0M), + Profit = productGoi.ProductSkuGOIList.Sum(x => x.PromotionGOI_Recent30Day?.Profit ?? 0M) + }; + productGoi.TotalCost = productGoi.ProductSkuGOIList.Sum(x => x.TotalCost); + } + + + return new ListResponse() + { + Count = productCount, + ItemList = productGOIList + }; } } } diff --git a/SiNan.Model/Core/GOI/GOIBySku.cs b/SiNan.Model/Core/GOI/GOIBySku.cs new file mode 100644 index 0000000..95a6f83 --- /dev/null +++ b/SiNan.Model/Core/GOI/GOIBySku.cs @@ -0,0 +1,9 @@ +using SiNan.Model.Dto; + +namespace SiNan.Model.Core +{ + public class GOIBySku : GOIResponse + { + public string Sku { get; set; } + } +} diff --git a/SiNan.Model/Db/GOI/JDOrderPopularizeRelation.cs b/SiNan.Model/Db/GOI/JDOrderPopularizeRelation.cs new file mode 100644 index 0000000..afbc3e3 --- /dev/null +++ b/SiNan.Model/Db/GOI/JDOrderPopularizeRelation.cs @@ -0,0 +1,75 @@ +using FreeSql.DataAnnotations; +using System; + +namespace SiNan.Model.Db +{ + + /// + /// 京东订单推广归属关系表 + /// + [Table(Name = "jdorderpopularizerelation", DisableSyncStructure = true)] + public partial class JDOrderPopularizeRelation { + + [ Column(IsPrimary = true)] + public long Id { get; set; } + + /// + /// 单元Id + /// + + public long? AdGroupId { get; set; } + + /// + /// 创意Id + /// + + public long? AdId { get; set; } + + /// + /// 业务线(快车:2 京速推:134217728) + /// + + public int? BusinessType { get; set; } + + /// + /// 计划Id + /// + + public long? CampaignId { get; set; } + + [Column(DbType = "datetime")] + public DateTime? CreateTime { get; set; } + + [Column(DbType = "datetime")] + public DateTime? OrderTime { get; set; } + + /// + /// 点击时间 + /// + [Column(DbType = "datetime")] + public DateTime? CookieTime { get; set; } + + /// + /// 订单Id + /// + [Column(StringLength = 50)] + public string OrderId { get; set; } + + /// + /// 下单Sku + /// + [Column(StringLength = 50)] + public string PlaceOrderSku { get; set; } + + /// + /// 推广Sku + /// + [Column(StringLength = 50)] + public string PopularizeSku { get; set; } + + + public long? ShopId { get; set; } + + } + +} diff --git a/SiNan.Model/Db/GOI/JDPopularizeAdGroup.cs b/SiNan.Model/Db/GOI/JDPopularizeAdGroup.cs new file mode 100644 index 0000000..63a272e --- /dev/null +++ b/SiNan.Model/Db/GOI/JDPopularizeAdGroup.cs @@ -0,0 +1,88 @@ +using FreeSql.DataAnnotations; +using System; + +namespace SiNan.Model.Db +{ + + /// + /// 京东推广单元表 + /// + [Table(Name = "jdpopularizeadgroup", DisableSyncStructure = true)] + public partial class JDPopularizeAdGroup + { + + [Column(IsPrimary = true)] + public long Id { get; set; } + + /// + /// 单元Id + /// + + public long? AdGroupId { get; set; } + + [Column(StringLength = 100)] + public string AdGroupName { get; set; } + + /// + /// 业务线(快车:2 京速推:134217728) + /// + + public int? BusinessType { get; set; } + + /// + /// 计划Id + /// + + public long? CampaignId { get; set; } + + /// + /// 点击数 + /// + [Column(Name = "clicks")] + 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")] + public int? Impressions { get; set; } + + /// + /// 账号归属 + /// + [Column(Name = "pin")] + public string Pin { get; set; } + + + public long? ShopId { get; set; } + + /// + /// 总加购人数 + /// + [Column(Name = "totalCartCnt")] + public int? TotalCartCnt { get; set; } + + /// + /// 总订单数 + /// + [Column(Name = "totalOrderCnt")] + public int? TotalOrderCnt { get; set; } + + } + +} diff --git a/SiNan.Model/Db/GOI/JDPopularizeAdSku.cs b/SiNan.Model/Db/GOI/JDPopularizeAdSku.cs new file mode 100644 index 0000000..633b46f --- /dev/null +++ b/SiNan.Model/Db/GOI/JDPopularizeAdSku.cs @@ -0,0 +1,108 @@ +using FreeSql.DataAnnotations; +using System; + +namespace SiNan.Model.Db +{ + + /// + /// 京东推广SKU创意表 + /// + [Table(Name = "jdpopularizeadsku", DisableSyncStructure = true)] + public partial class JDPopularizeAdSku + { + + [Column(IsPrimary = true)] + public long Id { get; set; } + + /// + /// 单元Id + /// + + public long? AdGroupId { get; set; } + + /// + /// 创意Id + /// + + public long? AdId { get; set; } + + [Column(StringLength = 100)] + public string AdName { get; set; } + + /// + /// 业务线(快车:2 京速推:134217728) + /// + + public int? BusinessType { get; set; } + + /// + /// 计划Id + /// + + public long? CampaignId { get; set; } + + /// + /// 点击数 + /// + [Column(Name = "clicks")] + 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")] + public int? Impressions { get; set; } + + /// + /// 账号归属 + /// + [Column(Name = "pin")] + public string Pin { get; set; } + + + public long? ShopId { get; set; } + + [Column(StringLength = 50)] + public string Sku { get; set; } + + /// + /// 总加购人数 + /// + [Column(Name = "totalCartCnt")] + public int? TotalCartCnt { get; set; } + + /// + /// 总订单数 + /// + [Column(Name = "totalOrderCnt")] + public int? TotalOrderCnt { get; set; } + + /// + /// 总订单金额 + /// + [Column(Name = "totalOrderSum")] + public decimal TotalOrderSum { get; set; } + + /// + /// 访客数 + /// + [Column(Name = "visitorCnt")] + public int VisitorCnt { get; set; } + } + +} diff --git a/SiNan.Model/Db/GOI/JDPopularizeCampaign.cs b/SiNan.Model/Db/GOI/JDPopularizeCampaign.cs new file mode 100644 index 0000000..21821fc --- /dev/null +++ b/SiNan.Model/Db/GOI/JDPopularizeCampaign.cs @@ -0,0 +1,81 @@ +using FreeSql.DataAnnotations; +using System; + +namespace SiNan.Model.Db +{ + + /// + /// 京东推广计划表 + /// + [Table(Name = "jdpopularizecampaign", DisableSyncStructure = true)] + public partial class JDPopularizeCampaign + { + + [Column(IsPrimary = true)] + public long Id { get; set; } + + /// + /// 业务线(快车:2 京速推:134217728) + /// + + public int? BusinessType { get; set; } + + /// + /// 计划Id + /// + public long? CampaignId { get; set; } + + [Column(StringLength = 100)] + public string CampaignName { get; set; } + + /// + /// 点击数 + /// + [Column(Name = "clicks")] + 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")] + public int? Impressions { get; set; } + + /// + /// 账号归属 + /// + [Column(Name = "pin")] + public string Pin { get; set; } + + + public long? ShopId { get; set; } + + /// + /// 总加购人数 + /// + [Column(Name = "totalCartCnt")] + public int? TotalCartCnt { get; set; } + + /// + /// 总订单数 + /// + [Column(Name = "totalOrderCnt")] + public int? TotalOrderCnt { get; set; } + + } + +} diff --git a/SiNan.Model/Db/Order/Order.cs b/SiNan.Model/Db/Order/Order.cs new file mode 100644 index 0000000..831ea26 --- /dev/null +++ b/SiNan.Model/Db/Order/Order.cs @@ -0,0 +1,289 @@ +using FreeSql.DataAnnotations; + +namespace SiNan.Model.Db +{ + + /// + /// 订单表 + /// + [Table(Name = "order", DisableSyncStructure = true)] + public partial class Order + { + + [Column(StringLength = 50, IsPrimary = true, IsNullable = false)] + public string Id { get; set; } + + /// + /// 买家备注 + /// + + public string BuyerRemark { get; set; } + + /// + /// 结束时间 + /// + [Column(DbType = "datetime")] + public DateTime? EndTime { get; set; } + + /// + /// 商品运费(用户承担) + /// + [Column(DbType = "decimal(20,2)")] + public decimal FreightPrice { get; set; } = 0.00M; + + /// + /// 修改时间 + /// + [Column(DbType = "datetime")] + public DateTime? ModifyTime { get; set; } + + /// + /// 用户应付金额 + /// + [Column(DbType = "decimal(20,2)")] + public decimal OrderPayment { get; set; } = 0.00M; + + /// + /// 订单货款金额 + /// + [Column(DbType = "decimal(20,2)")] + public decimal OrderSellerPrice { get; set; } = 0.00M; + + /// + /// 平台补贴 + /// + [Column(DbType = "decimal(20,2)")] + public decimal PreferentialAmount { get; set; } = 0.00M; + + /// + /// 商家优惠金额(商家承担) + /// + [Column(DbType = "decimal(20,2)")] + public decimal SellerPreferentialAmount { get; set; } = 0.00M; + + /// + /// 订单状态 + /// + [Column(DbType = "int(1)", MapType = typeof(int?))] + public Enums.OrderState? OrderState { get; set; } + + /// + /// 订单总价 + /// + [Column(DbType = "decimal(20,2)")] + public decimal OrderTotalPrice { get; set; } = 0.00M; + + /// + /// 订单类型 + /// + [Column(DbType = "int(1)", MapType = typeof(int?))] + public Enums.OrderType? OrderType { get; set; } + + /// + /// 支付方式 + /// + [Column(DbType = "int(1)", MapType = typeof(int?))] + public Enums.PayType? PayType { get; set; } + + /// + /// 订单平台 + /// + [Column(DbType = "int(1)", MapType = typeof(int?))] + public Enums.Platform? Platform { get; set; } + + /// + /// 开始时间 + /// + [Column(DbType = "datetime")] + public DateTime? StartTime { get; set; } + + /// + /// 仓储类型 + /// + [Column(DbType = "int(1)", MapType = typeof(int?))] + public Enums.StorageType? StorageType { get; set; } + + /// + /// 入仓订单标识 + /// + [Column(StringLength = 50)] + public string StoreOrder { get; set; } + + /// + /// 商家Id + /// + public long ShopId { get; set; } + + /// + /// 商家备注 + /// + + public string VenderRemark { get; set; } + + + public string PurchaseRemark { get; set; } + + /// + /// 仓库Id + /// + [Column(StringLength = 50)] + public string StoreId { get; set; } + + /// + /// 运单号 + /// + [Column(StringLength = 200)] + public string WaybillNo { get; set; } + + /// + /// 订单旗帜 + /// + [Column(StringLength = 10)] + public string Flag { get; set; } + + /// + /// 刷单类型 + /// + [Column(MapType = (typeof(int?)))] + public Enums.SDType? SDType { get; set; } + + /// + /// 刷单关键词 + /// + [Column(StringLength = 50)] + public string SDKey { get; set; } + + /// + /// 刷单支付渠道 + /// + [Column(MapType = (typeof(int?)))] + public Enums.PayChannelType? SDPayChannel { get; set; } + + /// + /// 刷单交易账单号 + /// + [Column(StringLength = 50)] + public string SDPayBillNo { get; set; } + + /// + /// 刷单人 + /// + [Column(StringLength = 20)] + public string SDOperator { get; set; } + + /// + /// 是否为售后订单 + /// + [Column(DbType = "bit")] + public bool IsAfterSaleOrder { get; set; } = false; + + /// + /// 是否为赠品 + /// + [Column(DbType = "bit")] + public bool IsGift { get; set; } = false; + + #region 订单成本 + /// + /// 平台扣点金额 + /// + [Column(IsIgnore = true)] + public decimal? PlatformCommissionAmount { get; set; } + + /// + /// 平台扣点百分比 + /// + [Column(IsIgnore = true)] + public decimal? PlatformCommissionRatio { get; set; } + + /// + /// 利润 + /// + [Column(IsIgnore = true)] + public decimal? Profit { get; set; } + + /// + /// 采购金额 + /// + [Column(IsIgnore = true)] + public decimal? PurchaseAmount { get; set; } = 0.00M; + + /// + /// 刷单佣金 + /// + [Column(IsIgnore = true)] + public decimal? SDCommissionAmount { get; set; } = 0.00M; + + /// + /// 刷单号费 + /// + [Column(IsIgnore = true)] + public decimal? SDOrderAmount { get; set; } = 0.00M; + + /// + /// 发货快递费 + /// + [Column(IsIgnore = true)] + public decimal? DeliveryExpressFreight { get; set; } = 0.00M; + + /// + /// 是否手动编辑过成本 + /// + [Column(IsIgnore = true)] + public bool IsManualEdited { get; set; } = false; + + /// + /// 退款金额 + /// + [Column(IsIgnore = true)] + public decimal RefundAmount { get; set; } = 0.00M; + + /// + /// 退款采购金额 + /// + [Column(IsIgnore = true)] + public decimal RefundPurchaseAmount { get; set; } = 0.0M; + + /// + /// 所有服务单的售后成本(不含退款采购成本) + /// + [Column(IsIgnore = true)] + public decimal AfterTotalCost { get; set; } = 0.0M; + #endregion + + #region 收货人信息 + [Column(IsIgnore = true)] + public string Address { get; set; } + + [Column(IsIgnore = true)] + public string City { get; set; } + + [Column(IsIgnore = true)] + public string ContactName { get; set; } + + [Column(IsIgnore = true)] + public string County { get; set; } + + [Column(IsIgnore = true)] + public string Mobile { get; set; } + + [Column(IsIgnore = true)] + public string Province { get; set; } + + [Column(IsIgnore = true)] + public string TelePhone { get; set; } + + [Column(IsIgnore = true)] + public string Town { get; set; } + + [Column(IsIgnore = true)] + public bool? IsDecode { get; set; } + #endregion + + #region 仓库 + [Column(IsIgnore = true)] + public string StoreName { get; set; } + #endregion + } + +} diff --git a/SiNan.Model/Db/Order/OrderCostDetail.cs b/SiNan.Model/Db/Order/OrderCostDetail.cs new file mode 100644 index 0000000..876523e --- /dev/null +++ b/SiNan.Model/Db/Order/OrderCostDetail.cs @@ -0,0 +1,121 @@ +using FreeSql.DataAnnotations; + +namespace SiNan.Model.Db +{ + + [Table(Name = "ordercostdetail", DisableSyncStructure = true)] + public partial class OrderCostDetail + { + + [Column(DbType = "bigint(1)", IsPrimary = true)] + public long Id { get; set; } + + [Column(DbType = "datetime")] + public DateTime? CreateTime { get; set; } + + /// + /// 扣减数量 + /// + [Column(DbType = "int(1)")] + public int DeductionQuantity { get; set; } = 0; + + /// + /// 发货运费 + /// + [Column(DbType = "decimal(20,2)")] + public decimal DeliveryExpressFreight { get; set; } = 0.00M; + + [Column(StringLength = 50)] + public string OrderId { get; set; } + + [Column(StringLength = 50)] + public string ProductId { get; set; } + + /*/// + /// 单件成本 + /// */ + //[Column(DbType = "decimal(20,2)")] + //public decimal UnitCost { get; set; } = 0.00M; + + /// + /// 采购单流水Id + /// + [Column(DbType = "bigint(1)")] + public long PurchaseOrderPKId { get; set; } + + [Column(StringLength = 50)] + public string SkuId { get; set; } + + /// + /// Sku成本(商品成本) + /// + [Column(DbType = "decimal(20,2)")] + public decimal SkuAmount { get; set; } = 0.00M; + + /// + /// 采购运费 + /// + [Column(DbType = "decimal(20,2)")] + public decimal PurchaseFreight { get; set; } = 0.00M; + + /// + /// 头程运费 + /// + [Column(DbType = "decimal(20,2)")] + public decimal FirstFreight { get; set; } = 0.00M; + + ///// + ///// 操作费 + ///// + //[Column(DbType = "decimal(20,2)")] + //public decimal OperationAmount { get; set; } = 0.00M; + + + /// + /// 入仓操作费 + /// + [Column(DbType = "decimal(20,2)")] + public decimal InStorageAmount { get; set; } = 0.00M; + + /// + /// 出仓操作费 + /// + [Column(DbType = "decimal(20,2)")] + public decimal OutStorageAmount { get; set; } = 0.00M; + + /// + /// 耗材费 + /// + [Column(DbType = "decimal(20,2)")] + public decimal ConsumableAmount { get; set; } = 0.00M; + + /// + /// 仓储费 + /// + [Column(DbType = "decimal(20,2)")] + public decimal StorageAmount { get; set; } = 0.00M; + + [Column(DbType = "bit")] + public bool IsEnabled { get; set; } = true; + + /// + /// sku毛利 + /// + [Column(DbType = "decimal(20,2)")] + public decimal SkuGrossProfit { get; set; } = 0.00M; + /// + /// 总计 + /// + [Column(IsIgnore = true)] + public decimal TotalCost + { + get + { + return SkuAmount + PurchaseFreight + FirstFreight + InStorageAmount + OutStorageAmount + StorageAmount + ConsumableAmount; + } + } + //[Column(DbType = "decimal(20,2)")] + //public decimal TotalCost { get; set; } = 0.00M; + } + +} diff --git a/SiNan.Model/Dto/Request/Product/QueryProductGOIRequest.cs b/SiNan.Model/Dto/Request/Product/QueryProductGOIRequest.cs index baa6244..7427194 100644 --- a/SiNan.Model/Dto/Request/Product/QueryProductGOIRequest.cs +++ b/SiNan.Model/Dto/Request/Product/QueryProductGOIRequest.cs @@ -14,6 +14,9 @@ public DateTime EndDate { get; set; } + /// + /// 页码 从1开始 + /// public int PageIndex { get; set; } public int PageSize { get; set; } diff --git a/SiNan.Model/Enums.cs b/SiNan.Model/Enums.cs index 40ffd3d..5c19ba3 100644 --- a/SiNan.Model/Enums.cs +++ b/SiNan.Model/Enums.cs @@ -22,5 +22,21 @@ 微信 = 4, 拳探 = 10 } + + /// + /// 订单状态 + /// + public enum OrderState + { + 待付款 = 0, + 等待采购 = 1, + 待出库 = 2, + 待收货 = 3, + 已完成 = 4, + 锁定 = 5, + 已取消 = 6, + 暂停 = 7, + 已退款 = 8 + } } } diff --git a/SiNan.Model/MappingProfiles.cs b/SiNan.Model/MappingProfiles.cs new file mode 100644 index 0000000..8462ee7 --- /dev/null +++ b/SiNan.Model/MappingProfiles.cs @@ -0,0 +1,14 @@ +using AutoMapper; +using SiNan.Model.Dto; + +namespace SiNan.Model +{ + public class MappingProfiles : Profile + { + public MappingProfiles() + { + CreateMap(); + CreateMap(); + } + } +} diff --git a/SiNan.Model/SiNan.Model.csproj b/SiNan.Model/SiNan.Model.csproj index ddc88ce..3c3d390 100644 --- a/SiNan.Model/SiNan.Model.csproj +++ b/SiNan.Model/SiNan.Model.csproj @@ -8,6 +8,11 @@ + + + + +