4 changed files with 104 additions and 3 deletions
@ -0,0 +1,28 @@ |
|||
using BBWY.Server.Business.QiKu; |
|||
using BBWY.Server.Model.Dto; |
|||
using Microsoft.AspNetCore.Http; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
|
|||
namespace BBWY.Server.API.Controllers |
|||
{ |
|||
|
|||
public class QiKuController : BaseApiController |
|||
{ |
|||
private QiKuBusiness qikuBusiness; |
|||
public QiKuController(IHttpContextAccessor httpContextAccessor, QiKuBusiness qikuBusiness) : base(httpContextAccessor) |
|||
{ |
|||
this.qikuBusiness = qikuBusiness; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取供应商和仓库信息
|
|||
/// </summary>
|
|||
/// <param name="request"></param>
|
|||
/// <returns></returns>
|
|||
[HttpPost] |
|||
public GetJDSupplierNameAndStoreNameResponse GetJDSupplierNameAndStoreName([FromBody] GetJDSupplierNameAndStoreNameRequest request) |
|||
{ |
|||
return qikuBusiness.GetJDSupplierNameAndStoreName(request); |
|||
} |
|||
} |
|||
} |
@ -1,12 +1,67 @@ |
|||
using BBWY.Common.Models; |
|||
using BBWY.Common.Http; |
|||
using BBWY.Common.Models; |
|||
using BBWY.Server.Model; |
|||
using BBWY.Server.Model.Dto; |
|||
using Microsoft.Extensions.Options; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Linq; |
|||
using Org.BouncyCastle.Ocsp; |
|||
using System.Linq; |
|||
using Yitter.IdGenerator; |
|||
|
|||
namespace BBWY.Server.Business.QiKu |
|||
{ |
|||
public class QiKuBusiness : BaseBusiness, IDenpendency |
|||
public class QiKuBusiness : BasePlatformRelayBusiness, IDenpendency |
|||
{ |
|||
public QiKuBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator) : base(fsql, nLogManager, idGenerator) |
|||
private VenderBusiness venderBusiness; |
|||
public QiKuBusiness(RestApiService restApiService, IOptions<GlobalConfig> options, YunDingBusiness yunDingBusiness, VenderBusiness venderBusiness) : base(restApiService, options, yunDingBusiness) |
|||
{ |
|||
this.venderBusiness = venderBusiness; |
|||
} |
|||
|
|||
public GetJDSupplierNameAndStoreNameResponse GetJDSupplierNameAndStoreName(GetJDSupplierNameAndStoreNameRequest request) |
|||
{ |
|||
#region 查询入库采购单
|
|||
var inStorePoHttpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(request.Platform), "api/PlatformSDK/GetJDInStorePurchaseOrderDetail", request, GetYunDingRequestHeader(), System.Net.Http.HttpMethod.Post); |
|||
if (inStorePoHttpResult.StatusCode != System.Net.HttpStatusCode.OK) |
|||
throw new BusinessException(inStorePoHttpResult.Content); |
|||
var inStorePoResponse = JsonConvert.DeserializeObject<ApiResponse<JToken>>(inStorePoHttpResult.Content); |
|||
if (!inStorePoResponse.Success) |
|||
throw new BusinessException(inStorePoResponse.Msg); |
|||
var inStorePoJToken = inStorePoResponse.Data; |
|||
var deptNo = inStorePoJToken["jingdong_eclp_po_queryPoOrder_responce"]["queryPoModelList"].Children().FirstOrDefault().Value<string>("deptNo"); |
|||
var whNo = inStorePoJToken["jingdong_eclp_po_queryPoOrder_responce"]["queryPoModelList"].Children().FirstOrDefault().Value<string>("whNo"); |
|||
#endregion
|
|||
|
|||
#region 查询供应商
|
|||
var supplierHttpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(request.Platform), "api/PlatformSDK/GetJDSupplierDetail", new |
|||
{ |
|||
DeptNo = deptNo, |
|||
request.AppKey, |
|||
request.AppSecret, |
|||
request.AppToken, |
|||
request.Platform |
|||
}, GetYunDingRequestHeader(), System.Net.Http.HttpMethod.Post); |
|||
if (supplierHttpResult.StatusCode != System.Net.HttpStatusCode.OK) |
|||
throw new BusinessException(supplierHttpResult.Content); |
|||
var supplierResponse = JsonConvert.DeserializeObject<ApiResponse<JToken>>(supplierHttpResult.Content); |
|||
if (!supplierResponse.Success) |
|||
throw new BusinessException(supplierResponse.Msg); |
|||
var supplierJToken = supplierResponse.Data; |
|||
var supplierName = supplierJToken["jingdong_eclp_master_querySupplier_responce"]["querysupplier_result"].Children().FirstOrDefault().Value<string>("supplierName"); |
|||
#endregion
|
|||
|
|||
#region 查询仓库信息
|
|||
var storeList = venderBusiness.GetStoreHouseList(request); |
|||
var store = storeList.FirstOrDefault(s => s.Id == whNo); |
|||
#endregion
|
|||
|
|||
return new GetJDSupplierNameAndStoreNameResponse() |
|||
{ |
|||
StoreId = store?.Id, |
|||
StoreName = store?.Name, |
|||
SupplierName = supplierName |
|||
}; |
|||
} |
|||
} |
|||
} |
|||
|
@ -0,0 +1,7 @@ |
|||
namespace BBWY.Server.Model.Dto |
|||
{ |
|||
public class GetJDSupplierNameAndStoreNameRequest:PlatformRequest |
|||
{ |
|||
public string PoOrderNo { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,11 @@ |
|||
namespace BBWY.Server.Model.Dto |
|||
{ |
|||
public class GetJDSupplierNameAndStoreNameResponse |
|||
{ |
|||
public string SupplierName { get; set; } |
|||
|
|||
public string StoreId { get; set; } |
|||
|
|||
public string StoreName { get; set; } |
|||
} |
|||
} |
Loading…
Reference in new issue