示例#1
0
        /// <summary>
        /// 采购篮添加赠品
        /// </summary>
        /// <param name="itemInfo"></param>
        /// <returns></returns>
        public virtual BasketItemsInfo CreateGiftForBasket(BasketItemsInfo itemInfo)
        {
            #region [Check 实体逻辑]
            if (!itemInfo.Quantity.HasValue || itemInfo.Quantity == 0)
            {
                //{0}:该商品数量不能为空!
                throw new BizException(string.Format(GetMessageString("Basket_ProductQtyEmpty"), itemInfo.ProductID));
            }

            if (!itemInfo.OrderPrice.HasValue)
            {
                //"{0}:该商品结算价不能为空!"
                throw new BizException(string.Format(GetMessageString("Basket_SettlePriceEmpty"), itemInfo.ProductID));
            }

            if (!itemInfo.ProductSysNo.HasValue || itemInfo.ProductSysNo == 0)
            {
                //{0}:该商品编号不能为空!
                throw new BizException(string.Format(GetMessageString("Basket_ItemSysNoEmpty"), itemInfo.ProductID));
            }

            if (itemInfo.ItemSysNo == null || !itemInfo.ItemSysNo.HasValue || itemInfo.ItemSysNo.Value == 0)
            {
                //如果ItemSysNo 为空,则为添加操作 :
                return(BasketDA.CreateBasketItemForPrepare(itemInfo));
            }
            else
            {
                return(BasketDA.UpdateBasketItemForGift(itemInfo));
            }
            #endregion
        }
示例#2
0
        /// <summary>
        /// 创建采购篮商品(备货中心用)
        /// </summary>
        /// <param name="prepareInfo"></param>
        /// <returns></returns>
        public virtual BasketItemsInfo CreateBasketItemForPrepare(BasketItemsInfo prepareInfo)
        {
            if (BasketDA.CheckProductHasExistInBasket(prepareInfo) && !prepareInfo.ItemSysNo.HasValue)
            {
                //添加采购篮中item记录是否重复判断条件:采购员,供应商,item,目标仓库
                //{0}:该商品已存在于采购篮中!
                throw new BizException(string.Format(GetMessageString("Basket_ItemExists"), prepareInfo.ProductID));
            }

            prepareInfo.LastVendorSysNo = BasketDA.GetVendorSysNoByProductNoAndStockSysNo(prepareInfo.ProductSysNo.Value, prepareInfo.StockSysNo.Value);

            #region [Check 实体逻辑]

            if (!prepareInfo.Quantity.HasValue || prepareInfo.Quantity == 0)
            {
                //{0}:该商品数量不能为空!
                throw new BizException(string.Format(GetMessageString("Basket_ProductQtyEmpty"), prepareInfo.ProductID));
            }

            if (!prepareInfo.OrderPrice.HasValue)
            {
                //{0}:该商品结算价不能为空!
                throw new BizException(string.Format(GetMessageString("Basket_SettlePriceEmpty"), prepareInfo.ProductID));
            }

            if (!prepareInfo.ProductSysNo.HasValue || prepareInfo.ProductSysNo == 0)
            {
                //{0}:该商品编号不能为空!
                throw new BizException(string.Format(GetMessageString("Basket_ItemSysNoEmpty"), prepareInfo.ProductID));
            }

            else if (BasketDA.CheckProductHasExistInBasket(prepareInfo) && !prepareInfo.ItemSysNo.HasValue)
            {
                //添加采购篮中item记录是否重复判断条件:采购员,供应商,item,目标仓库
                //{0}:该商品已存在于采购篮中!
                throw new BizException(string.Format(GetMessageString("Basket_ItemExists"), prepareInfo.ProductID));
            }
            #endregion

            //新建操作:
            prepareInfo = BasketDA.CreateBasketItemForPrepare(prepareInfo);
            //写LOG:
            // CommonService.WriteLog<BasketItemEntity>(entity, " Created BaksetItem For Prepare ", entity.SysNo.Value.ToString(), (int)LogType.PO_Basket_Insert);

            ExternalDomainBroker.CreateLog(" Created BaksetItem For Prepare "
                                           , BizEntity.Common.BizLogType.Purchase_Basket_Insert
                                           , prepareInfo.ItemSysNo.Value
                                           , prepareInfo.CompanyCode);

            return(prepareInfo);
        }
