Browse Source

1.新增1688SDK请求

2.订单预览窗口新增收货人信息
qianyi
shanji 3 years ago
parent
commit
623701c763
  1. 4
      BBWY.1688SDK/BBWY.1688SDK.csproj
  2. 20
      BBWY.1688SDK/SyncAPIClient.cs
  3. 48
      BBWY.1688SDK/http/HttpClient.cs
  4. 8
      BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs
  5. 2
      BBWY.Client/ViewModels/Order/OrderListViewModel.cs
  6. 32
      BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs
  7. 26
      BBWY.Client/Views/Purchase/1688Purchase.xaml
  8. 4
      BBWY.Client/Views/Purchase/1688Purchase.xaml.cs
  9. 4
      BBWY.Server.API/Controllers/PlatformSDKController.cs
  10. 16
      BBWY.Server.API/Controllers/PurchaseOrderController.cs
  11. 7
      BBWY.Server.Business/PlatformSDK/JDBusiness.cs
  12. 19
      BBWY.Server.Business/PlatformSDK/_1688Business.cs
  13. 16
      BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs

4
BBWY.1688SDK/BBWY.1688SDK.csproj

@ -9,4 +9,8 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BBWY.Common\BBWY.Common.csproj" />
</ItemGroup>
</Project> </Project>

20
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.http;
using com.alibaba.openapi.client.policy; using com.alibaba.openapi.client.policy;
using Newtonsoft.Json.Linq;
using System; using System;
namespace com.alibaba.openapi.client namespace com.alibaba.openapi.client
@ -8,6 +10,8 @@ namespace com.alibaba.openapi.client
public class SyncAPIClient public class SyncAPIClient
{ {
private ClientPolicy clientPolicy; private ClientPolicy clientPolicy;
private RestApiService restApiService;
private HttpClient alibabaHttpClient;
public SyncAPIClient(String appKey, String appSecret) public SyncAPIClient(String appKey, String appSecret)
{ {
@ -16,6 +20,15 @@ namespace com.alibaba.openapi.client
this.clientPolicy.SecretKey = appSecret; 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) public SyncAPIClient(String appKey, String appSecret, String gatewayHost)
{ {
this.clientPolicy = new ClientPolicy(); this.clientPolicy = new ClientPolicy();
@ -29,6 +42,11 @@ namespace com.alibaba.openapi.client
this.clientPolicy = clientPolicy; this.clientPolicy = clientPolicy;
} }
public JObject NewRequest(Request request, RequestPolicy policy)
{
return alibabaHttpClient.NewRequest(request, policy);
}
public T send<T>(Request request, RequestPolicy policy) public T send<T>(Request request, RequestPolicy policy)
{ {
HttpClient httpClient = new HttpClient(clientPolicy); HttpClient httpClient = new HttpClient(clientPolicy);

48
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 com.alibaba.openapi.client.util;
using Newtonsoft.Json.Linq;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.IO;
using System.Net; using System.Net;
using System.Net.Http;
using System.Text; 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; using System.Web;
namespace com.alibaba.openapi.client.http namespace com.alibaba.openapi.client.http
@ -18,12 +17,43 @@ namespace com.alibaba.openapi.client.http
public class HttpClient public class HttpClient
{ {
private ClientPolicy clientPolicy; private ClientPolicy clientPolicy;
private RestApiService restApiService;
private IDictionary<string, string> requestHeader;
public HttpClient(ClientPolicy clientPolicy) public HttpClient(ClientPolicy clientPolicy)
{ {
this.clientPolicy = clientPolicy; this.clientPolicy = clientPolicy;
} }
public HttpClient(ClientPolicy clientPolicy, RestApiService restApiService)
{
this.clientPolicy = clientPolicy;
this.restApiService = restApiService;
this.requestHeader = new Dictionary<string, string>()
{
{ "User-Agent","Ocean/NET-SDKClient"}
};
}
public JObject NewRequest(Request request, RequestPolicy requestPolicy)
{
StringBuilder path = createProtocolRequestPath(requestPolicy, request);
Dictionary<string, object> 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<T>(Request request, RequestPolicy requestPolicy) public T request<T>(Request request, RequestPolicy requestPolicy)
{ {
StringBuilder path = createProtocolRequestPath(requestPolicy, request); StringBuilder path = createProtocolRequestPath(requestPolicy, request);
@ -85,7 +115,7 @@ namespace com.alibaba.openapi.client.http
HttpWebResponse response = webException.Response as HttpWebResponse; HttpWebResponse response = webException.Response as HttpWebResponse;
Stream responseStream = response.GetResponseStream(); Stream responseStream = response.GetResponseStream();
DeSerializer deSerializer = SerializerProvider.getInstance().getDeSerializer(requestPolicy.ResponseProtocol); 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; throw rw;
} }
} }

8
BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs

@ -22,6 +22,8 @@ namespace BBWY.Client.ViewModels
public string OrderId { get; set; } public string OrderId { get; set; }
public int ItemTotal { get; set; } public int ItemTotal { get; set; }
public Consignee Consignee { get; set; }
public IList<PurchaseScheme> PurchaseSchemeList { get; set; } public IList<PurchaseScheme> PurchaseSchemeList { get; set; }
@ -50,15 +52,17 @@ namespace BBWY.Client.ViewModels
{ {
this.ItemTotal = 0; this.ItemTotal = 0;
this.OrderId = this.SkuId = this.SkuName = string.Empty; this.OrderId = this.SkuId = this.SkuName = string.Empty;
this.Consignee = null;
PurchaseSchemeList.Clear(); 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.OrderId = orderId;
this.SkuId = skuId; this.SkuId = skuId;
this.SkuName = skuName; this.SkuName = skuName;
this.ItemTotal = itemTotal; this.ItemTotal = itemTotal;
this.Consignee = consignee;
} }
public void LoadPurchaseScheme(string skuId) public void LoadPurchaseScheme(string skuId)
@ -110,7 +114,7 @@ namespace BBWY.Client.ViewModels
} }
else if (count == 1) 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(); p.ShowDialog();
} }
else else

2
BBWY.Client/ViewModels/Order/OrderListViewModel.cs

@ -257,7 +257,7 @@ namespace BBWY.Client.ViewModels
} }
else if (chooseDFType.DFType == DFType.线) 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(); var choosePurchaseScheme = new ChoosePurchaseScheme();
choosePurchaseScheme.ShowDialog(); choosePurchaseScheme.ShowDialog();
} }

