WarAllianceAuction.lua 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. Auction = {}
  2. AuctionConst = {
  3. AUCTION_WAY = 1,
  4. AUCTION_TIMER = 201,
  5. AUCTION_DIVIDEND = 14001002, -- 分红比例
  6. AUCTION_SUCCESS_EMAIL = 106001,
  7. AUCTION_FAIL_EMAIL = 106002, -- 拍卖失败返还邮件
  8. AUCTION_DIVIDE_EMAIL = 106012, -- 拍卖分红邮件
  9. AUCTION_GOODS = "U$AuctionGoods",
  10. CAN_DISTRIBUTE_IDS = "U$DistributeIds",
  11. CAN_REWARD_UNIONS = "R$CanRewardUnions",
  12. }
  13. local SortType = {
  14. ASC_BY_TIME = 1, -- 按照时间升序
  15. DESC_BY_TIME = 2, -- 按照时间降序
  16. ASC_BY_PRICE = 3, -- 按照价格升序
  17. DESC_BY_PRICE = 4, -- 按照价格降序
  18. }
  19. function Auction.NoticeClientToStartAuction(actor, unionId, myHurtMember, canRewardUnions)
  20. local goods = ConfigDataManager.getTable("cfg_stall", "way", AuctionConst.AUCTION_WAY)
  21. local openDays = getbaseinfo(actor, "serveropendays")
  22. local auctionGoods, closetDay = Auction.GetClosetGoodsData(goods, openDays)
  23. local idAndCount = {}
  24. for _, goodsInfo in ipairs(auctionGoods) do
  25. local probability = goodsInfo["probability"]
  26. local cfgid = goodsInfo['id']
  27. local count = goodsInfo['number']
  28. if probability ~= "" and probability ~= nil then
  29. probability = tonumber(probability)
  30. local num = math.random(1, 10000)
  31. if probability >= num then
  32. idAndCount[tonumber(cfgid)] = tonumber(count)
  33. end
  34. else
  35. idAndCount[tonumber(cfgid)] = tonumber(count)
  36. end
  37. end
  38. local itemInfos = saveunionitem(actor, DuplicateType.WAR_ALLIANCE, idAndCount)
  39. -- lg("返回的道具信息", itemInfos)
  40. local items = {}
  41. for index, itemInfo in ipairs(itemInfos) do
  42. local id = itemInfo["id"]
  43. local itemcfgid = itemInfo["itemcfgid"]
  44. local rank = itemInfo["rank"]
  45. local grade = itemInfo["grade"]
  46. local entrysize = itemInfo["entrysize"]
  47. local stalls = ConfigDataManager.getTable("cfg_stall", "id", itemcfgid, "startday", closetDay, "way",
  48. TRADE_WAY.GARD_BOSS)
  49. local itemStall = stalls[1]
  50. local bidderid = 0
  51. local itemname = itemStall["name"]
  52. local type = itemStall["type"]
  53. local subtype = itemStall["subtype"]
  54. local count = itemStall["number"]
  55. local state = ""
  56. local oneprice = itemStall["fixedprice"]
  57. local price = itemStall["startingprice"]
  58. local increment = itemStall["auction"]
  59. local cointype = itemStall["money"]
  60. local time = itemStall["time"]
  61. local now = getbaseinfo("now")
  62. local endTime = now + time * 60 * 1000
  63. local career = itemStall["job"]
  64. local item = {
  65. itemid = id,
  66. itemcfgid = itemcfgid,
  67. bidderid = bidderid,
  68. rank = rank,
  69. grade = grade or 1,
  70. entrysize = tonumber(entrysize),
  71. itemname = itemname,
  72. type = tonumber(type),
  73. subtype = tonumber(subtype),
  74. count = tonumber(count),
  75. state = state,
  76. price = tonumber(price),
  77. oneprice = tonumber(oneprice),
  78. increment = tonumber(increment),
  79. cointype = tonumber(cointype),
  80. time = time * 60,
  81. endtime = endTime,
  82. career = career,
  83. }
  84. table.insert(items, item)
  85. end
  86. -- lg("获取到拍卖行物品信息", items)
  87. local guild = getmyguild(actor)
  88. if not guild then
  89. return
  90. end
  91. local myUnionGoods = getguilddef(guild, AuctionConst.AUCTION_GOODS) or {}
  92. myUnionGoods = myUnionGoods == "" and {} or myUnionGoods
  93. if next(myUnionGoods) ~= nil then
  94. for _, item in ipairs(items) do
  95. table.insert(myUnionGoods, item)
  96. end
  97. else
  98. myUnionGoods = items
  99. end
  100. setguilddef(guild, AuctionConst.AUCTION_GOODS, myUnionGoods)
  101. -- lg("我的战盟伤害成员:", myHurtMember)
  102. setguilddef(guild, AuctionConst.CAN_DISTRIBUTE_IDS, myHurtMember)
  103. -- lg("可参与竞拍的战盟", canRewardUnions)
  104. setsysvar(actor, AuctionConst.CAN_REWARD_UNIONS, canRewardUnions)
  105. GlobalTimer.setontimerex(AuctionConst.AUCTION_TIMER, 3)
  106. Auction.SendOpenAuctionMessage(actor, myHurtMember)
  107. end
  108. function Auction.GetClosetGoodsData(goods, openDays)
  109. local closestDay = 0
  110. local minDiff = 99999
  111. for _, goodsInfo in ipairs(goods) do
  112. local startDay = goodsInfo["startday"]
  113. startDay = tonumber(startDay)
  114. local diff = math.abs(startDay - openDays)
  115. if startDay <= openDays then
  116. if diff < minDiff then
  117. minDiff = diff
  118. closestDay = startDay
  119. end
  120. end
  121. end
  122. local closestElements = {}
  123. for _, goodsInfo in ipairs(goods) do
  124. local startDay = goodsInfo["startday"]
  125. startDay = tonumber(startDay)
  126. if startDay == closestDay then
  127. table.insert(closestElements, goodsInfo)
  128. end
  129. end
  130. return closestElements, closestDay
  131. end
  132. function Auction.SendOpenAuctionMessage(actor, myHurtMember)
  133. for _, player in ipairs(myHurtMember) do
  134. local role = getactor(actor, player)
  135. local mapId = getbaseinfo(actor, "unimapid")
  136. if mapId ~= 0 then
  137. WarAlliance.ResTaskPhaseUpdate(role, mapId)
  138. end
  139. sendluamsg(role, LuaMessageIdToClient.RES_WAR_ALLIANCE_OPEN_AUCTION, { 1 })
  140. end
  141. end
  142. function ontimerex201()
  143. local guilds = getsysvar(AuctionConst.CAN_REWARD_UNIONS)
  144. if guilds == nil or guilds == "" or next(guilds) == nil then
  145. return
  146. end
  147. -- lg("可参与竞拍的战盟:", unionIds)
  148. for _, guild in ipairs(guilds) do
  149. local unionId = tonumber(guild:toString())
  150. local goods = getguilddef(guild, AuctionConst.AUCTION_GOODS) or {}
  151. goods = goods == "" and {} or goods
  152. -- lg("当前战盟拍卖行物品信息:", goods)
  153. if next(goods) ~= nil then
  154. local removeIndices = {}
  155. for i, goodsInfo in ipairs(goods) do
  156. local endTime = goodsInfo["endtime"]
  157. local now = getbaseinfo("now")
  158. if endTime < now then
  159. table.insert(removeIndices, i)
  160. end
  161. end
  162. -- lg("本次拍卖行过期商品索引:", removeIndices)
  163. for i = #removeIndices, 1, -1 do
  164. local indexToRemove = removeIndices[i]
  165. Auction.OnTimeSettleAuction(goods[indexToRemove], guild)
  166. table.remove(goods, indexToRemove)
  167. end
  168. end
  169. setguilddef(guild, AuctionConst.AUCTION_GOODS, goods)
  170. end
  171. local allHadExpired = true
  172. for _, guild in ipairs(guilds) do
  173. local goods = getguilddef(guild, AuctionConst.AUCTION_GOODS) or {}
  174. if next(goods) ~= nil then
  175. allHadExpired = false
  176. break
  177. end
  178. end
  179. if allHadExpired then
  180. GlobalTimer.setofftimer(AuctionConst.AUCTION_TIMER)
  181. end
  182. end
  183. -- 筛选商品
  184. function Auction.GetSomeGoods(actor, msgData, isCheck)
  185. local type = msgData[1]
  186. local subType = msgData[2]
  187. local sort = msgData[3]
  188. local career = msgData[4]
  189. local rank = msgData[5]
  190. local grade = msgData[6]
  191. local guild = getmyguild(actor)
  192. if not guild then
  193. return {}
  194. end
  195. local myUnionGoods = getguilddef(guild, AuctionConst.AUCTION_GOODS) or {}
  196. myUnionGoods = myUnionGoods == "" and {} or myUnionGoods
  197. if next(myUnionGoods) == nil then
  198. sendluamsg(actor, LuaMessageIdToClient.RES_WAR_ALLIANCE_AUCTION_GOODS, myUnionGoods)
  199. return myUnionGoods
  200. end
  201. local filteredGoods = Auction.FilterGoods(myUnionGoods, type, subType, career, grade, rank)
  202. Auction.SortGoods(filteredGoods, sort)
  203. -- 添加我的竞拍信息
  204. for _, goods in ipairs(filteredGoods) do
  205. local bidder = goods["bidderid"]
  206. if bidder == 0 then
  207. goods["state"] = ""
  208. elseif bidder:toString() == actor:toString() then
  209. goods["state"] = "我的竞拍"
  210. else
  211. goods["state"] = "竞拍中"
  212. end
  213. end
  214. if isCheck then
  215. return filteredGoods
  216. else
  217. sendluamsg(actor, LuaMessageIdToClient.RES_WAR_ALLIANCE_AUCTION_GOODS, filteredGoods)
  218. end
  219. end
  220. function Auction.FilterGoods(myUnionGoods, type, subType, career, grade, rank)
  221. local filteredGoods = {}
  222. -- lg("筛选商品:", "type", type, "career", career, "grade", grade, "rank", rank)
  223. for _, goods in ipairs(myUnionGoods) do
  224. if (type ~= 0 and type ~= tonumber(goods["type"])) then
  225. goto continue
  226. end
  227. if (subType ~= 0 and subType ~= tonumber(goods["subtype"])) then
  228. goto continue
  229. end
  230. if (career ~= 0) then
  231. local careers = goods["career"]
  232. local careerArr = string.splitByAll(careers, "#")
  233. local baseCareer = careerArr[1]
  234. local isCareerMatch = career == tonumber(baseCareer)
  235. if not isCareerMatch then
  236. goto continue
  237. end
  238. end
  239. if (rank ~= 0 and rank ~= tonumber(goods["rank"])) then
  240. goto continue
  241. end
  242. if (grade ~= 0 and grade ~= tonumber(goods["grade"])) then
  243. goto continue
  244. end
  245. local endTime = goods["endtime"]
  246. if tonumber(endTime) <= getbaseinfo("now") then
  247. goto continue
  248. end
  249. table.insert(filteredGoods, goods)
  250. ::continue::
  251. end
  252. return filteredGoods
  253. end
  254. function Auction.SortGoods(filteredGoods, sortType)
  255. local function compare(a, b)
  256. if sortType == SortType.ASC_BY_TIME then
  257. return a["time"] < b["time"]
  258. elseif sortType == SortType.DESC_BY_TIME then
  259. return a["time"] > b["time"]
  260. elseif sortType == SortType.ASC_BY_PRICE then
  261. return a["price"] < b["price"]
  262. elseif sortType == SortType.DESC_BY_PRICE then
  263. return a["price"] > b["price"]
  264. end
  265. end
  266. table.sort(filteredGoods, compare)
  267. end
  268. function Auction.GetGoodsDetailInfo(actor, msgData)
  269. local itemId = msgData["itemId"]
  270. local type = msgData["type"]
  271. goodsdetailinfo(actor, itemId, AuctionConst.AUCTION_WAY, actor:toString())
  272. end
  273. -- @description 玩家竞价
  274. function Auction.PlayerBidOnItem(actor, msgData)
  275. local goodsId = msgData["goodsId"]
  276. local guild = getmyguild(actor)
  277. if guild == nil then
  278. tipinfo(actor, "您不是战盟成员,无法参与竞拍")
  279. return
  280. end
  281. local hasQualify = Auction.CheckHQualify(actor)
  282. if not hasQualify then
  283. tipinfo(actor, "战盟boss未通关,无法参与竞拍")
  284. return
  285. end
  286. local result = Auction.BiddingGoods(actor, goodsId, guild)
  287. local biddingResult
  288. if result then
  289. info("玩家竞价成功", actor:toString(), goodsId)
  290. biddingResult = { opt = "bidding", ret = true }
  291. else
  292. info("玩家竞价失败", actor:toString(), goodsId)
  293. biddingResult = { opt = "bidding", ret = false }
  294. end
  295. sendluamsg(actor, LuaMessageIdToClient.RES_WAR_ALLIANCE_OPT_INFO, biddingResult)
  296. end
  297. function Auction.BiddingGoods(actor, goodsId, guild)
  298. local unionId = tonumber(guild:toString())
  299. local myUnionGoods = getguilddef(guild, AuctionConst.AUCTION_GOODS) or {}
  300. myUnionGoods = myUnionGoods == "" and {} or myUnionGoods
  301. local currGoods
  302. for _, goods in ipairs(myUnionGoods) do
  303. if tostring(goodsId) == tostring(goods["itemid"]) then
  304. currGoods = goods
  305. break
  306. end
  307. end
  308. if currGoods == nil then
  309. tipinfo(actor, "该商品已被购买或已下架")
  310. return false
  311. end
  312. local lastBidder = currGoods["bidderid"]
  313. if lastBidder ~= 0 and lastBidder:toString() == actor:toString() then
  314. tipinfo(actor, "您已经参与竞价,请勿重复参与")
  315. return false
  316. end
  317. local bidPrice = currGoods["price"]
  318. local onePrice = currGoods["oneprice"]
  319. local newPrice = Auction.CalculateNewPrice(currGoods)
  320. local coinType = currGoods["cointype"]
  321. local coinCount = getbagitemcountbyid(actor, coinType)
  322. if coinCount < newPrice then
  323. local coinName = ConfigDataManager.getTableValue("cfg_item", "name", "id", coinType)
  324. tipinfo(actor, "您的" .. coinName .. "不足")
  325. return false
  326. end
  327. if lastBidder ~= 0 then
  328. Auction.SendBidFaileMail(lastBidder, goodsId, coinType, bidPrice)
  329. end
  330. if newPrice == onePrice then
  331. tipinfo(actor, "当前价格达到一口价,转为一口价购买")
  332. local itemCfgId = tonumber(currGoods["itemcfgid"])
  333. local itemName = ConfigDataManager.getTableValue("cfg_item", "name", "id", itemCfgId)
  334. local result = moveunionitem(actor, goodsId, unionId, actor:toString(), AuctionConst.AUCTION_SUCCESS_EMAIL,
  335. itemName)
  336. if result then
  337. removeitemfrombag(actor, coinType, newPrice,0,9999,'战盟BOSS竞拍')
  338. local myHurtMembers = getguilddef(guild, AuctionConst.CAN_DISTRIBUTE_IDS)
  339. Auction.DistributeProfits(actor, itemCfgId, coinType, newPrice, myHurtMembers)
  340. end
  341. for i = #myUnionGoods, 1, -1 do
  342. local goods = myUnionGoods[i]
  343. if tostring(goods["itemid"]) == tostring(goodsId) then
  344. table.remove(myUnionGoods, i)
  345. end
  346. end
  347. setguilddef(guild, AuctionConst.AUCTION_GOODS, myUnionGoods)
  348. return true
  349. end
  350. removeitemfrombag(actor, coinType, newPrice,0,9999,'战盟BOSS竞拍')
  351. currGoods["price"] = newPrice
  352. currGoods["bidderid"] = actor
  353. setguilddef(guild, AuctionConst.AUCTION_GOODS, myUnionGoods)
  354. return true
  355. end
  356. function Auction.CalculateNewPrice(currGoods)
  357. local bidPrice = currGoods["price"]
  358. local increment = currGoods["increment"]
  359. local onePrice = currGoods["oneprice"]
  360. local newPrice = math.ceil(bidPrice * (1 + increment * 0.0001))
  361. if newPrice > onePrice then
  362. newPrice = onePrice
  363. end
  364. return newPrice
  365. end
  366. -- @description 玩家一口价购买
  367. function Auction.PlayerBuyNow(actor, msgData)
  368. local goodsId = msgData["goodsId"]
  369. -- 检查玩家是否属于战盟
  370. local guild = getmyguild(actor)
  371. if guild == nil then
  372. tipinfo(actor, "您不是战盟成员,无法参与竞拍")
  373. return
  374. end
  375. -- 检查战盟通关条件
  376. local hasQualify = Auction.CheckHQualify(actor)
  377. if not hasQualify then
  378. tipinfo(actor, "战盟通关条件不符合,无法一口价购买")
  379. return
  380. end
  381. -- 一口价购买
  382. local result = Auction.BuyGoods(actor, goodsId, guild)
  383. local buyResult;
  384. if result then
  385. info("玩家一口价购买成功", actor:toString(), goodsId)
  386. buyResult = { opt = "buy", ret = true }
  387. else
  388. info("玩家一口价购买失败", actor:toString(), goodsId)
  389. buyResult = { opt = "buy", ret = false }
  390. end
  391. -- lg("玩家一口价购买结果:", buyResult)
  392. sendluamsg(actor, LuaMessageIdToClient.RES_WAR_ALLIANCE_OPT_INFO, buyResult)
  393. end
  394. function Auction.BuyGoods(actor, goodsId, guild)
  395. local unionId = tonumber(guild:toString())
  396. local myUnionGoods = getguilddef(guild, AuctionConst.AUCTION_GOODS) or {}
  397. myUnionGoods = myUnionGoods == "" and {} or myUnionGoods
  398. local currGoods
  399. for _, goods in ipairs(myUnionGoods) do
  400. if tostring(goodsId) == tostring(goods["itemid"]) then
  401. currGoods = goods
  402. break
  403. end
  404. end
  405. if currGoods == nil then
  406. tipinfo(actor, "该商品已被购买或已下架")
  407. return false
  408. end
  409. local lastBidder = currGoods["bidderid"]
  410. if lastBidder ~= 0 and lastBidder:toString() == actor:toString() then
  411. tipinfo(actor, "您已经参与竞价,请勿重复参与")
  412. return false
  413. end
  414. local bidPrice = currGoods["price"]
  415. local newPrice = currGoods["oneprice"]
  416. local coinType = currGoods["cointype"]
  417. local coinCount = getbagitemcountbyid(actor, coinType)
  418. if coinCount < newPrice then
  419. local coinName = ConfigDataManager.getTableValue("cfg_item", "name", "id", coinType)
  420. tipinfo(actor, "您的" .. coinName .. "不足")
  421. return false
  422. end
  423. if lastBidder ~= 0 then
  424. Auction.SendBidFaileMail(lastBidder, goodsId, coinType, bidPrice)
  425. end
  426. local itemCfgId = tonumber(currGoods["itemcfgid"])
  427. local itemName = ConfigDataManager.getTableValue("cfg_item", "name", "id", itemCfgId)
  428. local result = moveunionitem(actor, goodsId, unionId, actor:toString(), AuctionConst.AUCTION_SUCCESS_EMAIL, itemName)
  429. if result then
  430. removeitemfrombag(actor, coinType, newPrice,0,9999,'战盟BOSS竞拍')
  431. local myHurtMembers = getguilddef(guild, AuctionConst.CAN_DISTRIBUTE_IDS) or {}
  432. Auction.DistributeProfits(actor, itemCfgId, coinType, newPrice, myHurtMembers)
  433. end
  434. for i = #myUnionGoods, 1, -1 do
  435. local goods = myUnionGoods[i]
  436. if tostring(goods["itemid"]) == tostring(goodsId) then
  437. table.remove(myUnionGoods, i)
  438. end
  439. end
  440. setguilddef(guild, AuctionConst.AUCTION_GOODS, myUnionGoods)
  441. return true
  442. end
  443. function Auction.ShowAutionPanel(actor)
  444. local result = Auction.CheckHQualify(actor)
  445. if result then
  446. sendluamsg(actor, LuaMessageIdToClient.RES_WAR_ALLIANCE_SHOW_AUCTION_PANEL, { true })
  447. else
  448. sendluamsg(actor, LuaMessageIdToClient.RES_WAR_ALLIANCE_SHOW_AUCTION_PANEL, { false })
  449. end
  450. end
  451. -- 检查自己的战盟是否通关
  452. function Auction.CheckHQualify(actor)
  453. local allianceId = getbaseinfo(actor, "guildid")
  454. if allianceId == 0 then
  455. return false
  456. end
  457. local goods = Auction.GetSomeGoods(actor, { 0, 0, 0, 0, 0, 0 }, true)
  458. return #goods > 0
  459. end
  460. function Auction.OnTimeSettleAuction(goodsInfo, guild)
  461. -- lg("开始结算拍卖,商品信息", goodsInfo)
  462. if goodsInfo == nil then
  463. return
  464. end
  465. local unionId = tonumber(guild:toString())
  466. local bidder = goodsInfo["bidderid"]
  467. local goodsId = goodsInfo["itemid"]
  468. info("结算拍卖,商品信息,竞拍者:", bidder)
  469. local result
  470. if bidder == 0 then
  471. -- lg("结算无购买者","goodsId",goodsId,"unionId",unionId)
  472. result = moveunionitem(goodsId, unionId)
  473. else
  474. local myHurtMembers = getguilddef(guild, AuctionConst.CAN_DISTRIBUTE_IDS)
  475. local cointype = tonumber(goodsInfo["cointype"])
  476. local price = tonumber(goodsInfo["price"])
  477. local itemcfgid = tonumber(goodsInfo["itemcfgid"])
  478. local itemName = ConfigDataManager.getTableValue("cfg_item", "name", "id", itemcfgid)
  479. info("结算有购买者", "unionId", unionId, "bidder", bidder)
  480. result = moveunionitem(bidder, goodsId, unionId, bidder:toString(), AuctionConst.AUCTION_SUCCESS_EMAIL, itemName)
  481. -- lg("删除结果:", result)
  482. if result then
  483. Auction.DistributeProfits(bidder, itemcfgid, cointype, price, myHurtMembers)
  484. end
  485. end
  486. end
  487. function Auction.DistributeProfits(actor, itemCfgId, coinType, price, canBuyIds)
  488. info("分红信息:","角色:",actor, "道具:",itemCfgId, "分红成员:",canBuyIds)
  489. if array.simpleContains(canBuyIds, actor:toString()) then
  490. for _, member in ipairs(canBuyIds) do
  491. local memberActor = getactor(actor, member)
  492. if memberActor:toString() ~= actor:toString() then
  493. Auction.ActDistribute(memberActor, itemCfgId, coinType, price, #canBuyIds - 1)
  494. end
  495. end
  496. else
  497. for _, member in ipairs(canBuyIds) do
  498. local memberActor = getactor(actor, member)
  499. Auction.ActDistribute(memberActor, itemCfgId, coinType, price, #canBuyIds)
  500. end
  501. end
  502. end
  503. function Auction.ActDistribute(actor, itemCfgId, coinType, price, personCount)
  504. local dividendRatio = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", AuctionConst.AUCTION_DIVIDEND)
  505. dividendRatio = tonumber(dividendRatio) * 0.0001
  506. local profitPerMember = price * dividendRatio
  507. profitPerMember = math.floor(profitPerMember)
  508. Auction.SendDivideMail(actor, itemCfgId, coinType, profitPerMember, personCount)
  509. end
  510. -- @description 发送分红邮件
  511. function Auction.SendDivideMail(actor, itemCfgId, coinType, profitPerMember, personCount)
  512. local itemName = ConfigDataManager.getTableValue("cfg_item", "name", "id", itemCfgId)
  513. local priceTypeName = ConfigDataManager.getTableValue("cfg_item", "name", "id", coinType)
  514. local totalDivide = profitPerMember * personCount
  515. local param = itemName .. "#" .. priceTypeName .. "#" .. totalDivide .. "#" .. profitPerMember
  516. sendconfigmailbyrid(actor, actor:toString(),
  517. AuctionConst.AUCTION_DIVIDE_EMAIL, { [tonumber(coinType)] = tonumber(profitPerMember) }, param)
  518. end
  519. -- @description 发送竞价失败邮件
  520. function Auction.SendBidFaileMail(lastBidder, goodsId, costType, costNum)
  521. -- lg("发送竞价失败邮件:", lastBidder, goodsId, costType, costNum)
  522. local itemName = ConfigDataManager.getTableValue("cfg_item", "name", "id", goodsId)
  523. local costName = ConfigDataManager.getTableValue("cfg_item", "name", "id", costType)
  524. local param = itemName .. "#" .. costName
  525. sendconfigmailbyrid(lastBidder, lastBidder:toString(),
  526. AuctionConst.AUCTION_FAIL_EMAIL, { [tonumber(costType)] = tonumber(costNum) }, param)
  527. end
  528. function Auction.combineGlobalVar(varName,varData)
  529. local data = {}
  530. for sid, var in pairs(varData) do
  531. table.AddRanage(data, var)
  532. end
  533. setsysvar(varName, data)
  534. end
  535. function clearauction(actor)
  536. local guild = getmyguild(actor)
  537. setguilddef(guild, AuctionConst.AUCTION_GOODS, {})
  538. setguilddef(guild, AuctionConst.CAN_DISTRIBUTE_IDS, {})
  539. setsysvar(actor, AuctionConst.CAN_REWARD_UNIONS, {})
  540. end