Ejemplo n.º 1
0
        protected void btnGoldBar_Click(object sender, EventArgs e)
        {
            try
            {
                if (CheckManager())
                {
                    var count = ConvertHelper.ConvertToInt(txt_GoldBar.Text);
                    if (count < 0)
                    {
                        ShowMessage("数量不能小于0");
                        return;
                    }
                    if (count > 5000)
                    {
                        ShowMessage("一次发送不能超过5000");
                        return;
                    }
                    GoldbarRecordEntity record = new GoldbarRecordEntity(0, _account.ManagerId, true, count,
                                                                         (int)EnumTransactionType.AdminAddItem, DateTime.Now);
                    var goldBarManager = ScoutingGoldbarMgr.GetById(_account.ManagerId, _account.ZoneId);
                    if (goldBarManager == null)
                    {
                        goldBarManager = new ScoutingGoldbarEntity(_account.ManagerId, count, 0, 0, 0, DateTime.Now,
                                                                   DateTime.Now);
                        if (!ScoutingGoldbarMgr.Insert(goldBarManager, null, _account.ZoneId))
                        {
                            ShowMessage("发送失败");
                            return;
                        }
                    }
                    else
                    {
                        goldBarManager.GoldBarNumber = goldBarManager.GoldBarNumber + count;
                        if (!ScoutingGoldbarMgr.Update(goldBarManager, null, _account.ZoneId))
                        {
                            ShowMessage("发送失败");
                            return;
                        }
                    }
                    GoldbarRecordMgr.Insert(record, null, _account.ZoneId);

                    ShowMessage("发送成功");
                }
            }
            catch (Exception ex)
            {
                LogHelper.Insert(ex);
                ShowMessage(ex.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 竞拍
        /// </summary>
        /// <param name="transferId"></param>
        /// <param name="managerId"></param>
        /// <param name="zoneName"></param>
        /// <returns></returns>
        public AuctionResponse Auction(Guid transferId, Guid managerId, string zoneName)
        {
            AuctionResponse response = new AuctionResponse();

            try
            {
                if (!IsOpen(managerId, zoneName))
                {
                    return(ResponseHelper.Create <AuctionResponse>(MessageCode.TransferNotOpen));
                }
                var entity = GetInfo(transferId);
                if (entity == null)
                {
                    return(ResponseHelper.Create <AuctionResponse>(MessageCode.ItemSoldOut));
                }
                var goldBarEntity = ScoutingGoldbarMgr.GetById(managerId, zoneName);
                if (goldBarEntity == null || goldBarEntity.GoldBarNumber < entity.Price)
                {
                    return(ResponseHelper.Create <AuctionResponse>(MessageCode.ScoutingGoldBarNot));
                }
                if (entity.Status == 1)
                {
                    return(ResponseHelper.Create <AuctionResponse>(MessageCode.ItemSoldOut));
                }
                if (entity.Status == 2)
                {
                    return(ResponseHelper.Create <AuctionResponse>(MessageCode.ItemHaveSellOut));
                }
                if (entity.SellId == managerId)
                {
                    return(ResponseHelper.Create <AuctionResponse>(MessageCode.NotBuyOneself));
                }
                goldBarEntity.GoldBarNumber = goldBarEntity.GoldBarNumber - entity.Price;
                //手续费 5%
                int poundage = entity.Price * 5 / 100;
                if (poundage == 0)
                {
                    poundage = 1;
                }
                else if (poundage > 20)
                {
                    poundage = 20;
                }

                GoldbarRecordEntity auctionRecord = new GoldbarRecordEntity();
                auctionRecord.IsAdd         = false;
                auctionRecord.ManagerId     = managerId;
                auctionRecord.Number        = entity.Price;
                auctionRecord.OperationType = (int)EnumTransactionType.Transfer;
                auctionRecord.RowTime       = DateTime.Now;

                entity.DealEndId       = managerId;
                entity.DealEndPrice    = entity.Price;
                entity.DealEndZoneName = zoneName;
                entity.Status          = 2;
                entity.UpdateTime      = DateTime.Now;
                entity.Poundage        = poundage;
                if (!TransferMainMgr.Update(entity))
                {
                    entity.Status = 0;
                    return(ResponseHelper.Create <AuctionResponse>(MessageCode.NbUpdateFail));
                }
                if (!ScoutingGoldbarMgr.Update(goldBarEntity, null, zoneName))
                {
                    return(ResponseHelper.Create <AuctionResponse>(MessageCode.NbUpdateFail));
                }

                Remove(transferId);
                //出售人邮件
                var sellMail = new MailBuilder(entity.SellId, entity.ItemName, EnumCurrencyType.GoldBar,
                                               entity.Price - poundage);
                //购买人邮件
                var buyMail = new MailBuilder(managerId, entity.ItemCode, entity.ItemName, entity.Price);
                if (!sellMail.Save(entity.SellZoneName))
                {
                    SystemlogMgr.Error("邮件发送失败",
                                       "邮件发送失败,ManagerId:" + entity.SellId + ",ZoneName:" + entity.SellZoneName + ",GoldBarNumber:" +
                                       (entity.Price - poundage));
                }
                if (!buyMail.Save(zoneName))
                {
                    SystemlogMgr.Error("邮件发送失败",
                                       "邮件发送失败,ManagerId:" + managerId + ",ZoneName:" + zoneName + ",GoldBarNumber:" +
                                       (entity.Price - poundage));
                }
                GoldbarRecordMgr.Insert(auctionRecord, null, zoneName);
                response.Data         = new AuctionEntity();
                response.Data.GoldBar = goldBarEntity.GoldBarNumber;
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("竞拍", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 金条抽卡
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="scoutingId"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        private ScoutingLotteryResponse ScoutingLotteryGoldBar(Guid managerId, int scoutingId, int count)
        {
            bool isTen          = count == 10; //是否十连抽
            var  configScouting = CacheFactory.ScoutingCache.GetEntity(scoutingId);

            if (configScouting == null)
            {
                return(ResponseHelper.InvalidParameter <ScoutingLotteryResponse>());
            }
            var scoutingType = configScouting.Type;

            var scoutingManager = ScoutingGoldbarMgr.GetById(managerId);
            int prize           = 10;

            ActivityExThread.Instance.ScoutingHalfPrice(ref prize);
            //没有数据直接返回金条数量不足
            if (scoutingManager == null)
            {
                return(ResponseHelper.Create <ScoutingLotteryResponse>(MessageCode.ScoutingGoldBarNot));
            }
            var limitedOrangeCount = 0;

            // ScoutingRecordfordaysMgr.GetCountByTime(managerId, DateTime.Today, DateTime.Today.AddDays(1), scoutingId,
            //    ref limitedOrangeCount);

            LotteryEntity lottery         = null;
            List <int>    cardList        = null;
            List <int>    limitedCardList = new List <int>();

            if (isTen)
            {
                if (!configScouting.HasTen)
                {
                    return(ResponseHelper.InvalidParameter <ScoutingLotteryResponse>());
                }
                lottery = CacheFactory.LotteryCache.ScoutingTen(scoutingType, configScouting.OrangeLib,
                                                                configScouting.LowLib, out cardList, limitedOrangeCount, out limitedCardList);
                prize = prize * 8; //8折  10连
                scoutingManager.TenNumber++;
            }
            else
            {
                lottery = CacheFactory.LotteryCache.LotteryFive(EnumLotteryType.Scouting, scoutingType);
                scoutingManager.ScoutingNumber++;
                if (scoutingManager.ScoutingNumber > 0 && scoutingManager.ScoutingNumber % 10 == 0)
                {
                    lottery = CacheFactory.LotteryCache.LotteryFive(EnumLotteryType.Scouting, 98);
                }
            }
            if (scoutingManager.GoldBarNumber < prize)
            {
                return(ResponseHelper.Create <ScoutingLotteryResponse>(MessageCode.ScoutingGoldBarNot));
            }
            scoutingManager.GoldBarNumber = scoutingManager.GoldBarNumber - prize;
            if (lottery == null)
            {
                return(ResponseHelper.Create <ScoutingLotteryResponse>(MessageCode.ScoutingLotteryFail));
            }
            DateTime             curTime        = DateTime.Now;
            ScoutingRecordEntity scoutingRecord = new ScoutingRecordEntity();

            scoutingRecord.ManagerId = managerId;
            if (!isTen)
            {
                var card = ItemsdicCache.Instance.GetItem(lottery.PrizeItemCode);
                if (scoutingManager.ScoutingNumber > 0 && scoutingManager.ScoutingNumber % 10 == 0)
                //抽卡十次必得89及以上的橙卡,元老,红卡,或传奇碎片
                {
                    lottery = CacheFactory.LotteryCache.LotteryFive(EnumLotteryType.Scouting, 98);
                    card    = ItemsdicCache.Instance.GetItem(lottery.PrizeItemCode);
                }
                ////C罗、梅西外每天只能出3张89以上的橙卡
                //if (limitedOrangeCount >= 3)
                //{
                //    while (card.PlayerKpi >= 89 || card.LinkId == 30001 || card.LinkId == 30002)
                //    {
                //        lottery = CacheFactory.LotteryCache.LotteryFive(EnumLotteryType.Scouting, scoutingType);
                //        card = ItemsdicCache.Instance.GetItem(lottery.PrizeItemCode);
                //    }
                //}
                //else
                //{
                //    if (card.PlayerKpi >= 89 && (card.LinkId != 30001 || card.LinkId != 30002))
                //    {
                //        limitedCardList = new List<int>();
                //        limitedCardList.Add(card.ItemCode);
                //    }
                //}
            }

            if (isTen)
            {
                bool isReplace = true;
                for (int i = 0; i < cardList.Count; i++)
                {
                    var itemcode = ActivityExThread.Instance.MidAutumnActivity(99, 0);
                    if (itemcode > 0)
                    {
                        cardList[i] = itemcode;
                    }
                    var card = ItemsdicCache.Instance.GetItem(cardList[i]);

                    if (card.ItemType == (int)EnumItemType.PlayerCard &&
                        card.PlayerCardLevel == (int)EnumPlayerCardLevel.Orange && card.PlayerKpi >= 89)
                    {
                        isReplace = false;
                    }
                    else if (card.ItemType == (int)EnumItemType.MallItem)
                    {
                        var player = CacheFactory.PlayersdicCache.GetPlayer(card.ImageId);
                        if (player != null && player.Capacity >= 89)
                        {
                            isReplace = false;
                        }
                    }
                    lottery.ItemString = string.Join(",", cardList);
                }
                if (isReplace)
                {
                    var pointlottery = CacheFactory.LotteryCache.LotteryFive(EnumLotteryType.Scouting, 98);
                    cardList[RandomHelper.GetInt32WithoutMax(0, cardList.Count)] = pointlottery.PrizeItemCode;
                }
                lottery.ItemString = string.Join(",", cardList);
            }
            scoutingRecord.ItemString   = lottery.ItemString;
            scoutingRecord.ItemCode     = lottery.PrizeItemCode;
            scoutingRecord.RowTime      = curTime;
            scoutingRecord.ScoutingType = configScouting.Type;
            scoutingRecord.Status       = 1;
            scoutingRecord.Strength     = lottery.Strength;

            scoutingManager.UpdateTiem = DateTime.Now;


            GoldbarRecordEntity goldBarRecord = new GoldbarRecordEntity();

            goldBarRecord.IsAdd         = false;
            goldBarRecord.ManagerId     = managerId;
            goldBarRecord.Number        = prize;
            goldBarRecord.OperationType = (int)EnumTransactionType.ScoutingLottery;
            goldBarRecord.RowTime       = DateTime.Now;


            #region 球探抽卡


            var response = MallCore.Instance.Scouting(managerId, DateTime.Now, scoutingRecord, scoutingManager,
                                                      isTen, cardList);

            GoldbarRecordMgr.Insert(goldBarRecord);

            #endregion

            if (response.Code == (int)MessageCode.Success)
            {
                foreach (var itemcode in limitedCardList)
                {
                    var scoutingRecordDays = new ScoutingRecordfordaysEntity();
                    scoutingRecordDays.ManagerId          = managerId;
                    scoutingRecordDays.CardItemCodeThen89 = itemcode;
                    scoutingRecordDays.RowTime            = DateTime.Now;
                    scoutingRecordDays.ScoutingType       = scoutingType;
                    ScoutingRecordfordaysMgr.Insert(scoutingRecordDays);
                }
                MailBuilder mail = null;
                if (isTen)
                {
                    foreach (var itemcode in cardList)
                    {
                        ActivityExThread.Instance.ScoutingDebris(managerId, itemcode, ref mail);
                    }
                }
                else
                {
                    ActivityExThread.Instance.ScoutingDebris(managerId, scoutingRecord.ItemCode, ref mail);
                }
                if (mail != null)
                {
                    mail.Save();
                }
                List <PopMessageEntity> popList = TaskHandler.Instance.ScoutingLottery(managerId, 1);
                response.Data.PopMsg              = popList;
                response.Data.LuckyCoinNumber     = 0;
                response.Data.GameCurrency        = 0;
                response.Data.NextGoldBarScouting = scoutingManager.ScoutingNumber == 0
                    ? 10
                    : 10 - scoutingManager.ScoutingNumber % 10;
                if (response.Data.AddReiki > 0)
                {
                    ManagerCore.Instance.DeleteCache(managerId);
                }
            }
            return(response);
        }