Beispiel #1
0
 MessageCode SaveExchange(CrossladderManagerEntity ladderManager, ItemPackageFrame package, CrossladderExchangerecordEntity ladderExchangerecord)
 {
     if (ladderManager == null || package == null || ladderExchangerecord == null)
     {
         return(MessageCode.NbUpdateFail);
     }
     try
     {
         if (!CrossladderManagerMgr.Update(ladderManager))
         {
             return(MessageCode.NbUpdateFail);
         }
         if (!package.Save())
         {
             return(MessageCode.NbUpdateFail);
         }
         if (!CrossladderExchangerecordMgr.Insert(ladderExchangerecord))
         {
             return(MessageCode.NbUpdateFail);
         }
         return(MessageCode.Success);
     }
     catch (Exception ex)
     {
         SystemlogMgr.Error("CrossLadder-SaveExchange", ex);
         return(MessageCode.Exception);
     }
 }
Beispiel #2
0
 public MessageCode SaveInvitePrize(NbManagerEntity manager, FriendinvitePrizerecordEntity record, ItemPackageFrame package, DbTransaction trans, int coin, string account)
 {
     if (manager != null)
     {
         if (!ManagerUtil.SaveManagerData(manager, null, trans))
         {
             return(MessageCode.NbUpdateFailPackage);
         }
     }
     if (coin > 0)
     {
         var mess = ManagerCore.Instance.AddCoin(manager, coin, EnumCoinChargeSourceType.FriendInvite, Guid.NewGuid().ToString(), trans);
         if (mess != MessageCode.Success)
         {
             return(mess);
         }
     }
     if (!FriendinvitePrizerecordMgr.Insert(record, trans))
     {
         return(MessageCode.NbUpdateFailPackage);
     }
     if (!package.Save(trans))
     {
         return(MessageCode.NbUpdateFailPackage);
     }
     package.Shadow.Save();
     return(MessageCode.Success);
 }
Beispiel #3
0
        private MessageCode Tran_SaveWincountPrizePrize(DbTransaction transaction, NbManagerEntity manager, LeagueWincountrecordEntity leagueWincountRecord, ItemPackageFrame package, int point, int coin)
        {
            if (point > 0)
            {
                var code = PayCore.Instance.AddBonus(leagueWincountRecord.ManagerId, point,
                                                     EnumChargeSourceType.LeaguePrize, ShareUtil.GenerateComb().ToString(), transaction);
                if (code != MessageCode.Success)
                {
                    return(code);
                }
            }
            else if (coin > 0)
            {
                var code = ManagerCore.Instance.AddCoin(manager, coin, EnumCoinChargeSourceType.LeaguePrize,
                                                        ShareUtil.GenerateComb().ToString(), transaction);
                if (code != MessageCode.Success)
                {
                    return(code);
                }
            }
            else
            {
                if (!package.Save(transaction))
                {
                    return(MessageCode.FailUpdate);
                }
                package.Shadow.Save();
            }

            if (!LeagueWincountrecordMgr.Update(leagueWincountRecord, transaction))
            {
                return(MessageCode.FailUpdate);
            }
            return(MessageCode.Success);
        }
Beispiel #4
0
        MessageCode SaveLuckDraw(Guid managerId, int addPoint, int addCoin, bool isAddPackage, ItemPackageFrame package, NbManagerEntity manager, TurntableFrame turntable, TurntableLuckyrecordEntity record, DbTransaction trans)
        {
            var messageCode = MessageCode.Success;

            if (addPoint > 0)
            {
                messageCode = PayCore.Instance.AddBonus(managerId, addPoint, EnumChargeSourceType.Turntable, ShareUtil.GenerateComb().ToString(), trans);
                if (messageCode != MessageCode.Success)
                {
                    return(messageCode);
                }
            }
            if (addCoin > 0)
            {
                messageCode = ManagerCore.Instance.AddCoin(manager, addCoin, EnumCoinChargeSourceType.Turntable, ShareUtil.GenerateComb().ToString(), trans);
                if (messageCode != MessageCode.Success)
                {
                    return(messageCode);
                }
            }
            if (!turntable.Save(trans))
            {
                return(MessageCode.NbUpdateFail);
            }
            if (isAddPackage)
            {
                if (!package.Save(trans))
                {
                    return(MessageCode.NbUpdateFail);
                }
                package.Shadow.Save();
            }
            TurntableLuckyrecordMgr.Insert(record, trans);
            return(MessageCode.Success);
        }
