ServerCommerceMiddle.lua 21 KB

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