/// <summary> /// 发放奖励 /// </summary> /// <param name="prizeList"></param> /// <param name="manager"></param> /// <param name="leagueId"></param> /// <returns></returns> public MessageCode SendPrize(List <ConfigLeagueprizeEntity> prizeList, NbManagerEntity manager, int leagueId, ref int exp, ref int coin, ref int score, ref ItemPackageFrame package, ref int point, ref int vipExp) { if (manager == null) { return(MessageCode.NbParameterError); } foreach (var prize in prizeList) { switch (prize.PrizeType) { case (int)EnumLeaguePrize.Exp: //经验 { //是否有vip效果 var vipRate = CacheFactory.VipdicCache.GetEffectValue(manager.VipLevel, EnumVipEffect.PkOrLeagueExpPlus); var totalPlusRate = vipRate / 100.00; var prizeExp = (int)(prize.Count * (1 + totalPlusRate)); exp = prizeExp; vipExp = prizeExp - prize.Count; break; } case (int)EnumLeaguePrize.Coin: //金币 coin = prize.Count; break; case (int)EnumLeaguePrize.Score: //联赛积分 score = prize.Count; //欧洲杯狂欢 ActivityExThread.Instance.EuropeCarnival(3, ref score); break; case (int)EnumLeaguePrize.Item: //道具 //获取背包 if (package == null) { package = ItemCore.Instance.GetPackage(manager.Idx, EnumTransactionType.LeaguePrize); } if (package == null) { return(MessageCode.NbNoPackage); } var result = package.AddItems(prize.ItemCode, prize.Count, 1, prize.IsBindIng, false); if (result != MessageCode.Success) { return(result); } break; case (int)EnumLeaguePrize.Point: //钻石 point = prize.Count; break; } } return(MessageCode.Success); }
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); }
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="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); }
MessageCode BuilReceiveAttachmentData(MailInfoEntity mail, ref NbManagerEntity manager, ref ItemPackageFrame package, ref int addCoin, ref int addSophisticate, ref int addPoint, ref int addPrestige, ref int addBindPoint, ref int addGoldBar, ref int addluckyCoin, ref int addGameCoin) { var attachments = SerializationHelper.FromByte <MailAttachmentEntity>(mail.Attachment); var managerId = mail.ManagerId; MessageCode code = MessageCode.Success; foreach (var attachment in attachments.Attachments) { #region build Attachment switch (attachment.AttachmentType) { case (int)EnumAttachmentType.Coin: if (manager == null) { manager = ManagerCore.Instance.GetManager(managerId); } addCoin += attachment.Count; break; case (int)EnumAttachmentType.Sophisticate: if (manager == null) { manager = ManagerCore.Instance.GetManager(managerId); } addSophisticate += attachment.Count; break; case (int)EnumAttachmentType.Point: if (manager == null) { manager = ManagerCore.Instance.GetManager(managerId); } addPoint += attachment.Count; break; case (int)EnumAttachmentType.Prestige: if (manager == null) { manager = ManagerCore.Instance.GetManager(managerId); } addPrestige += attachment.Count; break; case (int)EnumAttachmentType.NewItem: var attachmentItemEntity = attachment as AttachmentItemEntity; if (attachmentItemEntity == null) { return(MessageCode.NbParameterError); } if (package == null) { package = ItemCore.Instance.GetPackage(managerId, _mailTransactionTypeDic[mail.MailType]); } code = package.AddItems(attachmentItemEntity.ItemCode, attachmentItemEntity.Count, attachmentItemEntity.Strength, attachmentItemEntity.IsBinding, attachmentItemEntity.IsDeal); if (code != MessageCode.Success) { return(code); } break; case (int)EnumAttachmentType.UsedPlayerCard: if (package == null) { package = ItemCore.Instance.GetPackage(managerId, _mailTransactionTypeDic[mail.MailType]); } var usedPlayerCard = attachment as AttachmentUsedItemEntity; if (usedPlayerCard == null) { return(MessageCode.NbParameterError); } code = package.AddUsedItem(usedPlayerCard.ItemProperty as PlayerCardUsedEntity); if (code != MessageCode.Success) { return(code); } break; case (int)EnumAttachmentType.UsedEquipment: if (package == null) { package = ItemCore.Instance.GetPackage(managerId, _mailTransactionTypeDic[mail.MailType]); } var usedEquipment = attachment as AttachmentUsedItemEntity; if (usedEquipment == null) { return(MessageCode.NbParameterError); } code = package.AddUsedItem(usedEquipment.ItemProperty as EquipmentUsedEntity); if (code != MessageCode.Success) { return(code); } break; case (int)EnumAttachmentType.UsedMallItem: //if (package == null) // package = ItemCore.Instance.GetPackage(managerId, _mailTransactionTypeDic[mail.MailType]); //var usedMallItem = attachment as AttachmentUsedItemEntity; //if (usedMallItem == null) // return MessageCode.NbParameterError; //var itemProperty = usedMallItem.ItemProperty as MallItemUsedEntity; //code = package.AddUsedItem(itemProperty); //if (code != MessageCode.Success) //{ // return code; //} //break; case (int)EnumAttachmentType.Equipment: if (package == null) { package = ItemCore.Instance.GetPackage(managerId, _mailTransactionTypeDic[mail.MailType]); } var equipment = attachment as AttachmentEquipmentEntity; if (equipment == null) { return(MessageCode.NbParameterError); } code = package.AddEquipment(equipment.ItemCode, equipment.IsBinding, equipment.IsDeal, equipment.EquipmentProperty); if (code != MessageCode.Success) { return(code); } break; case (int)EnumAttachmentType.BindPoint: if (manager == null) { manager = ManagerCore.Instance.GetManager(managerId); } addBindPoint += attachment.Count; break; case (int)EnumAttachmentType.GoldBar: addGoldBar += attachment.Count; break; case (int)EnumAttachmentType.LuckyCoin: addluckyCoin += attachment.Count; break; case (int)EnumAttachmentType.GameCoin: addGameCoin += attachment.Count; break; default: return(MessageCode.NbParameterError); } #endregion } mail.IsRead = true; mail.HasAttach = false; mail.ExpiredTime = GetExpiredTime(false, DateTime.Now); return(MessageCode.Success); }
/// <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); }