From 0e6324f28182240f4612a5b09c166b5970c6055d Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Mon, 19 Jun 2023 19:27:04 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E5=88=B6=E6=8A=A5=E4=BB=B7=E5=92=8C?= =?UTF-8?q?=E4=B8=8B=E5=8D=95sku=E9=87=87=E8=B4=AD=E6=96=B9=E6=A1=88?= =?UTF-8?q?=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PurchaseOrder/PurchaseOrderBusiness.cs | 43 +++++++++++++++++++ .../Client/Impl/PP_1688Client.cs | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/BBWYB.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs b/BBWYB.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs index 854f071..f1d899c 100644 --- a/BBWYB.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs +++ b/BBWYB.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs @@ -105,6 +105,27 @@ namespace BBWYB.Server.Business if (request.CargoParamGroupList == null || request.CargoParamGroupList.Count() == 0) throw new BusinessException("缺少报价参数"); + #region 验证同一个批次中,一个订单sku不能同时拥有多个采购方案 + IDictionary schemeValidationDictionary = new Dictionary(); + foreach (var purchaseGroup in request.CargoParamGroupList) + { + foreach (var cargo in purchaseGroup.CargoParamList) + { + if (!schemeValidationDictionary.ContainsKey(cargo.BelongSkuId)) + schemeValidationDictionary.TryAdd(cargo.BelongSkuId, cargo.SchemeId); + + if (schemeValidationDictionary.TryGetValue(cargo.BelongSkuId, out long schemeId)) + { + if (cargo.SchemeId != schemeId) + { + throw new BusinessException($"订单sku{cargo.BelongSkuId}只允许使用一个采购方案进行报价"); + } + } + } + } + schemeValidationDictionary.Clear(); + #endregion + var extJArray = new List(); var errorBuilder = new StringBuilder(); var freightAmount = 0M; @@ -204,6 +225,28 @@ namespace BBWYB.Server.Business if (request.CargoParamGroupList == null || request.CargoParamGroupList.Count() == 0) throw new BusinessException("缺少下单商品参数"); + #region 验证同一个批次中,一个订单sku不能同时拥有多个采购方案 + IDictionary schemeValidationDictionary = new Dictionary(); + foreach (var purchaseGroup in request.CargoParamGroupList) + { + foreach (var cargo in purchaseGroup.CargoParamList) + { + if (!schemeValidationDictionary.ContainsKey(cargo.BelongSkuId)) + schemeValidationDictionary.TryAdd(cargo.BelongSkuId, cargo.SchemeId); + + if (schemeValidationDictionary.TryGetValue(cargo.BelongSkuId, out long schemeId)) + { + if (cargo.SchemeId != schemeId) + { + throw new BusinessException($"订单sku{cargo.BelongSkuId}只允许使用一个采购方案进行下单"); + } + } + } + } + schemeValidationDictionary.Clear(); + #endregion + + var isRepurchase = fsql.Select(dbOrder.Id).Any(); var orderSkus = fsql.Select().Where(osku => osku.Price != 0 && osku.OrderId == request.OrderId).ToList(); var orderPurchaseInfoList = fsql.Select().Where(opi => opi.OrderId == request.OrderId && opi.IsEnabled == true).ToList(); diff --git a/SDKAdapter/PurchasePlatform/Client/Impl/PP_1688Client.cs b/SDKAdapter/PurchasePlatform/Client/Impl/PP_1688Client.cs index 8bd875c..f1cc945 100644 --- a/SDKAdapter/PurchasePlatform/Client/Impl/PP_1688Client.cs +++ b/SDKAdapter/PurchasePlatform/Client/Impl/PP_1688Client.cs @@ -227,7 +227,7 @@ namespace SDKAdapter.PurchasePlatform.Client _request.AccessToken = request.AppToken; var result = client.NewRequest(_request, reqPolicy); if (result.Value("success") != true) - throw new Exception(result.Value("errorMessage")); + throw new BusinessException(result.Value("errorMessage")); return new PP_QueryOrderDetailResponse()