Example #1
0
 public virtual void CancleTopItem(List <TopItemInfo> list)
 {
     if (list.Count > 0)
     {
         using (TransactionScope scope = new TransactionScope())
         {
             list.ForEach(entity =>
             {
                 List <TopItemInfo> waitingHandleList = new List <TopItemInfo>();
                 waitingHandleList.Add(entity);
                 PageTypePresentationType currentType = PageTypeUtil.ResolvePresentationType(ModuleType.TopItem, entity.CategoryType.Value.ToString());
                 if (currentType == PageTypePresentationType.Category3 && entity.IsExtend.HasValue && entity.IsExtend.Value)
                 {
                     //处理扩展生效
                     var extendlist = ObjectFactory <ECCategoryProcessor> .Instance.GetRelatedECCategory3SysNo(entity.CategorySysNo.Value);
                     foreach (var item in extendlist)
                     {
                         entity.CategorySysNo = item.SysNo;
                         waitingHandleList.Add(entity);
                     }
                 }
                 waitingHandleList.ForEach(item =>
                 {
                     ObjectFactory <ITopItemDA> .Instance.DeleteTopItem(item);
                 });
             });
             scope.Complete();
         }
         ReSetPriority(list[0].CategoryType.Value, list[0].CategorySysNo.Value);
     }
 }
        /// <summary>
        /// 添加默认关键字
        /// </summary>
        /// <param name="item"></param>
        public virtual void AddDefaultKeywords(DefaultKeywordsInfo item)
        {
            //创建时默认SysNo为0,用于CheckDuplicate
            item.SysNo = 0;
            ValidateEntity(item);
            using (TransactionScope ts = new TransactionScope())
            {
                _defaultKeywordDA.AddDefaultKeywords(item);
                if (item.PageType.HasValue && item.PageID.HasValue)
                {
                    var pType = PageTypeUtil.ResolvePresentationType(ModuleType.DefaultKeywords, item.PageType.ToString());
                    //处理扩展生效
                    if (pType == PageTypePresentationType.Category3 && item.Extend == true)
                    {
                        var relatedECCategory3List = ObjectFactory <IECCategoryDA> .Instance.GetRelatedECCategory3SysNo(item.PageID.Value);

                        foreach (var rc3 in relatedECCategory3List)
                        {
                            item.PageID = rc3.C3SysNo;
                            if (!_defaultKeywordDA.CheckDuplicate(item))
                            {
                                _defaultKeywordDA.AddDefaultKeywords(item);
                            }
                        }
                    }
                }
                ts.Complete();
            }
        }
        public virtual List <CodeNamePair> GetProductRecommendPosition(string pageTypeID)
        {
            int pageType         = int.Parse(pageTypeID);
            var presentationType = PageTypeUtil.ResolvePresentationType(ModuleType.ProductRecommend, pageTypeID);
            //if (presentationType == PageTypePresentationType.Brand)
            //{
            //    //当PageType为专卖店时返回空,专卖店有特殊的加载位置信息的逻辑
            //    return new List<CodeNamePair>();
            //}

            //商品推荐位置Key格式:ProductRecommend+[PageTypeID],比如ProductRecommend0代表首页的推荐位
            var positionConfigKey = ModuleType.ProductRecommend.ToString();

            //if (pageType > 100)
            //{
            //    //PageTypeID>100表示是首页domain馆
            //    positionConfigKey += "-DomainList";
            //}
            //else
            //{
            positionConfigKey += pageType.ToString();
            //}

            var result = CodeNamePairManager.GetList("MKT", positionConfigKey);

            return(result);
        }
