Преглед изворни кода

提交跨服商业活动 时间问题存储在中心服

SCFC пре 1 година
родитељ
комит
1dcf18ebd1

+ 35 - 0
script/common/CommonDB.lua

@@ -40,6 +40,7 @@ kEY_RECOMMENDLINEUP = "recommendlineup"					-- 推荐阵容
 KEY_FIREWORKBONUS_TIME="fireWorksBonusTime"             -- 烟花加成时间
 KEY_COMMERCEACT_INFO = "commerceActInfo"				-- 跨服活动信息
 KEY_JJCLADDER_TIME = "jjcladderEndTime"					-- 天梯赛结束时间
+KEY_COMMERCEACT_MIDDLE_INFO = "commerceMiddleActInfo"	-- 中心服跨服商业活动信息
 
 db = db or {
 	serverStartTime = nil,								-- 开服时间
@@ -67,6 +68,7 @@ db = db or {
 	fireWorksBonusTime = nil,                           -- 烟花加成时间
 	commerceActInfo = {},								-- 跨服商业活动信息
 	jjcladderEndTime = nil,								-- 天梯赛结束时间
+	commerceMiddleActInfo = {},							-- 中心服跨服商业活动信息
 }
 
 function init()
@@ -480,4 +482,37 @@ end
 function SetJjcLadderEndTime(nEndTime)
 	db.jjcladderEndTime = nEndTime
 	updateValue(KEY_JJCLADDER_TIME, nEndTime)
+end
+
+-- 获取中心服跨服商业活动信息
+--[[
+	-- 战区所属服务器key
+	[nKey] = 
+	{
+		nBatchID,		-- 批次
+		nBeginTime,		-- 开始时间
+		nEndTime,		-- 结束时间
+	}
+]]
+function GetCommerceMiddleAct()
+	return db.commerceMiddleActInfo
+end
+
+-- 设置中心服跨服商业活动信息
+function SetCommerceMiddleAct(tData)
+	db.commerceMiddleActInfo = tData
+
+	updateValue(KEY_COMMERCEACT_MIDDLE_INFO, db.commerceMiddleActInfo)
+end
+
+-- 获取中心服跨服商业某个服的信息
+function GetCommerceMiddleAct_ByKey(nKey)
+	return db.commerceMiddleActInfo[nKey] or nil
+end
+
+-- 设置中心服跨服商业某个服的信息
+function SetCommerceMiddleAct_ByKey(nKey, tData)
+	db.commerceMiddleActInfo[nKey] = tData
+
+	updateValue(KEY_COMMERCEACT_MIDDLE_INFO, db.commerceMiddleActInfo)
 end

+ 22 - 0
script/common/InnerHandler.lua

@@ -259,4 +259,26 @@ function LW_COMMERCE_GM_CLEAR_MAIL(fd, msg)
     print("[LW_COMMERCE_GM_CLEAR_MAIL] GM清理排行榜邮件个人发送命令")
     MiddleCommonRank.MiddleCommonRank_GMClearMail(msg)
 end
+
+-- 中心服请求活动数据
+function WL_COMMERCE_GET_ACT_INFO(fd, msg)
+    print("[WL_COMMERCE_GET_ACT_INFO] 收到中心服请求活动开放时间数据")
+    CommerceMiddle.CommerceMiddle_GetActInfo_WL(msg)
+end
+
+-- 普通服发送活动时间数据
+function LW_COMMERCE_GET_ACT_INFO(fd, msg)
+    if _G.is_middle ~= true then return end
+    CommerceMiddle.CommerceMiddle_GetActInfo_LW(msg)
+end
+
+-- 普通服请求活动时间
+function LW_COMMERCE_ACT_GET_OPENTIME(fd, msg)
+    if _G.is_middle ~= true then return end
+    CommerceMiddle.CommerceMiddle_GetActOpenTime_LW(msg)
+end
+
+function WL_COMMERCE_ACT_GET_OPENTIME(fd, msg)
+    CommerceMiddle.CommerceMiddle_GetActOpenTime_WL(msg)
+end
 -------------------- 跨服商业活动结束 ---------------------------

+ 33 - 1
script/common/InnerProto.lua

@@ -192,7 +192,8 @@ WL_COMBAT_GETINFO_SEND =
 
 -------------------- 跨服商业活动开始 ---------------------------
 -- 请求开服天数
-WL_COMMERCE_QUERYOPENDAY = {}
+WL_COMMERCE_QUERYOPENDAY = {
+}
 
 -- 回复开服天数
 LW_COMMERCE_SENDOPENDAY = {
@@ -288,6 +289,37 @@ LW_COMMERCE_GM_CLEAR_MAIL =
 {
   {"nSrcServerID",      "int"},       -- 服务器ID
 }
+
+-- 获取战区第一个服的活动时间数据
+WL_COMMERCE_GET_ACT_INFO = {
+  {"nReqServerID",        "int"}    -- 不存在时为0
+}
+
+-- 发送给中心服活动时间数据
+LW_COMMERCE_GET_ACT_INFO = 
+{
+  {"nOperate",          "int"},       -- 0 失败 1 成功有数据 2 成功无数据
+  {"nReqServerID",      "int"},       -- 不存在时为0
+  {"nSrcServerID",      "int"},       -- 服务器ID 
+  {"nBatchID",          "int"},       -- 批次
+  {"nBeginTime",        "int"},       -- 开始时间
+  {"nEndTime",          "int"},       -- 结束时间
+}
+
+-- 请求中心服活动时间
+LW_COMMERCE_ACT_GET_OPENTIME = 
+{
+  {"nSrcServerID",      "int"},       -- 服务器ID
+}
+
+-- 回复普通服活动时间
+WL_COMMERCE_ACT_GET_OPENTIME = 
+{
+  {"nBatchID",          "int"},       -- 批次
+  {"nBeginTime",        "int"},       -- 开始时间
+  {"nEndTime",          "int"},       -- 结束时间
+}
+
 -------------------- 跨服商业活动结束 ---------------------------
 
 -------------------- 天梯赛开始 -----------------------------------

+ 5 - 1
script/common/InnerProtoID.lua

@@ -35,4 +35,8 @@ _ENV[34] = 'WL_COMMERCE_GET_SERVERRANK_PRIZE'
 _ENV[35] = 'LW_COMMERCE_TELL_SERVER_MAILOK'
 _ENV[36] = 'WL_COMMERCE_SEND_HUMAN_PRIZE'
 _ENV[37] = 'LW_COMMERCE_CLEAR_RANK'
-_ENV[38] = 'LW_COMMERCE_GM_CLEAR_MAIL'
+_ENV[38] = 'LW_COMMERCE_GM_CLEAR_MAIL'
+_ENV[39] = 'WL_COMMERCE_GET_ACT_INFO'
+_ENV[40] = 'LW_COMMERCE_GET_ACT_INFO'
+_ENV[41] = 'LW_COMMERCE_ACT_GET_OPENTIME'
+_ENV[42] = 'WL_COMMERCE_ACT_GET_OPENTIME'

+ 2 - 1
script/module/serverCommerce/ServerCommerceActCharge.lua

@@ -121,7 +121,8 @@ function CommerceActCharge_Query(human, nMoney)
     local tMoney = {}
     local tRed = tMsgData.tRed
     tRed[0] = 0
-
+    tMsgData.list[0] = 0
+    
     tMsgData.nMoney = nMoney
     local nChargeDay, nLen = 0, 0
     for nID, v in ipairs(tConf) do

+ 98 - 62
script/module/serverCommerce/ServerCommerceManager.lua

@@ -11,13 +11,7 @@ local Broadcast = require("broadcast.Broadcast")
 local MailExcel = require("excel.mail")
 local Msg = require("core.Msg")
 local ObjHuman = require("core.ObjHuman")
-local MailManager = require("mail.MailManager")
-local BagLogic = require("bag.BagLogic")
-local Grid = require("bag.Grid")
-local PanelDefine = require("broadcast.PanelDefine")
 local CommonDB = require("common.CommonDB")
-local BuyLogic = require("topup.BuyLogic")
-local GuideLogic = require("guide.GuideLogic")
 local Log = require("common.Log")
 local YunYingLogic = require("yunying.YunYingLogic")
 local ServerCommerceCof = require("excel.ServerCommerce")
@@ -43,6 +37,9 @@ tCommerceActInfo = nil
 -- 加载的模块
 tCommerceActModuel = {}
 
+-- 当前的操作类型
+local nQueryOperate = nil
+
 ----------------------------------------- 内部处理开始 -------------------------------------
 -- 下发数据
 local function CommerceAct_SendData(tMsgData, fd)
@@ -306,54 +303,20 @@ local function CommerceAct_ClearRankInfo()
     ServerCommerceMiddle.CommerceMiddle_ClearRank()
 end
 
+-- 请求中心服活动时间和批次数据
+local function CommerceAct_QueryActOpenTime()
+    ServerCommerceMiddle.CommerceMiddle_QueryActOpenTime()
+end
+
 -- 起服初始化数据
 local function CommerceAct_ActCheckOpen_InitServer(nOpen, nOperate, nServerKey)
     if ServerCommerceActDefine.COMMERCEACT_NOOPEN ~= nOpen then
-        local tCommerceInfo = CommonDB.GetCommerceActInfo()
-        local bIsCreateCache = true
-        -- 不存在数据
-        if not tCommerceInfo or nil == _G.next(tCommerceInfo) then
-            print("[CommerceAct_ActCheckOpen_InitServer] 不存在commonDB数据开始创建")
-            CommerceAct_CreateCommonDB()
-            -- 清理排行榜数据
-            CommerceAct_ClearRankInfo()
-        else
-            table.print_lua_table(tCommerceInfo)
-            -- 存在数据检查是否结束
-            if true == CommerceAct_CheckActIsOverTime() then
-                print("[CommerceAct_ActCheckOpen_InitServer] 存在commonDB数据开始进入判断")
-                local bOpenNext = CommerceAct_CanOpenNext()
-                if true == bOpenNext then
-                    print("[CommerceAct_ActCheckOpen_InitServer] 开启下一轮")
-                    -- 开启下一轮
-                    if tCommerceInfo.nBatchID < ServerCommerceActDefine.COMMERCEACT_ENDBATCH then
-                        CommerveManager_WriteLog("[CommerveManager-onZeroAll] 当前条件满足开启下一轮活动")
-                        CommerceAct_CreateCommonDB()
-                        -- 清理排行榜数据
-                        CommerceAct_ClearRankInfo()
-                    end
-                else
-                    bIsCreateCache = false
-                end
-            end
-        end
+        nQueryOperate = nOperate
 
-        local bLater = nOperate == ServerCommerceActDefine.COMMERCEACT_ZERO and true or false
-        if true == bIsCreateCache then
-            CommerceAct_CreateCacheInfo(nOpen, bLater)
-            ServerCommerceActRank.CommercerActRank_GetRankServerKey(nServerKey)
-            ServerCommerceActRank.CommercerActRank_InitServerQueryRank()
-            print("[CommerceAct_ActCheckOpen_InitServer] 起服初始化完成")
-        else
-            tCommerceInfo = CommonDB.GetCommerceActInfo()
-            tCommerceActInfo = {}
-            tCommerceActInfo.nStartTime = tCommerceInfo.nBeginTime
-            tCommerceActInfo.nEendTime = tCommerceInfo.nEndTime
-            tCommerceActInfo.isRun = false
-            tCommerceActInfo.nOpen = 0
-            tCommerceActInfo.nBatchID = tCommerceInfo.nBatchID
-            print("[CommerceAct_ActCheckOpen_InitServer] 活动不在开放时间")
-        end
+        ServerCommerceActRank.CommercerActRank_GetRankServerKey(nServerKey)
+
+        -- 活动开启去请求时间数据
+        CommerceAct_QueryActOpenTime()
     end
 end
 
@@ -399,21 +362,27 @@ function onZeroAll(funcID)
             -- 开启下一轮
             if tCommerceDBInfo.nBatchID < ServerCommerceActDefine.COMMERCEACT_ENDBATCH then
                 CommerveManager_WriteLog("[CommerveManager-onZeroAll] 当前条件满足开启下一轮活动 nOldBatchID = "..tCommerceDBInfo.nBatchID.." nNewBatchID = "..tCommerceDBInfo.nBatchID+1)
-                CommerceAct_CreateCommonDB()
-
-                -- 存在数据说明时间是满足的
-                CommerceAct_CreateCacheInfo(ServerCommerceActDefine.COMMERCEACT_OPEN, true)
-
-                -- 遍历在线玩家
-                for uuid, human in pairs(ObjHuman.onlineUuid) do
-                    CommerceAct_BeginAllAct(human)
-                end
 
                 -- 清理排行榜数据
                 CommerceAct_ClearRankInfo()
-                
-                -- 重新请求排行榜数据
-                ServerCommerceActRank.CommercerActRank_InitServerQueryRank()
+
+                -- 重新请求活动时间数据
+                CommerceAct_QueryActOpenTime()
+
+                nQueryOperate = ServerCommerceActDefine.COMMERCEACT_ZERO
+
+                -- CommerceAct_CreateCommonDB()
+
+                -- -- 存在数据说明时间是满足的
+                -- CommerceAct_CreateCacheInfo(ServerCommerceActDefine.COMMERCEACT_OPEN, true)
+
+                -- -- 遍历在线玩家
+                -- for uuid, human in pairs(ObjHuman.onlineUuid) do
+                --     CommerceAct_BeginAllAct(human)
+                -- end
+
+                -- -- 重新请求排行榜数据
+                -- ServerCommerceActRank.CommercerActRank_InitServerQueryRank()
             end
         end
     end
@@ -517,6 +486,73 @@ function CommerceAct_IsRun()
     return tCommerceActInfo.isRun
 end
 
+-- 获取到中心服活动时间数据
+function CommerceAct_GetActTime(tData)
+    local tOldDBData = CommonDB.GetCommerceActInfo()
+    local tNewDBData = nil
+    local szText = "[CommerceAct_GetActTime] 获取到对应的中心服时间数据 nBatchID = "..tData.nBatchID.." nBeginTime = "..tData.nBeginTime.." nEndTime = ".. tData.nEndTime
+    print(szText)
+    if tOldDBData then
+            if tOldDBData.nBatchID ~= tData.nBatchID or tOldDBData.nBeginTime ~= tData.nBeginTime
+                or tOldDBData.nEndTime ~= tOldDBData.nEndTime then
+                    szText = szText .."当前服务器数据和获取到的中心服数据不一致进行了重置 旧的DB数据 nOldBatchID = "..tOldDBData.nBatchID
+                                .." nOldBeginTime = "..tOldDBData.nBeginTime.." nOldEndTime = ".. tOldDBData.nEndTime
+                    print(szText)
+                    tNewDBData = {}
+                    tNewDBData.nBatchID = tData.nBatchID
+                    tNewDBData.nBeginTime = tData.nBeginTime
+                    tNewDBData.nEndTime = tData.nEndTime
+                    CommerveManager_WriteLog(szText)
+
+                    -- 存在旧数据,看看需要重置数据
+                    if tData.nBeginTime > tOldDBData.nEndTime then
+                        tNewDBData.nPoint = 0
+                        tNewDBData.nSendRankMail = 0
+                        CommerveManager_WriteLog("[CommerceAct_GetActTime] 存在旧的数据,当前批次开启时间大于上一次结束时间, 重置点数和发送邮件数据")
+                    else
+                        tNewDBData.nPoint = tOldDBData.nPoint
+                        tNewDBData.nSendRankMail = tOldDBData.nSendRankMail
+                    end
+                else 
+                    print("[CommerceAct_GetActTime] 当前时间相同")
+            end
+    else
+        tNewDBData = {}
+        tNewDBData.nBatchID = tData.nBatchID
+        tNewDBData.nBeginTime = tData.nBeginTime
+        tNewDBData.nEndTime = tData.nEndTime
+        tNewDBData.nPoint = 0
+        tNewDBData.nSendRankMail = 0
+
+        szText = szText.." 当前服务器不存在数据直接创建"
+        CommerveManager_WriteLog(szText)
+    end
+
+    if nil ~= tNewDBData then
+        CommonDB.SetCommerceActInfo(tNewDBData)
+    end
+
+    local tCommerceInfo = CommonDB.GetCommerceActInfo()
+    local nNowTime = os.time()
+    if nNowTime < tCommerceInfo.nEndTime then
+        table.print_lua_table(tCommerceInfo)
+        local bLater = nQueryOperate == ServerCommerceActDefine.COMMERCEACT_ZERO and true or false
+        CommerceAct_CreateCacheInfo(1, bLater)
+        print("\n")
+        table.print_lua_table(tCommerceActInfo)
+        ServerCommerceActRank.CommercerActRank_InitServerQueryRank()
+    else
+        tCommerceActInfo = {}
+        tCommerceActInfo.nStartTime = tCommerceInfo.nBeginTime
+        tCommerceActInfo.nEendTime = tCommerceInfo.nEndTime
+        tCommerceActInfo.isRun = false
+        tCommerceActInfo.nOpen = 0
+        tCommerceActInfo.nBatchID = tCommerceInfo.nBatchID
+        print("[CommerceAct_ActCheckOpen_InitServer] 活动不在开放时间")
+    end
+
+end
+
 -- 玩家登录
 function onLogin(human, funcID)
     if not human then

+ 328 - 1
script/module/serverCommerce/ServerCommerceMiddle.lua

@@ -10,11 +10,168 @@ local CommonDefine = require("common.CommonDefine")
 local ServerCommerceManger = require("serverCommerce.ServerCommerceManager")
 local ServerCommerceActDefine = require("serverCommerce.ServerCommerceActDefine")
 local ServerCommerceRank = require("serverCommerce.ServerCommerceActRank")
+local Log = require("common.Log")
+
 
 -- 缓存开服天数
 local tServerOpenDay = nil
 local SERVERCOMMERCEOPENDAY = 8     -- 活动开启要求天数
 
+-- 缓存已经回复的开服天数的服务器
+local tServerOKDay = nil
+
+local function CommerceMiddle_WriteLog(szLogText)
+    Log.write(Log.LOGID_OSS_COMMON_ACT, szLogText)
+end
+
+-- 检查是否进入下一轮
+local function CommerceMiddle_CheckGoNextBatch(nServerKey)
+    if _G.is_middle ~= true then 
+        return false
+    end
+
+    local tDBData = CommonDB.GetCommerceMiddleAct_ByKey(nServerKey)
+    if not tDBData then
+        return true
+    end
+
+    -- 已经是第三轮了
+    if tDBData.nBatchID >= 3 then
+        return false
+    end
+
+    local nNowTime = os.time()
+    if nNowTime < tDBData.nEndTime then
+        return false
+    end
+
+    local nDiffDay = Util.diffDay(tDBData.nEndTime)
+    if nDiffDay > ServerCommerceActDefine.COMMERCEACT_NEXTDAY  then
+        print("[CommerceMiddle_CheckGoNextBatch] 间隔天数已经满足条件 nDiffDay = "..nDiffDay)
+        return true
+    end
+    
+    return false
+end
+
+local function CommerceMiddle_CreateActTime()
+    local nNowTime = os.time()
+    local nEndTime = nNowTime + (ServerCommerceActDefine.COMMERCEACT_LASTDAY - 1)* 86400
+    local tEndDate = os.date("*t",nEndTime)
+    tEndDate.hour = ServerCommerceActDefine.COMMERCEACT_ENDTIME
+    tEndDate.min = 0
+    tEndDate.sec = 0
+    nEndTime = os.time(tEndDate)
+
+    return nNowTime, nEndTime
+end
+
+-- 更新下一轮DB数据
+local function CommerceMiddle_CreateNextBatchDB(nServerKey)
+    local tOldDBData = CommonDB.GetCommerceMiddleAct_ByKey(nServerKey)
+    if not tOldDBData then
+        CommerceMiddle_WriteLog("[CommerceMiddle_CreateNextBatchDB] 更新下一轮中心服活动时间数据, 但是不存在久的数据 nServerKey = "..nServerKey)
+    end
+
+    local nBeginTime, nEndTime = CommerceMiddle_CreateActTime()
+    local nBatchID = 1
+    if tOldDBData and tOldDBData.nBatchID then
+        nBatchID = tOldDBData.nBatchID + 1
+    end
+
+    local tDBData = 
+    {
+        nBatchID = nBatchID,
+        nBeginTime = nBeginTime,
+        nEndTime = nEndTime
+    }
+
+    local szText = "[CommerceMiddle_CreateNewDB] 更新下一轮的DB数据 nServerKey = "..nServerKey.." nBatchID = "..tDBData.nBatchID
+    .." nBeginTime = "..tDBData.nBeginTime.." nEndTime = "..tDBData.nEndTime
+    CommerceMiddle_WriteLog(szText)
+
+    CommonDB.SetCommerceMiddleAct_ByKey(nServerKey, tDBData)
+end
+
+-- 创建新的DB数据
+local function CommerceMiddle_CreateNewDB(nServerKey)
+    local tOldData = CommonDB.GetCommerceMiddleAct_ByKey(nServerKey)
+    if tOldData then
+        local bRet = CommerceMiddle_CheckGoNextBatch(nServerKey)
+        if false == bRet then
+            return
+        else
+            CommerceMiddle_WriteLog("[CommerceMiddle_CreateNewDB] 该服务器满足生成下一轮条件, 生成中心服时间数据 nServerKey = "..nServerKey)
+
+            CommerceMiddle_CreateNextBatchDB(nServerKey)
+
+            return
+        end
+    end
+
+    local nBeginTime, nEndTime = CommerceMiddle_CreateActTime()
+    local tDBData = 
+    {
+        nBatchID = 1,
+        nBeginTime = nBeginTime,
+        nEndTime = nEndTime
+    }
+
+    local szText = "[CommerceMiddle_CreateNewDB] 生成新的DB数据 nServerKey = "..nServerKey.." nBatchID = "..tDBData.nBatchID
+                    .." nBeginTime = "..tDBData.nBeginTime.." nEndTime = "..tDBData.nEndTime
+    CommerceMiddle_WriteLog(szText)
+
+    CommonDB.SetCommerceMiddleAct_ByKey(nServerKey, tDBData)
+end
+
+local function CommerceMiddle_Refresh(nServerKey)
+    if _G.is_middle ~= true or not tServerOpenDay then
+        return
+    end
+
+    local nOpenDay = tServerOpenDay[nServerKey]
+    if nOpenDay < 8 then
+        print("[CommerceMiddle_Refresh] 当前开服时间不足直接返回")
+        return
+    elseif nOpenDay == 8 then
+        CommerceMiddle_WriteLog("[CommerceMiddle_Refresh] 该服务器时间到达8天, 生成中心服时间数据 nServerKey = "..nServerKey)
+        CommerceMiddle_CreateNewDB(nServerKey)
+    else
+        if true == CommerceMiddle_CheckGoNextBatch(nServerKey) then
+            CommerceMiddle_WriteLog("[CommerceMiddle_Refresh] 该服务器满足生成下一轮条件, 生成中心服时间数据 nServerKey = "..nServerKey)
+
+            CommerceMiddle_CreateNextBatchDB(nServerKey)
+        else 
+            print("[CommerceMiddle_Refresh] 当前不满足条件不生成下一轮")
+        end
+    end
+end
+
+-- 发送活动开始时间
+local function CommerceMiddle_SendOpenTime(nServerID)
+    local fd = MiddleManager.getFDBySvrIndex(nServerID)
+    if not fd then
+        print("[CommerceMiddle_SendOpenTime] 获取不到对应的fd nServerID = "..nServerID)
+        return
+    end
+
+    local nServerConfID = MiddleConnect.MiddleConnect_TrueServerID2ConfServerID(nServerID)
+    local nServerKey = MiddleConnect.MiddleConnect_GetWarZoneServer(nServerConfID)
+
+    local tDBData = CommonDB.GetCommerceMiddleAct_ByKey(nServerKey)
+    if not tDBData then
+        CommerceMiddle_WriteLog("[CommerceMiddle_SendOpenTime] 不存在对应的中心服DB数据 nServerKey = "..nServerKey)
+        return
+    end
+ 
+    local tMsgData = InnerMsg.wl.WL_COMMERCE_ACT_GET_OPENTIME
+    tMsgData.nBatchID = tDBData.nBatchID
+    tMsgData.nBeginTime = tDBData.nBeginTime
+    tMsgData.nEndTime = tDBData.nEndTime
+
+    InnerMsg.sendMsg(fd, tMsgData)
+end
+
 -- 起服获取信息
 function CommerceMiddle_InitServer()
     if _G.is_middle ~= true then 
@@ -40,14 +197,16 @@ function CommerceMiddle_GetOpen()
     if _G.is_middle ~= true then 
         return
     end
+    tServerOKDay = {}
+
     print("[CommerceMiddle_GetOpen] 开始去获取服务器开启信息")
-    
     local tWarZoneConf = WarZoneConf.group
     for _, v in ipairs(tWarZoneConf) do
         local nFirstServerID = MiddleConnect.MiddleConnect_ConfServerID2TrueServerID(v.nMinServerID)
         print("[CommerceMiddle_GetOpen] nMinServerID = "..v.nMinServerID.." nFirstServerID = "..nFirstServerID)
         local fd = MiddleManager.getFDBySvrIndex(nFirstServerID)
         if fd then
+            tServerOKDay[nFirstServerID] = 0
             print("[CommerceMiddle_GetOpen] 中心服主动去获取数据 nFirstServerID = "..nFirstServerID)
             local tMsgData = InnerMsg.wl.WL_COMMERCE_QUERYOPENDAY
             InnerMsg.sendMsg(fd, tMsgData)
@@ -67,8 +226,26 @@ function CommerceMiddle_SendOpenDay(fd, msg)
         tServerOpenDay = {}
     end
 
+    if not tServerOKDay then
+        print("[CommerceMiddle_SendOpenDay] 没有正确的对 tServerOKDay 进行初始化")
+        tServerOKDay = {}
+    end
+
     tServerOpenDay[nServerConfID] = nOpenDay
     print("[CommerceMiddle_SendOpenDay] 回复开服天数 nServerConfID = "..nServerConfID.." nOpenDay = "..nOpenDay)
+    
+    tServerOKDay[msg.nSrcServerID] = 1
+
+    local bOK = true
+    for _, v in pairs(tServerOKDay) do
+        if 0 == v then
+            bOK = false
+        end
+    end
+
+    if true == bOK then
+        CommerMiddle_CheckMiddleInfo()
+    end
 end
 
 -- 请求开服天数
@@ -169,6 +346,149 @@ function CommerveMiddle_GetRankInfo(tData)
     ServerCommerceRank.CommercerActRank_GetRankInfo(tData)
 end
 
+-- 检测是否存在中心服数据
+function CommerMiddle_CheckMiddleInfo()
+    if _G.is_middle ~= true then
+        return
+    end
+    
+    for nServerID, v in pairs(tServerOKDay) do
+        local nServerConfID = MiddleConnect.MiddleConnect_TrueServerID2ConfServerID(nServerID)
+        local nServerKey = MiddleConnect.MiddleConnect_GetWarZoneServer(nServerConfID)
+        print("[CommerMiddle_CheckMiddleInfo] 进行判断中心服是否存在数据 nServerKey = "..nServerKey.." nServerID = "..nServerID)
+        local tDBData = CommonDB.GetCommerceMiddleAct_ByKey(nServerKey)
+        local nOpenDay = tServerOpenDay[nServerConfID]
+        -- 不存在去拿数据
+        if nil == tDBData then
+            --if nOpenDay >= 8 then
+                local fd = MiddleManager.getFDBySvrIndex(nServerID)
+                if fd then
+                    local tMsgData = InnerMsg.wl.WL_COMMERCE_GET_ACT_INFO
+                    tMsgData.nReqServerID = 0
+                    InnerMsg.sendMsg(fd, tMsgData)
+                    print("[CommerMiddle_CheckMiddleInfo] 发送数据完成")
+                else
+                    print("[CommerMiddle_CheckMiddleInfo] 获取不到FD nServerID = "..nServerID)
+                end
+            --end
+        else
+            print("[CommerMiddle_CheckMiddleInfo] 存在数据, 判断是否刷新 nServerID = "..nServerID.." nServerKey = "..nServerKey
+                    .." nBatchID = "..tDBData.nBatchID.." nBeginTime = "..tDBData.nBeginTime.." nEndTime = "..tDBData.nEndTime)
+            CommerceMiddle_Refresh(nServerKey)
+        end
+    end
+end
+
+-- 中心服请求活动时间相关数据
+function CommerceMiddle_GetActInfo_WL(msg)
+    print("[CommerceMiddle_GetActInfo] 收到中心服请求")
+
+    local tDBData = CommonDB.GetCommerceActInfo()
+    local tMsgData = InnerMsg.lw.LW_COMMERCE_GET_ACT_INFO
+    table.print_lua_table(tDBData)
+
+    tMsgData.nReqServerID = msg.nReqServerID
+    tMsgData.nSrcServerID = Config.SVR_INDEX
+    tMsgData.nOperate = 0
+    tMsgData.nBatchID = 0
+    tMsgData.nBeginTime = 0
+    tMsgData.nEndTime = 0
+
+    if not tDBData or nil == _G.next(tDBData) then
+        tMsgData.nOperate = 2
+    else
+        tMsgData.nOperate = 1
+        tMsgData.nBatchID = tDBData.nBatchID
+        tMsgData.nBeginTime = tDBData.nBeginTime
+        tMsgData.nEndTime = tDBData.nEndTime
+    end
+
+    InnerMsg.sendMsg(0, tMsgData)
+end
+
+-- 中心服收到活动相关数据
+function CommerceMiddle_GetActInfo_LW(msg)
+    if msg.nOperate == 0 then
+        print("[CommerceMiddle_GetActInfo_LW] 不存在对应的数据")
+    end
+    
+    local nReqServerID = msg.nReqServerID
+    local nServerConfID = MiddleConnect.MiddleConnect_TrueServerID2ConfServerID(msg.nSrcServerID)
+    local nServerKey = MiddleConnect.MiddleConnect_GetWarZoneServer(nServerConfID)
+    print("[CommerceMiddle_GetActInfo_LW] 中心服收到回包 nReqServerID = "..nReqServerID.." nServerConfID = "..nServerConfID)
+    table.print_lua_table(msg)
+
+    local tDBData = {
+        nBatchID = 0,
+        nBeginTime = 0,
+        nEndTime = 0
+    }
+
+    local tOldDBData = CommonDB.GetCommerceMiddleAct_ByKey(nServerKey)
+    if tOldDBData then
+        print("[CommerceMiddle_GetActInfo_LW] 存在db数据")
+        table.print_lua_table(tOldDBData)
+    end
+
+    -- 不存在对应的数据
+    if msg.nOperate == 2 then
+        print("[CommerceMiddle_GetActInfo_LW] 当前上报的服务器没有对应的数据, 活动未开始")
+        CommerceMiddle_Refresh(nServerKey)
+    elseif msg.nOperate == 1 then
+        if nil == tOldDBData then
+            tDBData.nBatchID = msg.nBatchID
+            tDBData.nBeginTime = msg.nBeginTime
+            tDBData.nEndTime = msg.nEndTime
+            print("[CommerceMiddle_GetActInfo_LW] 当前不存在数据, 进行了设置 nServerKey = "..nServerKey)
+            CommonDB.SetCommerceMiddleAct_ByKey(nServerKey, tDBData)
+        end
+
+        tOldDBData = CommonDB.GetCommerceMiddleAct_ByKey(nServerKey)
+        if tOldDBData then
+            print("[CommerceMiddle_GetActInfo_LW] 设置后的数据打印")
+            table.print_lua_table(tOldDBData)
+        end
+
+        CommerceMiddle_Refresh(nServerKey)
+    end
+
+    print("[CommerceMiddle_GetActInfo_LW] 1111111")
+    table.print_lua_table(tDBData)
+
+    if 0 ~= nReqServerID then
+        print("[CommerceMiddle_GetActInfo_LW] 当前有服务器请求数据 nReqServerID = "..nReqServerID)
+        CommerceMiddle_SendOpenTime(nReqServerID)
+    end
+end
+
+-- 普通服请求活动时间
+function CommerceMiddle_GetActOpenTime_LW(msg)
+    if _G.is_middle ~= true then return end
+
+    local nServerConfID = MiddleConnect.MiddleConnect_TrueServerID2ConfServerID(msg.nSrcServerID)
+    local nServerKey = MiddleConnect.MiddleConnect_GetWarZoneServer(nServerConfID)
+
+    local tDBData = CommonDB.GetCommerceMiddleAct_ByKey(nServerKey)
+    if nil == tDBData then
+        local nFirstServerID = MiddleConnect.MiddleConnect_ConfServerID2TrueServerID(nServerKey)
+        local fd = MiddleManager.getFDBySvrIndex(nFirstServerID)
+        if fd then
+            local tMsgData = InnerMsg.wl.WL_COMMERCE_GET_ACT_INFO
+            tMsgData.nReqServerID = msg.nSrcServerID
+            InnerMsg.sendMsg(fd, tMsgData)
+        else
+            print("[CommerceMiddle_GetActOpenTime_LW] 不存在对应的fd 数据 nFirstServerID = "..nFirstServerID)
+        end
+    else
+        CommerceMiddle_Refresh(nServerKey)
+        CommerceMiddle_SendOpenTime(msg.nSrcServerID)
+    end
+end
+
+function CommerceMiddle_GetActOpenTime_WL(msg)
+    ServerCommerceManger.CommerceAct_GetActTime(msg)
+end
+
 ------------------ 活动管理器操作 ------------------------
 -- 请求活动是否开启
 function CommerceMiddle_IsActOpen(nOperate)
@@ -221,4 +541,11 @@ function CommerceMiddle_GMClearMiddleMail()
     local tMsgData = InnerMsg.lw.LW_COMMERCE_GM_CLEAR_MAIL
     tMsgData.nSrcServerID = Config.SVR_INDEX
     InnerMsg.sendMsg(0, tMsgData)
+end
+
+function CommerceMiddle_QueryActOpenTime()
+    local tMsgData = InnerMsg.lw.LW_COMMERCE_ACT_GET_OPENTIME
+    tMsgData.nSrcServerID = Config.SVR_INDEX
+    InnerMsg.sendMsg(0, tMsgData)
+    print("[CommerceMiddle_QueryActOpenTime] 请求中心服活动开启时间")
 end