Exemple #1
0
        MessageCode SaveExchange(LadderManagerEntity ladderManager, ItemPackageFrame package, LadderExchangerecordEntity ladderExchangerecord)
        {
            if (ladderManager == null || package == null || ladderExchangerecord == null)
            {
                return(MessageCode.NbUpdateFail);
            }
            try
            {
                using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
                {
                    transactionManager.BeginTransaction();
                    var messageCode = Tran_SaveExchange(transactionManager.TransactionObject, ladderManager, package, ladderExchangerecord);

                    if (messageCode == ShareUtil.SuccessCode)
                    {
                        transactionManager.Commit();
                    }
                    else
                    {
                        transactionManager.Rollback();
                    }
                    return(messageCode);
                }
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("SaveExchange", ex);
                return(MessageCode.Exception);
            }
        }
Exemple #2
0
        MessageCode SaveAttachment(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)
        {
            if (mails == null || mails.Count <= 0)
            {
                return(MessageCode.NbUpdateFail);
            }
            try
            {
                using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
                {
                    transactionManager.BeginTransaction();
                    var messageCode = Tran_SaveAttachment(transactionManager.TransactionObject, mails, package, manager, coin, sophicate, point, prestige, bindPoint, addGoldBar, managerId, addluckyCoin, addGameCoin);

                    if (messageCode == ShareUtil.SuccessCode)
                    {
                        transactionManager.Commit();
                        if (coin > 0)
                        {
                            ManagerCore.Instance.UpdateCoinAfter(manager);
                        }
                    }
                    else
                    {
                        transactionManager.Rollback();
                    }
                    return(messageCode);
                }
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("SaveTourMatch", ex);
                return(MessageCode.Exception);
            }
        }
Exemple #3
0
        TeammemberResponse SetEquipment(TeammemberEntity teammember, ItemPackageFrame package, ItemInfoEntity item, int mod)
        {
            var newEquip     = new EquipmentUsedEntity(item);
            var newEquipData = SerializationHelper.ToByte(newEquip);

            return(SaveSetEquipment(teammember, package, newEquipData, mod));
        }
Exemple #4
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);
        }
Exemple #5
0
        // MessageCode SaveLottery(Guid matchId, Guid managerId, ItemPackageFrame package, MailBuilder mail, int lotteryRepeatCode)
        MessageCode SaveLottery(Guid matchId, Guid managerId, int lotteryRepeatCode, ItemPackageFrame package, MailBuilder mail, int point)
        {
            try
            {
                using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
                {
                    transactionManager.BeginTransaction();
                    //var messageCode = Tran_SaveLottery(transactionManager.TransactionObject, matchId, managerId, package, mail, lotteryRepeatCode);
                    var messageCode = Tran_SaveLottery(transactionManager.TransactionObject, matchId, managerId, lotteryRepeatCode, package, mail, point);

                    if (messageCode == ShareUtil.SuccessCode)
                    {
                        transactionManager.Commit();
                    }
                    else
                    {
                        transactionManager.Rollback();
                    }
                    return(messageCode);
                }
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("SavePlayerKillLottery", ex);
                return(MessageCode.Exception);
            }
        }
Exemple #6
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);
     }
 }
Exemple #7
0
        public ItemPackageFrame GetPackage(Guid managerId, EnumTransactionType transactionType, string zoneId = "")
        {
            var package = new ItemPackageFrame(ItemPackageMgr.GetById(managerId, zoneId), transactionType, zoneId);

            //AchievementTaskCore.Instance.UpdatePlayCardCount(package);
            return(package);
        }
Exemple #8
0
        ItemPackageDataResponse BuildPackageResponse(ItemPackageFrame package, int itemType = 0)
        {
            var response = ResponseHelper.CreateSuccess <ItemPackageDataResponse>();

            response.Data = BuildPackageData(package, itemType);
            return(response);
        }
