Example #1
0
        /// <summary>
        /// 更新用户充值的元宝数据
        /// </summary>
        public static void UpdateUsersMoney(DBManager dbMgr)
        {
            long nowTicks = DateTime.Now.Ticks / 10000;

            if (nowTicks - LastUpdateUserMoneyTicks < (3 * 1000))
            {
                return;
            }

            LastUpdateUserMoneyTicks = nowTicks;

            List <string> userIDList       = new List <string>();
            List <int>    addUserMoneyList = new List <int>();

            DBQuery.QueryTempMoney(dbMgr, userIDList, addUserMoneyList);
            if (userIDList.Count <= 0)
            {
                return;
            }

            int currentGiftID  = GameDBManager.GameConfigMgr.GetGameConfigItemInt("big_award_id", 0);
            int moneyToYuanBao = GameDBManager.GameConfigMgr.GetGameConfigItemInt("money-to-yuanbao", 10);
            int moneyToJiFen   = GameDBManager.GameConfigMgr.GetGameConfigItemInt("money-to-jifen", 1);

            for (int i = 0; i < userIDList.Count; i++)
            {
                string userID       = userIDList[i];
                int    addUserMoney = addUserMoneyList[i];

                DBUserInfo dbUserInfo = dbMgr.GetDBUserInfo(userID);
                if (null != dbUserInfo)
                {
                    int userMoney = 0;
                    int realMoney = 0;
                    int giftID    = 0;
                    int giftJiFen = 0;

                    lock (dbUserInfo)
                    {
                        dbUserInfo.Money += (addUserMoney * moneyToYuanBao); //一分钱??元宝
                        userMoney         = dbUserInfo.Money;

                        dbUserInfo.RealMoney += addUserMoney;
                        realMoney             = dbUserInfo.RealMoney;

                        if (currentGiftID != dbUserInfo.GiftID)
                        {
                            dbUserInfo.GiftJiFen = 0;
                            dbUserInfo.GiftID    = currentGiftID;
                        }

                        giftID = dbUserInfo.GiftID;

                        if (dbUserInfo.GiftID > 0)
                        {
                            dbUserInfo.GiftJiFen += (addUserMoney * moneyToJiFen); //一分钱??积分
                        }

                        giftJiFen = dbUserInfo.GiftJiFen;
                    }

                    //更新用户元宝表
                    DBWriter.UpdateUserMoney2(dbMgr, dbUserInfo.UserID, userMoney, realMoney, giftID, giftJiFen);
                    string resoult = "1";
                    int    rid     = DBQuery.LastLoginRole(dbMgr, dbUserInfo.UserID);
                    //送绑钻
                    CFirstChargeMgr.SendToRolebindgold(dbMgr, dbUserInfo.UserID, rid, addUserMoney);
                    //添加GM命令消息
                    string gmCmdData = string.Format("-updateyb {0} {1} {2} {3}", dbUserInfo.UserID, rid, addUserMoney, resoult);
                    ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
                }
            }
        }
