From eed4e4b6c64f7286b608b971764b337f9ef545d0 Mon Sep 17 00:00:00 2001
From: client_linchunjie <461730578@qq.com>
Date: 星期四, 30 八月 2018 14:51:51 +0800
Subject: [PATCH] 3009【前端】运营类活动优化

---
 System/OpenServerActivity/OSGiftModel.cs |   51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 50 insertions(+), 1 deletions(-)

diff --git a/System/OpenServerActivity/OSGiftModel.cs b/System/OpenServerActivity/OSGiftModel.cs
index f9921d5..814148e 100644
--- a/System/OpenServerActivity/OSGiftModel.cs
+++ b/System/OpenServerActivity/OSGiftModel.cs
@@ -31,6 +31,7 @@
         }
 
         public event Action<int> onStateUpate;
+        public event Action timeLimitUpdate;
 
         public bool activate { get; private set; }
 
@@ -74,6 +75,31 @@
             }
         }
 
+        public int timeOverdueGiftId { get; private set; }
+        public DateTime overDueTime = DateTime.Now;
+        public bool allOverdue { get; private set; }
+        public void UpdateTime(HAA16_tagMCSuperGiftInfo package)
+        {
+            timeOverdueGiftId = (int)package.GiftID;
+            var _time = new DateTime(TimeUtility.Year, TimeUtility.Month, TimeUtility.Day, 0, 0, 0);
+            overDueTime = _time.AddDays(package.RemainDay);
+            allOverdue = package.RemainDay == 0;
+            bool _activate = CheckActivate();
+            if (activate != _activate)
+            {
+                activate = _activate;
+                if (onStateUpate != null)
+                {
+                    onStateUpate(6);
+                }
+            }
+            if (timeLimitUpdate != null)
+            {
+                timeLimitUpdate();
+            }
+            UpdateRedpoint();
+        }
+
         private void FirstChargeRewardEvent()
         {
             bool _activate = CheckActivate();
@@ -95,15 +121,36 @@
             {
                 return false;
             }
+            if (allOverdue)
+            {
+                return false;
+            }
             List<StoreConfig> _list = null;
             StoreConfig.TryGetStoreConfigs((int)StoreFunc.OSGift,out _list);
             for (int i = 0; i < _list.Count; i++)
             {
+                if (IsGiftOverdue(_list[i].ID))
+                {
+                    continue;
+                }
                 var _limit = storeModel.GetBuyShopLimit((uint)_list[i].ID);
                 if (_limit == null || _limit.BuyCnt < _list[i].PurchaseNumber[0])
                 {
                     return true;
                 }
+            }
+            return false;
+        }
+
+        public bool IsGiftOverdue(int _id)
+        {
+            if (allOverdue || _id < timeOverdueGiftId)
+            {
+                return true;
+            }
+            if (_id == timeOverdueGiftId)
+            {
+                return TimeUtility.ServerNow >= overDueTime;
             }
             return false;
         }
@@ -123,8 +170,10 @@
 
         public void OnBeforePlayerDataInitialize()
         {
+            allOverdue = false;
+            timeOverdueGiftId = 0;
         }
-        
+
         public void SetDayRemind()
         {
             if (OSGiftRedpoint.state == RedPointState.Simple)

--
Gitblit v1.8.0