Example #4
0
 void ucPosition_PageTypeSelectionChanged(object sender, UserControls.PageTypeSelectionChangedEventArgs e)
 {
     if (ucPosition.PageType != null)
     {
         PageTypePresentationType type = PageTypeUtil.ResolvePresentationType(ModuleType.NewsAndBulletin, ucPosition.PageType.Value.ToString());
         this.chkIsExtend.IsEnabled = type == PageTypePresentationType.Category3;
         this.chkIsExtend.IsChecked = false;
     }
 }
 void ucPosition_PageTypeSelectionChanged(object sender, PageTypeSelectionChangedEventArgs e)
 {
     if (ucPosition.PageType.HasValue)
     {
         PageTypePresentationType type = PageTypeUtil.ResolvePresentationType(ModuleType.NewsAndBulletin, ucPosition.PageType.Value.ToString());
         this.ckbIsHomePageShow.Visibility = (type == PageTypePresentationType.Category1 || type == PageTypePresentationType.Category2 || type == PageTypePresentationType.Category3) ? Visibility.Visible : Visibility.Collapsed;
         this.ckbIsC1Show.Visibility       = (type == PageTypePresentationType.Category2 || type == PageTypePresentationType.Category3) ? Visibility.Visible : Visibility.Collapsed;
         this.ckbIsC2Show.Visibility       = (type == PageTypePresentationType.Category3) ? Visibility.Visible : Visibility.Collapsed;
     }
 }
Example #6
0
        public virtual QueryResult QueryHotKeywords(HotKeywordsQueryFilter filter)
        {
            int totalCount;
            var dataTable = ObjectFactory <IHotKeywordsQueryDA> .Instance.QueryHotKeywords(filter, out totalCount);

            List <CodeNamePair> pair = ObjectFactory <PageTypeAppService> .Instance.GetPageType(filter.CompanyCode, filter.ChannelID.ToString(), ModuleType.HotKeywords);

            List <ECCategory> category1List = ObjectFactory <IECCategoryQueryDA> .Instance.GetAllECCategory1(filter.CompanyCode, filter.ChannelID.ToString());

            List <ECCategory> category3List = ObjectFactory <IECCategoryQueryDA> .Instance.GetAllECCategory3(filter.CompanyCode, filter.ChannelID.ToString());

            foreach (DataRow dr in dataTable.Rows)
            {
                PageTypePresentationType pageTypePresentationType = PageTypeUtil.ResolvePresentationType(ModuleType.HotKeywords, dr["PageType"].ToString());
                switch (pageTypePresentationType)
                {
                case PageTypePresentationType.Category1:
                    dr["PageIDName"] = category1List.SingleOrDefault(a => a.SysNo.Value == int.Parse(dr["PageID"].ToString())).Name;
                    break;

                case PageTypePresentationType.Category3:
                    dr["PageIDName"] = category3List.SingleOrDefault(a => a.SysNo.Value == int.Parse(dr["PageID"].ToString())).Name;
                    break;

                default:
                    PageResult pr = ObjectFactory <PageTypeAppService> .Instance.GetPage(filter.CompanyCode, filter.ChannelID.ToString(), ModuleType.HotKeywords, dr["PageType"].ToString());

                    if (pr.PageList != null && pr.PageList.Count > 0)
                    {
                        dr["PageIDName"] = pr.PageList.SingleOrDefault(a => a.ID.Value == int.Parse(dr["PageID"].ToString())).PageName;
                    }
                    break;
                }
            }

            return(new QueryResult()
            {
                Data = dataTable,
                TotalCount = totalCount
            });
        }
Example #7
0
        //通过前台3级类别找到对应的后台3级类别,
        //然后把与后台3级类别对用的所有前台3级类别找出来,所有类别都插入记录
        private void ProcessECCategory3Extend(ProductRecommendInfo entity)
        {
            var presentationType = PageTypeUtil.ResolvePresentationType(ModuleType.ProductRecommend, entity.Location.PageType.Value.ToString());

            if (entity.IsExtendValid && entity.Status == ADStatus.Active &&
                presentationType == PageTypePresentationType.Category3 &&
                entity.Location.PageID != -1)
            {
                var relatedECCategory3List = ObjectFactory <IECCategoryDA> .Instance.GetRelatedECCategory3SysNo(entity.Location.PageID.Value);

                foreach (var c3 in relatedECCategory3List)
                {
                    entity.Location.PageID = c3.SysNo;

                    if (!CheckExists(entity))
                    {
                        CreateProductRecommend(entity);
                    }
                }
            }
        }
