コード例 #1
0
        private static bool GetPayment(int game, int server, string account, string userID)
        {
            try
            {
                GameUser userInfo = new PersonalCacheStruct <GameUser>().FindKey(userID);
                if (userInfo == null)
                {
                    return(false);
                }
                var         chatService = new TjxChatService();
                OrderInfo[] model       = PayManager.getPayment(game, server, account);
                foreach (OrderInfo order in model)
                {
                    userInfo.PayGold = MathUtils.Addition(userInfo.PayGold, order.GameCoins, int.MaxValue);
                    //userInfo.Update();
                    PayManager.Abnormal(order.OrderNO);

                    DialHelper.ReturnRatioGold(userID, order.GameCoins);  //大转盘抽奖奖励充值返还
                    chatService.SystemSendWhisper(userInfo, string.Format(LanguageManager.GetLang().PaySuccessMsg, order.GameCoins));

                    DoGiff(userID, order);
                    FestivalHelper.GetPayReward(userInfo, order.GameCoins, FestivalType.PayReward);
                }
                return(true);
            }
            catch (Exception ex)
            {
                BaseLog log = new BaseLog("PaymentLog");
                log.SaveLog(ex);
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// 累计充值活动
        /// </summary>
        private static void TriggerFestivalPack(UserRecharge userRecharge, int GameCoins)
        {
            FestivalInfo fest = FestivalHelper.GetInfo(FestivalType.PayCount);

            if (fest == null)
            {
                return;
            }
            if (userRecharge.FestivalDate == null || userRecharge.FestivalDate < fest.StartDate)
            {
                userRecharge.FestivalDate  = fest.StartDate;
                userRecharge.FestivalCount = GameCoins;
            }
            else
            {
                userRecharge.FestivalCount += GameCoins;
            }
        }
コード例 #3
0
        /// <summary>
        /// 处理礼包
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="order"></param>
        private static void DoGiff(string userID, OrderInfo order)
        {
            int packType = 0;
            List <PackageReceive> packageReceivess = new List <PackageReceive>();
            UserRechargeLog       rechargeLog      = new UserRechargeLog
            {
                LogID        = Guid.NewGuid().ToString(),
                UserID       = userID,
                OrderNo      = order.OrderNO,
                ChargeAmount = order.Amount,
                PayGold      = order.GameCoins,
                ReargeDate   = DateTime.Now
            };
            var sender = DataSyncManager.GetDataSender();

            sender.Send(rechargeLog);

            UserRecharge recharge = new PersonalCacheStruct <UserRecharge>().FindKey(userID);

            if (recharge == null)
            {
                recharge = new UserRecharge()
                {
                    UserID = userID
                };
            }
            //处理充值活动
            recharge.LastNum = order.GameCoins;
            TriggerFestivalPack(recharge, order.GameCoins);
            if (IsCurrentWeek(recharge.ChargeDate))
            {
                recharge.WeekNum = MathUtils.Addition(recharge.WeekNum, order.GameCoins, int.MaxValue);
            }
            else
            {
                recharge.WeekNum = order.GameCoins;
            }
            if (recharge.ChargeDate.Month == DateTime.Now.Month)
            {
                recharge.MonthNum = MathUtils.Addition(recharge.MonthNum, order.GameCoins, int.MaxValue);
            }
            else
            {
                recharge.MonthNum = order.GameCoins;
            }

            recharge.TotalGoldNum = MathUtils.Addition(recharge.TotalGoldNum, order.GameCoins, int.MaxValue);
            recharge.ChargeDate   = DateTime.Now;
            var rechargeCacheSet = new PersonalCacheStruct <UserRecharge>();

            if (rechargeCacheSet.FindKey(userID) == null)
            {
                packType          = 1;
                recharge.FirstNum = order.GameCoins;
                TriggerReceivePack(userID, packType, recharge.FirstNum);
                rechargeCacheSet.Add(recharge);
                FestivalHelper.GetFirstReward(userID, FestivalType.FirstReward);
                GameUser userInfo = new PersonalCacheStruct <GameUser>().FindKey(userID);
                if (userInfo != null)
                {
                    FestivalHelper.GetPayReward(userInfo, order.GameCoins, FestivalType.FirstPayDoubleSpar);
                }
            }

            //触发总累计充值礼包
            packType = 2;
            TriggerReceivePack(userID, packType, recharge.TotalGoldNum);
            List <RechargePacks> rechargePackseArray = new ShareCacheStruct <RechargePacks>().FindAll(m => m.PacksType == packType);

            foreach (RechargePacks rechargePackse in rechargePackseArray)
            {
                RemoveCharge(userID, rechargePackse.PacksID);
            }
            TriggerWeekPack(userID, recharge.WeekNum);   //每周礼包
            TriggerMonthPack(userID, recharge.MonthNum); //每月礼包
        }
コード例 #4
0
        /// <summary>
        /// 玩家荣誉值升级
        /// </summary>
        /// <param name="user"></param>
        /// <param name="honourNum"></param>
        public static void AddUserLv(GameUser user, int honourNum)
        {
            short generalMaxLv = GameConfigSet.CurrMaxLv.ToShort();

            if (user.UserLv >= generalMaxLv)
            {
                CheckFun(user);
                return;
            }
            short rankLv = user.UserLv;

            user.HonourNum = MathUtils.Addition(user.HonourNum, honourNum);
            short nextLv = MathUtils.Addition(user.UserLv, 1.ToShort());

            while (nextLv <= generalMaxLv)
            {
                GeneralEscalateInfo generalEscalate = new ConfigCacheSet <GeneralEscalateInfo>().FindKey(nextLv, GeneralType.YongHu);
                if (generalEscalate != null && user.HonourNum >= generalEscalate.UpExperience)
                {
                    user.UserLv = nextLv;
                    user.IsLv   = true;
                    UserHelper.OpenMagic(user.UserID, user.UserLv);
                    user.HonourNum = MathUtils.Subtraction(user.HonourNum, generalEscalate.UpExperience);

                    if (generalEscalate.FunctionEnum != null && generalEscalate.FunctionEnum != "")
                    {
                        var feArray = generalEscalate.FunctionEnum.Split(',');
                        foreach (var fun in feArray)
                        {
                            var userFun = _cacheSetUserFun.FindKey(user.UserID, fun);
                            if (userFun == null)
                            {
                                userFun            = new UserFunction();
                                userFun.UserID     = user.UserID;
                                userFun.FunEnum    = fun.ToEnum <FunctionEnum>();
                                userFun.CreateDate = DateTime.Now;
                                _cacheSetUserFun.Add(userFun, GameEnvironment.CacheUserPeriod);
                                _cacheSetUserFun.Update();
                                user.OpenFun.Add(userFun);
                            }
                        }
                    }
                    FestivalHelper.GetUpgradeGiveGift(user.UserID, nextLv);
                    nextLv = MathUtils.Addition(user.UserLv, 1.ToShort());
                }
                else
                {
                    break;
                }
            }
            if (user.UserLv > rankLv)
            {
                Ranking <UserRank> ranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey);
                UserRank           rankInfo;
                int rankID;
                if (ranking.TryGetRankNo(m => m.UserID == user.UserID, out rankID))
                {
                    rankInfo = ranking.Find(s => s.UserID == user.UserID);
                    if (rankInfo != null)
                    {
                        rankInfo.UserLv         = user.UserLv;
                        rankInfo.TotalCombatNum = user.CombatNum;
                        rankInfo.ObtainNum      = user.ObtainNum;
                    }
                }
            }
            CheckFun(user);
        }