Exemplo n.º 1
0
 public AddPetCacheDeal(IDatabase database, UserPetService userPetService, MemberInfoService memberInfoService,
                        PetService petService, BillFlowService billFlowService)
 {
     this._database    = database;
     UserPetService    = userPetService;
     MemberInfoService = memberInfoService;
     PetService        = petService;
     BillFlowService   = billFlowService;
 }
Exemplo n.º 2
0
 public IdiomsSolitaireCacheDeal(IdiomsService idiomsService, IDatabase database, BillFlowService billFlowService
                                 , MemberInfoService memberInfoService, GroupActivityService activityLogService, ManageService manageService)
 {
     IdiomsService      = idiomsService;
     this._database     = database;
     BillFlowService    = billFlowService;
     MemberInfoService  = memberInfoService;
     ActivityLogService = activityLogService;
     ManageService      = manageService;
 }
Exemplo n.º 3
0
        public async Task <GroupRes> Run(string msg, string account, string groupNo, Lazy <string> getLoginAccount)
        {
            if ("打卡".Equals(msg) || "签到".Equals(msg) || "冒泡".Equals(msg))
            {
                var now      = DateTime.Now;
                var today    = new DateTime(now.Year, now.Month, now.Day);
                var tomorrow = today.AddDays(1);

                if (await BillFlowService.GetAll().AnyAsync(u => u.Group == groupNo && u.Account == account &&
                                                            u.BillType == Data.Pikachu.Menu.BillTypes.Sign && u.CreateTime >= today && u.CreateTime < tomorrow))
                {
                    return("已签到");
                }

                var amount = 0;
                var desc   = string.Empty;

                var firstDay = new DateTime(now.Year, now.Month, 1);
                var nextMon  = firstDay.AddMonths(1);

                var count = await BillFlowService.GetAll().CountAsync(u => u.Group == groupNo && u.Account == account &&
                                                                      u.BillType == Data.Pikachu.Menu.BillTypes.Sign && u.CreateTime >= firstDay && u.CreateTime < nextMon);

                if (await BillFlowService.GetAll().AnyAsync(u => u.Group == groupNo &&
                                                            u.BillType == Data.Pikachu.Menu.BillTypes.Sign && u.CreateTime >= today && u.CreateTime < tomorrow))
                {
                    amount = _random.Next((count + 1) * 10);
                    desc   = "普通签到";
                }
                else
                {
                    amount = _random.Next((count + 1) * 50);
                    desc   = "首签";
                }

                amount += 5 + now.Month;

                await BillFlowService.AddBillAsync(groupNo, account, amount, amount, Data.Pikachu.Menu.BillTypes.Sign, desc);

                await MemberInfoService.ChangeAmountAsync(groupNo, account, amount);

                return($"签到成功,此次签到共获取{amount}钻石!");
            }

            return(null);
        }
Exemplo n.º 4
0
        public async Task <GroupRes> Run(string msg, string account, string groupNo, Lazy <string> getLoginAccount)
        {
            var activityKey = CacheConst.GetGroupActivityKey(groupNo);

            var groupActivity = _database.StringGet(activityKey);

            if (CacheConst.IdiomsSolitaire.Equals(groupActivity))
            {
                var idiomsKey         = CacheConst.GetIdiomsKey(groupNo);
                var idiomsTryCountKey = CacheConst.GetIdiomsTryCountKey(groupNo);

                var logId = int.Parse(await _database.StringGetAsync(CacheConst.GetActivityLogKey(groupNo)));

                var activityLog = ActivityLogService.GetActivity(logId);

                if (activityLog.ActivityStateType == Data.Pikachu.Menu.ActivityStateTypes.Close)
                {
                    // 移除活动缓存
                    await _database.KeyDeleteAsync(activityKey);

                    return("成语接龙活动已关闭!");
                }


                if ("关闭活动".Equals(msg) && await ManageService.IsManageAsync(account))// 管理员主动结束活动.
                {
                    // 移除活动缓存
                    await _database.KeyDeleteAsync(activityKey);

                    var log = await ActivityLogService.CloseActivityAsync(logId, "活动结束,管理员主动结束活动!");

                    return($@"
>>>>>>>>>本次活动已结束,欢迎下次再来挑战!<<<<<<<<<<<<
本次挑战成果:
    成功次数:{log.SuccessCount.ToString()}
    失败次数:{log.FailureCount.ToString()}
希望大家再接再厉!
");
                }

                // 增加尝试次数
                var tryCount = await _database.StringIncrementAsync(idiomsTryCountKey);

                var idiomId = await _database.StringGetAsync(idiomsKey);

                var spell = await IdiomsService.GetInfoAsync(int.Parse(idiomId));

                var confrimStr = $@"
>>>>>>>>>成语接龙火热进行中<<<<<<<<<<<<
    当前成语:{spell.Word}
    尾拼:{spell.LastSpell}
    成语解析:{spell.Explanation}
";

                if (msg.Length != 4)
                {
                    return(GroupRes.GetSuccess(new GroupItemRes()
                    {
                        AtTa = true, Msg = "输入格式有误!"
                    },
                                               await GetTryCountRes(tryCount, activityKey, logId), confrimStr));
                }

                var info = await IdiomsService.GetByWordAsync(msg);

                if (info == null)
                {
                    return(GroupRes.GetSuccess(new GroupItemRes()
                    {
                        AtTa = true, Msg = "词语输入有误!"
                    },
                                               await GetTryCountRes(tryCount, activityKey, logId), confrimStr));
                }

                if (!spell.LastSpell.Equals(info.FirstSpell))
                {
                    return(GroupRes.GetSuccess(new GroupItemRes()
                    {
                        AtTa = true, Msg = "你输入的词语并不能接上呢!"
                    },
                                               await GetTryCountRes(tryCount, activityKey, logId), confrimStr));
                }

                // 积分奖励
                var amount = _random.Next(100) + 5;

                await ActivityLogService.AddSuccessCountAsync(logId);

                await BillFlowService.AddBillAsync(groupNo, account, amount, amount, Data.Pikachu.Menu.BillTypes.Reward,
                                                   "成语接龙奖励");

                await MemberInfoService.ChangeAmountAsync(groupNo, account, amount);

                // 重新缓存
                await _database.StringSetAsync(idiomsKey, info.Id, RuleConst.GroupActivityExpiry);

                // 重新缓存
                await _database.StringSetAsync(idiomsTryCountKey, 0,
                                               RuleConst.GroupActivityExpiry);


                return(GroupRes.GetSuccess(new GroupItemRes()
                {
                    AtTa = true, Msg = $"   恭喜你获得{amount.ToString()}钻石奖励!"
                },
                                           $@"
>>>>>>>>>【成语接龙】下一回合<<<<<<<<<<<<
    当前成语:{info.Word}
    尾拼:{info.LastSpell}
    成语解析:{info.Explanation}
"
                                           ));
            }

            return(null);
        }
Exemplo n.º 5
0
 public SignDeal(BillFlowService billFlowService, MemberInfoService memberInfoService)
 {
     BillFlowService   = billFlowService;
     MemberInfoService = memberInfoService;
 }