You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
3.3 KiB

using BBWYB.Common.Log;
using BBWYB.Common.Models;
using BBWYB.Server.Model.Dto;
using SDKAdapter;
using SDKAdapter.PurchasePlatform.Client;
using SDKAdapter.PurchasePlatform.Models;
using Yitter.IdGenerator;
namespace BBWYB.Server.Business
{
public class PurchaseOrderBusiness : BaseBusiness, IDenpendency
{
private PP_PlatformClientFactory ppPlatformClientFactory;
public PurchaseOrderBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, PP_PlatformClientFactory ppPlatformClientFactory) : base(fsql, nLogManager, idGenerator)
{
this.ppPlatformClientFactory = ppPlatformClientFactory;
}
public PreviewOrderResponse PreviewPurchaseOrder(PreviewOrderRequest request)
{
var response = ppPlatformClientFactory.GetClient((AdapterEnums.PlatformType)request.Platform)
.PreviewOrder(new PP_PreviewOrderRequest()
{
AppKey = request.AppKey,
AppSecret = request.AppSecret,
AppToken = request.AppToken,
Consignee = new PP_ConsigneeRequest()
{
Address = request.Consignee.Address,
City = request.Consignee.City,
ContactName = request.Consignee.ContactName,
County = request.Consignee.County,
Mobile = request.Consignee.Mobile,
Province = request.Consignee.Province,
TelePhone = request.Consignee.TelePhone,
Town = request.Consignee.Town
},
Platform = (AdapterEnums.PlatformType)request.Platform,
PurchaseMode = (AdapterEnums.PurchaseMode)request.PurchaseOrderMode,
OrderProductParamList = request.CargoParamList.Select(p => new PP_OrderProductParamRequest()
{
ProductId = p.ProductId,
Quantity = p.Quantity,
SkuId = p.SkuId,
SpecId = p.SpecId
}).ToList()
});
return new PreviewOrderResponse()
{
Extensions = response.Extensions,
FreightAmount = response.FreightAmount,
ProductAmount = response.ProductAmount,
TotalAmount = response.TotalAmount
};
}
}
}