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; }
+ }
+}