예제 #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>
        /// <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); //每月礼包
        }