From 505624324cbcd11b44f0db3036fca1ffa562f3b7 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期三, 16 六月 2021 18:29:53 +0800
Subject: [PATCH] 8983 【港台】【BT2】【港台-1.100.7】【BT2-1.100.1】循环相关的活动配置优化(周循环支持配置开始循环日期及结束循环日期,格式: W1|开启日期  或 W7|结束日期)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py |   90 +++++++++++++++++++++++++++++++++------------
 1 files changed, 66 insertions(+), 24 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py
index e735c5f..78c0d00 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py
@@ -611,31 +611,73 @@
         return {}
     return actNumDict[actNum]
 
-def GetOperationActionDateStr(dateInfo, openServerDay):
-    '''获取运营活动对应日期,存数字代表开服天配置,需要转化为对应的日期
-    @param dateInfo: 运营活动表配置的日期信息, 如果是纯数字代表开服天
-    @param openServerDay: 当前开服天
-    '''
-    if not dateInfo:
-        curDateTime = datetime.datetime.today()
-        return "%d-%d-%d" % (curDateTime.year, curDateTime.month, curDateTime.day)
-    if dateInfo.startswith("W"):
-        curDateTime = datetime.datetime.today()
-        curWeekday = curDateTime.weekday() + 1
-        actionWeekday = int(dateInfo[1:])
-        actionDateTime = curDateTime + datetime.timedelta(days=(actionWeekday-curWeekday))
-        return "%d-%d-%d" % (actionDateTime.year, actionDateTime.month, actionDateTime.day)
-    if dateInfo.startswith("Mix"):
-        diffDay = GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_MixServerDay) + 1
-        actionServerDay = int(dateInfo[3:])
-    elif not dateInfo.isdigit():
-        return dateInfo
-    else:
-        diffDay = openServerDay
-        actionServerDay = int(dateInfo)
+def GetOperationActionDateStr(ipyData):
+    ## 获取运营活动对应日期,存数字代表开服天配置,需要转化为对应的日期
     curDateTime = datetime.datetime.today()
-    actionDateTime = curDateTime + datetime.timedelta(days=(actionServerDay-diffDay))
-    return "%d-%d-%d" % (actionDateTime.year, actionDateTime.month, actionDateTime.day)
+    startDateStr = ipyData.GetStartDate()
+    endDateStr = ipyData.GetEndDate()
+    if not startDateStr:
+        startDateStr = "%d-%d-%d" % (curDateTime.year, curDateTime.month, curDateTime.day)
+    if not endDateStr:
+        endDateStr = "%d-%d-%d" % (curDateTime.year, curDateTime.month, curDateTime.day)
+        
+    # 日期直接返回
+    if startDateStr.count("-") == 2 and "W" not in startDateStr:
+        return startDateStr, endDateStr
+    
+    # 开服天
+    if startDateStr.isdigit():
+        diffDay = GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
+        startDateTime = curDateTime + datetime.timedelta(days=(int(startDateStr)-diffDay))
+        endDateTime = curDateTime + datetime.timedelta(days=(int(endDateStr)-diffDay))
+        
+    # 合服天
+    elif startDateStr.startswith("Mix"):
+        diffDay = GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_MixServerDay) + 1
+        startDateTime = curDateTime + datetime.timedelta(days=(int(startDateStr[3:])-diffDay))
+        endDateTime = curDateTime + datetime.timedelta(days=(int(endDateStr[3:])-diffDay))
+        
+    # 周循环, 直接配置 Wx 或 Wx|有效开始日期  或 Wx|有效结束日期
+    elif startDateStr.startswith("W"):
+        curWeekday = curDateTime.weekday() + 1
+        
+        startWeekDateInfo = startDateStr.split("|")
+        startWeekInfo = startWeekDateInfo[0]
+        startWeekday = int(startWeekInfo[1:])
+        startDateTime = curDateTime + datetime.timedelta(days=(startWeekday-curWeekday))
+        
+        # 限制开启循环日期
+        if len(startWeekDateInfo) > 1:
+            startLoopDateStr = startWeekDateInfo[1]
+            startLoopDateTime = ChangeStrToDatetime(startLoopDateStr, ChConfig.TYPE_Time_Format_Day)
+            if startLoopDateTime > startDateTime:
+                startDateTime = startLoopDateTime
+                
+        startWeekDay = startDateTime.weekday() + 1 # 实际开启活动是周几,不一定和配置的周几一样,可能从中间被截断开始
+        
+        # 处理周循环的结束日期
+        endWeekDateInfo = endDateStr.split("|")
+        endWeekInfo = endWeekDateInfo[0]
+        endWeekday = int(endWeekInfo[1:])
+        endDateTime = startDateTime + datetime.timedelta(days=(endWeekday-startWeekDay))
+        if len(endWeekDateInfo) > 1:
+            endLoopDateStr = endWeekDateInfo[1]
+            endLoopDateTime = ChangeStrToDatetime(endLoopDateStr, ChConfig.TYPE_Time_Format_Day)
+            if endDateTime > endLoopDateTime:
+                endDateTime = endLoopDateTime
+                
+            # 只配置结束日期的时候可能导致开始日期计算出来比结束日期还大,即当前时间超过结束日期,且 配置还存在的情况
+            if startDateTime > endDateTime:
+                startDateTime = endDateTime # 反正都无法开启,随便给个日期,不超过结束日期即可
+                
+    # 默认
+    else:
+        startDateTime = curDateTime
+        endDateTime = curDateTime
+        
+    startDateStr = "%d-%d-%d" % (startDateTime.year, startDateTime.month, startDateTime.day)
+    endDateStr = "%d-%d-%d" % (endDateTime.year, endDateTime.month, endDateTime.day)
+    return startDateStr, endDateStr
 
 ##获得服务器系统时间
 # @param 无

--
Gitblit v1.8.0