ServerCommerceMiddle.lua 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. local Util = require("common.Util")
  2. local WarZoneConf = require("excel.WarZone")
  3. local MiddleConnect = require("middle.MiddleConnect")
  4. local MiddleManager = require("middle.MiddleManager")
  5. local InnerMsg = require("core.InnerMsg")
  6. local Config = require("Config")
  7. local CommonDB = require("common.CommonDB")
  8. local Timer = require("core.Timer")
  9. local CommonDefine = require("common.CommonDefine")
  10. local ServerCommerceManger = require("serverCommerce.ServerCommerceManager")
  11. local ServerCommerceActDefine = require("serverCommerce.ServerCommerceActDefine")
  12. local ServerCommerceRank = require("serverCommerce.ServerCommerceActRank")
  13. local Log = require("common.Log")
  14. local ServerCommerceActBattleGroundCS = require("serverCommerce.ServerCommerceActBattleGroundCS")
  15. -- 缓存开服天数
  16. local tServerOpenDay = nil
  17. local SERVERCOMMERCEOPENDAY = 8 -- 活动开启要求天数
  18. -- 缓存已经回复的开服天数的服务器
  19. local tServerOKDay = nil
  20. local function CommerceMiddle_WriteLog(szLogText)
  21. Log.write(Log.LOGID_OSS_COMMON_ACT, szLogText)
  22. end
  23. -- 检查是否进入下一轮
  24. local function CommerceMiddle_CheckGoNextBatch(nServerKey)
  25. if _G.is_middle ~= true then
  26. return false
  27. end
  28. local tDBData = CommonDB.GetCommerceMiddleAct_ByKey(nServerKey)
  29. if not tDBData then
  30. return true
  31. end
  32. -- 已经是第三轮了
  33. if tDBData.nBatchID >= 3 then
  34. return false
  35. end
  36. local nNowTime = os.time()
  37. if nNowTime < tDBData.nEndTime then
  38. return false
  39. end
  40. local nDiffDay = Util.diffDay(tDBData.nEndTime)
  41. if nDiffDay > ServerCommerceActDefine.COMMERCEACT_NEXTDAY then
  42. print("[CommerceMiddle_CheckGoNextBatch] 间隔天数已经满足条件 nDiffDay = "..nDiffDay)
  43. return true
  44. end
  45. return false
  46. end
  47. local function CommerceMiddle_CreateActTime()
  48. local nNowTime = os.time()
  49. local nEndTime = nNowTime + (ServerCommerceActDefine.COMMERCEACT_LASTDAY - 1)* 86400
  50. local tEndDate = os.date("*t",nEndTime)
  51. tEndDate.hour = ServerCommerceActDefine.COMMERCEACT_ENDTIME
  52. tEndDate.min = 0
  53. tEndDate.sec = 0
  54. nEndTime = os.time(tEndDate)
  55. return nNowTime, nEndTime
  56. end
  57. -- 更新下一轮DB数据
  58. local function CommerceMiddle_CreateNextBatchDB(nServerKey)
  59. local tOldDBData = CommonDB.GetCommerceMiddleAct_ByKey(nServerKey)
  60. if not tOldDBData then
  61. CommerceMiddle_WriteLog("[CommerceMiddle_CreateNextBatchDB] 更新下一轮中心服活动时间数据, 但是不存在久的数据 nServerKey = "..nServerKey)
  62. end
  63. local nBeginTime, nEndTime = CommerceMiddle_CreateActTime()
  64. local nBatchID = 1
  65. if tOldDBData and tOldDBData.nBatchID then
  66. nBatchID = tOldDBData.nBatchID + 1
  67. end
  68. local tDBData =
  69. {
  70. nBatchID = nBatchID,
  71. nBeginTime = nBeginTime,
  72. nEndTime = nEndTime
  73. }
  74. local szText = "[CommerceMiddle_CreateNewDB] 更新下一轮的DB数据 nServerKey = "..nServerKey.." nBatchID = "..tDBData.nBatchID
  75. .." nBeginTime = "..tDBData.nBeginTime.." nEndTime = "..tDBData.nEndTime
  76. CommerceMiddle_WriteLog(szText)
  77. CommonDB.SetCommerceMiddleAct_ByKey(nServerKey, tDBData)
  78. end
  79. -- 创建新的DB数据
  80. local function CommerceMiddle_CreateNewDB(nServerKey)
  81. local tOldData = CommonDB.GetCommerceMiddleAct_ByKey(nServerKey)
  82. if tOldData then
  83. local bRet = CommerceMiddle_CheckGoNextBatch(nServerKey)
  84. if false == bRet then
  85. return
  86. else
  87. CommerceMiddle_WriteLog("[CommerceMiddle_CreateNewDB] 该服务器满足生成下一轮条件, 生成中心服时间数据 nServerKey = "..nServerKey)
  88. CommerceMiddle_CreateNextBatchDB(nServerKey)
  89. return
  90. end
  91. end
  92. local nBeginTime, nEndTime = CommerceMiddle_CreateActTime()
  93. local tDBData =
  94. {
  95. nBatchID = 1,
  96. nBeginTime = nBeginTime,
  97. nEndTime = nEndTime
  98. }
  99. local szText = "[CommerceMiddle_CreateNewDB] 生成新的DB数据 nServerKey = "..nServerKey.." nBatchID = "..tDBData.nBatchID
  100. .." nBeginTime = "..tDBData.nBeginTime.." nEndTime = "..tDBData.nEndTime
  101. CommerceMiddle_WriteLog(szText)
  102. CommonDB.SetCommerceMiddleAct_ByKey(nServerKey, tDBData)
  103. end
  104. local function CommerceMiddle_Refresh(nServerKey)
  105. if _G.is_middle ~= true or not tServerOpenDay then
  106. return
  107. end
  108. local nOpenDay = tServerOpenDay[nServerKey]
  109. if nOpenDay < 8 then
  110. print("[CommerceMiddle_Refresh] 当前开服时间不足直接返回")
  111. return
  112. elseif nOpenDay == 8 then
  113. CommerceMiddle_WriteLog("[CommerceMiddle_Refresh] 该服务器时间到达8天, 生成中心服时间数据 nServerKey = "..nServerKey)
  114. CommerceMiddle_CreateNewDB(nServerKey)
  115. else
  116. if true == CommerceMiddle_CheckGoNextBatch(nServerKey) then
  117. CommerceMiddle_WriteLog("[CommerceMiddle_Refresh] 该服务器满足生成下一轮条件, 生成中心服时间数据 nServerKey = "..nServerKey)
  118. CommerceMiddle_CreateNextBatchDB(nServerKey)
  119. else
  120. print("[CommerceMiddle_Refresh] 当前不满足条件不生成下一轮")
  121. end
  122. end
  123. end
  124. -- 发送活动开始时间
  125. local function CommerceMiddle_SendOpenTime(nServerID)
  126. local fd = MiddleManager.getFDBySvrIndex(nServerID)
  127. if not fd then
  128. print("[CommerceMiddle_SendOpenTime] 获取不到对应的fd nServerID = "..nServerID)
  129. return
  130. end
  131. local nServerConfID = MiddleConnect.MiddleConnect_TrueServerID2ConfServerID(nServerID)
  132. local nServerKey = MiddleConnect.MiddleConnect_GetWarZoneServer(nServerConfID)
  133. local tDBData = CommonDB.GetCommerceMiddleAct_ByKey(nServerKey)
  134. if not tDBData then
  135. CommerceMiddle_WriteLog("[CommerceMiddle_SendOpenTime] 不存在对应的中心服DB数据 nServerKey = "..nServerKey)
  136. return
  137. end
  138. local tMsgData = InnerMsg.wl.WL_COMMERCE_ACT_GET_OPENTIME
  139. tMsgData.nBatchID = tDBData.nBatchID
  140. tMsgData.nBeginTime = tDBData.nBeginTime
  141. tMsgData.nEndTime = tDBData.nEndTime
  142. InnerMsg.sendMsg(fd, tMsgData)
  143. end
  144. -- 起服获取信息
  145. function CommerceMiddle_InitServer()
  146. if _G.is_middle ~= true then
  147. return
  148. end
  149. Timer.addLater(ServerCommerceActDefine.COMMERCEACT_INITOPENDAY, CommerceMiddle_GetOpen)
  150. print("[CommerceMiddle_InitServer] 起服定时去获取数据 nTime = "..ServerCommerceActDefine.COMMERCEACT_INITOPENDAY)
  151. end
  152. -- 定时获取普通服开服信息
  153. function CommerceMiddle_OnZero()
  154. if _G.is_middle ~= true then
  155. return
  156. end
  157. ServerCommerceActBattleGroundCS.onZero()
  158. Timer.addLater(15, CommerceMiddle_GetOpen)
  159. print("[CommerceMiddle_OnZero] 整点定时去获取数据")
  160. end
  161. -- 获取(中心服主动去获取)
  162. function CommerceMiddle_GetOpen()
  163. if _G.is_middle ~= true then
  164. return
  165. end
  166. tServerOKDay = {}
  167. print("[CommerceMiddle_GetOpen] 开始去获取服务器开启信息")
  168. local tWarZoneConf = WarZoneConf.group
  169. for _, v in ipairs(tWarZoneConf) do
  170. local nFirstServerID = MiddleConnect.MiddleConnect_ConfServerID2TrueServerID(v.nMinServerID)
  171. print("[CommerceMiddle_GetOpen] nMinServerID = "..v.nMinServerID.." nFirstServerID = "..nFirstServerID)
  172. local fd = MiddleManager.getFDBySvrIndex(nFirstServerID)
  173. if fd then
  174. tServerOKDay[nFirstServerID] = 0
  175. print("[CommerceMiddle_GetOpen] 中心服主动去获取数据 nFirstServerID = "..nFirstServerID)
  176. local tMsgData = InnerMsg.wl.WL_COMMERCE_QUERYOPENDAY
  177. InnerMsg.sendMsg(fd, tMsgData)
  178. print("[CommerceMiddle_GetOpen] 发送结束")
  179. else
  180. print("[CommerceMiddle_GetOpen] 中心服主动去获取数据, 但是获取不到fd nFirstServerID = "..nFirstServerID)
  181. end
  182. end
  183. end
  184. -- 回复开服天数
  185. function CommerceMiddle_SendOpenDay(fd, msg)
  186. local nOpenDay = msg.nOpenDay
  187. local nServerConfID = MiddleConnect.MiddleConnect_TrueServerID2ConfServerID(msg.nSrcServerID)
  188. if not tServerOpenDay then
  189. tServerOpenDay = {}
  190. end
  191. if not tServerOKDay then
  192. print("[CommerceMiddle_SendOpenDay] 没有正确的对 tServerOKDay 进行初始化")
  193. tServerOKDay = {}
  194. end
  195. tServerOpenDay[nServerConfID] = nOpenDay
  196. print("[CommerceMiddle_SendOpenDay] 回复开服天数 nServerConfID = "..nServerConfID.." nOpenDay = "..nOpenDay)
  197. tServerOKDay[msg.nSrcServerID] = 1
  198. local bOK = true
  199. for _, v in pairs(tServerOKDay) do
  200. if 0 == v then
  201. bOK = false
  202. end
  203. end
  204. if true == bOK then
  205. CommerMiddle_CheckMiddleInfo()
  206. end
  207. end
  208. -- 请求开服天数
  209. function CommerceMiddle_QueryOpenDay(fd, msg)
  210. local tMsgData = InnerMsg.lw.LW_COMMERCE_SENDOPENDAY
  211. tMsgData.nOpenDay = CommonDB.getServerOpenDay()
  212. tMsgData.nSrcServerID = Config.SVR_INDEX
  213. InnerMsg.sendMsg(0, tMsgData)
  214. print("[CommerceMiddle_QueryOpenDay] 请求开服天数")
  215. end
  216. function CommerceMiddle_QueryOpenAct(fd, msg)
  217. local nConfServerID = MiddleConnect.MiddleConnect_TrueServerID2ConfServerID(msg.nSrcServerID)
  218. local nFirstServerID
  219. for _, v in ipairs(WarZoneConf.group) do
  220. if v.nMinServerID <= nConfServerID and v.nMaxServerID >= nConfServerID then
  221. nFirstServerID = v.nMinServerID
  222. break
  223. end
  224. end
  225. if nil == nFirstServerID or not tServerOpenDay or not tServerOpenDay[nFirstServerID] then
  226. print("[QueryOpenAct] 获取不到战区的第一个服务器\n")
  227. return
  228. end
  229. local nSrcFD = MiddleManager.getFDBySvrIndex(msg.nSrcServerID)
  230. if not nSrcFD then
  231. return
  232. end
  233. local tMsgData = InnerMsg.wl.WL_COMMERCE_ACTOPEN
  234. tMsgData.nOpen = tServerOpenDay[nFirstServerID] >= SERVERCOMMERCEOPENDAY and 1 or 0
  235. tMsgData.nOperate = msg.nOperate
  236. tMsgData.nServerKey = nFirstServerID
  237. InnerMsg.sendMsg(nSrcFD, tMsgData)
  238. print("[CommerceMiddle_QueryOpenAct] 请求中心服活动是否开启 nOpen = "..tMsgData.nOpen)
  239. end
  240. function CommerceMiddle_SendOpenAct(fd, msg)
  241. print("[CommerceMiddle_SendOpenAct] 获取到中心服发送的是否开服数据 nOpen = "..msg.nOpen)
  242. ServerCommerceManger.CommerceAct_ActCheckOpen(msg.nOpen, msg.nOperate, msg.nServerKey)
  243. end
  244. -- 发送玩家排行榜信息
  245. function CommerveMiddle_HumanPointChange(human, nPoint)
  246. local tMsgData = InnerMsg.lw.LW_COMMERCE_RANK_POINT_CHANGE
  247. tMsgData.uuid = human.db._id
  248. tMsgData.name = human.db.name
  249. tMsgData.head = human.db.head
  250. tMsgData.headFrame = human.db.headFrame
  251. tMsgData.nSrcServerID = Config.SVR_INDEX
  252. tMsgData.nValue = nPoint
  253. tMsgData.nRankType = CommonDefine.COMMONRANK_TYPE_SERVERCOMMERCE
  254. tMsgData.nRankSubType = CommonDefine.COMMONRANK_SUB_TYPE_SERVERCOMMERCE_HUMAN
  255. tMsgData.nOperate = CommonDefine.COMMONRANK_VALUE_REPLACE
  256. tMsgData.servername = Config.NEW_SVR_INDEX.."区"
  257. InnerMsg.sendMsg(0, tMsgData)
  258. print("[CommerveMiddle_HumanPointChange] 发送玩家排行榜信息结束 name = "..tMsgData.name.." nValue = "..tMsgData.nValue)
  259. end
  260. -- 服务器点数改变发送排行榜信息
  261. function CommerveMiddle_ServerPointChange(nPoint)
  262. local tMsgData = InnerMsg.lw.LW_COMMERCE_RANK_POINT_CHANGE
  263. tMsgData.uuid = Config.NEW_SVR_INDEX
  264. tMsgData.name = Config.NEW_SVR_INDEX.."区"
  265. tMsgData.head = -1
  266. tMsgData.headFrame = -1
  267. tMsgData.nSrcServerID = Config.SVR_INDEX
  268. tMsgData.nValue = nPoint
  269. tMsgData.nRankType = CommonDefine.COMMONRANK_TYPE_SERVERCOMMERCE
  270. tMsgData.nRankSubType = CommonDefine.COMMONRANK_SUB_TYPE_SERVERCOMMERCE_SERVER
  271. tMsgData.nOperate = CommonDefine.COMMONRANK_VALUE_REPLACE
  272. tMsgData.servername = Config.NEW_SVR_INDEX.."区"
  273. InnerMsg.sendMsg(0, tMsgData)
  274. print("[CommerveMiddle_HumanPointChange] 发送服务器排行榜信息结束 name = "..tMsgData.name.." nValue = "..tMsgData.nValue)
  275. end
  276. -- 请求排行榜数据
  277. function CommerveMiddle_QueryRankInfo(nRankType, nRankSubType)
  278. local tMsgData = InnerMsg.lw.LW_COMMERCE_QUERY_RANK_INFO
  279. tMsgData.nRankType = nRankType
  280. tMsgData.nRankSubType = nRankSubType
  281. tMsgData.nSrcServerID = Config.SVR_INDEX
  282. InnerMsg.sendMsg(0, tMsgData)
  283. print("[CommerveMiddle_QueryRankInfo] 向中心服请求排行榜数据")
  284. end
  285. -- 获取到排行榜数据
  286. function CommerveMiddle_GetRankInfo(tData)
  287. ServerCommerceRank.CommercerActRank_GetRankInfo(tData)
  288. end
  289. -- 检测是否存在中心服数据
  290. function CommerMiddle_CheckMiddleInfo()
  291. if _G.is_middle ~= true then
  292. return
  293. end
  294. for nServerID, v in pairs(tServerOKDay) do
  295. local nServerConfID = MiddleConnect.MiddleConnect_TrueServerID2ConfServerID(nServerID)
  296. local nServerKey = MiddleConnect.MiddleConnect_GetWarZoneServer(nServerConfID)
  297. print("[CommerMiddle_CheckMiddleInfo] 进行判断中心服是否存在数据 nServerKey = "..nServerKey.." nServerID = "..nServerID)
  298. local tDBData = CommonDB.GetCommerceMiddleAct_ByKey(nServerKey)
  299. local nOpenDay = tServerOpenDay[nServerConfID]
  300. -- 不存在去拿数据
  301. if nil == tDBData then
  302. --if nOpenDay >= 8 then
  303. local fd = MiddleManager.getFDBySvrIndex(nServerID)
  304. if fd then
  305. local tMsgData = InnerMsg.wl.WL_COMMERCE_GET_ACT_INFO
  306. tMsgData.nReqServerID = 0
  307. InnerMsg.sendMsg(fd, tMsgData)
  308. print("[CommerMiddle_CheckMiddleInfo] 发送数据完成")
  309. else
  310. print("[CommerMiddle_CheckMiddleInfo] 获取不到FD nServerID = "..nServerID)
  311. end
  312. --end
  313. else
  314. print("[CommerMiddle_CheckMiddleInfo] 存在数据, 判断是否刷新 nServerID = "..nServerID.." nServerKey = "..nServerKey
  315. .." nBatchID = "..tDBData.nBatchID.." nBeginTime = "..tDBData.nBeginTime.." nEndTime = "..tDBData.nEndTime)
  316. CommerceMiddle_Refresh(nServerKey)
  317. end
  318. end
  319. end
  320. -- 中心服请求活动时间相关数据
  321. function CommerceMiddle_GetActInfo_WL(msg)
  322. print("[CommerceMiddle_GetActInfo] 收到中心服请求")
  323. local tDBData = CommonDB.GetCommerceActInfo()
  324. local tMsgData = InnerMsg.lw.LW_COMMERCE_GET_ACT_INFO
  325. -- table.print_lua_table(tDBData)
  326. tMsgData.nReqServerID = msg.nReqServerID
  327. tMsgData.nSrcServerID = Config.SVR_INDEX
  328. tMsgData.nOperate = 0
  329. tMsgData.nBatchID = 0
  330. tMsgData.nBeginTime = 0
  331. tMsgData.nEndTime = 0
  332. if not tDBData or nil == _G.next(tDBData) then
  333. tMsgData.nOperate = 2
  334. else
  335. tMsgData.nOperate = 1
  336. tMsgData.nBatchID = tDBData.nBatchID
  337. tMsgData.nBeginTime = tDBData.nBeginTime
  338. tMsgData.nEndTime = tDBData.nEndTime
  339. end
  340. InnerMsg.sendMsg(0, tMsgData)
  341. end
  342. -- 中心服收到活动相关数据
  343. function CommerceMiddle_GetActInfo_LW(msg)
  344. if msg.nOperate == 0 then
  345. print("[CommerceMiddle_GetActInfo_LW] 不存在对应的数据")
  346. end
  347. local nReqServerID = msg.nReqServerID
  348. local nServerConfID = MiddleConnect.MiddleConnect_TrueServerID2ConfServerID(msg.nSrcServerID)
  349. local nServerKey = MiddleConnect.MiddleConnect_GetWarZoneServer(nServerConfID)
  350. print("[CommerceMiddle_GetActInfo_LW] 中心服收到回包 nReqServerID = "..nReqServerID.." nServerConfID = "..nServerConfID)
  351. -- table.print_lua_table(msg)
  352. local tDBData = {
  353. nBatchID = 0,
  354. nBeginTime = 0,
  355. nEndTime = 0
  356. }
  357. local tOldDBData = CommonDB.GetCommerceMiddleAct_ByKey(nServerKey)
  358. if tOldDBData then
  359. print("[CommerceMiddle_GetActInfo_LW] 存在db数据")
  360. -- table.print_lua_table(tOldDBData)
  361. end
  362. -- 不存在对应的数据
  363. if msg.nOperate == 2 then
  364. print("[CommerceMiddle_GetActInfo_LW] 当前上报的服务器没有对应的数据, 活动未开始")
  365. CommerceMiddle_Refresh(nServerKey)
  366. elseif msg.nOperate == 1 then
  367. if nil == tOldDBData then
  368. tDBData.nBatchID = msg.nBatchID
  369. tDBData.nBeginTime = msg.nBeginTime
  370. tDBData.nEndTime = msg.nEndTime
  371. print("[CommerceMiddle_GetActInfo_LW] 当前不存在数据, 进行了设置 nServerKey = "..nServerKey)
  372. CommonDB.SetCommerceMiddleAct_ByKey(nServerKey, tDBData)
  373. end
  374. tOldDBData = CommonDB.GetCommerceMiddleAct_ByKey(nServerKey)
  375. if tOldDBData then
  376. print("[CommerceMiddle_GetActInfo_LW] 设置后的数据打印")
  377. -- table.print_lua_table(tOldDBData)
  378. end
  379. CommerceMiddle_Refresh(nServerKey)
  380. end
  381. print("[CommerceMiddle_GetActInfo_LW] 1111111")
  382. -- table.print_lua_table(tDBData)
  383. if 0 ~= nReqServerID then
  384. print("[CommerceMiddle_GetActInfo_LW] 当前有服务器请求数据 nReqServerID = "..nReqServerID)
  385. CommerceMiddle_SendOpenTime(nReqServerID)
  386. end
  387. end
  388. -- 普通服请求活动时间
  389. function CommerceMiddle_GetActOpenTime_LW(msg)
  390. if _G.is_middle ~= true then return end
  391. local nServerConfID = MiddleConnect.MiddleConnect_TrueServerID2ConfServerID(msg.nSrcServerID)
  392. local nServerKey = MiddleConnect.MiddleConnect_GetWarZoneServer(nServerConfID)
  393. local tDBData = CommonDB.GetCommerceMiddleAct_ByKey(nServerKey)
  394. if nil == tDBData then
  395. local nFirstServerID = MiddleConnect.MiddleConnect_ConfServerID2TrueServerID(nServerKey)
  396. local fd = MiddleManager.getFDBySvrIndex(nFirstServerID)
  397. if fd then
  398. local tMsgData = InnerMsg.wl.WL_COMMERCE_GET_ACT_INFO
  399. tMsgData.nReqServerID = msg.nSrcServerID
  400. InnerMsg.sendMsg(fd, tMsgData)
  401. else
  402. print("[CommerceMiddle_GetActOpenTime_LW] 不存在对应的fd 数据 nFirstServerID = "..nFirstServerID)
  403. end
  404. else
  405. CommerceMiddle_Refresh(nServerKey)
  406. CommerceMiddle_SendOpenTime(msg.nSrcServerID)
  407. end
  408. end
  409. function CommerceMiddle_GetActOpenTime_WL(msg)
  410. ServerCommerceManger.CommerceAct_GetActTime(msg)
  411. end
  412. ------------------ 活动管理器操作 ------------------------
  413. -- 请求活动是否开启
  414. function CommerceMiddle_IsActOpen(nOperate)
  415. local tMsgData = InnerMsg.lw.LW_COMMERCE_ACTOPEN
  416. tMsgData.nSrcServerID = Config.SVR_INDEX
  417. tMsgData.nOperate = nOperate
  418. InnerMsg.sendMsg(0, tMsgData)
  419. print("[CommerceMiddle_IsActOpen] 普通服开始请求活动信息")
  420. end
  421. -- 请求当前服务器排行最新的排名
  422. function CommerceMiddle_QueryServerRank(nOperate)
  423. local tMsgData = InnerMsg.lw.LW_COMMERCE_QUERY_SERVER_RANK
  424. tMsgData.nSrcServerID = Config.SVR_INDEX
  425. tMsgData.nServerUuid = tostring(Config.NEW_SVR_INDEX)
  426. tMsgData.nOperate = nOperate
  427. InnerMsg.sendMsg(0, tMsgData)
  428. end
  429. -- 获取到 当前服务器排行最新的排名
  430. function CommerceMiddle_GetServerRank(msg)
  431. ServerCommerceRank.CommercerActRank_GetServerRank(msg)
  432. end
  433. -- 通知中心服当前服务器在线全服玩家邮件结束
  434. function CommerceMiddle_TellServerMailOk()
  435. local tMsgData = InnerMsg.lw.LW_COMMERCE_TELL_SERVER_MAILOK
  436. tMsgData.nSrcServerID = Config.SVR_INDEX
  437. InnerMsg.sendMsg(0, tMsgData)
  438. print("[CommerceMiddle_TellServerMailOk] 通知中心服当前服务器在线全服玩家邮件结束")
  439. end
  440. function CommerceMiddle_GetHumanRank(msg)
  441. ServerCommerceRank.CommercerActRank_SendHumanRankPrize(msg)
  442. end
  443. function CommerceMiddle_ClearRank()
  444. local tMsgData = InnerMsg.lw.LW_COMMERCE_CLEAR_RANK
  445. tMsgData.nRankType = CommonDefine.COMMONRANK_TYPE_SERVERCOMMERCE
  446. tMsgData.nRankSubType = CommonDefine.COMMONRANK_SUB_TYPE_SERVERCOMMERCE_SERVER
  447. tMsgData.nSrcServerID = Config.SVR_INDEX
  448. InnerMsg.sendMsg(0, tMsgData)
  449. tMsgData.nRankSubType = CommonDefine.COMMONRANK_SUB_TYPE_SERVERCOMMERCE_HUMAN
  450. InnerMsg.sendMsg(0, tMsgData)
  451. end
  452. function CommerceMiddle_GMClearMiddleMail()
  453. local tMsgData = InnerMsg.lw.LW_COMMERCE_GM_CLEAR_MAIL
  454. tMsgData.nSrcServerID = Config.SVR_INDEX
  455. InnerMsg.sendMsg(0, tMsgData)
  456. end
  457. function CommerceMiddle_QueryActOpenTime()
  458. local tMsgData = InnerMsg.lw.LW_COMMERCE_ACT_GET_OPENTIME
  459. tMsgData.nSrcServerID = Config.SVR_INDEX
  460. InnerMsg.sendMsg(0, tMsgData)
  461. print("[CommerceMiddle_QueryActOpenTime] 请求中心服活动开启时间")
  462. end
  463. function CommerceMiddle_GMClearDB(nServerID)
  464. local nServerConfID = MiddleConnect.MiddleConnect_TrueServerID2ConfServerID(nServerID)
  465. local nServerKey = MiddleConnect.MiddleConnect_GetWarZoneServer(nServerConfID)
  466. local nBeginTime, nEndTime = CommerceMiddle_CreateActTime()
  467. local tDBData =
  468. {
  469. nBatchID = 1,
  470. nBeginTime = nBeginTime,
  471. nEndTime = nEndTime
  472. }
  473. local szText = "[CommerceMiddle_GMClearDB] 生成新的DB数据 nServerKey = "..nServerKey.." nBatchID = "..tDBData.nBatchID
  474. .." nBeginTime = "..tDBData.nBeginTime.." nEndTime = "..tDBData.nEndTime
  475. CommerceMiddle_WriteLog(szText)
  476. CommonDB.SetCommerceMiddleAct_ByKey(nServerKey, tDBData)
  477. CommerceMiddle_SendOpenTime(nServerID)
  478. end