32
BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs

@ -19,12 +19,34 @@ namespace BBWY.Client.ViewModels
public PurchaseAccount PurchaseAccount { get; set; } public PurchaseAccount PurchaseAccount { get; set; }
public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } } 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 string orderId;
private int skuItemCount; private int skuItemCount;
private bool isLoading; private bool isLoading;
private OneBoundAPIService oneBoundAPIService; private OneBoundAPIService oneBoundAPIService;
private DelayTrigger delayTrigger; 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) public _1688PreviewPurchaseViewModel(OneBoundAPIService oneBoundAPIService)
{ {
this.oneBoundAPIService = oneBoundAPIService; this.oneBoundAPIService = oneBoundAPIService;
@ -33,12 +55,20 @@ namespace BBWY.Client.ViewModels
PurchaseSchemeProductSkuList = new ObservableCollection<PurchaseSchemeProductSku>(); PurchaseSchemeProductSkuList = new ObservableCollection<PurchaseSchemeProductSku>();
} }
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.orderId = orderId;
this.skuItemCount = skuItemCount; this.skuItemCount = skuItemCount;
this.PurchaseScheme = purchaseScheme; this.PurchaseScheme = purchaseScheme;
this.PurchaseAccount = purchaseAccount; 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() protected override void Load()

26
BBWY.Client/Views/Purchase/1688Purchase.xaml