Example #8
0
        public virtual void SetTopItem(TopItemInfo entity)
        {
            Dictionary <int, int> affectCategory = new Dictionary <int, int>();//用于排重

            affectCategory.Add(entity.CategorySysNo.Value, 0);
            //扩展生效的处理
            if (entity.IsExtend.HasValue && entity.IsExtend.Value)
            {
                PageTypePresentationType currentType = PageTypeUtil.ResolvePresentationType(ModuleType.TopItem, entity.CategoryType.Value.ToString());
                if (currentType == PageTypePresentationType.Category3)
                {
                    var sameC3List = ObjectFactory <ECCategoryProcessor> .Instance.GetRelatedECCategory3SysNo(entity.CategorySysNo.Value);

                    sameC3List.ForEach(item =>
                    {
                        affectCategory.Add(item.SysNo.Value, 0);
                    });
                }
            }
            using (TransactionScope scope = new TransactionScope())
            {
                foreach (var item in affectCategory)
                {
                    entity.CategorySysNo = item.Key;
                    var orgain = ObjectFactory <ITopItemDA> .Instance.QueryTopItem(entity.CategoryType.Value, entity.CategorySysNo.Value);

                    if (orgain != null && orgain.Where(p => p.ProductSysNo.Value == entity.ProductSysNo).Count() > 0)
                    {
                        ObjectFactory <ITopItemDA> .Instance.UpdateTopItemPriority(entity);
                    }
                    else
                    {
                        ObjectFactory <ITopItemDA> .Instance.CreateTopItem(entity);
                    }
                }
                ReSetPriority(entity.CategoryType.Value, entity.CategorySysNo.Value);
                scope.Complete();
            }
        }