Exemple #9
0
        static List <ItemInfoEntity> GetPackItemList(Guid mid, ItemPackageFrame pack = null)
        {
            var packList = new List <ItemInfoEntity>();

            if (null == pack)
            {
                pack = ItemCore.Instance.GetPackageWithoutShadow(mid);
            }
            DicMallItemDataEntity mallCfg = null;

            foreach (var item in pack.GetItemsByType(0))
            {
                if (item.ItemType != (int)EnumItemType.MallItem)
                {
                    continue;
                }
                mallCfg = CacheFactory.ItemsdicCache.GetMallEntityWithoutPointByItemCode(item.ItemCode);
                if (null == mallCfg || mallCfg.EffectType != (int)EnumMallEffectType.SkillCardExp)
                {
                    continue;
                }
                packList.Add(item);
            }
            return(packList);
        }
Exemple #10
0
        /// <summary>
        /// 更新卡牌收集数量
        /// </summary>
        /// <param name="package"></param>
        /// <returns></returns>
        public MessageCode UpdatePlayCardCount(ItemPackageFrame package, string zoneId = "")
        {
            if (package == null)
            {
                return(MessageCode.Success);
            }
            var taskRecord = TaskRecordMgr.GetManagerTaskList(package.ManagerId, zoneId);

            if (taskRecord == null || taskRecord.Count == 0)
            {
                return(MessageCode.Success);
            }
            foreach (var item in taskRecord)
            {
                var task = CacheFactory.TaskConfigCache.GetTask(item.TaskId);
                if (task == null)
                {
                    continue;
                }
                var require = CacheFactory.TaskConfigCache.GetTaskByRequire(item.TaskId);
                if (require == null)
                {
                    continue;
                }
                switch (require.RequireType)
                {
                case (int)EnumTaskRequireFunc.PlayerCardStrengthCollection:
                    if (require.RequireSub >= 0 && require.RequireSub <= 4)
                    {
                        if (require.RequireThird >= 2 && require.RequireThird <= 9)
                        {
                            var number2 = package.GetStrengthCardCount(require.RequireSub, require.RequireThird);
                            if (number2 > 0)
                            {
                                SavePackageTask(item, number2, task, zoneId);
                            }
                        }
                    }
                    break;

                case (int)EnumTaskRequireFunc.PlayCardCollection:
                    var number1 = package.GetPlayCountByCardLevel(require.RequireSub);
                    if (number1 > 0)
                    {
                        SavePackageTask(item, number1, task, zoneId);
                    }
                    break;

                case (int)EnumTaskRequireFunc.PlayerCardLevel:
                    int number = package.GetLevelCardCount(require.RequireSub);
                    if (number > 0)
                    {
                        SavePackageTask(item, number, task, zoneId);
                    }
                    break;
                }
            }
            return(MessageCode.Success);
        }
Exemple #11
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);
 }
Exemple #12
0
        /// <summary>
        /// BuildPackageData
        /// </summary>
        /// <param name="package"></param>
        /// <param name="itemType"></param>
        /// <returns></returns>
        public ItemPackageData BuildPackageData(ItemPackageFrame package, int itemType = 0)
        {
            var data = new ItemPackageData();

            data.Items = package.GetItemsByType(itemType);
            var teammember = MatchDataHelper.GetSolutionTeammembers(package.ManagerId);

            ItemPackageFrame.CaluPackageCardKpi(data.Items, teammember);
            data.PackageSize = package.PackageSize;
            return(data);
        }