@ -85,24 +85,38 @@
TextWrapping="Wrap"/> TextWrapping="Wrap"/>
<TextBlock Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center"> <TextBlock Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center">
<Run Text="货品总运费"/> <Run Text="货品总运费"/>
<Run Text="132.3" Foreground="#EC808D"/> <Run Text="{Binding ProductAmount,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" Foreground="#EC808D"/>
<Run Text="元"/> <Run Text="元"/>
<LineBreak/> <LineBreak/>
<Run Text="运费共计"/> <Run Text="运费共计"/>
<Run Text="20" Foreground="#EC808D"/> <Run Text="{Binding FreightAmount,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" Foreground="#EC808D"/>
<Run Text="元"/> <Run Text="元"/>
</TextBlock> </TextBlock>
</Grid> </Grid>
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Center" Grid.Row="3" Margin="5,0"> <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Center" Grid.Row="3" Margin="5,0">
<c:BTextBox Text="收货人" WaterRemark="收货人"/> <c:BTextBox Text="{Binding ContactName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" WaterRemark="收货人"/>
<c:BTextBox Text="福建泉州鲤城区浮桥街龙景华庭B栋1008" Margin="0,2.5" WaterRemark="地址"/> <Grid>
<c:BTextBox Text="18996038927" WaterRemark="电话"/> <Grid.ColumnDefinitions>
<ColumnDefinition Width="80"/>
<ColumnDefinition Width="80"/>
<ColumnDefinition Width="80"/>
<ColumnDefinition Width="80"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<c:BTextBox Text="{Binding Province,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" WaterRemark="省" BorderThickness="1,1,0,1"/>
<c:BTextBox Text="{Binding City,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" WaterRemark="市" Grid.Column="1" BorderThickness="1,1,0,1"/>
<c:BTextBox Text="{Binding County,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" WaterRemark="区/县" Grid.Column="2" BorderThickness="1,1,0,1"/>
<c:BTextBox Text="{Binding Town,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" WaterRemark="镇" Grid.Column="3" BorderThickness="1,1,0,1"/>
<c:BTextBox Text="{Binding Address,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Margin="0,2.5" WaterRemark="街道地址" Grid.Column="4"/>
</Grid>
<c:BTextBox Text="{Binding Mobile,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" WaterRemark="电话"/>
</StackPanel> </StackPanel>
<TextBlock Grid.Row="4" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0" FontSize="16"> <TextBlock Grid.Row="4" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0" FontSize="16">
<Run Text="应付总额(含运费)"/> <Run Text="应付总额(含运费)"/>
<Run Text="163.3" Foreground="#EC808D"/> <Run Text="{Binding TotalAmount,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" Foreground="#EC808D"/>
<Run Text="元"/> <Run Text="元"/>
</TextBlock> </TextBlock>
<c:BButton Content="提交订单" Grid.Row="4" Width="80" HorizontalAlignment="Right" Margin="0,0,5,0"/> <c:BButton Content="提交订单" Grid.Row="4" Width="80" HorizontalAlignment="Right" Margin="0,0,5,0"/>

4
BBWY.Client/Views/Purchase/1688Purchase.xaml.cs

@ -9,10 +9,10 @@ namespace BBWY.Client.Views.Purchase
/// </summary> /// </summary>
public partial class _1688Purchase : BWindow 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(); InitializeComponent();
(this.DataContext as _1688PreviewPurchaseViewModel).SetData(orderId, skuItemCount, purchaseScheme, purchaseAccount); (this.DataContext as _1688PreviewPurchaseViewModel).SetData(orderId, skuItemCount, purchaseScheme, purchaseAccount, consignee);
} }
} }
} }

4
BBWY.Server.API/Controllers/PlatformSDKController.cs

@ -115,7 +115,7 @@ namespace BBWY.Server.API.Controllers
/// </summary> /// </summary>
/// <param name="outStockRequest"></param> /// <param name="outStockRequest"></param>
[HttpPost] [HttpPost]
public void OutStock(OutStockRequest outStockRequest) public void OutStock([FromBody]OutStockRequest outStockRequest)
{ {
platformSDKBusinessList.FirstOrDefault(p => p.Platform == outStockRequest.Platform).OutStock(outStockRequest); platformSDKBusinessList.FirstOrDefault(p => p.Platform == outStockRequest.Platform).OutStock(outStockRequest);
} }
@ -126,7 +126,7 @@ namespace BBWY.Server.API.Controllers
/// <param name="previewOrderReuqest"></param> /// <param name="previewOrderReuqest"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public PreviewOrderResponse PreviewOrder(PreviewOrderReuqest previewOrderReuqest) public PreviewOrderResponse PreviewOrder([FromBody]PreviewOrderReuqest previewOrderReuqest)
{ {
return platformSDKBusinessList.FirstOrDefault(p => p.Platform == previewOrderReuqest.Platform).PreviewOrder(previewOrderReuqest); return platformSDKBusinessList.FirstOrDefault(p => p.Platform == previewOrderReuqest.Platform).PreviewOrder(previewOrderReuqest);
} }

