Ejemplo n.º 1
0
        /// <summary>
        /// 变更商品推荐
        /// </summary>
        /// <param name="storeId"></param>
        public void SaveChangeStoreRecommend(long storeId)
        {
            using (WcfTcpClient <IStoreService> clint = factory.CreateClient <IStoreService>())
            {
                var      storePageContent = clint.Channel.GetStorePageContents(storeId, VersionEnum.Published, PageTypeEnum.DetailPage);
                string   moduleTag        = string.Empty;
                string   redisKey         = string.Empty;
                JSONPage jsonPage;
                if (storePageContent != null && storePageContent.Count > 0)
                {
                    foreach (var item in storePageContent)
                    {
                        if (item != null)
                        {
                            jsonPage = JsonConvert.DeserializeObject <JSONPage>(item.PageContent);
                            var moduleList = GetStoreModules(jsonPage.PageLayoutUnits);
                            CN100.Redis.Client.RedisClientUtility.SetData(RedisKeyConst.GetStorePageContentKey(item.StoreId, item.PageId).Key, JsonConvert.SerializeObject(item));
                            #region 处理店铺所有受装修配置影响的模块
                            //插入前先删除掉页面的所有Module数据
                            CN100.Redis.Client.RedisClientUtility.DelBySearchKey(RedisKeyConst.GetModuleKey(item.StoreId, item.PageId, "*", string.Empty).Key);
                            foreach (var moduleItem in moduleList)
                            {
                                var jobj = (Newtonsoft.Json.Linq.JObject)moduleItem;
                                moduleTag = jobj[moduleTagStr].ToString();
                                JsonObject ModuleJson = EasyJson.Parse(RegexFixSystemChar.Replace(moduleItem.ToString(), string.Empty));
                                redisKey = RedisKeyConst.GetModuleKey(item.StoreId, item.PageId, ModuleJson[moduleIdStr].Value, moduleTag).Key;
                                switch (moduleTag)
                                {
                                case ModuleTag.RankingProduct:     //排行模块
                                case ModuleTag.RecommProduct:
                                case ModuleTag.PromotionProduct:
                                    SaveProductList(ModuleJson, redisKey, storeId);
                                    break;

                                default: break;
                                }
                            }
                            #endregion
                        }
                    }
                }
            }
        }