Beispiel #1
0
        public IActionResult Package([FromServices] IMemberScoreService memberScoreService, [FromServices] IArticleService articleService, string id)
        {
            if (CoreContextProvider.CurrentMember == null)
            {
                return(ErrorPage("用户未登录,请登录!"));
            }

            var topic = _ArticleTopicService.GetForm(id);

            if (topic == null)
            {
                return(ErrorPage("该专题不存在,购买失败!"));
            }
            var buyResult = memberScoreService
                            .MarketBuy(CoreContextProvider.CurrentMember.UserId, ScoreType.buytopic, id, topic.PackageAmount, topic.CreatorUserId);

            if (buyResult.Success)
            {
                var files = articleService.GetPackageByTopicId(id);
                //文件
                byte[] fileBytes;
                var    contentType  = FileHelper.GetContentType("zip");
                var    resourceType = "zip";
                fileBytes = FileDownHelper.DownloadZip(files.ToDictionary(k => k.Code, v => v.Text));
                return(File(fileBytes, contentType, $"{topic.Title}.{resourceType}"));
            }
            return(ErrorPage("购买后下载文件失败!"));
        }
Beispiel #2
0
        public IActionResult BuyTopics([FromServices] IMemberScoreService memberScoreService, string id)
        {
            if (CoreContextProvider.CurrentMember == null)
            {
                return(Error("用户未登录,请登录!", "/login"));
            }
            var topic = _ArticleTopicService.GetForm(id);

            if (topic == null)
            {
                return(Error("该专题不存在,购买失败!"));
            }

            if (topic.TopicStatus != (int)TopicStatus.Audited)
            {
                return(Error("该专题未审核成功,购买失败!"));
            }
            if (CoreContextProvider.CurrentMember.UserId == topic.CreatorUserId)
            {
                return(Error("无法 购买自己的专题,购买失败!"));
            }
            var buyResult = memberScoreService
                            .MarketBuy(CoreContextProvider.CurrentMember.UserId, ScoreType.buytopic, topic.Id, topic.PackageAmount, topic.CreatorUserId);

            return(JsonResult(buyResult));
        }
Beispiel #3
0
 public MemberService(ISysLogRespository sysLogRespository, IMemberRespository respository
                      , IMemberScoreService memberScoreService)
 {
     _Respository        = respository;
     _MemberScoreService = memberScoreService;
     _logger             = SkyCore.GlobalProvider.CoreContextProvider.GetLogger("MemberService");
 }
 public HomeController(ISysUserService sysUserService,
                       IArticleService articleService,
                       IMemberScoreService memberScoreService,
                       IMemberService memberService)
 {
     _SysUserService      = sysUserService;
     _ArticleService      = articleService;
     _IMemberScoreService = memberScoreService;
     _IMemberService      = memberService;
 }
 /// <summary>
 /// 我的积分
 /// </summary>
 /// <returns></returns>
 public IActionResult UserScore([FromServices] IMemberScoreService memberScoreService, MemScoreSearchView searchView, int p = 1)
 {
     AddPageCrumbs("我的积分");
     searchView.MemberId = CoreContextProvider.CurrentMember.UserId;
     return(View(memberScoreService.GetList(searchView, p, PageSize)));
 }
        public IActionResult BuyBooks([FromServices] IArticleTopicService articleTopicService, [FromServices] IMemberScoreService memberScoreService,
                                      string id)
        {
            if (CoreContextProvider.CurrentMember == null)
            {
                return(Error("购买失败,请先登录!"));
            }
            var article = _ArticleService.GetForm(id);

            if (article == null)
            {
                return(Error("该文库不存在,购买失败!"));
            }

            if (article.BookStatus != (int)BookStatus.审核通过)
            {
                return(Error("该文库未审核成功,购买失败!"));
            }

            //如果选择专题,无分类,则无法下载
            if (!article.SpecialTopicId.IsEmpty() && article.CategoryId.IsEmpty())
            {
                //var topicServie = CoreContextProvider.GetService<IArticleTopicService>();
                var topicName = articleTopicService.GetCate(article.SpecialTopicId)?.Text;
                if (!topicName.IsEmpty())
                {
                    return(Error($"该文库已绑定资源专题,无法单独购买,请到专题【{topicName}】购买!"));
                }
            }

            var buyResult = memberScoreService.MarketBuy(CoreContextProvider.CurrentMember.UserId,
                                                         ScoreType.buybook, article.Id, article.RequireAmount, article.CreatorUserId);

            return(JsonResult(buyResult));
        }
Beispiel #7
0
 public SysMemScoreController(IMemberScoreService MemberScoreService, IMemberService memberService)
 {
     _MemberScoreService = MemberScoreService;
     _IMemberService     = memberService;
 }