Browse Source

限制报价和下单sku采购方案数量

yijia
shanji 2 years ago
parent
commit
0e6324f281
  1. 43
      BBWYB.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs
  2. 2
      SDKAdapter/PurchasePlatform/Client/Impl/PP_1688Client.cs

43
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<string, long> schemeValidationDictionary = new Dictionary<string, long>();
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<object>();
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<string, long> schemeValidationDictionary = new Dictionary<string, long>();
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<OrderCost>(dbOrder.Id).Any();
var orderSkus = fsql.Select<OrderSku>().Where(osku => osku.Price != 0 && osku.OrderId == request.OrderId).ToList();
var orderPurchaseInfoList = fsql.Select<OrderPurchaseInfo>().Where(opi => opi.OrderId == request.OrderId && opi.IsEnabled == true).ToList();

2
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<bool>("success") != true)
throw new Exception(result.Value<string>("errorMessage"));
throw new BusinessException(result.Value<string>("errorMessage"));
return new PP_QueryOrderDetailResponse()

Loading…
Cancel
Save