Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
        }