Example #1
0
        /// <summary>
        /// 创建/更新 采购篮商品
        /// </summary>
        /// <param name="basketInfo"></param>
        /// <returns></returns>
        public virtual BasketItemsInfo SaveBasket(BasketItemsInfo basketInfo)
        {
            #region [Check 实体逻辑]
            //检查商品数量:
            if (!basketInfo.Quantity.HasValue || basketInfo.Quantity.Value == 0)
            {
                //{0}:该商品数量不能为空
                throw new BizException(string.Format(GetMessageString("Basket_ProductQtyEmpty"), basketInfo.ProductID));
            }
            if (!basketInfo.OrderPrice.HasValue)
            {
                //{0}:该商品结算价不能为空!
                throw new BizException(string.Format(GetMessageString("Basket_SettlePriceEmpty"), basketInfo.ProductID));
            }
            //商品编号:
            if (!basketInfo.ProductSysNo.HasValue || basketInfo.ProductSysNo == 0)
            {
                //{0}:该商品编号不能为空!
                throw new BizException(string.Format(GetMessageString("Basket_ItemSysNoEmpty"), basketInfo.ProductID));
            }
            //商品是否存在于采购篮中:
            else if (BasketDA.CheckProductHasExistInBasket(basketInfo))
            {
                //{0}:该商品已存在于采购篮中!
                throw new BizException(string.Format(GetMessageString("Basket_ItemExists"), basketInfo.ProductID));
            }
            #endregion

            //保存和更新操作:
            if (basketInfo.ItemSysNo == null || !basketInfo.ItemSysNo.HasValue || basketInfo.ItemSysNo.Value == 0)
            {
                //如果不存在SysNo,则为新建操作:
                basketInfo = BasketDA.CreateBasketItem(basketInfo);
                //写LOG:
                //CommonService.WriteLog<BasketItemEntity>(entity, " Created BaksetItem ", entity.SysNo.Value.ToString(), (int)LogType.PO_Basket_Insert);
                ExternalDomainBroker.CreateLog(" Created BaksetItem "
                                               , BizEntity.Common.BizLogType.Purchase_Basket_Insert
                                               , basketInfo.ItemSysNo.Value
                                               , basketInfo.CompanyCode);
            }
            else
            {
                basketInfo = BasketDA.UpdateBasketItem(basketInfo);
                //写LOG:
                //CommonService.WriteLog<BasketItemEntity>(entity, " Updated BaksetItem ", entity.SysNo.Value.ToString(), (int)LogType.PO_Basket_Update);

                ExternalDomainBroker.CreateLog(" Updated BaksetItem "
                                               , BizEntity.Common.BizLogType.Purchase_Basket_Update
                                               , basketInfo.ItemSysNo.Value
                                               , basketInfo.CompanyCode);
            }
            return(basketInfo);
        }
Example #2
0
        /// <summary>
        /// 批量更新采购篮商品
        /// </summary>
        /// <param name="itemList"></param>
        /// <returns></returns>
        public virtual List <BasketItemsInfo> BatchUpdateBasketItems(List <BasketItemsInfo> itemList)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                if (null != itemList && 0 < itemList.Count)
                {
                    foreach (BasketItemsInfo entity in itemList)
                    {
                        #region [Check 实体逻辑]

                        if (entity == null)
                        {
                            throw new ArgumentNullException("entity");
                        }

                        if (entity.ItemSysNo == 0)
                        {
                            //系统编号不能为空
                            throw new BizException(GetMessageString("Basket_SysNoEmpty"));
                        }

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

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

                        //目标分仓
                        if (!entity.StockSysNo.HasValue || entity.StockSysNo == 0)
                        {
                            //{0}:该商品目标分仓为空!
                            throw new BizException(string.Format(GetMessageString("Basket_StockEmpty"), entity.ProductSysNo.Value));
                        }

                        if (!entity.IsTransfer.HasValue)//是否中转
                        {
                            //{0}:该商品是否中转为空!
                            throw new BizException(string.Format(GetMessageString("Basket_TransferEmpty"), entity.ProductSysNo.Value));
                        }
                        #endregion
                        BasketDA.UpdateBasketItem(entity);
                    }
                }
                ts.Complete();
            }
            return(itemList);
        }