Пример #1
0
 public ActionResult Add(long?id)
 {
     if (id.HasValue)
     {
         var topicInfo  = TopicApplication.GetTopic(id.Value);
         var modules    = TopicApplication.GetModules(id.Value);
         var products   = TopicApplication.GetModuleProducts(modules.Select(p => p.Id));
         var topicModel = new Models.TopicModel()
         {
             BackgroundImage = topicInfo.BackgroundImage,
             Id              = topicInfo.Id,
             Name            = topicInfo.Name,
             TopImage        = topicInfo.TopImage,
             TopicModuleInfo = modules,
             ModuleProducts  = products,
             IsRecommend     = topicInfo.IsRecommend,
             SelfDefineText  = topicInfo.SelfDefineText
         };
         return(View(topicModel));
     }
     else
     {
         return(View(new Models.TopicModel()));
     }
 }
Пример #2
0
        public ActionResult Save(long id = 0)
        {
            Entities.TopicInfo topicInfo;

            if (id > 0)
            {
                topicInfo = TopicApplication.GetTopic(id);
                if (topicInfo.ShopId != CurrentSellerManager.ShopId)
                {
                    throw new HimallException("不存在该专题或者删除!" + id);
                }
            }
            else
            {
                topicInfo = new Entities.TopicInfo();
            }

            var modules  = TopicApplication.GetModules(id);
            var products = TopicApplication.GetModuleProducts(modules.Select(p => p.Id));

            var topicModel = new Models.TopicModel()
            {
                Id              = topicInfo.Id,
                Name            = topicInfo.Name,
                TopImage        = topicInfo.TopImage,
                TopicModuleInfo = modules,
                Products        = products,
                Tags            = topicInfo.Tags,
            };

            return(View(topicModel));
        }
Пример #3
0
        public JsonResult ChooseTopic(string frontCoverImage, long topicId)
        {
            var topicService = _iTopicService;
            var topic        = TopicApplication.GetTopic(topicId);

            topic.FrontCoverImage = frontCoverImage;
            topicService.UpdateTopicInfo(topic);
            _iMobileHomeTopicService.AddMobileHomeTopic(topicId, 0, PlatformType.WeiXin, frontCoverImage);
            return(Json(new { success = true }));
        }
Пример #4
0
        // GET: Web/Topic
        public ActionResult Detail(long id)
        {
            var topic = TopicApplication.GetTopic(id);

            if (topic == null)
            {
                //404页面
            }
            var model = new TopicViewModel();

            model.Topic          = topic;
            model.Modules        = TopicApplication.GetModules(id);
            model.ModuleProducts = TopicApplication.GetModuleProducts(model.Modules.Select(p => p.Id));
            model.Products       = ProductManagerApplication.GetProducts(model.ModuleProducts.Select(p => p.ProductId));
            ViewBag.Keyword      = SiteSettings.Keyword;
            return(View(model));
        }
Пример #5
0
        public JsonResult Add(string topicJson)
        {
            var s = new Newtonsoft.Json.JsonSerializerSettings();

            s.MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore;
            s.NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore;
            var topic = Newtonsoft.Json.JsonConvert.DeserializeObject <Topic>(topicJson, s);

            if (string.IsNullOrWhiteSpace(topic.Name))
            {
                return(Json(new { success = false, msg = "专题名不可为空" }));
            }
            topic.Name = topic.Name.Trim();
            if (string.IsNullOrWhiteSpace(topic.Tags))
            {
                return(Json(new { success = false, msg = "标签不可为空" }));
            }
            foreach (var item in topic.TopicModuleInfo)
            {
                if (string.IsNullOrWhiteSpace(item.Name))
                {
                    return(Json(new { success = false, msg = "错误的模块名" }));
                }
            }
            topic.Tags = topic.Tags.Trim();
            var oriTopic = TopicApplication.GetTopic(topic.Id);

            topic.Platform        = PlatformType.Mobile;
            topic.ShopId          = CurrentSellerManager.ShopId;
            topic.BackgroundImage = oriTopic == null ? string.Empty : oriTopic.BackgroundImage;
            topic.FrontCoverImage = oriTopic == null ? string.Empty : oriTopic.FrontCoverImage;


            if (topic.Id > 0)
            {
                _iTopicService.UpdateTopic(topic);
            }
            else
            {
                _iTopicService.AddTopic(topic);
            }

            return(Json(new { success = true }));
        }
        ///// <summary>
        ///// 修改同步小程序状态
        ///// </summary>
        ///// <param name="type"></param>
        ///// <param name="status"></param>
        ///// <returns></returns>
        //[HttpPost]
        //public JsonResult ShopBranchSettingUpdateAppletSyncStatus(int type, bool status)
        //{
        //    var setting = SiteSettingApplication.SiteSettings;
        //    switch (type)
        //    {
        //        case 1:
        //            setting.O2OApplet_IsUseTopSlide = status;
        //            break;
        //        case 2:
        //            setting.O2OApplet_IsUseIconArea = status;
        //            break;
        //        case 3:
        //            setting.O2OApplet_IsUseAdArea = status;
        //            break;
        //        case 4:
        //            setting.O2OApplet_IsUseMiddleSlide = status;
        //            break;
        //        default:
        //            return Json(new Result { success = false, status = -1, msg = "错误的操作参数" });
        //    }
        //    SiteSettingApplication.SaveChanges();
        //    return Json(new Result { success = true, status = 1, msg = "操作成功" });
        //}

        private string GetLinkName(string url)
        {
            var arr = url.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            if (arr.Length == 2)
            {
                var  strID = arr[1].Substring(arr[1].LastIndexOf('/') + 1);
                long id    = 0;
                long.TryParse(strID, out id);
                switch (arr[0])
                {
                case "1":
                {
                    var model = ShopBranchApplication.GetShopBranchTagInfo(id, false);
                    if (null != model)
                    {
                        return(model.Title);
                    }
                }
                break;

                case "2":
                {
                    var model = ShopBranchApplication.GetShopBranchById(id);
                    if (null != model)
                    {
                        return(model.ShopBranchName);
                    }
                }
                break;

                case "3":
                {
                    var model = TopicApplication.GetTopic(id);
                    if (null != model)
                    {
                        return(model.Name);
                    }
                }
                break;
                }
            }
            return("");
        }
