public void Calculate(ref OrderInfo order) { WarehouseAllocateRequest request = new WarehouseAllocateRequest(); SetWarehouseAllocateRequest(order, request); WarehouseAllocateResponse response = GetWarehouseAllocateResponse(request); if (response.AllocateResult > -1) { SetWarehouseAllocateResult(order, response.AllocateItemInventoryInfoList); } }
private void SetWarehouseAllocateRequest(OrderInfo orderInfo, WarehouseAllocateRequest request) { request.ShippingAreaID = orderInfo.Contact != null ? orderInfo.Contact.AddressAreaID : 0; request.ProductList = new List <AllocateItemInfo>(); if (orderInfo.OrderItemGroupList != null) { foreach (OrderItemGroup itemGroup in orderInfo.OrderItemGroupList) { if (itemGroup.ProductItemList != null) { itemGroup.ProductItemList.ForEach(masterItem => { SetAllocationItemInfo(masterItem, SOItemType.ForSale, itemGroup.Quantity, request.ProductList); }); } } } if (orderInfo.GiftItemList != null) { orderInfo.GiftItemList.ForEach(giftItem => { SetAllocationItemInfo(giftItem, (giftItem.SaleGiftType == SaleGiftType.Vendor ? SOItemType.Gift : SOItemType.ActivityGift), giftItem.ParentCount, request.ProductList); }); } if (orderInfo.AttachmentItemList != null) { orderInfo.AttachmentItemList.ForEach(attachment => { SetAllocationItemInfo(attachment, SOItemType.HiddenGift, attachment.ParentCount, request.ProductList); }); } //加够商品 if (orderInfo.PlusPriceItemList != null) { orderInfo.PlusPriceItemList.ForEach(plusPriceItem => { SetAllocationItemInfo(plusPriceItem, (plusPriceItem.SaleGiftType == SaleGiftType.Vendor ? SOItemType.Gift : SOItemType.ActivityGift), plusPriceItem.ParentCount, request.ProductList); }); } }
private WarehouseAllocateResponse GetWarehouseAllocateResponse(WarehouseAllocateRequest request) { WarehouseAllocateResponse response = PipelineDA.AllocateWarehouse(request); if (response.AllocateItemInventoryInfoList != null) { List <AllocatedItemInventoryInfo> allocatedItemInventoryInfoResult = new List <AllocatedItemInventoryInfo>(); foreach (AllocateItemInfo productInfo in request.ProductList) { List <AllocatedItemInventoryInfo> thisItemAllocateInventoryList = response.AllocateItemInventoryInfoList.FindAll(item => { return(productInfo.ProductID == item.ProductID); }); if (thisItemAllocateInventoryList != null && thisItemAllocateInventoryList.Count > 0) { //删除库存不足的仓库,不做并单发货,不存在前台自动移仓单 thisItemAllocateInventoryList.RemoveAll(item => { return((item.StockAvailableQty + item.StockConsignQty + item.StockVirtualQty) < productInfo.Quantity); }); //筛选出最佳出库仓库 if (thisItemAllocateInventoryList.Count > 0) { FilterAllocatedItemInventoryInfo(productInfo, thisItemAllocateInventoryList); allocatedItemInventoryInfoResult.AddRange(thisItemAllocateInventoryList); } } } response.AllocateItemInventoryInfoList = allocatedItemInventoryInfoResult; if (response.AllocateItemInventoryInfoList.Count == 0) { response.AllocateResult = -1; } } return(response); }