16
BBWY.Server.API/Controllers/PurchaseOrderController.cs

@ -2,7 +2,9 @@
using BBWY.Server.Model.Dto; using BBWY.Server.Model.Dto;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace BBWY.Server.API.Controllers namespace BBWY.Server.API.Controllers
{ {
@ -10,7 +12,8 @@ namespace BBWY.Server.API.Controllers
{ {
private PurchaseOrderBusiness purchaseOrderBusiness; private PurchaseOrderBusiness purchaseOrderBusiness;
public PurchaseOrderController(PurchaseOrderBusiness purchaseOrderBusiness, IHttpContextAccessor httpContextAccessor) : base(httpContextAccessor) public PurchaseOrderController(PurchaseOrderBusiness purchaseOrderBusiness,
IHttpContextAccessor httpContextAccessor) : base(httpContextAccessor)
{ {
this.purchaseOrderBusiness = purchaseOrderBusiness; this.purchaseOrderBusiness = purchaseOrderBusiness;
} }
@ -38,5 +41,16 @@ namespace BBWY.Server.API.Controllers
{ {
purchaseOrderBusiness.DeletePurchaseOrder(id); purchaseOrderBusiness.DeletePurchaseOrder(id);
} }
/// <summary>
/// 订单预览
/// </summary>
/// <param name="previewOrderReuqest"></param>
/// <returns></returns>
[HttpPost]
public PreviewOrderResponse PreviewPurchaseOrder([FromBody] PreviewOrderReuqest previewOrderReuqest)
{
return purchaseOrderBusiness.PreviewPurchaseOrder(previewOrderReuqest);
}
} }
} }

7
BBWY.Server.Business/PlatformSDK/JDBusiness.cs

@ -347,6 +347,7 @@ namespace BBWY.Server.Business
var decryptContactName = tdeClient.DecryptString(orderInfo["consigneeInfo"].Value<string>("fullname")); var decryptContactName = tdeClient.DecryptString(orderInfo["consigneeInfo"].Value<string>("fullname"));
var decryptAddress = tdeClient.DecryptString(orderInfo["consigneeInfo"].Value<string>("fullAddress")); var decryptAddress = tdeClient.DecryptString(orderInfo["consigneeInfo"].Value<string>("fullAddress"));
/*
PopOrderGetmobilelistRequest decryptMobileReq = new PopOrderGetmobilelistRequest(); PopOrderGetmobilelistRequest decryptMobileReq = new PopOrderGetmobilelistRequest();
decryptMobileReq.appName = "订单管家"; decryptMobileReq.appName = "订单管家";
decryptMobileReq.orderId = decryptConsigneeRequest.OrderId; 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<string>("consMobilePhone"); var decryptMobile = decryptMobileResponse.Json["jingdong_pop_order_getmobilelist_responce"]["result"]["data"][decryptConsigneeRequest.OrderId].Value<string>("consMobilePhone");
var decryptTelePhone = decryptMobileResponse.Json["jingdong_pop_order_getmobilelist_responce"]["result"]["data"][decryptConsigneeRequest.OrderId].Value<string>("customerPhone"); var decryptTelePhone = decryptMobileResponse.Json["jingdong_pop_order_getmobilelist_responce"]["result"]["data"][decryptConsigneeRequest.OrderId].Value<string>("customerPhone");
*/
return new ConsigneeSimpleResponse() return new ConsigneeSimpleResponse()
{ {
Address = decryptAddress, Address = decryptAddress,
ContactName = decryptContactName, ContactName = decryptContactName,
Mobile = decryptMobile, //Mobile = decryptMobile,
TelePhone = decryptTelePhone //TelePhone = decryptTelePhone
}; };
} }

