public static TCPProcessCmdResults ProcessQueryUserFirstCharge(DBManager dbMgr, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket) { tcpOutPacket = null; string cmdData = null; try { cmdData = new UTF8Encoding().GetString(data, 0, count); } catch (Exception) { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767); return(TCPProcessCmdResults.RESULT_DATA); } try { string[] fields = cmdData.Split(new char[] { ':' }); if (fields.Length != 1) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767); return(TCPProcessCmdResults.RESULT_DATA); } string uid = fields[0]; DBUserInfo info = dbMgr.GetDBUserInfo(uid); if (null == info) { LogManager.WriteLog(LogTypes.Error, string.Format("发起请求的账号不存在,CMD={0}, RoleID={1}", (TCPGameServerCmds)nID, uid), null, true); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767); return(TCPProcessCmdResults.RESULT_DATA); } DBUserInfo userInfo = dbMgr.GetDBUserInfo(uid); string ret = CFirstChargeMgr.GetFirstChargeInfo(dbMgr, uid); if (ret != "-2") { tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, ret, nID); } else { tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767); } return(TCPProcessCmdResults.RESULT_DATA); } catch (Exception e) { LogManager.WriteException("ProcessSaveUserFirstCharge:" + e.ToString()); } return(TCPProcessCmdResults.RESULT_DATA); }
/// <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); } } }
private static List <int> MuiltchargeGetBindmoney(int addMoney, int nPlatfromID, string[] binddatalist, CFirstChargeMgr.ChargeType eChargeType, SingleChargeData chargeData) { List <int> templist = new List <int>(); switch (eChargeType) { case CFirstChargeMgr.ChargeType.YingYongBao: { List <int> typelist = chargeData.singleData.Keys.ToList <int>(); typelist.Sort(); int tempmoney = 0; int i = typelist.Count - 1; while (i >= 0) { if (typelist[i] <= addMoney) { if (typelist[i] != chargeData.YueKaMoney || chargeData.ChargePlatType == 1) { if (!CFirstChargeMgr.HasGetFirstbindMoney(typelist[i], binddatalist)) { if (tempmoney + typelist[i] <= addMoney) { templist.Add(typelist[i]); tempmoney += typelist[i]; } } } } IL_CB: i--; continue; goto IL_CB; } break; } case CFirstChargeMgr.ChargeType.GangAoTai: { List <int> typelist = chargeData.singleData.Keys.ToList <int>(); typelist.Sort(); for (int i = typelist.Count - 1; i >= 0; i--) { if (typelist[i] <= addMoney) { if (chargeData.YueKaBangZuan == 1 || typelist[i] != chargeData.YueKaMoney) { if (!CFirstChargeMgr.HasGetFirstbindMoney(typelist[i], binddatalist)) { templist.Add(typelist[i]); break; } } } } break; } default: { int nValue = 0; chargeData.singleData.TryGetValue(addMoney, out nValue); if (nValue > 0) { if (chargeData.YueKaBangZuan == 1 || addMoney != chargeData.YueKaMoney || chargeData.ChargePlatType == 1) { if (!CFirstChargeMgr.HasGetFirstbindMoney(addMoney, binddatalist)) { templist.Add(addMoney); } } } break; } } return(templist); }
public static void SendToRolebindgold(DBManager dbMgr, string uid, int rid, int addMoney, SingleChargeData chargeData) { if (chargeData == null) { LogManager.WriteException(string.Concat(new object[] { "送绑钻失败,配置表信息为空 uid=", uid, " money=", addMoney })); } else { string data = CFirstChargeMgr.GetFirstChargeInfo(dbMgr, uid); string strPlat = (uid.Length >= 4) ? uid.Substring(0, 4) : ""; int nPlatformID = 1; if (strPlat == "APPS") { nPlatformID = 2; } CFirstChargeMgr.ChargeType type = CFirstChargeMgr.ChargeType.Normal; string strYYB = (uid.Length >= 3) ? uid.Substring(0, 3) : ""; if (strYYB == "YYB") { type = CFirstChargeMgr.ChargeType.YingYongBao; } else if (strYYB == "GAT" || strYYB == "430") { type = CFirstChargeMgr.ChargeType.GangAoTai; } string[] datalist = null; if (!string.IsNullOrEmpty(data)) { datalist = data.Split(new char[] { ',' }); } List <int> listAddMoney = CFirstChargeMgr.MuiltchargeGetBindmoney(addMoney, nPlatformID, datalist, type, chargeData); if (listAddMoney != null) { for (int i = 0; i < listAddMoney.Count; i++) { if (!string.IsNullOrEmpty(data)) { data = data + "," + listAddMoney[i]; } else { data = string.Concat(listAddMoney[i]); } } if (!CFirstChargeMgr.UpdateFirstCharge(dbMgr, uid, data, 0)) { LogManager.WriteException(string.Concat(new object[] { "送绑钻失败,保存数据库失败 uid=", uid, " money=", addMoney })); } else { for (int i = 0; i < listAddMoney.Count; i++) { int bindMoney = chargeData.singleData[listAddMoney[i]]; string gmCmdData = string.Format("-updateBindgold {0} {1} {2} {3}", new object[] { uid, rid, bindMoney, data }); ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData); } } } } }
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); }