diff --git a/BBWYB.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs b/BBWYB.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs index a588427..ae2da82 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()