19
BBWY.Server.Business/PlatformSDK/_1688Business.cs

@ -1,4 +1,6 @@
using BBWY._1688SDK.entity.OrderPreview; using BBWY._1688SDK.entity.OrderPreview;
using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Server.Model; using BBWY.Server.Model;
using BBWY.Server.Model.Dto; using BBWY.Server.Model.Dto;
using com.alibaba.openapi.client; using com.alibaba.openapi.client;
@ -13,17 +15,18 @@ namespace BBWY.Server.Business
public class _1688Business : PlatformSDKBusiness public class _1688Business : PlatformSDKBusiness
{ {
public override Enums.Platform Platform => Enums.Platform.; 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) private SyncAPIClient GetSyncAPIClient(string appKey, string appSecret)
{ {
if (!memoryCache.TryGetValue(appKey, out SyncAPIClient syncAPIClient)) if (!memoryCache.TryGetValue(appKey, out SyncAPIClient syncAPIClient))
{ {
syncAPIClient = new SyncAPIClient(appKey, appSecret); syncAPIClient = new SyncAPIClient(appKey, appSecret, restApiService);
memoryCache.Set(appKey, syncAPIClient, expirationTimeSpan); memoryCache.Set(appKey, syncAPIClient, expirationTimeSpan);
} }
return syncAPIClient; return syncAPIClient;
@ -35,7 +38,7 @@ namespace BBWY.Server.Business
RequestPolicy reqPolicy = new RequestPolicy(); RequestPolicy reqPolicy = new RequestPolicy();
reqPolicy.HttpMethod = "POST"; reqPolicy.HttpMethod = "POST";
reqPolicy.NeedAuthorization = false; reqPolicy.NeedAuthorization = false;
reqPolicy.RequestSendTimestamp = true; reqPolicy.RequestSendTimestamp = false;
reqPolicy.UseHttps = false; reqPolicy.UseHttps = false;
reqPolicy.UseSignture = true; reqPolicy.UseSignture = true;
reqPolicy.AccessPrivateApi = false; reqPolicy.AccessPrivateApi = false;
@ -74,7 +77,13 @@ namespace BBWY.Server.Business
}); });
} }
request.RequestEntity = param; request.RequestEntity = param;
var result = client.send<JObject>(request, reqPolicy); if (!string.IsNullOrEmpty(previewOrderReuqest.AppToken))
request.AccessToken = previewOrderReuqest.AppToken;
var result = client.NewRequest(request, reqPolicy);
if (result.Value<bool>("success") != true)
{
throw new BusinessException(result.Value<string>("errorMsg")) { Code = result.Value<int>("errorCode") };
}
return new PreviewOrderResponse() return new PreviewOrderResponse()
{ {

16
BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs

@ -4,13 +4,18 @@ using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto; using BBWY.Server.Model.Dto;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Yitter.IdGenerator; using Yitter.IdGenerator;
namespace BBWY.Server.Business namespace BBWY.Server.Business
{ {
public class PurchaseOrderBusiness : BaseBusiness, IDenpendency public class PurchaseOrderBusiness : BaseBusiness, IDenpendency
{ {
public PurchaseOrderBusiness(IFreeSql fsql, NLog.ILogger logger, IIdGenerator idGenerator) : base(fsql, logger, idGenerator) { } private IEnumerable<PlatformSDKBusiness> platformSDKBusinessList;
public PurchaseOrderBusiness(IFreeSql fsql, NLog.ILogger logger, IIdGenerator idGenerator, IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(fsql, logger, idGenerator)
{
this.platformSDKBusinessList = platformSDKBusinessList;
}
public void AddPurchaseOrder(AddPurchaseOrderRequest addPurchaseOrderRequest) public void AddPurchaseOrder(AddPurchaseOrderRequest addPurchaseOrderRequest)
{ {
@ -57,5 +62,14 @@ namespace BBWY.Server.Business
{ {
fsql.Delete<PurchaseOrder>(id).ExecuteAffrows(); fsql.Delete<PurchaseOrder>(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);
}
} }
} }

Loading…
Cancel
Save