From cc5dac1925b4b2dcf6cac03eff123d53cf77238f Mon Sep 17 00:00:00 2001
From: client_Zxw <826696702@qq.com>
Date: 星期二, 08 一月 2019 21:00:59 +0800
Subject: [PATCH] 5767 【前端】【1.5】新增8-14天活动功能(制作成7日运营活动的模板)

---
 System/OpenServerActivity/OpenServiceAchievementWin.cs |  118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 115 insertions(+), 3 deletions(-)

diff --git a/System/OpenServerActivity/OpenServiceAchievementWin.cs b/System/OpenServerActivity/OpenServiceAchievementWin.cs
index 3047e20..3229e44 100644
--- a/System/OpenServerActivity/OpenServiceAchievementWin.cs
+++ b/System/OpenServerActivity/OpenServiceAchievementWin.cs
@@ -21,6 +21,7 @@
         private int InDay;
         #region Built-in
         OpenServiceAchievementModel model { get { return ModelCenter.Instance.GetModel<OpenServiceAchievementModel>(); } }
+        List<int> SortList = new List<int>();
         protected override void BindController()
         {
             m_ScrollerController1.OnRefreshCell += OnRefreshGridCell_1;
@@ -40,14 +41,22 @@
 
         protected override void OnAfterOpen()
         {
+            model.WeekPartyDayInfoUpdate += WeekPartyDayInfoUpdate;
         }
 
         protected override void OnPreClose()
-        {
-        }
-
+        {
+            model.WeekPartyDayInfoUpdate -= WeekPartyDayInfoUpdate;
+        }
+
+       
+
         protected override void OnAfterClose()
         {
+        }
+        private void WeekPartyDayInfoUpdate()//鍒楄〃鍒锋柊
+        {
+            m_ScrollerController2.m_Scorller.RefreshActiveCellViews();//鍒锋柊鍙
         }
         #endregion
         void OnCreateGridLineCell1(ScrollerController gridCtrl)
@@ -83,6 +92,7 @@
                 {
                     InDay = Index;
                     model.SelectedNow = InDay;//閫変腑澶�
+                    OnCreateGridLineCell2(m_ScrollerController2);
                     m_ScrollerController1.m_Scorller.RefreshActiveCellViews();//鍒锋柊鍙
                 }
             });
@@ -110,6 +120,7 @@
         //-------------------------------
         void OnCreateGridLineCell2(ScrollerController gridCtrl)
         {
+            ToAddSorting();//鎺掑簭
             gridCtrl.Refresh();
             for (int i = 0; i < 8; i++)
             {
@@ -122,6 +133,107 @@
            
         }
 
+        private void ToAddSorting()
+        {
+            SortList.Clear();
+            foreach (var key in model.WeekPartyDayDic.Keys)
+            {
+                if (key == model.SelectedNow)
+                {
+                    for (int i = 0; i < model.WeekPartyDayDic[key].TemplateList.Length; i++)
+                    {
+                        SortList.Add(model.WeekPartyDayDic[key].TemplateList[i]);
+                    }
+                }
+            }
+            SortList.Sort(Compare);
+        }
+        int Compare(int x, int y)//鏁扮粍鎺掑垪
+        {
+            bool havex1 = IsReceive(x);
+            bool havey1 = IsReceive(y);
+            if (havex1.CompareTo(havey1) != 0)
+            {
+                return -havex1.CompareTo(havey1);
+            }
+            bool havex2 = Undone(x);
+            bool havey2 = Undone(y);
+            if (havex2.CompareTo(havey2) != 0)
+            {
+                return -havex2.CompareTo(havey2);
+            }
+            bool havex3 = Completed(x);
+            bool havey3 = Completed(y);
+            if (havex3.CompareTo(havey3) != 0)
+            {
+                return -havex3.CompareTo(havey3);
+            }
+            int havex4 = SizeId(x);
+            int havey4 = SizeId(y);
+            if (havex4.CompareTo(havey4) != 0)
+            {
+                return havex4.CompareTo(havey4);
+            }
+            return 1;
+        }
+        private bool IsReceive(int ID)//鍙鍙�
+        {
+            bool Bool = false;
+            if (model.WeekPartyActionDic.ContainsKey(ID))
+            {
+                var WeekPartyAction = model.WeekPartyActionDic[ID];
+                int number = WeekPartyAction.TotalTimes / WeekPartyAction.SingleTimes;
+                int rewardNum = model.GetRewardNumber(model.SelectedNow, ID);//宸查濂栨鏁�
+                int carryOutNum = model.GetCarryOutNum(model.SelectedNow, ID);//宸插畬鎴愭鏁�
+                if (carryOutNum >= WeekPartyAction.SingleTimes && number > rewardNum)
+                {
+                    Bool = true;
+                }
+            }            
+            return Bool;
+        }
+        private bool Undone(int ID)//鏈畬鎴�
+        {
+            bool Bool = false;
+            if (model.WeekPartyActionDic.ContainsKey(ID))
+            {
+                var WeekPartyAction = model.WeekPartyActionDic[ID];
+                int number = WeekPartyAction.TotalTimes / WeekPartyAction.SingleTimes;
+                int rewardNum = model.GetRewardNumber(model.SelectedNow, ID);//宸查濂栨鏁�
+                int carryOutNum = model.GetCarryOutNum(model.SelectedNow, ID);//宸插畬鎴愭鏁�
+                if (WeekPartyAction.SingleTimes > carryOutNum)
+                {
+                    Bool = true;
+                }
+            }
+            return Bool;
+        }
+        private bool Completed(int ID)//宸查鍙�
+        {
+            bool Bool = false;
+            if (model.WeekPartyActionDic.ContainsKey(ID))
+            {
+                var WeekPartyAction = model.WeekPartyActionDic[ID];
+                int number = WeekPartyAction.TotalTimes / WeekPartyAction.SingleTimes;
+                int rewardNum = model.GetRewardNumber(model.SelectedNow, ID);//宸查濂栨鏁�
+                int carryOutNum = model.GetCarryOutNum(model.SelectedNow, ID);//宸插畬鎴愭鏁�
+                if (rewardNum> number)
+                {
+                    Bool = true;
+                }
+            }
+            return Bool;
+        }
+        private int SizeId(int ID)
+        {
+            int index = 1;
+            var config = Config.Instance.Get<WeekPartyConfig>(ID);
+            if (config != null)
+            {
+                index = config.order;
+            }
+            return index;
+        }
     }
 
 }

--
Gitblit v1.8.0