Example #9
0
        public System.Data.DataTable QueryTopItem(QueryFilter.MKT.TopItemFilter filter, out int totalCount)
        {
            PagingInfoEntity pagingEntity = new PagingInfoEntity();

            pagingEntity.SortField     = filter.PageInfo.SortBy;
            pagingEntity.MaximumRows   = filter.PageInfo.PageSize;
            pagingEntity.StartRowIndex = filter.PageInfo.PageIndex * filter.PageInfo.PageSize;

            var cmd = DataCommandManager.CreateCustomDataCommandFromConfig("TopItemList_Query");

            cmd.SetParameterValue("@FrontPageSize", filter.FrontPageSize);
            cmd.SetParameterValue("@CategoryType", filter.PageType);
            using (var sqlBuilder = new DynamicQuerySqlBuilder(cmd.CommandText, cmd, pagingEntity, "OrderPriority ASC,CreateTime DESC"))
            {
                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "A.[Status]", DbType.String, "@Status", QueryConditionOperatorType.Equal, 1);
                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "A.[ProductType]", DbType.String, "@ProductType", QueryConditionOperatorType.Equal, 0);
                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "C.C1SysNo", DbType.String, "@C1SysNo", QueryConditionOperatorType.Equal, filter.C1SysNo);
                if (filter.PageType.HasValue)
                {
                    PageTypePresentationType pType = PageTypeUtil.ResolvePresentationType(ModuleType.TopItem, filter.PageType.Value.ToString());
                    if (pType == PageTypePresentationType.Category2)
                    {
                        sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "C.C2SysNo", DbType.String, "@C2SysNo", QueryConditionOperatorType.Equal, filter.RefSysNo);
                    }
                    else if (pType == PageTypePresentationType.Category3)
                    {
                        sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "C.C3SysNo", DbType.String, "@C3SysNo", QueryConditionOperatorType.Equal, filter.RefSysNo);
                    }
                }
                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "A.[ProductID]", DbType.String, "@ProductID", QueryConditionOperatorType.Equal, filter.ProductID);
                cmd.CommandText = sqlBuilder.BuildQuerySql();
                DataTable dt = cmd.ExecuteDataTable();
                totalCount = Convert.ToInt32(cmd.GetParameterValue("@TotalCount"));
                return(dt);
            }
        }
        public DataTable Query(ProductRecommendQueryFilter filter, out int totalCount)
        {
            PagingInfoEntity pagingEntity = new PagingInfoEntity();

            pagingEntity.SortField     = filter.PagingInfo.SortBy;
            pagingEntity.MaximumRows   = filter.PagingInfo.PageSize;
            pagingEntity.StartRowIndex = filter.PagingInfo.PageIndex * filter.PagingInfo.PageSize;

            var cmd = DataCommandManager.CreateCustomDataCommandFromConfig("ProductRecommend_Query");

            using (var sqlBuilder = new DynamicQuerySqlBuilder(cmd.CommandText, cmd, pagingEntity, "result.[SysNo] DESC"))
            {
                //商品ID
                sqlBuilder.ConditionConstructor.AddCondition(
                    QueryConditionRelationType.AND,
                    "IC.ProductID",
                    DbType.String,
                    "@ProductID",
                    QueryConditionOperatorType.Equal,
                    filter.ProductID);

                //商品系统编号
                sqlBuilder.ConditionConstructor.AddCondition(
                    QueryConditionRelationType.AND,
                    "IC.SysNo",
                    DbType.Int32,
                    "@SysNo",
                    QueryConditionOperatorType.Equal,
                    filter.ProductSysNo);
                if (filter.ProductStatus.HasValue)
                {
                    sqlBuilder.ConditionConstructor.AddCondition(
                        QueryConditionRelationType.AND,
                        "IC.Status",
                        DbType.Int32,
                        "@ProductStatus",
                        QueryConditionOperatorType.Equal,
                        filter.ProductStatus.Value);
                }

                //状态
                sqlBuilder.ConditionConstructor.AddCondition(
                    QueryConditionRelationType.AND,
                    "A.Status",
                    DbType.AnsiStringFixedLength,
                    "@AStatus",
                    QueryConditionOperatorType.Equal,
                    filter.Status);

                #region PageType,PageID,PositionID相关

                //位置编号
                sqlBuilder.ConditionConstructor.AddCondition(
                    QueryConditionRelationType.AND,
                    "B.PositionID",
                    DbType.Int32,
                    "@PositionID",
                    QueryConditionOperatorType.Equal,
                    filter.PositionID);

                if (filter.PageType.HasValue)
                {
                    //页面类型
                    sqlBuilder.ConditionConstructor.AddCondition(
                        QueryConditionRelationType.AND,
                        "B.PageType",
                        DbType.Int32,
                        "@PageType",
                        QueryConditionOperatorType.Equal,
                        filter.PageType);

                    PageTypePresentationType pType = PageTypeUtil.ResolvePresentationType(ModuleType.ProductRecommend, filter.PageType.Value.ToString());
                    if (pType == PageTypePresentationType.Merchant && filter.PageID == 1)
                    {
                        //特殊商家
                        sqlBuilder.ConditionConstructor.AddCondition(
                            QueryConditionRelationType.AND,
                            "V.VendorType",
                            DbType.Int32,
                            "@VendorType",
                            QueryConditionOperatorType.Equal,
                            0);
                    }
                    else if (pType == PageTypePresentationType.Category1)
                    {
                        sqlBuilder.ConditionConstructor.AddCondition(
                            QueryConditionRelationType.AND,
                            "C3.[C1Sysno]",
                            DbType.Int32,
                            "@C1Sysno",
                            QueryConditionOperatorType.Equal,
                            filter.PageID);
                    }
                    else if (pType == PageTypePresentationType.Category2)
                    {
                        sqlBuilder.ConditionConstructor.AddCondition(
                            QueryConditionRelationType.AND,
                            "C3.[C2Sysno]",
                            DbType.Int32,
                            "@C2Sysno",
                            QueryConditionOperatorType.Equal,
                            filter.PageID);
                    }
                    else if (pType == PageTypePresentationType.Category3)
                    {
                        sqlBuilder.ConditionConstructor.AddCondition(
                            QueryConditionRelationType.AND,
                            "C3.[C3SysNo]",
                            DbType.Int32,
                            "@C3Sysno",
                            QueryConditionOperatorType.Equal,
                            filter.PageID);
                    }
                    else
                    {
                        sqlBuilder.ConditionConstructor.AddCondition(
                            QueryConditionRelationType.AND,
                            "B.PageID",
                            DbType.Int32,
                            "@PageID",
                            QueryConditionOperatorType.Equal,
                            filter.PageID);
                    }
                }
                #endregion

                sqlBuilder.ConditionConstructor.AddCondition(
                    QueryConditionRelationType.AND,
                    "A.BeginDate",
                    DbType.DateTime,
                    "@BeginDateFrom",
                    QueryConditionOperatorType.MoreThanOrEqual,
                    filter.BeginDateFrom);

                sqlBuilder.ConditionConstructor.AddCondition(
                    QueryConditionRelationType.AND,
                    "A.BeginDate",
                    DbType.DateTime,
                    "@BeginDateTo",
                    QueryConditionOperatorType.LessThan,
                    filter.BeginDateTo);

                sqlBuilder.ConditionConstructor.AddCondition(
                    QueryConditionRelationType.AND,
                    "A.EndDate",
                    DbType.DateTime,
                    "@EndDateFrom",
                    QueryConditionOperatorType.MoreThanOrEqual,
                    filter.EndDateFrom);

                sqlBuilder.ConditionConstructor.AddCondition(
                    QueryConditionRelationType.AND,
                    "A.EndDate",
                    DbType.DateTime,
                    "@EndDateTo",
                    QueryConditionOperatorType.LessThan,
                    filter.EndDateTo);


                sqlBuilder.ConditionConstructor.AddCondition(
                    QueryConditionRelationType.AND,
                    "B.Status",
                    DbType.String,
                    "@BStatus",
                    QueryConditionOperatorType.Equal,
                    "A");
                //TODO:添加渠道过滤条件

                cmd.CommandText = sqlBuilder.BuildQuerySql();
                var ds = cmd.ExecuteDataSet();
                //转换DataTable的枚举列
                EnumColumnList enumConfig = new EnumColumnList();
                enumConfig.Add("Status", typeof(ADStatus));
                enumConfig.Add("ProductStatus", typeof(ProductStatus));
                cmd.ConvertEnumColumn(ds.Tables[0], enumConfig);

                totalCount = Convert.ToInt32(cmd.GetParameterValue("@TotalCount"));
                return(ds.Tables[0]);
            }
        }
