From 6feba339ba092c33fafa494a33dcbfbc3228f22f Mon Sep 17 00:00:00 2001
From: shanji <18996038927@163.com>
Date: Wed, 23 Feb 2022 16:04:57 +0800
Subject: [PATCH 01/20] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BA=97=E9=93=BA?=
=?UTF-8?q?=E9=87=87=E8=B4=AD=E8=B4=A6=E5=8F=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BBWY.1688SDK/BBWY.1688SDK.csproj | 8 +++++++
.../APIModel/Response/Shop/ShopResponse.cs | 22 ++++++++++++++++++-
BBWY.Client/Models/MappingProfile.cs | 7 +++---
BBWY.Client/Models/Shop/Shop.cs | 11 +++++++++-
BBWY.sln | 11 ++++++++--
5 files changed, 52 insertions(+), 7 deletions(-)
create mode 100644 BBWY.1688SDK/BBWY.1688SDK.csproj
diff --git a/BBWY.1688SDK/BBWY.1688SDK.csproj b/BBWY.1688SDK/BBWY.1688SDK.csproj
new file mode 100644
index 00000000..fad4a782
--- /dev/null
+++ b/BBWY.1688SDK/BBWY.1688SDK.csproj
@@ -0,0 +1,8 @@
+
+
+
+ netstandard2.0
+ BBWY._1688SDK
+
+
+
diff --git a/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs b/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs
index c6e91524..5103060d 100644
--- a/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs
+++ b/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs
@@ -1,4 +1,6 @@
-namespace BBWY.Client.Models
+using System.Collections.Generic;
+
+namespace BBWY.Client.Models
{
public class ShopResponse
{
@@ -18,5 +20,23 @@
public string AppToken { get; set; }
+ public IList PurchaseAccountList { get; set; }
+ }
+
+ public class PurchaseAccountResponse
+ {
+ public long Id { get; set; }
+
+ public string AccountName { get; set; }
+
+ public long ShopId { get; set; }
+
+ public Platform PurchasePlatformId { get; set; }
+
+ public string AppKey { get; set; }
+
+ public string AppSecret { get; set; }
+
+ public string AppToken { get; set; }
}
}
diff --git a/BBWY.Client/Models/MappingProfile.cs b/BBWY.Client/Models/MappingProfile.cs
index 54251f4c..d1b49a87 100644
--- a/BBWY.Client/Models/MappingProfile.cs
+++ b/BBWY.Client/Models/MappingProfile.cs
@@ -19,9 +19,10 @@ namespace BBWY.Client.Models
.ForMember(t => t.Name, opt => opt.MapFrom(f => f.UserName));
CreateMap().ForMember(t => t.ShopId, opt => opt.MapFrom(f => f.ShopId))
- .ForMember(t => t.Name, opt => opt.MapFrom(f => f.ShopName))
- .ForMember(t => t.VenderType, opt => opt.MapFrom(f => f.ShopType))
- .ForMember(t => t.Platform, opt => opt.MapFrom(f => f.PlatformId));
+ .ForMember(t => t.Name, opt => opt.MapFrom(f => f.ShopName))
+ .ForMember(t => t.VenderType, opt => opt.MapFrom(f => f.ShopType))
+ .ForMember(t => t.Platform, opt => opt.MapFrom(f => f.PlatformId));
+ CreateMap();
CreateMap();
CreateMap();
diff --git a/BBWY.Client/Models/Shop/Shop.cs b/BBWY.Client/Models/Shop/Shop.cs
index 92f1fb14..0facae53 100644
--- a/BBWY.Client/Models/Shop/Shop.cs
+++ b/BBWY.Client/Models/Shop/Shop.cs
@@ -1,4 +1,6 @@
-namespace BBWY.Client.Models
+using System.Collections.Generic;
+
+namespace BBWY.Client.Models
{
public class Shop : NotifyObject
{
@@ -26,5 +28,12 @@
public string AppToken { get; set; }
public string Name { get => name; set { Set(ref name, value); } }
+
+ public IList PurchaseAccountList { get; set; }
+ }
+
+ public class PurchaseAccount : PurchaseAccountResponse
+ {
+
}
}
diff --git a/BBWY.sln b/BBWY.sln
index 77d29a96..d545c4d3 100644
--- a/BBWY.sln
+++ b/BBWY.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.0.31808.319
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30225.117
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BBWY.Client", "BBWY.Client\BBWY.Client.csproj", "{04DAF636-2630-45BB-BEFA-264EC273E920}"
EndProject
@@ -30,6 +30,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BBWY.1688SDK", "BBWY.1688SDK\BBWY.1688SDK.csproj", "{1A7EB438-5DEF-4940-8CB2-C58141C75524}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -68,6 +70,10 @@ Global
{2DC24A1B-EFE0-4F9D-8A9A-A6B530696E17}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2DC24A1B-EFE0-4F9D-8A9A-A6B530696E17}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2DC24A1B-EFE0-4F9D-8A9A-A6B530696E17}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1A7EB438-5DEF-4940-8CB2-C58141C75524}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1A7EB438-5DEF-4940-8CB2-C58141C75524}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1A7EB438-5DEF-4940-8CB2-C58141C75524}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1A7EB438-5DEF-4940-8CB2-C58141C75524}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -80,6 +86,7 @@ Global
{5FC60547-0934-4AAD-921B-F4DA03C9F47D} = {B545F3FA-E6A7-4CB1-B92D-801C66357CF5}
{E38A95F5-05E6-4856-811C-30D7A1B77C68} = {B545F3FA-E6A7-4CB1-B92D-801C66357CF5}
{2DC24A1B-EFE0-4F9D-8A9A-A6B530696E17} = {B131026A-2025-4A74-ABF1-644059FADF78}
+ {1A7EB438-5DEF-4940-8CB2-C58141C75524} = {B131026A-2025-4A74-ABF1-644059FADF78}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CC045257-4D86-45FD-A1F0-2715C024F1B5}
From 4868ff5e03742650b5a24526a32ee1132fc429d5 Mon Sep 17 00:00:00 2001
From: shanji <18996038927@163.com>
Date: Wed, 23 Feb 2022 18:22:02 +0800
Subject: [PATCH 02/20] =?UTF-8?q?=E5=BA=97=E9=93=BA=E5=A2=9E=E5=8A=A0?=
=?UTF-8?q?=E9=87=87=E8=B4=AD=E8=B4=A6=E5=8F=B7=E5=88=97=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../APIModel/Response/Shop/ShopResponse.cs | 2 +-
BBWY.Client/Models/MappingProfile.cs | 3 ++-
.../Order/ChoosePurchaseSchemeViewModel.cs | 18 ++++++++++++++++--
.../Purchase/1688PreviewPurchaseViewModel.cs | 6 ++++--
.../Views/Purchase/1688Purchase.xaml.cs | 4 ++--
5 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs b/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs
index 5103060d..97f5559e 100644
--- a/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs
+++ b/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs
@@ -20,7 +20,7 @@ namespace BBWY.Client.Models
public string AppToken { get; set; }
- public IList PurchaseAccountList { get; set; }
+ public IList PurchaseList { get; set; }
}
public class PurchaseAccountResponse
diff --git a/BBWY.Client/Models/MappingProfile.cs b/BBWY.Client/Models/MappingProfile.cs
index d1b49a87..d9d6c71b 100644
--- a/BBWY.Client/Models/MappingProfile.cs
+++ b/BBWY.Client/Models/MappingProfile.cs
@@ -21,7 +21,8 @@ namespace BBWY.Client.Models
CreateMap().ForMember(t => t.ShopId, opt => opt.MapFrom(f => f.ShopId))
.ForMember(t => t.Name, opt => opt.MapFrom(f => f.ShopName))
.ForMember(t => t.VenderType, opt => opt.MapFrom(f => f.ShopType))
- .ForMember(t => t.Platform, opt => opt.MapFrom(f => f.PlatformId));
+ .ForMember(t => t.Platform, opt => opt.MapFrom(f => f.PlatformId))
+ .ForMember(t => t.PurchaseAccountList, opt => opt.MapFrom(f => f.PurchaseList));
CreateMap();
CreateMap();
diff --git a/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs b/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs
index d38c7049..0de90c7e 100644
--- a/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs
+++ b/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs
@@ -5,6 +5,7 @@ using BBWY.Common.Models;
using GalaSoft.MvvmLight.Command;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
@@ -102,8 +103,21 @@ namespace BBWY.Client.ViewModels
public void PreviewPurchase(PurchaseScheme purchaseScheme)
{
- var p = new _1688Purchase(this.OrderId, this.ItemTotal, purchaseScheme);
- p.ShowDialog();
+ var count = globalContext.User.Shop.PurchaseAccountList.Count();
+ if (count > 1)
+ {
+ //选择采购账号
+ }
+ else if (count == 1)
+ {
+ var p = new _1688Purchase(this.OrderId, this.ItemTotal, purchaseScheme, globalContext.User.Shop.PurchaseAccountList[0]);
+ p.ShowDialog();
+ }
+ else
+ {
+ MessageBox.Show("缺少采购账号", "提示");
+ return;
+ }
}
}
}
diff --git a/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs b/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs
index 53cb9f55..c746a27f 100644
--- a/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs
+++ b/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs
@@ -16,6 +16,7 @@ namespace BBWY.Client.ViewModels
public IList PurchaseSchemeProductSkuList { get; set; }
public PurchaseScheme PurchaseScheme { get; set; }
+ public PurchaseAccount PurchaseAccount { get; set; }
public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } }
private string orderId;
@@ -32,11 +33,12 @@ namespace BBWY.Client.ViewModels
PurchaseSchemeProductSkuList = new ObservableCollection();
}
- public void SetData(string orderId, int skuItemCount, PurchaseScheme purchaseScheme)
+ public void SetData(string orderId, int skuItemCount, PurchaseScheme purchaseScheme, PurchaseAccount purchaseAccount)
{
this.orderId = orderId;
this.skuItemCount = skuItemCount;
this.PurchaseScheme = purchaseScheme;
+ this.PurchaseAccount = purchaseAccount;
}
protected override void Load()
@@ -153,7 +155,7 @@ namespace BBWY.Client.ViewModels
private void OnDelayTriggerExecute(string key)
{
-
+
}
}
}
diff --git a/BBWY.Client/Views/Purchase/1688Purchase.xaml.cs b/BBWY.Client/Views/Purchase/1688Purchase.xaml.cs
index ae6532ef..a6298977 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)
+ public _1688Purchase(string orderId, int skuItemCount, PurchaseScheme purchaseScheme,PurchaseAccount purchaseAccount)
{
InitializeComponent();
- (this.DataContext as _1688PreviewPurchaseViewModel).SetData(orderId, skuItemCount, purchaseScheme);
+ (this.DataContext as _1688PreviewPurchaseViewModel).SetData(orderId, skuItemCount, purchaseScheme, purchaseAccount);
}
}
}
From 9320ffe4bfb4ea4cd592189018003be8570a5e98 Mon Sep 17 00:00:00 2001
From: shanj <18996038927@163.com>
Date: Fri, 25 Feb 2022 04:46:28 +0800
Subject: [PATCH 03/20] =?UTF-8?q?=E4=B8=8B=E5=8D=95=E9=87=87=E8=B4=AD?=
=?UTF-8?q?=E8=B4=A6=E5=8F=B7=E9=AA=8C=E8=AF=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs b/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs
index 0de90c7e..e003e85a 100644
--- a/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs
+++ b/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs
@@ -103,7 +103,7 @@ namespace BBWY.Client.ViewModels
public void PreviewPurchase(PurchaseScheme purchaseScheme)
{
- var count = globalContext.User.Shop.PurchaseAccountList.Count();
+ var count = globalContext.User.Shop.PurchaseAccountList == null ? 0 : globalContext.User.Shop.PurchaseAccountList.Count();
if (count > 1)
{
//选择采购账号
From 905d664a3400b4c626327b9b9724d53698ab3189 Mon Sep 17 00:00:00 2001
From: shanj <18996038927@163.com>
Date: Wed, 2 Mar 2022 03:11:54 +0800
Subject: [PATCH 04/20] =?UTF-8?q?1688sdk=E5=AF=B9=E6=8E=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BBWY.1688SDK/APIFacade.cs | 39 ++++
BBWY.1688SDK/APIId.cs | 43 ++++
BBWY.1688SDK/GatewayAPIRequest.cs | 23 ++
BBWY.1688SDK/GatewayAPIResponse.cs | 14 ++
BBWY.1688SDK/Request.cs | 66 ++++++
BBWY.1688SDK/Response.cs | 56 +++++
BBWY.1688SDK/SyncAPIClient.cs | 99 ++++++++
BBWY.1688SDK/entity/AuthorizationToken.cs | 159 +++++++++++++
BBWY.1688SDK/entity/ErrorExceptionDesc.cs | 35 +++
.../entity/OrderPreview/CreateOrderPreview.cs | 49 ++++
BBWY.1688SDK/entity/ResponseStatus.cs | 28 +++
BBWY.1688SDK/entity/ResponseWrapper.cs | 40 ++++
BBWY.1688SDK/example/ExampleFacade.cs | 88 ++++++++
.../example/param/apiexample/ExampleCar.cs | 160 +++++++++++++
.../example/param/apiexample/ExampleFamily.cs | 132 +++++++++++
.../param/apiexample/ExampleFamilyGetParam.cs | 41 ++++
.../apiexample/ExampleFamilyGetResult.cs | 37 +++
.../apiexample/ExampleFamilyPostParam.cs | 75 ++++++
.../apiexample/ExampleFamilyPostResult.cs | 56 +++++
.../example/param/apiexample/ExampleHouse.cs | 94 ++++++++
.../example/param/apiexample/ExamplePerson.cs | 99 ++++++++
BBWY.1688SDK/exception/OceanException.cs | 58 +++++
BBWY.1688SDK/http/HttpClient.cs | 213 ++++++++++++++++++
BBWY.1688SDK/policy/ClientPolicy.cs | 70 ++++++
BBWY.1688SDK/policy/GrantType.cs | 17 ++
BBWY.1688SDK/policy/Protocol.cs | 26 +++
BBWY.1688SDK/policy/RequestPolicy.cs | 113 ++++++++++
BBWY.1688SDK/primitive/NullableBool.cs | 36 +++
BBWY.1688SDK/primitive/NullableByte.cs | 36 +++
BBWY.1688SDK/primitive/NullableChar.cs | 36 +++
BBWY.1688SDK/primitive/NullableDateTime.cs | 36 +++
BBWY.1688SDK/primitive/NullableDouble.cs | 36 +++
BBWY.1688SDK/primitive/NullableFloat.cs | 36 +++
BBWY.1688SDK/primitive/NullableInt.cs | 36 +++
BBWY.1688SDK/primitive/NullableLong.cs | 36 +++
.../primitive/NullablePrimitiveObject.cs | 12 +
BBWY.1688SDK/serialize/DeSerializer.cs | 21 ++
BBWY.1688SDK/serialize/Json2Deserializer.cs | 56 +++++
.../serialize/Param2RequestSerializer.cs | 109 +++++++++
BBWY.1688SDK/serialize/Serializer.cs | 18 ++
BBWY.1688SDK/serialize/SerializerProvider.cs | 60 +++++
BBWY.1688SDK/util/DateUtil.cs | 66 ++++++
BBWY.1688SDK/util/SignatureUtil.cs | 74 ++++++
.../Controllers/PlatformSDKController.cs | 11 +
BBWY.Server.API/Startup.cs | 1 +
.../BBWY.Server.Business.csproj | 1 +
.../PlatformSDK/JDBusiness.cs | 2 +-
.../PlatformSDK/PDDBusiness.cs | 7 +-
.../PlatformSDK/PlatformSDKBusiness.cs | 14 +-
.../PlatformSDK/TaoBaoBusiness.cs | 7 +-
.../PlatformSDK/_1688Business.cs | 85 +++++++
.../OnlinePurchase/CargoParamRequest.cs | 14 ++
.../OnlinePurchase/ConsigneeRequest.cs | 43 ++++
.../OnlinePurchase/PreviewOrderReuqest.cs | 11 +
.../OnlinePurchase/PreviewOrderResponse.cs | 20 ++
55 files changed, 2842 insertions(+), 8 deletions(-)
create mode 100644 BBWY.1688SDK/APIFacade.cs
create mode 100644 BBWY.1688SDK/APIId.cs
create mode 100644 BBWY.1688SDK/GatewayAPIRequest.cs
create mode 100644 BBWY.1688SDK/GatewayAPIResponse.cs
create mode 100644 BBWY.1688SDK/Request.cs
create mode 100644 BBWY.1688SDK/Response.cs
create mode 100644 BBWY.1688SDK/SyncAPIClient.cs
create mode 100644 BBWY.1688SDK/entity/AuthorizationToken.cs
create mode 100644 BBWY.1688SDK/entity/ErrorExceptionDesc.cs
create mode 100644 BBWY.1688SDK/entity/OrderPreview/CreateOrderPreview.cs
create mode 100644 BBWY.1688SDK/entity/ResponseStatus.cs
create mode 100644 BBWY.1688SDK/entity/ResponseWrapper.cs
create mode 100644 BBWY.1688SDK/example/ExampleFacade.cs
create mode 100644 BBWY.1688SDK/example/param/apiexample/ExampleCar.cs
create mode 100644 BBWY.1688SDK/example/param/apiexample/ExampleFamily.cs
create mode 100644 BBWY.1688SDK/example/param/apiexample/ExampleFamilyGetParam.cs
create mode 100644 BBWY.1688SDK/example/param/apiexample/ExampleFamilyGetResult.cs
create mode 100644 BBWY.1688SDK/example/param/apiexample/ExampleFamilyPostParam.cs
create mode 100644 BBWY.1688SDK/example/param/apiexample/ExampleFamilyPostResult.cs
create mode 100644 BBWY.1688SDK/example/param/apiexample/ExampleHouse.cs
create mode 100644 BBWY.1688SDK/example/param/apiexample/ExamplePerson.cs
create mode 100644 BBWY.1688SDK/exception/OceanException.cs
create mode 100644 BBWY.1688SDK/http/HttpClient.cs
create mode 100644 BBWY.1688SDK/policy/ClientPolicy.cs
create mode 100644 BBWY.1688SDK/policy/GrantType.cs
create mode 100644 BBWY.1688SDK/policy/Protocol.cs
create mode 100644 BBWY.1688SDK/policy/RequestPolicy.cs
create mode 100644 BBWY.1688SDK/primitive/NullableBool.cs
create mode 100644 BBWY.1688SDK/primitive/NullableByte.cs
create mode 100644 BBWY.1688SDK/primitive/NullableChar.cs
create mode 100644 BBWY.1688SDK/primitive/NullableDateTime.cs
create mode 100644 BBWY.1688SDK/primitive/NullableDouble.cs
create mode 100644 BBWY.1688SDK/primitive/NullableFloat.cs
create mode 100644 BBWY.1688SDK/primitive/NullableInt.cs
create mode 100644 BBWY.1688SDK/primitive/NullableLong.cs
create mode 100644 BBWY.1688SDK/primitive/NullablePrimitiveObject.cs
create mode 100644 BBWY.1688SDK/serialize/DeSerializer.cs
create mode 100644 BBWY.1688SDK/serialize/Json2Deserializer.cs
create mode 100644 BBWY.1688SDK/serialize/Param2RequestSerializer.cs
create mode 100644 BBWY.1688SDK/serialize/Serializer.cs
create mode 100644 BBWY.1688SDK/serialize/SerializerProvider.cs
create mode 100644 BBWY.1688SDK/util/DateUtil.cs
create mode 100644 BBWY.1688SDK/util/SignatureUtil.cs
create mode 100644 BBWY.Server.Business/PlatformSDK/_1688Business.cs
create mode 100644 BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CargoParamRequest.cs
create mode 100644 BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/ConsigneeRequest.cs
create mode 100644 BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/PreviewOrderReuqest.cs
create mode 100644 BBWY.Server.Model/Dto/Response/PurchaseOrder/OnlinePurchase/PreviewOrderResponse.cs
diff --git a/BBWY.1688SDK/APIFacade.cs b/BBWY.1688SDK/APIFacade.cs
new file mode 100644
index 00000000..24a71cbb
--- /dev/null
+++ b/BBWY.1688SDK/APIFacade.cs
@@ -0,0 +1,39 @@
+using com.alibaba.openapi.client;
+using com.alibaba.openapi.client.entity;
+using com.alibaba.openapi.client.policy;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace NetSdkClient.sdk
+{
+ public class APIFacade
+ {
+ private ClientPolicy clientPolicy;
+
+ public APIFacade(ClientPolicy clientPolicy)
+ {
+ this.clientPolicy = clientPolicy;
+ }
+
+
+ private SyncAPIClient getAPIClient()
+ {
+ return new SyncAPIClient(clientPolicy);
+ }
+
+ public AuthorizationToken getToken(string code)
+ {
+
+ return getAPIClient().getToken(code);
+
+ }
+
+ public AuthorizationToken refreshToken(String refreshToken)
+ {
+ return getAPIClient().refreshToken(refreshToken);
+ }
+ }
+}
diff --git a/BBWY.1688SDK/APIId.cs b/BBWY.1688SDK/APIId.cs
new file mode 100644
index 00000000..0fefda53
--- /dev/null
+++ b/BBWY.1688SDK/APIId.cs
@@ -0,0 +1,43 @@
+using System;
+
+namespace com.alibaba.openapi.client
+{
+ public class APIId
+ {
+ public APIId()
+ {
+
+ }
+
+ public APIId(String namespaceValue,String name, int version)
+ {
+ this.NamespaceValue = namespaceValue;
+ this.Name = name;
+ this.version = version;
+ }
+
+ private String namespaceValue;
+
+ public String NamespaceValue
+ {
+ get { return namespaceValue; }
+ set { namespaceValue = value; }
+ }
+ private String name;
+
+ public String Name
+ {
+ get { return name; }
+ set { name = value; }
+ }
+ private int version;
+
+ public int Version
+ {
+ get { return version; }
+ set { version = value; }
+ }
+
+
+ }
+}
diff --git a/BBWY.1688SDK/GatewayAPIRequest.cs b/BBWY.1688SDK/GatewayAPIRequest.cs
new file mode 100644
index 00000000..8d4508a7
--- /dev/null
+++ b/BBWY.1688SDK/GatewayAPIRequest.cs
@@ -0,0 +1,23 @@
+using com.alibaba.openapi.client.entity;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client
+{
+ public class GatewayAPIRequest
+ {
+ [DataMember(Order = 0)]
+ private APIId apiId;
+
+ public APIId ApiId
+ {
+ get { return apiId; }
+ set { apiId = value; }
+ }
+
+ }
+}
diff --git a/BBWY.1688SDK/GatewayAPIResponse.cs b/BBWY.1688SDK/GatewayAPIResponse.cs
new file mode 100644
index 00000000..15a3bfe8
--- /dev/null
+++ b/BBWY.1688SDK/GatewayAPIResponse.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client
+{
+ [DataContract(Namespace = "com.alibaba.openapi.client")]
+ public class GatewayAPIResponse
+ {
+ }
+}
diff --git a/BBWY.1688SDK/Request.cs b/BBWY.1688SDK/Request.cs
new file mode 100644
index 00000000..54835073
--- /dev/null
+++ b/BBWY.1688SDK/Request.cs
@@ -0,0 +1,66 @@
+using com.alibaba.openapi.client.entity;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client
+{
+ [DataContract(Namespace = "com.alibaba.openapi.client")]
+ public class Request
+ {
+ [DataMember(Order = 0)]
+ private APIId apiId;
+
+ public APIId ApiId
+ {
+ get { return apiId; }
+ set { apiId = value; }
+ }
+ private Dictionary addtionalParams = new Dictionary();
+
+ public Dictionary AddtionalParams
+ {
+ get { return addtionalParams; }
+ set { addtionalParams = value; }
+ }
+ private Object requestEntity;
+
+ public Object RequestEntity
+ {
+ get { return requestEntity; }
+ set { requestEntity = value; }
+ }
+ private Dictionary attachments;
+
+ public Dictionary Attachments
+ {
+ get { return attachments; }
+ set { attachments = value; }
+ }
+ private String authCodeKey;
+
+ public String AuthCodeKey
+ {
+ get { return authCodeKey; }
+ set { authCodeKey = value; }
+ }
+ [DataMember(Order = 1)]
+ private String accessToken;
+
+ public String AccessToken
+ {
+ get { return accessToken; }
+ set { accessToken = value; }
+ }
+ private AuthorizationToken authToken;
+
+ internal AuthorizationToken AuthToken
+ {
+ get { return authToken; }
+ set { authToken = value; }
+ }
+ }
+}
diff --git a/BBWY.1688SDK/Response.cs b/BBWY.1688SDK/Response.cs
new file mode 100644
index 00000000..5db43fa6
--- /dev/null
+++ b/BBWY.1688SDK/Response.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using com.alibaba.openapi.client.entity;
+
+namespace com.alibaba.openapi.client
+{
+ public class Response
+ {
+ private int statusCode;
+
+ public int StatusCode
+ {
+ get { return statusCode; }
+ set { statusCode = value; }
+ }
+ private Object result;
+
+ public Object Result
+ {
+ get { return result; }
+ set { result = value; }
+ }
+ private Exception exception;
+
+ public Exception Exception
+ {
+ get { return exception; }
+ set { exception = value; }
+ }
+ private String charset = "UTF-8";
+
+ public String Charset
+ {
+ get { return charset; }
+ set { charset = value; }
+ }
+ private String encoding;
+
+ public String Encoding
+ {
+ get { return encoding; }
+ set { encoding = value; }
+ }
+
+ private ResponseWrapper responseWrapper;
+
+ internal ResponseWrapper ResponseWrapper
+ {
+ get { return responseWrapper; }
+ set { responseWrapper = value; }
+ }
+ }
+}
diff --git a/BBWY.1688SDK/SyncAPIClient.cs b/BBWY.1688SDK/SyncAPIClient.cs
new file mode 100644
index 00000000..b0d73c27
--- /dev/null
+++ b/BBWY.1688SDK/SyncAPIClient.cs
@@ -0,0 +1,99 @@
+using com.alibaba.openapi.client.entity;
+using com.alibaba.openapi.client.http;
+using com.alibaba.openapi.client.policy;
+using System;
+
+namespace com.alibaba.openapi.client
+{
+ public class SyncAPIClient
+ {
+ private ClientPolicy clientPolicy;
+
+ public SyncAPIClient(String appKey, String appSecret)
+ {
+ this.clientPolicy = new ClientPolicy();
+ this.clientPolicy.AppKey = appKey;
+ this.clientPolicy.SecretKey = appSecret;
+ }
+
+ public SyncAPIClient(String appKey, String appSecret, String gatewayHost)
+ {
+ this.clientPolicy = new ClientPolicy();
+ this.clientPolicy.AppKey = appKey;
+ this.clientPolicy.SecretKey = appSecret;
+ this.clientPolicy.ServerHost = gatewayHost;
+ }
+
+ public SyncAPIClient(ClientPolicy clientPolicy)
+ {
+ this.clientPolicy = clientPolicy;
+ }
+
+ public T send(Request request, RequestPolicy policy)
+ {
+ HttpClient httpClient = new HttpClient(clientPolicy);
+ T result = httpClient.request(request, policy);
+ return result;
+ }
+
+ public Res execute(GatewayAPIRequest gatewayAPIRequest, String accessToken)
+ {
+ HttpClient httpClient = new HttpClient(clientPolicy);
+ RequestPolicy policy = new RequestPolicy();
+ policy.UseHttps = true;
+ Request request = new Request();
+ request.ApiId = gatewayAPIRequest.ApiId;
+ request.RequestEntity = gatewayAPIRequest;
+ request.AccessToken = accessToken;
+ Res result = httpClient.request(request, policy);
+ return result;
+ }
+
+ public AuthorizationToken getToken(String code)
+ {
+
+ APIId apiId = new APIId();
+ apiId.Name = "getToken";
+ apiId.NamespaceValue = "system.oauth2";
+ apiId.Version = 1;
+
+ Request request = new Request();
+ request.ApiId = apiId;
+
+ request.AddtionalParams["code"] = code;
+ request.AddtionalParams["grant_type"] = "authorization_code";
+ request.AddtionalParams["need_refresh_token"] = true;
+ request.AddtionalParams["client_id"] = clientPolicy.AppKey;
+ request.AddtionalParams["client_secret"] = clientPolicy.SecretKey;
+ request.AddtionalParams["redirect_uri"] = "default";
+ RequestPolicy oauthPolicy = new RequestPolicy();
+ oauthPolicy.UseHttps = true;
+
+ return this.send(request, oauthPolicy);
+ }
+
+ public AuthorizationToken refreshToken(String refreshToken)
+ {
+
+ APIId apiId = new APIId();
+ apiId.Name = "getToken";
+ apiId.NamespaceValue = "system.oauth2";
+ apiId.Version = 1;
+
+ Request request = new Request();
+ request.ApiId = apiId;
+
+ request.AddtionalParams["refreshToken"] = refreshToken;
+ request.AddtionalParams["grant_type"] = "refresh_token";
+ request.AddtionalParams["client_id"] = clientPolicy.AppKey;
+ request.AddtionalParams["client_secret"] = clientPolicy.SecretKey;
+ request.AddtionalParams["redirect_uri"] = "default";
+ RequestPolicy oauthPolicy = new RequestPolicy();
+ oauthPolicy.UseHttps = true;
+ return this.send(request, oauthPolicy);
+
+
+ }
+ }
+}
+
diff --git a/BBWY.1688SDK/entity/AuthorizationToken.cs b/BBWY.1688SDK/entity/AuthorizationToken.cs
new file mode 100644
index 00000000..15163a7b
--- /dev/null
+++ b/BBWY.1688SDK/entity/AuthorizationToken.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.entity
+{
+ [DataContract(Namespace = "com.alibaba.openapi.client")]
+ public class AuthorizationToken
+ {
+ [DataMember(Order = 0)]
+ private String access_token;
+ [DataMember(Order = 1)]
+ private String refresh_token;
+ [DataMember(Order = 2)]
+ private long expires_in;
+ [DataMember(Order = 3)]
+ private DateTime expires_time;
+ [DataMember(Order = 4)]
+ private DateTime refresh_token_timeout;
+ [DataMember(Order = 5)]
+ private String resource_owner;
+ [DataMember(Order = 6)]
+ private String uid;
+ [DataMember(Order = 7)]
+ private long aliId;
+ [DataMember(Order = 8)]
+ private String memberId;
+
+ /**
+ * 获取access_token
+ *
+ * @return the accessToken
+ */
+ public String getAccess_token()
+ {
+ return access_token;
+ }
+
+ /**
+ * 获取access_token过期时间
+ *
+ * @return the accessTokenTimeout
+ */
+ public long getExpires_in()
+ {
+ return expires_in;
+ }
+
+ /**
+ * 获取refresh_token
+ *
+ * @return the refreshToken
+ */
+ public String getRefresh_token()
+ {
+ return refresh_token;
+ }
+
+ /**
+ * 获取refresh_token过期时间
+ *
+ * @return the refreshTokenTimeout
+ */
+ public DateTime getRefresh_token_timeout()
+ {
+ return refresh_token_timeout;
+ }
+
+ public String getMemberId()
+ {
+ return memberId;
+ }
+
+ public void setMemberId(String memberId)
+ {
+ this.memberId = memberId;
+ }
+
+ /**
+ * 获取resource_owner
+ *
+ * @return the resourceOwnerId
+ */
+ public String getResource_owner()
+ {
+ return resource_owner;
+ }
+
+ /**
+ * 获取uid
+ *
+ * @return the uid
+ */
+ public String getUid()
+ {
+ return uid;
+ }
+
+ /**
+ * 获取aliId
+ *
+ * @return the aliId
+ */
+ public long getAliId()
+ {
+ return aliId;
+ }
+
+ public void setAccess_token(String accessToken)
+ {
+ this.access_token = accessToken;
+ }
+
+ public void setRefresh_token(String refreshToken)
+ {
+ this.refresh_token = refreshToken;
+ }
+
+ public void setExpires_in(long accessTokenTimeout)
+ {
+ this.expires_in = accessTokenTimeout;
+ DateTime now = new DateTime();
+ this.expires_time = now.AddSeconds(accessTokenTimeout);
+ }
+
+ public void setRefresh_token_timeout(DateTime refresh_token_timeout)
+ {
+ this.refresh_token_timeout = refresh_token_timeout;
+ }
+
+ public void setResource_owner(String resourceOwnerId)
+ {
+ this.resource_owner = resourceOwnerId;
+ }
+
+ public void setUid(String uid)
+ {
+ this.uid = uid;
+ }
+
+ public void setAliId(long aliId)
+ {
+ this.aliId = aliId;
+ }
+
+ /**
+ * 获取access_token过期时间,Date格式
+ *
+ * @return the accessTokenTimeout
+ */
+ public DateTime getExpires_time()
+ {
+ return expires_time;
+ }
+ }
+}
diff --git a/BBWY.1688SDK/entity/ErrorExceptionDesc.cs b/BBWY.1688SDK/entity/ErrorExceptionDesc.cs
new file mode 100644
index 00000000..62fce097
--- /dev/null
+++ b/BBWY.1688SDK/entity/ErrorExceptionDesc.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.entity
+{
+ [DataContract(Namespace = "com.alibaba.openapi.client")]
+ public class ErrorExceptionDesc
+ {
+ [DataMember(Order = 0)]
+ private string error_code;
+ [DataMember(Order = 1)]
+ private string error_message;
+ [DataMember(Order = 2)]
+ private string exception;
+
+ public string getError_code()
+ {
+ return this.error_code;
+ }
+
+ public string getError_message()
+ {
+ return this.error_message;
+ }
+
+ public string getException()
+ {
+ return this.exception;
+ }
+ }
+}
diff --git a/BBWY.1688SDK/entity/OrderPreview/CreateOrderPreview.cs b/BBWY.1688SDK/entity/OrderPreview/CreateOrderPreview.cs
new file mode 100644
index 00000000..20533221
--- /dev/null
+++ b/BBWY.1688SDK/entity/OrderPreview/CreateOrderPreview.cs
@@ -0,0 +1,49 @@
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+
+namespace BBWY._1688SDK.entity.OrderPreview
+{
+ [DataContract]
+ public class CreateOrderPreview
+ {
+ [DataMember]
+ public AddressParam addressParam { get; set; }
+ [DataMember]
+ public IList cargoParamList { get; set; }
+ [DataMember]
+ public string flow { get; set; }
+ }
+ [DataContract]
+ public class AddressParam
+ {
+ [DataMember]
+ public string fullName { get; set; }
+ [DataMember]
+ public string mobile { get; set; }
+ [DataMember]
+ public string phone { get; set; }
+ [DataMember]
+ public string postCode { get; set; }
+ [DataMember]
+ public string address { get; set; }
+ [DataMember]
+ public string provinceText { get; set; }
+ [DataMember]
+ public string cityText { get; set; }
+ [DataMember]
+ public string areaText { get; set; }
+ [DataMember]
+ public string townText { get; set; }
+
+ }
+ [DataContract]
+ public class CargoParam
+ {
+ [DataMember]
+ public long offerId { get; set; }
+ [DataMember]
+ public string specId { get; set; }
+ [DataMember]
+ public int quantity { get; set; }
+ }
+}
diff --git a/BBWY.1688SDK/entity/ResponseStatus.cs b/BBWY.1688SDK/entity/ResponseStatus.cs
new file mode 100644
index 00000000..139a9572
--- /dev/null
+++ b/BBWY.1688SDK/entity/ResponseStatus.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.entity
+{
+ public class ResponseStatus
+ {
+ private String code;
+
+ public String Code
+ {
+ get { return code; }
+ set { code = value; }
+ }
+ private String message;
+
+ public String Message
+ {
+ get { return message; }
+ set { message = value; }
+ }
+
+
+ }
+}
diff --git a/BBWY.1688SDK/entity/ResponseWrapper.cs b/BBWY.1688SDK/entity/ResponseWrapper.cs
new file mode 100644
index 00000000..2d9f868a
--- /dev/null
+++ b/BBWY.1688SDK/entity/ResponseWrapper.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.entity
+{
+ public class ResponseWrapper
+ {
+ private String invokeStartTime;
+
+ public String InvokeStartTime
+ {
+ get { return invokeStartTime; }
+ set { invokeStartTime = value; }
+ }
+ private long invokeCostTime;
+
+ public long InvokeCostTime
+ {
+ get { return invokeCostTime; }
+ set { invokeCostTime = value; }
+ }
+ private ResponseStatus status;
+
+ internal ResponseStatus Status
+ {
+ get { return status; }
+ set { status = value; }
+ }
+ private Object result;
+
+ public Object Result
+ {
+ get { return result; }
+ set { result = value; }
+ }
+ }
+}
diff --git a/BBWY.1688SDK/example/ExampleFacade.cs b/BBWY.1688SDK/example/ExampleFacade.cs
new file mode 100644
index 00000000..7cce8ab5
--- /dev/null
+++ b/BBWY.1688SDK/example/ExampleFacade.cs
@@ -0,0 +1,88 @@
+using com.alibaba.openapi.client;
+using com.alibaba.openapi.client.entity;
+using com.alibaba.openapi.client.policy;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using com.alibaba.china.openapi.client.example.param.apiexample;
+
+namespace com.alibaba.china.openapi.client.example
+{
+
+ public class ExampleFacade
+ {
+ private ClientPolicy clientPolicy;
+
+ public ExampleFacade(ClientPolicy clientPolicy)
+ {
+ this.clientPolicy = clientPolicy;
+ }
+
+ private SyncAPIClient getAPIClient()
+ {
+ return new SyncAPIClient(clientPolicy);
+ }
+
+ public AuthorizationToken getToken(string code)
+ {
+
+ return getAPIClient().getToken(code);
+
+ }
+
+ public AuthorizationToken refreshToken(String refreshToken)
+ {
+ return getAPIClient().refreshToken(refreshToken);
+ }
+
+
+
+
+ public ExampleFamilyGetResult exampleFamilyGet(ExampleFamilyGetParam param) {
+ RequestPolicy reqPolicy = new RequestPolicy();
+ reqPolicy.HttpMethod="POST";
+ reqPolicy.NeedAuthorization=false;
+ reqPolicy.RequestSendTimestamp=false;
+ reqPolicy.UseHttps=false;
+ reqPolicy.UseSignture=false;
+ reqPolicy.AccessPrivateApi=false;
+
+ Request request = new Request ();
+ APIId apiId = new APIId();
+ apiId.Name = "example.family.get";
+ apiId.NamespaceValue = "api.example";
+ apiId.Version = 1;
+ request.ApiId = apiId;
+
+ request.RequestEntity=param;
+
+ return this.getAPIClient().send(request, reqPolicy);
+ }
+
+
+
+ public ExampleFamilyPostResult exampleFamilyPost(ExampleFamilyPostParam param, string accessToken) {
+ 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 = "example.family.post";
+ apiId.NamespaceValue = "api.example";
+ apiId.Version = 1;
+ request.ApiId = apiId;
+
+ request.RequestEntity=param;
+ request.AccessToken=accessToken;
+ return this.getAPIClient().send(request, reqPolicy);
+ }
+ }
+}
\ No newline at end of file
diff --git a/BBWY.1688SDK/example/param/apiexample/ExampleCar.cs b/BBWY.1688SDK/example/param/apiexample/ExampleCar.cs
new file mode 100644
index 00000000..4b9fe3b4
--- /dev/null
+++ b/BBWY.1688SDK/example/param/apiexample/ExampleCar.cs
@@ -0,0 +1,160 @@
+using com.alibaba.openapi.client.primitive;
+using com.alibaba.openapi.client.util;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+
+
+namespace com.alibaba.china.openapi.client.example.param.apiexample
+{
+[DataContract(Namespace = "com.alibaba.openapi.client")]
+public class ExampleCar {
+
+ [DataMember(Order = 1)]
+ private string builtDate;
+
+ /**
+ * @return
+ */
+ public DateTime? getBuiltDate() {
+ if (builtDate != null)
+ {
+ DateTime datetime = DateUtil.formatFromStr(builtDate);
+ return datetime;
+ }
+ return null;
+ }
+
+ /**
+ * 设置 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setBuiltDate(DateTime builtDate) {
+ this.builtDate = DateUtil.format(builtDate);
+ }
+
+ [DataMember(Order = 2)]
+ private string boughtDate;
+
+ /**
+ * @return
+ */
+ public DateTime? getBoughtDate() {
+ if (boughtDate != null)
+ {
+ DateTime datetime = DateUtil.formatFromStr(boughtDate);
+ return datetime;
+ }
+ return null;
+ }
+
+ /**
+ * 设置 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setBoughtDate(DateTime boughtDate) {
+ this.boughtDate = DateUtil.format(boughtDate);
+ }
+
+ [DataMember(Order = 3)]
+ private string name;
+
+ /**
+ * @return
+ */
+ public string getName() {
+ return name;
+ }
+
+ /**
+ * 设置 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setName(string name) {
+ this.name = name;
+ }
+
+ [DataMember(Order = 4)]
+ private string builtArea;
+
+ /**
+ * @return
+ */
+ public string getBuiltArea() {
+ return builtArea;
+ }
+
+ /**
+ * 设置 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setBuiltArea(string builtArea) {
+ this.builtArea = builtArea;
+ }
+
+ [DataMember(Order = 5)]
+ private string carNumber;
+
+ /**
+ * @return
+ */
+ public string getCarNumber() {
+ return carNumber;
+ }
+
+ /**
+ * 设置 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setCarNumber(string carNumber) {
+ this.carNumber = carNumber;
+ }
+
+ [DataMember(Order = 6)]
+ private double? price;
+
+ /**
+ * @return
+ */
+ public double? getPrice() {
+ return price;
+ }
+
+ /**
+ * 设置 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setPrice(double price) {
+ this.price = price;
+ }
+
+ [DataMember(Order = 7)]
+ private int? seats;
+
+ /**
+ * @return
+ */
+ public int? getSeats() {
+ return seats;
+ }
+
+ /**
+ * 设置 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setSeats(int seats) {
+ this.seats = seats;
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/BBWY.1688SDK/example/param/apiexample/ExampleFamily.cs b/BBWY.1688SDK/example/param/apiexample/ExampleFamily.cs
new file mode 100644
index 00000000..8bcf2c54
--- /dev/null
+++ b/BBWY.1688SDK/example/param/apiexample/ExampleFamily.cs
@@ -0,0 +1,132 @@
+using com.alibaba.openapi.client.primitive;
+using com.alibaba.openapi.client.util;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+
+
+namespace com.alibaba.china.openapi.client.example.param.apiexample
+{
+[DataContract(Namespace = "com.alibaba.openapi.client")]
+ public class ExampleFamily
+ {
+
+ [DataMember(Order = 1)]
+ private int? familyNumber;
+
+ /**
+ * @return 家庭编号
+ */
+ public int? getFamilyNumber() {
+ return familyNumber;
+ }
+
+ /**
+ * 设置家庭编号 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setFamilyNumber(int familyNumber) {
+ this.familyNumber = familyNumber;
+ }
+
+ [DataMember(Order = 2)]
+ private ExamplePerson father;
+
+ /**
+ * @return 父亲对象,可以为空
+ */
+ public ExamplePerson getFather() {
+ return father;
+ }
+
+ /**
+ * 设置父亲对象,可以为空 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setFather(ExamplePerson father) {
+ this.father = father;
+ }
+
+ [DataMember(Order = 3)]
+ private ExamplePerson mother;
+
+ /**
+ * @return 母亲对象,可以为空
+ */
+ public ExamplePerson getMother() {
+ return mother;
+ }
+
+ /**
+ * 设置母亲对象,可以为空 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setMother(ExamplePerson mother) {
+ this.mother = mother;
+ }
+
+ [DataMember(Order = 4)]
+ private ExamplePerson[] children;
+
+ /**
+ * @return 孩子列表
+ */
+ public ExamplePerson[] getChildren() {
+ return children;
+ }
+
+ /**
+ * 设置孩子列表 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setChildren(ExamplePerson[] children) {
+ this.children = children;
+ }
+
+ [DataMember(Order = 5)]
+ private ExampleCar[] ownedCars;
+
+ /**
+ * @return 拥有的汽车信息
+ */
+ public ExampleCar[] getOwnedCars() {
+ return ownedCars;
+ }
+
+ /**
+ * 设置拥有的汽车信息 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setOwnedCars(ExampleCar[] ownedCars) {
+ this.ownedCars = ownedCars;
+ }
+
+ [DataMember(Order = 6)]
+ private ExampleHouse myHouse;
+
+ /**
+ * @return 所住的房屋信息
+ */
+ public ExampleHouse getMyHouse() {
+ return myHouse;
+ }
+
+ /**
+ * 设置所住的房屋信息 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setMyHouse(ExampleHouse myHouse) {
+ this.myHouse = myHouse;
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/BBWY.1688SDK/example/param/apiexample/ExampleFamilyGetParam.cs b/BBWY.1688SDK/example/param/apiexample/ExampleFamilyGetParam.cs
new file mode 100644
index 00000000..f2318237
--- /dev/null
+++ b/BBWY.1688SDK/example/param/apiexample/ExampleFamilyGetParam.cs
@@ -0,0 +1,41 @@
+using com.alibaba.openapi.client.primitive;
+using com.alibaba.openapi.client.util;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using com.alibaba.openapi.client;
+
+namespace com.alibaba.china.openapi.client.example.param.apiexample
+{
+[DataContract(Namespace = "com.alibaba.openapi.client")]
+ public class ExampleFamilyGetParam : GatewayAPIRequest
+ {
+ public ExampleFamilyGetParam()
+ {
+ this.ApiId = new APIId("api.example", "example.family.get",1);
+ }
+
+ [DataMember(Order = 1)]
+ private int? familyNumber;
+
+ /**
+ * @return 可接受参数1或者2,其余参数无法找到family对象
+ */
+ public int? getFamilyNumber() {
+ return familyNumber;
+ }
+
+ /**
+ * 设置可接受参数1或者2,其余参数无法找到family对象 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setFamilyNumber(int familyNumber) {
+ this.familyNumber = familyNumber;
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/BBWY.1688SDK/example/param/apiexample/ExampleFamilyGetResult.cs b/BBWY.1688SDK/example/param/apiexample/ExampleFamilyGetResult.cs
new file mode 100644
index 00000000..36d53bab
--- /dev/null
+++ b/BBWY.1688SDK/example/param/apiexample/ExampleFamilyGetResult.cs
@@ -0,0 +1,37 @@
+using com.alibaba.openapi.client.primitive;
+using com.alibaba.openapi.client.util;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using com.alibaba.openapi.client;
+
+namespace com.alibaba.china.openapi.client.example.param.apiexample
+{
+[DataContract(Namespace = "com.alibaba.openapi.client")]
+ public class ExampleFamilyGetResult : GatewayAPIResponse
+ {
+
+ [DataMember(Order = 1)]
+ private ExampleFamily result;
+
+ /**
+ * @return
+ */
+ public ExampleFamily getResult() {
+ return result;
+ }
+
+ /**
+ * 设置 *
+
+ * 此参数必填
+ */
+ public void setResult(ExampleFamily result) {
+ this.result = result;
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/BBWY.1688SDK/example/param/apiexample/ExampleFamilyPostParam.cs b/BBWY.1688SDK/example/param/apiexample/ExampleFamilyPostParam.cs
new file mode 100644
index 00000000..355cd1e1
--- /dev/null
+++ b/BBWY.1688SDK/example/param/apiexample/ExampleFamilyPostParam.cs
@@ -0,0 +1,75 @@
+using com.alibaba.openapi.client.primitive;
+using com.alibaba.openapi.client.util;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+
+
+namespace com.alibaba.china.openapi.client.example.param.apiexample
+{
+[DataContract(Namespace = "com.alibaba.openapi.client")]
+ public class ExampleFamilyPostParam
+ {
+
+ [DataMember(Order = 1)]
+ private ExampleFamily family;
+
+ /**
+ * @return 上传Family对象信息
+ */
+ public ExampleFamily getFamily() {
+ return family;
+ }
+
+ /**
+ * 设置上传Family对象信息 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setFamily(ExampleFamily family) {
+ this.family = family;
+ }
+
+ [DataMember(Order = 2)]
+ private string comments;
+
+ /**
+ * @return 备注信息
+ */
+ public string getComments() {
+ return comments;
+ }
+
+ /**
+ * 设置备注信息 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setComments(string comments) {
+ this.comments = comments;
+ }
+
+ [DataMember(Order = 3)]
+ private byte[] houseImg;
+
+ /**
+ * @return 房屋信息
+ */
+ public byte[] getHouseImg() {
+ return houseImg;
+ }
+
+ /**
+ * 设置房屋信息 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setHouseImg(byte[] houseImg) {
+ this.houseImg = houseImg;
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/BBWY.1688SDK/example/param/apiexample/ExampleFamilyPostResult.cs b/BBWY.1688SDK/example/param/apiexample/ExampleFamilyPostResult.cs
new file mode 100644
index 00000000..7ef81163
--- /dev/null
+++ b/BBWY.1688SDK/example/param/apiexample/ExampleFamilyPostResult.cs
@@ -0,0 +1,56 @@
+using com.alibaba.openapi.client.primitive;
+using com.alibaba.openapi.client.util;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+
+
+namespace com.alibaba.china.openapi.client.example.param.apiexample
+{
+[DataContract(Namespace = "com.alibaba.openapi.client")]
+ public class ExampleFamilyPostResult
+ {
+
+ [DataMember(Order = 1)]
+ private ExampleFamily result;
+
+ /**
+ * @return 返回的接听信息
+ */
+ public ExampleFamily getResult() {
+ return result;
+ }
+
+ /**
+ * 设置返回的接听信息 *
+
+ * 此参数必填
+ */
+ public void setResult(ExampleFamily result) {
+ this.result = result;
+ }
+
+ [DataMember(Order = 2)]
+ private string resultDesc;
+
+ /**
+ * @return 返回结果描述
+ */
+ public string getResultDesc() {
+ return resultDesc;
+ }
+
+ /**
+ * 设置返回结果描述 *
+
+ * 此参数必填
+ */
+ public void setResultDesc(string resultDesc) {
+ this.resultDesc = resultDesc;
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/BBWY.1688SDK/example/param/apiexample/ExampleHouse.cs b/BBWY.1688SDK/example/param/apiexample/ExampleHouse.cs
new file mode 100644
index 00000000..d865cd9b
--- /dev/null
+++ b/BBWY.1688SDK/example/param/apiexample/ExampleHouse.cs
@@ -0,0 +1,94 @@
+using com.alibaba.openapi.client.primitive;
+using com.alibaba.openapi.client.util;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+
+
+namespace com.alibaba.china.openapi.client.example.param.apiexample
+{
+[DataContract(Namespace = "com.alibaba.openapi.client")]
+ public class ExampleHouse
+ {
+
+ [DataMember(Order = 1)]
+ private string location;
+
+ /**
+ * @return
+ */
+ public string getLocation() {
+ return location;
+ }
+
+ /**
+ * 设置 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setLocation(string location) {
+ this.location = location;
+ }
+
+ [DataMember(Order = 2)]
+ private int? areaSize;
+
+ /**
+ * @return
+ */
+ public int? getAreaSize() {
+ return areaSize;
+ }
+
+ /**
+ * 设置 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setAreaSize(int areaSize) {
+ this.areaSize = areaSize;
+ }
+
+ [DataMember(Order = 3)]
+ private bool? rent;
+
+ /**
+ * @return
+ */
+ public bool? getRent() {
+ return rent;
+ }
+
+ /**
+ * 设置 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setRent(bool rent) {
+ this.rent = rent;
+ }
+
+ [DataMember(Order = 4)]
+ private int? rooms;
+
+ /**
+ * @return
+ */
+ public int? getRooms() {
+ return rooms;
+ }
+
+ /**
+ * 设置 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setRooms(int rooms) {
+ this.rooms = rooms;
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/BBWY.1688SDK/example/param/apiexample/ExamplePerson.cs b/BBWY.1688SDK/example/param/apiexample/ExamplePerson.cs
new file mode 100644
index 00000000..636baff1
--- /dev/null
+++ b/BBWY.1688SDK/example/param/apiexample/ExamplePerson.cs
@@ -0,0 +1,99 @@
+using com.alibaba.openapi.client.primitive;
+using com.alibaba.openapi.client.util;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+
+
+namespace com.alibaba.china.openapi.client.example.param.apiexample
+{
+[DataContract(Namespace = "com.alibaba.openapi.client")]
+ public class ExamplePerson
+ {
+
+ [DataMember(Order = 1)]
+ private string name;
+
+ /**
+ * @return
+ */
+ public string getName() {
+ return name;
+ }
+
+ /**
+ * 设置 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setName(string name) {
+ this.name = name;
+ }
+
+ [DataMember(Order = 2)]
+ private int? age;
+
+ /**
+ * @return
+ */
+ public int? getAge() {
+ return age;
+ }
+
+ /**
+ * 设置 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ [DataMember(Order = 3)]
+ private string birthday;
+
+ /**
+ * @return
+ */
+ public DateTime? getBirthday() {
+ if (birthday != null)
+ {
+ DateTime datetime = DateUtil.formatFromStr(birthday);
+ return datetime;
+ }
+ return null;
+ }
+
+ /**
+ * 设置 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setBirthday(DateTime birthday) {
+ this.birthday = DateUtil.format(birthday);
+ }
+
+ [DataMember(Order = 4)]
+ private string mobileNumber;
+
+ /**
+ * @return
+ */
+ public string getMobileNumber() {
+ return mobileNumber;
+ }
+
+ /**
+ * 设置 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setMobileNumber(string mobileNumber) {
+ this.mobileNumber = mobileNumber;
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/BBWY.1688SDK/exception/OceanException.cs b/BBWY.1688SDK/exception/OceanException.cs
new file mode 100644
index 00000000..fcf0d9a3
--- /dev/null
+++ b/BBWY.1688SDK/exception/OceanException.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.exception
+{
+ public class OceanException : Exception
+ {
+ public OceanException(string mess)
+ : base(mess)
+ {
+
+ }
+ public OceanException()
+ {
+
+ }
+ private string error_code;
+
+ private string error_message;
+
+ private string exception;
+
+ public string getError_code()
+ {
+ return this.error_code;
+ }
+
+ public void setError_code(string error_code)
+ {
+ this.error_code = error_code;
+ }
+
+ public string getError_message()
+ {
+ return this.error_message;
+ }
+
+ public void setError_message(string error_message)
+ {
+ this.error_message = error_message;
+ }
+
+ public string getException()
+ {
+ return this.exception;
+ }
+
+ public void setException(String exception)
+ {
+ this.exception = exception;
+ }
+
+ }
+}
diff --git a/BBWY.1688SDK/http/HttpClient.cs b/BBWY.1688SDK/http/HttpClient.cs
new file mode 100644
index 00000000..e6e7971c
--- /dev/null
+++ b/BBWY.1688SDK/http/HttpClient.cs
@@ -0,0 +1,213 @@
+using com.alibaba.openapi.client.policy;
+using com.alibaba.openapi.client.util;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+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
+{
+ public class HttpClient
+ {
+ private ClientPolicy clientPolicy;
+
+ public HttpClient(ClientPolicy clientPolicy)
+ {
+ this.clientPolicy = clientPolicy;
+ }
+
+ public T request(Request request, RequestPolicy requestPolicy)
+ {
+ StringBuilder path = createProtocolRequestPath(requestPolicy, request);
+ Dictionary parameters = createParameterDictionary(requestPolicy, request);
+ StringBuilder queryBuilder = new StringBuilder();
+ signature(path.ToString(), parameters, requestPolicy, clientPolicy);
+ if ("GET".Equals(requestPolicy.HttpMethod))
+ {
+
+ String queryString = createParameterStr(parameters);
+ String uriStr = buildRequestUri(requestPolicy, request);
+ uriStr = uriStr + "?" + queryString;
+ Uri uri = new Uri(uriStr);
+ HttpWebRequest httpWebRequest = WebRequest.Create(uri) as HttpWebRequest;
+
+ httpWebRequest.Method = "GET";
+ httpWebRequest.KeepAlive = false;
+ httpWebRequest.AllowAutoRedirect = true;
+ httpWebRequest.ContentType = "application/x-www-form-urlencoded";
+ httpWebRequest.UserAgent = "Ocean/NET-SDKClient";
+
+ 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;
+ }
+ else
+ {
+ String postString = createParameterStr(parameters);
+ byte[] postData = Encoding.UTF8.GetBytes(postString);
+ String uriStr = buildRequestUri(requestPolicy, request);
+ Uri uri = new Uri(uriStr);
+ HttpWebRequest httpWebRequest = WebRequest.Create(uri) as HttpWebRequest;
+
+ httpWebRequest.Method = "POST";
+ httpWebRequest.KeepAlive = false;
+ httpWebRequest.AllowAutoRedirect = true;
+ httpWebRequest.ContentType = "application/x-www-form-urlencoded";
+ httpWebRequest.UserAgent = "Ocean/NET-SDKClient";
+ httpWebRequest.ContentLength = postData.Length;
+
+ System.IO.Stream outputStream = httpWebRequest.GetRequestStream();
+ outputStream.Write(postData, 0, postData.Length);
+ outputStream.Close();
+ try
+ {
+ 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;
+ }
+ catch (System.Net.WebException webException)
+ {
+ 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);
+ throw rw;
+ }
+ }
+ }
+
+ private String buildRequestUri(RequestPolicy requestPolicy, Request request)
+ {
+ String schema = "http";
+ int port = clientPolicy.HttpPort;
+ if (requestPolicy.UseHttps)
+ {
+ schema = "https";
+ port = clientPolicy.HttpsPort;
+ }
+ StringBuilder relativeBuilder = new StringBuilder(schema);
+ relativeBuilder.Append("://");
+ relativeBuilder.Append(clientPolicy.ServerHost);
+ if (port != 80 && port != 443)
+ {
+ relativeBuilder.Append(":");
+ relativeBuilder.Append(port);
+ }
+
+ if (requestPolicy.AccessPrivateApi)
+ {
+ relativeBuilder.Append("/api");
+ }
+ else
+ {
+ relativeBuilder.Append("/openapi");
+ }
+
+ relativeBuilder.Append("/");
+ relativeBuilder.Append(createProtocolRequestPath(requestPolicy, request));
+ return relativeBuilder.ToString();
+ }
+
+ private StringBuilder createProtocolRequestPath(RequestPolicy requestPolicy, Request request)
+ {
+
+ StringBuilder relativeBuilder = new StringBuilder();
+
+ relativeBuilder.Append(requestPolicy.RequestProtocol);
+ relativeBuilder.Append("/").Append(request.ApiId.Version);
+ relativeBuilder.Append("/").Append(request.ApiId.NamespaceValue);
+ relativeBuilder.Append("/").Append(request.ApiId.Name);
+ relativeBuilder.Append("/").Append(clientPolicy.AppKey);
+ return relativeBuilder;
+
+ }
+
+ private String createParameterStr(Dictionary parameters)
+ {
+ StringBuilder paramBuilder = new StringBuilder();
+ foreach (KeyValuePair kvp in parameters)
+ {
+ String encodedValue = null;
+ if (kvp.Value != null)
+ {
+ String tempValue = kvp.Value.ToString();
+ byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(tempValue);
+ encodedValue = HttpUtility.UrlEncode(byteArray, 0, byteArray.Length);
+ }
+ paramBuilder.Append(kvp.Key).Append("=").Append(encodedValue);
+ paramBuilder.Append("&");
+ }
+ return paramBuilder.ToString();
+ }
+
+ private Dictionary createParameterDictionary(RequestPolicy requestPolicy, Request request)
+ {
+
+ Serializer serializer = SerializerProvider.getInstance().getSerializer(requestPolicy.RequestProtocol);
+
+ Dictionary parameters = serializer.serialize(request.RequestEntity);
+ if (!requestPolicy.RequestProtocol.Equals(requestPolicy.ResponseProtocol))
+ {
+ parameters.Add("_aop_responseFormat", requestPolicy.ResponseProtocol);
+ }
+ if (requestPolicy.RequestSendTimestamp)
+ {
+ parameters.Add("_aop_timestamp", DateUtil.currentTimeMillis());
+ }
+ parameters.Add("_aop_datePattern", DateUtil.getDatePattern());
+ foreach (KeyValuePair kvp in request.AddtionalParams)
+ {
+ parameters.Add(kvp.Key, kvp.Value);
+ }
+ if (request.AccessToken != null)
+ {
+ parameters.Add("access_token", request.AccessToken);
+ }
+ return parameters;
+ }
+
+ private void signature(String path, Dictionary parameters, RequestPolicy requestPolicy, ClientPolicy clientPolicy)
+ {
+ if (!requestPolicy.UseSignture)
+ {
+ return;
+ }
+ if (clientPolicy.AppKey == null
+ || clientPolicy.SecretKey == null)
+ {
+ return;
+ }
+ byte[] sign = SignatureUtil.hmacSha1(path, parameters, clientPolicy.SecretKey);
+ String signStr = SignatureUtil.toHex(sign);
+ if (signStr != null)
+ {
+ parameters.Add("_aop_signature", signStr);
+ }
+ }
+
+
+ private WebClient createWebClient()
+ {
+
+ WebClient client = new WebClient();
+ client.Headers.Add("user-agent", "Ocean/SDK Client");
+
+ return client;
+ }
+ }
+}
diff --git a/BBWY.1688SDK/policy/ClientPolicy.cs b/BBWY.1688SDK/policy/ClientPolicy.cs
new file mode 100644
index 00000000..15a98f55
--- /dev/null
+++ b/BBWY.1688SDK/policy/ClientPolicy.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.policy
+{
+ public class ClientPolicy
+ {
+ private string serverHost = "gw.open.1688.com";
+
+ public string ServerHost
+ {
+ get { return serverHost; }
+ set { serverHost = value; }
+ }
+ private int httpPort = 80;
+
+ public int HttpPort
+ {
+ get { return httpPort; }
+ set { httpPort = value; }
+ }
+ private int httpsPort = 443;
+
+ public int HttpsPort
+ {
+ get { return httpsPort; }
+ set { httpsPort = value; }
+ }
+ private string appKey;
+
+ public string AppKey
+ {
+ get { return appKey; }
+ set { appKey = value; }
+ }
+ private string secretKey;
+
+ public string SecretKey
+ {
+ get { return secretKey; }
+ set { secretKey = value; }
+ }
+ private int defaultTimeout = 5000;
+
+ public int DefaultTimeout
+ {
+ get { return defaultTimeout; }
+ set { defaultTimeout = value; }
+ }
+ private string defaultContentCharset = "UTF-8";
+
+ public string DefaultContentCharset
+ {
+ get { return defaultContentCharset; }
+ set { defaultContentCharset = value; }
+ }
+ private bool defaultUseHttps = true;
+
+ public bool DefaultUseHttps
+ {
+ get { return defaultUseHttps; }
+ set { defaultUseHttps = value; }
+ }
+
+
+ }
+}
diff --git a/BBWY.1688SDK/policy/GrantType.cs b/BBWY.1688SDK/policy/GrantType.cs
new file mode 100644
index 00000000..4f4e0397
--- /dev/null
+++ b/BBWY.1688SDK/policy/GrantType.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.policy
+{
+ public class GrantType
+ {
+ public const string refresh_token="refresh_token";
+ /**
+ * 请求参数通过json串的方式传递,默认格式_data_={"key":"value"}
+ */
+ public const string get_token = "get_token";
+ }
+}
diff --git a/BBWY.1688SDK/policy/Protocol.cs b/BBWY.1688SDK/policy/Protocol.cs
new file mode 100644
index 00000000..3b7a5a4c
--- /dev/null
+++ b/BBWY.1688SDK/policy/Protocol.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.policy
+{
+ public class Protocol
+ {
+ public const string param2 = "param2";
+ /**
+ * 请求参数通过json串的方式传递,默认格式_data_={"key":"value"}
+ */
+ public const string json2 = "json2";
+ /**
+ *
+ * 请求参数通过xml的方式传递,默认格式_data_=<test>data</test>
+ */
+ public const string xml2 = "xml2";
+ public const string param = "param";
+ public const string json = "json";
+ public const string xml = "xml";
+ public const string http = "http";
+ }
+}
diff --git a/BBWY.1688SDK/policy/RequestPolicy.cs b/BBWY.1688SDK/policy/RequestPolicy.cs
new file mode 100644
index 00000000..762226e7
--- /dev/null
+++ b/BBWY.1688SDK/policy/RequestPolicy.cs
@@ -0,0 +1,113 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.policy
+{
+ public class RequestPolicy
+ {
+ private bool requestSendTimestamp = false;
+
+ public bool RequestSendTimestamp
+ {
+ get { return requestSendTimestamp; }
+ set { requestSendTimestamp = value; }
+ }
+ private bool useHttps = false;
+
+ public bool UseHttps
+ {
+ get { return useHttps; }
+ set { useHttps = value; }
+ }
+ private string requestProtocol = Protocol.param2;
+
+ internal string RequestProtocol
+ {
+ get { return requestProtocol; }
+ set { requestProtocol = value; }
+ }
+ private string responseProtocol = Protocol.json2;
+
+ internal string ResponseProtocol
+ {
+ get { return responseProtocol; }
+ set { responseProtocol = value; }
+ }
+ private bool responseCompress = true;
+
+ public bool ResponseCompress
+ {
+ get { return responseCompress; }
+ set { responseCompress = value; }
+ }
+ private int requestCompressThreshold = -1;
+
+ public int RequestCompressThreshold
+ {
+ get { return requestCompressThreshold; }
+ set { requestCompressThreshold = value; }
+ }
+ private int timeout = 5000;
+
+ public int Timeout
+ {
+ get { return timeout; }
+ set { timeout = value; }
+ }
+ private string httpMethod = "POST";
+
+ public string HttpMethod
+ {
+ get { return httpMethod; }
+ set { httpMethod = value; }
+ }
+ private String queryStringCharset = "GB18030";
+
+ public String QueryStringCharset
+ {
+ get { return queryStringCharset; }
+ set { queryStringCharset = value; }
+ }
+ private String contentCharset = "UTF-8";
+
+ public String ContentCharset
+ {
+ get { return contentCharset; }
+ set { contentCharset = value; }
+ }
+ private bool useSignture = true;
+
+ public bool UseSignture
+ {
+ get { return useSignture; }
+ set { useSignture = value; }
+ }
+ private bool needAuthorization = false;
+
+ public bool NeedAuthorization
+ {
+ get { return needAuthorization; }
+ set { needAuthorization = value; }
+ }
+ private bool accessPrivateApi = false;
+
+ public bool AccessPrivateApi
+ {
+ get { return accessPrivateApi; }
+ set { accessPrivateApi = value; }
+ }
+ private int defaultApiVersion = 1;
+
+ public int DefaultApiVersion
+ {
+ get { return defaultApiVersion; }
+ set { defaultApiVersion = value; }
+ }
+
+
+
+ }
+}
diff --git a/BBWY.1688SDK/primitive/NullableBool.cs b/BBWY.1688SDK/primitive/NullableBool.cs
new file mode 100644
index 00000000..63caafdb
--- /dev/null
+++ b/BBWY.1688SDK/primitive/NullableBool.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.primitive
+{
+ public class NullableBool : NullablePrimitiveObject
+ {
+ public NullableBool(bool value)
+ {
+ this.value = value;
+ this.isNull = false;
+ }
+
+ bool value;
+ private Boolean isNull = true;
+
+ public Boolean IsNull
+ {
+ get { return isNull; }
+ }
+
+ public void setValue(bool value)
+ {
+ this.value = value;
+ this.isNull = false;
+ }
+
+ public bool getValue()
+ {
+ return this.value;
+ }
+ }
+}
diff --git a/BBWY.1688SDK/primitive/NullableByte.cs b/BBWY.1688SDK/primitive/NullableByte.cs
new file mode 100644
index 00000000..4d73775d
--- /dev/null
+++ b/BBWY.1688SDK/primitive/NullableByte.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.primitive
+{
+ public class NullableByte : NullablePrimitiveObject
+ {
+ public NullableByte(byte value)
+ {
+ this.value = value;
+ this.isNull = false;
+ }
+
+ byte value;
+ private Boolean isNull;
+
+ public Boolean IsNull
+ {
+ get { return isNull; }
+ }
+
+ public void setValue(byte value)
+ {
+ this.value = value;
+ this.isNull = false;
+ }
+
+ public byte getValue()
+ {
+ return this.value;
+ }
+ }
+}
diff --git a/BBWY.1688SDK/primitive/NullableChar.cs b/BBWY.1688SDK/primitive/NullableChar.cs
new file mode 100644
index 00000000..f7375045
--- /dev/null
+++ b/BBWY.1688SDK/primitive/NullableChar.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.primitive
+{
+ public class NullableChar : NullablePrimitiveObject
+ {
+ public NullableChar(char value)
+ {
+ this.value = value;
+ this.isNull = false;
+ }
+
+ char value;
+ private Boolean isNull = true;
+
+ public Boolean IsNull
+ {
+ get { return isNull; }
+ }
+
+ public void setValue(char value)
+ {
+ this.value = value;
+ this.isNull = false;
+ }
+
+ public char getValue()
+ {
+ return this.value;
+ }
+ }
+}
diff --git a/BBWY.1688SDK/primitive/NullableDateTime.cs b/BBWY.1688SDK/primitive/NullableDateTime.cs
new file mode 100644
index 00000000..1b621c05
--- /dev/null
+++ b/BBWY.1688SDK/primitive/NullableDateTime.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.primitive
+{
+ public class NullableDateTime : NullablePrimitiveObject
+ {
+ public NullableDateTime(DateTime value)
+ {
+ this.value = value;
+ this.isNull = false;
+ }
+
+ DateTime value;
+ private Boolean isNull;
+
+ public Boolean IsNull
+ {
+ get { return isNull; }
+ }
+
+ public void setValue(DateTime value)
+ {
+ this.value = value;
+ this.isNull = false;
+ }
+
+ public DateTime getValue()
+ {
+ return this.value;
+ }
+ }
+}
diff --git a/BBWY.1688SDK/primitive/NullableDouble.cs b/BBWY.1688SDK/primitive/NullableDouble.cs
new file mode 100644
index 00000000..2bd5c3cf
--- /dev/null
+++ b/BBWY.1688SDK/primitive/NullableDouble.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.primitive
+{
+ public class NullableDouble : NullablePrimitiveObject
+ {
+ public NullableDouble(double value)
+ {
+ this.value = value;
+ this.isNull = false;
+ }
+
+ double value;
+ private Boolean isNull;
+
+ public Boolean IsNull
+ {
+ get { return isNull; }
+ }
+
+ public void setValue(double value)
+ {
+ this.value = value;
+ this.isNull = false;
+ }
+
+ public double getValue()
+ {
+ return this.value;
+ }
+ }
+}
diff --git a/BBWY.1688SDK/primitive/NullableFloat.cs b/BBWY.1688SDK/primitive/NullableFloat.cs
new file mode 100644
index 00000000..8a294cf3
--- /dev/null
+++ b/BBWY.1688SDK/primitive/NullableFloat.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.primitive
+{
+ public class NullableFloat : NullablePrimitiveObject
+ {
+ public NullableFloat(float value)
+ {
+ this.value = value;
+ this.isNull = false;
+ }
+
+ float value;
+ private Boolean isNull;
+
+ public Boolean IsNull
+ {
+ get { return isNull; }
+ }
+
+ public void setValue(float value)
+ {
+ this.value = value;
+ this.isNull = false;
+ }
+
+ public float getValue()
+ {
+ return this.value;
+ }
+ }
+}
diff --git a/BBWY.1688SDK/primitive/NullableInt.cs b/BBWY.1688SDK/primitive/NullableInt.cs
new file mode 100644
index 00000000..a9fd6def
--- /dev/null
+++ b/BBWY.1688SDK/primitive/NullableInt.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.primitive
+{
+ public class NullableInt : NullablePrimitiveObject
+ {
+ public NullableInt(int value)
+ {
+ this.value = value;
+ this.isNull = false;
+ }
+
+ int value;
+ private Boolean isNull;
+
+ public Boolean IsNull
+ {
+ get { return isNull; }
+ }
+
+ public void setValue(int value)
+ {
+ this.value = value;
+ this.isNull = false;
+ }
+
+ public int getValue()
+ {
+ return this.value;
+ }
+ }
+}
diff --git a/BBWY.1688SDK/primitive/NullableLong.cs b/BBWY.1688SDK/primitive/NullableLong.cs
new file mode 100644
index 00000000..1dfd55ac
--- /dev/null
+++ b/BBWY.1688SDK/primitive/NullableLong.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.primitive
+{
+ public class NullableLong : NullablePrimitiveObject
+ {
+ public NullableLong(long value)
+ {
+ this.value = value;
+ this.isNull = false;
+ }
+
+ long value;
+ private Boolean isNull;
+
+ public Boolean IsNull
+ {
+ get { return isNull; }
+ }
+
+ public void setValue(long value)
+ {
+ this.value = value;
+ this.isNull = false;
+ }
+
+ public long getValue()
+ {
+ return this.value;
+ }
+ }
+}
diff --git a/BBWY.1688SDK/primitive/NullablePrimitiveObject.cs b/BBWY.1688SDK/primitive/NullablePrimitiveObject.cs
new file mode 100644
index 00000000..e9a4ef41
--- /dev/null
+++ b/BBWY.1688SDK/primitive/NullablePrimitiveObject.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.primitive
+{
+ public class NullablePrimitiveObject
+ {
+ }
+}
diff --git a/BBWY.1688SDK/serialize/DeSerializer.cs b/BBWY.1688SDK/serialize/DeSerializer.cs
new file mode 100644
index 00000000..332ed39f
--- /dev/null
+++ b/BBWY.1688SDK/serialize/DeSerializer.cs
@@ -0,0 +1,21 @@
+using com.alibaba.openapi.client.entity;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.serialize
+{
+ public interface DeSerializer
+ {
+ //返回该反序列化接口支持的数据协议.
+ String supportedContentType();
+
+ ResponseWrapper deSerialize(Stream istream, Type resultType, String charSet);
+
+ Exception buildException(Stream inputStream, int statusCode, String charSet);
+
+ }
+}
diff --git a/BBWY.1688SDK/serialize/Json2Deserializer.cs b/BBWY.1688SDK/serialize/Json2Deserializer.cs
new file mode 100644
index 00000000..79b9dbe5
--- /dev/null
+++ b/BBWY.1688SDK/serialize/Json2Deserializer.cs
@@ -0,0 +1,56 @@
+using com.alibaba.openapi.client.entity;
+using com.alibaba.openapi.client.exception;
+using com.alibaba.openapi.client.policy;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.Serialization.Json;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.serialize
+{
+ public class Json2Deserializer : DeSerializer
+ {
+ //返回该反序列化接口支持的数据协议.
+ public String supportedContentType()
+ {
+ return Protocol.json2;
+ }
+
+ public ResponseWrapper deSerialize(Stream istream, Type resultType, String charSet)
+ {
+ StreamReader sr = new StreamReader(istream, Encoding.UTF8);
+ string strhtml = sr.ReadToEnd();
+ using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(strhtml)))
+ {
+ DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(resultType);
+ object result = jsonSerializer.ReadObject(ms);
+ ResponseWrapper responseWrapper = new ResponseWrapper();
+ responseWrapper.Result = result;
+
+ return responseWrapper;
+ }
+ }
+
+ public Exception buildException(Stream istream, int statusCode, String charSet)
+ {
+
+
+ istream.Position = 0;
+ DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(ErrorExceptionDesc));
+ object resultObj = jsonSerializer.ReadObject(istream);
+ ErrorExceptionDesc result = (ErrorExceptionDesc)resultObj;
+ String errorCodeStr = result.getError_code();
+ String errorMesage = result.getError_message();
+
+ OceanException oceanException = new OceanException(errorMesage);
+ oceanException.setError_code(errorCodeStr);
+ oceanException.setError_message(errorMesage);
+ return oceanException;
+
+
+ }
+ }
+}
diff --git a/BBWY.1688SDK/serialize/Param2RequestSerializer.cs b/BBWY.1688SDK/serialize/Param2RequestSerializer.cs
new file mode 100644
index 00000000..2812bdc8
--- /dev/null
+++ b/BBWY.1688SDK/serialize/Param2RequestSerializer.cs
@@ -0,0 +1,109 @@
+using com.alibaba.openapi.client.policy;
+using com.alibaba.openapi.client.primitive;
+using com.alibaba.openapi.client.util;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.Serialization.Json;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.serialize
+{
+ public class Param2RequestSerializer : Serializer
+ {
+ public String supportedContentType()
+ {
+ return Protocol.param2;
+ }
+
+ public Dictionary serialize(Object serializer)
+ {
+ Dictionary result = serializeNest(serializer);
+ return result;
+ }
+
+ private Dictionary serializeNest(Object serializer)
+ {
+ Dictionary result = new Dictionary();
+ if (serializer == null)
+ {
+ return result;
+ }
+ Type type = serializer.GetType();
+
+ IEnumerable fis = type.GetRuntimeFields();
+ TextInfo tInfo = Thread.CurrentThread.CurrentCulture.TextInfo;
+
+ foreach (FieldInfo fi in fis)
+ {
+ Type fieldType = fi.FieldType;
+
+ String piName = fi.Name;
+ String firstCharacter = piName.Substring(0, 1);
+ String upperFirstCharacter = firstCharacter.ToUpper(Thread.CurrentThread.CurrentCulture);
+ String tempName = upperFirstCharacter + piName.Substring(1);
+ if (!"ApiId".Equals(tempName))
+ {
+ MethodInfo mi = type.GetMethod("get" + tempName);
+ object value = mi.Invoke(serializer, null);
+ if (value != null)
+ {
+ object trueValue = null;
+ if (fieldType.IsAssignableFrom(typeof(bool?))
+ ||fieldType.IsAssignableFrom(typeof(byte?))
+ ||fieldType.IsAssignableFrom(typeof(char?))
+ ||fieldType.IsAssignableFrom(typeof(double?))
+ ||fieldType.IsAssignableFrom(typeof(float?))
+ ||fieldType.IsAssignableFrom(typeof(int?))
+ ||fieldType.IsAssignableFrom(typeof(long?)))
+ {
+ trueValue = value;
+ }
+ else if (fieldType.IsAssignableFrom(typeof(String)))
+ {
+ if (value.GetType().IsAssignableFrom(typeof(DateTime)))
+ {
+ DateTime dateTime = (DateTime)value;
+ trueValue = DateUtil.formatForOcean(dateTime);
+ }
+ else
+ {
+ trueValue = value;
+ }
+ }
+ else if (fieldType.IsAssignableFrom(typeof(DateTime?)))
+ {
+ DateTime dateTime = (DateTime)value;
+ trueValue = DateUtil.format(dateTime);
+ }
+ else if (fieldType.IsAssignableFrom(typeof(Byte[])) || fieldType.IsAssignableFrom(typeof(byte[])))
+ {
+ trueValue = Convert.ToBase64String((byte[])value);
+ }
+ else
+ {
+ DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(fieldType);
+ MemoryStream stream = new MemoryStream();
+ dataContractJsonSerializer.WriteObject(stream, value);
+ byte[] dataBytes = new byte[stream.Length];
+ stream.Position = 0;
+ stream.Read(dataBytes, 0, (int)stream.Length);
+
+ string dataString = Encoding.UTF8.GetString(dataBytes);
+ trueValue = dataString;
+ }
+ result.Add(piName, trueValue);
+ }
+
+ }
+ }
+ return result;
+ }
+
+ }
+}
diff --git a/BBWY.1688SDK/serialize/Serializer.cs b/BBWY.1688SDK/serialize/Serializer.cs
new file mode 100644
index 00000000..7dfba74c
--- /dev/null
+++ b/BBWY.1688SDK/serialize/Serializer.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.serialize
+{
+ public interface Serializer
+ {
+
+ //返回该反序列化接口支持的数据协议.
+ String supportedContentType();
+
+ //序列化方法
+ Dictionary serialize(Object serializer);
+ }
+}
diff --git a/BBWY.1688SDK/serialize/SerializerProvider.cs b/BBWY.1688SDK/serialize/SerializerProvider.cs
new file mode 100644
index 00000000..86249f53
--- /dev/null
+++ b/BBWY.1688SDK/serialize/SerializerProvider.cs
@@ -0,0 +1,60 @@
+using com.alibaba.openapi.client.policy;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.serialize
+{
+ public class SerializerProvider
+ {
+ private static SerializerProvider instance;
+ private static Object lockObject=new Object();
+ public static SerializerProvider getInstance()
+ {
+ if (instance == null)
+ {
+ lock (lockObject)
+ {
+ if (instance == null)
+ {
+ instance = new SerializerProvider();
+ instance.initial();
+ }
+ }
+ }
+ return instance;
+ }
+
+ private SerializerProvider()
+ {
+
+ }
+
+ private void initial()
+ {
+ serializerStore.Add(Protocol.param2, new Param2RequestSerializer());
+ deSerializerStore.Add(Protocol.param2, new Json2Deserializer());
+ deSerializerStore.Add(Protocol.json2, new Json2Deserializer());
+ }
+
+ private Dictionary serializerStore = new Dictionary();
+
+ public Serializer getSerializer(String contentType)
+ {
+ return serializerStore[contentType];
+ }
+
+ private Dictionary deSerializerStore = new Dictionary();
+
+ public DeSerializer getDeSerializer(String contentType)
+ {
+ return deSerializerStore[contentType];
+ }
+
+
+
+
+ }
+}
diff --git a/BBWY.1688SDK/util/DateUtil.cs b/BBWY.1688SDK/util/DateUtil.cs
new file mode 100644
index 00000000..242fd011
--- /dev/null
+++ b/BBWY.1688SDK/util/DateUtil.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.util
+{
+ public class DateUtil
+ {
+ //这里定义两个日期格式,由于.Net平台的毫秒格式用fff表示,Ocean平台(Java)的毫秒格式用SSS表示。
+ private static string Date_Pattern = "yyyyMMddHHmmssfff";
+
+ private static string Date_PatternForOcean = "yyyyMMddHHmmssSSS";
+
+
+ public static String getDatePattern()
+ {
+ return Date_PatternForOcean;
+ }
+
+ public static String format(DateTime date)
+ {
+ return date.ToString(Date_Pattern);
+ }
+
+ public static String formatForOcean(DateTime date)
+ {
+ String value = date.ToString("yyyyMMddHHmmssfffzzz");
+ String newValue = value.Replace(":", "");
+ return newValue;
+ }
+
+ public static DateTime formatFromStr(String dateDesc)
+ {
+ if (dateDesc.Contains("+") || dateDesc.Contains("-"))
+ {
+ try
+ {
+ IFormatProvider culture = new CultureInfo("zh-CN", true);
+ DateTime datetime = DateTime.ParseExact(dateDesc, "yyyyMMddHHmmssfffzzz", culture);
+ return datetime;
+ }
+ catch (Exception x)
+ {
+ String message = x.Message;
+ }
+ }
+ IFormatProvider newculture = new CultureInfo("zh-CN", true);
+ DateTime newdatetime = DateTime.ParseExact(dateDesc, Date_Pattern, newculture);
+ return newdatetime;
+ }
+
+
+
+ public static long currentTimeMillis()
+ {
+ System.DateTime current = new DateTime();
+ System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
+ double ms = (current - startTime).TotalMilliseconds;
+ long b = Convert.ToInt64(ms);
+ return b;
+ }
+ }
+}
diff --git a/BBWY.1688SDK/util/SignatureUtil.cs b/BBWY.1688SDK/util/SignatureUtil.cs
new file mode 100644
index 00000000..ceb22a28
--- /dev/null
+++ b/BBWY.1688SDK/util/SignatureUtil.cs
@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.alibaba.openapi.client.util
+{
+ public class SignatureUtil
+ {
+ public static byte[] hmacSha1(String path, Dictionary parameters, String signingKey)
+ {
+ List lists = new List();
+ foreach (KeyValuePair kvp in parameters)
+ {
+ lists.Add(kvp.Key + kvp.Value);
+ }
+ lists.Sort(StringComparer.Ordinal);
+ StringBuilder sb = new StringBuilder();
+ sb.Append(path);
+ foreach (String param in lists)
+ {
+ sb.Append(param);
+ }
+ String contentToHmac = sb.ToString();
+ byte[] byteToHmac = System.Text.Encoding.UTF8.GetBytes(contentToHmac);
+ byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(signingKey);
+ HMACSHA1 hmac = new HMACSHA1(byteArray);
+ byte[] hashValue = hmac.ComputeHash(byteToHmac, 0, byteToHmac.Length);
+ return hashValue;
+ }
+
+ public static string toHex( byte[] bytes)
+ {
+ char[] c = new char[bytes.Length * 2];
+
+ byte b;
+
+ for (int bx = 0, cx = 0; bx < bytes.Length; ++bx, ++cx)
+ {
+ b = ((byte)(bytes[bx] >> 4));
+ c[cx] = (char)(b > 9 ? b + 0x37 + 0x20 : b + 0x30);
+
+ b = ((byte)(bytes[bx] & 0x0F));
+ c[++cx] = (char)(b > 9 ? b + 0x37 + 0x20 : b + 0x30);
+ }
+
+ return new string(c).ToUpper();
+ }
+
+ public static byte[] hexToBytes( string str)
+ {
+ if (str.Length == 0 || str.Length % 2 != 0)
+ return new byte[0];
+
+ byte[] buffer = new byte[str.Length / 2];
+ char c;
+ for (int bx = 0, sx = 0; bx < buffer.Length; ++bx, ++sx)
+ {
+ // Convert first half of byte
+ c = str[sx];
+ buffer[bx] = (byte)((c > '9' ? (c > 'Z' ? (c - 'a' + 10) : (c - 'A' + 10)) : (c - '0')) << 4);
+
+ // Convert second half of byte
+ c = str[++sx];
+ buffer[bx] |= (byte)(c > '9' ? (c > 'Z' ? (c - 'a' + 10) : (c - 'A' + 10)) : (c - '0'));
+ }
+
+ return buffer;
+ }
+ }
+}
diff --git a/BBWY.Server.API/Controllers/PlatformSDKController.cs b/BBWY.Server.API/Controllers/PlatformSDKController.cs
index 3caea906..c7821abf 100644
--- a/BBWY.Server.API/Controllers/PlatformSDKController.cs
+++ b/BBWY.Server.API/Controllers/PlatformSDKController.cs
@@ -119,5 +119,16 @@ namespace BBWY.Server.API.Controllers
{
platformSDKBusinessList.FirstOrDefault(p => p.Platform == outStockRequest.Platform).OutStock(outStockRequest);
}
+
+ ///
+ /// 订单预览
+ ///
+ ///
+ ///
+ [HttpPost]
+ public PreviewOrderResponse PreviewOrder(PreviewOrderReuqest previewOrderReuqest)
+ {
+ return platformSDKBusinessList.FirstOrDefault(p => p.Platform == previewOrderReuqest.Platform).PreviewOrder(previewOrderReuqest);
+ }
}
}
diff --git a/BBWY.Server.API/Startup.cs b/BBWY.Server.API/Startup.cs
index 4f7b4508..20570bbe 100644
--- a/BBWY.Server.API/Startup.cs
+++ b/BBWY.Server.API/Startup.cs
@@ -67,6 +67,7 @@ namespace BBWY.Server.API
});
services.BatchRegisterServices(new Assembly[] { Assembly.Load("BBWY.Server.Business") }, typeof(IDenpendency));
services.AddSingleton();
+ services.AddSingleton();
//var stores = Configuration.GetSection("Stores").Get>();
diff --git a/BBWY.Server.Business/BBWY.Server.Business.csproj b/BBWY.Server.Business/BBWY.Server.Business.csproj
index 1c50ffda..c9937f02 100644
--- a/BBWY.Server.Business/BBWY.Server.Business.csproj
+++ b/BBWY.Server.Business/BBWY.Server.Business.csproj
@@ -15,6 +15,7 @@
+
diff --git a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs
index 0aac43f0..1e22c310 100644
--- a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs
+++ b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs
@@ -34,7 +34,7 @@ namespace BBWY.Server.Business
};
- public JDBusiness(IMemoryCache memoryCache, ILogger logger) : base(memoryCache) { this.logger = logger; }
+ public JDBusiness(IMemoryCache memoryCache, ILogger logger) : base(memoryCache, logger) { }
private IJdClient GetJdClient(string appKey, string appSecret)
{
diff --git a/BBWY.Server.Business/PlatformSDK/PDDBusiness.cs b/BBWY.Server.Business/PlatformSDK/PDDBusiness.cs
index 6f1f0e4f..e2e26e5d 100644
--- a/BBWY.Server.Business/PlatformSDK/PDDBusiness.cs
+++ b/BBWY.Server.Business/PlatformSDK/PDDBusiness.cs
@@ -1,4 +1,6 @@
-using Microsoft.Extensions.Caching.Memory;
+using BBWY.Server.Model;
+using Microsoft.Extensions.Caching.Memory;
+using NLog;
using System;
using System.Collections.Generic;
using System.Text;
@@ -7,7 +9,8 @@ namespace BBWY.Server.Business
{
public class PDDBusiness : PlatformSDKBusiness
{
- public PDDBusiness(IMemoryCache memoryCache) : base(memoryCache)
+ public override Enums.Platform Platform => Enums.Platform.拼多多;
+ public PDDBusiness(IMemoryCache memoryCache, ILogger logger) : base(memoryCache, logger)
{
}
}
diff --git a/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs b/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs
index 8c969ddb..0b452351 100644
--- a/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs
+++ b/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs
@@ -2,6 +2,7 @@
using BBWY.Server.Model.Dto;
using Microsoft.Extensions.Caching.Memory;
using Newtonsoft.Json.Linq;
+using NLog;
using System;
using System.Collections.Generic;
@@ -11,16 +12,20 @@ namespace BBWY.Server.Business
{
protected IMemoryCache memoryCache;
- protected TimeSpan expirationTimeSpan = TimeSpan.FromMinutes(60);
+ protected TimeSpan expirationTimeSpan;
///
/// 产品平台
///
public virtual Enums.Platform Platform { get; }
- public PlatformSDKBusiness(IMemoryCache memoryCache)
+ protected ILogger logger;
+
+ public PlatformSDKBusiness(IMemoryCache memoryCache, ILogger logger)
{
this.memoryCache = memoryCache;
+ this.logger = logger;
+ this.expirationTimeSpan = TimeSpan.FromMinutes(60);
}
public virtual ProductListResponse GetProductList(SearchProductRequest searchProductRequest)
@@ -67,5 +72,10 @@ namespace BBWY.Server.Business
{
throw new NotImplementedException();
}
+
+ public virtual PreviewOrderResponse PreviewOrder(PreviewOrderReuqest previewOrderReuqest)
+ {
+ throw new NotImplementedException();
+ }
}
}
diff --git a/BBWY.Server.Business/PlatformSDK/TaoBaoBusiness.cs b/BBWY.Server.Business/PlatformSDK/TaoBaoBusiness.cs
index c143488c..b5873afb 100644
--- a/BBWY.Server.Business/PlatformSDK/TaoBaoBusiness.cs
+++ b/BBWY.Server.Business/PlatformSDK/TaoBaoBusiness.cs
@@ -1,5 +1,6 @@
using BBWY.Server.Model;
using Microsoft.Extensions.Caching.Memory;
+using NLog;
using System;
using System.Collections.Generic;
using System.Text;
@@ -8,10 +9,10 @@ namespace BBWY.Server.Business
{
public class TaoBaoBusiness : PlatformSDKBusiness
{
- public override Enums.Platform Platform => Enums.Platform.淘宝;
-
- public TaoBaoBusiness(IMemoryCache memoryCache) : base(memoryCache)
+ public TaoBaoBusiness(IMemoryCache memoryCache, ILogger logger) : base(memoryCache, logger)
{
}
+
+ public override Enums.Platform Platform => Enums.Platform.淘宝;
}
}
diff --git a/BBWY.Server.Business/PlatformSDK/_1688Business.cs b/BBWY.Server.Business/PlatformSDK/_1688Business.cs
new file mode 100644
index 00000000..459d9c24
--- /dev/null
+++ b/BBWY.Server.Business/PlatformSDK/_1688Business.cs
@@ -0,0 +1,85 @@
+using BBWY._1688SDK.entity.OrderPreview;
+using BBWY.Server.Model;
+using BBWY.Server.Model.Dto;
+using com.alibaba.openapi.client;
+using com.alibaba.openapi.client.policy;
+using Microsoft.Extensions.Caching.Memory;
+using Newtonsoft.Json.Linq;
+using NLog;
+using System.Collections.Generic;
+
+namespace BBWY.Server.Business
+{
+ public class _1688Business : PlatformSDKBusiness
+ {
+ public override Enums.Platform Platform => Enums.Platform.阿里巴巴;
+
+ public _1688Business(IMemoryCache memoryCache, ILogger logger) : base(memoryCache, logger)
+ {
+
+ }
+
+ private SyncAPIClient GetSyncAPIClient(string appKey, string appSecret)
+ {
+ if (!memoryCache.TryGetValue(appKey, out SyncAPIClient syncAPIClient))
+ {
+ syncAPIClient = new SyncAPIClient(appKey, appSecret);
+ memoryCache.Set(appKey, syncAPIClient, expirationTimeSpan);
+ }
+ return syncAPIClient;
+ }
+
+ public override PreviewOrderResponse PreviewOrder(PreviewOrderReuqest previewOrderReuqest)
+ {
+ var client = GetSyncAPIClient(previewOrderReuqest.AppKey, previewOrderReuqest.AppSecret);
+ RequestPolicy reqPolicy = new RequestPolicy();
+ reqPolicy.HttpMethod = "POST";
+ reqPolicy.NeedAuthorization = false;
+ reqPolicy.RequestSendTimestamp = true;
+ reqPolicy.UseHttps = false;
+ reqPolicy.UseSignture = true;
+ reqPolicy.AccessPrivateApi = false;
+
+ Request request = new Request();
+ APIId apiId = new APIId();
+ apiId.Name = "alibaba.createOrder.preview";
+ apiId.NamespaceValue = "com.alibaba.trade";
+ apiId.Version = 1;
+ request.ApiId = apiId;
+
+ var param = new CreateOrderPreview()
+ {
+ addressParam = new AddressParam()
+ {
+ fullName = previewOrderReuqest.ConsigneeRequest.ContactName,
+ mobile = previewOrderReuqest.ConsigneeRequest.Mobile,
+ phone = previewOrderReuqest.ConsigneeRequest.TelePhone,
+ postCode = "000000",
+ address = previewOrderReuqest.ConsigneeRequest.Address,
+ provinceText = previewOrderReuqest.ConsigneeRequest.Province,
+ cityText = previewOrderReuqest.ConsigneeRequest.City,
+ areaText = previewOrderReuqest.ConsigneeRequest.County,
+ townText = previewOrderReuqest.ConsigneeRequest.Town
+ },
+ cargoParamList = new List(),
+ flow = "general"
+ };
+ foreach (var cargo in previewOrderReuqest.CargoParamList)
+ {
+ param.cargoParamList.Add(new CargoParam()
+ {
+ offerId = long.Parse(cargo.SkuId),
+ specId = cargo.SpecId,
+ quantity = cargo.Quantity
+ });
+ }
+ request.RequestEntity = param;
+ var result = client.send(request, reqPolicy);
+
+ return new PreviewOrderResponse()
+ {
+
+ };
+ }
+ }
+}
diff --git a/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CargoParamRequest.cs b/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CargoParamRequest.cs
new file mode 100644
index 00000000..6f6f13df
--- /dev/null
+++ b/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CargoParamRequest.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace BBWY.Server.Model.Dto
+{
+ public class CargoParamRequest
+ {
+ public string ProductId { get; set; }
+ public string SkuId { get; set; }
+ public string SpecId { get; set; }
+ public int Quantity { get; set; }
+ }
+}
diff --git a/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/ConsigneeRequest.cs b/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/ConsigneeRequest.cs
new file mode 100644
index 00000000..320e8ef5
--- /dev/null
+++ b/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/ConsigneeRequest.cs
@@ -0,0 +1,43 @@
+namespace BBWY.Server.Model.Dto
+{
+ public class ConsigneeRequest
+ {
+ ///
+ /// 联系人名称
+ ///
+ public string ContactName { get; set; }
+
+ ///
+ /// 座机
+ ///
+ public string TelePhone { get; set; }
+
+ ///
+ /// 手机
+ ///
+ public string Mobile { get; set; }
+
+ public string Address { get; set; }
+
+ ///
+ /// 省
+ ///
+ public string Province { get; set; }
+
+ ///
+ /// 市
+ ///
+ public string City { get; set; }
+
+ ///
+ /// 县
+ ///
+ public string County { get; set; }
+
+ ///
+ /// 镇
+ ///
+ public string Town { get; set; }
+
+ }
+}
diff --git a/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/PreviewOrderReuqest.cs b/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/PreviewOrderReuqest.cs
new file mode 100644
index 00000000..b74f31ef
--- /dev/null
+++ b/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/PreviewOrderReuqest.cs
@@ -0,0 +1,11 @@
+using System.Collections.Generic;
+
+namespace BBWY.Server.Model.Dto
+{
+ public class PreviewOrderReuqest: PlatformRequest
+ {
+ public ConsigneeRequest ConsigneeRequest { get; set; }
+
+ public IList CargoParamList { get; set; }
+ }
+}
diff --git a/BBWY.Server.Model/Dto/Response/PurchaseOrder/OnlinePurchase/PreviewOrderResponse.cs b/BBWY.Server.Model/Dto/Response/PurchaseOrder/OnlinePurchase/PreviewOrderResponse.cs
new file mode 100644
index 00000000..5fff9c2a
--- /dev/null
+++ b/BBWY.Server.Model/Dto/Response/PurchaseOrder/OnlinePurchase/PreviewOrderResponse.cs
@@ -0,0 +1,20 @@
+namespace BBWY.Server.Model.Dto
+{
+ public class PreviewOrderResponse
+ {
+ ///
+ /// 总额
+ ///
+ public decimal TotalAmount { get; set; }
+
+ ///
+ /// 货款总额
+ ///
+ public decimal ProductAmount { get; set; }
+
+ ///
+ /// 运费
+ ///
+ public decimal FreightAmount { get; set; }
+ }
+}
From 80f84f6bd45f1c57c8401af5f8ef5c5ea8de1f57 Mon Sep 17 00:00:00 2001
From: shanj <18996038927@163.com>
Date: Wed, 2 Mar 2022 05:02:35 +0800
Subject: [PATCH 05/20] =?UTF-8?q?=E9=87=8D=E5=86=99=E9=80=82=E5=90=88.net?=
=?UTF-8?q?=E7=9A=84=E5=8F=82=E6=95=B0=E5=BA=8F=E5=88=97=E5=8C=96=E6=96=B9?=
=?UTF-8?q?=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BBWY.1688SDK/BBWY.1688SDK.csproj | 4 +
.../example/param/apiexample/ExampleFamily.cs | 200 ++++++++++--------
.../apiexample/ExampleFamilyPostParam.cs | 104 ++++-----
.../example/param/apiexample/ExampleHouse.cs | 136 ++++++------
BBWY.1688SDK/serialize/Json2Deserializer.cs | 2 +-
.../serialize/Param2RequestSerializer.cs | 107 ++++++----
6 files changed, 303 insertions(+), 250 deletions(-)
diff --git a/BBWY.1688SDK/BBWY.1688SDK.csproj b/BBWY.1688SDK/BBWY.1688SDK.csproj
index fad4a782..ce828eff 100644
--- a/BBWY.1688SDK/BBWY.1688SDK.csproj
+++ b/BBWY.1688SDK/BBWY.1688SDK.csproj
@@ -5,4 +5,8 @@
BBWY._1688SDK
+
+
+
+
diff --git a/BBWY.1688SDK/example/param/apiexample/ExampleFamily.cs b/BBWY.1688SDK/example/param/apiexample/ExampleFamily.cs
index 8bcf2c54..51580a39 100644
--- a/BBWY.1688SDK/example/param/apiexample/ExampleFamily.cs
+++ b/BBWY.1688SDK/example/param/apiexample/ExampleFamily.cs
@@ -9,124 +9,136 @@ using System.Text;
namespace com.alibaba.china.openapi.client.example.param.apiexample
{
-[DataContract(Namespace = "com.alibaba.openapi.client")]
+ [DataContract(Namespace = "com.alibaba.openapi.client")]
public class ExampleFamily
{
- [DataMember(Order = 1)]
- private int? familyNumber;
-
+ [DataMember(Order = 1)]
+ private int? familyNumber;
+
/**
* @return 家庭编号
*/
- public int? getFamilyNumber() {
- return familyNumber;
- }
-
- /**
- * 设置家庭编号 *
- * 参数示例:
- * 此参数必填
- */
- public void setFamilyNumber(int familyNumber) {
- this.familyNumber = familyNumber;
- }
-
+ public int? getFamilyNumber()
+ {
+ return familyNumber;
+ }
+
+ /**
+ * 设置家庭编号 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setFamilyNumber(int familyNumber)
+ {
+ this.familyNumber = familyNumber;
+ }
+
[DataMember(Order = 2)]
- private ExamplePerson father;
-
+ private ExamplePerson father;
+
/**
* @return 父亲对象,可以为空
*/
- public ExamplePerson getFather() {
- return father;
- }
-
- /**
- * 设置父亲对象,可以为空 *
- * 参数示例:
- * 此参数必填
- */
- public void setFather(ExamplePerson father) {
- this.father = father;
- }
-
+ public ExamplePerson getFather()
+ {
+ return father;
+ }
+
+ /**
+ * 设置父亲对象,可以为空 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setFather(ExamplePerson father)
+ {
+ this.father = father;
+ }
+
[DataMember(Order = 3)]
- private ExamplePerson mother;
-
+ private ExamplePerson mother;
+
/**
* @return 母亲对象,可以为空
*/
- public ExamplePerson getMother() {
- return mother;
- }
-
- /**
- * 设置母亲对象,可以为空 *
- * 参数示例:
- * 此参数必填
- */
- public void setMother(ExamplePerson mother) {
- this.mother = mother;
- }
-
+ public ExamplePerson getMother()
+ {
+ return mother;
+ }
+
+ /**
+ * 设置母亲对象,可以为空 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setMother(ExamplePerson mother)
+ {
+ this.mother = mother;
+ }
+
[DataMember(Order = 4)]
- private ExamplePerson[] children;
-
+ private ExamplePerson[] children;
+
/**
* @return 孩子列表
*/
- public ExamplePerson[] getChildren() {
- return children;
- }
-
- /**
- * 设置孩子列表 *
- * 参数示例:
- * 此参数必填
- */
- public void setChildren(ExamplePerson[] children) {
- this.children = children;
- }
-
+ public ExamplePerson[] getChildren()
+ {
+ return children;
+ }
+
+ /**
+ * 设置孩子列表 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setChildren(ExamplePerson[] children)
+ {
+ this.children = children;
+ }
+
[DataMember(Order = 5)]
- private ExampleCar[] ownedCars;
-
+ private ExampleCar[] ownedCars;
+
/**
* @return 拥有的汽车信息
*/
- public ExampleCar[] getOwnedCars() {
- return ownedCars;
- }
-
- /**
- * 设置拥有的汽车信息 *
- * 参数示例:
- * 此参数必填
- */
- public void setOwnedCars(ExampleCar[] ownedCars) {
- this.ownedCars = ownedCars;
- }
-
+ public ExampleCar[] getOwnedCars()
+ {
+ return ownedCars;
+ }
+
+ /**
+ * 设置拥有的汽车信息 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setOwnedCars(ExampleCar[] ownedCars)
+ {
+ this.ownedCars = ownedCars;
+ }
+
[DataMember(Order = 6)]
- private ExampleHouse myHouse;
-
+ private ExampleHouse myHouse;
+
/**
* @return 所住的房屋信息
*/
- public ExampleHouse getMyHouse() {
- return myHouse;
- }
-
- /**
- * 设置所住的房屋信息 *
- * 参数示例:
- * 此参数必填
- */
- public void setMyHouse(ExampleHouse myHouse) {
- this.myHouse = myHouse;
- }
-
-
- }
+ public ExampleHouse getMyHouse()
+ {
+ return myHouse;
+ }
+
+ /**
+ * 设置所住的房屋信息 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setMyHouse(ExampleHouse myHouse)
+ {
+ this.myHouse = myHouse;
+ }
+
+
+ }
}
\ No newline at end of file
diff --git a/BBWY.1688SDK/example/param/apiexample/ExampleFamilyPostParam.cs b/BBWY.1688SDK/example/param/apiexample/ExampleFamilyPostParam.cs
index 355cd1e1..087c88a8 100644
--- a/BBWY.1688SDK/example/param/apiexample/ExampleFamilyPostParam.cs
+++ b/BBWY.1688SDK/example/param/apiexample/ExampleFamilyPostParam.cs
@@ -9,67 +9,73 @@ using System.Text;
namespace com.alibaba.china.openapi.client.example.param.apiexample
{
-[DataContract(Namespace = "com.alibaba.openapi.client")]
+ [DataContract(Namespace = "com.alibaba.openapi.client")]
public class ExampleFamilyPostParam
{
- [DataMember(Order = 1)]
- private ExampleFamily family;
-
+ [DataMember(Order = 1)]
+ private ExampleFamily family;
+
/**
* @return 上传Family对象信息
*/
- public ExampleFamily getFamily() {
- return family;
- }
-
- /**
- * 设置上传Family对象信息 *
- * 参数示例:
- * 此参数必填
- */
- public void setFamily(ExampleFamily family) {
- this.family = family;
- }
-
+ public ExampleFamily getFamily()
+ {
+ return family;
+ }
+
+ /**
+ * 设置上传Family对象信息 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setFamily(ExampleFamily family)
+ {
+ this.family = family;
+ }
+
[DataMember(Order = 2)]
- private string comments;
-
+ private string comments;
+
/**
* @return 备注信息
*/
- public string getComments() {
- return comments;
- }
-
- /**
- * 设置备注信息 *
- * 参数示例:
- * 此参数必填
- */
- public void setComments(string comments) {
- this.comments = comments;
- }
-
+ public string getComments()
+ {
+ return comments;
+ }
+
+ /**
+ * 设置备注信息 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setComments(string comments)
+ {
+ this.comments = comments;
+ }
+
[DataMember(Order = 3)]
- private byte[] houseImg;
-
+ private byte[] houseImg;
+
/**
* @return 房屋信息
*/
- public byte[] getHouseImg() {
- return houseImg;
- }
-
- /**
- * 设置房屋信息 *
- * 参数示例:
- * 此参数必填
- */
- public void setHouseImg(byte[] houseImg) {
- this.houseImg = houseImg;
- }
-
-
- }
+ public byte[] getHouseImg()
+ {
+ return houseImg;
+ }
+
+ /**
+ * 设置房屋信息 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setHouseImg(byte[] houseImg)
+ {
+ this.houseImg = houseImg;
+ }
+
+
+ }
}
\ No newline at end of file
diff --git a/BBWY.1688SDK/example/param/apiexample/ExampleHouse.cs b/BBWY.1688SDK/example/param/apiexample/ExampleHouse.cs
index d865cd9b..728a04de 100644
--- a/BBWY.1688SDK/example/param/apiexample/ExampleHouse.cs
+++ b/BBWY.1688SDK/example/param/apiexample/ExampleHouse.cs
@@ -9,86 +9,94 @@ using System.Text;
namespace com.alibaba.china.openapi.client.example.param.apiexample
{
-[DataContract(Namespace = "com.alibaba.openapi.client")]
+ [DataContract(Namespace = "com.alibaba.openapi.client")]
public class ExampleHouse
{
- [DataMember(Order = 1)]
- private string location;
-
+ [DataMember(Order = 1)]
+ private string location;
+
/**
* @return
*/
- public string getLocation() {
- return location;
- }
-
- /**
- * 设置 *
- * 参数示例:
- * 此参数必填
- */
- public void setLocation(string location) {
- this.location = location;
- }
-
+ public string getLocation()
+ {
+ return location;
+ }
+
+ /**
+ * 设置 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setLocation(string location)
+ {
+ this.location = location;
+ }
+
[DataMember(Order = 2)]
- private int? areaSize;
-
+ private int? areaSize;
+
/**
* @return
*/
- public int? getAreaSize() {
- return areaSize;
- }
-
- /**
- * 设置 *
- * 参数示例:
- * 此参数必填
- */
- public void setAreaSize(int areaSize) {
- this.areaSize = areaSize;
- }
-
+ public int? getAreaSize()
+ {
+ return areaSize;
+ }
+
+ /**
+ * 设置 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setAreaSize(int areaSize)
+ {
+ this.areaSize = areaSize;
+ }
+
[DataMember(Order = 3)]
- private bool? rent;
-
+ private bool? rent;
+
/**
* @return
*/
- public bool? getRent() {
- return rent;
- }
-
- /**
- * 设置 *
- * 参数示例:
- * 此参数必填
- */
- public void setRent(bool rent) {
- this.rent = rent;
- }
-
+ public bool? getRent()
+ {
+ return rent;
+ }
+
+ /**
+ * 设置 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setRent(bool rent)
+ {
+ this.rent = rent;
+ }
+
[DataMember(Order = 4)]
- private int? rooms;
-
+ private int? rooms;
+
/**
* @return
*/
- public int? getRooms() {
- return rooms;
- }
-
- /**
- * 设置 *
- * 参数示例:
- * 此参数必填
- */
- public void setRooms(int rooms) {
- this.rooms = rooms;
- }
-
-
- }
+ public int? getRooms()
+ {
+ return rooms;
+ }
+
+ /**
+ * 设置 *
+ * 参数示例:
+ * 此参数必填
+ */
+ public void setRooms(int rooms)
+ {
+ this.rooms = rooms;
+ }
+
+
+ }
}
\ No newline at end of file
diff --git a/BBWY.1688SDK/serialize/Json2Deserializer.cs b/BBWY.1688SDK/serialize/Json2Deserializer.cs
index 79b9dbe5..2b12b423 100644
--- a/BBWY.1688SDK/serialize/Json2Deserializer.cs
+++ b/BBWY.1688SDK/serialize/Json2Deserializer.cs
@@ -38,7 +38,7 @@ namespace com.alibaba.openapi.client.serialize
{
- istream.Position = 0;
+ //istream.Position = 0;
DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(ErrorExceptionDesc));
object resultObj = jsonSerializer.ReadObject(istream);
ErrorExceptionDesc result = (ErrorExceptionDesc)resultObj;
diff --git a/BBWY.1688SDK/serialize/Param2RequestSerializer.cs b/BBWY.1688SDK/serialize/Param2RequestSerializer.cs
index 2812bdc8..3e9878bb 100644
--- a/BBWY.1688SDK/serialize/Param2RequestSerializer.cs
+++ b/BBWY.1688SDK/serialize/Param2RequestSerializer.cs
@@ -1,6 +1,7 @@
using com.alibaba.openapi.client.policy;
using com.alibaba.openapi.client.primitive;
using com.alibaba.openapi.client.util;
+using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -23,8 +24,9 @@ namespace com.alibaba.openapi.client.serialize
public Dictionary serialize(Object serializer)
{
- Dictionary result = serializeNest(serializer);
- return result;
+ //Dictionary result = serializeNest(serializer);
+ //return result;
+ return serializeParam(serializer);
}
private Dictionary serializeNest(Object serializer)
@@ -49,57 +51,78 @@ namespace com.alibaba.openapi.client.serialize
String tempName = upperFirstCharacter + piName.Substring(1);
if (!"ApiId".Equals(tempName))
{
- MethodInfo mi = type.GetMethod("get" + tempName);
- object value = mi.Invoke(serializer, null);
- if (value != null)
- {
- object trueValue = null;
- if (fieldType.IsAssignableFrom(typeof(bool?))
- ||fieldType.IsAssignableFrom(typeof(byte?))
- ||fieldType.IsAssignableFrom(typeof(char?))
- ||fieldType.IsAssignableFrom(typeof(double?))
- ||fieldType.IsAssignableFrom(typeof(float?))
- ||fieldType.IsAssignableFrom(typeof(int?))
- ||fieldType.IsAssignableFrom(typeof(long?)))
- {
- trueValue = value;
- }
- else if (fieldType.IsAssignableFrom(typeof(String)))
+ MethodInfo mi = type.GetMethod("get" + tempName);
+ object value = mi.Invoke(serializer, null);
+ if (value != null)
{
- if (value.GetType().IsAssignableFrom(typeof(DateTime)))
+ object trueValue = null;
+ if (fieldType.IsAssignableFrom(typeof(bool?))
+ || fieldType.IsAssignableFrom(typeof(byte?))
+ || fieldType.IsAssignableFrom(typeof(char?))
+ || fieldType.IsAssignableFrom(typeof(double?))
+ || fieldType.IsAssignableFrom(typeof(float?))
+ || fieldType.IsAssignableFrom(typeof(int?))
+ || fieldType.IsAssignableFrom(typeof(long?)))
+ {
+ trueValue = value;
+ }
+ else if (fieldType.IsAssignableFrom(typeof(String)))
+ {
+ if (value.GetType().IsAssignableFrom(typeof(DateTime)))
+ {
+ DateTime dateTime = (DateTime)value;
+ trueValue = DateUtil.formatForOcean(dateTime);
+ }
+ else
+ {
+ trueValue = value;
+ }
+ }
+ else if (fieldType.IsAssignableFrom(typeof(DateTime?)))
{
DateTime dateTime = (DateTime)value;
- trueValue = DateUtil.formatForOcean(dateTime);
+ trueValue = DateUtil.format(dateTime);
+ }
+ else if (fieldType.IsAssignableFrom(typeof(Byte[])) || fieldType.IsAssignableFrom(typeof(byte[])))
+ {
+ trueValue = Convert.ToBase64String((byte[])value);
}
else
{
- trueValue = value;
+ DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(fieldType);
+ MemoryStream stream = new MemoryStream();
+ dataContractJsonSerializer.WriteObject(stream, value);
+ byte[] dataBytes = new byte[stream.Length];
+ stream.Position = 0;
+ stream.Read(dataBytes, 0, (int)stream.Length);
+
+ string dataString = Encoding.UTF8.GetString(dataBytes);
+ trueValue = dataString;
}
+ result.Add(piName, trueValue);
}
- else if (fieldType.IsAssignableFrom(typeof(DateTime?)))
- {
- DateTime dateTime = (DateTime)value;
- trueValue = DateUtil.format(dateTime);
- }
- else if (fieldType.IsAssignableFrom(typeof(Byte[])) || fieldType.IsAssignableFrom(typeof(byte[])))
- {
- trueValue = Convert.ToBase64String((byte[])value);
- }
- else
- {
- DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(fieldType);
- MemoryStream stream = new MemoryStream();
- dataContractJsonSerializer.WriteObject(stream, value);
- byte[] dataBytes = new byte[stream.Length];
- stream.Position = 0;
- stream.Read(dataBytes, 0, (int)stream.Length);
- string dataString = Encoding.UTF8.GetString(dataBytes);
- trueValue = dataString;
- }
- result.Add(piName, trueValue);
}
+ }
+ return result;
+ }
+ private Dictionary serializeParam(object param)
+ {
+ Dictionary result = new Dictionary();
+ Type type = param.GetType();
+ var properties = type.GetProperties();
+ foreach (var property in properties)
+ {
+ var value = property.GetValue(param);
+ var valueType = value.GetType();
+ if (valueType.IsClass)
+ {
+ result.Add(property.Name, JsonConvert.SerializeObject(value));
+ }
+ else
+ {
+ result.Add(property.Name, value);
}
}
return result;
From 623701c76327309dbffacfd84d131f8c1be7aed8 Mon Sep 17 00:00:00 2001
From: shanj <18996038927@163.com>
Date: Thu, 3 Mar 2022 02:21:15 +0800
Subject: [PATCH 06/20] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E1688SDK=E8=AF=B7?=
=?UTF-8?q?=E6=B1=82=202.=E8=AE=A2=E5=8D=95=E9=A2=84=E8=A7=88=E7=AA=97?=
=?UTF-8?q?=E5=8F=A3=E6=96=B0=E5=A2=9E=E6=94=B6=E8=B4=A7=E4=BA=BA=E4=BF=A1?=
=?UTF-8?q?=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BBWY.1688SDK/BBWY.1688SDK.csproj | 4 ++
BBWY.1688SDK/SyncAPIClient.cs | 22 +++++++-
BBWY.1688SDK/http/HttpClient.cs | 52 +++++++++++++++----
.../Order/ChoosePurchaseSchemeViewModel.cs | 8 ++-
.../ViewModels/Order/OrderListViewModel.cs | 2 +-
.../Purchase/1688PreviewPurchaseViewModel.cs | 32 +++++++++++-
BBWY.Client/Views/Purchase/1688Purchase.xaml | 26 +++++++---
.../Views/Purchase/1688Purchase.xaml.cs | 4 +-
.../Controllers/PlatformSDKController.cs | 4 +-
.../Controllers/PurchaseOrderController.cs | 16 +++++-
.../PlatformSDK/JDBusiness.cs | 7 +--
.../PlatformSDK/_1688Business.cs | 19 +++++--
.../PurchaseOrder/PurchaseOrderBusiness.cs | 16 +++++-
13 files changed, 175 insertions(+), 37 deletions(-)
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);
+ }
}
}
From 39f5e32dc4f47ae695cc12b2bb32795d5014d7b2 Mon Sep 17 00:00:00 2001
From: shanj <18996038927@163.com>
Date: Thu, 3 Mar 2022 11:56:09 +0800
Subject: [PATCH 07/20] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E9=A2=84=E8=A7=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BBWY.1688SDK/serialize/Param2RequestSerializer.cs | 15 ++++++++++-----
BBWY.Server.Business/PlatformSDK/_1688Business.cs | 4 ++--
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/BBWY.1688SDK/serialize/Param2RequestSerializer.cs b/BBWY.1688SDK/serialize/Param2RequestSerializer.cs
index 3e9878bb..29093c7d 100644
--- a/BBWY.1688SDK/serialize/Param2RequestSerializer.cs
+++ b/BBWY.1688SDK/serialize/Param2RequestSerializer.cs
@@ -116,13 +116,18 @@ namespace com.alibaba.openapi.client.serialize
{
var value = property.GetValue(param);
var valueType = value.GetType();
- if (valueType.IsClass)
- {
- result.Add(property.Name, JsonConvert.SerializeObject(value));
- }
+ if (valueType.IsAssignableFrom(typeof(string)) ||
+ valueType.IsAssignableFrom(typeof(bool?)) ||
+ valueType.IsAssignableFrom(typeof(byte?)) ||
+ valueType.IsAssignableFrom(typeof(char?)) ||
+ valueType.IsAssignableFrom(typeof(double?)) ||
+ valueType.IsAssignableFrom(typeof(float?)) ||
+ valueType.IsAssignableFrom(typeof(int?)) ||
+ valueType.IsAssignableFrom(typeof(long?)))
+ result.Add(property.Name, value);
else
{
- result.Add(property.Name, value);
+ result.Add(property.Name, JsonConvert.SerializeObject(value));
}
}
return result;
diff --git a/BBWY.Server.Business/PlatformSDK/_1688Business.cs b/BBWY.Server.Business/PlatformSDK/_1688Business.cs
index 1bca45d4..6601504a 100644
--- a/BBWY.Server.Business/PlatformSDK/_1688Business.cs
+++ b/BBWY.Server.Business/PlatformSDK/_1688Business.cs
@@ -71,7 +71,7 @@ namespace BBWY.Server.Business
{
param.cargoParamList.Add(new CargoParam()
{
- offerId = long.Parse(cargo.SkuId),
+ offerId = long.Parse(cargo.ProductId),
specId = cargo.SpecId,
quantity = cargo.Quantity
});
@@ -82,7 +82,7 @@ namespace BBWY.Server.Business
var result = client.NewRequest(request, reqPolicy);
if (result.Value("success") != true)
{
- throw new BusinessException(result.Value("errorMsg")) { Code = result.Value("errorCode") };
+ throw new BusinessException(result.Value("errorMsg")) { Code = 0 };
}
return new PreviewOrderResponse()
From 034b6159ae466473c63d3a09b3d09f1581695991 Mon Sep 17 00:00:00 2001
From: shanj <18996038927@163.com>
Date: Fri, 4 Mar 2022 01:57:15 +0800
Subject: [PATCH 08/20] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=AE=A2=E5=8D=95?=
=?UTF-8?q?=E9=A2=84=E8=A7=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../APIServices/PurchaseOrderService.cs | 27 +++++++++++++
.../APIModel/Response/Order/OrderResponse.cs | 5 +++
.../OnlinePurchase/PreviewOrderResponse.cs | 20 ++++++++++
.../PurchaseOrderResponse.cs | 0
BBWY.Client/Models/Order/Order.cs | 5 ++-
.../Order/ChoosePurchaseSchemeViewModel.cs | 1 +
.../Purchase/1688PreviewPurchaseViewModel.cs | 40 ++++++++++++++++---
.../Ware/BindingPurchaseProductViewModel.cs | 7 ++--
.../Views/Order/ChoosePurchaseScheme.xaml.cs | 1 +
BBWY.Client/Views/Purchase/1688Purchase.xaml | 5 ++-
BBWY.Server.Business/Order/OrderBusiness.cs | 1 +
.../PlatformSDK/_1688Business.cs | 22 +++++-----
BBWY.Server.Model/Db/Order/Order.cs | 3 ++
.../OnlinePurchase/PreviewOrderReuqest.cs | 2 +-
.../Dto/Response/Order/OrderResponse.cs | 5 +++
15 files changed, 124 insertions(+), 20 deletions(-)
create mode 100644 BBWY.Client/Models/APIModel/Response/PurchaseOrder/OnlinePurchase/PreviewOrderResponse.cs
rename BBWY.Client/Models/APIModel/Response/{ => PurchaseOrder}/PurchaseOrderResponse.cs (100%)
diff --git a/BBWY.Client/APIServices/PurchaseOrderService.cs b/BBWY.Client/APIServices/PurchaseOrderService.cs
index ba7d78e7..949a5b7a 100644
--- a/BBWY.Client/APIServices/PurchaseOrderService.cs
+++ b/BBWY.Client/APIServices/PurchaseOrderService.cs
@@ -2,6 +2,7 @@
using BBWY.Common.Http;
using BBWY.Common.Models;
using System.Collections.Generic;
+using System.Linq;
using System.Net.Http;
namespace BBWY.Client.APIServices
@@ -48,5 +49,31 @@ namespace BBWY.Client.APIServices
null,
HttpMethod.Delete);
}
+
+ ///
+ /// 预览订单
+ ///
+ ///
+ ///
+ ///
+ public ApiResponse PreviewPurchaseOrder(Consignee consignee, IList purchaseSchemeProductSkuList, Platform purchasePlatform, PurchaseAccount purchaseAccount)
+ {
+ return SendRequest(globalContext.BBYWApiHost, "api/purchaseOrder/PreviewPurchaseOrder", new
+ {
+ consignee,
+ CargoParamList = purchaseSchemeProductSkuList.Select(sku => new
+ {
+ ProductId = sku.PurchaseProductId,
+ SkuId = sku.PurchaseSkuId,
+ SpecId = sku.PurchaseSkuSpecId,
+ Quantity = sku.ItemTotal
+ }),
+ Platform = purchasePlatform,
+ AppKey = purchaseAccount.AppKey,
+ AppSecret = purchaseAccount.AppSecret,
+ AppToken = purchaseAccount.AppToken,
+ SaveResponseLog = true
+ }, null, HttpMethod.Post);
+ }
}
}
diff --git a/BBWY.Client/Models/APIModel/Response/Order/OrderResponse.cs b/BBWY.Client/Models/APIModel/Response/Order/OrderResponse.cs
index 446e7072..a285f0d9 100644
--- a/BBWY.Client/Models/APIModel/Response/Order/OrderResponse.cs
+++ b/BBWY.Client/Models/APIModel/Response/Order/OrderResponse.cs
@@ -86,6 +86,11 @@ namespace BBWY.Client.Models
///
public string VenderRemark { get; set; }
+ ///
+ /// 采购备注
+ ///
+ public string PurchaseRemark { get; set; }
+
public StorageType? StorageType { get; set; }
///
diff --git a/BBWY.Client/Models/APIModel/Response/PurchaseOrder/OnlinePurchase/PreviewOrderResponse.cs b/BBWY.Client/Models/APIModel/Response/PurchaseOrder/OnlinePurchase/PreviewOrderResponse.cs
new file mode 100644
index 00000000..cc15aa01
--- /dev/null
+++ b/BBWY.Client/Models/APIModel/Response/PurchaseOrder/OnlinePurchase/PreviewOrderResponse.cs
@@ -0,0 +1,20 @@
+namespace BBWY.Client.Models
+{
+ public class PreviewOrderResponse
+ {
+ ///
+ /// 总额
+ ///
+ public decimal TotalAmount { get; set; }
+
+ ///
+ /// 货款总额
+ ///
+ public decimal ProductAmount { get; set; }
+
+ ///
+ /// 运费
+ ///
+ public decimal FreightAmount { get; set; }
+ }
+}
diff --git a/BBWY.Client/Models/APIModel/Response/PurchaseOrderResponse.cs b/BBWY.Client/Models/APIModel/Response/PurchaseOrder/PurchaseOrderResponse.cs
similarity index 100%
rename from BBWY.Client/Models/APIModel/Response/PurchaseOrderResponse.cs
rename to BBWY.Client/Models/APIModel/Response/PurchaseOrder/PurchaseOrderResponse.cs
diff --git a/BBWY.Client/Models/Order/Order.cs b/BBWY.Client/Models/Order/Order.cs
index 8a289fd0..0c09ee2c 100644
--- a/BBWY.Client/Models/Order/Order.cs
+++ b/BBWY.Client/Models/Order/Order.cs
@@ -93,7 +93,10 @@ namespace BBWY.Client.Models
///
public string VenderRemark { get; set; }
-
+ ///
+ /// 采购备注
+ ///
+ public string PurchaseRemark { get; set; }
///
/// 仓储类型
diff --git a/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs b/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs
index 51463b7f..2c9f2ac2 100644
--- a/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs
+++ b/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs
@@ -114,6 +114,7 @@ namespace BBWY.Client.ViewModels
}
else if (count == 1)
{
+ GalaSoft.MvvmLight.Messaging.Messenger.Default.Send
public string VenderRemark { get; set; }
+ ///
+ /// 采购备注
+ ///
+ public string PurchaseRemark { get; set; }
+
public Enums.StorageType? StorageType { get; set; }
///
From 33d61438941f80697c4e652a371a6e23dd5ad426 Mon Sep 17 00:00:00 2001
From: shanji <18996038927@163.com>
Date: Fri, 4 Mar 2022 15:43:30 +0800
Subject: [PATCH 09/20] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AD=90=E7=B1=BBlogge?=
=?UTF-8?q?r=E4=B8=BA=E7=A9=BA=E7=9A=84bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BBWY.Server.Business/PlatformSDK/JDBusiness.cs | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs
index b0a37fbe..b0d3bfef 100644
--- a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs
+++ b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs
@@ -19,8 +19,6 @@ namespace BBWY.Server.Business
{
public override Enums.Platform Platform => Enums.Platform.京东;
- private ILogger logger;
-
private readonly string searchFields = "orderId,venderId,orderType,payType,orderTotalPrice,orderSellerPrice,orderPayment,freightPrice,orderState,orderStateRemark,orderRemark,orderStartTime,orderEndTime,modified,consigneeInfo,itemInfoList,couponDetailList,taxFee,venderRemark,pin,waybill,storeOrder,storeId,sellerDiscount";
private readonly IDictionary flagDictionary = new Dictionary()
@@ -161,6 +159,7 @@ namespace BBWY.Server.Business
public override IList GetOrderList(SearchPlatformOrderRequest searchOrderRequest)
{
+ //logger.Info($"searchOrderRequest ${JsonConvert.SerializeObject(searchOrderRequest)}");
if (searchOrderRequest.StartDate == null || searchOrderRequest.EndDate == null)
throw new BusinessException("缺少开始/结束日期");
if ((searchOrderRequest.EndDate.Value - searchOrderRequest.StartDate.Value).TotalDays > 30)
@@ -229,6 +228,8 @@ namespace BBWY.Server.Business
//sopReq.dateType = "";
var sopResponse = jdClient.Execute(sopReq, searchOrderRequest.AppToken, DateTime.Now.ToLocalTime());
+
+ //logger.Info($"sopResponse is null ${sopResponse == null}");
if (searchOrderRequest.SaveResponseLog)
logger.Info($"sopResponse\r\n{JsonConvert.SerializeObject(sopResponse)}");
if (sopResponse.IsError)
From f052b3cd360afa73c93e71bf67f8e91be0f42afd Mon Sep 17 00:00:00 2001
From: shanj <18996038927@163.com>
Date: Fri, 4 Mar 2022 22:36:06 +0800
Subject: [PATCH 10/20] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=A2=E5=8D=95?=
=?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BB=BB=E5=8A=A1=E5=AE=9E=E4=BD=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BBWY.Server.Model/Db/Order/OrderSyncTask.cs | 28 +++++++++++++++++++++
BBWY.Server.Model/Enums.cs | 9 +++++++
2 files changed, 37 insertions(+)
create mode 100644 BBWY.Server.Model/Db/Order/OrderSyncTask.cs
diff --git a/BBWY.Server.Model/Db/Order/OrderSyncTask.cs b/BBWY.Server.Model/Db/Order/OrderSyncTask.cs
new file mode 100644
index 00000000..a28786b9
--- /dev/null
+++ b/BBWY.Server.Model/Db/Order/OrderSyncTask.cs
@@ -0,0 +1,28 @@
+using FreeSql.DataAnnotations;
+using System;
+
+namespace BBWY.Server.Model.Db
+{
+
+ [Table(Name = "ordersynctask", DisableSyncStructure = true)]
+ public partial class Ordersynctask
+ {
+
+ [Column(DbType = "bigint(1)", IsPrimary = true)]
+ public long Id { get; set; }
+
+ [Column(DbType = "bigint(1)")]
+ public long ShopId { get; set; }
+
+ [Column(DbType = "int(1)", MapType = typeof(int))]
+ public Enums.OrderSyncState State { get; set; }
+
+ [Column(DbType = "datetime")]
+ public DateTime SyncEndTime { get; set; }
+
+ [Column(DbType = "datetime")]
+ public DateTime SyncStartTime { get; set; }
+
+ }
+
+}
diff --git a/BBWY.Server.Model/Enums.cs b/BBWY.Server.Model/Enums.cs
index 59a0570a..0464934d 100644
--- a/BBWY.Server.Model/Enums.cs
+++ b/BBWY.Server.Model/Enums.cs
@@ -83,5 +83,14 @@
精准打标 = 1,
京礼金 = 2
}
+
+ ///
+ /// 订单同步任务状态
+ ///
+ public enum OrderSyncState
+ {
+ Running = 0,
+ End = 1
+ }
}
}
From 44b20d85d63ea06b07aa8360874b7cc096c4a965 Mon Sep 17 00:00:00 2001
From: shanj <18996038927@163.com>
Date: Sat, 5 Mar 2022 05:45:02 +0800
Subject: [PATCH 11/20] =?UTF-8?q?=E6=8C=87=E5=AE=9A=E6=97=B6=E9=97=B4?=
=?UTF-8?q?=E5=90=8C=E6=AD=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BBWY.Client/APIServices/OrderService.cs | 2 +-
.../Controllers/OrderController.cs | 10 +++
BBWY.Server.Business/Order/OrderBusiness.cs | 78 +++++++++++++++++--
.../PlatformSDK/JDBusiness.cs | 4 +-
.../Statistics/StatisticsBusiness.cs | 4 +-
BBWY.Server.Model/Db/Order/OrderSyncTask.cs | 2 +-
.../Request/Order/SyncOrderByDateRequest.cs | 13 ++++
7 files changed, 102 insertions(+), 11 deletions(-)
create mode 100644 BBWY.Server.Model/Dto/Request/Order/SyncOrderByDateRequest.cs
diff --git a/BBWY.Client/APIServices/OrderService.cs b/BBWY.Client/APIServices/OrderService.cs
index a170b632..b164607f 100644
--- a/BBWY.Client/APIServices/OrderService.cs
+++ b/BBWY.Client/APIServices/OrderService.cs
@@ -33,7 +33,7 @@ namespace BBWY.Client.APIServices
{
orderId,
startDate,
- EndDate = endDate.Date.AddDays(1).AddSeconds(-1),
+ endDate,
orderState,
pageIndex,
pageSize,
diff --git a/BBWY.Server.API/Controllers/OrderController.cs b/BBWY.Server.API/Controllers/OrderController.cs
index f08b50ee..72acd51e 100644
--- a/BBWY.Server.API/Controllers/OrderController.cs
+++ b/BBWY.Server.API/Controllers/OrderController.cs
@@ -88,6 +88,16 @@ namespace BBWY.Server.API.Controllers
orderBusiness.OutStock(outStockRequest);
}
+ ///
+ /// 指定时间范围的订单同步
+ ///
+ ///
+ [HttpPost]
+ public void SyncOrderByDate([FromBody] SyncOrderByDateRequest syncOrderByDateRequest)
+ {
+ orderBusiness.SyncOrderByDate(syncOrderByDateRequest);
+ }
+
///
/// 订单同步
///
diff --git a/BBWY.Server.Business/Order/OrderBusiness.cs b/BBWY.Server.Business/Order/OrderBusiness.cs
index 3793e155..1cd91861 100644
--- a/BBWY.Server.Business/Order/OrderBusiness.cs
+++ b/BBWY.Server.Business/Order/OrderBusiness.cs
@@ -15,6 +15,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
+using System.Threading.Tasks;
using Yitter.IdGenerator;
namespace BBWY.Server.Business
@@ -26,12 +27,14 @@ namespace BBWY.Server.Business
private IDictionary> syncOrderMethodDic;
private IIdGenerator idGenerator;
private IDictionary mdsApiHeader;
+ private TaskSchedulerManager taskSchedulerManager;
- public OrderBusiness(RestApiService restApiService, IConfiguration configuration, ILogger logger, IFreeSql fsql, IIdGenerator idGenerator, IOptions options) : base(restApiService, options)
+ public OrderBusiness(RestApiService restApiService, IConfiguration configuration, ILogger logger, IFreeSql fsql, IIdGenerator idGenerator, IOptions options, TaskSchedulerManager taskSchedulerManager) : base(restApiService, options)
{
this.logger = logger;
this.fsql = fsql;
this.idGenerator = idGenerator;
+ this.taskSchedulerManager = taskSchedulerManager;
syncOrderMethodDic = new Dictionary>()
{
{ Enums.Platform.京东, SyncJDOrder }
@@ -45,6 +48,8 @@ namespace BBWY.Server.Business
{
if (searchOrderRequest.OrderState == Enums.OrderState.已取消)
searchOrderRequest.ExcludeCanceled = false;
+ if (searchOrderRequest.EndDate != null)
+ searchOrderRequest.EndDate = searchOrderRequest.EndDate.Value.Date.AddDays(1).AddSeconds(-1);
var select = fsql.Select().LeftJoin((o, ocs, oct, ods) => o.Id == ocs.OrderId)
.LeftJoin((o, ocs, oct, ods) => o.Id == oct.OrderId)
@@ -651,7 +656,15 @@ namespace BBWY.Server.Business
.ExecuteAffrows();
}
- public void SyncOrder(long shopId, string orderId)
+ ///
+ /// 同步订单
+ ///
+ ///
+ ///
+ /// 默认3小时前
+ /// 默认当前时间
+ ///
+ public void SyncOrder(long shopId, string orderId, DateTime? startTime = null, DateTime? endTime = null)
{
#region 获取店铺信息;
var shopResult = restApiService.SendRequest(globalConfig.MdsApi, "/TaskList/Shop/GetShopsByShopId", $"shopId={shopId}", mdsApiHeader, HttpMethod.Get, enableRandomTimeStamp: true);
@@ -682,8 +695,8 @@ namespace BBWY.Server.Business
var relayAPIHost = GetPlatformRelayAPIHost((Enums.Platform)platformId);
var orderListApiResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetOrderList", new SearchPlatformOrderRequest()
{
- StartDate = DateTime.Now.AddHours(-3),
- EndDate = DateTime.Now,
+ StartDate = startTime ?? DateTime.Now.AddHours(-3),
+ EndDate = endTime ?? DateTime.Now,
AppKey = appKey,
AppSecret = appSecret,
AppToken = appToken,
@@ -713,6 +726,62 @@ namespace BBWY.Server.Business
}
}
+ public void SyncOrderByDate(SyncOrderByDateRequest syncOrderByDateRequest)
+ {
+ if (fsql.Select().Where(ost => ost.ShopId == syncOrderByDateRequest.ShopId && ost.State == Enums.OrderSyncState.Running).Any())
+ throw new BusinessException("存在未结束的同步任务,请稍后同步");
+ syncOrderByDateRequest.EndTime = syncOrderByDateRequest.EndTime.Date.AddDays(1).AddSeconds(-1);
+ if ((syncOrderByDateRequest.EndTime - syncOrderByDateRequest.StartTime).Days > 7)
+ throw new BusinessException("同步任务时差最长7天");
+
+ var orderSyncTask = new OrderSyncTask()
+ {
+ Id = idGenerator.NewLong(),
+ ShopId = syncOrderByDateRequest.ShopId,
+ State = Enums.OrderSyncState.Running,
+ SyncStartTime = syncOrderByDateRequest.StartTime,
+ SyncEndTime = syncOrderByDateRequest.EndTime
+ };
+ fsql.Insert(orderSyncTask).ExecuteAffrows();
+ Task.Factory.StartNew(() =>
+ {
+ var currentStartTime = syncOrderByDateRequest.StartTime;
+ var currentEndTime = currentStartTime.AddHours(3);
+ var keeploop = true;
+ while (keeploop)
+ {
+ try
+ {
+ SyncOrder(syncOrderByDateRequest.ShopId, String.Empty, currentStartTime, currentEndTime);
+ }
+ catch (Exception ex) { }
+ finally
+ {
+ var lessHour = (syncOrderByDateRequest.EndTime - currentEndTime).TotalHours;
+ if (lessHour > 3)
+ {
+ currentStartTime = currentStartTime.AddHours(3);
+ currentEndTime = currentEndTime.AddHours(3);
+ }
+ else if (lessHour > 0 && lessHour < 3)
+ {
+ currentStartTime = currentEndTime;
+ currentEndTime = syncOrderByDateRequest.EndTime;
+ }
+ else if (lessHour <= 0)
+ {
+ keeploop = false;
+ }
+ }
+ }
+ try
+ {
+ fsql.Update(orderSyncTask.Id).Set(ost => ost.State, Enums.OrderSyncState.End).ExecuteAffrows();
+ }
+ catch (Exception ex) { }
+ }, System.Threading.CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.SyncOrderTaskScheduler);
+ }
+
private void SyncJDOrder(JArray orderTokenJArray, long shopId, string relayAPIHost, string appKey, string appSecret, string appToken)
{
var orderTokenList = orderTokenJArray.Where(o => o.Value("orderTotalPrice") != 0);
@@ -738,7 +807,6 @@ namespace BBWY.Server.Business
dbOrderCostDetailList = fsql.Select().Where(ocd => interfaceCanceledOrderIdList.Contains(ocd.OrderId)).ToList();
}
-
var orderSkuIds = new List();
foreach (var orderJToken in orderTokenList)
{
diff --git a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs
index b0d3bfef..56ea584a 100644
--- a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs
+++ b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs
@@ -178,7 +178,7 @@ namespace BBWY.Server.Business
if (searchOrderRequest.StartDate != null)
fbpReq.startDate = searchOrderRequest.StartDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
if (searchOrderRequest.EndDate != null)
- fbpReq.endDate = searchOrderRequest.EndDate.Value.Date.AddDays(1).AddSeconds(-1).ToString("yyyy-MM-dd HH:mm:ss");
+ fbpReq.endDate = searchOrderRequest.EndDate.Value.Date.ToString("yyyy-MM-dd HH:mm:ss");
if (string.IsNullOrEmpty(searchOrderRequest.OrderState))
{
fbpReq.orderState = "DengDaiDaYin,DengDaiChuKu,DengDaiDaBao,DengDaiFaHuo,ZiTiTuZhong,ShangMenTiHuo,ZiTiTuiHuo,DengDaiQueRenShouHuo,PeiSongTuiHuo,HuoDaoFuKuanQueRen,WanCheng,DengDaiFenQiFuKuan,ServiceFinished,SuoDing,DengDaiTuiKuan,DengDaiKeHuHuiFu,TRADE_CANCELED,LOCKED";
@@ -211,7 +211,7 @@ namespace BBWY.Server.Business
if (searchOrderRequest.StartDate != null)
sopReq.startDate = searchOrderRequest.StartDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
if (searchOrderRequest.EndDate != null)
- sopReq.endDate = searchOrderRequest.EndDate.Value.Date.AddDays(1).AddSeconds(-1).ToString("yyyy-MM-dd HH:mm:ss");
+ sopReq.endDate = searchOrderRequest.EndDate.Value.Date.ToString("yyyy-MM-dd HH:mm:ss");
if (string.IsNullOrEmpty(searchOrderRequest.OrderState))
{
//WAIT_SELLER_STOCK_OUT,WAIT_GOODS_RECEIVE_CONFIRM,WAIT_SELLER_DELIVER,PAUSE,FINISHED_L,TRADE_CANCELED,LOCKED
diff --git a/BBWY.Server.Business/Statistics/StatisticsBusiness.cs b/BBWY.Server.Business/Statistics/StatisticsBusiness.cs
index 1e886422..7d379c78 100644
--- a/BBWY.Server.Business/Statistics/StatisticsBusiness.cs
+++ b/BBWY.Server.Business/Statistics/StatisticsBusiness.cs
@@ -19,13 +19,13 @@ namespace BBWY.Server.Business
public OrderAchievementResponse GetOrderAchievementStatistics(OrderAchievementRequest request)
{
- request.EndTime = request.EndTime.Date.AddDays(1);
+ request.EndTime = request.EndTime.Date.AddDays(1).AddSeconds(-1);
var response = fsql.Select().LeftJoin((o, oc) => o.Id == oc.OrderId)
.Where((o, oc) => o.ShopId == request.ShopId &&
o.OrderState != null &&
!invalidOrderStateList.Contains(o.OrderState.Value) &&
o.StartTime >= request.StartTime &&
- o.StartTime < request.EndTime)
+ o.StartTime <= request.EndTime)
.ToAggregate((o, oc) => new OrderAchievementResponse()
{
OrderCount = o.Count(),
diff --git a/BBWY.Server.Model/Db/Order/OrderSyncTask.cs b/BBWY.Server.Model/Db/Order/OrderSyncTask.cs
index a28786b9..e80d36e8 100644
--- a/BBWY.Server.Model/Db/Order/OrderSyncTask.cs
+++ b/BBWY.Server.Model/Db/Order/OrderSyncTask.cs
@@ -5,7 +5,7 @@ namespace BBWY.Server.Model.Db
{
[Table(Name = "ordersynctask", DisableSyncStructure = true)]
- public partial class Ordersynctask
+ public partial class OrderSyncTask
{
[Column(DbType = "bigint(1)", IsPrimary = true)]
diff --git a/BBWY.Server.Model/Dto/Request/Order/SyncOrderByDateRequest.cs b/BBWY.Server.Model/Dto/Request/Order/SyncOrderByDateRequest.cs
new file mode 100644
index 00000000..04a8b3af
--- /dev/null
+++ b/BBWY.Server.Model/Dto/Request/Order/SyncOrderByDateRequest.cs
@@ -0,0 +1,13 @@
+using System;
+
+namespace BBWY.Server.Model.Dto
+{
+ public class SyncOrderByDateRequest
+ {
+ public long ShopId { get; set; }
+
+ public DateTime StartTime { get; set; }
+
+ public DateTime EndTime { get; set; }
+ }
+}
From 2d4ab35dd52c747ca0c68f00f88f4e4a5ec59d58 Mon Sep 17 00:00:00 2001
From: shanj <18996038927@163.com>
Date: Sun, 6 Mar 2022 05:45:38 +0800
Subject: [PATCH 12/20] =?UTF-8?q?=E6=8A=A5=E4=BB=B7=E6=97=B6=E8=8E=B7?=
=?UTF-8?q?=E5=8F=96=E4=BA=A4=E6=98=93=E6=A8=A1=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../OnlinePurchase/OrderTradeTypeResponse.cs | 9 ++++
.../OnlinePurchase/PreviewOrderResponse.cs | 5 +++
.../Purchase/1688PreviewPurchaseViewModel.cs | 4 ++
.../BBWY.Server.Business.csproj | 4 ++
.../PlatformSDK/_1688Business.cs | 42 +++++++++++++++++--
.../OnlinePurchase/OrderTradeTypeResponse.cs | 9 ++++
.../OnlinePurchase/PreviewOrderResponse.cs | 5 +++
7 files changed, 75 insertions(+), 3 deletions(-)
create mode 100644 BBWY.Client/Models/APIModel/Response/PurchaseOrder/OnlinePurchase/OrderTradeTypeResponse.cs
create mode 100644 BBWY.Server.Model/Dto/Response/PurchaseOrder/OnlinePurchase/OrderTradeTypeResponse.cs
diff --git a/BBWY.Client/Models/APIModel/Response/PurchaseOrder/OnlinePurchase/OrderTradeTypeResponse.cs b/BBWY.Client/Models/APIModel/Response/PurchaseOrder/OnlinePurchase/OrderTradeTypeResponse.cs
new file mode 100644
index 00000000..258076d7
--- /dev/null
+++ b/BBWY.Client/Models/APIModel/Response/PurchaseOrder/OnlinePurchase/OrderTradeTypeResponse.cs
@@ -0,0 +1,9 @@
+namespace BBWY.Client.Models
+{
+ public class OrderTradeTypeResponse
+ {
+ public string Code { get; set; }
+
+ public string Name { get; set; }
+ }
+}
diff --git a/BBWY.Client/Models/APIModel/Response/PurchaseOrder/OnlinePurchase/PreviewOrderResponse.cs b/BBWY.Client/Models/APIModel/Response/PurchaseOrder/OnlinePurchase/PreviewOrderResponse.cs
index cc15aa01..845a2611 100644
--- a/BBWY.Client/Models/APIModel/Response/PurchaseOrder/OnlinePurchase/PreviewOrderResponse.cs
+++ b/BBWY.Client/Models/APIModel/Response/PurchaseOrder/OnlinePurchase/PreviewOrderResponse.cs
@@ -16,5 +16,10 @@
/// 运费
///
public decimal FreightAmount { get; set; }
+
+ ///
+ /// 交易方式
+ ///
+ public OrderTradeTypeResponse OrderTradeType { get; set; }
}
}
diff --git a/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs b/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs
index 5b5d486b..44845f06 100644
--- a/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs
+++ b/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs
@@ -51,6 +51,8 @@ namespace BBWY.Client.ViewModels
private string town;
private string prucahseRemark;
+ private string tradeMode;
+
public _1688PreviewPurchaseViewModel(OneBoundAPIService oneBoundAPIService, PurchaseOrderService purchaseOrderService)
{
this.oneBoundAPIService = oneBoundAPIService;
@@ -209,12 +211,14 @@ namespace BBWY.Client.ViewModels
if (!r.Success)
{
ProductAmount = FreightAmount = TotalAmount = 0;
+ tradeMode = string.Empty;
App.Current.Dispatcher.Invoke(() => MessageBox.Show(r.Msg, "预览订单报价"));
return;
}
ProductAmount = r.Data.ProductAmount;
FreightAmount = r.Data.FreightAmount;
TotalAmount = r.Data.TotalAmount;
+ tradeMode = r.Data.OrderTradeType?.Code;
});
}
}
diff --git a/BBWY.Server.Business/BBWY.Server.Business.csproj b/BBWY.Server.Business/BBWY.Server.Business.csproj
index c9937f02..9c1f3f0e 100644
--- a/BBWY.Server.Business/BBWY.Server.Business.csproj
+++ b/BBWY.Server.Business/BBWY.Server.Business.csproj
@@ -21,4 +21,8 @@
+
+
+
+
diff --git a/BBWY.Server.Business/PlatformSDK/_1688Business.cs b/BBWY.Server.Business/PlatformSDK/_1688Business.cs
index 642009d2..3e049cb5 100644
--- a/BBWY.Server.Business/PlatformSDK/_1688Business.cs
+++ b/BBWY.Server.Business/PlatformSDK/_1688Business.cs
@@ -17,10 +17,12 @@ namespace BBWY.Server.Business
{
public override Enums.Platform Platform => Enums.Platform.阿里巴巴;
private RestApiService restApiService;
+ private _1688TradeTypeCompare _1688TradeTypeCompare;
public _1688Business(IMemoryCache memoryCache, ILogger logger, RestApiService restApiService) : base(memoryCache, logger)
{
this.restApiService = restApiService;
+ _1688TradeTypeCompare = new _1688TradeTypeCompare();
}
private SyncAPIClient GetSyncAPIClient(string appKey, string appSecret)
@@ -82,17 +84,51 @@ namespace BBWY.Server.Business
request.AccessToken = previewOrderReuqest.AppToken;
var result = client.NewRequest(request, reqPolicy);
if (result.Value("success") != true)
- {
throw new BusinessException(result.Value("errorMsg")) { Code = 0 };
- }
var orderPreviewResuslt = (JArray)result["orderPreviewResuslt"];
+ List intersectTradeModeList = new List();
+
+ foreach (var orderPreviewJToken in orderPreviewResuslt)
+ {
+ if (orderPreviewJToken["tradeModelList"] == null)
+ throw new BusinessException("当前交易不可通过API下单,请使用1688网页交易 [交易模式列表为空]");
+ var tradeModeJArray = ((JArray)orderPreviewJToken["tradeModelList"]).Where(tradeJToken => tradeJToken.Value("opSupport"));
+ if (tradeModeJArray.Count() == 0)
+ throw new BusinessException("当前交易不可通过API下单,请使用1688网页交易 [没有支持开放平台下单的交易模式]");
+
+ if (intersectTradeModeList.Count() == 0)
+ intersectTradeModeList.AddRange(tradeModeJArray);
+ else
+ intersectTradeModeList = intersectTradeModeList.Intersect(tradeModeJArray, _1688TradeTypeCompare).ToList();
+ }
+
+ if (intersectTradeModeList.Count() == 0)
+ throw new BusinessException("当前交易不可通过API下单,请使用1688网页交易 [多个拆单之间没有相同的交易模式]");
return new PreviewOrderResponse()
{
FreightAmount = orderPreviewResuslt.Sum(jt => jt.Value("sumCarriage")) / 100M,
ProductAmount = orderPreviewResuslt.Sum(jt => jt.Value("sumPaymentNoCarriage")) / 100M,
- TotalAmount = orderPreviewResuslt.Sum(jt => jt.Value("sumPayment")) / 100M
+ TotalAmount = orderPreviewResuslt.Sum(jt => jt.Value("sumPayment")) / 100M,
+ OrderTradeType = new OrderTradeTypeResponse()
+ {
+ Code = intersectTradeModeList.First().Value("tradeType"),
+ Name = intersectTradeModeList.First().Value("name"),
+ }
};
}
}
+
+ public class _1688TradeTypeCompare : IEqualityComparer
+ {
+ public bool Equals(JToken x, JToken y)
+ {
+ return x.Value("tradeType").Equals(y.Value("tradeType"));
+ }
+
+ public int GetHashCode(JToken obj)
+ {
+ return obj.GetHashCode();
+ }
+ }
}
diff --git a/BBWY.Server.Model/Dto/Response/PurchaseOrder/OnlinePurchase/OrderTradeTypeResponse.cs b/BBWY.Server.Model/Dto/Response/PurchaseOrder/OnlinePurchase/OrderTradeTypeResponse.cs
new file mode 100644
index 00000000..1ad9b62b
--- /dev/null
+++ b/BBWY.Server.Model/Dto/Response/PurchaseOrder/OnlinePurchase/OrderTradeTypeResponse.cs
@@ -0,0 +1,9 @@
+namespace BBWY.Server.Model.Dto
+{
+ public class OrderTradeTypeResponse
+ {
+ public string Code { get; set; }
+
+ public string Name { get; set; }
+ }
+}
diff --git a/BBWY.Server.Model/Dto/Response/PurchaseOrder/OnlinePurchase/PreviewOrderResponse.cs b/BBWY.Server.Model/Dto/Response/PurchaseOrder/OnlinePurchase/PreviewOrderResponse.cs
index 5fff9c2a..e69eeead 100644
--- a/BBWY.Server.Model/Dto/Response/PurchaseOrder/OnlinePurchase/PreviewOrderResponse.cs
+++ b/BBWY.Server.Model/Dto/Response/PurchaseOrder/OnlinePurchase/PreviewOrderResponse.cs
@@ -16,5 +16,10 @@
/// 运费
///
public decimal FreightAmount { get; set; }
+
+ ///
+ /// 支持的交易方式
+ ///
+ public OrderTradeTypeResponse OrderTradeType { get; set; }
}
}
From 16cb3a15a30c088de9b25eacff78bd34146ebbd2 Mon Sep 17 00:00:00 2001
From: shanj <18996038927@163.com>
Date: Mon, 7 Mar 2022 05:12:59 +0800
Subject: [PATCH 13/20] =?UTF-8?q?=E5=AF=B9=E6=8E=A51688=E9=87=87=E8=B4=AD?=
=?UTF-8?q?=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../PlatformSDK/PlatformSDKBusiness.cs | 6 +++
.../PlatformSDK/_1688Business.cs | 53 +++++++++++++++++++
.../CreateOnlinePurchaseOrderRequest.cs | 15 ++++++
3 files changed, 74 insertions(+)
create mode 100644 BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs
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; }
+ }
+}
From a522b6d9cc73eec3625e7b355d68228639704536 Mon Sep 17 00:00:00 2001
From: shanj <18996038927@163.com>
Date: Mon, 7 Mar 2022 12:55:31 +0800
Subject: [PATCH 14/20] =?UTF-8?q?sku=E5=A4=8D=E5=88=B6=E6=8D=95=E6=8D=89?=
=?UTF-8?q?=E5=BC=82=E5=B8=B8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ViewModels/Order/OrderListViewModel.cs | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs
index 68fdec64..208454ed 100644
--- a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs
+++ b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs
@@ -110,7 +110,20 @@ namespace BBWY.Client.ViewModels
Task.Factory.StartNew(() => LoadOrder(1));
Task.Factory.StartNew(() => LoadTodayAchievement(StartDate, EndDate));
});
- CopyTextCommand = new RelayCommand(s => Clipboard.SetText(s));
+ CopyTextCommand = new RelayCommand(s =>
+ {
+ try
+ {
+ Clipboard.SetText(s);
+ }
+ catch (Exception ex)
+ {
+ Console.ForegroundColor = ConsoleColor.Red;
+ Console.WriteLine(ex);
+ Console.ResetColor();
+ }
+ }
+ );
CopyOrderWaybillCommand = new RelayCommand(o => Clipboard.SetText(o.WaybillNo));
SetSearchDateCommand = new RelayCommand(d =>
{
From 142f993f1d88b6052b4a3945d724ffb2b88c479c Mon Sep 17 00:00:00 2001
From: shanj <18996038927@163.com>
Date: Tue, 8 Mar 2022 05:27:58 +0800
Subject: [PATCH 15/20] =?UTF-8?q?=E5=AF=B9=E6=8E=A51688=E4=B8=8B=E5=8D=95?=
=?UTF-8?q?=20=E6=9C=AA=E5=AE=8C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/PurchaseOrderController.cs | 10 +++++++
.../PlatformSDK/PlatformSDKBusiness.cs | 2 +-
.../PlatformSDK/_1688Business.cs | 29 ++++++++++++++++--
.../PurchaseOrder/PurchaseOrderBusiness.cs | 12 ++++++--
.../CreateOnlinePurchaseOrderRequest.cs | 10 +++++++
.../CreateOnlinePurchaseOrderResponse.cs | 30 +++++++++++++++++++
6 files changed, 88 insertions(+), 5 deletions(-)
create mode 100644 BBWY.Server.Model/Dto/Response/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderResponse.cs
diff --git a/BBWY.Server.API/Controllers/PurchaseOrderController.cs b/BBWY.Server.API/Controllers/PurchaseOrderController.cs
index 2d96451e..9c5f9f3d 100644
--- a/BBWY.Server.API/Controllers/PurchaseOrderController.cs
+++ b/BBWY.Server.API/Controllers/PurchaseOrderController.cs
@@ -52,5 +52,15 @@ namespace BBWY.Server.API.Controllers
{
return purchaseOrderBusiness.PreviewPurchaseOrder(previewOrderReuqest);
}
+
+ ///
+ /// 创建在线采购单
+ ///
+ ///
+ [HttpPost]
+ public void FastCreateOrder(CreateOnlinePurchaseOrderRequest createOnlinePurchaseOrderRequest)
+ {
+ purchaseOrderBusiness.FastCreateOrder(createOnlinePurchaseOrderRequest);
+ }
}
}
diff --git a/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs b/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs
index 531e96ef..c883ec10 100644
--- a/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs
+++ b/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs
@@ -78,7 +78,7 @@ namespace BBWY.Server.Business
throw new NotImplementedException();
}
- public virtual void FastCreateOrder(CreateOnlinePurchaseOrderRequest createOnlinePurchaseOrderRequest)
+ public virtual CreateOnlinePurchaseOrderResponse FastCreateOrder(CreateOnlinePurchaseOrderRequest createOnlinePurchaseOrderRequest)
{
throw new NotImplementedException();
}
diff --git a/BBWY.Server.Business/PlatformSDK/_1688Business.cs b/BBWY.Server.Business/PlatformSDK/_1688Business.cs
index 4bc13f83..3aab9b76 100644
--- a/BBWY.Server.Business/PlatformSDK/_1688Business.cs
+++ b/BBWY.Server.Business/PlatformSDK/_1688Business.cs
@@ -2,14 +2,18 @@
using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Server.Model;
+using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using com.alibaba.openapi.client;
using com.alibaba.openapi.client.policy;
using Microsoft.Extensions.Caching.Memory;
+using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;
+using System;
using System.Collections.Generic;
using System.Linq;
+using System.Text;
namespace BBWY.Server.Business
{
@@ -118,7 +122,7 @@ namespace BBWY.Server.Business
};
}
- public override void FastCreateOrder(CreateOnlinePurchaseOrderRequest createOnlinePurchaseOrderRequest)
+ public override CreateOnlinePurchaseOrderResponse FastCreateOrder(CreateOnlinePurchaseOrderRequest createOnlinePurchaseOrderRequest)
{
var client = GetSyncAPIClient(createOnlinePurchaseOrderRequest.AppKey, createOnlinePurchaseOrderRequest.AppSecret);
RequestPolicy reqPolicy = new RequestPolicy();
@@ -167,8 +171,29 @@ namespace BBWY.Server.Business
if (result.Value("success") != true)
throw new BusinessException(result.Value("errorMsg")) { Code = 0 };
- var totalSuccessAmount = result["result"].Value("totalSuccessAmount") / 100M; //采购总金额
+ var totalSuccessAmount = result["result"].Value("totalSuccessAmount") / 100M; //采购单总金额,单位分
+ var purchaseOrderId = result["result"].Value("orderId"); //采购单号
+ var postFee = result["result"].Value("postFee") / 100M; //采购单运费,单位分
+ var purchaseAmount = totalSuccessAmount - postFee; //采购成本
+ var failedOfferJArray = result["failedOfferList"] != null ? (JArray)result["failedOfferList"] : null;
+ if (failedOfferJArray != null)
+ {
+ StringBuilder failOrderStringBuilder = new StringBuilder();
+ foreach (var failedOfferJToken in failedOfferJArray)
+ failOrderStringBuilder.AppendLine(failedOfferJToken.ToString());
+ var ex = new Exception(failOrderStringBuilder.ToString());
+ logger.Error(ex, $"下单部分商品失败 采购单Id{purchaseOrderId} 请求参数{JsonConvert.SerializeObject(createOnlinePurchaseOrderRequest)}");
+ }
+
+ return new CreateOnlinePurchaseOrderResponse()
+ {
+ TotalAmount = totalSuccessAmount,
+ ProductAmount = purchaseAmount,
+ FreightAmount = postFee,
+ PurchaseOrderId = purchaseOrderId,
+ FailProductMessageList = failedOfferJArray == null ? null : failedOfferJArray.Select(failedOfferJToken => failedOfferJToken.ToString()).ToList()
+ };
}
}
diff --git a/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs b/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs
index 90f458a9..b74a6378 100644
--- a/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs
+++ b/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs
@@ -66,10 +66,18 @@ namespace BBWY.Server.Business
public PreviewOrderResponse PreviewPurchaseOrder(PreviewOrderReuqest previewOrderReuqest)
{
if (previewOrderReuqest.Platform != Model.Enums.Platform.阿里巴巴)
- {
throw new NotImplementedException();
- }
return platformSDKBusinessList.FirstOrDefault(p => p.Platform == previewOrderReuqest.Platform).PreviewOrder(previewOrderReuqest);
}
+
+ public void FastCreateOrder(CreateOnlinePurchaseOrderRequest createOnlinePurchaseOrderRequest)
+ {
+ if (createOnlinePurchaseOrderRequest.Platform != Model.Enums.Platform.阿里巴巴)
+ throw new NotImplementedException();
+ var createOrderResponse = platformSDKBusinessList.FirstOrDefault(p => p.Platform == createOnlinePurchaseOrderRequest.Platform)
+ .FastCreateOrder(createOnlinePurchaseOrderRequest);
+
+
+ }
}
}
diff --git a/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs b/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs
index 8d8730af..5f7fd53e 100644
--- a/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs
+++ b/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs
@@ -11,5 +11,15 @@
/// 采购单留言
///
public string Remark { get; set; }
+
+ ///
+ /// 店铺订单Id
+ ///
+ public string OrderId { get; set; }
+
+ ///
+ /// 店铺Id
+ ///
+ public long ShopId { get; set; }
}
}
diff --git a/BBWY.Server.Model/Dto/Response/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderResponse.cs b/BBWY.Server.Model/Dto/Response/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderResponse.cs
new file mode 100644
index 00000000..3517a7a7
--- /dev/null
+++ b/BBWY.Server.Model/Dto/Response/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderResponse.cs
@@ -0,0 +1,30 @@
+using System.Collections.Generic;
+
+namespace BBWY.Server.Model.Dto
+{
+ public class CreateOnlinePurchaseOrderResponse
+ {
+
+ public string PurchaseOrderId { get; set; }
+
+ ///
+ /// 订单总额
+ ///
+ public decimal TotalAmount { get; set; }
+
+ ///
+ /// 货款总额
+ ///
+ public decimal ProductAmount { get; set; }
+
+ ///
+ /// 运费总额
+ ///
+ public decimal FreightAmount { get; set; }
+
+ ///
+ /// 下单失败的商品信息
+ ///
+ public IList FailProductMessageList { get; set; }
+ }
+}
From 808f7700708df8e6f7785fd3a03883f0cb9b2ed6 Mon Sep 17 00:00:00 2001
From: shanji <18996038927@163.com>
Date: Tue, 8 Mar 2022 14:29:22 +0800
Subject: [PATCH 16/20] =?UTF-8?q?=E5=AE=9E=E6=94=B6=E6=94=B9=E6=88=90?=
=?UTF-8?q?=E5=AE=9E=E4=BB=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BBWY.Client/ViewModels/Order/OrderListViewModel.cs | 14 +++++++-------
BBWY.Client/Views/Order/OrderList.xaml | 2 +-
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs
index 208454ed..6e692a76 100644
--- a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs
+++ b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs
@@ -101,13 +101,13 @@ namespace BBWY.Client.ViewModels
this.choosePurchaseSchemeViewModel = choosePurchaseSchemeViewModel;
OrderList = new ObservableCollection();
EndDate = DateTime.Now;
- StartDate = DateTime.Now.Date.AddDays(-29);
+ StartDate = DateTime.Now.Date.AddDays(-6);
ToDayOrderAchievement = new ToDayOrderAchievement();
SetOrderStateCommand = new RelayCommand(SetOrderState);
SearchOrderCommand = new RelayCommand(() =>
{
PageIndex = 1;
- Task.Factory.StartNew(() => LoadOrder(1));
+ Task.Factory.StartNew(() => LoadOrder(1)); //手动点击查询订单
Task.Factory.StartNew(() => LoadTodayAchievement(StartDate, EndDate));
});
CopyTextCommand = new RelayCommand(s =>
@@ -130,7 +130,7 @@ namespace BBWY.Client.ViewModels
EndDate = d == 1 ? DateTime.Now.Date.AddDays(-1) : DateTime.Now;
StartDate = DateTime.Now.Date.AddDays(d * -1);
PageIndex = 1;
- Task.Factory.StartNew(() => LoadOrder(1));
+ Task.Factory.StartNew(() => LoadOrder(1)); //点击日期查询订单
Task.Factory.StartNew(() => LoadTodayAchievement(StartDate, EndDate));
});
OrderPageIndexChangedCommand = new RelayCommand(p =>
@@ -154,9 +154,9 @@ namespace BBWY.Client.ViewModels
SearchSku = String.Empty;
SearchWaybill = String.Empty;
EndDate = DateTime.Now;
- StartDate = DateTime.Now.Date.AddDays(-29);
+ StartDate = DateTime.Now.Date.AddDays(-6);
PageIndex = 1;
- Task.Factory.StartNew(() => LoadOrder(1));
+ Task.Factory.StartNew(() => LoadOrder(1)); //选择状态查询订单
}
private void LoadOrder(int pageIndex)
@@ -295,7 +295,7 @@ namespace BBWY.Client.ViewModels
App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "关联采购订单"));
return;
}
- LoadOrder(PageIndex); //手动计算成功刷新订单列表
+ LoadOrder(PageIndex); //关联订单刷新订单列表
});
}
@@ -329,7 +329,7 @@ namespace BBWY.Client.ViewModels
App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "设置刷单成本"));
return;
}
- LoadOrder(PageIndex); //手动计算成功刷新订单列表
+ LoadOrder(PageIndex); //设置刷单刷新订单列表
});
}
diff --git a/BBWY.Client/Views/Order/OrderList.xaml b/BBWY.Client/Views/Order/OrderList.xaml
index bf1028aa..453d82aa 100644
--- a/BBWY.Client/Views/Order/OrderList.xaml
+++ b/BBWY.Client/Views/Order/OrderList.xaml
@@ -476,7 +476,7 @@
-
+
From c5975fbeabb9e6d21e5ac62074088cb0ba09c56b Mon Sep 17 00:00:00 2001
From: shanji <18996038927@163.com>
Date: Tue, 8 Mar 2022 18:57:52 +0800
Subject: [PATCH 17/20] =?UTF-8?q?=E5=AE=8C=E5=96=84=E9=87=87=E8=B4=AD?=
=?UTF-8?q?=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/PurchaseOrderController.cs | 2 +-
.../BBWY.Server.Business.csproj | 10 +-
.../PurchaseOrder/PurchaseOrderBusiness.cs | 108 ++++++++++++++++++
.../Db/Order/OrderDropShipping.cs | 6 +-
.../Db/PurchaseOrder/PurchaseOrder.cs | 3 +
.../CreateOnlinePurchaseOrderRequest.cs | 7 ++
6 files changed, 128 insertions(+), 8 deletions(-)
diff --git a/BBWY.Server.API/Controllers/PurchaseOrderController.cs b/BBWY.Server.API/Controllers/PurchaseOrderController.cs
index 9c5f9f3d..c16f3d42 100644
--- a/BBWY.Server.API/Controllers/PurchaseOrderController.cs
+++ b/BBWY.Server.API/Controllers/PurchaseOrderController.cs
@@ -58,7 +58,7 @@ namespace BBWY.Server.API.Controllers
///
///
[HttpPost]
- public void FastCreateOrder(CreateOnlinePurchaseOrderRequest createOnlinePurchaseOrderRequest)
+ public void FastCreateOrder([FromBody]CreateOnlinePurchaseOrderRequest createOnlinePurchaseOrderRequest)
{
purchaseOrderBusiness.FastCreateOrder(createOnlinePurchaseOrderRequest);
}
diff --git a/BBWY.Server.Business/BBWY.Server.Business.csproj b/BBWY.Server.Business/BBWY.Server.Business.csproj
index 9c1f3f0e..58ecf8d7 100644
--- a/BBWY.Server.Business/BBWY.Server.Business.csproj
+++ b/BBWY.Server.Business/BBWY.Server.Business.csproj
@@ -5,6 +5,12 @@
True
+
+
+
+
+
+
@@ -21,8 +27,4 @@
-
-
-
-
diff --git a/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs b/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs
index b74a6378..c717fe86 100644
--- a/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs
+++ b/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs
@@ -2,6 +2,7 @@
using BBWY.Common.Models;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
+using FreeSql;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -74,10 +75,117 @@ namespace BBWY.Server.Business
{
if (createOnlinePurchaseOrderRequest.Platform != Model.Enums.Platform.阿里巴巴)
throw new NotImplementedException();
+ var dbOrder = fsql.Select(createOnlinePurchaseOrderRequest.OrderId).ToOne();
+ if (dbOrder == null)
+ throw new BusinessException("订单不存在");
+ if (dbOrder.OrderState != Model.Enums.OrderState.等待采购)
+ throw new BusinessException("只能为等待采购的订单进行采购");
+ var orderSku = fsql.Select().Where(osku => osku.OrderId == createOnlinePurchaseOrderRequest.OrderId).ToOne();
+ if (orderSku == null)
+ throw new BusinessException("订单Sku不存在");
+
var createOrderResponse = platformSDKBusinessList.FirstOrDefault(p => p.Platform == createOnlinePurchaseOrderRequest.Platform)
.FastCreateOrder(createOnlinePurchaseOrderRequest);
+ IInsert insertPurchaseOrder = null;
+ IInsert insertOrderCostDetail = null;
+ IInsert insertOrderCost = null;
+ IInsert insertOrderDropShipping = null;
+
+ #region 采购单
+ var purchaseOrder = new PurchaseOrder()
+ {
+ Id = idGenerator.NewLong(),
+ CreateTime = DateTime.Now,
+ ProductId = orderSku.ProductId,
+ SkuId = orderSku.SkuId,
+ PurchaseMethod = Model.Enums.PurchaseMethod.线上采购,
+ PurchaseOrderId = createOrderResponse.PurchaseOrderId,
+ PurchasePlatform = createOnlinePurchaseOrderRequest.Platform,
+ PurchaseQuantity = orderSku.ItemTotal.Value,
+ RemainingQuantity = 0,
+ ShopId = createOnlinePurchaseOrderRequest.ShopId,
+ SingleConsumableAmount = 0,
+ SingleDeliveryFreight = 0,
+ SingleFirstFreight = 0,
+ SingleStorageAmount = 0,
+ SingleOperationAmount = 0,
+ SingleSkuAmount = createOrderResponse.ProductAmount / orderSku.ItemTotal.Value,
+ SingleFreight = createOrderResponse.FreightAmount / orderSku.ItemTotal.Value,
+ StorageType = Model.Enums.StorageType.代发
+ };
+ insertPurchaseOrder = fsql.Insert(purchaseOrder);
+ #endregion
+
+ #region 成本明细
+ var orderCostDetail = new OrderCostDetail()
+ {
+ Id = idGenerator.NewLong(),
+ ConsumableAmount = 0,
+ CreateTime = DateTime.Now,
+ DeductionQuantity = orderSku.ItemTotal.Value,
+ DeliveryExpressFreight = 0,
+ FirstFreight = 0,
+ OperationAmount = 0,
+ OrderId = createOnlinePurchaseOrderRequest.OrderId,
+ ProductId = orderSku.ProductId,
+ PurchaseFreight = createOrderResponse.FreightAmount,
+ PurchaseOrderPKId = purchaseOrder.Id,
+ SkuAmount = createOrderResponse.ProductAmount,
+ SkuId = orderSku.SkuId,
+ StorageAmount = 0,
+ UnitCost = purchaseOrder.UnitCost,
+ TotalCost = createOrderResponse.TotalAmount //purchaseOrder.UnitCost * orderSku.ItemTotal.Value
+ };
+ insertOrderCostDetail = fsql.Insert(orderCostDetail);
+ #endregion
+
+ #region 订单成本
+ var orderCost = new OrderCost()
+ {
+ OrderId = orderSku.OrderId,
+ CreateTime = DateTime.Now,
+ DeliveryExpressFreight = 0,
+ IsManualEdited = false,
+ PlatformCommissionRatio = 0.05M,
+ PreferentialAmount = dbOrder.PreferentialAmount,
+ SDCommissionAmount = 0,
+ PurchaseAmount = createOrderResponse.TotalAmount
+ };
+ orderCost.PlatformCommissionAmount = dbOrder.OrderSellerPrice * orderCost.PlatformCommissionRatio;
+ orderCost.Profit = dbOrder.OrderSellerPrice +
+ dbOrder.FreightPrice -
+ orderCost.PurchaseAmount -
+ orderCost.DeliveryExpressFreight -
+ orderCost.PlatformCommissionAmount;
+ insertOrderCost = fsql.Insert(orderCost);
+ #endregion
+
+ #region 采购信息
+ var orderDropShipping = new OrderDropShipping()
+ {
+ OrderId = createOnlinePurchaseOrderRequest.OrderId,
+ BuyerAccount = createOnlinePurchaseOrderRequest.BuyerAccount,
+ SellerAccount = createOnlinePurchaseOrderRequest.SellerAccount,
+ CreateTime = DateTime.Now,
+ DeliveryFreight = 0,
+ PurchaseAmount = createOrderResponse.TotalAmount,
+ PurchaseOrderId = createOrderResponse.PurchaseOrderId,
+ PurchasePlatform = createOnlinePurchaseOrderRequest.Platform
+ };
+ insertOrderDropShipping = fsql.Insert(orderDropShipping);
+ #endregion
+ fsql.Transaction(() =>
+ {
+ insertPurchaseOrder.ExecuteAffrows();
+ insertOrderCostDetail.ExecuteAffrows();
+ insertOrderCost.ExecuteAffrows();
+ insertOrderDropShipping.ExecuteAffrows();
+ fsql.Update(createOnlinePurchaseOrderRequest.OrderId).Set(o => o.OrderState, Model.Enums.OrderState.待出库)
+ .Set(o => o.StorageType, Model.Enums.StorageType.代发)
+ .ExecuteAffrows();
+ });
}
}
}
diff --git a/BBWY.Server.Model/Db/Order/OrderDropShipping.cs b/BBWY.Server.Model/Db/Order/OrderDropShipping.cs
index f7651ae1..557ec12f 100644
--- a/BBWY.Server.Model/Db/Order/OrderDropShipping.cs
+++ b/BBWY.Server.Model/Db/Order/OrderDropShipping.cs
@@ -17,7 +17,7 @@ namespace BBWY.Server.Model.Db
///
/// 买家账号
///
- [Column(StringLength = 50)]
+ [Column(StringLength = 200)]
public string BuyerAccount { get; set; }
[Column(DbType = "datetime")]
@@ -38,7 +38,7 @@ namespace BBWY.Server.Model.Db
///
/// 采购单号
///
- [Column(StringLength = 50)]
+ [Column(StringLength = 200)]
public string PurchaseOrderId { get; set; }
///
@@ -50,7 +50,7 @@ namespace BBWY.Server.Model.Db
///
/// 卖家账号
///
- [Column(StringLength = 50)]
+ [Column(StringLength = 200)]
public string SellerAccount { get; set; }
}
diff --git a/BBWY.Server.Model/Db/PurchaseOrder/PurchaseOrder.cs b/BBWY.Server.Model/Db/PurchaseOrder/PurchaseOrder.cs
index fd730ea0..9352327f 100644
--- a/BBWY.Server.Model/Db/PurchaseOrder/PurchaseOrder.cs
+++ b/BBWY.Server.Model/Db/PurchaseOrder/PurchaseOrder.cs
@@ -29,6 +29,9 @@ namespace BBWY.Server.Model.Db
//[Column(DbType = "decimal(20,2)")]
//public decimal Freight { get; set; } = 0.00M;
+ ///
+ /// 产品Id
+ ///
[Column(StringLength = 50)]
public string ProductId { get; set; }
diff --git a/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs b/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs
index 5f7fd53e..a73ba736 100644
--- a/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs
+++ b/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs
@@ -21,5 +21,12 @@
/// 店铺Id
///
public long ShopId { get; set; }
+
+ ///
+ /// 买家账号
+ ///
+ public string BuyerAccount { get; set; }
+
+ public string SellerAccount { get; set; }
}
}
From 28887d8c48fd81c07221173cf817fbd9937ee464 Mon Sep 17 00:00:00 2001
From: shanji <18996038927@163.com>
Date: Wed, 9 Mar 2022 04:17:47 +0800
Subject: [PATCH 18/20] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E9=87=87=E8=B4=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../APIServices/PurchaseOrderService.cs | 49 +++++++++++++++
.../ViewModels/Order/OrderListViewModel.cs | 5 ++
.../Purchase/1688PreviewPurchaseViewModel.cs | 61 ++++++++++++++++++-
.../Views/Order/ChoosePurchaseScheme.xaml.cs | 14 ++++-
BBWY.Client/Views/Purchase/1688Purchase.xaml | 3 +-
.../Views/Purchase/1688Purchase.xaml.cs | 13 ++++
6 files changed, 142 insertions(+), 3 deletions(-)
diff --git a/BBWY.Client/APIServices/PurchaseOrderService.cs b/BBWY.Client/APIServices/PurchaseOrderService.cs
index 949a5b7a..e47fd4ab 100644
--- a/BBWY.Client/APIServices/PurchaseOrderService.cs
+++ b/BBWY.Client/APIServices/PurchaseOrderService.cs
@@ -75,5 +75,54 @@ namespace BBWY.Client.APIServices
SaveResponseLog = true
}, null, HttpMethod.Post);
}
+
+ ///
+ /// 创建采购单
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public ApiResponse FastCreateOrder(Consignee consignee,
+ IList purchaseSchemeProductSkuList,
+ Platform purchasePlatform,
+ PurchaseAccount purchaseAccount,
+ string tradeMode,
+ string remark,
+ string orderId,
+ long shopId,
+ string buyerAccount,
+ string sellerAccount)
+ {
+ return SendRequest(globalContext.BBYWApiHost, "api/purchaseOrder/FastCreateOrder", new
+ {
+ consignee,
+ CargoParamList = purchaseSchemeProductSkuList.Select(sku => new
+ {
+ ProductId = sku.PurchaseProductId,
+ SkuId = sku.PurchaseSkuId,
+ SpecId = sku.PurchaseSkuSpecId,
+ Quantity = sku.ItemTotal
+ }),
+ Platform = purchasePlatform,
+ AppKey = purchaseAccount.AppKey,
+ AppSecret = purchaseAccount.AppSecret,
+ AppToken = purchaseAccount.AppToken,
+ SaveResponseLog = true,
+ tradeMode,
+ remark,
+ orderId,
+ shopId,
+ buyerAccount,
+ sellerAccount
+ }, null, HttpMethod.Post);
+ }
}
}
diff --git a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs
index 6e692a76..9075f60f 100644
--- a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs
+++ b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs
@@ -159,6 +159,11 @@ namespace BBWY.Client.ViewModels
Task.Factory.StartNew(() => LoadOrder(1)); //选择状态查询订单
}
+ public void RefreshOrder()
+ {
+ Task.Factory.StartNew(() => LoadOrder(PageIndex));
+ }
+
private void LoadOrder(int pageIndex)
{
IsLoading = true;
diff --git a/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs b/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs
index 44845f06..694f5fcd 100644
--- a/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs
+++ b/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs
@@ -1,6 +1,7 @@
using BBWY.Client.APIServices;
using BBWY.Client.Models;
using BBWY.Common.Trigger;
+using GalaSoft.MvvmLight.Command;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
@@ -9,11 +10,14 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
+using System.Windows.Input;
namespace BBWY.Client.ViewModels
{
public class _1688PreviewPurchaseViewModel : BaseVM
{
+ public ICommand FastCreateOrderCommand { get; set; }
+
public IList PurchaseSchemeProductSkuList { get; set; }
public PurchaseScheme PurchaseScheme { get; set; }
@@ -32,6 +36,8 @@ namespace BBWY.Client.ViewModels
public string Town { get => town; set { Set(ref town, value); } }
public string PrucahseRemark { get => prucahseRemark; set { Set(ref prucahseRemark, value); } }
+ private OrderListViewModel orderListViewModel;
+ private GlobalContext globalContext;
private string orderId;
private int skuItemCount;
private bool isLoading;
@@ -53,13 +59,16 @@ namespace BBWY.Client.ViewModels
private string tradeMode;
- public _1688PreviewPurchaseViewModel(OneBoundAPIService oneBoundAPIService, PurchaseOrderService purchaseOrderService)
+ public _1688PreviewPurchaseViewModel(OneBoundAPIService oneBoundAPIService, PurchaseOrderService purchaseOrderService, GlobalContext globalContext, OrderListViewModel orderListViewModel)
{
this.oneBoundAPIService = oneBoundAPIService;
this.purchaseOrderService = purchaseOrderService;
this.delayTrigger = new DelayTrigger();
this.delayTrigger.OnExecute = OnDelayTriggerExecute;
PurchaseSchemeProductSkuList = new ObservableCollection();
+ FastCreateOrderCommand = new RelayCommand(FastCreateOrder);
+ this.globalContext = globalContext;
+ this.orderListViewModel = orderListViewModel;
}
public void SetData(string orderId, int skuItemCount, PurchaseScheme purchaseScheme, PurchaseAccount purchaseAccount, Consignee consignee)
@@ -102,7 +111,11 @@ namespace BBWY.Client.ViewModels
PurchaseSchemeProductSkuList.Clear();
PurchaseScheme = null;
orderId = string.Empty;
+ tradeMode = string.Empty;
skuItemCount = 0;
+ ProductAmount = FreightAmount = TotalAmount = 0;
+ ContactName = Address = Mobile = Province = City = County = Town = PrucahseRemark = string.Empty;
+
}
private void LoadPurchaseProduct(PurchaseSchemeProduct purchaseSchemeProduct, ManualResetEvent ewh)
@@ -221,5 +234,51 @@ namespace BBWY.Client.ViewModels
tradeMode = r.Data.OrderTradeType?.Code;
});
}
+
+ private void FastCreateOrder()
+ {
+ if (TotalAmount == 0)
+ {
+ MessageBox.Show("总金额为0不能提交订单", "提示");
+ return;
+ }
+
+ IsLoading = true;
+
+ Task.Factory.StartNew(() => purchaseOrderService.FastCreateOrder(new Consignee()
+ {
+ Address = Address,
+ City = City,
+ ContactName = ContactName,
+ County = County,
+ Mobile = Mobile,
+ Province = Province,
+ TelePhone = Mobile,
+ Town = Town
+ }, PurchaseSchemeProductSkuList,
+ Platform.阿里巴巴,
+ PurchaseAccount,
+ tradeMode,
+ PrucahseRemark,
+ orderId,
+ globalContext.User.Shop.ShopId,
+ PurchaseAccount.AccountName,
+ PurchaseScheme.PurchaserName)).ContinueWith(t =>
+ {
+ IsLoading = false;
+ var r = t.Result;
+ if (!r.Success)
+ {
+ App.Current.Dispatcher.Invoke(() => MessageBox.Show(r.Msg, "下单"));
+ return;
+ }
+
+ //刷新订单列表
+ orderListViewModel.RefreshOrder();
+
+ //关闭当前窗口
+ GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(null, "OnlinePurchase_Close");
+ });
+ }
}
}
diff --git a/BBWY.Client/Views/Order/ChoosePurchaseScheme.xaml.cs b/BBWY.Client/Views/Order/ChoosePurchaseScheme.xaml.cs
index bd329b2d..181cfe0c 100644
--- a/BBWY.Client/Views/Order/ChoosePurchaseScheme.xaml.cs
+++ b/BBWY.Client/Views/Order/ChoosePurchaseScheme.xaml.cs
@@ -1,4 +1,5 @@
using BBWY.Controls;
+using GalaSoft.MvvmLight.Messaging;
namespace BBWY.Client.Views.Order
{
@@ -10,7 +11,18 @@ namespace BBWY.Client.Views.Order
public ChoosePurchaseScheme()
{
InitializeComponent();
- GalaSoft.MvvmLight.Messaging.Messenger.Default.Register(this, "ChoosePurchaseScheme_Close", (x) => this.Close());
+ this.Loaded += ChoosePurchaseScheme_Loaded;
+ this.Unloaded += ChoosePurchaseScheme_Unloaded;
+ }
+
+ private void ChoosePurchaseScheme_Unloaded(object sender, System.Windows.RoutedEventArgs e)
+ {
+ Messenger.Default.Unregister(this);
+ }
+
+ private void ChoosePurchaseScheme_Loaded(object sender, System.Windows.RoutedEventArgs e)
+ {
+ Messenger.Default.Register(this, "ChoosePurchaseScheme_Close", (x) => this.Close());
}
}
}
diff --git a/BBWY.Client/Views/Purchase/1688Purchase.xaml b/BBWY.Client/Views/Purchase/1688Purchase.xaml
index 0cc45bd2..adfa7a4e 100644
--- a/BBWY.Client/Views/Purchase/1688Purchase.xaml
+++ b/BBWY.Client/Views/Purchase/1688Purchase.xaml
@@ -122,6 +122,7 @@
-
+
diff --git a/BBWY.Client/Views/Purchase/1688Purchase.xaml.cs b/BBWY.Client/Views/Purchase/1688Purchase.xaml.cs
index b96521d8..28b1e5b3 100644
--- a/BBWY.Client/Views/Purchase/1688Purchase.xaml.cs
+++ b/BBWY.Client/Views/Purchase/1688Purchase.xaml.cs
@@ -1,6 +1,7 @@
using BBWY.Client.Models;
using BBWY.Client.ViewModels;
using BBWY.Controls;
+using GalaSoft.MvvmLight.Messaging;
namespace BBWY.Client.Views.Purchase
{
@@ -13,6 +14,18 @@ namespace BBWY.Client.Views.Purchase
{
InitializeComponent();
(this.DataContext as _1688PreviewPurchaseViewModel).SetData(orderId, skuItemCount, purchaseScheme, purchaseAccount, consignee);
+ this.Loaded += _1688Purchase_Loaded;
+ this.Unloaded += _1688Purchase_Unloaded;
+ }
+
+ private void _1688Purchase_Unloaded(object sender, System.Windows.RoutedEventArgs e)
+ {
+ Messenger.Default.Unregister(this);
+ }
+
+ private void _1688Purchase_Loaded(object sender, System.Windows.RoutedEventArgs e)
+ {
+ Messenger.Default.Register(this, "OnlinePurchase_Close", (x) => this.Close());
}
}
}
From 8d7f0252c2211998cc72296d3e3083ca837be9b5 Mon Sep 17 00:00:00 2001
From: shanji <18996038927@163.com>
Date: Thu, 10 Mar 2022 04:30:54 +0800
Subject: [PATCH 19/20] =?UTF-8?q?=E9=A2=84=E8=A7=88=E8=AE=A2=E5=8D=95?=
=?UTF-8?q?=E7=AA=97=E5=8F=A3=E5=A2=9E=E5=8A=A0=E5=88=86=E9=94=80=E6=A8=A1?=
=?UTF-8?q?=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../APIServices/PurchaseOrderService.cs | 5 ++-
BBWY.Client/App.xaml | 1 +
.../Converters/EnumToBooleanConverter.cs | 21 ++++++++++
BBWY.Client/Models/Enums.cs | 9 +++++
.../Models/Order/RelationPurchaseOrderSku.cs | 19 ++++++++++
.../ViewModels/Order/OrderListViewModel.cs | 3 +-
.../Purchase/1688PreviewPurchaseViewModel.cs | 38 +++++++++++++++++--
.../Views/Order/RelationPurchaseOrder.xaml | 2 +-
BBWY.Client/Views/Purchase/1688Purchase.xaml | 9 +++++
.../PlatformSDK/_1688Business.cs | 4 +-
BBWY.Server.Business/Vender/VenderBusiness.cs | 2 +-
.../OnlinePurchase/PreviewOrderReuqest.cs | 6 +++
BBWY.Server.Model/Enums.cs | 9 +++++
13 files changed, 118 insertions(+), 10 deletions(-)
create mode 100644 BBWY.Client/Converters/EnumToBooleanConverter.cs
diff --git a/BBWY.Client/APIServices/PurchaseOrderService.cs b/BBWY.Client/APIServices/PurchaseOrderService.cs
index e47fd4ab..b6c37501 100644
--- a/BBWY.Client/APIServices/PurchaseOrderService.cs
+++ b/BBWY.Client/APIServices/PurchaseOrderService.cs
@@ -56,10 +56,11 @@ namespace BBWY.Client.APIServices
///
///
///
- public ApiResponse PreviewPurchaseOrder(Consignee consignee, IList purchaseSchemeProductSkuList, Platform purchasePlatform, PurchaseAccount purchaseAccount)
+ public ApiResponse PreviewPurchaseOrder(Consignee consignee, IList purchaseSchemeProductSkuList, Platform purchasePlatform, PurchaseAccount purchaseAccount, PurchaseOrderMode purchaseOrderMode)
{
return SendRequest(globalContext.BBYWApiHost, "api/purchaseOrder/PreviewPurchaseOrder", new
{
+ purchaseOrderMode,
consignee,
CargoParamList = purchaseSchemeProductSkuList.Select(sku => new
{
@@ -94,6 +95,7 @@ namespace BBWY.Client.APIServices
IList purchaseSchemeProductSkuList,
Platform purchasePlatform,
PurchaseAccount purchaseAccount,
+ PurchaseOrderMode purchaseOrderMode,
string tradeMode,
string remark,
string orderId,
@@ -103,6 +105,7 @@ namespace BBWY.Client.APIServices
{
return SendRequest(globalContext.BBYWApiHost, "api/purchaseOrder/FastCreateOrder", new
{
+ purchaseOrderMode,
consignee,
CargoParamList = purchaseSchemeProductSkuList.Select(sku => new
{
diff --git a/BBWY.Client/App.xaml b/BBWY.Client/App.xaml
index 0c4e72d0..19e6c302 100644
--- a/BBWY.Client/App.xaml
+++ b/BBWY.Client/App.xaml
@@ -20,6 +20,7 @@
+
diff --git a/BBWY.Client/Converters/EnumToBooleanConverter.cs b/BBWY.Client/Converters/EnumToBooleanConverter.cs
new file mode 100644
index 00000000..0933e9b5
--- /dev/null
+++ b/BBWY.Client/Converters/EnumToBooleanConverter.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Globalization;
+using System.Windows.Data;
+
+namespace BBWY.Client.Converters
+{
+ public class EnumToBooleanConverter : IValueConverter
+ {
+ ///
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return value == null ? false : value.Equals(parameter);
+ }
+
+ ///
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return value != null && value.Equals(true) ? parameter : Binding.DoNothing;
+ }
+ }
+}
diff --git a/BBWY.Client/Models/Enums.cs b/BBWY.Client/Models/Enums.cs
index f446b363..3790cc9d 100644
--- a/BBWY.Client/Models/Enums.cs
+++ b/BBWY.Client/Models/Enums.cs
@@ -20,6 +20,15 @@
线下采购 = 1
}
+ ///
+ /// 采购单模式
+ ///
+ public enum PurchaseOrderMode
+ {
+ 批发 = 0,
+ 代发 = 1
+ }
+
///
/// 仓储类型
///
diff --git a/BBWY.Client/Models/Order/RelationPurchaseOrderSku.cs b/BBWY.Client/Models/Order/RelationPurchaseOrderSku.cs
index 177f0f43..87082933 100644
--- a/BBWY.Client/Models/Order/RelationPurchaseOrderSku.cs
+++ b/BBWY.Client/Models/Order/RelationPurchaseOrderSku.cs
@@ -5,6 +5,12 @@ namespace BBWY.Client.Models
{
public class RelationPurchaseOrderSku : NotifyObject
{
+ public RelationPurchaseOrderSku()
+ {
+ SingleSkuAmountStr = (0).ToString();
+ }
+
+ private string singleSkuAmountStr;
private decimal singleSkuAmount;
private decimal skuAmount;
@@ -18,6 +24,18 @@ namespace BBWY.Client.Models
public string Title { get; set; }
+ public string SingleSkuAmountStr
+ {
+ get => singleSkuAmountStr; set
+ {
+ if (Set(ref singleSkuAmountStr, value))
+ {
+ if (decimal.TryParse(value, out decimal d))
+ SingleSkuAmount = d;
+ }
+ }
+ }
+
public decimal SingleSkuAmount
{
get => singleSkuAmount;
@@ -41,5 +59,6 @@ namespace BBWY.Client.Models
[JsonIgnore]
public Action OnSkuAmountChanged { get; set; }
+
}
}
diff --git a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs
index 9075f60f..320c224f 100644
--- a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs
+++ b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs
@@ -351,7 +351,8 @@ namespace BBWY.Client.ViewModels
SkuId = osku.Id,
Quantity = osku.ItemTotal,
Title = osku.Title,
- SingleSkuAmount = (order.OrderCostDetailList.FirstOrDefault(ocd => ocd.SkuId == osku.Id)?.SkuAmount / osku.ItemTotal) ?? 0
+ SingleSkuAmount = (order.OrderCostDetailList.FirstOrDefault(ocd => ocd.SkuId == osku.Id)?.SkuAmount / osku.ItemTotal) ?? 0,
+ SingleSkuAmountStr = ((order.OrderCostDetailList.FirstOrDefault(ocd => ocd.SkuId == osku.Id)?.SkuAmount / osku.ItemTotal) ?? 0).ToString()
}).ToList());
relationPurchaseOrder.Closed += RelationPurchaseOrder_Closed;
relationPurchaseOrder.ShowDialog();
diff --git a/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs b/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs
index 694f5fcd..af3df55c 100644
--- a/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs
+++ b/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs
@@ -36,6 +36,15 @@ namespace BBWY.Client.ViewModels
public string Town { get => town; set { Set(ref town, value); } }
public string PrucahseRemark { get => prucahseRemark; set { Set(ref prucahseRemark, value); } }
+ public PurchaseOrderMode PurchaseOrderMode
+ {
+ get => purchaseOrderMode; set
+ {
+ if (Set(ref purchaseOrderMode, value))
+ OnDelayTriggerExecute(Guid.NewGuid().ToString());
+ }
+ }
+
private OrderListViewModel orderListViewModel;
private GlobalContext globalContext;
private string orderId;
@@ -56,7 +65,7 @@ namespace BBWY.Client.ViewModels
private string county;
private string town;
private string prucahseRemark;
-
+ private PurchaseOrderMode purchaseOrderMode = PurchaseOrderMode.代发;
private string tradeMode;
public _1688PreviewPurchaseViewModel(OneBoundAPIService oneBoundAPIService, PurchaseOrderService purchaseOrderService, GlobalContext globalContext, OrderListViewModel orderListViewModel)
@@ -69,6 +78,7 @@ namespace BBWY.Client.ViewModels
FastCreateOrderCommand = new RelayCommand(FastCreateOrder);
this.globalContext = globalContext;
this.orderListViewModel = orderListViewModel;
+ //PurchaseOrderMode = PurchaseOrderMode.代发;
}
public void SetData(string orderId, int skuItemCount, PurchaseScheme purchaseScheme, PurchaseAccount purchaseAccount, Consignee consignee)
@@ -102,7 +112,13 @@ namespace BBWY.Client.ViewModels
{
WaitHandle.WaitAll(waitList.ToArray());
//IsLoading = false;
- OnDelayTriggerExecute(string.Empty);
+ if (PurchaseSchemeProductSkuList.Count() > 0)
+ OnDelayTriggerExecute(Guid.NewGuid().ToString());
+ else
+ {
+ IsLoading = false;
+ App.Current.Dispatcher.Invoke(() => MessageBox.Show("采购方案商品加载失败,请重新打开预览窗口", "提示"));
+ }
});
}
@@ -150,6 +166,7 @@ namespace BBWY.Client.ViewModels
//记录日志
errorMsg = response.Msg;
+ Console.WriteLine(errorMsg);
return null;
}
var jobject = response.Data;
@@ -205,6 +222,8 @@ namespace BBWY.Client.ViewModels
private void OnDelayTriggerExecute(string key)
{
+ if (string.IsNullOrEmpty(key))
+ return;
IsLoading = true;
Task.Factory.StartNew(() => purchaseOrderService.PreviewPurchaseOrder(new Consignee()
{
@@ -216,7 +235,7 @@ namespace BBWY.Client.ViewModels
Province = Province,
TelePhone = Mobile,
Town = Town
- }, PurchaseSchemeProductSkuList, Platform.阿里巴巴, PurchaseAccount))
+ }, PurchaseSchemeProductSkuList, Platform.阿里巴巴, PurchaseAccount, PurchaseOrderMode))
.ContinueWith(t =>
{
IsLoading = false;
@@ -242,9 +261,19 @@ namespace BBWY.Client.ViewModels
MessageBox.Show("总金额为0不能提交订单", "提示");
return;
}
+ if (string.IsNullOrEmpty(Mobile) ||
+ string.IsNullOrEmpty(Address) ||
+ string.IsNullOrEmpty(City) ||
+ string.IsNullOrEmpty(Province) ||
+ string.IsNullOrEmpty(County) ||
+ string.IsNullOrEmpty(Town) ||
+ string.IsNullOrEmpty(ContactName))
+ {
+ MessageBox.Show("收货人信息不全", "下单");
+ return;
+ }
IsLoading = true;
-
Task.Factory.StartNew(() => purchaseOrderService.FastCreateOrder(new Consignee()
{
Address = Address,
@@ -258,6 +287,7 @@ namespace BBWY.Client.ViewModels
}, PurchaseSchemeProductSkuList,
Platform.阿里巴巴,
PurchaseAccount,
+ PurchaseOrderMode,
tradeMode,
PrucahseRemark,
orderId,
diff --git a/BBWY.Client/Views/Order/RelationPurchaseOrder.xaml b/BBWY.Client/Views/Order/RelationPurchaseOrder.xaml
index 04b10983..2341956b 100644
--- a/BBWY.Client/Views/Order/RelationPurchaseOrder.xaml
+++ b/BBWY.Client/Views/Order/RelationPurchaseOrder.xaml
@@ -123,7 +123,7 @@
TextWrapping="Wrap"/>
+ Text="{Binding SingleSkuAmountStr,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
diff --git a/BBWY.Client/Views/Purchase/1688Purchase.xaml b/BBWY.Client/Views/Purchase/1688Purchase.xaml
index adfa7a4e..1defc6aa 100644
--- a/BBWY.Client/Views/Purchase/1688Purchase.xaml
+++ b/BBWY.Client/Views/Purchase/1688Purchase.xaml
@@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BBWY.Client.Views.Purchase"
+ xmlns:cmodel="clr-namespace:BBWY.Client.Models"
xmlns:c="clr-namespace:BBWY.Controls;assembly=BBWY.Controls"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
mc:Ignorable="d"
@@ -122,6 +123,14 @@
+
+
+
+
diff --git a/BBWY.Server.Business/PlatformSDK/_1688Business.cs b/BBWY.Server.Business/PlatformSDK/_1688Business.cs
index 3aab9b76..526fcf79 100644
--- a/BBWY.Server.Business/PlatformSDK/_1688Business.cs
+++ b/BBWY.Server.Business/PlatformSDK/_1688Business.cs
@@ -72,7 +72,7 @@ namespace BBWY.Server.Business
townText = previewOrderReuqest.Consignee.Town
},
cargoParamList = new List(),
- flow = "general"
+ flow = previewOrderReuqest.PurchaseOrderMode == Enums.PurchaseOrderMode.批发 ? "general" : "saleproxy"
};
foreach (var cargo in previewOrderReuqest.CargoParamList)
{
@@ -142,7 +142,7 @@ namespace BBWY.Server.Business
var param = new
{
- flow = "general",
+ flow = createOnlinePurchaseOrderRequest.PurchaseOrderMode == Enums.PurchaseOrderMode.批发 ? "general" : "saleproxy",
message = createOnlinePurchaseOrderRequest.Remark,
addressParam = new
{
diff --git a/BBWY.Server.Business/Vender/VenderBusiness.cs b/BBWY.Server.Business/Vender/VenderBusiness.cs
index 32e49b6c..d93417c3 100644
--- a/BBWY.Server.Business/Vender/VenderBusiness.cs
+++ b/BBWY.Server.Business/Vender/VenderBusiness.cs
@@ -20,7 +20,7 @@ namespace BBWY.Server.Business
public VenderResponse GetVenderInfo(PlatformRequest platformRequest)
{
var relayAPIHost = GetPlatformRelayAPIHost(platformRequest.Platform);
- var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetVenderInfo", platformRequest, null, System.Net.Http.HttpMethod.Post);
+ var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetVenderInfo", platformRequest, null, HttpMethod.Post);
if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
var response = JsonConvert.DeserializeObject>(sendResult.Content);
diff --git a/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/PreviewOrderReuqest.cs b/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/PreviewOrderReuqest.cs
index ffe3c825..23d13394 100644
--- a/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/PreviewOrderReuqest.cs
+++ b/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/PreviewOrderReuqest.cs
@@ -4,6 +4,12 @@ namespace BBWY.Server.Model.Dto
{
public class PreviewOrderReuqest: PlatformRequest
{
+ ///
+ /// 订单模式
+ /// 1688 general大市场订单 saleproxy分销订单
+ ///
+ public Enums.PurchaseOrderMode PurchaseOrderMode { get; set; }
+
public ConsigneeRequest Consignee { get; set; }
public IList CargoParamList { get; set; }
diff --git a/BBWY.Server.Model/Enums.cs b/BBWY.Server.Model/Enums.cs
index 0464934d..6e767a6f 100644
--- a/BBWY.Server.Model/Enums.cs
+++ b/BBWY.Server.Model/Enums.cs
@@ -22,6 +22,15 @@
线下采购 = 1
}
+ ///
+ /// 采购单模式
+ ///
+ public enum PurchaseOrderMode
+ {
+ 批发 = 0,
+ 代发 = 1
+ }
+
///
/// 仓储类型
///
From 3681a50da2a100fe60746c448b6fd7b2cd56f679 Mon Sep 17 00:00:00 2001
From: shanji <18996038927@163.com>
Date: Fri, 11 Mar 2022 17:37:51 +0800
Subject: [PATCH 20/20] =?UTF-8?q?=E7=BB=91=E5=AE=9A=E9=87=87=E8=B4=AD?=
=?UTF-8?q?=E5=95=86=20=E9=AA=8C=E8=AF=81=E9=87=87=E8=B4=AD=E5=95=86?=
=?UTF-8?q?=E5=90=8D=E7=A7=B0=E6=98=AF=E5=90=A6=E4=B8=BA=E7=A9=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BBWY.Client/Views/Purchase/1688Purchase.xaml.cs | 4 ++--
.../PurchaseScheme/PurchaseSchemeBusiness.cs | 9 +++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/BBWY.Client/Views/Purchase/1688Purchase.xaml.cs b/BBWY.Client/Views/Purchase/1688Purchase.xaml.cs
index 28b1e5b3..03b81284 100644
--- a/BBWY.Client/Views/Purchase/1688Purchase.xaml.cs
+++ b/BBWY.Client/Views/Purchase/1688Purchase.xaml.cs
@@ -14,7 +14,7 @@ namespace BBWY.Client.Views.Purchase
{
InitializeComponent();
(this.DataContext as _1688PreviewPurchaseViewModel).SetData(orderId, skuItemCount, purchaseScheme, purchaseAccount, consignee);
- this.Loaded += _1688Purchase_Loaded;
+ this.Loaded += _1688Purchase_Loaded;
this.Unloaded += _1688Purchase_Unloaded;
}
@@ -25,7 +25,7 @@ namespace BBWY.Client.Views.Purchase
private void _1688Purchase_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
- Messenger.Default.Register(this, "OnlinePurchase_Close", (x) => this.Close());
+ Messenger.Default.Register(this, "OnlinePurchase_Close", (x) => this.Dispatcher.Invoke(() => this.Close()));
}
}
}
diff --git a/BBWY.Server.Business/PurchaseScheme/PurchaseSchemeBusiness.cs b/BBWY.Server.Business/PurchaseScheme/PurchaseSchemeBusiness.cs
index b4e83dbf..595eb4ba 100644
--- a/BBWY.Server.Business/PurchaseScheme/PurchaseSchemeBusiness.cs
+++ b/BBWY.Server.Business/PurchaseScheme/PurchaseSchemeBusiness.cs
@@ -29,6 +29,15 @@ namespace BBWY.Server.Business
{
if (batchCURDSchemeRequest.EditPurchaseSchemeList.Count == 0 && batchCURDSchemeRequest.AddPurchaseSchemeList.Count == 0)
throw new BusinessException("非法参数");
+ if (batchCURDSchemeRequest.AddPurchaseSchemeList.Any(p => string.IsNullOrEmpty(p.PurchaserId) ||
+ string.IsNullOrEmpty(p.PurchaserName) ||
+ string.IsNullOrEmpty(p.PurchaserLocation)))
+ throw new BusinessException("新增方案中有采购商Id/Name/Location为空");
+
+ if (batchCURDSchemeRequest.AddPurchaseSchemeList.Any(p => string.IsNullOrEmpty(p.PurchaserId) ||
+ string.IsNullOrEmpty(p.PurchaserName) ||
+ string.IsNullOrEmpty(p.PurchaserLocation)))
+ throw new BusinessException("编辑方案中有采购商Id/Name/Location为空");
List addPurchaseSchemeList = null;
List addPurchaseSchemeProductList = new List();