| using System;  | 
| using System.Collections;  | 
| using System.Collections.Generic;  | 
|   | 
| using UnityEngine;  | 
| using LitJson;  | 
| using System.Linq;  | 
|   | 
|   | 
| public class RechargeManager : GameSystemManager<RechargeManager>  | 
| {  | 
|     private Dictionary<string, List<int>> m_CTGConfigDict = new Dictionary<string, List<int>>();  | 
|     public List<int> voucherCTGList = new List<int>();  | 
|   | 
|     public event Action OnVipOpenPayWinEvent;  | 
|   | 
|     public event Action firstChargeRewardEvent;  | 
|     public event Action<int> rechargeCountEvent;  | 
|   | 
|     private bool serverInited = false;  | 
|   | 
|     private bool waitingJump = false;  | 
|   | 
|     public int realRecharge = 0; //真实充值金额  | 
|     public event Action rechargeChangeEvent;  | 
|   | 
|     //代金券记录  | 
|     public List<HA008_tagGCPlayerRecInfo.tagGCPlayerRec> m_PlayerRecsVoucher = new List<HA008_tagGCPlayerRecInfo.tagGCPlayerRec>();  | 
|   | 
|   | 
|     public override void Init()  | 
|     {  | 
|         ParseConfig();  | 
|         ParseCTGConfig();  | 
|         ParseFirstCharge();  | 
|         PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshInfoEvent;  | 
|         DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;  | 
|         SDKUtils.Instance.onFreePlatformPayCancel += OnChargeFail;  | 
|         SDKUtils.Instance.onFreePlatformPayFail += OnChargeFail;  | 
|         SDKUtils.Instance.onFreePlatformPayOk += OnChargeComplete;  | 
|         TimeUtility.OnServerOpenDayRefresh += OnServerOpenDayRefresh;  | 
|         DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk;  | 
|     }  | 
|   | 
|   | 
|     public override void Release()  | 
|     {  | 
|         DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;  | 
|         PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshInfoEvent;  | 
|         SDKUtils.Instance.onFreePlatformPayCancel -= OnChargeFail;  | 
|         SDKUtils.Instance.onFreePlatformPayFail -= OnChargeFail;  | 
|         SDKUtils.Instance.onFreePlatformPayOk -= OnChargeComplete;  | 
|         TimeUtility.OnServerOpenDayRefresh -= OnServerOpenDayRefresh;  | 
|         DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk;  | 
|     }  | 
|   | 
|     public void OnBeforePlayerDataInitialize()  | 
|     {  | 
|         TimeMgr.Instance.UnRegister(TimeMgr.SyntonyType.VipExperirnceOverdue);  | 
|         // if (UIManager.Instance.IsOpened<GotoChargeWin>())  | 
|         // {  | 
|         //     UIManager.Instance.CloseWindow<GotoChargeWin>();  | 
|         // }  | 
|         m_RechargeCountDict.Clear();  | 
|         m_ChargeReset = true;  | 
|         serverInited = false;  | 
|         firstRechargeOpen = false;  | 
|         waitingJump = false;  | 
|         RechargeTimeLismit.Clear();  | 
|         m_PlayerRecsVoucher.Clear();  | 
|         realRecharge = 0;  | 
|     }  | 
|   | 
|     private void PlayerDataRefreshInfoEvent(PlayerDataType _type)  | 
|     {  | 
|         if (_type == PlayerDataType.ChangeCoinPointTotal)  | 
|         {  | 
|             if (serverInited && FirstGoldServerDay > 0  | 
|                 && !beforeRecharge)  | 
|             {  | 
|                 firstRechargeOpen = true;  | 
|             }  | 
|             m_ChargeReset = true;  | 
|             UpdateRedpoint();  | 
|         }  | 
|   | 
|     }  | 
|   | 
|   | 
|     private void OnChargeComplete()  | 
|     {  | 
|         m_ChargeReset = true;  | 
|         // if (UIManager.Instance.IsOpened<RechargeBoxWin>())  | 
|         // {  | 
|         //     UIManager.Instance.CloseWindow<RechargeBoxWin>();  | 
|         // }  | 
|   | 
|     }  | 
|   | 
|     private void OnChargeFail()  | 
|     {  | 
|         m_ChargeReset = true;  | 
|     }  | 
|   | 
|   | 
|     private bool m_ChargeReset = true;  | 
|   | 
|     #region 配置  | 
|     private static string[] lineSplit = new string[] { "</r>" };  | 
|     private int m_CTGDelayTime = 1;   // 充值的公共间隔,见配置ChargeDelayTime  | 
|     private int m_CTGLimitDelayTime = 1; // 限购商品的充值间隔,见配置ChargeDelayTime  | 
|   | 
|     //多倍图片  | 
|     public Dictionary<int, string> MultiRechageImageDict = new Dictionary<int, string>();  | 
|     //港台多倍充值要对应不同的充值编号  | 
|     public Dictionary<int, List<string>> MultiOrderInfoDict = new Dictionary<int, List<string>>();  | 
|     private void ParseConfig()  | 
|     {  | 
|   | 
|         var textConfig = FuncConfigConfig.Get("MultiRechageImage");  | 
|         var json = JsonMapper.ToObject(textConfig.Numerical1);  | 
|         foreach (var key in json.Keys)  | 
|         {  | 
|             var multi = int.Parse(key);  | 
|             MultiRechageImageDict[multi] = json[key].ToString();  | 
|         }  | 
|   | 
|         //多倍充值对应不同编号  | 
|         var _json = JsonMapper.ToObject(textConfig.Numerical2);  | 
|         foreach (var _key in _json.Keys)  | 
|         {  | 
|             var _type = int.Parse(_key);  | 
|   | 
|             MultiOrderInfoDict.Add(_type, new List<string>(JsonMapper.ToObject<string[]>(_json[_key].ToJson()))); ;  | 
|         }  | 
|   | 
|         var cfg = FuncConfigConfig.Get("DaiJQCTG");  | 
|         voucherCTGList = JsonMapper.ToObject<List<int>>(cfg.Numerical1);  | 
|     }  | 
|   | 
|       | 
|     Dictionary<int, int> fightPowerDict = new Dictionary<int, int>();  | 
|     // public int GetTitlePower(int vipLv)  | 
|     // {  | 
|     //     int[] propertys = DienstgradConfig.GetTitleAttrType(vipTitleDic[vipLv]);  | 
|     //     int[] values = DienstgradConfig.GetTitleAttrValue(vipTitleDic[vipLv]);  | 
|     //     fightPowerDict.Clear();  | 
|     //     for (int i = 0; i < propertys.Length; i++)  | 
|     //     {  | 
|     //         fightPowerDict.Add(propertys[i], values[i]);  | 
|     //     }  | 
|     //     return (int)UIHelper.GetFightPower(fightPowerDict);  | 
|     // }  | 
|   | 
|   | 
|     private void ParseCTGConfig()  | 
|     {  | 
|         var configs = OrderInfoConfig.GetValues();  | 
|         m_RechargeGainItemDict = new Dictionary<int, List<Item>>();  | 
|         for (int i = 0; i < configs.Count; i++)  | 
|         {  | 
|             List<OrderInfoConfig> list;  | 
|             if (!m_OrderInfoDict.TryGetValue(configs[i].AppId, out list))  | 
|             {  | 
|                 list = new List<OrderInfoConfig>();  | 
|                 m_OrderInfoDict.Add(configs[i].AppId, list);  | 
|             }  | 
|             list.Add(configs[i]);  | 
|   | 
| #if UNITY_EDITOR  | 
|             orderInfoToCTGID[configs[i].OrderInfo] = configs[i].CTGID;  | 
| #else  | 
|             if (configs[i].AppId == VersionConfig.Get().appId)  | 
|             {   | 
|                 orderInfoToCTGID[configs[i].OrderInfo] = configs[i].CTGID;  | 
|             }  | 
| #endif  | 
|             if (configs[i].CTGID == 0)  | 
|             {  | 
|                 continue;  | 
|             }  | 
|             List<int> _list = null;  | 
|             if (!m_CTGConfigDict.TryGetValue(configs[i].AppId, out _list))  | 
|             {  | 
|                 _list = new List<int>();  | 
|                 m_CTGConfigDict.Add(configs[i].AppId, _list);  | 
|             }  | 
|             //港台存在多个orderinfo对应同一个ctgid的情况  | 
|             if (!_list.Contains(configs[i].CTGID))  | 
|             {  | 
|                 _list.Add(configs[i].CTGID);  | 
|             }  | 
|             if (!m_RechargeGainItemDict.ContainsKey(configs[i].CTGID))  | 
|             {  | 
| #if UNITY_EDITOR  | 
|                 try  | 
|                 {  | 
| #endif  | 
|                     var ctg = CTGConfig.Get(configs[i].CTGID);  | 
|                     var _itemArray = LitJson.JsonMapper.ToObject<int[][]>(ctg.GainItemList);  | 
|                     if (_itemArray != null && _itemArray.Length > 0)  | 
|                     {  | 
|                         var _itemList = new List<Item>();  | 
|                         m_RechargeGainItemDict.Add(configs[i].CTGID, _itemList);  | 
|                         for (int k = 0; k < _itemArray.Length; k++)  | 
|                         {  | 
|                             Item _item = new Item(_itemArray[k][0], _itemArray[k][1]);  | 
|                             _itemList.Add(_item);  | 
|                         }  | 
|                     }  | 
| #if UNITY_EDITOR  | 
|                 }  | 
|                 catch (Exception e)  | 
|                 {  | 
|                     Debug.LogError("错误的 充值商品ctgid = " + configs[i].CTGID + e);  | 
|                 }  | 
| #endif  | 
|             }  | 
|         }  | 
|     }  | 
|   | 
|     public List<int> GetCTGConfigs(string _appid)  | 
|     {  | 
|         if (m_CTGConfigDict.ContainsKey(_appid))  | 
|         {  | 
|             return m_CTGConfigDict[_appid];  | 
|         }  | 
|         return m_CTGConfigDict.Values.Last();  | 
|     }  | 
|   | 
|     //外部调用不可以修改list  | 
|     public bool TryGetRechargeItem(int id, out List<Item> list)  | 
|     {  | 
|         return m_RechargeGainItemDict.TryGetValue(id, out list);  | 
|     }  | 
|   | 
|       | 
|   | 
|   | 
|     private Dictionary<int, Dictionary<int, List<Item>>> m_FirstChargeItemDict = new Dictionary<int, Dictionary<int, List<Item>>>();  | 
|     public Dictionary<int, List<Item>> m_FirstChargeCommonItemDict = new Dictionary<int, List<Item>>();  | 
|     private void ParseFirstCharge()  | 
|     {  | 
|         foreach (var day in FirstGoldConfig.GetKeys())  | 
|         {  | 
|             if (!m_FirstChargeItemDict.ContainsKey(day))  | 
|             {  | 
|                 Dictionary<int, List<Item>> JobItems = new Dictionary<int, List<Item>>();  | 
|                 m_FirstChargeItemDict[day] = JobItems;  | 
|             }  | 
|             var config = FirstGoldConfig.Get(day);  | 
|             var _itemJson = JsonMapper.ToObject(config.JobItemInfo);  | 
|             foreach (var jobstr in _itemJson.Keys)  | 
|             {  | 
|                 var job = int.Parse(jobstr);  | 
|                 if (!m_FirstChargeItemDict[day].ContainsKey(job))  | 
|                 {  | 
|                     List<Item> JobItems = new List<Item>();  | 
|                     m_FirstChargeItemDict[day][job] = JobItems;  | 
|                 }  | 
|   | 
|                 for (int i = 0; i < _itemJson[jobstr].Count; i++)  | 
|                 {  | 
|                     m_FirstChargeItemDict[day][job].Add(new Item(int.Parse(_itemJson[jobstr][i][0].ToString()),  | 
|                         long.Parse(_itemJson[jobstr][i][1].ToString())));  | 
|                 }  | 
|             }  | 
|   | 
|             if (!m_FirstChargeCommonItemDict.ContainsKey(day))  | 
|             {  | 
|                 List<Item> ItemsComm = new List<Item>();  | 
|                 m_FirstChargeCommonItemDict[day] = ItemsComm;  | 
|             }  | 
|             var _itemCommon = JsonMapper.ToObject<int[][]>(config.CommItemList);  | 
|             for (int i = 0; i < _itemCommon.Length; i++)  | 
|             {  | 
|                 m_FirstChargeCommonItemDict[day].Add(new Item(_itemCommon[i][0], _itemCommon[i][1]));  | 
|             }  | 
|   | 
|   | 
|         }  | 
|     }  | 
|   | 
|     public bool TryGetFirstReward(int day, int _job, out List<Item> _list)  | 
|     {  | 
|         List<Item> newItems = new List<Item>();  | 
|         newItems.Clear();  | 
|         if (m_FirstChargeItemDict.ContainsKey(day) && m_FirstChargeItemDict[day].ContainsKey(_job))  | 
|         {  | 
|             newItems.AddRange(m_FirstChargeItemDict[day][_job]);  | 
|         }  | 
|         newItems.AddRange(m_FirstChargeCommonItemDict[day]);  | 
|         _list = newItems;  | 
|         return true;  | 
|     }  | 
|   | 
|   | 
|     #endregion  | 
|   | 
|       | 
|   | 
|     #region 充值  | 
|     public Dictionary<int, List<Item>> m_RechargeGainItemDict { get; private set; }  | 
|     private Dictionary<int, RechargeCount> m_RechargeCountDict = new Dictionary<int, RechargeCount>();  | 
|     Dictionary<string, List<OrderInfoConfig>> m_OrderInfoDict = new Dictionary<string, List<OrderInfoConfig>>();  | 
|     public Dictionary<string, int> orderInfoToCTGID = new Dictionary<string, int>();  | 
|   | 
|     public int presentSelectRechargeId { get; private set; }  | 
|     public bool beforeRecharge { get; private set; }  | 
|     private DateTime beforeCTGTime = DateTime.Now;  | 
|     private Redpoint rechargeRedpoint = new Redpoint(21);  | 
|     public Redpoint firstRechargeRedpoint = new Redpoint(210000);//首充领取红点  | 
|     public Redpoint rechargeFuncRedpoint = new Redpoint(21, 2101);  | 
|     public Redpoint rechargeGiftRedpoint = new Redpoint(2101, 210101);//18元礼包  | 
|   | 
|     public bool TryGetOrderInfo(int _id, out OrderInfoConfig config)  | 
|     {  | 
|         config = null;  | 
|         if (_id == 0)  | 
|         {  | 
|             return false;  | 
|         }  | 
|         List<OrderInfoConfig> list;  | 
|         if (m_OrderInfoDict.TryGetValue(VersionConfig.Get().appId, out list))  | 
|         {  | 
|             for (int i = 0; i < list.Count; i++)  | 
|             {  | 
|                 if (list[i].CTGID == _id)  | 
|                 {  | 
|                     config = list[i];  | 
|                     return true;  | 
|                 }  | 
|             }  | 
|         }  | 
|         return false;  | 
|     }  | 
|   | 
|     //港台版本比较特殊同一个CTGID 有多个OrderInfo  | 
|     //暂且只用到首充多倍的区分  | 
|     public bool TryGetOrderInfoList(int _id, out List<OrderInfoConfig> configs)  | 
|     {  | 
|         configs = new List<OrderInfoConfig>();  | 
|         bool result = false;  | 
|         if (_id == 0)  | 
|         {  | 
|             return result;  | 
|         }  | 
|         List<OrderInfoConfig> list;  | 
|         if (m_OrderInfoDict.TryGetValue(VersionConfig.Get().appId, out list))  | 
|         {  | 
|             for (int i = 0; i < list.Count; i++)  | 
|             {  | 
|                 if (list[i].CTGID == _id)  | 
|                 {  | 
|                     configs.Add(list[i]);  | 
|                     result = true;  | 
|                 }  | 
|             }  | 
|         }  | 
|         return result;  | 
|     }  | 
|   | 
|     public bool TryGetOrderInfoByOrderInfo(string orderInfo, out OrderInfoConfig config)  | 
|     {  | 
|         config = null;  | 
|         List<OrderInfoConfig> list;  | 
|         if (m_OrderInfoDict.TryGetValue(VersionConfig.Get().appId, out list))  | 
|         {  | 
|             for (int i = 0; i < list.Count; i++)  | 
|             {  | 
|                 if (list[i].OrderInfo == orderInfo)  | 
|                 {  | 
|                     config = list[i];  | 
|                     return true;  | 
|                 }  | 
|             }  | 
|         }  | 
|         return false;  | 
|     }  | 
|   | 
|   | 
|     public float GetOnSalePayRmb(int _id)  | 
|     {  | 
|         var appid = VersionConfig.Get().appId;  | 
|         appid = m_CTGConfigDict.ContainsKey(appid) ? appid : m_CTGConfigDict.Keys.Last();  | 
|         var configs = OrderInfoConfig.GetValues();  | 
|         for (int i = 0; i < configs.Count; i++)  | 
|         {  | 
|             if (configs[i].AppId.Equals(appid)  | 
|                 && configs[i].CTGID == _id)  | 
|             {  | 
|                 return configs[i].PayRMBNumOnSale;  | 
|             }  | 
|         }  | 
|         return 0;  | 
|     }  | 
|   | 
|     public float GetOrgPayRmb(int _id)  | 
|     {  | 
|         var appid = VersionConfig.Get().appId;  | 
|         appid = m_CTGConfigDict.ContainsKey(appid) ? appid : m_CTGConfigDict.Keys.Last();  | 
|         var configs = OrderInfoConfig.GetValues();  | 
|         for (int i = 0; i < configs.Count; i++)  | 
|         {  | 
|             if (configs[i].AppId.Equals(appid)  | 
|                 && configs[i].CTGID == _id)  | 
|             {  | 
|                 return configs[i].PayRMBNum;  | 
|             }  | 
|         }  | 
|         return 0;  | 
|     }  | 
|   | 
|     public void CTG(int _id)  | 
|     {  | 
|         OrderInfoConfig orderInfo = null;  | 
|         if (TryGetOrderInfo(_id, out orderInfo))  | 
|         {  | 
|             CTG(orderInfo);  | 
|         }  | 
|     }  | 
|   | 
|       | 
|     public void CTG(OrderInfoConfig config)  | 
|     {  | 
|         if (config == null)  | 
|         {  | 
|             return;  | 
|         }  | 
|         var rechargeConfig = CTGConfig.Get(config.CTGID);  | 
|         if (!VersionConfig.Get().appId.Equals(config.AppId))  | 
|         {  | 
|             return;  | 
|         }  | 
|         if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Recharge))  | 
|         {  | 
|             FuncOpen.Instance.ProcessorFuncErrorTip((int)FuncOpenEnum.Recharge);  | 
|             return;  | 
|         }  | 
|   | 
|         if (rechargeConfig.SelectItemInfo != null && rechargeConfig.SelectItemInfo.Length != 0)  | 
|         {   | 
|             int goodsCount; //固定商品种类数量  | 
|             int goodsSumCount; //商品总数量  | 
|             List<Item> awards = new List<Item>();  | 
|             CustomizedRechargeModel.Instance.TryGetRechargeItemEx(config.CTGID, out awards, out goodsCount, out goodsSumCount);  | 
|   | 
|             //自选礼包没有选全 不能购买  | 
|             if (awards.Count != goodsSumCount)  | 
|             {  | 
|                 SysNotifyMgr.Instance.ShowTip("CustomizedGift02");  | 
|                 return;  | 
|             }  | 
|         }  | 
|   | 
|         if ((DateTime.Now - beforeCTGTime).TotalSeconds < m_CTGDelayTime && !m_ChargeReset)  | 
|         {  | 
|             ScrollTip.ShowTip(Language.Get("RechargeTimesLimit"));  | 
|             return;  | 
|         }  | 
|         if (m_RechargeCountDict.ContainsKey(config.CTGID))  | 
|         {  | 
|             if (rechargeConfig != null)  | 
|             {  | 
|                 if (rechargeConfig.DailyBuyCount > 0 &&  | 
|                 rechargeConfig.DailyBuyCount <= m_RechargeCountDict[config.CTGID].todayCount)  | 
|                 {  | 
|                     ScrollTip.ShowTip(Language.Get("RechargeCountsLimit"));  | 
|                     return;  | 
|                 }  | 
|   | 
|                 if (rechargeConfig.TotalBuyCount > 0 &&  | 
|                     rechargeConfig.TotalBuyCount <= m_RechargeCountDict[config.CTGID].totalCount)  | 
|                 {  | 
|                     return;  | 
|                 }  | 
|             }  | 
|         }  | 
|   | 
|         // 对有限购次数的物品 特别提醒,避免玩家短时间内重复购买限购物品  | 
|         if (rechargeConfig.TotalBuyCount > 0 || rechargeConfig.DailyBuyCount > 0)  | 
|         {  | 
|             if (RechargeTimeLismit.ContainsKey(config.OrderInfo))  | 
|             {  | 
|                 if ((DateTime.Now - RechargeTimeLismit[config.OrderInfo]).TotalSeconds < m_CTGLimitDelayTime)  | 
|                 {  | 
|                     ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("RechargeLimit", rechargeConfig.Title),  | 
|                         (bool isOk) =>  | 
|                         {  | 
|                             if (isOk)  | 
|                             {  | 
|                                 m_ChargeReset = false;  | 
|                                 beforeCTGTime = DateTime.Now;  | 
|                                 // if (!WindowCenter.Instance.IsOpen<GotoChargeWin>())  | 
|                                 // {  | 
|                                 //     WindowCenter.Instance.Open<GotoChargeWin>(true);  | 
|                                 // }  | 
|                                 SDKUtils.Instance.FreePlatformPay(rechargeConfig.Title, config.PayRMBNum, config.OrderInfo);  | 
|   | 
|                                 RechargeTimeLismit[config.OrderInfo] = DateTime.Now;  | 
|                             }  | 
|                             return;  | 
|                         });  | 
|                     return;  | 
|                 }  | 
|             }  | 
|             RechargeTimeLismit[config.OrderInfo] = DateTime.Now;  | 
|         }  | 
|   | 
|   | 
|         m_ChargeReset = false;  | 
|         beforeCTGTime = DateTime.Now;  | 
|         // if (!WindowCenter.Instance.IsOpen<GotoChargeWin>())  | 
|         // {  | 
|         //     WindowCenter.Instance.Open<GotoChargeWin>(true);  | 
|         // }  | 
|         SDKUtils.Instance.FreePlatformPay(rechargeConfig == null ? string.Empty : rechargeConfig.Title, config.PayRMBNum, config.OrderInfo);  | 
|     }  | 
|   | 
|     Dictionary<string, DateTime> RechargeTimeLismit = new Dictionary<string, DateTime>();  | 
|   | 
|   | 
|   | 
|     // 用于服务端通知的商品,充值表里没有配置的,正常都是活动的限购  | 
|     public void OpenFreePlat(string Title, float RMBNum, string OrderInfo)  | 
|     {  | 
|         // 对有限购次数的物品 特别提醒,避免玩家短时间内重复购买限购物品  | 
|         if (RechargeTimeLismit.ContainsKey(OrderInfo))  | 
|         {  | 
|             if ((DateTime.Now - RechargeTimeLismit[OrderInfo]).TotalSeconds < m_CTGLimitDelayTime)  | 
|             {  | 
|                 ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("RechargeLimit", Title),  | 
|                     (bool isOk) =>  | 
|                     {  | 
|                         if (isOk)  | 
|                         {  | 
|                             // if (!WindowCenter.Instance.IsOpen<GotoChargeWin>())  | 
|                             // {  | 
|                             //     WindowCenter.Instance.Open<GotoChargeWin>(true);  | 
|                             // }  | 
|                             SDKUtils.Instance.FreePlatformPay(Title, RMBNum, OrderInfo);  | 
|                             RechargeTimeLismit[OrderInfo] = DateTime.Now;  | 
|                         }  | 
|                         return;  | 
|                     });  | 
|                 return;  | 
|             }  | 
|         }  | 
|         RechargeTimeLismit[OrderInfo] = DateTime.Now;  | 
|   | 
|   | 
|         // if (!WindowCenter.Instance.IsOpen<GotoChargeWin>())  | 
|         // {  | 
|         //     WindowCenter.Instance.Open<GotoChargeWin>(true);  | 
|         // }  | 
|   | 
|         SDKUtils.Instance.FreePlatformPay(Title, RMBNum, OrderInfo);  | 
|   | 
|     }  | 
|   | 
|     public event Action<string> OnCTGStageChange;  | 
|     public void SetCTGDisplay(string _display)  | 
|     {  | 
|         if (OnCTGStageChange != null)  | 
|         {  | 
|             OnCTGStageChange(_display);  | 
|         }  | 
|     }  | 
|   | 
|   | 
|     public void UpdateRechargeCount(HA110_tagMCCoinToGoldCountInfo package)  | 
|     {  | 
|         realRecharge = (int)package.RealTotal;  | 
|         for (int i = 0; i < package.RecordCount; i++)  | 
|         {  | 
|             var _data = package.CTGCountInfoList[i];  | 
|   | 
|             m_RechargeCountDict[_data.RecordID] = new RechargeCount()  | 
|             {  | 
|                 todayCount = _data.TodayPayCount,  | 
|                 totalCount = (int)_data.TotalPayCount,  | 
|                 weekPayCount = _data.WeekPayCount,  | 
|                 monthPayCount = _data.MonthPayCount,  | 
|                 selectItemValue = (int)_data.SelectItemValue,  | 
|             };  | 
|             if (rechargeCountEvent != null)  | 
|             {  | 
|                 rechargeCountEvent(_data.RecordID);  | 
|             }  | 
|         }  | 
|   | 
|         rechargeChangeEvent?.Invoke();  | 
|         UpdateRedpoint();  | 
|     }  | 
|   | 
|     public bool TryGetRechargeCount(int _rechargeId, out RechargeCount _rechargeCount)  | 
|     {  | 
|         return m_RechargeCountDict.TryGetValue(_rechargeId, out _rechargeCount);  | 
|     }  | 
|   | 
|     private bool firstRechargeOpen  | 
|     {  | 
|         get;  | 
|         set;  | 
|     }  | 
|   | 
|     public void AreadyGetFirstRecharge()  | 
|     {  | 
|         if (IsFirstChargeRewardGetByDay())  | 
|         {  | 
|             SysNotifyMgr.Instance.ShowTip("FirstPayAlreadyGet");  | 
|         }  | 
|     }  | 
|   | 
|   | 
|   | 
|     public int FirstGoldServerDay = 0; //0表示未充值,首充时为开服第几天(openday+1)   | 
|   | 
|     int m_FirstChargeRewardGet = 0;  | 
|     public int firstChargeRewardGet  | 
|     {  | 
|         get { return m_FirstChargeRewardGet; }  | 
|         set  | 
|         {  | 
|             m_FirstChargeRewardGet = value;  | 
|             UpdateFirstRechargeRedpoint();  | 
|             if (firstChargeRewardEvent != null)  | 
|             {  | 
|                 firstChargeRewardEvent();  | 
|             }  | 
|         }  | 
|     }  | 
|   | 
|     //是否已领取  | 
|     public bool IsFirstChargeRewardGetByDay(int day = 0)  | 
|     {  | 
|         if (day == 0)  | 
|         {  | 
|             if (m_FirstChargeRewardGet == 7)  | 
|             {  | 
|                 //三天全领取  | 
|                 return true;  | 
|             }  | 
|             return false;  | 
|         }  | 
|   | 
|         if (((int)Math.Pow(2, day - 1) & m_FirstChargeRewardGet) != 0)  | 
|             return true;  | 
|         return false;  | 
|     }  | 
|   | 
|     // 是否可领取,判断实际天  | 
|     public bool CanGetFirstChargeRewardByDay(int day)  | 
|     {  | 
|         if (FirstGoldServerDay == 0)  | 
|             return false;  | 
|   | 
|         if (FirstGoldServerDay + day - 2 <= TimeUtility.OpenDay)  | 
|         {  | 
|             if (!IsFirstChargeRewardGetByDay(day))  | 
|                 return true;  | 
|         }  | 
|         return false;  | 
|     }  | 
|   | 
|     // 获取首充可领取的第一个奖励  | 
|     public int GetFirstChargeRewardIndex()  | 
|     {  | 
|         for (int i = 1; i <= 3; i++)  | 
|         {  | 
|             if (CanGetFirstChargeRewardByDay(i))  | 
|                 return i;  | 
|         }  | 
|         return 0;  | 
|     }  | 
|   | 
|     // public void UpdateFirstChargeReward(HAA02_tagMCFirstGoldInfo package)  | 
|     // {  | 
|     //     FirstGoldServerDay = package.FirstGoldServerDay;  | 
|     //     firstChargeRewardGet = package.FirstGoldRewardState;  | 
|     //     UpdateFirstRechargeRedpoint();  | 
|     //     UpdateRedpoint();  | 
|     // }  | 
|   | 
|     private void UpdateFirstRechargeRedpoint()  | 
|     {  | 
|         firstRechargeRedpoint.state = RedPointState.None;  | 
|         if (FirstGoldServerDay == 0)  | 
|         {  | 
|             if (PlayerDatas.Instance.baseData.LV <= GeneralDefine.rechargeRedpointLv  | 
|                 && PlayerDatas.Instance.baseData.LV >= GeneralDefine.rechargeRedpointMinLv)  | 
|             {  | 
|                 firstRechargeRedpoint.state = RedPointState.Quantity;  | 
|             }  | 
|             return;  | 
|         }  | 
|         firstRechargeRedpoint.state = GetFirstChargeRewardIndex() == 0 ? RedPointState.None : RedPointState.Simple;  | 
|     }  | 
|   | 
|   | 
|   | 
|   | 
|     private void UpdateRedpoint()  | 
|     {  | 
|         if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Recharge))  | 
|         {  | 
|             return;  | 
|         }  | 
|         if (FirstGoldServerDay <= 0 || !IsFirstChargeRewardGetByDay(1))  | 
|         {  | 
|             return;  | 
|         }  | 
|         var list = GetCTGConfigs(VersionConfig.Get().appId);  | 
|         var config = CTGConfig.Get(list[0]);  | 
|         if (m_RechargeCountDict.ContainsKey(config.RecordID))  | 
|         {  | 
|             if (config.DailyBuyCount > 0 &&  | 
|                 config.DailyBuyCount <= m_RechargeCountDict[config.RecordID].todayCount)  | 
|             {  | 
|                 return;  | 
|             }  | 
|         }  | 
|     }  | 
|   | 
|   | 
|   | 
|     private void OnServerOpenDayRefresh()  | 
|     {  | 
|         UpdateRedpoint();  | 
|         UpdateFirstRechargeRedpoint();  | 
|     }  | 
|   | 
|     public void OnPlayerLoginOk()  | 
|     {  | 
|         UpdateFirstRechargeRedpoint();  | 
|         UpdateRedpoint();  | 
|         serverInited = true;  | 
|         beforeRecharge = FirstGoldServerDay > 0;  | 
|     }  | 
|     #endregion  | 
|   | 
|     public void UpdatePlayerRecInfoVoucher(HA008_tagGCPlayerRecInfo pack)  | 
|     {  | 
|         //只处理代金券  | 
|         if (pack.Type != 3) return;  | 
|   | 
|         for (int i = 0; i < pack.Count; i++)  | 
|         {  | 
|             m_PlayerRecsVoucher.Add(pack.PlayerRecList[i]);  | 
|         }  | 
|   | 
|         m_PlayerRecsVoucher.Sort(SortByTime);  | 
|     }  | 
|   | 
|     int SortByTime(HA008_tagGCPlayerRecInfo.tagGCPlayerRec a, HA008_tagGCPlayerRecInfo.tagGCPlayerRec b)  | 
|     {  | 
|         return b.Time.CompareTo(a.Time);  | 
|     }  | 
| }  | 
|   | 
|   | 
| public struct RechargeCount  | 
| {  | 
|     public int todayCount;  | 
|     public int totalCount;  | 
|     public int weekPayCount;  | 
|     public int monthPayCount;  | 
|     public int selectItemValue;  | 
|   | 
| }  |