Example #11
0
        /// <summary>
        /// 根据页面类型(PageTypeID),获取Page List
        /// </summary>
        /// <param name="companyCode"></param>
        /// <param name="channelID"></param>
        /// <param name="moduleType"></param>
        /// <param name="pageTypeID"></param>
        /// <returns></returns>
        public virtual PageResult GetPage(string companyCode, string channelID, ModuleType moduleType, string pageTypeID)
        {
            PageResult result = new PageResult();

            result.PresentationType = PageTypeUtil.ResolvePresentationType(moduleType, pageTypeID);

            switch (result.PresentationType)
            {
            case PageTypePresentationType.NoneSubPages:
                result.PageList = GetNoneSubPages(companyCode, channelID, moduleType, pageTypeID);
                break;

            case PageTypePresentationType.OtherSales:    //其他促销页面
                result.PageList = ObjectFactory <ISaleAdvTemplateQueryDA> .Instance.GetActiveCodeNames(companyCode, channelID);

                break;

            case PageTypePresentationType.Merchant:    //商家页面
                //读商家列表
                var vendorList = ObjectFactory <IPOBizInteract> .Instance.GetVendorNameListByVendorType(VendorType.VendorPortal, companyCode);

                if (vendorList != null)
                {
                    result.PageList = new List <WebPage>();
                    result.PageList.Add(new WebPage {
                        ID = 1, PageName = "泰隆优选"
                    });
                    foreach (var kv in vendorList)
                    {
                        result.PageList.Add(new WebPage {
                            ID = kv.Key, PageName = kv.Value
                        });
                    }
                }
                break;

            case PageTypePresentationType.AppleZone:    //Apple专区
                result.PageList = GetApplePage(companyCode, channelID, PageTypePresentationType.AppleZone);
                break;

            case PageTypePresentationType.Brand:    //品牌
                //TODO:读品牌列表
                result.PageList = GetWebPageFromBrandList((b) => b.Status == ValidStatus.Active && b.BrandStoreType > 0);
                break;

            case PageTypePresentationType.BrandExclusive:    //品牌专卖
                //TODO:读品牌列表
                result.PageList = GetWebPageFromBrandList((b) => b.Status == ValidStatus.Active);
                break;

            case PageTypePresentationType.Flagship:    //品牌旗舰店
                //TODO:读品牌旗舰店列表
                //result.PageList = GetWebPageFromBrandList((b) => b.BrandStoreType == BrandStoreType.FlagshipStore && b.Status == ValidStatus.Active);
                result.PageList = GetStoresList((b) => b.BrandStoreType == BrandStoreType.FlagshipStore, companyCode);
                break;

            case PageTypePresentationType.Stores:    //专卖店
                result.PageList = GetStoresList((b) => b.Status == BizEntity.IM.ManufacturerStatus.Active, companyCode);
                break;
            }

            return(result);
        }