示例#3
0
        /// <summary>
        /// 验证导入的采购篮数据是否合法并创建采购篮
        /// </summary>
        /// <param name="itemList"></param>
        /// <returns></returns>
        public virtual List <BasketItemsInfo> BatchImportAndCreateBasketItem(List <BasketItemsInfo> itemList, bool isThrowException)
        {
            if (null == itemList || 0 == itemList.Count)
            {
                //没有需要导入的数据
                throw new BizException(GetMessageString("Basket_NoDataImport"));
            }
            foreach (var entity in itemList)
            {
                #region [Check实体逻辑]
                if (!entity.LastVendorSysNo.HasValue)
                {
                    //供应商编号无效
                    entity.ErrorMessage += GetMessageString("Basket_VendorSysNoInvalid");
                    if (isThrowException)
                    {
                        throw new BizException(GetMessageString("Basket_VendorSysNoInvalid"));
                    }
                }
                var vendor = VendorDA.LoadVendorInfo(entity.LastVendorSysNo.Value);


                if (vendor == null)
                {
                    //供应商无效
                    entity.ErrorMessage += GetMessageString("Basket_VendorInvalid");
                    if (isThrowException)
                    {
                        throw new BizException(GetMessageString("Basket_VendorInvalid"));
                    }
                }
                else
                {
                    entity.CompanyCode = vendor.CompanyCode;
                    entity.VendorSysNo = vendor.SysNo.Value;
                }

                if (!entity.Quantity.HasValue || entity.Quantity == 0)
                {
                    //{0}:该商品数量不能为空!
                    entity.ErrorMessage += string.Format(GetMessageString("Basket_ProductQtyEmpty"), entity.ProductID);
                    if (isThrowException)
                    {
                        throw new BizException(string.Format(GetMessageString("Basket_ProductQtyEmpty"), entity.ProductID));
                    }
                }

                if (!entity.OrderPrice.HasValue)
                {
                    //采购价格为空
                    entity.ErrorMessage += GetMessageString("Basket_PurchasePriceEmpty");
                    if (isThrowException)
                    {
                        throw new BizException(GetMessageString("Basket_PurchasePriceEmpty"));
                    }
                }

                entity.ProductSysNo = BasketDA.GetItemSysNoByItemID(entity.ProductID, entity.CompanyCode);

                if (!entity.ProductSysNo.HasValue || entity.ProductSysNo == 0)
                {
                    entity.ErrorMessage += GetMessageString("Basket_ProductSysNoInvalid");
                    if (isThrowException)
                    {
                        throw new BizException(GetMessageString("Basket_ProductSysNoInvalid"));
                    }
                }

                entity.StockSysNo = BasketDA.GetStockSysNoByName(entity.StockName, entity.CompanyCode);

                if (!entity.StockSysNo.HasValue || entity.StockSysNo == 0)
                {
                    entity.ErrorMessage += GetMessageString("Basket_StocknameInvalid");
                    if (isThrowException)
                    {
                        throw new BizException(GetMessageString("Basket_StocknameInvalid"));
                    }
                }

                if (BasketDA.CheckProductHasExistInBasket(entity) && !entity.ItemSysNo.HasValue)
                {
                    //添加采购篮中item记录是否重复判断条件:采购员,供应商,item,目标仓库
                    //{0}:该商品已存在于采购篮中!
                    entity.ErrorMessage += string.Format(GetMessageString("Basket_ItemExists"), entity.ProductID);
                    if (isThrowException)
                    {
                        throw new BizException(string.Format(GetMessageString("Basket_ItemExists"), entity.ProductID));
                    }
                }
                #endregion

                if (string.IsNullOrEmpty(entity.ErrorMessage))
                {
                    entity.ReadyQuantity = 0;
                    var resultEntity = BasketDA.CreateBasketItemForPrepare(entity);
                    //写LOG:
                    //CommonService.WriteLog<BasketItemEntity>(entity, " Batch Created BaksetItem ", entity.SysNo.Value.ToString(), (int)LogType.PO_Basket_Insert);

                    ExternalDomainBroker.CreateLog(" Batch Created BaksetItem "
                                                   , BizEntity.Common.BizLogType.Purchase_Basket_Insert
                                                   , entity.ItemSysNo.Value
                                                   , entity.CompanyCode);
                }
            }
            return(itemList);
        }