Exemple #13
0
        MessageCode Receive()
        {
            var exRecord = new ActivityexCountrecordEntity();

            exRecord.Idx              = 1;
            exRecord.ZoneActivityId   = 19;
            exRecord.ExcitingId       = 32;
            exRecord.GroupId          = 2;
            exRecord.ExData           = 6000;
            exRecord.CurData          = 6000;
            exRecord.ExStep           = 1;
            exRecord.AlreadySendCount = 0;

            var detail         = new TemplateActivityexdetailEntity(105, 32, 2, 1, 5000, 0, 0, 0, 1, 310161);
            int prizeItemcode  = detail.EffectValue;
            int prizeItemCount = exRecord.ExData - exRecord.AlreadySendCount;
            int itemCount      = 0;
            var group          = new TemplateActivityexgroupEntity(103, 32, 2, 1, 108, 3, false, 0, 5000);

            if (group.ExRequireId == (int)EnumActivityExRequire.ChargeCount) //充值计数
            {
                itemCount = prizeItemCount / group.RankCount;
                exRecord.AlreadySendCount += (itemCount * group.RankCount);
                if (detail.EffectRate > 0)
                {
                    prizeItemCount = itemCount * detail.EffectRate;
                }
            }
            else
            {
                exRecord.AlreadySendCount += prizeItemCount;
            }
            MessageCode           code           = MessageCode.Success;
            ItemPackageFrame      package        = null;
            ScoutingGoldbarEntity goldBarManager = null;
            bool isInsert = false;

            if (prizeItemcode > 10000) //物品
            {
                package = ItemCore.Instance.GetPackage(new Guid("A995C3B5-4CA2-4348-A1B0-A60E013163A5"), EnumTransactionType.ActivityExPrize);
                if (package == null || package.PackageSize < prizeItemCount)
                {
                    return(MessageCode.ItemPackageFull);
                }
                code = package.AddItems(prizeItemcode, prizeItemCount);
                if (code != MessageCode.Success)
                {
                    return(code);
                }
            }
            return(MessageCode.Success);
        }
Exemple #14
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);
        }
Exemple #15
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);
        }
Exemple #16
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);
        }
Exemple #17
0
        TeammemberResponse SaveSetEquipment(TeammemberEntity teammember, ItemPackageFrame package,
                                            byte[] newEquipData, int mod)
        {
            int    returnCode   = 0;
            string errorMessage = "";

            TeammemberMgr.SetEquipment(teammember.Idx, teammember.ManagerId, mod, newEquipData, package.NewItemString,
                                       package.RowVersion, ref returnCode, ref errorMessage);
            if (!string.IsNullOrEmpty(errorMessage))
            {
                SystemlogMgr.Error("SaveSetEquipment", errorMessage);
            }
            if (returnCode == ShareUtil.SuccessCode)
            {
                teammember.UsedEquipment = newEquipData;
                return(BuildTeammemberResponse(teammember.ManagerId, teammember.Idx, true));
            }
            else
            {
                return(ResponseHelper.Create <TeammemberResponse>(returnCode));
            }
        }
Exemple #18
0
        public ItemPackageResponse GetPackageResponse(Guid managerId)
        {
            var package  = ItemPackageMgr.GetById(managerId);
            var response = ResponseHelper.CreateSuccess <ItemPackageResponse>();

            response.Data = package;

            //AchievementTaskCore.Instance.UpdatePlayCardCount(new ItemPackageFrame(package));

            var packageItemsEntity = SerializationHelper.FromByte <ItemPackageItemsEntity>(package.ItemString);

            if (packageItemsEntity == null || packageItemsEntity.Items == null)
            {
                response.Data.Items = new List <ItemInfoEntity>();
            }
            else
            {
                var teammember = MatchDataHelper.GetSolutionTeammembers(managerId);
                ItemPackageFrame.CaluPackageCardKpi(packageItemsEntity.Items, teammember);
                response.Data.Items = packageItemsEntity.Items;
            }

            return(response);
        }
        public MessageCode AddPrize(ConfigCrossactivityprizeEntity prize, Guid managerId, string zoneName, ref ItemPackageFrame package, ref int addPoint, ref int addGoldBar, ref int itemCode, ref int itemCount)
        {
            switch (prize.PrizeType)
            {
            case (int)EnumCrossActivityType.Point:
                itemCount = RandomHelper.GetInt32(prize.PrizeCount, prize.PrizeCount2);
                addPoint  = itemCount;
                break;

            case (int)EnumCrossActivityType.Coin:
                break;

            case (int)EnumCrossActivityType.Item:
                if (package == null)
                {
                    package = ItemCore.Instance.GetPackage(managerId, EnumTransactionType.CrossActivity, zoneName);
                }
                if (package == null)
                {
                    return(MessageCode.NbParameterError);
                }
                itemCode  = prize.PrizeCode;
                itemCount = prize.PrizeCount;
                return(package.AddItems(prize.PrizeCode, prize.PrizeCount));

            case (int)EnumCrossActivityType.Random:
                itemCode = CacheFactory.LotteryCache.LotteryByLib(prize.PrizeCode);
                if (itemCode == 0)
                {
                    return(MessageCode.NbParameterError);
                }
                if (package == null)
                {
                    package = ItemCore.Instance.GetPackage(managerId, EnumTransactionType.CrossActivity, zoneName);
                }
                if (package == null)
                {
                    return(MessageCode.NbParameterError);
                }
                itemCount = prize.PrizeCount;
                return(package.AddItems(itemCode, prize.PrizeCount));

            case (int)EnumCrossActivityType.Equipment:
                itemCode = GetRandomDebris();;
                if (itemCode == 0)
                {
                    return(MessageCode.NbParameterError);
                }
                if (package == null)
                {
                    package = ItemCore.Instance.GetPackage(managerId, EnumTransactionType.CrossActivity, zoneName);
                }
                if (package == null)
                {
                    return(MessageCode.NbParameterError);
                }
                itemCount = prize.PrizeCount;
                return(package.AddItems(itemCode, prize.PrizeCount));

            case (int)EnumCrossActivityType.GoleBar:
                itemCount  = RandomHelper.GetInt32(prize.PrizeCount, prize.PrizeCount2);
                addGoldBar = itemCount;
                _ActivityInfo.GoldBarNumber = _ActivityInfo.GoldBarNumber - addGoldBar;
                if (_ActivityInfo.GoldBarNumber < 0)
                {
                    _ActivityInfo.GoldBarNumber = 0;
                }
                break;
            }
            return(MessageCode.Success);
        }
        /// <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);
        }