Beispiel #5
0
        static MessageCode InnerSaveMix(Guid mid, ItemPackageFrame pack, SkillBagWrap bag, ItemInfoEntity mixItems, string setSkills = null)
        {
            string itemMap   = mixItems.ItemId.ToString();
            int    errorCode = (int)MessageCode.FailUpdate;

            using (var tranMgr = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
            {
                tranMgr.BeginTransaction();
                do
                {
                    if (null != pack && !pack.Save(tranMgr.TransactionObject))
                    {
                        break;
                    }
                    NbManagerskillbagMgr.MixUpTran(false, mid, setSkills, bag.SetMap, itemMap, bag.RawBag.RowVersion, ref errorCode);
                }while (false);
                if (errorCode == (int)MessageCode.Success)
                {
                    tranMgr.Commit();
                }
                else
                {
                    tranMgr.Rollback();
                }
            }
            itemMap = null;
            return((MessageCode)errorCode);
        }
Beispiel #6
0
 private MessageCode SaveRankPrize(NbManagerEntity manager, LeagueRecordEntity leagueRecord, LeagueManagerrecordEntity mLeagueRecord, LaegueManagerinfoEntity leagueManagerinfo, ItemPackageFrame package, int point, DbTransaction trans)
 {
     if (!ManagerUtil.SaveManagerData(manager, null, trans))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (!LeagueRecordMgr.Update(leagueRecord, trans))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (!LeagueManagerrecordMgr.Update(mLeagueRecord, trans))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (!LaegueManagerinfoMgr.Update(leagueManagerinfo, trans))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (package != null)
     {
         if (!package.Save(trans))
         {
             return(MessageCode.NbUpdateFail);
         }
         package.Shadow.Save();
     }
     if (point > 0)
     {
         var code = PayCore.Instance.AddBonus(manager.Idx, point, EnumChargeSourceType.LeaguePrize,
                                              ShareUtil.GenerateComb().ToString(), trans);
         return(code);
     }
     return(MessageCode.Success);
 }
Beispiel #7
0
 private MessageCode SaveMatchConfirm(NbManagerEntity manager, ItemPackageFrame package, LeagueRecordEntity leagueRecordInfo,
                                      LeagueManagerrecordEntity nextManagerRecord, LeagueManagerrecordEntity leagueManagerRecord, int point,
                                      bool isUpdatenextManagerRecord, LaegueManagerinfoEntity leagueManagerInfo, LeagueFightMapFrame fightMap, NbManagerextraEntity managerExtra, LeagueWincountrecordEntity leagueWinCount, DbTransaction trans)
 {
     if (!ManagerUtil.SaveManagerData(manager, managerExtra, trans))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (!NbManagerextraMgr.Update(managerExtra, trans))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (package != null)
     {
         if (!package.Save(trans))
         {
             return(MessageCode.NbUpdateFail);
         }
         package.Shadow.Save();
     }
     if (!LeagueRecordMgr.Update(leagueRecordInfo, trans))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (isUpdatenextManagerRecord)
     {
         if (nextManagerRecord != null)
         {
             if (!LeagueManagerrecordMgr.Update(nextManagerRecord, trans))
             {
                 return(MessageCode.NbUpdateFail);
             }
         }
     }
     if (!LaegueManagerinfoMgr.Update(leagueManagerInfo, trans))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (!LeagueManagerrecordMgr.Update(leagueManagerRecord, trans))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (point > 0)
     {
         var code = PayCore.Instance.AddBonus(manager.Idx, point, EnumChargeSourceType.LeaguePrize,
                                              ShareUtil.GenerateComb().ToString(), trans);
         return(code);
     }
     if (!fightMap.SaveFIghtMap(trans))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (!LeagueWincountrecordMgr.Update(leagueWinCount, trans))
     {
         return(MessageCode.NbUpdateFail);
     }
     return(MessageCode.Success);
 }
Beispiel #8
0
 MessageCode Tran_SaveExchange(DbTransaction transaction, LadderManagerEntity ladderManager, ItemPackageFrame package, LadderExchangerecordEntity ladderExchangerecord)
 {
     if (!LadderManagerMgr.Update(ladderManager, transaction))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (!package.Save(transaction))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (!LadderExchangerecordMgr.Insert(ladderExchangerecord, transaction))
     {
         return(MessageCode.NbUpdateFail);
     }
     return(MessageCode.Success);
 }
Beispiel #9
0
        /// <summary>
        /// 更新物品并保存
        /// </summary>
        /// <param name="package"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        public MessageCode UpdateItem(ItemPackageFrame package, ItemInfoEntity item)
        {
            var code = package.Update(item);

            if (code == MessageCode.Success)
            {
                if (package.Save())
                {
                    package.Shadow.Save();
                    return(code);
                }
                else
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            return(code);
        }
Beispiel #10
0
        /// <summary>
        /// 删除物品,并保存
        /// </summary>
        /// <param name="package"></param>
        /// <param name="itemId"></param>
        /// <returns></returns>
        public MessageCode DeleteItem(ItemPackageFrame package, Guid itemId, int count = 0)
        {
            var code = package.Delete(itemId, count, true);

            if (code == MessageCode.Success)
            {
                if (package.Save())
                {
                    package.Shadow.Save();
                    return(code);
                }
                else
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            return(code);
        }
Beispiel #11
0
        private int SaveCharge(ItemPackageFrame package, string account, int sourceType, string orderId, int point, int chargePoint, decimal cash, int bonus, DbTransaction trans, string eqid)
        {
            int result = -1;

            PayChargehistoryMgr.ChargeCSDK(account, sourceType, orderId, point, chargePoint, cash, bonus, ref result, int.Parse(eqid), trans);
            if (result != 0)
            {
                return(result);
            }
            if (package != null)
            {
                if (!package.Save(trans))
                {
                    return((int)MessageCode.NbUpdateFail);
                }
                package.Shadow.Save();
            }
            return(0);
        }
Beispiel #12
0
        //MessageCode Tran_SaveLottery(DbTransaction transaction, Guid matchId, Guid managerId, ItemPackageFrame package, MailBuilder mail, int lotteryRepeatCode)
        MessageCode Tran_SaveLottery(DbTransaction transaction, Guid matchId, Guid managerId, int lotteryRepeatCode, ItemPackageFrame package, MailBuilder mail, int point)
        {
            MessageCode msg = MessageCode.Success;

            if (point > 0)
            {
                msg = PayCore.Instance.AddBonus(managerId, point, EnumChargeSourceType.PkMatchPrize,
                                                ShareUtil.GenerateComb().ToString(), transaction);
                if (msg != MessageCode.Success)
                {
                    return(msg);
                }
            }
            int returnCode = -2;

            PlayerkillInfoMgr.LotterySave(matchId, managerId, lotteryRepeatCode, ref returnCode, transaction);
            if (returnCode != 0)
            {
                return(MessageCode.NbUpdateFail);
            }
            if (package != null)
            {
                if (!package.Save(transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
                package.Shadow.Save();
            }
            if (mail != null)
            {
                if (!mail.Save(transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }

            return(MessageCode.Success);
        }
Beispiel #13
0
        /// <summary>
        /// 抽奖
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="zoneName"></param>
        /// <returns></returns>
        public CrossActivityPrizeResponse Prize(Guid managerId, string zoneName)
        {
            CrossActivityPrizeResponse response = new CrossActivityPrizeResponse();

            response.Data = new CrossActivityPrize();
            try
            {
                if (!IsActivity)
                {
                    return(ResponseHelper.Create <CrossActivityPrizeResponse>(MessageCode.CrowdNoData));
                }
                var managerInfo = NbManagerMgr.GetById(managerId, zoneName);
                if (managerInfo == null)
                {
                    return(ResponseHelper.Create <CrossActivityPrizeResponse>(MessageCode.NbParameterError));
                }
                var maxCount = CacheFactory.VipdicCache.GetEffectValue(managerInfo.VipLevel,
                                                                       (int)EnumVipEffect.BeThankfulActivity);
                var usedNumber = CrossactivityRecordMgr.GetActivityNumber(managerId, DateTime.Now.Date);
                if (maxCount <= usedNumber)
                {
                    return(ResponseHelper.Create <CrossActivityPrizeResponse>(MessageCode.DayNumberNot));
                }
                var result = Prize(managerInfo.VipLevel);
                CrossactivityRecordEntity entity = new CrossactivityRecordEntity(0, managerId, zoneName, result.PrizeId,
                                                                                 DateTime.Now);
                ItemPackageFrame package = null;
                int addPoint             = 0;
                int addGoldBar           = 0;
                int itemCode             = 0;
                int itemCount            = 0;
                var messageCode          = AddPrize(result, managerId, zoneName, ref package, ref addPoint, ref addGoldBar, ref itemCode, ref itemCount);
                if (messageCode != MessageCode.Success)
                {
                    return(ResponseHelper.Create <CrossActivityPrizeResponse>(messageCode));
                }
                if (addPoint > 0)
                {
                    messageCode = PayCore.Instance.AddBonus(managerInfo.Account, addPoint, EnumChargeSourceType.CrossActivity,
                                                            ShareUtil.GenerateComb().ToString(), null, zoneName);
                    if (messageCode != MessageCode.Success)
                    {
                        return(ResponseHelper.Create <CrossActivityPrizeResponse>(messageCode));
                    }
                }
                else if (package != null)
                {
                    if (!package.Save())
                    {
                        return(ResponseHelper.Create <CrossActivityPrizeResponse>(MessageCode.NbUpdateFail));
                    }
                    package.Shadow.Save();
                }
                else if (addGoldBar > 0)
                {
                    var goldBarManager = ScoutingGoldbarMgr.GetById(managerId, zoneName);
                    if (goldBarManager == null)
                    {
                        goldBarManager = new ScoutingGoldbarEntity(managerId, addGoldBar, 0, 0, 0, DateTime.Now,
                                                                   DateTime.Now);
                        if (!ScoutingGoldbarMgr.Insert(goldBarManager, null, zoneName))
                        {
                            return(ResponseHelper.Create <CrossActivityPrizeResponse>(MessageCode.NbUpdateFail));
                        }
                    }
                    else
                    {
                        goldBarManager.GoldBarNumber = goldBarManager.GoldBarNumber + addGoldBar;
                        if (!ScoutingGoldbarMgr.Update(goldBarManager, null, zoneName))
                        {
                            return(ResponseHelper.Create <CrossActivityPrizeResponse>(MessageCode.NbUpdateFail));
                        }
                    }
                }
                try
                {
                    CrossactivityRecordMgr.Insert(entity);
                }
                catch
                {
                }

                response.Data.MaxNumber  = maxCount;
                response.Data.PrizeId    = result.PrizeId;
                response.Data.UsedNumber = usedNumber + 1;
                response.Data.Number     = itemCount;
                response.Data.ItemCode   = itemCode;
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("抽奖", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }
Beispiel #14
0
        MessageCode Tran_SaveAttachment(DbTransaction transaction, List <MailInfoEntity> mails, ItemPackageFrame package, NbManagerEntity manager, int coin, int sophicate, int point, int prestige, int bindPoint, int addGoldBar, Guid managerId, int addluckyCoin, int addGameCoin)
        {
            var orderId = mails[0].Idx.ToString();

            foreach (var mail in mails)
            {
                if (!MailInfoMgr.Update(mail, transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (package != null)
            {
                if (!package.Save(transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }

            if (coin > 0)
            {
                var code = ManagerCore.Instance.AddCoin(manager, coin, EnumCoinChargeSourceType.MailAttachment, orderId, transaction);
                if (code != MessageCode.Success)
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (sophicate > 0)
            {
                int resultSophisticate = manager.Sophisticate;
                if (!NbManagerMgr.AddSophisticate(manager.Idx, sophicate, ref resultSophisticate, transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (point > 0)
            {
                var code = PayCore.Instance.AddBonus(manager.Account, point, EnumChargeSourceType.MailAttachment,
                                                     orderId, transaction);
                if (code != MessageCode.Success)
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (bindPoint > 0)
            {
                var payUser = PayUserMgr.GetById(manager.Account);
                if (payUser == null)
                {
                    payUser           = new PayUserEntity();
                    payUser.Account   = manager.Account;
                    payUser.BindPoint = bindPoint;
                    payUser.RowTime   = DateTime.Now;
                    payUser.IsNew     = true;
                }
                else
                {
                    payUser.BindPoint += bindPoint;
                }
                if (payUser.IsNew)
                {
                    if (!PayUserMgr.Insert(payUser, transaction))
                    {
                        return(MessageCode.NbUpdateFail);
                    }
                }
                else
                {
                    if (!PayUserMgr.Update(payUser, transaction))
                    {
                        return(MessageCode.NbUpdateFail);
                    }
                }
            }
            if (addGoldBar > 0)
            {
                var goldBarManager = ScoutingGoldbarMgr.GetById(managerId);
                if (goldBarManager == null)
                {
                    goldBarManager = new ScoutingGoldbarEntity(managerId, addGoldBar, 0, 0, 0, DateTime.Now,
                                                               DateTime.Now);
                    if (!ScoutingGoldbarMgr.Insert(goldBarManager, transaction))
                    {
                        return(MessageCode.NbUpdateFail);
                    }
                }
                else
                {
                    goldBarManager.GoldBarNumber = goldBarManager.GoldBarNumber + addGoldBar;
                    if (!ScoutingGoldbarMgr.Update(goldBarManager, transaction))
                    {
                        return(MessageCode.NbUpdateFail);
                    }
                }
                GoldbarRecordEntity record = new GoldbarRecordEntity(0, managerId, true, addGoldBar, (int)EnumCoinChargeSourceType.MailAttachment, DateTime.Now);
                GoldbarRecordMgr.Insert(record);
            }
            if (addluckyCoin > 0)
            {
                if (!TurntableManagerMgr.AddLuckyCoin(managerId, addluckyCoin, transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (addGameCoin > 0)
            {
                if (!PenaltykickManagerMgr.AddGameCurrency(managerId, addGameCoin, transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }

            return(MessageCode.Success);
        }
Beispiel #15
0
        /// <summary>
        /// 领取竞猜正确活动奖励
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="step"></param>
        /// <returns></returns>
        public EuropeGambleMatchResponse DrawPrize(Guid managerId, int step)
        {
            EuropeGambleMatchResponse response = new EuropeGambleMatchResponse();

            response.Data = new EuropeGambleMatch();
            try
            {
                var manager = ManagerCore.Instance.GetManager(managerId);
                if (manager == null)
                {
                    response.Code = (int)MessageCode.MissManager;
                    return(response);
                }
                var info      = GetMyGambleInfo(managerId);
                var prizeList = info.PrizeRecord.Split(',');
                if (prizeList.Length < step || prizeList[step - 1] == "0")
                {
                    response.Code = (int)MessageCode.TourNoPassPrize;
                    return(response);
                }
                if (prizeList[step - 1] == "2")
                {
                    response.Code = (int)MessageCode.NbPrizeRepeat;
                    return(response);
                }
                var prizeConfig = EuropeConfig.Instance.GetPrize(step);
                if (prizeConfig.Count <= 0)
                {
                    response.Code = (int)MessageCode.ActivityNoConfigPrize;
                    return(response);
                }
                ItemPackageFrame package = null;

                prizeList[step - 1] = "2";
                info.PrizeRecord    = String.Join(",", prizeList);
                info.UpdateTime     = DateTime.Now;
                int addPoint = 0;
                int addCoin  = 0;
                foreach (var prize in prizeConfig)
                {
                    switch (prize.PrizeType)
                    {
                    case 1:
                        addPoint += prize.PrizeCount;
                        break;

                    case 2:
                        addCoin += prize.PrizeCount;
                        break;

                    case 3:
                        if (package == null)
                        {
                            package = ItemCore.Instance.GetPackage(managerId,
                                                                   Entity.Enums.Shadow.EnumTransactionType.EuropeConfig);
                            if (package == null)
                            {
                                return(ResponseHelper.Create <EuropeGambleMatchResponse>(MessageCode.NbNoPackage));
                            }
                        }
                        package.AddItems(prize.PrizeCode, prize.PrizeCount);
                        break;
                    }
                }
                if (addCoin > 0)
                {
                    ManagerUtil.AddManagerData(manager, 0, addCoin, 0, EnumCoinChargeSourceType.Eruope,
                                               ShareUtil.GenerateComb().ToString());
                }

                using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
                {
                    transactionManager.BeginTransaction();
                    var code = MessageCode.FailUpdate;
                    do
                    {
                        if (addPoint > 0)
                        {
                            code = PayCore.Instance.AddBonus(managerId, addPoint, EnumChargeSourceType.Europe,
                                                             ShareUtil.GenerateComb().ToString(), transactionManager.TransactionObject);
                            if (code != MessageCode.Success)
                            {
                                break;
                            }
                        }
                        if (addCoin > 0)
                        {
                            if (!ManagerUtil.SaveManagerData(manager, null, transactionManager.TransactionObject))
                            {
                                break;
                            }
                        }
                        if (package != null)
                        {
                            if (!package.Save(transactionManager.TransactionObject))
                            {
                                break;
                            }
                            package.Shadow.Save();
                        }
                        if (!EuropeGambleMgr.Update(info, transactionManager.TransactionObject))
                        {
                            break;
                        }
                        code = MessageCode.Success;
                    } while (false);

                    if (code != MessageCode.Success)
                    {
                        transactionManager.Rollback();
                        response.Code = (int)MessageCode.GamblePayError;
                        return(response);
                    }
                    transactionManager.Commit();
                    response.Data.Point = PayCore.Instance.GetPoint(managerId);
                }
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("领取竞猜正确活动奖励", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }