diff --git a/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs b/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs index 0b452351..531e96ef 100644 --- a/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs +++ b/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs @@ -77,5 +77,11 @@ namespace BBWY.Server.Business { throw new NotImplementedException(); } + + public virtual void FastCreateOrder(CreateOnlinePurchaseOrderRequest createOnlinePurchaseOrderRequest) + { + throw new NotImplementedException(); + } + } } diff --git a/BBWY.Server.Business/PlatformSDK/_1688Business.cs b/BBWY.Server.Business/PlatformSDK/_1688Business.cs index 3e049cb5..4bc13f83 100644 --- a/BBWY.Server.Business/PlatformSDK/_1688Business.cs +++ b/BBWY.Server.Business/PlatformSDK/_1688Business.cs @@ -117,6 +117,59 @@ namespace BBWY.Server.Business } }; } + + public override void FastCreateOrder(CreateOnlinePurchaseOrderRequest createOnlinePurchaseOrderRequest) + { + var client = GetSyncAPIClient(createOnlinePurchaseOrderRequest.AppKey, createOnlinePurchaseOrderRequest.AppSecret); + RequestPolicy reqPolicy = new RequestPolicy(); + reqPolicy.HttpMethod = "POST"; + reqPolicy.NeedAuthorization = false; + reqPolicy.RequestSendTimestamp = false; + reqPolicy.UseHttps = false; + reqPolicy.UseSignture = true; + reqPolicy.AccessPrivateApi = false; + + Request request = new Request(); + APIId apiId = new APIId(); + apiId.Name = "alibaba.trade.fastCreateOrder"; + apiId.NamespaceValue = "com.alibaba.trade"; + apiId.Version = 1; + request.ApiId = apiId; + + var param = new + { + flow = "general", + message = createOnlinePurchaseOrderRequest.Remark, + addressParam = new + { + fullName = createOnlinePurchaseOrderRequest.Consignee.ContactName, + mobile = createOnlinePurchaseOrderRequest.Consignee.Mobile, + phone = createOnlinePurchaseOrderRequest.Consignee.Mobile, + cityText = createOnlinePurchaseOrderRequest.Consignee.City, + provinceText = createOnlinePurchaseOrderRequest.Consignee.Province, + areaText = createOnlinePurchaseOrderRequest.Consignee.County, + townText = createOnlinePurchaseOrderRequest.Consignee.Town, + address = createOnlinePurchaseOrderRequest.Consignee.Address + }, + cargoParamList = createOnlinePurchaseOrderRequest.CargoParamList.Select(cargo => new + { + offerId = long.Parse(cargo.ProductId), + specId = cargo.SpecId, + quantity = cargo.Quantity + }), + tradeType = createOnlinePurchaseOrderRequest.TradeMode + }; + + request.RequestEntity = param; + if (!string.IsNullOrEmpty(createOnlinePurchaseOrderRequest.AppToken)) + request.AccessToken = createOnlinePurchaseOrderRequest.AppToken; + var result = client.NewRequest(request, reqPolicy); + if (result.Value("success") != true) + throw new BusinessException(result.Value("errorMsg")) { Code = 0 }; + + var totalSuccessAmount = result["result"].Value("totalSuccessAmount") / 100M; //采购总金额 + + } } public class _1688TradeTypeCompare : IEqualityComparer diff --git a/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs b/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs new file mode 100644 index 00000000..8d8730af --- /dev/null +++ b/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs @@ -0,0 +1,15 @@ +namespace BBWY.Server.Model.Dto +{ + public class CreateOnlinePurchaseOrderRequest : PreviewOrderReuqest + { + /// + /// 下单模式 + /// + public string TradeMode { get; set; } + + /// + /// 采购单留言 + /// + public string Remark { get; set; } + } +}