Example #2
0
        private static void _ProcessCharge(DBManager dbMgr, DBUserInfo dbUserInfo, int chargeRoleID, int addUserMoney, int zhigouID, string chargeTm, SingleChargeData chargeData, bool bZhiGouFail = false)
        {
            int currentGiftID  = GameDBManager.GameConfigMgr.GetGameConfigItemInt("big_award_id", 0);
            int moneyToYuanBao = GameDBManager.GameConfigMgr.GetGameConfigItemInt("money-to-yuanbao", 10);
            int moneyToJiFen   = GameDBManager.GameConfigMgr.GetGameConfigItemInt("money-to-jifen", 1);
            int ChargeID       = 0;

            chargeData.MoneyVsChargeIDDict.TryGetValue(addUserMoney, out ChargeID);
            bool bWillGiveZuanShi     = zhigouID == 0 && (chargeData.ChargePlatType == 1 || addUserMoney != chargeData.YueKaMoney);
            bool bSystemProcessCharge = chargeRoleID == -1;
            bool bProcessBuyItem      = zhigouID != 0 && chargeRoleID > 0;

            lock (dbUserInfo)
            {
                if (bWillGiveZuanShi)
                {
                    dbUserInfo.Money += addUserMoney * moneyToYuanBao;
                    if (dbUserInfo.Money < 0)
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("充值后玩家元宝变负数修正为0, UserID={0}, Money={1}, AddMoney={2}", dbUserInfo.UserID, dbUserInfo.Money, addUserMoney), null, true);
                        dbUserInfo.Money = 0;
                    }
                }
                if (!bSystemProcessCharge && !bZhiGouFail)
                {
                    dbUserInfo.RealMoney += addUserMoney;
                    if (dbUserInfo.RealMoney < 0)
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("充值后玩家realmoney变负数修正为0, UserID={0}, Money={1}, AddMoney={2}", dbUserInfo.UserID, dbUserInfo.RealMoney, addUserMoney), null, true);
                        dbUserInfo.RealMoney = 0;
                    }
                    if (currentGiftID != dbUserInfo.GiftID)
                    {
                        dbUserInfo.GiftJiFen = 0;
                        dbUserInfo.GiftID    = currentGiftID;
                    }
                    if (dbUserInfo.GiftID > 0)
                    {
                        dbUserInfo.GiftJiFen += addUserMoney * moneyToJiFen;
                    }
                }
                int userMoney = dbUserInfo.Money;
                int realMoney = dbUserInfo.RealMoney;
                int giftID    = dbUserInfo.GiftID;
                int giftJiFen = dbUserInfo.GiftJiFen;
                DBWriter.UpdateUserInfo(dbMgr, dbUserInfo);
            }
            DBRoleInfo dbRoleInfo = Global.FindOnlineRoleInfoByUserInfo(dbMgr, dbUserInfo);

            if (dbRoleInfo != null && !bZhiGouFail)
            {
                DBWriter.UpdateCityInfoItem(dbMgr, dbRoleInfo.LastIP, dbRoleInfo.UserID, "inputmoney", addUserMoney * moneyToYuanBao);
            }
            int rid = chargeRoleID;

            if (!bSystemProcessCharge && !bProcessBuyItem)
            {
                rid = DBQuery.LastLoginRole(dbMgr, dbUserInfo.UserID);
            }
            int addUserYuanBao = Global.TransMoneyToYuanBao(addUserMoney);

            if (bProcessBuyItem)
            {
                UserMoneyMgr._ProcessBuyItem(dbMgr, dbUserInfo, chargeRoleID, addUserMoney, zhigouID, chargeTm);
            }
            int superInputFanLi = 0;

            if (!bProcessBuyItem && addUserMoney != chargeData.YueKaMoney && !bZhiGouFail)
            {
                superInputFanLi = UserMoneyMgr._ProcessSuperInputFanLi(dbMgr, dbUserInfo, chargeData, addUserMoney, ChargeID, chargeTm);
            }
            if (!bSystemProcessCharge && bWillGiveZuanShi)
            {
                CFirstChargeMgr.SendToRolebindgold(dbMgr, dbUserInfo.UserID, rid, addUserMoney, chargeData);
            }
            if (!bSystemProcessCharge && !bZhiGouFail)
            {
                SingletonTemplate <FundManager> .Instance().FundAddMoney(dbUserInfo.UserID, addUserYuanBao, rid, 0);

                GameDBManager.RankCacheMgr.OnUserDoSomething(rid, RankType.Charge, addUserYuanBao);
            }
            string gmCmdData = string.Format("-updateyb {0} {1} {2} {3} {4}", new object[]
            {
                dbUserInfo.UserID,
                rid,
                addUserMoney,
                superInputFanLi,
                zhigouID
            });

            ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
            LogManager.WriteLog(LogTypes.Error, string.Format("处理充值成功 UID={0},money={1},itemid={2}", dbUserInfo.UserID, addUserMoney, zhigouID), null, true);
        }