From f96ea2e06a2b80db907e53fd848b7be8626b6f4e Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Thu, 26 Oct 2023 00:22:38 +0800 Subject: [PATCH] 1 --- SiNan.API/Controllers/ProductController.cs | 26 +++++++++ SiNan.Business/GOIBusiness.cs | 1 - SiNan.Business/ProductBusiness.cs | 35 ++++++++++++ SiNan.Model/Db/Product/Product.cs | 6 ++ SiNan.Model/Db/Product/ProductSku.cs | 6 ++ .../Product/SetMaxDeficitThresholdRequest.cs | 12 ++++ SiNan.Model/Enums.cs | 55 +++++++++++++++++++ 7 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 SiNan.API/Controllers/ProductController.cs create mode 100644 SiNan.Business/ProductBusiness.cs create mode 100644 SiNan.Model/Dto/Request/Product/SetMaxDeficitThresholdRequest.cs diff --git a/SiNan.API/Controllers/ProductController.cs b/SiNan.API/Controllers/ProductController.cs new file mode 100644 index 0000000..4c0a273 --- /dev/null +++ b/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; + } + + /// + /// 设置SKU最大亏损,级联更新SPU最大亏损 + /// + /// + [HttpPost] + public void SetMaxDeficitThreshold([FromBody]SetMaxDeficitThresholdRequest request) + { + productBusiness.SetMaxDeficitThreshold(request); + } + } +} diff --git a/SiNan.Business/GOIBusiness.cs b/SiNan.Business/GOIBusiness.cs index 18029ed..1bf50b7 100644 --- a/SiNan.Business/GOIBusiness.cs +++ b/SiNan.Business/GOIBusiness.cs @@ -237,7 +237,6 @@ namespace SiNan.Business productGoi.TotalDeficit = productGoi.ProductSkuGOIList.Sum(x => x.TotalDeficit); } - return new ListResponse() { Count = productCount, diff --git a/SiNan.Business/ProductBusiness.cs b/SiNan.Business/ProductBusiness.cs new file mode 100644 index 0000000..46a097a --- /dev/null +++ b/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(request.Sku).ToOne(); + if (_temp == null) + throw new BusinessException("未查询到sku"); + var productSkuList = fsql.Select().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(_temp.ProductId).Set(p => p.MaxDeficitThreshold, spuMaxDeficitThreshold).ExecuteAffrows(); + fsql.Update(request.Sku).Set(p => p.MaxDeficitThreshold, spuMaxDeficitThreshold).ExecuteAffrows(); + }); + } + } +} diff --git a/SiNan.Model/Db/Product/Product.cs b/SiNan.Model/Db/Product/Product.cs index c7a1682..0e1adf7 100644 --- a/SiNan.Model/Db/Product/Product.cs +++ b/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.新品款; + /// + /// 最大亏损阈值 + /// + [Column(DbType = "decimal(18,2)")] + public decimal? MaxDeficitThreshold { get; set; } = 0.00M; + } } diff --git a/SiNan.Model/Db/Product/ProductSku.cs b/SiNan.Model/Db/Product/ProductSku.cs index 36d3a2e..7f4496f 100644 --- a/SiNan.Model/Db/Product/ProductSku.cs +++ b/SiNan.Model/Db/Product/ProductSku.cs @@ -52,6 +52,12 @@ namespace SiNan.Model.Db public int? CategoryId { get; set; } public string CategoryName { get; set; } + + /// + /// 最大亏损阈值 + /// + [Column(DbType = "decimal(18,2)")] + public decimal? MaxDeficitThreshold { get; set; } = 0.00M; } } diff --git a/SiNan.Model/Dto/Request/Product/SetMaxDeficitThresholdRequest.cs b/SiNan.Model/Dto/Request/Product/SetMaxDeficitThresholdRequest.cs new file mode 100644 index 0000000..a6e7a4f --- /dev/null +++ b/SiNan.Model/Dto/Request/Product/SetMaxDeficitThresholdRequest.cs @@ -0,0 +1,12 @@ +namespace SiNan.Model.Dto +{ + public class SetMaxDeficitThresholdRequest + { + public string Sku { get; set; } + + /// + /// 最大亏损阈值 + /// + public decimal MaxDeficitThreshold { get; set; } + } +} diff --git a/SiNan.Model/Enums.cs b/SiNan.Model/Enums.cs index 5c19ba3..947ef83 100644 --- a/SiNan.Model/Enums.cs +++ b/SiNan.Model/Enums.cs @@ -23,6 +23,43 @@ 拳探 = 10 } + /// + /// 仓储类型 + /// + public enum StorageType + { + 京仓 = 0, + 云仓 = 1, + 本地自发 = 2, + 代发 = 3, + SD = 4 + } + + /// + /// 订单类型 + /// + public enum OrderType + { + #region JD订单类型 + SOP = 22, + LOC = 75, + FBP = 21 + #endregion + } + + /// + /// 支付方式 + /// + public enum PayType + { + 货到付款 = 1, + 邮局汇款 = 2, + 自提 = 3, + 在线支付 = 4, + 公司转账 = 5, + 银行卡转账 = 6 + } + /// /// 订单状态 /// @@ -38,5 +75,23 @@ 暂停 = 7, 已退款 = 8 } + + public enum PayChannelType + { + 支付宝 = 0, + 微信 = 1, + 银行卡 = 2 + } + + /// + /// 刷单类型 + /// + public enum SDType + { + 自刷 = 0, + 其他 = 1, + 京礼金 = 2, + 刷单组 = 3 + } } }