Browse Source

1

GOIAggregation
shanji 2 years ago
parent
commit
f96ea2e06a
  1. 26
      SiNan.API/Controllers/ProductController.cs
  2. 1
      SiNan.Business/GOIBusiness.cs
  3. 35
      SiNan.Business/ProductBusiness.cs
  4. 6
      SiNan.Model/Db/Product/Product.cs
  5. 6
      SiNan.Model/Db/Product/ProductSku.cs
  6. 12
      SiNan.Model/Dto/Request/Product/SetMaxDeficitThresholdRequest.cs
  7. 55
      SiNan.Model/Enums.cs

26
SiNan.API/Controllers/ProductController.cs

@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Mvc;
using SiNan.Business;
using SiNan.Model.Dto;
namespace SiNan.API.Controllers
{
public class ProductController : BaseApiController
{
private ProductBusiness productBusiness;
public ProductController(IHttpContextAccessor httpContextAccessor, ProductBusiness productBusiness) : base(httpContextAccessor)
{
this.productBusiness = productBusiness;
}
/// <summary>
/// 设置SKU最大亏损,级联更新SPU最大亏损
/// </summary>
/// <param name="request"></param>
[HttpPost]
public void SetMaxDeficitThreshold([FromBody]SetMaxDeficitThresholdRequest request)
{
productBusiness.SetMaxDeficitThreshold(request);
}
}
}

1
SiNan.Business/GOIBusiness.cs

@ -237,7 +237,6 @@ namespace SiNan.Business
productGoi.TotalDeficit = productGoi.ProductSkuGOIList.Sum(x => x.TotalDeficit);
}
return new ListResponse<ProductGOIResponse>()
{
Count = productCount,

35
SiNan.Business/ProductBusiness.cs

@ -0,0 +1,35 @@
using SiNan.Common.Log;
using SiNan.Common.Models;
using SiNan.Model.Db;
using SiNan.Model.Dto;
using Yitter.IdGenerator;
namespace SiNan.Business
{
public class ProductBusiness : BaseBusiness, IDenpendency
{
public ProductBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator) : base(fsql, nLogManager, idGenerator)
{
}
public void SetMaxDeficitThreshold(SetMaxDeficitThresholdRequest request)
{
var _temp = fsql.Select<ProductSku>(request.Sku).ToOne();
if (_temp == null)
throw new BusinessException("未查询到sku");
var productSkuList = fsql.Select<ProductSku>().Where(ps => ps.ProductId == _temp.ProductId).ToList();
var productSku = productSkuList.FirstOrDefault(ps => ps.Id == request.Sku);
productSku.MaxDeficitThreshold = request.MaxDeficitThreshold;
var spuMaxDeficitThreshold = productSkuList.Sum(ps => ps.MaxDeficitThreshold);
fsql.Transaction(() =>
{
fsql.Update<Product>(_temp.ProductId).Set(p => p.MaxDeficitThreshold, spuMaxDeficitThreshold).ExecuteAffrows();
fsql.Update<ProductSku>(request.Sku).Set(p => p.MaxDeficitThreshold, spuMaxDeficitThreshold).ExecuteAffrows();
});
}
}
}

6
SiNan.Model/Db/Product/Product.cs

@ -49,6 +49,12 @@ namespace SiNan.Model.Db
[Column(MapType = typeof(int), DbType = "int")]
public Enums.Stage Stage { get; set; } = Enums.Stage.;
/// <summary>
/// 最大亏损阈值
/// </summary>
[Column(DbType = "decimal(18,2)")]
public decimal? MaxDeficitThreshold { get; set; } = 0.00M;
}
}

6
SiNan.Model/Db/Product/ProductSku.cs

@ -52,6 +52,12 @@ namespace SiNan.Model.Db
public int? CategoryId { get; set; }
public string CategoryName { get; set; }
/// <summary>
/// 最大亏损阈值
/// </summary>
[Column(DbType = "decimal(18,2)")]
public decimal? MaxDeficitThreshold { get; set; } = 0.00M;
}
}

12
SiNan.Model/Dto/Request/Product/SetMaxDeficitThresholdRequest.cs

@ -0,0 +1,12 @@
namespace SiNan.Model.Dto
{
public class SetMaxDeficitThresholdRequest
{
public string Sku { get; set; }
/// <summary>
/// 最大亏损阈值
/// </summary>
public decimal MaxDeficitThreshold { get; set; }
}
}

55
SiNan.Model/Enums.cs

@ -23,6 +23,43 @@
= 10
}
/// <summary>
/// 仓储类型
/// </summary>
public enum StorageType
{
= 0,
= 1,
= 2,
= 3,
SD = 4
}
/// <summary>
/// 订单类型
/// </summary>
public enum OrderType
{
#region JD订单类型
SOP = 22,
LOC = 75,
FBP = 21
#endregion
}
/// <summary>
/// 支付方式
/// </summary>
public enum PayType
{
= 1,
= 2,
= 3,
线 = 4,
= 5,
= 6
}
/// <summary>
/// 订单状态
/// </summary>
@ -38,5 +75,23 @@
= 7,
退 = 8
}
public enum PayChannelType
{
= 0,
= 1,
= 2
}
/// <summary>
/// 刷单类型
/// </summary>
public enum SDType
{
= 0,
= 1,
= 2,
= 3
}
}
}

Loading…
Cancel
Save