public override bool TakeAction() { receipt = new RestoreUserData(); //receipt.Vit = GetBasis.Vit; //receipt.CombatTimes = GetCombat.CombatTimes; //receipt.GiveAwayCount = GetFriends.GiveAwayCount; receipt.Combat = GetCombat; receipt.Task = GetTask; receipt.LotteryTimes = GetLottery.LotteryTimes; receipt.SignStartID = DataHelper.SignStartID; receipt.EventAward = GetEventAward; //receipt.IsTodayLottery = false; //var lottery = new ShareCacheStruct<Config_Lottery>().FindKey(GetBasis.RandomLotteryId); //if (lottery != null) //{ // receipt.LotteryAwardType = lottery.Type; // receipt.LotteryId = lottery.Content.ToInt(); //} UserPayCache userpay = UserHelper.FindUserPay(Current.UserId); if (userpay != null) { receipt.QuarterCardDays = userpay.QuarterCardDays; receipt.MonthCardDays = userpay.MonthCardDays; } return(true); }
public override bool TakeAction() { UserPayCache usepay = UserHelper.FindUserPay(Current.UserId); if (usepay == null || usepay.PayMoney == 0) { return(false); } //receipt = new JPRequestSFOData(); //receipt.Result = EventStatus.Bad; if (usepay.IsReceiveFirstPay) { return(true); } usepay.IsReceiveFirstPay = true; List <ItemData> items = new List <ItemData>(); items.Add(new ItemData() { ID = 10002, Num = 2 }); items.Add(new ItemData() { ID = 10006, Num = 1 }); items.Add(new ItemData() { ID = 22002, Num = 1 }); items.Add(new ItemData() { ID = 32005, Num = 1 }); UserHelper.RewardsItems(Current.UserId, items); //UserHelper.RewardsGold(Current.UserId, 100000); //UserHelper.RewardsDiamond(Current.UserId, 20); //UserHelper.RewardsItem(Current.UserId, 20024, 1); //UserHelper.RewardsItem(Current.UserId, 32005, 1); ////usepay.WeekCardDays += 7; ////PushMessageHelper.UserPaySucceedNotification(Current); receipt = true; return(true); }
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 static UserBasisCache CreateRole(int _UserId, string _Sid, int _ServerID, string _Pid, string _RetailID, string _UserName, int _profession, string _HeadID) { // Basis初始化 UserBasisCache basis = new UserBasisCache(_UserId); basis.IsRefreshing = true; basis.SessionID = _Sid; basis.ServerID = _ServerID; basis.Pid = _Pid; basis.RetailID = _RetailID; basis.NickName = _UserName; basis.UserLv = (short)ConfigEnvSet.GetInt("User.Level"); basis.RewardsDiamond = ConfigEnvSet.GetInt("User.InitDiamond"); //bisis.Vit = DataHelper.InitVit; basis.VipLv = ConfigEnvSet.GetInt("User.VipLv"); basis.Profession = _profession; basis.AvatarUrl = _HeadID; basis.UserStatus = UserStatus.MainUi; basis.LoginDate = DateTime.Now; basis.CreateDate = DateTime.Now; basis.OfflineDate = DateTime.Now; basis.Gold = ConfigEnvSet.GetString("User.InitGold"); basis.OfflineEarnings = "0"; var cacheSet = new PersonalCacheStruct <UserBasisCache>(); cacheSet.Add(basis); cacheSet.Update(); // 属性初始化 UserAttributeCache attcache = new UserAttributeCache(); attcache.UserID = basis.UserID; var attributeSet = new PersonalCacheStruct <UserAttributeCache>(); attributeSet.Add(attcache); attributeSet.Update(); // 装备初始化 UserEquipsCache equipcache = new UserEquipsCache(); equipcache.UserID = basis.UserID; equipcache.ResetCache(); var equipsSet = new PersonalCacheStruct <UserEquipsCache>(); equipsSet.Add(equipcache); equipsSet.Update(); // 背包初始化 UserPackageCache packagecache = new UserPackageCache(); packagecache.UserID = basis.UserID; packagecache.ResetCache(); var packageSet = new PersonalCacheStruct <UserPackageCache>(); packagecache.AddItem(20001, 1); packagecache.AddItem(20012, 1); packagecache.AddItem(20023, 1); packagecache.AddItem(20034, 1); packagecache.AddItem(20045, 1); packagecache.AddItem(20056, 1); packagecache.AddItem(20067, 1); //for (int i = 20001; i < 20077; ++i) // packagecache.AddItem(i, 10); //for (int i = 30001; i < 30005; ++i) // packagecache.AddItem(i, 9999); //for (int i = 40001; i < 40009; ++i) // packagecache.AddItem(i, 1); packageSet.Add(packagecache); packageSet.Update(); // 战魂初始化 UserSoulCache soulcache = new UserSoulCache(); soulcache.UserID = basis.UserID; soulcache.ResetCache(); var soulSet = new PersonalCacheStruct <UserSoulCache>(); soulSet.Add(soulcache); soulSet.Update(); // 技能初始化 UserSkillCache skillcache = new UserSkillCache(); skillcache.UserID = basis.UserID; skillcache.ResetCache(_profession); var skillSet = new PersonalCacheStruct <UserSkillCache>(); skillSet.Add(skillcache); skillSet.Update(); // 好友初始化 UserFriendsCache friendscache = new UserFriendsCache(); friendscache.UserID = basis.UserID; friendscache.ResetCache(); var friendsSet = new PersonalCacheStruct <UserFriendsCache>(); friendsSet.Add(friendscache); friendsSet.Update(); // 成就初始化 UserAchievementCache achievecache = new UserAchievementCache(); achievecache.UserID = basis.UserID; achievecache.ResetCache(); var achieveSet = new PersonalCacheStruct <UserAchievementCache>(); achieveSet.Add(achievecache); achieveSet.Update(); // 充值初始化 UserPayCache paycache = new UserPayCache(); paycache.UserID = basis.UserID; paycache.ResetCache(); var paySet = new PersonalCacheStruct <UserPayCache>(); paySet.Add(paycache); paySet.Update(); // 邮箱初始化 UserMailBoxCache mailcache = new UserMailBoxCache(); mailcache.UserID = basis.UserID; mailcache.ResetCache(); var mailSet = new PersonalCacheStruct <UserMailBoxCache>(); MailData mail = new MailData() { ID = Guid.NewGuid().ToString(), Title = "恭喜您已获得月卡免费体验资格", Sender = "系统", Date = DateTime.Now, Context = "恭喜您已获得月卡免费体验资格,月卡有效期为1天,为了您能获得更好的游戏体验,您可以在充值页面续费成为我们正式的月卡用户!", }; UserHelper.AddNewMail(basis.UserID, mail, false); mailSet.Add(mailcache); mailSet.Update(); // 任务初始化 UserTaskCache taskcache = new UserTaskCache(); taskcache.UserID = basis.UserID; taskcache.ResetCache(); var taskSet = new PersonalCacheStruct <UserTaskCache>(); taskSet.Add(taskcache); taskSet.Update(); // 竞技场初始化 UserCombatCache combatcache = new UserCombatCache(); combatcache.UserID = basis.UserID; combatcache.ResetCache(); var combatSet = new PersonalCacheStruct <UserCombatCache>(); combatSet.Add(combatcache); combatSet.Update(); // 活动相关初始化 UserEventAwardCache eventawardcache = new UserEventAwardCache(); eventawardcache.UserID = basis.UserID; eventawardcache.ResetCache(); var eventAwardSet = new PersonalCacheStruct <UserEventAwardCache>(); eventAwardSet.Add(eventawardcache); eventAwardSet.Update(); // 公会初始化 UserGuildCache guildcache = new UserGuildCache(); guildcache.UserID = basis.UserID; guildcache.ResetCache(); var guildSet = new PersonalCacheStruct <UserGuildCache>(); guildSet.Add(guildcache); guildSet.Update(); // 精灵初始化 UserElfCache elfcache = new UserElfCache(); elfcache.UserID = basis.UserID; elfcache.ResetCache(); var elfSet = new PersonalCacheStruct <UserElfCache>(); elfSet.Add(elfcache); elfSet.Update(); // 赠送物品初始化 UserTransferItemCache transfercache = new UserTransferItemCache(); transfercache.UserID = basis.UserID; transfercache.ResetCache(); var transferSet = new PersonalCacheStruct <UserTransferItemCache>(); transferSet.Add(transfercache); transferSet.Update(); // 仇人数据初始化 UserEnemysCache enemy = new UserEnemysCache(); enemy.UserID = basis.UserID; enemy.ResetCache(); var enemySet = new PersonalCacheStruct <UserEnemysCache>(); enemySet.Add(enemy); enemySet.Update(); // 抽奖数据初始化 UserLotteryCache lottery = new UserLotteryCache(); lottery.UserID = basis.UserID; lottery.ResetCache(); var lotterySet = new PersonalCacheStruct <UserLotteryCache>(); lotterySet.Add(lottery); lotterySet.Update(); UserHelper.RefreshUserFightValue(basis.UserID, false); // 排行榜初始化 UserRank combatRank = new UserRank() { UserID = basis.UserID, NickName = basis.NickName, Profession = basis.Profession, UserLv = basis.UserLv, AvatarUrl = basis.AvatarUrl, VipLv = basis.VipLv, FightValue = attcache.FightValue, RankId = int.MaxValue, RankDate = DateTime.Now, }; Ranking <UserRank> combatranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey); var combat = combatranking as CombatRanking; combat.TryAppend(combatRank); combat.rankList.Add(combatRank); UserRank levelRank = new UserRank(combatRank); Ranking <UserRank> levelranking = RankingFactory.Get <UserRank>(LevelRanking.RankingKey); var level = levelranking as LevelRanking; level.TryAppend(levelRank); level.rankList.Add(levelRank); UserRank fightRank = new UserRank(combatRank); Ranking <UserRank> fightranking = RankingFactory.Get <UserRank>(FightValueRanking.RankingKey); var fight = fightranking as FightValueRanking; fight.TryAppend(fightRank); fight.rankList.Add(fightRank); UserRank comboRank = new UserRank(combatRank); Ranking <UserRank> comboranking = RankingFactory.Get <UserRank>(ComboRanking.RankingKey); var combo = comboranking as ComboRanking; combo.TryAppend(comboRank); combo.rankList.Add(comboRank); UserHelper.RestoreUserData(basis.UserID); UserHelper.EveryDayTaskProcess(basis.UserID, TaskType.Login, 1, false); //UserHelper.AddMouthCardMail(basis.UserID); return(basis); }
private JsonResult verifyDeliver(Dictionary <string, string> parms) { receipt = new JsonResult(); receipt.ResultCode = 0; try { while (true) { parms.TryGetValue("DATA", out _data); JsonInfo jsoninfo = MathUtils.ParseJson <JsonInfo>(_data); if (jsoninfo == null) { receipt.ResultString = "数据解析错误"; break; } // MD5 string signParameter = md5key + jsoninfo.UserId + jsoninfo.ServerID + jsoninfo.PayId; string sign = CryptoHelper.MD5_Encrypt(signParameter, Encoding.UTF8).ToLower(); if (sign.CompareTo(jsoninfo.Sign) != 0) { receipt.ResultString = "MD5验证失败"; break; } UserBasisCache user = UserHelper.FindUserBasis(jsoninfo.UserId); if (user == null || user.ServerID != jsoninfo.ServerID) { receipt.ResultString = "没有找到该玩家"; break; } UserPayCache userpay = UserHelper.FindUserPay(user.UserID); if (userpay == null) { receipt.ResultString = "没有找到该玩家充值信息表"; break; } var paycfg = new ShareCacheStruct <Config_Pay>().FindKey(jsoninfo.PayId); if (paycfg == null) { receipt.ResultString = "PayId 错误"; break; } if (!UserHelper.OnWebPay(user.UserID, jsoninfo.PayId)) { receipt.ResultString = "发货失败"; return(receipt); } receipt.ResultCode = 1; receipt.ResultString = "SUCCEED"; break; } } catch (Exception e) { receipt.ResultString = "Url参数格式错误"; TraceLog.WriteError(string.Format("{0} {1}", receipt.ResultString, e)); return(receipt); } return(receipt); }