private BatchCreateGiftRuleInfo CreateGiftRules(BatchCreateGiftRuleInfo info) { string msg = string.Empty; int special = 0;//是否特殊规则1是0否 SaleGiftInfo g = _SaleGiftDA.Load(info.PromotionSysNo); int vendorsysno = g.VendorSysNo.Value; if (g.VendorType == 0) { vendorsysno = 1; } CheckGiftRules(info); foreach (ProductItemInfo entity in info.ProductList) { //只有状态为2(不展示)的赠品才允许插入 if (entity.ProductStatus == ProductStatus.InActive_UnShow) { int count = _BatchCreateSaleGiftDA.CheckGiftRulesForVendor(entity.ProductSysNo, g.Type == SaleGiftType.Vendor?true:false, info.CompanyCode); if (count > 0) { //msg += string.Format("赠品{0}[#:{1}]存在有效记录 ", entity.ProductName, entity.ProductID); msg += string.Format(ResouceManager.GetMessageString("MKT.Promotion.SaleGift", "SaleGift_AlreadyExsistActiceRecord"), entity.ProductName, entity.ProductID); continue; } //判断是否为附件 bool isAttachment = ExternalDomainBroker.CheckIsAttachment(entity.ProductSysNo.Value); if (isAttachment) { //msg += string.Format("商品{0}[#:{1}]已经设置成附件,不能设置为赠品 ", entity.ProductName,entity.ProductID); msg += string.Format(ResouceManager.GetMessageString("MKT.Promotion.SaleGift", "SaleGift_AccessoryCannotBeGift"), entity.ProductName, entity.ProductID); continue; } //如果是赠品池,把赠送数量置为NULL if (info.GiftComboType == SaleGiftGiftItemType.GiftPool) { entity.HandselQty = null; } _BatchCreateSaleGiftDA.CreateGiftRules(entity, info); } else { //msg += string.Format("赠品{0}[#:{1}]必须为不展示状态 ", entity.ProductName, entity.ProductID); msg += string.Format(ResouceManager.GetMessageString("MKT.Promotion.SaleGift", "SaleGift_AccessoryCannotBeGift"), entity.ProductName, entity.ProductID); } //检查不能添加其他商家的商品 if (entity.ProductSysNo.HasValue) { int productvendorsysno = _da.GetVendorSysNoByProductSysNo(entity.ProductSysNo.Value); if (productvendorsysno != vendorsysno) { //msg += string.Format("赠品信息中{0}不能添加其他商家的商品【{1}】 ", g.VendorName, entity.ProductID); msg += string.Format(ResouceManager.GetMessageString("MKT.Promotion.SaleGift", "SaleGift_AccessoryCannotBeGift"), entity.ProductName, entity.ProductID); } } } if (msg != string.Empty) { throw new BizException(msg); } else { _BatchCreateSaleGiftDA.UpdateItemGiftCouontGiftRules(info.PromotionSysNo, (info.GiftComboType == SaleGiftGiftItemType.AssignGift ? null : info.SumCount), info.GiftComboType.Value, info.CompanyCode, info.InUser, special); } return(info); }