WarAllianceAuction.lua 22 KB

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