Пример #1
0
        /// <summary>
        /// 获取我的拍卖列表
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="zoneName"></param>
        /// <returns></returns>
        public AuctionItemResponse GetMyAuctionList(Guid managerId, string zoneName)
        {
            var response = new AuctionItemResponse();

            response.Data = new AuctionItemEntity();
            try
            {
                var manager = NbManagerMgr.GetById(managerId, zoneName);
                if (manager == null)
                {
                    return(ResponseHelper.Create <AuctionItemResponse>(MessageCode.AdMissManager));
                }
                if (!IsOpen(managerId, zoneName, manager))
                {
                    return(ResponseHelper.Create <AuctionItemResponse>(MessageCode.TransferNotOpen));
                }
                //已经挂牌了多少个
                var number = TransferMainMgr.GetTransferNumber(managerId);
                //最多可以挂牌多少个
                var gambleCountMax = CacheFactory.VipdicCache.GetEffectValue(manager.VipLevel, EnumVipEffect.TransferNumber);
                response.Data.MyTransferList     = GetMyTransfer(managerId);
                response.Data.MaxTransferNumber  = gambleCountMax;
                response.Data.HaveTransferNumber = number;
                var goldBarEntity = ScoutingGoldbarMgr.GetById(managerId, zoneName);
                if (goldBarEntity != null)
                {
                    response.Data.MyGoldBar = goldBarEntity.GoldBarNumber;
                }
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("获取我的拍卖列表", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }
Пример #2
0
        /// <summary>
        /// 开始拍卖
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="zoneName"></param>
        /// <param name="itemId"></param>
        /// <param name="price"></param>
        /// <param name="transferDuration"></param>
        public AuctionItemResponse AuctionItem(Guid managerId, string zoneName, Guid itemId, int price, int transferDuration)
        {
            var response = new AuctionItemResponse();

            response.Data = new AuctionItemEntity();
            try
            {
                DateTime date    = DateTime.Now;
                var      manager = NbManagerMgr.GetById(managerId, zoneName);
                if (manager == null)
                {
                    return(ResponseHelper.Create <AuctionItemResponse>(MessageCode.AdMissManager));
                }
                if (!IsOpen(managerId, zoneName, manager))
                {
                    return(ResponseHelper.Create <AuctionItemResponse>(MessageCode.TransferNotOpen));
                }
                //已经挂牌了多少个
                var number = TransferMainMgr.GetTransferNumber(managerId);
                //最多可以挂牌多少个
                var gambleCountMax = CacheFactory.VipdicCache.GetEffectValue(manager.VipLevel, EnumVipEffect.TransferNumber);
                if (gambleCountMax <= number)
                {
                    return(ResponseHelper.Create <AuctionItemResponse>(MessageCode.TransferNumberMax));
                }
                var package = ItemCore.Instance.GetPackage(managerId, EnumTransactionType.Transfer, zoneName);
                if (package == null)
                {
                    return(ResponseHelper.Create <AuctionItemResponse>(MessageCode.NbNoPackage));
                }

                if (price < 2)
                {
                    return(ResponseHelper.Create <AuctionItemResponse>(MessageCode.StartPriceSmall));
                }
                var item = package.GetItem(itemId);
                if (item == null)
                {
                    return(ResponseHelper.Create <AuctionItemResponse>(MessageCode.ItemNotExists));
                }
                if (!item.IsDeal)
                {
                    return(ResponseHelper.Create <AuctionItemResponse>(MessageCode.NotDeal));
                }
                var strength = item.GetStrength();
                if (strength > 1)
                {
                    return(ResponseHelper.Create <AuctionItemResponse>(MessageCode.NotDeal));
                }
                var iteminfo = CacheFactory.ItemsdicCache.GetItem(item.ItemCode);
                if (iteminfo == null)
                {
                    return(ResponseHelper.Create <AuctionItemResponse>(MessageCode.ItemNotExists));
                }
                //默认86400秒  24小时
                TransferMainEntity entity = new TransferMainEntity(ShareUtil.GenerateComb(), _domainId, item.ItemCode, iteminfo.ItemName,
                                                                   new byte[0], manager.Name, managerId, zoneName, price, "",
                                                                   "", 0, Guid.Empty, date, date.AddDays(1), 0, 0, 0, date, date);

                var messageCode = package.Delete(itemId);
                if (messageCode != MessageCode.Success)
                {
                    return(ResponseHelper.Create <AuctionItemResponse>(messageCode));
                }
                if (!package.Save())
                {
                    return(ResponseHelper.Create <AuctionItemResponse>(MessageCode.NbUpdateFail));
                }
                if (!TransferMainMgr.Insert(entity))
                {
                    messageCode = package.AddItem(item.ItemCode);
                    if (messageCode != MessageCode.Success)
                    {
                        SystemlogMgr.Error("拍卖返还物品失败",
                                           "拍卖返还物品失败,managerId:" + managerId + ",zoneName:" + zoneName + "物品ID:" + item.ItemCode);
                    }
                    return(ResponseHelper.Create <AuctionItemResponse>(MessageCode.NbUpdateFail));
                }
                package.Shadow.Save();
                entity.TransferDurationTick = ShareUtil.GetTimeTick(entity.TransferDuration);
                entity.TransferDurationTick = ShareUtil.GetTimeTick(entity.TransferDuration);
                var modId = ShareUtil.GetTableMod(entity.TransferId);
                entity.ModId = modId;
                _tenTransferList.Add(entity);
                Sort();
                response.Data.MyTransferList     = GetMyTransfer(managerId);
                response.Data.MaxTransferNumber  = gambleCountMax;
                response.Data.HaveTransferNumber = number + 1;
                var goldBarEntity = ScoutingGoldbarMgr.GetById(managerId, zoneName);
                if (goldBarEntity != null)
                {
                    response.Data.MyGoldBar = goldBarEntity.GoldBarNumber;
                }
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("开始拍卖", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }