From b8ddbd67430c1f32e5f1630c6119c6c2349ee521 Mon Sep 17 00:00:00 2001
From: client_linchunjie <461730578@qq.com>
Date: 星期四, 22 十一月 2018 14:16:26 +0800
Subject: [PATCH] 4941 【前端】【1.3】超值礼包改成人民币购买

---
 System/OpenServerActivity/OSGiftModel.cs |   58 ++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 40 insertions(+), 18 deletions(-)

diff --git a/System/OpenServerActivity/OSGiftModel.cs b/System/OpenServerActivity/OSGiftModel.cs
index d0ad6e8..705d79f 100644
--- a/System/OpenServerActivity/OSGiftModel.cs
+++ b/System/OpenServerActivity/OSGiftModel.cs
@@ -8,10 +8,15 @@
     [XLua.LuaCallCSharp]
 	public class OSGiftModel : Model, IPlayerLoginOk, IBeforePlayerDataInitialize, IOpenServerActivity
     {
+        VipModel vipModel
+        {
+            get { return ModelCenter.Instance.GetModel<VipModel>(); }
+        }
+
         public override void Init()
         {
             ParseConfig();
-            storeModel.RefreshBuyShopLimitEvent += RefreshBuyShopLimitEvent;
+            vipModel.rechargeCountEvent += RechargeCountEvent;
             OpenServerActivityCenter.Instance.Register(6, this);
         }
 
@@ -36,8 +41,6 @@
 
         public event Action<int> onStateUpate;
         public event Action onSelectUpdate;
-
-        StoreModel storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } }
 
         public bool IsOpen
         {
@@ -102,7 +105,7 @@
             {
                 gifts.Add(new SuperValueGift()
                 {
-                    giftId = array[i][0],
+                    payType = array[i][0],
                     openDays = array[i][1],
                 });
             }
@@ -113,7 +116,7 @@
             }
         }
 
-        private void RefreshBuyShopLimitEvent()
+        private void RechargeCountEvent(int id)
         {
             UpdateRedpoint();
         }
@@ -133,7 +136,7 @@
         {
             for (int i = 0; i < gifts.Count; i++)
             {
-                if (!IsGiftExist(gifts[i].giftId))
+                if (!IsGiftExist(gifts[i].payType))
                 {
                     continue;
                 }
@@ -142,7 +145,7 @@
             return false;
         }
 
-        public bool IsGiftExist(int _id)
+        public bool IsGiftExist(int payType)
         {
             if (startSeconds == 0)
             {
@@ -150,7 +153,7 @@
             }
             var gift = gifts.Find((x) =>
             {
-                return x.giftId == _id;
+                return x.payType == payType;
             });
             if (!gift.Equals(default(SuperValueGift)))
             {
@@ -162,16 +165,35 @@
             return true;
         }
 
-        public bool IsGiftBuy(int _id)
+        public bool IsGiftBuy(int payType)
         {
-            var _limit = storeModel.GetBuyShopLimit((uint)_id);
-            var config = Config.Instance.Get<StoreConfig>(_id);
-            if (_limit != null && config != null
-                && _limit.BuyCnt >= config.PurchaseNumber[0])
+            var rechargeId = GetRechargeId(payType);
+            if (rechargeId != 0)
             {
-                return true;
+                VipModel.RechargeCount rechargeCount;
+                if (vipModel.TryGetRechargeCount(rechargeId, out rechargeCount))
+                {
+                    return rechargeCount.todayCount >= 1;
+                }
             }
             return false;
+        }
+
+        public int GetRechargeId(int payType)
+        {
+            var list = vipModel.GetCTGConfigs(VersionConfig.Get().appId);
+            if (list != null)
+            {
+                for (int i = 0; i < list.Count; i++)
+                {
+                    var config = Config.Instance.Get<CTGConfig>(list[i]);
+                    if (config != null && config.PayType == payType)
+                    {
+                        return config.RecordID;
+                    }
+                }
+            }
+            return 0;
         }
 
         public void SetAreadyOpens()
@@ -179,7 +201,7 @@
             alreadyOpens.Clear();
             for (int i = 0; i < gifts.Count; i++)
             {
-                if (IsGiftExist(gifts[i].giftId))
+                if (IsGiftExist(gifts[i].payType))
                 {
                     alreadyOpens.Add(i);
                 }
@@ -190,7 +212,7 @@
         {
             for (int i = 0; i < alreadyOpens.Count; i++)
             {
-                if (gifts[i].giftId == jumpGiftId)
+                if (gifts[i].payType == jumpGiftId)
                 {
                     jumpGiftId = 0;
                     return alreadyOpens[i];
@@ -230,7 +252,7 @@
             for (int i = 0; i < redpoints.Count; i++)
             {
                 redpoints[i].state = RedPointState.None;
-                if (IsGiftExist(gifts[i].giftId) && !IsGiftBuy(gifts[i].giftId)
+                if (IsGiftExist(gifts[i].payType) && !IsGiftBuy(gifts[i].payType)
                     && !GetDayRemind(i))
                 {
                     redpoints[i].state = RedPointState.Simple;
@@ -240,7 +262,7 @@
 
         public struct SuperValueGift
         {
-            public int giftId;
+            public int payType;
             public int openDays;
         }
     }

--
Gitblit v1.8.0