Пример #7
0
        public ActionResult TopicSettings()
        {
            var homeTopicInfos = _iMobileHomeTopicService.GetMobileHomeTopicInfos(PlatformType.WeiXin).ToArray();
            var topicService   = _iTopicService;
            var models         = homeTopicInfos.Select(item =>
            {
                var topic = TopicApplication.GetTopic(item.TopicId);
                return(new TopicModel()
                {
                    FrontCoverImage = topic.FrontCoverImage,
                    Id = item.Id,
                    Name = topic.Name,
                    Tags = topic.Tags,
                    Sequence = item.Sequence
                });
            });

            return(View(models));
        }
Пример #8
0
        public object LoadProducts(long topicId, long moduleId)
        {
            var topic    = TopicApplication.GetTopic(topicId);
            var module   = TopicApplication.GetModules(moduleId);
            var products = TopicApplication.GetModuleProducts(moduleId);
            var onSales  = ProductManagerApplication.GetOnSaleProducts(products.Select(p => p.ProductId).ToList());
            var model    = onSales.Select(item => new TopicModuleProductModel
            {
                Name        = item.ProductName,
                Id          = item.Id,
                Image       = item.GetImage(ImageSize.Size_350),
                Price       = item.MinSalePrice,
                MarketPrice = item.MarketPrice
            });
            dynamic result = SuccessResult();

            result.data = model.ToList();
            return(result);
        }
Пример #9
0
        public ActionResult Detail(long id)
        {
            var    topic   = TopicApplication.GetTopic(id);
            string tmppath = VTemplateHelper.GetTemplatePath(id.ToString(), VTemplateClientTypes.WapSpecial);

            tmppath = "~" + tmppath;
            string viewpath = tmppath + "Skin-HomePage.cshtml";

            if (topic != null)
            {//判空处理
                ViewBag.Title = "专题-" + topic.Name;
            }
            else
            {
                throw new Himall404();
            }
            VTemplateHelper.DownloadTemplate(id.ToString(), VTemplateClientTypes.WapSpecial);
            ViewBag.ShopId = topic.ShopId;
            var vshop = VshopApplication.GetVShopByShopId(topic.ShopId);

            ViewBag.VshopId = vshop == null ? 0 : vshop.Id;
            return(View(viewpath, topic));
        }
