|  |  |  | 
|---|
|  |  |  | import NetPackCommon | 
|---|
|  |  |  | import PlayerBourse | 
|---|
|  |  |  | import PlayerFamily | 
|---|
|  |  |  | import ShareDefine | 
|---|
|  |  |  | import ChConfig | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import operator | 
|---|
|  |  |  | 
|---|
|  |  |  | # 拍卖成功收益,都以玩家收益向上取整 | 
|---|
|  |  |  | if familyID and auctionItem.FamilyPlayerIDInfo: | 
|---|
|  |  |  | familyPlayerIDList = json.loads(auctionItem.FamilyPlayerIDInfo) | 
|---|
|  |  |  | taxRate = IpyGameDataPY.GetFuncCfg("AuctionTaxrate", 2) # 仙盟拍品税率百分比 | 
|---|
|  |  |  | personMaxRate = IpyGameDataPY.GetFuncCfg("AuctionTaxrate", 3) # 仙盟拍品个人最大收益百分比 | 
|---|
|  |  |  | taxGold = max(1, int(bidderPrice * taxRate / 100.0)) # 最少收税1 | 
|---|
|  |  |  | giveTotalGold = max(0, bidderPrice - taxGold) | 
|---|
|  |  |  | giveMaxGold = int(math.ceil(giveTotalGold * personMaxRate / 100.0)) | 
|---|
|  |  |  | memCount = len(familyPlayerIDList) | 
|---|
|  |  |  | giveGoldAverage = min(giveMaxGold, int(math.ceil(giveTotalGold * 1.0 / memCount))) # 有收益的人平分 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | # 仙盟拍品收益邮件 | 
|---|
|  |  |  | detail = {"ItemGUID":itemGUID, "ItemID":itemID, "Count":itemCount, "BidderPrice":bidderPrice, "FamilyPlayerIDList":familyPlayerIDList} | 
|---|
|  |  |  | paramList = [itemID, itemID, auctionItem.BidderName, bidderPrice, taxRate, giveGoldAverage, personMaxRate] | 
|---|
|  |  |  | PlayerCompensation.SendMailByKey("PaimaiMail6", familyPlayerIDList, [], paramList, gold=giveGoldAverage, | 
|---|
|  |  |  | detail=detail, moneySource=ChConfig.Def_GiveMoney_AuctionGain) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if familyPlayerIDList: | 
|---|
|  |  |  | taxRate = IpyGameDataPY.GetFuncCfg("AuctionTaxrate", 2) # 仙盟拍品税率百分比 | 
|---|
|  |  |  | personMaxRate = IpyGameDataPY.GetFuncCfg("AuctionTaxrate", 3) # 仙盟拍品个人最大收益百分比 | 
|---|
|  |  |  | taxGold = max(1, int(bidderPrice * taxRate / 100.0)) # 最少收税1 | 
|---|
|  |  |  | giveTotalGold = max(0, bidderPrice - taxGold) | 
|---|
|  |  |  | giveMaxGold = int(math.ceil(giveTotalGold * personMaxRate / 100.0)) | 
|---|
|  |  |  | memCount = len(familyPlayerIDList) | 
|---|
|  |  |  | giveGoldAverage = min(giveMaxGold, int(math.ceil(giveTotalGold * 1.0 / memCount))) # 有收益的人平分 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | # 仙盟拍品收益邮件 | 
|---|
|  |  |  | detail = {"ItemGUID":itemGUID, "ItemID":itemID, "Count":itemCount, "BidderPrice":bidderPrice, "FamilyPlayerIDList":familyPlayerIDList} | 
|---|
|  |  |  | paramList = [itemID, itemID, bidderPrice, taxRate, giveGoldAverage, personMaxRate] | 
|---|
|  |  |  | PlayerCompensation.SendMailByKey("PaimaiMail8", familyPlayerIDList, [], paramList, gold=giveGoldAverage, | 
|---|
|  |  |  | detail=detail, moneySource=ChConfig.Def_GiveMoney_AuctionGain) | 
|---|
|  |  |  | else: | 
|---|
|  |  |  | GameWorld.ErrLog("仙盟拍品没有人获得收益!familyID=%s,itemID=%s,itemGUID=%s" % (familyID, itemID, itemGUID)) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | elif playerID: | 
|---|
|  |  |  | taxRate = IpyGameDataPY.GetFuncCfg("AuctionTaxrate", 1) # 全服拍品税率百分比 | 
|---|
|  |  |  | taxGold = max(1, int(bidderPrice * taxRate / 100.0)) # 最少收税1 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | # 个人拍卖收益邮件 | 
|---|
|  |  |  | detail = {"ItemGUID":itemGUID, "ItemID":itemID, "Count":itemCount, "BidderPrice":bidderPrice} | 
|---|
|  |  |  | paramList = [itemID, itemID, auctionItem.BidderName, bidderPrice, taxRate, givePlayerGold] | 
|---|
|  |  |  | PlayerCompensation.SendMailByKey("PaimaiMail5", [playerID], [], paramList, gold=givePlayerGold, | 
|---|
|  |  |  | paramList = [itemID, itemID, bidderPrice, taxRate, givePlayerGold] | 
|---|
|  |  |  | PlayerCompensation.SendMailByKey("PaimaiMail7", [playerID], [], paramList, gold=givePlayerGold, | 
|---|
|  |  |  | detail=detail, moneySource=ChConfig.Def_GiveMoney_AuctionGain) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | AddAuctionRecord(auctionItem, AuctionRecordResult_SellOK) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ipyData = IpyGameDataPY.GetIpyGameData("AuctionItem", itemID) | 
|---|
|  |  |  | if ipyData and ipyData.GetNeedWorldNotify(): | 
|---|
|  |  |  | PlayerControl.WorldNotify(0, "Paimai6", [auctionItem.BidderName, bidderID, auctionItem.AuctionType, bidderPrice, itemID]) | 
|---|
|  |  |  | #策划需求屏蔽掉成交广播 | 
|---|
|  |  |  | #ipyData = IpyGameDataPY.GetIpyGameData("AuctionItem", itemID) | 
|---|
|  |  |  | #if ipyData and ipyData.GetNeedWorldNotify(): | 
|---|
|  |  |  | #    PlayerControl.WorldNotify(0, "Paimai6", [auctionItem.BidderName, bidderID, auctionItem.AuctionType, bidderPrice, itemID]) | 
|---|
|  |  |  | else: | 
|---|
|  |  |  | # 仙盟拍品回收 | 
|---|
|  |  |  | if familyID: | 
|---|
|  |  |  | 
|---|
|  |  |  | @param curPlayer: 可能为None | 
|---|
|  |  |  | ''' | 
|---|
|  |  |  |  | 
|---|
|  |  |  | notifyWorldAddItemList = [] # 新增全服拍品通知 [[itemGUID, itemID, playerID], ...] | 
|---|
|  |  |  | isSortWorldItem = False | 
|---|
|  |  |  | notifyAddItemList = [] # 新增拍品通知 [[itemGUID, itemID, playerID], ...] | 
|---|
|  |  |  | notifyFamilyAddItemDict = {} # 新增仙盟拍品通知 {familyID:[auctionItem, ...], ...} | 
|---|
|  |  |  | for playerID, familyID, familyPlayerIDList, itemData in addAuctionItemList: | 
|---|
|  |  |  | if not playerID and not familyID: | 
|---|
|  |  |  | 
|---|
|  |  |  | if not auctionItem: | 
|---|
|  |  |  | continue | 
|---|
|  |  |  |  | 
|---|
|  |  |  | itemGUID = auctionItem.ItemGUID | 
|---|
|  |  |  | itemID = auctionItem.ItemID | 
|---|
|  |  |  | notifyAddItemList.append([itemGUID, itemID, playerID]) | 
|---|
|  |  |  | if familyID: | 
|---|
|  |  |  | familyAddItemList = notifyFamilyAddItemDict.get(familyID, []) | 
|---|
|  |  |  | familyAddItemList.append(auctionItem) | 
|---|
|  |  |  | notifyFamilyAddItemDict[familyID] = familyAddItemList | 
|---|
|  |  |  | else: | 
|---|
|  |  |  | itemGUID = auctionItem.ItemGUID | 
|---|
|  |  |  | itemID = auctionItem.ItemID | 
|---|
|  |  |  | notifyWorldAddItemList.append([itemGUID, itemID, playerID]) | 
|---|
|  |  |  | isSortWorldItem = True | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if notifyFamilyAddItemDict or notifyWorldAddItemList: | 
|---|
|  |  |  | isSortWorldItem = notifyWorldAddItemList != [] | 
|---|
|  |  |  | if notifyAddItemList: | 
|---|
|  |  |  | __SortAuctionitem(isSortWorldItem=isSortWorldItem) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | # 通知新增仙盟拍品 | 
|---|
|  |  |  | for familyID, familyAddItemList in notifyFamilyAddItemDict.items(): | 
|---|
|  |  |  | Sync_FamilyAuctionItemInfo(None, familyID, familyAddItemList) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | # 通知全服拍品关注玩家 | 
|---|
|  |  |  | __NotifyAuctionPlayerAddItem(notifyWorldAddItemList) | 
|---|
|  |  |  | # 通知拍品关注玩家 | 
|---|
|  |  |  | __NotifyAuctionPlayerAddItem(notifyAddItemList) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def __DoAddAuctionItem(curPlayer, playerID, familyID, familyPlayerIDList, itemData): | 
|---|
|  |  |  | 
|---|
|  |  |  | GameWorld.DebugLog("更新拍品数: %s" % len(auctionItemMgr.allAuctionItemDict)) | 
|---|
|  |  |  | return auctionItem | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def __NotifyAuctionPlayerAddItem(notifyWorldAddItemList): | 
|---|
|  |  |  | def __NotifyAuctionPlayerAddItem(notifyAddItemList): | 
|---|
|  |  |  | ## 通知关注物品的玩家新上架物品了 | 
|---|
|  |  |  | if not notifyWorldAddItemList: | 
|---|
|  |  |  | if not notifyAddItemList: | 
|---|
|  |  |  | return | 
|---|
|  |  |  | attentionMgr = PyDataManager.GetAuctionAttentionManager() | 
|---|
|  |  |  | playerManager = GameWorld.GetPlayerManager() | 
|---|
|  |  |  | 
|---|
|  |  |  | if not playerAttentionIDList: | 
|---|
|  |  |  | continue | 
|---|
|  |  |  | infoPack = None | 
|---|
|  |  |  | for itemGUID, itemID, playerID in notifyWorldAddItemList: | 
|---|
|  |  |  | if playerID == player.GetPlayerID(): | 
|---|
|  |  |  | for itemGUID, itemID, playerID in notifyAddItemList: | 
|---|
|  |  |  | if playerID and playerID == player.GetPlayerID(): | 
|---|
|  |  |  | # 自己上架的物品不通知 | 
|---|
|  |  |  | continue | 
|---|
|  |  |  | if itemID not in playerAttentionIDList: | 
|---|
|  |  |  | 
|---|
|  |  |  | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) | 
|---|
|  |  |  | tagItemGUID = clientData.ItemGUID | 
|---|
|  |  |  | queryDir = 3 | 
|---|
|  |  |  | __Sync_WorldAuctionItemQueryResult(curPlayer, fromItemGUID=tagItemGUID, queryDir=queryDir) | 
|---|
|  |  |  | __Sync_WorldAuctionItemQueryResult(curPlayer, fromItemGUID=tagItemGUID, queryDir=queryDir, isNotify=True) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def __Sync_WorldAuctionItemQueryResult(curPlayer, job=0, itemTypeList=[], classLV=0, specItemIDList=[], fromItemGUID="", queryDir=1, queryCount=10): | 
|---|
|  |  |  | def __Sync_WorldAuctionItemQueryResult(curPlayer, job=0, itemTypeList=[], classLV=0, specItemIDList=[], fromItemGUID="", queryDir=1, queryCount=10, isNotify=False): | 
|---|
|  |  |  | ## 根据过滤条件同步全服拍品列表,目前仅全服拍品需要通过查询服务器获得,个人拍品及仙盟拍品由于个数较少直接由上线或变更时主动同步 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | fromAuctionItem = None | 
|---|
|  |  |  | 
|---|
|  |  |  | fromAuctionItem = GetAuctionItem(fromItemGUID) | 
|---|
|  |  |  | if not fromAuctionItem: | 
|---|
|  |  |  | GameWorld.DebugLog("查询的目标拍品不存在! fromItemGUID=%s" % fromItemGUID) | 
|---|
|  |  |  | PlayerControl.NotifyCode(curPlayer, "Paimai5") | 
|---|
|  |  |  | if isNotify: | 
|---|
|  |  |  | PlayerControl.NotifyCode(curPlayer, "Paimai5") | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | # {(job, (itemType, ...), itemClassLV, (itemID, ...)):[tagDBAuctionItem, ...], ...} | 
|---|
|  |  |  | 
|---|
|  |  |  | # 载入对应查询条件拍品缓存 | 
|---|
|  |  |  | auctionItemQueryList = [] | 
|---|
|  |  |  | for worldAuctionItem in auctionItemMgr.worldAuctionItemList: | 
|---|
|  |  |  | if job and worldAuctionItem.ItemJobLimit != job: | 
|---|
|  |  |  | if job and worldAuctionItem.ItemJobLimit != job and worldAuctionItem.ItemJobLimit: | 
|---|
|  |  |  | continue | 
|---|
|  |  |  | if itemTypeList and worldAuctionItem.ItemType not in itemTypeList: | 
|---|
|  |  |  | continue | 
|---|
|  |  |  | 
|---|
|  |  |  | if fromAuctionItem: | 
|---|
|  |  |  | if fromAuctionItem not in auctionItemQueryList: | 
|---|
|  |  |  | GameWorld.ErrLog("查询的目标拍品不在所在的过滤的条件里! fromItemGUID=%s" % fromItemGUID) | 
|---|
|  |  |  | PlayerControl.NotifyCode(curPlayer, "Paimai5") | 
|---|
|  |  |  | if isNotify: | 
|---|
|  |  |  | PlayerControl.NotifyCode(curPlayer, "Paimai5") | 
|---|
|  |  |  | return | 
|---|
|  |  |  | fromIndex = auctionItemQueryList.index(fromAuctionItem) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | DataRecordPack.SendEventPack("AuctionHouse", dataDict, curPlayer) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def DoAddFamilyAuctionItem(mapID, familyAuctionItemDict): | 
|---|
|  |  |  | ''' 上架仙盟拍品,因为仙盟拍品默认上架,所以使用批量上架 | 
|---|
|  |  |  | @param familyAuctionItemDict: {仙盟ID:[[享受收益的成员ID, ...], [[拍品ID,个数], [拍品ID,个数,是否拍品], ...]], ...} | 
|---|
|  |  |  | ''' | 
|---|
|  |  |  | GameWorld.Log("发送地图上架仙盟拍品: mapID=%s, %s" % (mapID, familyAuctionItemDict)) | 
|---|
|  |  |  | GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_AddFamilyAuctionItem, [mapID, familyAuctionItemDict]) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|