Exemple #21
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);
        }
Exemple #22
0
        /// <summary>
        /// 保存抽奖
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="addPoint"></param>
        /// <param name="addCoin"></param>
        /// <param name="isAddPackage"></param>
        /// <param name="package"></param>
        /// <param name="manager"></param>
        /// <param name="turntable"></param>
        /// <param name="record"></param>
        /// <returns></returns>
        MessageCode SaveLuckDraw(Guid managerId, int addPoint, int addCoin, bool isAddPackage, ItemPackageFrame package, NbManagerEntity manager, TurntableFrame turntable, TurntableLuckyrecordEntity record)
        {
            MessageCode messageCode = MessageCode.Success;

            using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetConnectionString(EnumDbType.Main)))
            {
                transactionManager.BeginTransaction();
                messageCode = SaveLuckDraw(managerId, addPoint, addCoin, isAddPackage, package, manager, turntable, record, transactionManager.TransactionObject);
                if (messageCode == MessageCode.Success)
                {
                    transactionManager.Commit();
                }
                else
                {
                    transactionManager.Rollback();
                }
            }
            return(messageCode);
        }
Exemple #23
0
        /// <summary>
        /// 发奖
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="prizeEntity"></param>
        /// <param name="specialItem"></param>
        /// <param name="addpoint"></param>
        /// <param name="addcoin"></param>
        /// <param name="isAddPackage"></param>
        /// <param name="package"></param>
        /// <param name="response"></param>
        /// <param name="record"></param>
        /// <returns></returns>
        MessageCode SendPrize(Guid managerId, ConfigTurntableprizeEntity prizeEntity, int specialItem, ref int addpoint, ref int addcoin, ref bool isAddPackage, ref ItemPackageFrame package, TurntableLuckDrawResponse response, TurntableLuckyrecordEntity record)
        {
            var messCode = MessageCode.Success;

            response.Data.PrizeCount = prizeEntity.ItemCount;
            switch (prizeEntity.PrizeType)
            {
            case (int)EnumTurntablePrizeType.Point:
                addpoint = prizeEntity.ItemCount;
                response.Data.PrizeCode = 0;
                response.Data.PrizeType = (int)EnumTurntablePrizeType.Point;
                record.LuckDrawString   = (int)prizeEntity.PrizeType + "," + prizeEntity.SubType + "," + prizeEntity.ItemCount;
                break;

            case (int)EnumTurntablePrizeType.Coin:
                addcoin = prizeEntity.ItemCount;
                response.Data.PrizeCode = 0;
                response.Data.PrizeType = (int)EnumTurntablePrizeType.Coin;
                record.LuckDrawString   = (int)prizeEntity.PrizeType + "," + prizeEntity.SubType + "," + prizeEntity.ItemCount;
                break;

            case (int)EnumTurntablePrizeType.Item:
                isAddPackage = true;
                messCode     = package.AddItems(prizeEntity.SubType, prizeEntity.ItemCount);
                if (messCode != MessageCode.Success)
                {
                    return(messCode);
                }
                response.Data.PrizeCode = prizeEntity.SubType;
                response.Data.PrizeType = (int)EnumTurntablePrizeType.Item;
                record.LuckDrawString   = (int)prizeEntity.PrizeType + "," + prizeEntity.SubType + "," + prizeEntity.ItemCount;
                break;

            case (int)EnumTurntablePrizeType.Random:
                isAddPackage = true;
                var itemCode  = CacheFactory.LotteryCache.LotteryByLib(prizeEntity.SubType);
                var itemCache = CacheFactory.ItemsdicCache.GetItem(itemCode);
                if (itemCache == null)
                {
                    return(MessageCode.ItemNotExists);
                }
                if (itemCache.ItemType == (int)EnumItemType.PlayerCard)
                {
                    messCode = package.AddPlayerCard(itemCode, 1, false, 1, false);
                }
                else
                {
                    messCode = package.AddItems(itemCode, prizeEntity.ItemCount);
                }
                if (messCode != MessageCode.Success)
                {
                    return(messCode);
                }
                response.Data.PrizeCode = itemCode;
                response.Data.PrizeType = (int)EnumTurntablePrizeType.Item;
                record.LuckDrawString   = (int)prizeEntity.PrizeType + "," + itemCode + "," + prizeEntity.ItemCount;
                break;

            case (int)EnumTurntablePrizeType.Turntable:
                record.LuckDrawString = (int)prizeEntity.PrizeType + "," + prizeEntity.SubType + "," + prizeEntity.ItemCount;
                break;

            case (int)EnumTurntablePrizeType.Special:
                isAddPackage = true;
                if (specialItem == 0)
                {
                    return(MessageCode.NbParameterError);
                }
                messCode = package.AddItems(specialItem, prizeEntity.ItemCount);
                if (messCode != MessageCode.Success)
                {
                    return(messCode);
                }
                response.Data.PrizeCode = specialItem;
                response.Data.PrizeType = (int)EnumTurntablePrizeType.Item;
                record.LuckDrawString   = (int)prizeEntity.PrizeType + "," + specialItem + "," + prizeEntity.ItemCount;
                break;

            default:
                break;
            }
            return(MessageCode.Success);
        }
Exemple #24
0
        /// <summary>
        /// 领取赛季奖励
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="leagueRecordId"></param>
        /// <returns></returns>
        public LeaguePrizeResponse GetRankPrize(Guid managerId, Guid leagueRecordId)
        {
            var leagueRecordInfo = LeagueRecordMgr.GetById(leagueRecordId);

            if (leagueRecordInfo == null)
            {
                return(ResponseHelper.Create <LeaguePrizeResponse>(MessageCode.NbParameterError));
            }
            var npcCount = CacheFactory.LeagueCache.GetTeamCount(leagueRecordInfo.LaegueId);
            int maxWheel = npcCount * 2;

            //最后一轮
            if (leagueRecordInfo.Schedule <= maxWheel)
            {
                return(ResponseHelper.Create <LeaguePrizeResponse>(MessageCode.LeagueNoEnd));
            }

            //玩家记录
            var leagueManagerRecord = LeagueManagerrecordMgr.GetManagerMarkInfo(managerId,
                                                                                leagueRecordInfo.LaegueId);

            if (leagueRecordInfo.PrizeTime == DateTime.Today)
            {
                return(ResponseHelper.Create <LeaguePrizeResponse>(MessageCode.LeaguePrizeReceivedToday));
            }

            if (leagueRecordInfo.Rank == 1)                 //冠军奖励
            {
                if (leagueManagerRecord.SendFirstPassPrize) //首次通关才有奖励
                {
                    return(ResponseHelper.Create <LeaguePrizeResponse>(MessageCode.LeaguePrizeReceivedToday));
                }
                leagueManagerRecord.SendFirstPassPrize = true;
                //排名奖励
                var rankPrizes           = LeagueCache.Instance.GetLeaguePrize(leagueRecordInfo.LaegueId, 5);
                int exp                  = 0;
                int coin                 = 0;
                int score                = 0;
                int vipExp               = 0;
                ItemPackageFrame package = null;
                int point                = 0;
                var manager              = ManagerCore.Instance.GetManager(managerId);
                SendPrize(rankPrizes, manager, leagueRecordInfo.LaegueId, ref exp, ref coin, ref score, ref package, ref point, ref vipExp);
                leagueRecordInfo.IsSend     = true;
                leagueRecordInfo.Schedule   = -1;
                leagueRecordInfo.PrizeTime  = DateTime.Today;
                leagueRecordInfo.UpdateTime = DateTime.Now;

                leagueManagerRecord.Score += score;


                var leagueManager = LaegueManagerinfoMgr.GetById(managerId);
                leagueManager.SumScore += score;

                ManagerUtil.AddManagerData(manager, exp, coin, 0, EnumCoinChargeSourceType.LeaguePrize, ShareUtil.CreateSequential().ToString());

                leagueManagerRecord.LastPrizeLeagueRecordId = new Guid();
                using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetConnectionString(EnumDbType.Main)))
                {
                    transactionManager.BeginTransaction();
                    var messageCode = SaveRankPrize(manager, leagueRecordInfo, leagueManagerRecord, leagueManager, package, point, transactionManager.TransactionObject);
                    if (messageCode == MessageCode.Success)
                    {
                        transactionManager.Commit();
                    }
                    else
                    {
                        transactionManager.Rollback();
                        return(ResponseHelper.Create <LeaguePrizeResponse>(messageCode));
                    }
                }
                //leagueManagerRecord.LastPrizeLeagueRecordId = leagueManagerRecord.LeagueRecordId;

                //奖励结果
                var response = ResponseHelper.CreateSuccess <LeaguePrizeResponse>();
                response.Data = new LeaguePrizes
                {
                    PrizeList = new List <LeaguePrizeEntity>()
                };
                foreach (var prize in rankPrizes)
                {
                    var entity = new LeaguePrizeEntity();
                    entity.PrizeType = prize.PrizeType;
                    entity.ItemCode  = prize.PrizeType;
                    entity.Count     = prize.Count;
                    response.Data.PrizeList.Add(entity);
                }
                response.Data.VipExp = vipExp;
                return(response);
            }
            return(ResponseHelper.Create <LeaguePrizeResponse>(MessageCode.LeagueNotChampion));
        }
Exemple #25
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);
 }
Exemple #26
0
        /// <summary>
        /// 替换上场
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="teammemberId"></param>
        /// <param name="byTeammemberId"></param>
        /// <returns></returns>
        public NBSolutionInfoResponse ReplacePlayer(Guid managerId, Guid teammemberId, Guid byTeammemberId)
        {
            bool isChanagePlayer = false;

            try
            {
                ItemPackageFrame package  = null;
                MessageCode      messCode = MessageCode.Success;
                var soluti = MatchDataHelper.GetSolution(managerId);
                if (soluti == null)
                {
                    return(ResponseHelper.InvalidParameter <NBSolutionInfoResponse>());
                }
                var byteammember = GetTeammember(managerId, byTeammemberId);
                if (byteammember == null || !soluti.PlayerDic.ContainsKey(byteammember.PlayerId))
                {
                    return(ResponseHelper.Create <NBSolutionInfoResponse>((int)MessageCode.TeammemberNotMain));
                }
                var teammember   = GetTeammember(managerId, teammemberId);
                var playerString = "";
                var playerIdList = FrameUtil.CastIntList(soluti.PlayerString, ',');


                if (teammember != null)
                {
                    ExchangePlayer(playerIdList, teammember.PlayerId, byteammember.PlayerId, false, ref playerString);
                    soluti.PlayerString = playerString;
                    if (!NbSolutionMgr.Update(soluti))
                    {
                        return(ResponseHelper.Create <NBSolutionInfoResponse>((int)MessageCode.NbUpdateFail));
                    }
                    MemcachedFactory.SolutionClient.Delete(managerId);
                    KpiHandler.Instance.RebuildKpi(managerId, true);
                    var manager = MatchDataHelper.GetManager(managerId, true, true);
                    if (manager == null)
                    {
                        return(ResponseHelper.Create <NBSolutionInfoResponse>((int)MessageCode.NbParameterError));
                    }

                    var response1 = SolutionAndTeammemberResponse(managerId);
                    return(response1);
                    //换位置
                }
                else //换替补
                {
                    isChanagePlayer = true;
                    package         = ItemCore.Instance.GetPackage(managerId, EnumTransactionType.TeammemberTrans);
                    if (package == null)
                    {
                        return(ResponseHelper.Create <NBSolutionInfoResponse>(MessageCode.NbNoPackage));
                    }
                    var player = package.GetPlayer(teammemberId);
                    if (player.ItemType != (int)EnumItemType.PlayerCard)
                    {
                        return(ResponseHelper.Exception <NBSolutionInfoResponse>());
                    }
                    player.IsDeal = false;
                    var itemInfo = CacheFactory.ItemsdicCache.GetItem(player.ItemCode);
                    //限制金卡
                    if (itemInfo != null && itemInfo.ItemType == (int)EnumItemType.PlayerCard &&
                        itemInfo.PlayerCardLevel == (int)EnumPlayerCardLevel.Gold)
                    {
                        var solution = MatchDataHelper.GetSolutionInfo(managerId);
                        if (solution == null)
                        {
                            return(ResponseHelper.InvalidParameter <NBSolutionInfoResponse>());
                        }
                        if (solution.MaxVeteranCount <= solution.VeteranCount)
                        {
                            return
                                (ResponseHelper.Create <NBSolutionInfoResponse>(
                                     (int)MessageCode.TeammemberVeteranCountOver));
                        }
                    }
                    var pid = player.ItemCode % 100000;

                    //检查是否已有相同pid的球员
                    var linkList = CacheFactory.PlayersdicCache.GetLinkPlayerList(pid);
                    if (linkList != null)
                    {
                        foreach (var link in linkList)
                        {
                            if (playerIdList.Exists(d => d == link))
                            {
                                return(ResponseHelper.Create <NBSolutionInfoResponse>(MessageCode.TeammemberSolutionPlayerRepeat));
                            }
                        }
                    }
                    int teammemberCount = 0;
                    int returnCode      = 0;
                    TeammemberMgr.GetForTransCheck(managerId, pid, ShareUtil.GetTableMod(managerId),
                                                   (int)MessageCode.TeammemberRepeat, ref teammemberCount, ref returnCode);
                    if (returnCode != (int)MessageCode.Success)
                    {
                        return(ResponseHelper.Create <NBSolutionInfoResponse>(returnCode));
                    }
                    messCode = package.ReplacePlayerCard(100000 + byteammember.PlayerId, false,
                                                         byteammember.Strength,
                                                         byteammember.Idx, byteammember.Equipment, player.ItemId, byteammember.Level);
                    ExchangePlayer(playerIdList, pid, byteammember.PlayerId, true, ref playerString);
                    soluti.PlayerString = playerString;
                    if (messCode != MessageCode.Success)
                    {
                        return(ResponseHelper.Create <NBSolutionInfoResponse>(messCode));
                    }
                }
                using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
                {
                    transactionManager.BeginTransaction();
                    messCode = MessageCode.NbUpdateFail;
                    do
                    {
                        if (package != null)
                        {
                            if (!package.SavePlayer(transactionManager.TransactionObject))
                            {
                                break;
                            }
                        }
                        if (!NbSolutionMgr.Update(soluti, transactionManager.TransactionObject))
                        {
                            break;
                        }
                        messCode = MessageCode.Success;
                    } while (false);
                    if (messCode == MessageCode.Success)
                    {
                        transactionManager.Commit();
                        MemcachedFactory.TeammembersClient.Delete(managerId);
                        MemcachedFactory.SolutionClient.Delete(managerId);
                        package.Shadow.Save();
                        int      orangeCount = 0;
                        string[] pIds        = playerString.Split(',');
                        foreach (var pId in pIds)
                        {
                            int id     = ConvertHelper.ConvertToInt(pId);
                            var player = CacheFactory.PlayersdicCache.GetPlayer(id);
                            if (player.CardLevel == (int)EnumPlayerCardLevel.Orange)
                            {
                                orangeCount++;
                            }
                        }
                        ActivityExThread.Instance.TememberColect(managerId, 3, orangeCount);
                    }
                    else
                    {
                        transactionManager.Rollback();
                        return(ResponseHelper.Create <NBSolutionInfoResponse>(messCode));
                    }
                }
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("替换球员上场", ex);
            }
            KpiHandler.Instance.RebuildKpi(managerId, true);

            var response = SolutionAndTeammemberResponse(managerId);

            if (isChanagePlayer)
            {
                var pop = TaskHandler.Instance.SolutionChangePlayer(managerId);
                if (response.Data != null)
                {
                    response.Data.PopMsg = pop;
                }
            }

            return(response);
        }
