ServerCommerceActRank.lua 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. --------------------------------
  2. -- 文件名 : WeekendLoopActRank.lua
  3. -- 文件说明 : 周末冲刺-排行榜
  4. -- 创建时间 : 2024/12/09
  5. -- 创建人 : FC
  6. --------------------------------
  7. local Msg = require("core.Msg")
  8. local Util = require("common.Util")
  9. local Lang = require("common.Lang")
  10. local CommonDB = require("common.CommonDB")
  11. local Broadcast = require("broadcast.Broadcast")
  12. local CommonDefine = require("common.CommonDefine")
  13. local Timer = require("core.Timer")
  14. local Config = require("Config")
  15. local Grid = require("bag.Grid")
  16. local ObjHuman = require("core.ObjHuman")
  17. local MailExcel = require("excel.mail")
  18. local MailManager = require("mail.MailManager")
  19. local RoleDBLogic = require("role.RoleDBLogic")
  20. local ServerCommerceMiddle = require("serverCommerce.ServerCommerceMiddle")
  21. local ServerCommerceDefine = require("serverCommerce.ServerCommerceActDefine")
  22. local ServerCommerceRankConf = require("excel.ServerCommerce").CommerceRank
  23. local ServerCommerceManager = require("serverCommerce.ServerCommerceManager")
  24. -- 缓存的排行榜数据
  25. local COMMERCE_RANK_CACHE = {}
  26. -- 缓存的ServerKey
  27. local COMMERCE_RANK_SERVER_KEY = nil
  28. -- 缓存的服务器排名
  29. local COMMERCE_RANK_SERVER_RANK = nil
  30. -- 待发送全服奖励的玩家
  31. local COMMRCE_RANK_SERVERMAIL_HUMAN = nil
  32. ----------------------------------------- 内部处理开始 -------------------------------------
  33. function CommercerActRank_QueryRankInfo(nRankType, nRankSubType)
  34. do
  35. return
  36. end
  37. ServerCommerceMiddle.CommerveMiddle_QueryRankInfo(nRankType, nRankSubType)
  38. print("[CommercerActRank_QueryRankInfo] 向中心服请求排行榜 nRankType = "..nRankType.." nRankSubType = "..nRankSubType)
  39. CommercerActRank_CreateTime(ServerCommerceDefine.COMMERCEACT_RANKUPDATE, nRankType, nRankSubType)
  40. end
  41. -- 检查是否存在对应缓存
  42. local function CommercerActRank_CheckCache(nRankType, nRankSubType, nServerKey)
  43. if not COMMERCE_RANK_CACHE then
  44. return false
  45. end
  46. if not COMMERCE_RANK_CACHE[nRankType] or not COMMERCE_RANK_CACHE[nRankType][nRankSubType]
  47. or not COMMERCE_RANK_CACHE[nRankType][nRankSubType][nServerKey] then
  48. return false
  49. end
  50. return true
  51. end
  52. -- 获取上榜的最小条件
  53. local function CommercerActRank_GetInRankMinValue(nRankSubType, nRank)
  54. for nID, v in ipairs(ServerCommerceRankConf) do
  55. if v.nRankType == nRankSubType then
  56. if v.nOrder[1] <= nRank and v.nOrder[2] >= nRank then
  57. return v.nPoint
  58. end
  59. end
  60. end
  61. return 0
  62. end
  63. -- 创建缓存
  64. local function CommercerActRank_CreateCache(nRankType, nRankSubType, nServerKey)
  65. if not COMMERCE_RANK_CACHE then
  66. COMMERCE_RANK_CACHE = {}
  67. end
  68. if not COMMERCE_RANK_CACHE[nRankType] then
  69. COMMERCE_RANK_CACHE[nRankType] = {}
  70. end
  71. if not COMMERCE_RANK_CACHE[nRankType][nRankSubType] then
  72. COMMERCE_RANK_CACHE[nRankType][nRankSubType] = {}
  73. end
  74. if not COMMERCE_RANK_CACHE[nRankType][nRankSubType][nServerKey] then
  75. COMMERCE_RANK_CACHE[nRankType][nRankSubType][nServerKey] = {}
  76. end
  77. end
  78. -- 获取缓存的排行榜数据
  79. local function CommercerActRank_GetCacheRankData(nRankType, nRankSubType, nServerKey)
  80. return COMMERCE_RANK_CACHE[nRankType][nRankSubType][nServerKey]
  81. end
  82. local function CommercerActRank_GetCacheRankDataByRank(nRankType, nRankSubType, nServerKey, nRank)
  83. return COMMERCE_RANK_CACHE[nRankType][nRankSubType][nServerKey][nRank]
  84. end
  85. -- 清空对应的排行榜
  86. local function CommercerActRank_ClearCache(nRankType, nRankSubType, nServerKey)
  87. COMMERCE_RANK_CACHE[nRankType][nRankSubType][nServerKey] = {}
  88. end
  89. -- 插入排行榜数据
  90. local function CommercerActRank_InsertRank(nRankType, nRankSubType, nServerKey, nRank, tRankInfo)
  91. local tCacheRankData = CommercerActRank_GetCacheRankData(nRankType, nRankSubType, nServerKey)
  92. tCacheRankData[nRank] = tRankInfo
  93. end
  94. local function CommercerActRank_GetRankInfoByUuid(nRankType, nRankSubType, uuid)
  95. local tCacheRankData = CommercerActRank_GetCacheRankData(nRankType, nRankSubType, COMMERCE_RANK_SERVER_KEY)
  96. if not tCacheRankData then
  97. return nil, nil
  98. end
  99. table.print_lua_table(tCacheRankData)
  100. local nGetRank, tGetRankInfo = nil, nil
  101. for nRank, v in pairs(tCacheRankData) do
  102. if "table" == type(v) then
  103. print("[CommercerActRank_GetRankInfoByUuid] v.uuid = "..v.uuid.." uuid = "..uuid)
  104. if v.uuid == uuid then
  105. print("[CommercerActRank_GetRankInfoByUuid] 相等的")
  106. end
  107. end
  108. if "table" == type(v) and v.uuid == uuid then
  109. nGetRank = nRank
  110. tGetRankInfo = v
  111. break
  112. end
  113. end
  114. return nGetRank, tGetRankInfo
  115. end
  116. -- 包装自己名次数据
  117. local function CommercerActRank_WrapOwnerData(nRankType, nRankSubType, net, uuid)
  118. local nRank, tRankInfo = CommercerActRank_GetRankInfoByUuid(nRankType, nRankSubType, uuid)
  119. net.rank = nRank or -1
  120. net.rankValue = tRankInfo and tRankInfo.nValue or 0
  121. local len = 0
  122. local nNeedPoint = 0
  123. if nRank and tRankInfo then
  124. for _, v in ipairs(ServerCommerceRankConf) do
  125. if v.nRankType == nRankSubType then
  126. if v.nOrder[1] <= nRank and v.nOrder[2] >= nRank then
  127. for index, itemInfo in ipairs(v.Prize) do
  128. len = len + 1
  129. Grid.makeItem(net.items[index], itemInfo[1], itemInfo[2])
  130. nNeedPoint = v.nPoint
  131. end
  132. break
  133. end
  134. end
  135. end
  136. else
  137. local nMinRank, tMinPrize = 0, nil
  138. for _, v in ipairs(ServerCommerceRankConf) do
  139. if v.nRankType == nRankSubType then
  140. if v.nOrder[1] > nMinRank then
  141. nMinRank = v.nOrder[1]
  142. tMinPrize = v.Prize
  143. nNeedPoint = v.nPoint
  144. end
  145. end
  146. end
  147. if nil ~= tMinPrize then
  148. for index, itemInfo in ipairs(tMinPrize) do
  149. len = len + 1
  150. Grid.makeItem(net.items[index], itemInfo[1], itemInfo[2])
  151. end
  152. end
  153. end
  154. net.rankNeedValue = nNeedPoint
  155. net.servername = "寻宝"..Config.NEW_SVR_INDEX.."区"
  156. net.items[0] = len
  157. end
  158. -- 包装档位名次数据
  159. local function CommercerActRank_WrapRankList(nRankType, nRankSubType, net, nRank)
  160. local tRankData = CommercerActRank_GetCacheRankDataByRank(nRankType, nRankSubType, COMMERCE_RANK_SERVER_KEY, nRank)
  161. net.rank = nRank
  162. net.rankNeedValue = CommercerActRank_GetInRankMinValue(nRankSubType, nRank)
  163. if tRankData and tRankData ~= -1 then
  164. net.uid = tRankData.uuid
  165. net.name = tRankData.name
  166. net.head = tRankData.head
  167. net.rankValue = tRankData.nValue
  168. net.headFrame = tRankData.headFrame
  169. net.servername = tRankData.servername
  170. else
  171. net.uid = "-1"
  172. net.name = ""
  173. net.head = -1
  174. net.rankValue = 0
  175. net.headFrame = -1
  176. net.servername = ""
  177. end
  178. local len, nNeedPoint = 0, 0
  179. for _, v in ipairs(ServerCommerceRankConf) do
  180. if v.nRankType == nRankSubType then
  181. if v.nOrder[1] <= nRank and v.nOrder[2] >= nRank then
  182. nNeedPoint = v.nPoint
  183. for index, itemInfo in ipairs(v.Prize) do
  184. len = len + 1
  185. Grid.makeItem(net.items[index], itemInfo[1], itemInfo[2])
  186. end
  187. break
  188. end
  189. end
  190. end
  191. --Grid.makeItem(net.pointItem, ServerCommerceDefine.COMERCEACT_POINT_GOODSID, nNeedPoint)
  192. net.items[0] = len
  193. end
  194. ----------------------------------------- 外部调用 -------------------------------------
  195. function CommercerActRank_ResetData(human)
  196. if not human then
  197. return
  198. end
  199. --CommercerActRank_ResetCharge(human)
  200. end
  201. -- 活动结束
  202. function CommercerActRank_End()
  203. end
  204. function ClearCache()
  205. COMMERCE_RANK_CACHE = {}
  206. COMMERCE_RANK_SERVER_KEY = nil
  207. COMMERCE_RANK_SERVER_RANK = nil
  208. COMMRCE_RANK_SERVERMAIL_HUMAN = nil
  209. end
  210. -- 玩家点数改变
  211. function CommercerActRank_HumanPointChange(human, nNowPoint)
  212. ServerCommerceMiddle.CommerveMiddle_HumanPointChange(human, nNowPoint)
  213. end
  214. -- 服务器总点数改变
  215. function onAllPointChange()
  216. local nNowPoint = CommonDB.GetCommerceActInfo_Point()
  217. ServerCommerceMiddle.CommerveMiddle_ServerPointChange(nNowPoint)
  218. end
  219. -- 定时请求数据
  220. function CommercerActRank_CreateTime(nTime, nRankType, nRankSubType)
  221. local nNowTime = os.time()
  222. local nOpenTime, nEndTime = ServerCommerceManager.CommerceAct_GetOpenAndEndTime()
  223. if nEndTime == 0 or nEndTime < nNowTime then
  224. print("[CommercerActRank_CreateTime] 当前活动时间不满足条件 nEndTime = "..nEndTime.." nNowTime = "..nNowTime)
  225. return
  226. end
  227. Timer.addLater(nTime, CommercerActRank_QueryRankInfo, nRankType, nRankSubType)
  228. print("[CommercerActRank_CreateTime] 重新创建定时器成功")
  229. end
  230. -- 起服活动开启 请求排行榜数据
  231. function CommercerActRank_InitServerQueryRank()
  232. CommercerActRank_QueryRankInfo(CommonDefine.COMMONRANK_TYPE_SERVERCOMMERCE,
  233. CommonDefine.COMMONRANK_SUB_TYPE_SERVERCOMMERCE_SERVER)
  234. -- 延迟20秒请求 个人排行榜
  235. Timer.addLater(20, CommercerActRank_QueryRankInfo,
  236. CommonDefine.COMMONRANK_TYPE_SERVERCOMMERCE, CommonDefine.COMMONRANK_SUB_TYPE_SERVERCOMMERCE_HUMAN)
  237. end
  238. -- 获取到排行榜数据
  239. function CommercerActRank_GetRankInfo(tGetData)
  240. local nRankType = tGetData.nRankType
  241. local nRankSubType = tGetData.nRankSubType
  242. local nServerKey = tGetData.nServerKey
  243. local nBegin = tGetData.nBegin
  244. local nEnd = tGetData.nEnd
  245. local tRankData = tGetData.tRankData
  246. print("[CommercerActRank_GetRankInfo] nRankType = "..nRankType.." nRankSubType = "..nRankSubType.." nServerKey = "..nServerKey
  247. .." nBegin = "..nBegin.." nEnd = "..nEnd)
  248. CommercerActRank_CreateCache(nRankType, nRankSubType, nServerKey)
  249. if COMMERCE_RANK_SERVER_KEY == nil then
  250. print("[CommercerActRank_GetRankInfo] 设置 nServerKey = "..nServerKey)
  251. COMMERCE_RANK_SERVER_KEY = nServerKey
  252. else
  253. if COMMERCE_RANK_SERVER_KEY ~= nServerKey then
  254. print("[CommercerActRank_GetRankInfo] 一个战区的 nServerKey 为什么会改变")
  255. COMMERCE_RANK_SERVER_KEY = nServerKey
  256. end
  257. end
  258. if nBegin == 1 then
  259. CommercerActRank_ClearCache(nRankType, nRankSubType, nServerKey)
  260. end
  261. local nAllLen = tRankData[0]
  262. if 0 < nAllLen then
  263. print("[CommercerActRank_GetRankInfo] 获取到排行榜数据,进行插入")
  264. for i = 1, nAllLen, 1 do
  265. CommercerActRank_InsertRank(nRankType, nRankSubType, nServerKey, tRankData[i].nRank, tRankData[i].tRankData)
  266. end
  267. end
  268. end
  269. -- 获取到排名信息
  270. function CommercerActRank_GetServerRank(tData)
  271. COMMERCE_RANK_SERVER_RANK = tData.nRank
  272. if tData.nOperate == ServerCommerceDefine.COMMERCEACT_SENDSERVERMAIL then
  273. CommercerActRank_SendServerRankPrize(tData)
  274. else
  275. CommercerActRank_SendServerMail2Human()
  276. end
  277. end
  278. -- 发送服务器排行榜奖励
  279. function CommercerActRank_SendServerRankPrize(tData)
  280. local nRank = tData.nRank
  281. local tPrize = nil
  282. for _, v in ipairs(ServerCommerceRankConf) do
  283. if v.nRankType == CommonDefine.COMMONRANK_SUB_TYPE_SERVERCOMMERCE_SERVER then
  284. if v.nOrder[1] <= nRank and v.nOrder[2] >= nRank then
  285. tPrize = v.Prize
  286. break
  287. end
  288. end
  289. end
  290. local szLogText = "[CommercerActRank_SendServerRankPrize] 发送服务器奖励 nRank = "..nRank
  291. if not tPrize then
  292. szLogText = szLogText .. "获取不到对应奖励"
  293. ServerCommerceManager.CommerveManager_WriteLog(szLogText)
  294. return
  295. end
  296. local nSendMail = ServerCommerceManager.CommerveManager_GetCommDBSendMail()
  297. if true == nSendMail then
  298. return
  299. end
  300. -- 设置当前发送邮件奖励
  301. ServerCommerceManager.CommerveManager_SetCommDBSendMail(true)
  302. -- 遍历在线玩家
  303. local mailConfig = MailExcel.mail[ServerCommerceDefine.COMMERCEACT_SERVERMAILID]
  304. local title = mailConfig.title
  305. local senderName = mailConfig.senderName
  306. local content = mailConfig.content
  307. for uuid, human in pairs(ObjHuman.onlineUuid) do
  308. MailManager.add(MailManager.SYSTEM, uuid,
  309. title, Util.format(content, nRank), tPrize, senderName)
  310. -- 设置该玩家已经发送邮件
  311. ServerCommerceManager.CommerveManager_SetHumanSendServerMail(human, true)
  312. -- 记录信息
  313. ServerCommerceManager.CommerveManager_WriteLog(szLogText, human)
  314. end
  315. -- 告诉中心服全服邮件在线的处理完成
  316. ServerCommerceMiddle.CommerceMiddle_TellServerMailOk()
  317. print("[CommercerActRank_SendServerRankPrize] 全服在线玩家邮件处理完成")
  318. end
  319. -- 发送玩家邮件奖励
  320. function CommercerActRank_SendHumanRankPrize(tData)
  321. local nRank, uuid = tData.nRank, tData.uuid
  322. local tPrize = nil
  323. for _, v in ipairs(ServerCommerceRankConf) do
  324. if v.nRankType == CommonDefine.COMMONRANK_SUB_TYPE_SERVERCOMMERCE_HUMAN then
  325. if v.nOrder[1] <= nRank and v.nOrder[2] >= nRank then
  326. tPrize = v.Prize
  327. break
  328. end
  329. end
  330. end
  331. local szLogText = "[CommercerActRank_SendHumanRankPrize] 发送个人奖励 nRank = "..nRank
  332. if not tPrize then
  333. szLogText = szLogText .. "获取不到对应奖励"
  334. ServerCommerceManager.CommerveManager_WriteLog(szLogText)
  335. return
  336. end
  337. local human = ObjHuman.onlineUuid[uuid]
  338. local bNowSave = false
  339. if not human then
  340. human = {}
  341. human.db = RoleDBLogic.getDb(uuid)
  342. bNowSave = true
  343. end
  344. if not human then
  345. szLogText = szLogText.." 获取不到玩家DB数据信息 uuid = "..uuid
  346. ServerCommerceManager.CommerveManager_WriteLog(szLogText)
  347. return
  348. end
  349. table.print_lua_table(human.db.ServerCommerce)
  350. print("[CommercerActRank_SendHumanRankPrize] 下发玩家奖励 name = "..human.db.name)
  351. local bSendMail = ServerCommerceManager.CommerveManager_GetHumanSendPlayerMail(human)
  352. if true == bSendMail then
  353. szLogText = szLogText .. "已经发送了邮件为什么又一次走到这里 name = "..human.db.name
  354. ServerCommerceManager.CommerveManager_WriteLog(szLogText)
  355. print(szLogText)
  356. return
  357. end
  358. -- 设置发送了邮件奖励
  359. ServerCommerceManager.CommerveManager_SetHumanSendPlayerMail(human, true)
  360. -- 发奖励
  361. local mailConfig = MailExcel.mail[ServerCommerceDefine.COMMERCEACT_HUMANMAILID]
  362. local title = mailConfig.title
  363. local senderName = mailConfig.senderName
  364. local content = mailConfig.content
  365. MailManager.add(MailManager.SYSTEM, uuid,
  366. title, Util.format(content, nRank), tPrize, senderName)
  367. -- 写日志
  368. szLogText = szLogText.."发送奖励成功"
  369. ServerCommerceManager.CommerveManager_WriteLog(szLogText, human)
  370. print("[CommercerActRank_SendHumanRankPrize] 发送玩家奖励结束 name = "..human.db.name.." nRank = "..nRank)
  371. if true == bNowSave then
  372. print("[CommercerActRank_SendHumanRankPrize] 发送玩家奖励结束, 玩家不在线进行存库 name = "..human.db.name.." nRank = "..nRank)
  373. RoleDBLogic.saveRole(human.db)
  374. end
  375. end
  376. -- 玩家登录发送玩家邮件奖励(全服邮件奖励)
  377. function CommercerActRank_SendServerMailHumanLogin(human)
  378. if not COMMRCE_RANK_SERVERMAIL_HUMAN then
  379. COMMRCE_RANK_SERVERMAIL_HUMAN = {}
  380. end
  381. table.insert(COMMRCE_RANK_SERVERMAIL_HUMAN, human.db._id)
  382. -- 不存在请求一次排名
  383. if not COMMERCE_RANK_SERVER_RANK then
  384. ServerCommerceMiddle.CommerceMiddle_QueryServerRank(ServerCommerceDefine.COMMERCEACT_GETSERVERRANK)
  385. else
  386. CommercerActRank_SendServerMail2Human()
  387. end
  388. end
  389. -- 发送活动结束后登录的的玩家(全服邮件奖励)
  390. function CommercerActRank_SendServerMail2Human()
  391. if not COMMRCE_RANK_SERVERMAIL_HUMAN or not COMMERCE_RANK_SERVER_RANK then
  392. return
  393. end
  394. local tPrize = nil
  395. for _, v in ipairs(ServerCommerceRankConf) do
  396. if v.nRankType == CommonDefine.COMMONRANK_SUB_TYPE_SERVERCOMMERCE_SERVER then
  397. if v.nOrder[1] <= COMMERCE_RANK_SERVER_RANK and v.nOrder[2] >= COMMERCE_RANK_SERVER_RANK then
  398. tPrize = v.Prize
  399. break
  400. end
  401. end
  402. end
  403. if not tPrize then
  404. return
  405. end
  406. local mailConfig = MailExcel.mail[ServerCommerceDefine.COMMERCEACT_SERVERMAILID]
  407. local title = mailConfig.title
  408. local senderName = mailConfig.senderName
  409. local content = mailConfig.content
  410. for _, uuid in ipairs(COMMRCE_RANK_SERVERMAIL_HUMAN) do
  411. -- 设置该玩家已经发送邮件
  412. local human = ObjHuman.onlineUuid[uuid]
  413. if not human then
  414. human = RoleDBLogic.getDb(uuid)
  415. end
  416. if human then
  417. MailManager.add(MailManager.SYSTEM, uuid,
  418. title, Util.format(content, COMMERCE_RANK_SERVER_RANK), tPrize, senderName)
  419. -- 记录信息
  420. ServerCommerceManager.CommerveManager_WriteLog("[CommercerActRank_SendServerMail2Human] 玩家登录发送全服奖励邮件完成", human)
  421. end
  422. end
  423. COMMRCE_RANK_SERVERMAIL_HUMAN = nil
  424. end
  425. -- 玩家登录活动结束发送个人排行榜邮件
  426. function CommercerActRank_SendHumanMailHumanLogin(human)
  427. local tPrize, nRank = nil, 0
  428. for _, v in ipairs(ServerCommerceRankConf) do
  429. if v.nRankType == CommonDefine.COMMONRANK_SUB_TYPE_SERVERCOMMERCE_HUMAN then
  430. if v.nOrder[1] >= nRank then
  431. tPrize = v.Prize
  432. nRank = v.nOrder[1]
  433. end
  434. end
  435. end
  436. local mailConfig = MailExcel.mail[ServerCommerceDefine.COMMERCEACT_HUMANMAILID]
  437. local title = mailConfig.title
  438. local senderName = mailConfig.senderName
  439. local content = mailConfig.content
  440. local newcontent = string.gsub(content, "{1}", "21+")
  441. MailManager.add(MailManager.SYSTEM, human.db_id,
  442. title, newcontent, tPrize, senderName)
  443. -- 写日志
  444. ServerCommerceManager.CommerveManager_WriteLog("[CommercerActRank_SendHumanMailHumanLogin] 玩家登录发送邮件完成", human)
  445. end
  446. function CommercerActRank_GetRankServerKey(nServerKey)
  447. COMMERCE_RANK_SERVER_KEY = nServerKey
  448. print("[CommercerActRank_GetRankServerKey] 当前服务器收到战区Key nServerID = "..Config.SVR_INDEX.." nServerKey = "..COMMERCE_RANK_SERVER_KEY)
  449. end
  450. ----------------------------------------- 客户端请求 -------------------------------------
  451. -- 客户端请求
  452. function CommercerActRank_Query(human, nRankSubType)
  453. local msgRet = Msg.gc.GC_SERVEERCOMMERCE_ACT_RANK_QUERY
  454. local maxSendRank = CommonDefine.COMMONRANK_SENDPRIZE_LEN
  455. if CommonDefine.COMMONRANK_SUB_TYPE_SERVERCOMMERCE_SERVER == nRankSubType then
  456. maxSendRank = ServerCommerceDefine.COMMERCEACT_SERVER_RANKLEN
  457. end
  458. local uuid = human.db._id
  459. if CommonDefine.COMMONRANK_SUB_TYPE_SERVERCOMMERCE_SERVER == nRankSubType then
  460. uuid = tostring(Config.NEW_SVR_INDEX)
  461. end
  462. -- print("[CommercerActRank_Query] uuid = "..uuid)
  463. if false == CommercerActRank_CheckCache(CommonDefine.COMMONRANK_TYPE_SERVERCOMMERCE, nRankSubType, COMMERCE_RANK_SERVER_KEY) then
  464. CommercerActRank_CreateCache(CommonDefine.COMMONRANK_TYPE_SERVERCOMMERCE, nRankSubType, COMMERCE_RANK_SERVER_KEY)
  465. end
  466. CommercerActRank_WrapOwnerData(CommonDefine.COMMONRANK_TYPE_SERVERCOMMERCE, nRankSubType, msgRet.ownerData, uuid)
  467. if 0 == msgRet.ownerData.rankValue then
  468. if CommonDefine.COMMONRANK_SUB_TYPE_SERVERCOMMERCE_SERVER == nRankSubType then
  469. msgRet.ownerData.rankValue = CommonDB.GetCommerceActInfo_Point()
  470. else
  471. msgRet.ownerData.rankValue = ServerCommerceManager.CommerceAct_GetHumanPoint(human)
  472. end
  473. end
  474. print("[CommercerActRank_Query] 玩家的rank = "..msgRet.ownerData.rank)
  475. for rank = 1, maxSendRank do
  476. CommercerActRank_WrapRankList(CommonDefine.COMMONRANK_TYPE_SERVERCOMMERCE, nRankSubType, msgRet.list[rank], rank)
  477. print("[CommercerActRank_Query] 遍历的rank = "..rank.." 下发的 "..msgRet.list[rank].rank)
  478. end
  479. msgRet.list[0] = maxSendRank
  480. Msg.send(msgRet, human.fd)
  481. end