From 7edc031f465bdd21decd47f346e00c512d969d45 Mon Sep 17 00:00:00 2001
From: client_linchunjie <461730578@qq.com>
Date: 星期五, 14 九月 2018 16:04:22 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts

---
 System/Store/StoreModel.cs |   97 ++++++++++++++++++++++++++++++++++--------------
 1 files changed, 68 insertions(+), 29 deletions(-)

diff --git a/System/Store/StoreModel.cs b/System/Store/StoreModel.cs
index 0c915dc..1c1ea9e 100644
--- a/System/Store/StoreModel.cs
+++ b/System/Store/StoreModel.cs
@@ -54,6 +54,7 @@
 
     public void OnBeforePlayerDataInitialize()
     {
+        IsMustBuyDay = false;
         isLogin = true;
         FuncOpen.Instance.OnFuncStateChangeEvent -= FuncStateChange;
         PlayerDatas.Instance.fairyData.OnRefreshFairyMine -= RefreshServerHour;
@@ -82,7 +83,7 @@
         FuncOpen.Instance.OnFuncStateChangeEvent += FuncStateChange;
         RefreshTCBPlayerDataEvent += RefreshPlayerLv;
         TimeMgr.Instance.OnHourEvent += RefreshServerHour;
-
+        SetIsMustBuyDay();
         shoplist = null;
         CheckWeekStoreIsShopBuy(out shoplist);
         ControllerRedPoint();
@@ -239,7 +240,16 @@
     private void RefreshServerHour()
     {
         ControllerRedPoint();
-        UpdateMustBuyRedpoint();
+        if (PlayerPrefs.HasKey(MUSTBUYSAVE_KEY))
+        {
+            int day = LocalSave.GetInt(MUSTBUYSAVE_KEY);
+            if (day != TimeUtility.ServerNow.Day)
+            {
+                IsMustBuyDay = true;
+                LocalSave.SetInt(MUSTBUYSAVE_KEY, TimeUtility.ServerNow.Day);
+                UpdateMustBuyRedpoint();
+            }
+        }
         if(!PlayerDatas.Instance.fairyData.HasFairy)
         {
             PlayerPrefs.DeleteKey(UNIONSTORESAVE_KEY);
@@ -828,28 +838,32 @@
         foreach(var key in shopRedDict.Keys)
         {
             StoreConfig storeConfig = Config.Instance.Get<StoreConfig>(key);
-            if (storeConfig.MoneyNumber == 0)
+            if(!mustIdlist.Contains(storeConfig.ItemID))
             {
-                if(CheckShopIsCanBuy(storeConfig))
+                if (storeConfig.MoneyNumber == 0)
                 {
-                    shopRedDict[storeConfig.ID].state = RedPointState.Simple;
+                    if (CheckShopIsCanBuy(storeConfig))
+                    {
+                        shopRedDict[storeConfig.ID].state = RedPointState.Simple;
+                    }
+                    else
+                    {
+                        shopRedDict[storeConfig.ID].state = RedPointState.None;
+                    }
                 }
                 else
                 {
-                    shopRedDict[storeConfig.ID].state = RedPointState.None;
+                    if (CheckScoreStoreIsCanBuy(storeConfig))
+                    {
+                        shopRedDict[storeConfig.ID].state = RedPointState.Simple;
+                    }
+                    else
+                    {
+                        shopRedDict[storeConfig.ID].state = RedPointState.None;
+                    }
                 }
             }
-            else
-            {
-                if(CheckScoreStoreIsCanBuy(storeConfig))
-                {
-                    shopRedDict[storeConfig.ID].state = RedPointState.Simple;
-                }
-                else
-                {
-                    shopRedDict[storeConfig.ID].state = RedPointState.None;
-                }
-            }
+          
         }
     }
 
@@ -860,13 +874,16 @@
         foreach (var key in shopRedDict.Keys)
         {
             StoreConfig storeConfig = Config.Instance.Get<StoreConfig>(key);
-            if (CheckIsMustBuy(storeConfig))
+            if(mustIdlist.Contains(storeConfig.ItemID))
             {
-                shopRedDict[storeConfig.ID].state = RedPointState.Simple;
-            }
-            else
-            {
-                shopRedDict[storeConfig.ID].state = RedPointState.None;
+                if (CheckIsMustBuy(storeConfig))
+                {
+                    shopRedDict[storeConfig.ID].state = RedPointState.Simple;
+                }
+                else
+                {
+                    shopRedDict[storeConfig.ID].state = RedPointState.None;
+                }
             }
         }
     }
@@ -876,19 +893,41 @@
         if(mustIdlist.Contains(storeConfig.ItemID))
         {
             shopRedDict[storeConfig.ID].state = RedPointState.None;
+            IsMustBuyDay = false;
+        }
+    }
+
+    public bool IsMustBuyDay { get; private set; }
+    public void SetIsMustBuyDay()
+    {
+        if (IsMustBuyDay) return;
+
+        if (PlayerPrefs.HasKey(MUSTBUYSAVE_KEY))
+        {
+            int day = LocalSave.GetInt(MUSTBUYSAVE_KEY);
+            if (day != TimeUtility.ServerNow.Day)
+            {
+                IsMustBuyDay = true;
+                LocalSave.SetInt(MUSTBUYSAVE_KEY, TimeUtility.ServerNow.Day);
+            }
+            else
+            {
+                IsMustBuyDay = false;
+            }
+        }
+        else
+        {
+            IsMustBuyDay = true;
+            LocalSave.SetInt(MUSTBUYSAVE_KEY, TimeUtility.ServerNow.Day);
         }
     }
 
     public List<int> mustIdlist = new List<int>() { 4741};
     public bool CheckIsMustBuy(StoreConfig config)
     {
-        if(mustIdlist.Contains(config.ItemID)
-            && CheckShopIsCanBuy(config))
+        if(CheckShopIsCanBuy(config) && IsMustBuyDay)
         {
-            if(IsNewDay(MUSTBUYSAVE_KEY))
-            {
-                return true;
-            }
+            return true;
         }
         return false;
     }

--
Gitblit v1.8.0