From 3c39c001cf493f453972049aebb8347ea9cdeb08 Mon Sep 17 00:00:00 2001 From: shanji <18996038927@163.com> Date: Wed, 19 Apr 2023 15:12:16 +0800 Subject: [PATCH] 1 --- .../Middlewares/CustomExceptionMiddleWare.cs | 1 + .../PurchasePlatform/Client/Impl/PP_1688Client.cs | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/BBWYB.Server.API/Middlewares/CustomExceptionMiddleWare.cs b/BBWYB.Server.API/Middlewares/CustomExceptionMiddleWare.cs index 9aacf9d..80cf2a3 100644 --- a/BBWYB.Server.API/Middlewares/CustomExceptionMiddleWare.cs +++ b/BBWYB.Server.API/Middlewares/CustomExceptionMiddleWare.cs @@ -25,6 +25,7 @@ namespace BBWYB.Server.API.Middlewares { _next = next; //this.logger = logger; + this.nLogManager = nLogManager; _exceptionStatusCodeDic = new Dictionary { { 401, "未授权的请求" }, diff --git a/SDKAdapter/PurchasePlatform/Client/Impl/PP_1688Client.cs b/SDKAdapter/PurchasePlatform/Client/Impl/PP_1688Client.cs index 5349335..d55421d 100644 --- a/SDKAdapter/PurchasePlatform/Client/Impl/PP_1688Client.cs +++ b/SDKAdapter/PurchasePlatform/Client/Impl/PP_1688Client.cs @@ -1,4 +1,5 @@ using BBWYB.Common.Http; +using BBWYB.Common.Models; using com.alibaba.openapi.client; using com.alibaba.openapi.client.entity; using com.alibaba.openapi.client.policy; @@ -74,10 +75,12 @@ namespace SDKAdapter.PurchasePlatform.Client { result = client.NewRequest(_request, reqPolicy); if (result.Value("success") != true) - throw new Exception(result.Value("errorMsg")); + throw new BusinessException(result.Value("errorMsg")); } catch (Exception ex) { + if (ex.Message.Contains("通道") && ex.Message.Contains("不能使用")) + throw new BusinessException(ex.Message); throw; } @@ -87,10 +90,10 @@ namespace SDKAdapter.PurchasePlatform.Client foreach (var orderPreviewJToken in orderPreviewResuslt) { if (orderPreviewJToken["tradeModelList"] == null) - throw new Exception("当前交易不可通过API下单,请使用1688网页交易 [交易模式列表为空]"); + throw new BusinessException("当前交易不可通过API下单,请使用1688网页交易 [交易模式列表为空]"); var tradeModeJArray = ((JArray)orderPreviewJToken["tradeModelList"]).Where(tradeJToken => tradeJToken.Value("opSupport")); if (tradeModeJArray.Count() == 0) - throw new Exception("当前交易不可通过API下单,请使用1688网页交易 [没有支持开放平台下单的交易模式]"); + throw new BusinessException("当前交易不可通过API下单,请使用1688网页交易 [没有支持开放平台下单的交易模式]"); if (intersectTradeModeList.Count() == 0) intersectTradeModeList.AddRange(tradeModeJArray); @@ -99,7 +102,7 @@ namespace SDKAdapter.PurchasePlatform.Client } if (intersectTradeModeList.Count() == 0) - throw new Exception("当前交易不可通过API下单,请使用1688网页交易 [多个拆单之间没有相同的交易模式]"); + throw new BusinessException("当前交易不可通过API下单,请使用1688网页交易 [多个拆单之间没有相同的交易模式]"); return new PP_PreviewOrderResponse() { FreightAmount = orderPreviewResuslt.Sum(jt => jt.Value("sumCarriage")) / 100M, @@ -164,7 +167,7 @@ namespace SDKAdapter.PurchasePlatform.Client var result = client.NewRequest(_request, reqPolicy); if (result.Value("success") != true) { - throw new Exception(result.ToString()); + throw new BusinessException(result.ToString()); } var totalSuccessAmount = result["result"].Value("totalSuccessAmount") / 100M; //采购单总金额,单位分