ServerCommerceActRank.lua 20 KB

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