diff --git a/BBWY.1688SDK/BBWY.1688SDK.csproj b/BBWY.1688SDK/BBWY.1688SDK.csproj
index ce828eff..4b4233dd 100644
--- a/BBWY.1688SDK/BBWY.1688SDK.csproj
+++ b/BBWY.1688SDK/BBWY.1688SDK.csproj
@@ -9,4 +9,8 @@
+
+
+
+
diff --git a/BBWY.1688SDK/SyncAPIClient.cs b/BBWY.1688SDK/SyncAPIClient.cs
index b0d73c27..9d49d04a 100644
--- a/BBWY.1688SDK/SyncAPIClient.cs
+++ b/BBWY.1688SDK/SyncAPIClient.cs
@@ -1,6 +1,8 @@
-using com.alibaba.openapi.client.entity;
+using BBWY.Common.Http;
+using com.alibaba.openapi.client.entity;
using com.alibaba.openapi.client.http;
using com.alibaba.openapi.client.policy;
+using Newtonsoft.Json.Linq;
using System;
namespace com.alibaba.openapi.client
@@ -8,6 +10,8 @@ namespace com.alibaba.openapi.client
public class SyncAPIClient
{
private ClientPolicy clientPolicy;
+ private RestApiService restApiService;
+ private HttpClient alibabaHttpClient;
public SyncAPIClient(String appKey, String appSecret)
{
@@ -16,6 +20,15 @@ namespace com.alibaba.openapi.client
this.clientPolicy.SecretKey = appSecret;
}
+ public SyncAPIClient(String appKey, String appSecret, RestApiService restApiService)
+ {
+ this.clientPolicy = new ClientPolicy();
+ this.clientPolicy.AppKey = appKey;
+ this.clientPolicy.SecretKey = appSecret;
+ this.restApiService = restApiService;
+ this.alibabaHttpClient = new HttpClient(clientPolicy, restApiService);
+ }
+
public SyncAPIClient(String appKey, String appSecret, String gatewayHost)
{
this.clientPolicy = new ClientPolicy();
@@ -29,6 +42,11 @@ namespace com.alibaba.openapi.client
this.clientPolicy = clientPolicy;
}
+ public JObject NewRequest(Request request, RequestPolicy policy)
+ {
+ return alibabaHttpClient.NewRequest(request, policy);
+ }
+
public T send(Request request, RequestPolicy policy)
{
HttpClient httpClient = new HttpClient(clientPolicy);
@@ -79,7 +97,7 @@ namespace com.alibaba.openapi.client
apiId.Name = "getToken";
apiId.NamespaceValue = "system.oauth2";
apiId.Version = 1;
-
+
Request request = new Request();
request.ApiId = apiId;
diff --git a/BBWY.1688SDK/http/HttpClient.cs b/BBWY.1688SDK/http/HttpClient.cs
index e6e7971c..658f6994 100644
--- a/BBWY.1688SDK/http/HttpClient.cs
+++ b/BBWY.1688SDK/http/HttpClient.cs
@@ -1,16 +1,15 @@
-using com.alibaba.openapi.client.policy;
+using BBWY.Common.Http;
+using com.alibaba.openapi.client.entity;
+using com.alibaba.openapi.client.policy;
+using com.alibaba.openapi.client.serialize;
using com.alibaba.openapi.client.util;
+using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
-using System.Linq;
+using System.IO;
using System.Net;
+using System.Net.Http;
using System.Text;
-using System.Threading.Tasks;
-using System.Runtime.Serialization.Json;
-using System.IO;
-using com.alibaba.openapi.client.serialize;
-using com.alibaba.openapi.client.entity;
-using System.Collections;
using System.Web;
namespace com.alibaba.openapi.client.http
@@ -18,12 +17,43 @@ namespace com.alibaba.openapi.client.http
public class HttpClient
{
private ClientPolicy clientPolicy;
+ private RestApiService restApiService;
+ private IDictionary requestHeader;
public HttpClient(ClientPolicy clientPolicy)
{
this.clientPolicy = clientPolicy;
}
+ public HttpClient(ClientPolicy clientPolicy, RestApiService restApiService)
+ {
+ this.clientPolicy = clientPolicy;
+ this.restApiService = restApiService;
+ this.requestHeader = new Dictionary()
+ {
+ { "User-Agent","Ocean/NET-SDKClient"}
+ };
+ }
+
+ public JObject NewRequest(Request request, RequestPolicy requestPolicy)
+ {
+ StringBuilder path = createProtocolRequestPath(requestPolicy, request);
+ Dictionary parameters = createParameterDictionary(requestPolicy, request);
+ signature(path.ToString(), parameters, requestPolicy, clientPolicy);
+ string paramString = createParameterStr(parameters);
+ Uri uri = new Uri(buildRequestUri(requestPolicy, request));
+
+ var result = restApiService.SendRequest($"{uri.Scheme}://{uri.Host}",
+ uri.LocalPath,
+ paramString,
+ requestHeader,
+ requestPolicy.HttpMethod.Equals("GET") ? HttpMethod.Get : HttpMethod.Post,
+ RestApiService.ContentType_Form);
+ if (result.StatusCode != HttpStatusCode.OK)
+ throw new Exception(result.Content.ToString());
+ return JObject.Parse(result.Content);
+ }
+
public T request(Request request, RequestPolicy requestPolicy)
{
StringBuilder path = createProtocolRequestPath(requestPolicy, request);
@@ -75,7 +105,7 @@ namespace com.alibaba.openapi.client.http
HttpWebResponse response = httpWebRequest.GetResponse() as HttpWebResponse;
Stream responseStream = response.GetResponseStream();
-
+
DeSerializer deSerializer = SerializerProvider.getInstance().getDeSerializer(requestPolicy.ResponseProtocol);
ResponseWrapper rw = deSerializer.deSerialize(responseStream, typeof(T), Encoding.UTF8.EncodingName);
return (T)rw.Result;
@@ -85,7 +115,7 @@ namespace com.alibaba.openapi.client.http
HttpWebResponse response = webException.Response as HttpWebResponse;
Stream responseStream = response.GetResponseStream();
DeSerializer deSerializer = SerializerProvider.getInstance().getDeSerializer(requestPolicy.ResponseProtocol);
- Exception rw = deSerializer.buildException(responseStream,500, Encoding.UTF8.EncodingName);
+ Exception rw = deSerializer.buildException(responseStream, 500, Encoding.UTF8.EncodingName);
throw rw;
}
}
@@ -147,7 +177,7 @@ namespace com.alibaba.openapi.client.http
{
String tempValue = kvp.Value.ToString();
byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(tempValue);
- encodedValue = HttpUtility.UrlEncode(byteArray, 0, byteArray.Length);
+ encodedValue = HttpUtility.UrlEncode(byteArray, 0, byteArray.Length);
}
paramBuilder.Append(kvp.Key).Append("=").Append(encodedValue);
paramBuilder.Append("&");
diff --git a/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs b/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs
index e003e85a..51463b7f 100644
--- a/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs
+++ b/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs
@@ -22,6 +22,8 @@ namespace BBWY.Client.ViewModels
public string OrderId { get; set; }
public int ItemTotal { get; set; }
+ public Consignee Consignee { get; set; }
+
public IList PurchaseSchemeList { get; set; }
@@ -50,15 +52,17 @@ namespace BBWY.Client.ViewModels
{
this.ItemTotal = 0;
this.OrderId = this.SkuId = this.SkuName = string.Empty;
+ this.Consignee = null;
PurchaseSchemeList.Clear();
}
- public void SetData(string orderId, string skuId, string skuName, int itemTotal)
+ public void SetData(string orderId, string skuId, string skuName, int itemTotal, Consignee consignee)
{
this.OrderId = orderId;
this.SkuId = skuId;
this.SkuName = skuName;
this.ItemTotal = itemTotal;
+ this.Consignee = consignee;
}
public void LoadPurchaseScheme(string skuId)
@@ -110,7 +114,7 @@ namespace BBWY.Client.ViewModels
}
else if (count == 1)
{
- var p = new _1688Purchase(this.OrderId, this.ItemTotal, purchaseScheme, globalContext.User.Shop.PurchaseAccountList[0]);
+ var p = new _1688Purchase(this.OrderId, this.ItemTotal, purchaseScheme, globalContext.User.Shop.PurchaseAccountList[0], this.Consignee);
p.ShowDialog();
}
else
diff --git a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs
index 2d73a25c..68fdec64 100644
--- a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs
+++ b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs
@@ -257,7 +257,7 @@ namespace BBWY.Client.ViewModels
}
else if (chooseDFType.DFType == DFType.在线采购)
{
- choosePurchaseSchemeViewModel.SetData(order.Id, order.ItemList[0].Id, order.ItemList[0].Title, order.ItemList[0].ItemTotal);
+ choosePurchaseSchemeViewModel.SetData(order.Id, order.ItemList[0].Id, order.ItemList[0].Title, order.ItemList[0].ItemTotal, order.Consignee);
var choosePurchaseScheme = new ChoosePurchaseScheme();
choosePurchaseScheme.ShowDialog();
}
diff --git a/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs b/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs
index c746a27f..483d1e9a 100644
--- a/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs
+++ b/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs
@@ -19,12 +19,34 @@ namespace BBWY.Client.ViewModels
public PurchaseAccount PurchaseAccount { get; set; }
public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } }
+ public decimal ProductAmount { get => productAmount; set { Set(ref productAmount, value); } }
+ public decimal FreightAmount { get => freightAmount; set { Set(ref freightAmount, value); } }
+ public decimal TotalAmount { get => totalAmount; set { Set(ref totalAmount, value); } }
+ public string ContactName { get => contactName; set { Set(ref contactName, value); } }
+ public string Address { get => address; set { Set(ref address, value); } }
+ public string Mobile { get => mobile; set { Set(ref mobile, value); } }
+ public string Province { get => province; set { Set(ref province, value); } }
+ public string City { get => city; set { Set(ref city, value); } }
+ public string County { get => county; set { Set(ref county, value); } }
+ public string Town { get => town; set { Set(ref town, value); } }
+
private string orderId;
private int skuItemCount;
private bool isLoading;
private OneBoundAPIService oneBoundAPIService;
private DelayTrigger delayTrigger;
+ private decimal productAmount;
+ private decimal freightAmount;
+ private decimal totalAmount;
+ private string contactName;
+ private string address;
+ private string mobile;
+ private string province;
+ private string city;
+ private string county;
+ private string town;
+
public _1688PreviewPurchaseViewModel(OneBoundAPIService oneBoundAPIService)
{
this.oneBoundAPIService = oneBoundAPIService;
@@ -33,12 +55,20 @@ namespace BBWY.Client.ViewModels
PurchaseSchemeProductSkuList = new ObservableCollection();
}
- public void SetData(string orderId, int skuItemCount, PurchaseScheme purchaseScheme, PurchaseAccount purchaseAccount)
+ public void SetData(string orderId, int skuItemCount, PurchaseScheme purchaseScheme, PurchaseAccount purchaseAccount, Consignee consignee)
{
this.orderId = orderId;
this.skuItemCount = skuItemCount;
this.PurchaseScheme = purchaseScheme;
this.PurchaseAccount = purchaseAccount;
+
+ this.ContactName = consignee.ContactName;
+ this.Address = consignee.Address;
+ this.Province = consignee.Province;
+ this.City = consignee.City;
+ this.County = consignee.County;
+ this.Town = consignee.Town;
+ //this.Mobile = consignee.Mobile;
}
protected override void Load()
diff --git a/BBWY.Client/Views/Purchase/1688Purchase.xaml b/BBWY.Client/Views/Purchase/1688Purchase.xaml
index 3cac376f..0d55199a 100644
--- a/BBWY.Client/Views/Purchase/1688Purchase.xaml
+++ b/BBWY.Client/Views/Purchase/1688Purchase.xaml
@@ -85,24 +85,38 @@
TextWrapping="Wrap"/>
-
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/BBWY.Client/Views/Purchase/1688Purchase.xaml.cs b/BBWY.Client/Views/Purchase/1688Purchase.xaml.cs
index a6298977..b96521d8 100644
--- a/BBWY.Client/Views/Purchase/1688Purchase.xaml.cs
+++ b/BBWY.Client/Views/Purchase/1688Purchase.xaml.cs
@@ -9,10 +9,10 @@ namespace BBWY.Client.Views.Purchase
///
public partial class _1688Purchase : BWindow
{
- public _1688Purchase(string orderId, int skuItemCount, PurchaseScheme purchaseScheme,PurchaseAccount purchaseAccount)
+ public _1688Purchase(string orderId, int skuItemCount, PurchaseScheme purchaseScheme, PurchaseAccount purchaseAccount, Consignee consignee)
{
InitializeComponent();
- (this.DataContext as _1688PreviewPurchaseViewModel).SetData(orderId, skuItemCount, purchaseScheme, purchaseAccount);
+ (this.DataContext as _1688PreviewPurchaseViewModel).SetData(orderId, skuItemCount, purchaseScheme, purchaseAccount, consignee);
}
}
}
diff --git a/BBWY.Server.API/Controllers/PlatformSDKController.cs b/BBWY.Server.API/Controllers/PlatformSDKController.cs
index c7821abf..c3cd8487 100644
--- a/BBWY.Server.API/Controllers/PlatformSDKController.cs
+++ b/BBWY.Server.API/Controllers/PlatformSDKController.cs
@@ -115,7 +115,7 @@ namespace BBWY.Server.API.Controllers
///
///
[HttpPost]
- public void OutStock(OutStockRequest outStockRequest)
+ public void OutStock([FromBody]OutStockRequest outStockRequest)
{
platformSDKBusinessList.FirstOrDefault(p => p.Platform == outStockRequest.Platform).OutStock(outStockRequest);
}
@@ -126,7 +126,7 @@ namespace BBWY.Server.API.Controllers
///
///
[HttpPost]
- public PreviewOrderResponse PreviewOrder(PreviewOrderReuqest previewOrderReuqest)
+ public PreviewOrderResponse PreviewOrder([FromBody]PreviewOrderReuqest previewOrderReuqest)
{
return platformSDKBusinessList.FirstOrDefault(p => p.Platform == previewOrderReuqest.Platform).PreviewOrder(previewOrderReuqest);
}
diff --git a/BBWY.Server.API/Controllers/PurchaseOrderController.cs b/BBWY.Server.API/Controllers/PurchaseOrderController.cs
index 7d07d658..2d96451e 100644
--- a/BBWY.Server.API/Controllers/PurchaseOrderController.cs
+++ b/BBWY.Server.API/Controllers/PurchaseOrderController.cs
@@ -2,7 +2,9 @@
using BBWY.Server.Model.Dto;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
+using System;
using System.Collections.Generic;
+using System.Linq;
namespace BBWY.Server.API.Controllers
{
@@ -10,7 +12,8 @@ namespace BBWY.Server.API.Controllers
{
private PurchaseOrderBusiness purchaseOrderBusiness;
- public PurchaseOrderController(PurchaseOrderBusiness purchaseOrderBusiness, IHttpContextAccessor httpContextAccessor) : base(httpContextAccessor)
+ public PurchaseOrderController(PurchaseOrderBusiness purchaseOrderBusiness,
+ IHttpContextAccessor httpContextAccessor) : base(httpContextAccessor)
{
this.purchaseOrderBusiness = purchaseOrderBusiness;
}
@@ -38,5 +41,16 @@ namespace BBWY.Server.API.Controllers
{
purchaseOrderBusiness.DeletePurchaseOrder(id);
}
+
+ ///
+ /// 订单预览
+ ///
+ ///
+ ///
+ [HttpPost]
+ public PreviewOrderResponse PreviewPurchaseOrder([FromBody] PreviewOrderReuqest previewOrderReuqest)
+ {
+ return purchaseOrderBusiness.PreviewPurchaseOrder(previewOrderReuqest);
+ }
}
}
diff --git a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs
index 1e22c310..b0a37fbe 100644
--- a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs
+++ b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs
@@ -347,6 +347,7 @@ namespace BBWY.Server.Business
var decryptContactName = tdeClient.DecryptString(orderInfo["consigneeInfo"].Value("fullname"));
var decryptAddress = tdeClient.DecryptString(orderInfo["consigneeInfo"].Value("fullAddress"));
+ /*
PopOrderGetmobilelistRequest decryptMobileReq = new PopOrderGetmobilelistRequest();
decryptMobileReq.appName = "订单管家";
decryptMobileReq.orderId = decryptConsigneeRequest.OrderId;
@@ -367,13 +368,13 @@ namespace BBWY.Server.Business
var decryptMobile = decryptMobileResponse.Json["jingdong_pop_order_getmobilelist_responce"]["result"]["data"][decryptConsigneeRequest.OrderId].Value("consMobilePhone");
var decryptTelePhone = decryptMobileResponse.Json["jingdong_pop_order_getmobilelist_responce"]["result"]["data"][decryptConsigneeRequest.OrderId].Value("customerPhone");
-
+ */
return new ConsigneeSimpleResponse()
{
Address = decryptAddress,
ContactName = decryptContactName,
- Mobile = decryptMobile,
- TelePhone = decryptTelePhone
+ //Mobile = decryptMobile,
+ //TelePhone = decryptTelePhone
};
}
diff --git a/BBWY.Server.Business/PlatformSDK/_1688Business.cs b/BBWY.Server.Business/PlatformSDK/_1688Business.cs
index 459d9c24..1bca45d4 100644
--- a/BBWY.Server.Business/PlatformSDK/_1688Business.cs
+++ b/BBWY.Server.Business/PlatformSDK/_1688Business.cs
@@ -1,4 +1,6 @@
using BBWY._1688SDK.entity.OrderPreview;
+using BBWY.Common.Http;
+using BBWY.Common.Models;
using BBWY.Server.Model;
using BBWY.Server.Model.Dto;
using com.alibaba.openapi.client;
@@ -13,17 +15,18 @@ namespace BBWY.Server.Business
public class _1688Business : PlatformSDKBusiness
{
public override Enums.Platform Platform => Enums.Platform.阿里巴巴;
+ private RestApiService restApiService;
- public _1688Business(IMemoryCache memoryCache, ILogger logger) : base(memoryCache, logger)
+ public _1688Business(IMemoryCache memoryCache, ILogger logger, RestApiService restApiService) : base(memoryCache, logger)
{
-
+ this.restApiService = restApiService;
}
private SyncAPIClient GetSyncAPIClient(string appKey, string appSecret)
{
if (!memoryCache.TryGetValue(appKey, out SyncAPIClient syncAPIClient))
{
- syncAPIClient = new SyncAPIClient(appKey, appSecret);
+ syncAPIClient = new SyncAPIClient(appKey, appSecret, restApiService);
memoryCache.Set(appKey, syncAPIClient, expirationTimeSpan);
}
return syncAPIClient;
@@ -35,7 +38,7 @@ namespace BBWY.Server.Business
RequestPolicy reqPolicy = new RequestPolicy();
reqPolicy.HttpMethod = "POST";
reqPolicy.NeedAuthorization = false;
- reqPolicy.RequestSendTimestamp = true;
+ reqPolicy.RequestSendTimestamp = false;
reqPolicy.UseHttps = false;
reqPolicy.UseSignture = true;
reqPolicy.AccessPrivateApi = false;
@@ -74,7 +77,13 @@ namespace BBWY.Server.Business
});
}
request.RequestEntity = param;
- var result = client.send(request, reqPolicy);
+ if (!string.IsNullOrEmpty(previewOrderReuqest.AppToken))
+ request.AccessToken = previewOrderReuqest.AppToken;
+ var result = client.NewRequest(request, reqPolicy);
+ if (result.Value("success") != true)
+ {
+ throw new BusinessException(result.Value("errorMsg")) { Code = result.Value("errorCode") };
+ }
return new PreviewOrderResponse()
{
diff --git a/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs b/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs
index bd68fe02..90f458a9 100644
--- a/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs
+++ b/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs
@@ -4,13 +4,18 @@ using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using System;
using System.Collections.Generic;
+using System.Linq;
using Yitter.IdGenerator;
namespace BBWY.Server.Business
{
public class PurchaseOrderBusiness : BaseBusiness, IDenpendency
{
- public PurchaseOrderBusiness(IFreeSql fsql, NLog.ILogger logger, IIdGenerator idGenerator) : base(fsql, logger, idGenerator) { }
+ private IEnumerable platformSDKBusinessList;
+ public PurchaseOrderBusiness(IFreeSql fsql, NLog.ILogger logger, IIdGenerator idGenerator, IEnumerable platformSDKBusinessList) : base(fsql, logger, idGenerator)
+ {
+ this.platformSDKBusinessList = platformSDKBusinessList;
+ }
public void AddPurchaseOrder(AddPurchaseOrderRequest addPurchaseOrderRequest)
{
@@ -57,5 +62,14 @@ namespace BBWY.Server.Business
{
fsql.Delete(id).ExecuteAffrows();
}
+
+ public PreviewOrderResponse PreviewPurchaseOrder(PreviewOrderReuqest previewOrderReuqest)
+ {
+ if (previewOrderReuqest.Platform != Model.Enums.Platform.阿里巴巴)
+ {
+ throw new NotImplementedException();
+ }
+ return platformSDKBusinessList.FirstOrDefault(p => p.Platform == previewOrderReuqest.Platform).PreviewOrder(previewOrderReuqest);
+ }
}
}