/// <summary> /// 得到随心配的商品在团购里的毛利率 /// </summary> /// <param name="info"></param> /// <returns></returns> public string GetProductPromotionMarginByGroupBuying(GroupBuyingInfo info) { ProductInfo productInfo = ExternalDomainBroker.GetProductInfo(info.ProductSysNo.Value); ProductPriceRequestInfo priceMsg = new ProductPriceRequestInfo() { CurrentPrice = info.PriceRankList.OrderBy(s => s.DiscountValue).First().DiscountValue,//最低阶梯价格 UnitCost = productInfo.ProductPriceInfo.UnitCost, Point = info.GroupBuyingPoint, Category = productInfo.ProductBasicInfo.ProductCategoryInfo }; string returnMsgStr = string.Empty; StringBuilder checkMsg = new StringBuilder(); List <ProductPromotionMarginInfo> marginList = ObjectFactory <IIMBizInteract> .Instance.GetProductPromotionMargin( priceMsg, info.ProductSysNo.Value, "", 0m, ref returnMsgStr); marginList = marginList.Where(ppm => ppm.PromotionType == PromotionType.OptionalAccessories).ToList(); foreach (var mgInfo in marginList) { //checkMsg.Append(string.Format("此商品的最低阶梯价格在在随心配{0}中毛利率{1}%\r", mgInfo.ReferenceSysNo // , (Decimal.Round(mgInfo.Margin, 4) * 100m).ToString("0.00"))); checkMsg.Append(string.Format(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_LowestGrossMagin"), mgInfo.ReferenceSysNo , (Decimal.Round(mgInfo.Margin, 4) * 100m).ToString("0.00"))); } return(checkMsg.ToString()); }
//private SaleDiscountRulePromotionEngine _promotionEngine = ObjectFactory<SaleDiscountRulePromotionEngine>.Instance; public virtual SaleDiscountRule Load(int sysNo) { var result = _daSaleDiscountRule.Load(sysNo); if (result == null) { //throw new BizException(string.Format("系统编号为{0}的销售立减规则不存在。", sysNo)); throw new BizException(string.Format(ResouceManager.GetMessageString("MKT.SaleDiscountRule", "SaleDiscountRule_NotExistSaleDiscountRule"), sysNo)); } if (result.BrandSysNo > 0) { var brand = ExternalDomainBroker.GetBrandInfoBySysNo(result.BrandSysNo.Value); if (brand != null && brand.BrandNameLocal != null) { result.UIBrandName = brand.BrandNameLocal.Content; } } if (result.ProductSysNo > 0) { var productInfo = ExternalDomainBroker.GetProductInfo(result.ProductSysNo.Value); if (productInfo != null) { result.UIProductID = productInfo.ProductID; } } return(result); }
/// <summary> /// 加载 /// </summary> public virtual ProductRecommendInfo Load(int sysNo) { var result = _recommendDA.Load(sysNo); var productInfo = ExternalDomainBroker.GetProductInfo(result.ProductID); result.ProductSysNo = productInfo.SysNo; return(result); }
/// <summary> /// 回复邮件操作,并发送邮件 /// </summary> /// <param name="item"></param> public virtual void UpdateProductReviewMailLog(ProductReview item) { //保存邮件日志 if (!string.IsNullOrEmpty(item.ProductReviewMailLog.TopicMailContent.Content) || !string.IsNullOrEmpty(item.ProductReviewMailLog.CSNote.Content)) { if (productReviewMailLogDA.CheckProductCommentMailLog(item.ProductReviewMailLog)) { productReviewMailLogDA.UpdateProductCommentMailLog(item.ProductReviewMailLog); } else { productReviewMailLogDA.CreateProductCommentMailLog(item.ProductReviewMailLog); } } productReviewDA.UpdateProductReview(item); #region 发送邮件 KeyValueVariables replaceVariables = new KeyValueVariables(); ECCentral.BizEntity.IM.ProductInfo product = ExternalDomainBroker.GetProductInfo(item.ProductSysNo.Value); replaceVariables.AddKeyValue(@"ProductID", product.ProductID); replaceVariables.AddKeyValue(@"ProductName", product.ProductName); replaceVariables.AddKeyValue(@"ProductLink", item.ProductID); replaceVariables.AddKeyValue(@"Title", item.Title); replaceVariables.AddKeyValue(@"ProductContent", string.Format(ResouceManager.GetMessageString("MKT.Comment", "Comment_ProductReviewMailMainContent"), item.Prons, item.Cons, item.Service)); //replaceVariables.AddKeyValue(@"#InUser#", ServiceContext.Current.); //replaceVariables.AddKeyValue(@"#InDateAll#", DateTime.Now.ToString()); replaceVariables.AddKeyValue(@"InDateAll-Y", DateTime.Now.Year.ToString()); replaceVariables.AddKeyValue(@"InDateAll-M", DateTime.Now.Month.ToString()); replaceVariables.AddKeyValue(@"InDateAll-D", DateTime.Now.Day.ToString()); replaceVariables.AddKeyValue(@"EmailText", item.ProductReviewMailLog.TopicMailContent.Content); replaceVariables.AddKeyValue(@"All", DateTime.Now.ToString()); replaceVariables.AddKeyValue(@"InDate-Y", DateTime.Now.Year.ToString()); replaceVariables.AddKeyValue(@"InDate-M", DateTime.Now.Month.ToString()); replaceVariables.AddKeyValue(@"InDate-D", DateTime.Now.Day.ToString()); replaceVariables.AddKeyValue(@"Year", DateTime.Now.Year.ToString()); ECCentral.BizEntity.Customer.CustomerInfo customer = ExternalDomainBroker.GetCustomerInfo(item.CustomerSysNo.Value); replaceVariables.AddKeyValue(@"CustomerName", customer.BasicInfo.CustomerID); if (string.IsNullOrEmpty(customer.BasicInfo.Email)) { //throw new BizException("邮件地址为空!"); throw new BizException(ResouceManager.GetMessageString("MKT.ProductReview", "ProductReview_EmailNotNull")); } else { ECCentral.Service.Utility.EmailHelper.SendEmailByTemplate(customer.BasicInfo.Email, "MKT_ProductReviewMailContent", replaceVariables, false); } #endregion }
/// <summary> /// 获取指定商品当前时间生效的“厂商赠品”的赠品成本总和 /// Old Method:GetGiftAmount /// </summary> /// <param name="productSysNo"></param> /// <returns></returns> public virtual decimal GetSaleGiftCurrentAmountForVendor(int productSysNo) { decimal result = 0.00m; //取得指定商品所有的有效赠品及赠品数量 DataTable dt = _da.GetSaleGiftCurrentGiftProductsForVendor(productSysNo); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dt.Rows[i]; int giftProductSysNo = int.Parse(dr["ProductSysNo"].ToString()); int productCount = int.Parse(dr["ProductCount"].ToString()); ProductInfo product = ExternalDomainBroker.GetProductInfo(giftProductSysNo); result += Math.Round(productCount * product.ProductPriceInfo.UnitCost, 2); } } return(result); }
/// <summary> /// 获取指定商品,指定赠品活动的非“买满即赠”的赠品成本总和 -OK /// Old Method:GetCurrentGiftAmount /// </summary> /// <param name="productSysNo"></param> /// <returns></returns> public virtual decimal GetSaleGiftAmountForNotFull(int productSysNo, int saleGiftSysNo) { decimal result = 0.00m; //获取指定商品,指定赠品活动的非“买满即赠”的赠品及赠品数量 DataTable dt = _da.GetSaleGiftGiftProductsExcludeFull(productSysNo, saleGiftSysNo); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dt.Rows[i]; int giftProductSysNo = int.Parse(dr["ProductSysNo"].ToString()); int productCount = int.Parse(dr["ProductCount"].ToString()); ProductInfo product = ExternalDomainBroker.GetProductInfo(giftProductSysNo); result += Math.Round(productCount * product.ProductPriceInfo.CurrentPrice.Value, 2); } } return(result); }
public virtual BuyLimitRule Load(int sysNo) { var result = _daBuyLimitRule.Load(sysNo); if (result == null) { //throw new BizException(string.Format("系统编号为{0}的限购规则不存在。", sysNo)); throw new BizException(string.Format(ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_NotExistThisLimitRule"), sysNo)); } if (result.LimitType == LimitType.SingleProduct) { var productInfo = ExternalDomainBroker.GetProductInfo(result.ItemSysNo); if (productInfo != null) { result.UIProductID = productInfo.ProductID; } } return(result); }
/// <summary> /// 根据用户输入的商品信息构造一个ConfigItem /// </summary> /// <param name="item"></param> /// <returns></returns> public ComputerConfigItem BuildConfigItem(ComputerConfigItem item) { var foundProduct = ExternalDomainBroker.GetProductInfo(item.ProductSysNo.Value); if (foundProduct == null) { throw new BizException("商品不存在。"); } var partsCategoryList = _configDA.GetComputerPartsCategory(item.ComputerPartSysNo); if (!foundProduct.ProductBasicInfo.ProductCategoryInfo.SysNo.HasValue || !partsCategoryList.Exists(c => c == foundProduct.ProductBasicInfo.ProductCategoryInfo.SysNo.Value)) { throw new BizException(string.Format("商品{0}不在该组件的可选分类中,不能添加。", foundProduct.ProductID)); } if (foundProduct.ProductStatus != BizEntity.IM.ProductStatus.Active) { throw new BizException(string.Format("商品{0}不是上架状态,不能添加!。", foundProduct.ProductID)); } //填充商品详细 item.ProductID = foundProduct.ProductID; item.ProductName = foundProduct.ProductName; item.UnitCost = foundProduct.ProductPriceInfo.UnitCost; item.CurrentPrice = foundProduct.ProductPriceInfo.CurrentPrice; //填充库存信息 var foundInventory = ExternalDomainBroker.GetProductTotalInventoryInfo(item.ProductSysNo.Value); if (foundInventory != null) { if (foundInventory.OnlineQty <= 0) { throw new BizException(string.Format("商品{0}库存为零,不能添加!。", foundProduct.ProductID)); } item.OnlineQty = foundInventory.OnlineQty; } item.ProductQty = 1; item.Discount = 0; return(item); }
/// <summary> /// 更新产品Keywords0 /// </summary> /// <param name="item"></param> public virtual void UpdateProductPageKeywords(ProductPageKeywords item) { using (TransactionScope scope = new TransactionScope()) { keywordDA.UpdateProductPageKeywords(item); /*2012-12-31 update bug95058 jack.g.tang * 修改目的:ProductSysNo可能为null * 解决办法:为null时 根据productId取得ProducuSysNo */ int?productSysNo = item.ProductSysNo; if (item.ProductSysNo == null || item.ProductSysNo == 0) { productSysNo = ExternalDomainBroker.GetProductInfo(item.ProductId).SysNo; } ExternalDomainBroker.UpdateProductExKeyKeywords( (int)productSysNo, item.Keywords.ToString() , item.Keywords0.ToString(), ServiceContext.Current.UserSysNo, item.CompanyCode); scope.Complete(); } }
/// <summary> /// 获取指定商品,赠品池活动的非“买满即赠”的赠品成本总和 -OK /// Old Method:GetCurrentGiftAmount /// </summary> /// <param name="productSysNo"></param> /// <returns></returns> public virtual decimal GetSaleGiftAmountForFull(int productSysNo, int saleGiftSysNo, int ItemGiftCount) { decimal result = 0.00m; //获取指定商品,指定赠品活动的非“买满即赠”的赠品及赠品数量 DataTable dt = _da.GetSaleGiftGiftProductsExcludeFull(productSysNo, saleGiftSysNo); var productPrices = new List <decimal>(); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dt.Rows[i]; int giftProductSysNo = int.Parse(dr["ProductSysNo"].ToString()); ProductInfo product = ExternalDomainBroker.GetProductInfo(giftProductSysNo); productPrices.Add(product.ProductPriceInfo.CurrentPrice.Value); } } var price = productPrices.OrderByDescending(p => p).Take(ItemGiftCount).Sum(); return(price); }
public ProductPriceCompareEntity Load(int sysNo) { var productPriceCompare = _ProductPriceCompareDA.Load(sysNo); var productInfo = ExternalDomainBroker.GetProductInfo(productPriceCompare.ProductSysNo); if (productInfo != null) { productPriceCompare.ProductID = productInfo.ProductID; productPriceCompare.ProductName = productInfo.ProductBasicInfo.ProductBriefName; } var customerInfo = ExternalDomainBroker.GetCustomerInfo(productPriceCompare.CustomerSysNo); if (customerInfo != null) { productPriceCompare.CustomerID = customerInfo.BasicInfo.CustomerID; productPriceCompare.CustomerName = customerInfo.BasicInfo.CustomerName; productPriceCompare.CustomerEmail = customerInfo.BasicInfo.Email; } return(productPriceCompare); }
/// <summary> /// 回复邮件操作,并发送邮件 /// </summary> /// <param name="item"></param> public virtual void UpdateProductConsultMailLog(ProductReview item) { if (productReviewMailLogDA.CheckProductCommentMailLog(item.ProductReviewMailLog)) { productReviewMailLogDA.UpdateProductCommentMailLog(item.ProductReviewMailLog); } else { productReviewMailLogDA.CreateProductCommentMailLog(item.ProductReviewMailLog); } #region 发送邮件 KeyValueVariables replaceVariables = new KeyValueVariables(); ECCentral.BizEntity.IM.ProductInfo product = ExternalDomainBroker.GetProductInfo(item.ProductSysNo.Value); replaceVariables.AddKeyValue(@"ProductID", product.ProductID); replaceVariables.AddKeyValue(@"ProductName", product.ProductName); replaceVariables.AddKeyValue(@"Content", item.ProductReviewMailLog.Content); replaceVariables.AddKeyValue(@"EmailText", item.ProductReviewMailLog.TopicMailContent.Content); replaceVariables.AddKeyValue(@"All", DateTime.Now.ToString()); replaceVariables.AddKeyValue(@"InDate-Y", DateTime.Now.Year.ToString()); replaceVariables.AddKeyValue(@"InDate-M", DateTime.Now.Month.ToString()); replaceVariables.AddKeyValue(@"InDate-D", DateTime.Now.Day.ToString()); replaceVariables.AddKeyValue(@"Year", DateTime.Now.Year.ToString()); ECCentral.BizEntity.Customer.CustomerInfo customer = ExternalDomainBroker.GetCustomerInfo(item.CustomerSysNo.Value); replaceVariables.AddKeyValue(@"CustomerName", customer.BasicInfo.CustomerID); if (string.IsNullOrEmpty(customer.BasicInfo.Email)) { throw new BizException("邮件地址为空!"); } else { ECCentral.Service.Utility.EmailHelper.SendEmailByTemplate(customer.BasicInfo.Email, "MKT_ProductConsultMailContent", replaceVariables, false); } #endregion }
/// <summary> /// 加载 /// </summary> /// <param name="sysNo"></param> /// <returns></returns> public GroupBuyingInfo Load(int?sysNo) { var result = m_GroupBuyingDA.Load(sysNo.Value); if (result == null) { //throw new BizException("团购信息不存在!"); throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_NotExsitGroupBuyInfo")); } if (result.ProductSysNo > 0) { var product = ExternalDomainBroker.GetProductInfo(result.ProductSysNo.Value); result.BasicPrice = product.ProductPriceInfo.BasicPrice; List <object> oPriceList = m_GroupBuyingDA.GetProductOriginalPrice(product.SysNo, result.IsByGroup ?? false ? "Y" : "N", result.CompanyCode); //result.OriginalPrice = (oPriceList == null || oPriceList[0] == null // ? 0m : decimal.Round(decimal.Parse(oPriceList[0].ToString()), 2)); } if (result.CategoryType == GroupBuyingCategoryType.Virtual) { result.VendorStoreSysNoList = m_GroupBuyingDA.GetGroupBuyingVendorStores(result.SysNo.Value); } return(result); }
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); }
private void ValidateCommon(ComputerConfigMaster entity) { entity.SysNo = entity.SysNo ?? 0; if (entity.ComputerConfigTypeSysNo <= 0) { throw new BizException("请选择配置单类型!"); } if (string.IsNullOrEmpty(entity.ComputerConfigName)) { throw new BizException("配置单名称不能为空!"); } if (string.IsNullOrEmpty(entity.Note)) { throw new BizException("配置单说明不能为空!"); } if (entity.Priority < 0) { throw new BizException("配置单优先级必须>=0!"); } if (entity.ConfigItemList == null || entity.ConfigItemList.Count == 0) { throw new BizException("配置单商品信息列表不能为空!"); } int duplicateCount = _configDA.CountComputerConfigName(entity.SysNo.Value, entity.ComputerConfigName, entity.CompanyCode, entity.WebChannel.ChannelID); if (duplicateCount > 0) { throw new BizException("配置单名称已存在,请验证。"); } decimal totalDiscountPrice = 0M; foreach (ComputerConfigItem configItem in entity.ConfigItemList) { var product = ExternalDomainBroker.GetProductInfo(configItem.ProductSysNo.Value); if (product == null) { throw new BizException(string.Format("商品{0}不存在。", configItem.ProductSysNo)); } if (configItem.ProductQty <= 0) { throw new BizException("商品购买数量未填写或输入有误!"); } if (configItem.Discount > 0) { throw new BizException("商品折扣未填写或输入有误!"); } if (configItem.OnlineQty <= 0 || configItem.ProductQty > configItem.OnlineQty) { throw new BizException(configItem.ComputerPartName + "商品库存不足!"); } totalDiscountPrice += ObjectFactory <IIMBizInteract> .Instance.GetProductMarginAmount( configItem.CurrentPrice.Value + configItem.Discount, 0, configItem.UnitCost) * configItem.ProductQty; } if (totalDiscountPrice < 0) { if (entity.Status != ComputerConfigStatus.Pending) { throw new BizException("配置单折扣价毛利率低于基准毛利率,请提交审核!"); } } else if (entity.Status == ComputerConfigStatus.Pending) { throw new BizException("不需要审核,请直接保存!"); } ValidateMustParts(entity); //如果通过所有Check, 且提交状态为初始‘O’,则直接运行‘A’ if (entity.Status == ComputerConfigStatus.Origin) { entity.Status = ComputerConfigStatus.Running; } }
private void CheckData(BuyLimitRule data) { int sysNo = data.SysNo ?? 0; if (data.LimitType == LimitType.Combo) { //1.验证套餐是否存在 var combo = ObjectFactory <ComboProcessor> .Instance.Load(data.ItemSysNo); if (combo == null) { throw new BizException(string.Format(ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_NotExistThisGroupBuy"), data.ItemSysNo)); } //2.验证套餐是否已存在规则设置 //CheckExistsRule(LimitType.Combo, "该套餐已存在相关限购规则,请不要重复设置。" // , sysNo, data.ItemSysNo); CheckExistsRule(LimitType.Combo, ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_ExisitThisLimitRuleForGroupBuy") , sysNo, data.ItemSysNo); } else { //1.验证商品是否存在 var product = ExternalDomainBroker.GetProductInfo(data.ItemSysNo); if (product == null) { //throw new BizException("商品不存在。"); throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_NotExistProduct")); } //2.验证商品或其所属商品组是否已存在规则设置 var productInGroup = ExternalDomainBroker.GetProductsInSameGroupWithProductSysNo(data.ItemSysNo); List <int> productSysNos = new List <int>(0); if (productInGroup != null && productInGroup.Count > 0) { productSysNos = productInGroup.Select(item => item.SysNo).ToList(); } else { productSysNos.Add(data.ItemSysNo); } //CheckExistsRule(LimitType.SingleProduct, "该单品或其所属商品组已存在相关限购规则,请不要重复设置。" // , sysNo, productSysNos.ToArray()); CheckExistsRule(LimitType.SingleProduct, ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_ExisitThisLimitRuleForProduct") , sysNo, productSysNos.ToArray()); } if (data.EndDate <= data.BeginDate) { //throw new BizException("结束时间必须大于开始时间。"); throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_EndDateNeedMoreThanStartDate")); } if (data.EndDate.HasValue && data.EndDate.Value <= DateTime.Now) { //throw new BizException("结束时间必须大于当前时间。"); throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_EndDateNeedMoreThanCurrentDate")); } if (data.MinQty < 0) { //throw new BizException("限购下限必须大于等于零。"); throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_LowerLimitNeedMoreThan0")); } if (data.MaxQty < 0) { //throw new BizException("限购上限必须大于等于零。"); throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_UpperLimitNeedMoreThan0")); } if (data.MaxQty < data.MinQty) { //throw new BizException("限购上限必须大于等于限购下限"); throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_UpperLimitNeedMoreThanLowerLimit")); } if (data.OrderTimes < 0) { //throw new BizException("当日限购次数必须大于等于零。"); throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_LimitCountNeedMoreThan0InCurrentDay")); } }
/// <summary> /// 获取指定商品类别下最小毛利 /// </summary> /// <param name="itemSysNo"></param> /// <param name="minMargin"></param> public virtual decimal GetCategoryMinGrossMarginRate(int productSysNo) { ProductInfo product = ExternalDomainBroker.GetProductInfo(productSysNo); return(GetCategoryMinGrossMarginRate(product)); }
private void Validate(ProductRecommendInfo entity) { //大于等于100的PageType是首页Domain馆,对应的PageID应置为0 if (entity.Location.PageType >= 100) { entity.Location.PageID = 0; } //如果PageID为空,则置为0 if (!entity.Location.PageID.HasValue) { entity.Location.PageID = 0; } if (entity.BeginDate == DateTime.MinValue) { entity.BeginDate = null; } if (entity.EndDate == DateTime.MinValue) { entity.EndDate = null; } //验证商品状态必须为show ProductInfo product = ExternalDomainBroker.GetProductInfo(entity.ProductID); if (product == null) { //throw new BizException("商品不存在。"); throw new BizException(ResouceManager.GetMessageString("MKT.ProductRecommend", "ProductRecommend_ProductNotExists")); } if (product.ProductStatus != ProductStatus.Active) { //throw new BizException("商品状态必须为上架状态。"); throw new BizException(ResouceManager.GetMessageString("MKT.ProductRecommend", "ProductRecommend_ProductStatusNotValid")); } ////验证商品必须有库存OnlineQty>0 //var inventory = ExternalDomainBroker.GetProductTotalInventoryInfo(entity.ProductSysNo); //if (inventory.OnlineQty <= 0) //{ // throw new BizException("商品库存不足。"); //} //如果是首页新品推荐,验证商品FirstOnlineTime不能大于1天 bool isNewRecommend = PageTypeUtil.IsProductRecommendHomePageNewPosition(entity.Location.PageType, entity.Location.PageID, entity.Location.PositionID); if (isNewRecommend) { if (!product.FirstOnSaleDate.HasValue || product.FirstOnSaleDate.Value < DateTime.Parse(DateTime.Now.AddDays(-1).ToLongDateString() + " 00:00:01")) { //throw new BizException("请选择上架时间小于1天的商品进行维护。"); throw new BizException(ResouceManager.GetMessageString("MKT.ProductRecommend", "ProductRecommend_ProductOnlineTimeInvalid")); } } //8.PageType=4,当类型是专卖店时判断description是否有重复的 var presentationType = PageTypeUtil.ResolvePresentationType(ModuleType.ProductRecommend, entity.Location.PageType.ToString()); //如果是专卖店,判断description是否有重复的 if (presentationType == PageTypePresentationType.Brand) { if (product.ProductBasicInfo.ProductBrandInfo.SysNo != entity.Location.PageID) { //throw new BizException("该产品不属于所选专卖店。"); throw new BizException(ResouceManager.GetMessageString("MKT.ProductRecommend", "ProductRecommend_ProductBrandInvalid")); } if (_recommendDA.ExitsSameDescription(entity.Location) > 0) { // throw new BizException("已存在相同的模块名称。"); throw new BizException(ResouceManager.GetMessageString("MKT.ProductRecommend", "ProductRecommend_ExistsSameModuleName")); } } //如果是品牌专属或类别专属 else if (presentationType == PageTypePresentationType.BrandExclusive) { if (product.ProductBasicInfo.ProductBrandInfo.SysNo != entity.Location.PageID) { //throw new BizException("该产品不属于所选专卖店。"); throw new BizException(ResouceManager.GetMessageString("MKT.ProductRecommend", "ProductRecommend_ProductBrandInvalid")); } } else if (presentationType == PageTypePresentationType.Merchant) { if (product.Merchant.MerchantID != entity.Location.PageID) { //throw new BizException("该产品不属于所选商家。"); throw new BizException(ResouceManager.GetMessageString("MKT.ProductRecommend", "ProductRecommend_ProductMerchantInvalid")); } } else if (presentationType == PageTypePresentationType.Category3) { //-1表示默认类别,即不指定任何分类 if (entity.Location.PageID.Value != -1) { var ecC3 = ObjectFactory <ECCategoryProcessor> .Instance.Load(entity.Location.PageID.Value); if (ecC3 == null || !ecC3.C3SysNo.HasValue) { //throw new BizException("请选择产品三级分类!"); throw new BizException(ResouceManager.GetMessageString("MKT.ProductRecommend", "ProductRecommend_Category3NotNull")); } if (product.ProductBasicInfo.ProductCategoryInfo.SysNo != ecC3.C3SysNo) { //throw new BizException("该产品不属于所选分类。"); throw new BizException(ResouceManager.GetMessageString("MKT.ProductRecommend", "ProductRecommend_ProductCategoryInvalid")); } } } if (CheckExists(entity)) { //throw new BizException("已经存在同一位置同一时期的商品,请更换后重试。"); throw new BizException(ResouceManager.GetMessageString("MKT.ProductRecommend", "ProductRecommend_ExistsSameProductRecommend")); } }
/// <summary> /// 获取指定商品的库龄高级毛利率下限 /// </summary> /// <param name="productSysNo"></param> /// <returns></returns> public virtual decimal GetStockSeniorGrossMarginRate(int productSysNo) { ProductInfo product = ExternalDomainBroker.GetProductInfo(productSysNo); return(GetStockGrossMarginRate(product, false)); }
/// <summary> /// 指定活动,指定商品的“PM-产品优惠券”的折扣金额 /// Old Method:GetCurrentCouponAmount /// </summary> /// <param name="productSysNo"></param> /// <param name="couponSysNo"></param> /// <returns></returns> public virtual decimal GetCouponAmountForPM(int productSysNo, int couponSysNo) { ProductInfo product = ExternalDomainBroker.GetProductInfo(productSysNo); return(GetCouponAmountForPM(product, couponSysNo)); }