Ejemplo n.º 1
0
 public async Task <IActionResult> GetPoster([FromBody] ParamGetPoster param)
 {
     return(await ActionWrapAsync(async() =>
     {
         ResultData <RpsData <RpsUserGetPoster> > result = new ResultData <RpsData <RpsUserGetPoster> >();
         param = HttpContext.User.GetUserBase <ParamGetPoster>(param);
         result.Data = await _otherService.GetPoster(param);
         return result;
     }));
 }
Ejemplo n.º 2
0
        public async Task <RpsData <RpsUserGetPoster> > GetPoster(ParamGetPoster param)
        {
            var posterLevel = await _context.PosterRewards.AsNoTracking().SingleAsync(x => x.Gate == param.Gate && x.Score == param.Score);


            var existPoster = await _context.Posters.AsNoTracking().Where(x => x.UserId == param.Id)
                              .AnyAsync(x => _context.PosterGalleries.AsNoTracking().Any(y =>
                                                                                         y.Gate == param.Gate && y.Id == x.PosterId && y.PosterLevel == posterLevel.PosterLevel));

            if (!existPoster)
            {
                var poseterGallery = await _context.PosterGalleries.Where(x =>
                                                                          x.Gate == param.Gate && x.PosterLevel == posterLevel.PosterLevel).Select(x => new PosterGallery()
                {
                    Id = x.Id, Icon = x.Icon
                }).SingleAsync();


                _context.Posters.Add(new Poster()
                {
                    CreateDateTime = DateTime.Now,
                    GateId         = posterLevel.Gate,
                    PosterId       = poseterGallery.Id,
                    UserId         = param.Id
                });
                _context.BuyGoodHistories.Add(new BuyGoodHistory()
                {
                    CreateDate = DateTime.Now,
                    HaveGet    = true,
                    MallId     = 0,
                    Num        = posterLevel.Num,
                    UserId     = param.Id,
                    Type       = BuyTypeEnum.解锁图鉴赠送
                });
                var userGoods = await _context.UserGoods.SingleAsync(x => x.UserId == param.Id && x.GoodsType == MallGoodsTypeEnum.金币);

                userGoods.Num += posterLevel.Num;

                bool flag = await _context.SaveChangesAsync() > 0;

                if (flag)
                {
                    return(RpsData <RpsUserGetPoster> .Ok(new RpsUserGetPoster()
                    {
                        Gate = param.Gate,
                        PosterId = poseterGallery.Id,
                        Icon = poseterGallery.Icon,
                        Reward = new RewardDataDto()
                        {
                            GoodsType = MallGoodsTypeEnum.金币,
                            Num = posterLevel.Num,
                            Type = MallTypeEnum.金币商城
                        }
                    }));
                }
                else
                {
                    return(RpsData <RpsUserGetPoster> .Error("解锁图鉴失败"));
                }
            }
            return(RpsData <RpsUserGetPoster> .Error("已解锁,无需再解锁", 2));
        }
Ejemplo n.º 3
0
 public async Task <RpsData <RpsUserGetPoster> > GetPoster(ParamGetPoster param)
 {
     return(await _otherRepository.GetPoster(param));
 }