Browse Source

1

updatebug
shanji 2 years ago
parent
commit
3c39c001cf
  1. 1
      BBWYB.Server.API/Middlewares/CustomExceptionMiddleWare.cs
  2. 13
      SDKAdapter/PurchasePlatform/Client/Impl/PP_1688Client.cs

1
BBWYB.Server.API/Middlewares/CustomExceptionMiddleWare.cs

@ -25,6 +25,7 @@ namespace BBWYB.Server.API.Middlewares
{ {
_next = next; _next = next;
//this.logger = logger; //this.logger = logger;
this.nLogManager = nLogManager;
_exceptionStatusCodeDic = new Dictionary<int, string> _exceptionStatusCodeDic = new Dictionary<int, string>
{ {
{ 401, "未授权的请求" }, { 401, "未授权的请求" },

13
SDKAdapter/PurchasePlatform/Client/Impl/PP_1688Client.cs

@ -1,4 +1,5 @@
using BBWYB.Common.Http; using BBWYB.Common.Http;
using BBWYB.Common.Models;
using com.alibaba.openapi.client; using com.alibaba.openapi.client;
using com.alibaba.openapi.client.entity; using com.alibaba.openapi.client.entity;
using com.alibaba.openapi.client.policy; using com.alibaba.openapi.client.policy;
@ -74,10 +75,12 @@ namespace SDKAdapter.PurchasePlatform.Client
{ {
result = client.NewRequest(_request, reqPolicy); result = client.NewRequest(_request, reqPolicy);
if (result.Value<bool>("success") != true) if (result.Value<bool>("success") != true)
throw new Exception(result.Value<string>("errorMsg")); throw new BusinessException(result.Value<string>("errorMsg"));
} }
catch (Exception ex) catch (Exception ex)
{ {
if (ex.Message.Contains("通道") && ex.Message.Contains("不能使用"))
throw new BusinessException(ex.Message);
throw; throw;
} }
@ -87,10 +90,10 @@ namespace SDKAdapter.PurchasePlatform.Client
foreach (var orderPreviewJToken in orderPreviewResuslt) foreach (var orderPreviewJToken in orderPreviewResuslt)
{ {
if (orderPreviewJToken["tradeModelList"] == null) if (orderPreviewJToken["tradeModelList"] == null)
throw new Exception("当前交易不可通过API下单,请使用1688网页交易 [交易模式列表为空]"); throw new BusinessException("当前交易不可通过API下单,请使用1688网页交易 [交易模式列表为空]");
var tradeModeJArray = ((JArray)orderPreviewJToken["tradeModelList"]).Where(tradeJToken => tradeJToken.Value<bool>("opSupport")); var tradeModeJArray = ((JArray)orderPreviewJToken["tradeModelList"]).Where(tradeJToken => tradeJToken.Value<bool>("opSupport"));
if (tradeModeJArray.Count() == 0) if (tradeModeJArray.Count() == 0)
throw new Exception("当前交易不可通过API下单,请使用1688网页交易 [没有支持开放平台下单的交易模式]"); throw new BusinessException("当前交易不可通过API下单,请使用1688网页交易 [没有支持开放平台下单的交易模式]");
if (intersectTradeModeList.Count() == 0) if (intersectTradeModeList.Count() == 0)
intersectTradeModeList.AddRange(tradeModeJArray); intersectTradeModeList.AddRange(tradeModeJArray);
@ -99,7 +102,7 @@ namespace SDKAdapter.PurchasePlatform.Client
} }
if (intersectTradeModeList.Count() == 0) if (intersectTradeModeList.Count() == 0)
throw new Exception("当前交易不可通过API下单,请使用1688网页交易 [多个拆单之间没有相同的交易模式]"); throw new BusinessException("当前交易不可通过API下单,请使用1688网页交易 [多个拆单之间没有相同的交易模式]");
return new PP_PreviewOrderResponse() return new PP_PreviewOrderResponse()
{ {
FreightAmount = orderPreviewResuslt.Sum(jt => jt.Value<decimal>("sumCarriage")) / 100M, FreightAmount = orderPreviewResuslt.Sum(jt => jt.Value<decimal>("sumCarriage")) / 100M,
@ -164,7 +167,7 @@ namespace SDKAdapter.PurchasePlatform.Client
var result = client.NewRequest(_request, reqPolicy); var result = client.NewRequest(_request, reqPolicy);
if (result.Value<bool>("success") != true) if (result.Value<bool>("success") != true)
{ {
throw new Exception(result.ToString()); throw new BusinessException(result.ToString());
} }
var totalSuccessAmount = result["result"].Value<long>("totalSuccessAmount") / 100M; //采购单总金额,单位分 var totalSuccessAmount = result["result"].Value<long>("totalSuccessAmount") / 100M; //采购单总金额,单位分

Loading…
Cancel
Save