From 83fcd4aa3aa775457baa90dc2b1c65977598a05e Mon Sep 17 00:00:00 2001 From: sanji Date: Fri, 10 Nov 2023 15:02:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=A7=E5=93=81=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SiNan.API/Controllers/ProductController.cs | 24 +++++++++++++- SiNan.Business/ProductBusiness.cs | 32 +++++++++++++++++-- SiNan.Model/Dto/PlatformRequest.cs | 15 +++++++++ .../Request/Product/SearchProductRequest.cs | 19 +++++++++++ .../Product/SearchProductSkuRequest.cs | 30 +++++++++++++++++ .../Response/Product/ProductListResponse.cs | 9 ++++++ 6 files changed, 125 insertions(+), 4 deletions(-) create mode 100644 SiNan.Model/Dto/PlatformRequest.cs create mode 100644 SiNan.Model/Dto/Request/Product/SearchProductRequest.cs create mode 100644 SiNan.Model/Dto/Request/Product/SearchProductSkuRequest.cs create mode 100644 SiNan.Model/Dto/Response/Product/ProductListResponse.cs diff --git a/SiNan.API/Controllers/ProductController.cs b/SiNan.API/Controllers/ProductController.cs index 4c0a273..198aba0 100644 --- a/SiNan.API/Controllers/ProductController.cs +++ b/SiNan.API/Controllers/ProductController.cs @@ -18,9 +18,31 @@ namespace SiNan.API.Controllers /// /// [HttpPost] - public void SetMaxDeficitThreshold([FromBody]SetMaxDeficitThresholdRequest request) + public void SetMaxDeficitThreshold([FromBody] SetMaxDeficitThresholdRequest request) { productBusiness.SetMaxDeficitThreshold(request); } + + /// + /// 获取产品列表 + /// + /// + /// + [HttpPost] + public ProductListResponse GetProductList([FromBody] SearchProductRequest searchProductRequest) + { + return productBusiness.GetProductList(searchProductRequest); + } + + /// + /// 获取sku列表 + /// + /// + /// + [HttpPost] + public IList GetProductSkuList([FromBody] SearchProductSkuRequest searchProductSkuRequest) + { + return productBusiness.GetProductSkuList(searchProductSkuRequest); + } } } diff --git a/SiNan.Business/ProductBusiness.cs b/SiNan.Business/ProductBusiness.cs index 46a097a..b41accf 100644 --- a/SiNan.Business/ProductBusiness.cs +++ b/SiNan.Business/ProductBusiness.cs @@ -1,4 +1,6 @@ -using SiNan.Common.Log; +using Newtonsoft.Json; +using SiNan.Common.Http; +using SiNan.Common.Log; using SiNan.Common.Models; using SiNan.Model.Db; using SiNan.Model.Dto; @@ -8,9 +10,10 @@ namespace SiNan.Business { public class ProductBusiness : BaseBusiness, IDenpendency { - public ProductBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator) : base(fsql, nLogManager, idGenerator) + private RestApiService restApiService; + public ProductBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, RestApiService restApiService) : base(fsql, nLogManager, idGenerator) { - + this.restApiService = restApiService; } public void SetMaxDeficitThreshold(SetMaxDeficitThresholdRequest request) @@ -31,5 +34,28 @@ namespace SiNan.Business fsql.Update(request.Sku).Set(p => p.MaxDeficitThreshold, spuMaxDeficitThreshold).ExecuteAffrows(); }); } + + public ProductListResponse GetProductList(SearchProductRequest searchProductRequest) + { + var sendResult = restApiService.SendRequest("http://bbwytest.qiyue666.com", "api/product/GetProductList", searchProductRequest, null, HttpMethod.Post); + if (sendResult.StatusCode != System.Net.HttpStatusCode.OK) + throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode }; + var response = JsonConvert.DeserializeObject>(sendResult.Content); + if (!response.Success) + throw new BusinessException(response.Msg) { Code = response.Code }; + return response.Data; + } + + public IList GetProductSkuList(SearchProductSkuRequest searchProductSkuRequest) + { + + var sendResult = restApiService.SendRequest("http://bbwytest.qiyue666.com", "api/product/GetProductSkuList", searchProductSkuRequest, null, HttpMethod.Post); + if (sendResult.StatusCode != System.Net.HttpStatusCode.OK) + throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode }; + var response = JsonConvert.DeserializeObject>>(sendResult.Content); + if (!response.Success) + throw new BusinessException(response.Msg) { Code = response.Code }; + return response.Data; + } } } diff --git a/SiNan.Model/Dto/PlatformRequest.cs b/SiNan.Model/Dto/PlatformRequest.cs new file mode 100644 index 0000000..4753201 --- /dev/null +++ b/SiNan.Model/Dto/PlatformRequest.cs @@ -0,0 +1,15 @@ +namespace SiNan.Model.Dto +{ + public class PlatformRequest + { + public Enums.Platform Platform { get; set; } + + public string AppKey { get; set; } + + public string AppSecret { get; set; } + + public string AppToken { get; set; } + + public bool SaveResponseLog { get; set; } + } +} diff --git a/SiNan.Model/Dto/Request/Product/SearchProductRequest.cs b/SiNan.Model/Dto/Request/Product/SearchProductRequest.cs new file mode 100644 index 0000000..a992c38 --- /dev/null +++ b/SiNan.Model/Dto/Request/Product/SearchProductRequest.cs @@ -0,0 +1,19 @@ +namespace SiNan.Model.Dto +{ + public class SearchProductRequest : PlatformRequest + { + + public string Spu { get; set; } + + /// + /// 货号 + /// + public string ProductItem { get; set; } + + public string ProductName { get; set; } + + public int PageIndex { get; set; } + + public int PageSize { get; set; } + } +} diff --git a/SiNan.Model/Dto/Request/Product/SearchProductSkuRequest.cs b/SiNan.Model/Dto/Request/Product/SearchProductSkuRequest.cs new file mode 100644 index 0000000..f26216e --- /dev/null +++ b/SiNan.Model/Dto/Request/Product/SearchProductSkuRequest.cs @@ -0,0 +1,30 @@ +namespace SiNan.Model.Dto +{ + public class SearchProductSkuRequest : PlatformRequest + { + /// + /// 当Spu有值时会忽略Sku + /// + public string Spu { get; set; } + + /// + /// 多个Sku逗号间隔 + /// + public string Sku { get; set; } + + /// + /// 是否包含源 + /// + public bool IsContainSource { get; set; } + + /// + /// 检查sku数量是否匹配,仅在使用sku条件查询时生效 + /// + public bool IsCheckSkuCount { get; set; } + + /// + /// 检查环节 + /// + public string CheckStep { get; set; } + } +} diff --git a/SiNan.Model/Dto/Response/Product/ProductListResponse.cs b/SiNan.Model/Dto/Response/Product/ProductListResponse.cs new file mode 100644 index 0000000..0a781b1 --- /dev/null +++ b/SiNan.Model/Dto/Response/Product/ProductListResponse.cs @@ -0,0 +1,9 @@ +namespace SiNan.Model.Dto +{ + public class ProductListResponse + { + public int Count { get; set; } + + public IList Items { get; set; } + } +}