Exemplo n.º 1
0
        public static int GetAndUpdate(long GroupNum)
        {
            var todayStr = DateTime.Now.ToString("yyyyMMdd");
            var rec      = MongoService <SignInGroupInfo> .GetOnly(p => p.GroupNum == GroupNum && p.DateStr == todayStr);

            if (rec == null)
            {
                rec = new SignInGroupInfo()
                {
                    GroupNum = GroupNum, DateStr = todayStr
                };
                MongoService <SignInGroupInfo> .Insert(rec);
            }

            rec.IndexNo++;
            MongoService <SignInGroupInfo> .Update(rec);

            return(rec.IndexNo);
        }
Exemplo n.º 2
0
        protected override void Sign(MsgInformationEx MsgDTO)
        {
            var sign     = SignInSuccessiveRecord.Sign(MsgDTO.FromGroup, MsgDTO.FromQQ);
            var goldsGen = Math.Min(sign.SuccessiveDays * 5, 50);

            OSPerson.GoldIncome(MsgDTO.FromQQ, goldsGen);
            var indexNo = SignInGroupInfo.GetAndUpdate(MsgDTO.FromGroup);

            var msg = $"签到成功!你已连续签到 {sign.SuccessiveDays}天,获得 {goldsGen.CurencyFormat()}!\r\n本群签到排名:【No.{indexNo}】";

            if (sign.SuccessiveDays % 10 == 0)
            {
                var cache = PersonCacheRecord.Get(MsgDTO.FromQQ, "抽奖");
                cache.Value = !string.IsNullOrEmpty(cache.Value) && int.TryParse(cache.Value, out var times) ? (times + 1).ToString() : 1.ToString();
                cache.Update();

                msg += "\r\n恭喜你获得一次抽奖机会,快去试试吧(当日有效!)";
            }
            MsgSender.PushMsg(MsgDTO, msg, true);
        }