Browse Source

在线采购支持分批采购

1.取消将现有采购单设为失效
2.计算订单成本时将该笔订单下所有采购单成本查出并进行计算
yijia
shanji 2 years ago
parent
commit
afa9defe17
  1. 32
      BBWYB.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs

32
BBWYB.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs

@ -255,6 +255,23 @@ namespace BBWYB.Server.Business
var isRepurchase = fsql.Select<OrderCost>(dbOrder.Id).Any();
var orderSkus = fsql.Select<OrderSku>().Where(osku => osku.OrderId == request.OrderId).ToList();
var orderPurchaseInfoList = fsql.Select<OrderPurchaseInfo>().Where(opi => opi.OrderId == request.OrderId && opi.IsEnabled == true).ToList();
var orderCostDetailList = fsql.Select<OrderCostDetail>().Where(ocd => ocd.OrderId == request.OrderId && ocd.IsEnabled == true).ToList();
foreach (var cargoParamGroup in request.CargoParamGroupList)
{
var purchaseOrder = orderPurchaseInfoList.FirstOrDefault(opi => opi.PurchaserId == cargoParamGroup.PurchaserId);
if (purchaseOrder != null)
{
foreach (var cargoParam in cargoParamGroup.CargoParamList)
{
if (purchaseOrder.BelongSkuIds.Contains(cargoParam.BelongSkuId))
{
//throw new BusinessException($"订单sku[{cargoParam.BelongSkuId}]已经存在同一个商家[{cargoParamGroup.PurchaserId}][{cargoParamGroup.PurchaserName}]的另一笔采购单中[{purchaseOrder.PurchaseOrderId}],请不要为同一笔订单sku进行同商家采购");
throw new BusinessException($"提示:请勿为同一个订单中的sku重复向同一个商家下采购单\r\n重复信息:\r\n- 订单sku:{cargoParam.BelongSkuId}\r\n- 商家:{cargoParamGroup.PurchaserName}");
}
}
}
}
var extJArray = JsonConvert.DeserializeObject<JArray>(request.Extensions);
@ -279,8 +296,8 @@ namespace BBWYB.Server.Business
IInsert<OrderCost> insertOrderCost = null;
IUpdate<OrderCost> updateOrderCost = null;
var totalPurchaseProductAmount = 0M;
var totalPurchaseFreight = 0M;
//var totalPurchaseProductAmount = 0M;
//var totalPurchaseFreight = 0M;
foreach (var cargoParamGroup in request.CargoParamGroupList)
{
@ -326,8 +343,8 @@ namespace BBWYB.Server.Business
OrderId = createOrderResponse.OrderId
});
totalPurchaseProductAmount += purchaseOrderSimpleInfo.ProductAmount;
totalPurchaseFreight += purchaseOrderSimpleInfo.FreightAmount;
//totalPurchaseProductAmount += purchaseOrderSimpleInfo.ProductAmount;
//totalPurchaseFreight += purchaseOrderSimpleInfo.FreightAmount;
foreach (var cargoParam in cargoParamGroup.CargoParamList)
{
@ -478,9 +495,12 @@ namespace BBWYB.Server.Business
CreateTime = DateTime.Now,
IsManualEdited = false
};
var totalPurchaseProductAmount = orderCostDetailList.Union(insertOrderCostDetails).Sum(ocd => ocd.SkuAmount);
var totalPurchaseFreight = orderCostDetailList.Union(insertOrderCostDetails).Sum(ocd => ocd.PurchaseFreight);
orderCost.CalculationOrderCostCostAndProfit(dbOrder.OrderTotalPrice.Value,
totalPurchaseProductAmount,
totalPurchaseFreight,
totalPurchaseProductAmount ?? 0M,
totalPurchaseFreight ?? 0M,
0M,
0M);

Loading…
Cancel
Save