protected override IList <UserRank> GetCacheList() { rankList.Clear(); if (rankingData.RankList.Count == 0) { var gameCache = new ShareCacheStruct <GameCache>(); var levelrank = gameCache.FindKey("LevelRanking"); if (levelrank == null) { levelrank = new GameCache(); levelrank.Key = "LevelRanking"; levelrank.Value = ""; gameCache.Add(levelrank); gameCache.Update(); } LevelRankingData data = null; data = JsonUtils.Deserialize <LevelRankingData>(levelrank.Value); if (data == null) { data = new LevelRankingData(); } } foreach (var v in rankingData.RankList) { UserRank rank = new UserRank(v); rankList.Add(rank); } return(rankList); }
/// <summary> /// 生成Id /// </summary> /// <returns></returns> public static int GenerateId() { lock (SyncRoot) { string userCode = "USER_CODE"; var userCache = new ShareCacheStruct<UserSet>(); UserSet userSet = userCache.FindKey(userCode); if (userSet == null) { userSet = new UserSet() { Code = userCode, CurrUserId = 1000 }; userCache.Add(userSet); } userSet.CurrUserId++; userCache.Update(); return userSet.CurrUserId; } }
/// <summary> /// 生成Id /// </summary> /// <returns></returns> public static int GenerateId() { lock (SyncRoot) { string userCode = "USER_CODE"; var userCache = new ShareCacheStruct <UserSet>(); UserSet userSet = userCache.FindKey(userCode); if (userSet == null) { userSet = new UserSet() { Code = userCode, CurrUserId = 1000 }; userCache.Add(userSet); } userSet.CurrUserId++; userCache.Update(); return(userSet.CurrUserId); } }
protected override IList <GuildRank> GetCacheList() { rankList.Clear(); if (rankingData.RankList.Count == 0) { var gameCache = new ShareCacheStruct <GameCache>(); var guildrank = gameCache.FindKey("GuildRanking"); if (guildrank == null) { guildrank = new GameCache(); guildrank.Key = "GuildRanking"; guildrank.Value = ""; gameCache.Add(guildrank); gameCache.Update(); } GuildRankingData data = null; data = JsonUtils.Deserialize <GuildRankingData>(guildrank.Value); if (data == null) { data = new GuildRankingData(); } } foreach (var v in rankingData.RankList) { GuildRank rank = new GuildRank() { GuildID = v.GuildID, GuildName = v.GuildName, Liveness = v.Liveness, RankId = v.RankId, Lv = v.Lv, CreateDate = v.CreateDate }; rankList.Add(rank); } return(rankList); }
static public UserCenterUser CreateUserCenterUser(string openid, string retailId, int serverId) { var cache = new ShareCacheStruct <UserCenterUser>(); Interlocked.Increment(ref SystemGlobal.UserCenterUserCount); var ucu = new UserCenterUser() { UserID = GameEnvironment.ProductServerId * 1000000 + SystemGlobal.UserCenterUserCount, NickName = string.Empty, OpenID = openid, ServerID = serverId, AccessTime = DateTime.Now, LoginNum = 0, RetailID = retailId, Unid = string.Empty }; cache.Add(ucu); cache.Update(); return(ucu); }
public override void Process(JsonParameter[] paramList) { JsonParameterList parameters = JsonParameter.Convert(paramList); string op = parameters["op"]; string[] UserList = Convert.ToString(parameters["UserID"]).Split(new char[] { ',' }); string itemPackage = Convert.ToString(parameters["Item"]); string crystalList = Convert.ToString(parameters["Crystal"]); string sparePackage = Convert.ToString(parameters["SparePackage"]); string enchantPackage = Convert.ToString(parameters["EnchantPackage"]); int obtainNum = 0; if (parameters["ObtainNum"].Length > 0) { obtainNum = Convert.ToInt32(parameters["ObtainNum"]); } short energyNum = 0; if (parameters["EnergyNum"].Length > 0) { energyNum = Convert.ToInt16(parameters["EnergyNum"]); } int gameCoin = 0; if (parameters["GameCoin"].Length > 0) { gameCoin = Convert.ToInt32(parameters["GameCoin"]); } int gold = 0; if (parameters["Gold"].Length > 0) { gold = Convert.ToInt32(parameters["Gold"]); } int expNum = 0; if (parameters["ExpNum"].Length > 0) { expNum = Convert.ToInt32(parameters["ExpNum"]); } int vipLv = 0; if (parameters["VipLv"].Length > 0) { vipLv = Convert.ToInt32(parameters["VipLv"]); } int gainBlessing = 0; if (parameters["GainBlessing"].Length > 0) { gainBlessing = Convert.ToInt32(parameters["GainBlessing"]); } int honourNum = 0; if (parameters["HonourNum"].Length > 0) { honourNum = Convert.ToInt32(parameters["HonourNum"]); } string mailContent = Convert.ToString(parameters["MailContent"]); int opUserID = Convert.ToInt32(parameters["OpUserID"]); //var cacheSetUserItem = new GameDataCacheSet<UserItemPackage>(); var cacheSetItemInfo = new ShareCacheStruct<ItemBaseInfo>(); var itemArray = itemPackage.Split(','); foreach (string str in UserList) { try { int userID = str.Trim().ToInt(); var user = new GameDataCacheSet<GameUser>().FindKey(str); if(user!=null) { user.GiftGold = MathUtils.Addition(user.GiftGold, gold); user.ObtainNum = MathUtils.Addition(user.ObtainNum, obtainNum); user.EnergyNum = MathUtils.Addition(user.EnergyNum, energyNum); user.GameCoin = MathUtils.Addition(user.GameCoin, gameCoin); user.ExpNum = MathUtils.Addition(user.ExpNum, expNum); user.HonourNum = MathUtils.Addition(user.HonourNum, honourNum); } foreach (var item in itemArray) { if(item.Split('=').Length==2) { var itemInfo = cacheSetItemInfo.FindKey(item.Split('=')[0]); if(itemInfo!=null) { UserItemHelper.AddUserItem(str, item.Split('=')[0].ToInt(), item.Split('=')[1].ToInt()); } } } Guid newGuid = Guid.NewGuid(); UserTakePrize userPrizeLog = new UserTakePrize { ID = newGuid.ToString(), UserID = userID, ObtainNum = obtainNum, EnergyNum = energyNum, GameCoin = gameCoin, Gold = gold, ExpNum = expNum, VipLv = vipLv, GainBlessing = gainBlessing, ItemPackage = itemPackage, CrystalPackage = crystalList, SparePackage = sparePackage, EnchantPackage = enchantPackage, MailContent = mailContent, IsTasked = false, TaskDate = MathUtils.SqlMinDate, OpUserID = opUserID, CreateDate = DateTime.Now, HonourNum = honourNum, Items = itemPackage, }; var cacheSet = new ShareCacheStruct<UserTakePrize>(); cacheSet.Add(userPrizeLog, GameEnvironment.CacheGlobalPeriod); cacheSet.Update(); PutCrystal(crystalList.Split(','), str); // 发送系统信件 UserMail userMail = new UserMail(newGuid); userMail.UserId = userID; userMail.MailType = (int)MailType.System; userMail.Title = LanguageManager.GetLang().St_SystemMailTitle; userMail.Content = mailContent; userMail.SendDate = DateTime.Now; TjxMailService mailService=new TjxMailService(user); mailService.Send(userMail); } catch (Exception ex) { new BaseLog().SaveLog(ex); } } }
public override void Process(JsonParameter[] paramList) { JsonParameterList parameters = JsonParameter.Convert(paramList); string op = parameters["op"]; string[] UserList = Convert.ToString(parameters["UserID"]).Split(new char[] { ',' }); string itemPackage = Convert.ToString(parameters["Item"]); string crystalList = Convert.ToString(parameters["Crystal"]); string sparePackage = Convert.ToString(parameters["SparePackage"]); string enchantPackage = Convert.ToString(parameters["EnchantPackage"]); int obtainNum = 0; if (parameters["ObtainNum"].Length > 0) { obtainNum = Convert.ToInt32(parameters["ObtainNum"]); } short energyNum = 0; if (parameters["EnergyNum"].Length > 0) { energyNum = Convert.ToInt16(parameters["EnergyNum"]); } int gameCoin = 0; if (parameters["GameCoin"].Length > 0) { gameCoin = Convert.ToInt32(parameters["GameCoin"]); } int gold = 0; if (parameters["Gold"].Length > 0) { gold = Convert.ToInt32(parameters["Gold"]); } int expNum = 0; if (parameters["ExpNum"].Length > 0) { expNum = Convert.ToInt32(parameters["ExpNum"]); } int vipLv = 0; if (parameters["VipLv"].Length > 0) { vipLv = Convert.ToInt32(parameters["VipLv"]); } int gainBlessing = 0; if (parameters["GainBlessing"].Length > 0) { gainBlessing = Convert.ToInt32(parameters["GainBlessing"]); } int honourNum = 0; if (parameters["HonourNum"].Length > 0) { honourNum = Convert.ToInt32(parameters["HonourNum"]); } string mailContent = Convert.ToString(parameters["MailContent"]); int opUserID = Convert.ToInt32(parameters["OpUserID"]); //var cacheSetUserItem = new GameDataCacheSet<UserItemPackage>(); var cacheSetItemInfo = new ShareCacheStruct <ItemBaseInfo>(); var itemArray = itemPackage.Split(','); foreach (string str in UserList) { try { int userID = str.Trim().ToInt(); var user = new GameDataCacheSet <GameUser>().FindKey(str); if (user != null) { user.GiftGold = MathUtils.Addition(user.GiftGold, gold); user.ObtainNum = MathUtils.Addition(user.ObtainNum, obtainNum); user.EnergyNum = MathUtils.Addition(user.EnergyNum, energyNum); user.GameCoin = MathUtils.Addition(user.GameCoin, gameCoin); user.ExpNum = MathUtils.Addition(user.ExpNum, expNum); user.HonourNum = MathUtils.Addition(user.HonourNum, honourNum); } foreach (var item in itemArray) { if (item.Split('=').Length == 2) { var itemInfo = cacheSetItemInfo.FindKey(item.Split('=')[0]); if (itemInfo != null) { UserItemHelper.AddUserItem(str, item.Split('=')[0].ToInt(), item.Split('=')[1].ToInt()); } } } Guid newGuid = Guid.NewGuid(); UserTakePrize userPrizeLog = new UserTakePrize { ID = newGuid.ToString(), UserID = userID, ObtainNum = obtainNum, EnergyNum = energyNum, GameCoin = gameCoin, Gold = gold, ExpNum = expNum, VipLv = vipLv, GainBlessing = gainBlessing, ItemPackage = itemPackage, CrystalPackage = crystalList, SparePackage = sparePackage, EnchantPackage = enchantPackage, MailContent = mailContent, IsTasked = false, TaskDate = MathUtils.SqlMinDate, OpUserID = opUserID, CreateDate = DateTime.Now, HonourNum = honourNum, Items = itemPackage, }; var cacheSet = new ShareCacheStruct <UserTakePrize>(); cacheSet.Add(userPrizeLog); cacheSet.Update(); PutCrystal(crystalList.Split(','), str); // 发送系统信件 UserMail userMail = new UserMail(newGuid); userMail.UserId = userID; userMail.MailType = (int)MailType.System; userMail.Title = LanguageManager.GetLang().St_SystemMailTitle; userMail.Content = mailContent; userMail.SendDate = DateTime.Now; TjxMailService mailService = new TjxMailService(user); mailService.Send(userMail); } catch (Exception ex) { new BaseLog().SaveLog(ex); } } }
private JsonResult verifyDeliver(Dictionary <string, string> parms) { receipt = new JsonResult(); receipt.ResultCode = 0; JsonOrderInfo jsonorder = null; JsonCustomData jsoncustom = null; try { parms.TryGetValue("DATA", out _data); jsonorder = MathUtils.ParseJson <JsonOrderInfo>(_data); if (jsonorder == null) { receipt.ResultString = "DATA 数据解析错误"; return(receipt); } jsonorder.CustomData = CryptoHelper.HttpBase64Decode(jsonorder.CustomData); jsonorder.CustomData = HttpUtility.UrlDecode(jsonorder.CustomData); jsoncustom = MathUtils.ParseJson <JsonCustomData>(jsonorder.CustomData); if (jsoncustom == null) { receipt.ResultString = "CustomData 自定义数据解析错误"; return(receipt); } } catch (Exception e) { receipt.ResultString = "解析失败!JSON格式错误"; TraceLog.WriteError(string.Format("{0}\n {1}\n {2}", receipt.ResultString, _data, e)); return(receipt); } try { // MD5 string signParameter = md5key + jsonorder.OrderId + jsonorder.CpOrderId + jsonorder.Amount + jsoncustom.PayId; string sign = CryptoHelper.MD5_Encrypt(signParameter, Encoding.UTF8).ToLower(); if (sign.CompareTo(jsonorder.Sign) != 0) { receipt.ResultString = "MD5验证失败"; return(receipt); } var orderInfoCache = new ShareCacheStruct <OrderInfoCache>(); var orderinfo = orderInfoCache.FindKey(jsonorder.OrderId); if (orderinfo != null) {// 如果是已经发货了,返回成功 receipt.ResultCode = 1; receipt.ResultString = "该订单已经发货"; return(receipt); } UserBasisCache user = UserHelper.FindUserBasisOfRetail(jsoncustom.RetailID, jsonorder.OpenId, jsoncustom.ServerID); if (user == null) {// 优先使用OpenId + RetailID + ServerID来获取充值角色 user = UserHelper.FindUserBasis(jsonorder.UserId); if (user == null) { receipt.ResultString = "没有找到该玩家"; return(receipt); } } UserPayCache userpay = UserHelper.FindUserPay(user.UserID); if (userpay == null) { receipt.ResultString = "没有找到该玩家充值信息表"; return(receipt); } var paycfg = new ShareCacheStruct <Config_Pay>().FindKey(jsoncustom.PayId); if (paycfg == null) { receipt.ResultString = "PayId 错误"; return(receipt); } int deliverNum = paycfg.AcquisitionDiamond + paycfg.PresentedDiamond; if (jsonorder.Amount != paycfg.PaySum) { receipt.ResultString = "金额错误"; TraceLog.WriteError("Pay error Uid:{0}, Name:{1}, OrderAmount:{2}, ConfigAmount:{3} .", user.UserID, user.NickName, jsonorder.Amount, paycfg.PaySum); return(receipt); } if (!UserHelper.OnWebPay(user.UserID, jsoncustom.PayId)) { receipt.ResultString = "发货失败"; return(receipt); } OrderInfoCache newOrderInfo = new OrderInfoCache() { OrderId = jsonorder.OrderId, UserId = user.UserID, NickName = user.NickName, MerchandiseName = paycfg.Identifying, PayId = jsoncustom.PayId, Amount = jsonorder.Amount, PassportID = user.Pid, ServerID = user.ServerID, GameCoins = deliverNum, CreateDate = DateTime.Now, RetailID = jsoncustom.RetailID, RcId = jsonorder.RcId }; orderInfoCache.Add(newOrderInfo); orderInfoCache.Update(); receipt.ResultCode = 1; receipt.ResultString = "SUCCEED"; } catch (Exception e) { receipt.ResultString = "发货过程出现异常"; TraceLog.WriteError(string.Format("{0}\n {1}\n {2}", receipt.ResultString, _data, e)); return(receipt); } return(receipt); }
public override bool TakeAction() { receipt = ReceiveCdKeyResult.OK; //if (GetEventAward.IsReceivedCDK) //{ // receipt = ReceiveCdKeyResult.Had; // return true; //} var acc = new ShareCacheStruct <Config_CdKey>().Find(t => t.Key == _CDKey); if (acc == null) { receipt = ReceiveCdKeyResult.Invalid; return(true); } var cdkscache = new ShareCacheStruct <CDKeyCache>(); if (cdkscache.FindKey(_CDKey) != null) { receipt = ReceiveCdKeyResult.Received; return(true); } if (GetEventAward.ReceivedCDKTypeList.Find(t => t == acc.Type) != 0) { receipt = ReceiveCdKeyResult.Had; return(true); } CDKeyCache cdk = new CDKeyCache() { CDKey = _CDKey, UsedTime = DateTime.Now }; GetEventAward.IsReceivedCDK = true; GetEventAward.ReceivedCDKTypeList.Add(acc.Type); cdkscache.Add(cdk); cdkscache.Update(); List <ItemData> itemlist = new List <ItemData>(); itemlist.Add(new ItemData() { ID = acc.AAwardID, Num = acc.AAwardN }); itemlist.Add(new ItemData() { ID = acc.BAwardID, Num = acc.BAwardN }); itemlist.Add(new ItemData() { ID = acc.CAwardID, Num = acc.CAwardN }); itemlist.Add(new ItemData() { ID = acc.DAwardID, Num = acc.DAwardN }); UserHelper.RewardsItems(Current.UserId, itemlist); return(true); }
public static void InitData() { VitInit = ConfigEnvSet.GetInt("User.VitInit"); VitMax = ConfigEnvSet.GetInt("User.VitMax"); VitRestore = ConfigEnvSet.GetInt("User.VitRestore"); CombatLogCountMax = ConfigEnvSet.GetInt("User.CombatLogCountMax"); FriendCountMax = ConfigEnvSet.GetInt("User.FriendCountMax"); FriendApplyCountMax = ConfigEnvSet.GetInt("User.FriendApplyCountMax"); FriendGiveAwayCountMax = ConfigEnvSet.GetInt("User.FriendGiveAwayCountMax"); FriendGiveAwayVitValue = ConfigEnvSet.GetInt("User.FriendGiveAwayVitValue"); RepairSignNeedDiamond = ConfigEnvSet.GetInt("User.RepairSignNeedDiamond"); MaxMailNum = ConfigEnvSet.GetInt("User.MaxMailNum"); OpenTaskSystemUserLevel = ConfigEnvSet.GetInt("System.OpenTaskSystemUserLevel"); OpenRankSystemUserLevel = ConfigEnvSet.GetInt("System.OpenRankSystemLevel"); InviteFightAwardGold = ConfigEnvSet.GetInt("User.InviteFightAwardGold"); InviteFightDiamondWeekMax = ConfigEnvSet.GetInt("User.InviteFightDiamondWeekMax"); var guildlist = new ShareCacheStruct <GuildsCache>().FindAll(); foreach (var v in guildlist) { v.Lv = v.ConvertLevel(); } var gameCache = new ShareCacheStruct <GameCache>(); GameCache openServiceCache = gameCache.FindKey(OpenServiceDataCacheKey); if (openServiceCache == null) { openServiceCache = new GameCache(); openServiceCache.Key = OpenServiceDataCacheKey; openServiceCache.Value = DateTime.Now.ToString(); gameCache.Add(openServiceCache); gameCache.Update(); IsFirstOpenService = true; } OpenServiceDate = openServiceCache.Value.ToDateTime(); OpenServiceDate = new DateTime(OpenServiceDate.Year, 8 /*OpenServiceDate.Month*/, 1, 9, 0, 0); //GameCache signStartIDCache = gameCache.FindKey(SignStartIDCacheKey); //if (signStartIDCache == null) //{ // signStartIDCache = new GameCache(); // signStartIDCache.Key = SignStartIDCacheKey; // signStartIDCache.Value = "1"; // gameCache.Add(signStartIDCache); // gameCache.Update(); //} //SignStartID = signStartIDCache.Value.ToInt(); SignStartID = GetSignStartID(); // 加载老用户记录 var cacheSet = new MemoryCacheStruct <OldUserCache>(); var dbProvider = DbConnectionProvider.CreateDbProvider(DbConfig.Log); string sql = "SELECT OpenID,NickName,AvatarUrl,CreateDate FROM OldUserLog"; using (IDataReader reader = dbProvider.ExecuteReader(CommandType.Text, sql)) { while (reader.Read()) { OldUserCache olduser = new OldUserCache(); olduser.OpenID = reader["OpenID"].ToString(); olduser.NickName = reader["NickName"].ToString(); olduser.AvatarUrl = reader["AvatarUrl"].ToString(); olduser.CreateDate = reader["CreateDate"].ToDateTime(); cacheSet.TryAdd(olduser.OpenID, olduser); } } // 排行榜奖励数据 GameCache levelCache = gameCache.FindKey(LevelRankingAwardCacheKey); if (levelCache == null) { levelCache = new GameCache(); levelCache.Key = LevelRankingAwardCacheKey; levelCache.Value = MathUtils.ToJson(LevelRankingAwardCacheList); gameCache.Add(levelCache); gameCache.Update(); } LevelRankingAwardCacheList = MathUtils.ParseJson <CacheList <UserRankAward> >(levelCache.Value); GameCache fightValueCache = gameCache.FindKey(FightValueRankingAwardCacheKey); if (fightValueCache == null) { fightValueCache = new GameCache(); fightValueCache.Key = FightValueRankingAwardCacheKey; fightValueCache.Value = MathUtils.ToJson(FightValueRankingAwardCacheList); gameCache.Add(fightValueCache); gameCache.Update(); } FightValueRankingAwardCacheList = MathUtils.ParseJson <CacheList <UserRankAward> >(fightValueCache.Value); GameCache comboCache = gameCache.FindKey(ComboRankingAwardCacheKey); if (comboCache == null) { comboCache = new GameCache(); comboCache.Key = ComboRankingAwardCacheKey; comboCache.Value = MathUtils.ToJson(ComboRankingAwardCacheList); gameCache.Add(comboCache); gameCache.Update(); } ComboRankingAwardCacheList = MathUtils.ParseJson <CacheList <UserRankAward> >(comboCache.Value); }
public override bool TakeAction() { var guildsSet = new ShareCacheStruct <GuildsCache>(); if (!GetGuild.GuildID.IsEmpty()) { var oldguild = guildsSet.FindKey(GetGuild.GuildID); if (oldguild != null && oldguild.FindMember(Current.UserId) != null) { return(false); } } int needDiamond = ConfigEnvSet.GetInt("User.CreateGuildNeedDiamond"); if (GetBasis.DiamondNum < needDiamond) { receipt = RequestGuildResult.NoDiamond; return(true); } if (guildsSet.Find(t => t.GuildName == _guildName) != null) { receipt = RequestGuildResult.HadName; return(true); } GuildsCache guild = new GuildsCache() { GuildID = Guid.NewGuid().ToString(), GuildName = _guildName, Liveness = 0, RankID = 0, CreateDate = DateTime.Now, Lv = 1 }; GuildCharacter member = new GuildCharacter() { UserID = Current.UserId, JobTitle = GuildJobTitle.Atevent, Liveness = 0 }; guild.AddNewMember(member); GuildLogData log = new GuildLogData() { UserId = Current.UserId, UserName = GetBasis.NickName, LogTime = DateTime.Now, Content = string.Format("玩家 {0} 创建了公会。", GetBasis.NickName), }; guild.NewLog(log); guildsSet.Add(guild); guildsSet.Update(); GetGuild.GuildID = guild.GuildID; PushMessageHelper.JoinGuildNotification(Current); GlobalRemoteService.SendUserData(GetBasis, GetGuild.GuildID); receipt = RequestGuildResult.Successfully; return(true); }