Exemple #27
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);
        }
Exemple #28
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);
 }
Exemple #29
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);
 }
Exemple #30
0
        public MessageCode Charge(string account, int sourceType, decimal cash, int point, int bonus, string orderId, string eqid)
        //用户名,      充值类型,        现金  ,       点券, 赠送点券,      订单号,   装备id
        {
            try
            {
                if (point <= 0 && bonus <= 0)
                {
                    return(MessageCode.NbParameterError);
                }
                if (point > 0 && cash <= 0)
                {
                    return(MessageCode.NbParameterError);
                }
                if (string.IsNullOrEmpty(orderId))
                {
                    return(MessageCode.NbParameterError);
                }
                int result      = 0;
                int chargePoint = point;
                if (sourceType == (int)EnumChargeSourceType.GmCharge)
                {
                    chargePoint = bonus;
                }
                ItemPackageFrame package = null;
                //登记装备
                if (!eqid.IsNullOrWhiteSpace())
                {
                    var manager = ManagerCore.Instance.GetManager(account);
                    package = ItemCore.Instance.GetPackage(manager.Idx, EnumTransactionType.Charge);
                    if (package == null)
                    {
                        return(MessageCode.NbNoPackage);
                    }

                    package.AddItem(int.Parse(eqid), false, false);
                }
                using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
                {
                    transactionManager.BeginTransaction();
                    //var messageCode = Tran_SaveLottery(transactionManager.TransactionObject, matchId, managerId, package, mail, lotteryRepeatCode);
                    var messageCode = SaveCharge(package, account, sourceType, orderId, point, chargePoint, cash, bonus, transactionManager.TransactionObject, eqid);

                    if (messageCode == ShareUtil.SuccessCode)
                    {
                        transactionManager.Commit();
                        if (point > 0)
                        {
                            doChargeAfter(account, point);
                        }
                        if (sourceType == (int)EnumChargeSourceType.GmCharge)
                        {
                            GmVip(account, bonus, PayContinuePoint, DateTime.Now);
                        }
                    }
                    else
                    {
                        transactionManager.Rollback();
                    }
                }
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("Charge", ex);
                return(MessageCode.Exception);
            }
            if (point > 0)
            {
                doChargeAfter(account, point);
            }
            if (sourceType == (int)EnumChargeSourceType.GmCharge)
            {
                GmVip(account, bonus, PayContinuePoint, DateTime.Now);
            }
            return(MessageCode.Success);
        }