Example #12
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (!ValidationManager.Validate(this))
            {
                return;
            }
            DefaultKeywordsInfo item = EntityConvertorExtensions.ConvertVM <DefaultKeywordsVM, DefaultKeywordsInfo>(VM, (v, t) =>
            {
                t.Keywords = new BizEntity.LanguageContent(ConstValue.BizLanguageCode, v.Keywords);
            });

            item.CompanyCode = Newegg.Oversea.Silverlight.ControlPanel.Core.CPApplication.Current.CompanyCode;
            //从控件取页面类型相关的值
            item.PageType = this.ucPageType.PageType;
            var pType = PageTypeUtil.ResolvePresentationType(ModuleType.DefaultKeywords, this.ucPageType.PageType.ToString());

            if (item.PageType == 0)
            {
                item.PageID = this.ucPageType.PageID ?? 0;
            }
            else
            {
                item.PageID = this.ucPageType.PageID ?? -1;
            }
            item.Extend = this.ucPageType.IsExtendValid;
            if (item.PageType == null)
            {
                CPApplication.Current.CurrentPage.Context.Window.Alert("页面类型不能为空!", MessageType.Error);
                return;
            }
            if (item.BeginDate == null || item.EndDate == null)
            {
                CPApplication.Current.CurrentPage.Context.Window.Alert("开始时间和结束时间不能为空!", MessageType.Error);
                return;
            }
            if (item.BeginDate != null && item.EndDate != null)
            {
                if (item.EndDate.Value.CompareTo(item.BeginDate) <= 0)
                {
                    CPApplication.Current.CurrentPage.Context.Window.Alert("结束时间不能小于开始时间!", MessageType.Error);
                    return;
                }
            }


            if (isAdd)
            {
                facade.AddDefaultKeywords(item, (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }
                    CloseDialog(DialogResultType.OK);
                    CPApplication.Current.CurrentPage.Context.Window.Alert(ResKeywords.Information_CreateSuccessful, MessageType.Information);
                });
            }
            else
            {
                item.SysNo = SysNo;
                facade.EditDefaultKeywords(item, (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }
                    CloseDialog(DialogResultType.OK);
                    CPApplication.Current.CurrentPage.Context.Window.Alert(ResKeywords.Information_UpdateSuccessful, MessageType.Information);
                });
            }
        }
Example #13
0
        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"));
            }
        }