Пример #10
0
        public object GetTopicDetail(long id)
        {
            var topic             = TopicApplication.GetTopic(id);
            var modules           = TopicApplication.GetModules(id);
            var allModuleProducts = TopicApplication.GetModuleProducts(modules.Select(p => p.Id));
            var allOnSaleProducts = ProductManagerApplication.GetOnSaleProducts(allModuleProducts.Select(p => p.ProductId).ToList());

            TopicModel model = new TopicModel();

            model.Id          = topic.Id;
            model.Name        = topic.Name;
            model.TopImage    = MallIO.GetRomoteImagePath(topic.TopImage);
            model.TopicModule = new List <TopicModuleModel>();
            foreach (var module in modules)
            {
                var topicModuleModel = new TopicModuleModel();
                var moduleProducts   = allModuleProducts.Where(p => p.ModuleId == module.Id);
                topicModuleModel.Id   = module.Id;
                topicModuleModel.Name = module.Name;
                topicModuleModel.TopicModelProduct = allOnSaleProducts
                                                     .Where(p => moduleProducts.Select(x => x.ProductId).Contains(p.Id))
                                                     .Select(item => new TopicModuleProductModel
                {
                    Name        = item.ProductName,
                    Id          = item.Id,
                    Image       = Core.MallIO.GetRomoteProductSizeImage(item.RelativePath, 1, (int)Mall.CommonModel.ImageSize.Size_350),
                    Price       = item.MinSalePrice,
                    MarketPrice = item.MarketPrice
                }).ToList();

                model.TopicModule.Add(topicModuleModel);
            }
            dynamic result = SuccessResult();

            result.Topic = model;
            return(result);
        }
Пример #11
0
        public JsonResult GetUserShippingAddressesList(long topicId, long moduleId, int page, int pageSize)
        {
            var topic    = TopicApplication.GetTopic(topicId);
            var module   = TopicApplication.GetModules(moduleId);
            var products = TopicApplication.GetModuleProducts(moduleId);
            var onSales  = ProductManagerApplication.GetOnSaleProducts(products.Select(p => p.ProductId).ToList())
                           .Skip(pageSize * (page - 1))
                           .Take(pageSize); //TODO:FG 数据分页 业务需要降层。

            var model = onSales.Select(item =>
            {
                var flashSaleModel = _iLimitTimeBuyService.GetFlaseSaleByProductId(item.Id);
                return(new
                {
                    name = item.ProductName,
                    id = item.Id,
                    image = item.GetImage(ImageSize.Size_350),
                    price = flashSaleModel != null ? flashSaleModel.MinPrice : item.MinSalePrice,
                    marketPrice = item.MarketPrice
                });
            });

            return(SuccessResult <dynamic>(data: model));
        }
Пример #12
0
        // GET: Admin/APPShop
        //APP首页配置共用于安卓和IOS,这里的平台类型写的为IOS,安卓调用首页接口数据时平台类型也选IOS
        public ActionResult HomePageSetting()
        {
            var homeTopicInfos = MobileHomeTopicApplication.GetMobileHomeTopicInfos(PlatformType.IOS);

            //专题
            ViewBag.imageAds = SlideApplication.GetImageAds(0).Where(p => p.TypeId == ImageAdsType.APPSpecial).ToList();
            //门店授权
            ViewBag.IsOpenStore = SiteSettingApplication.SiteSettings.IsOpenStore;
            var topics = TopicApplication.GetTopics(homeTopicInfos.Select(p => p.TopicId).ToList());
            var models = homeTopicInfos.Select(item =>
            {
                var topic = topics.FirstOrDefault(p => p.Id == item.TopicId);
                return(new TopicModel()
                {
                    FrontCoverImage = topic.FrontCoverImage,
                    Id = item.Id,
                    Name = topic.Name,
                    Tags = topic.Tags,
                    Sequence = item.Sequence
                });
            });

            return(View(models));
        }
Пример #13
0
        public JsonResult Add(string topicJson)
        {
            var s = new Newtonsoft.Json.JsonSerializerSettings();

            s.MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore;
            s.NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore;
            var topic    = Newtonsoft.Json.JsonConvert.DeserializeObject <Topic>(topicJson, s);
            var oriTopic = TopicApplication.GetTopic(topic.Id);

            topic.Platform        = PlatformType.Mobile;
            topic.BackgroundImage = oriTopic?.BackgroundImage ?? string.Empty;
            topic.FrontCoverImage = oriTopic?.FrontCoverImage ?? string.Empty;

            if (topic.Id == 0)
            {
                _iTopicService.AddTopic(topic);
            }
            else
            {
                _iTopicService.UpdateTopic(topic);
            }

            return(Json(new { success = true }));
        }
Пример #14
0
        public ActionResult Save(long id = 0)
        {
            var topic = new Entities.TopicInfo();

            if (id > 0)
            {
                topic = TopicApplication.GetTopic(id);
            }


            var modules    = TopicApplication.GetModules(id);
            var products   = TopicApplication.GetModuleProducts(modules.Select(p => p.Id));
            var topicModel = new Models.TopicModel()
            {
                Id              = topic.Id,
                Name            = topic.Name,
                TopImage        = topic.TopImage,
                TopicModuleInfo = modules,
                ModuleProducts  = products,
                Tags            = topic.Tags,
            };

            return(View(topicModel));
        }