|
|
@ -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<ProductSku>(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<ApiResponse<ProductListResponse>>(sendResult.Content); |
|
|
|
if (!response.Success) |
|
|
|
throw new BusinessException(response.Msg) { Code = response.Code }; |
|
|
|
return response.Data; |
|
|
|
} |
|
|
|
|
|
|
|
public IList<ProductSkuResponse> 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<ApiResponse<IList<ProductSkuResponse>>>(sendResult.Content); |
|
|
|
if (!response.Success) |
|
|
|
throw new BusinessException(response.Msg) { Code = response.Code }; |
|
|
|
return response.Data; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|