예제 #1
0
        /// <summary>
        /// 出库操作
        /// </summary>
        /// <param name="GoodsID"></param>
        /// <param name="InventoryID"></param>
        /// <param name="BatchNumber"></param>
        /// <param name="OutQuantity"></param>
        /// <param name="UserID"></param>
        public static void InventoryOut(int GoodsID, int InventoryID, string BatchNumber, int OutQuantity, long UserID)
        {
            // 当前库存信息
            InventoryEntity entity = InventoryService.GetInventoryEntityById(InventoryID);
            // 商品信息
            GoodsEntity goodsEntity = GoodsService.GetGoodsEntityById(GoodsID);

            if (entity != null && goodsEntity != null)
            {
                // 库存可用数量=库存数量-待出库数量
                int canQuantity = entity.Quantity - entity.WaitQuantity;
                if (canQuantity >= OutQuantity)
                {
                    entity.Quantity = canQuantity - OutQuantity;
                    // 商品库存扣减
                    OrderInventoryService.ModifyQuantity(entity);

                    //记录库存明细
                    createInventoryDetail(entity, goodsEntity, UserID);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 库存处理
        /// </summary>
        /// <param name="orderInfo"></param>
        private static void OutInventoryProcess(OrderEntity orderInfo)
        {
            List <OrderDetailEntity> orderDetailList = orderInfo.orderDetailList;

            if (orderDetailList != null && orderDetailList.Count > 0)
            {
                foreach (OrderDetailEntity entity in orderDetailList)
                {
                    List <InventoryEntity> inventoryList = new List <InventoryEntity>();
                    if (entity.InventoryID > 0)
                    {
                        inventoryList.Add(InventoryService.GetInventoryEntityById(entity.InventoryID));
                    }
                    //同商品+批次号+客户
                    else
                    {
                        inventoryList = InventoryService.GetInventoryByRule(entity.GoodsID, -1, entity.BatchNumber.Trim(), orderInfo.CustomerID, true);
                    }

                    inventoryInfoProcess(entity, inventoryList, orderInfo);
                }
            }
        }