public virtual SaleAdvertisementItem CreateItem(SaleAdvertisementItem entity) { if (entity == null) { throw new ArgumentNullException("entity"); } if (string.IsNullOrEmpty(entity.Introduction)) { entity.Introduction = null; } //UI上可以不选择Group,如果GroupSysNo写入DB为null的话则查不出来 if (entity.GroupSysNo == null) { entity.GroupName = null; entity.GroupSysNo = 0; } ProductInfo product = null; if (entity.ProductSysNo == null) { product = ExternalDomainBroker.GetProductInfo(entity.ProductID); } else { product = ExternalDomainBroker.GetProductInfo(entity.ProductSysNo.Value); } if (product == null) { //throw new BizException("商品无效!"); throw new BizException(ResouceManager.GetMessageString("MKT.SaleAdvertisement", "SaleAdvertisement_InvalidProduct")); } else { entity.MarketPrice = product.ProductPriceInfo.BasicPrice; entity.ProductSysNo = product.SysNo; entity.ProductID = product.ProductID; entity.ProductName = product.ProductName; entity.ProductStatus = product.ProductStatus; } if (da.CheckSaleAdvItemDuplicate(entity)) { //throw new BizException("你要创建或修改的记录已经存在了!"); throw new BizException(ResouceManager.GetMessageString("MKT.SaleAdvertisement", "SaleAdvertisement_RecordAreadyExsist")); } #warning To do 获取京东价 var inventoryInfo = ExternalDomainBroker.GetProductInventoryInfo(entity.ProductSysNo.Value); entity.OnlineQty = inventoryInfo.Sum(p => p.OnlineQty); entity.Status = ADStatus.Active; TransactionOptions options = new TransactionOptions(); options.IsolationLevel = IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope()) { da.CreateItem(entity); da.CreateSaleAdvItemLog(entity, "A"); scope.Complete(); } return(entity); }