zhaoyang 2 years ago
parent
commit
c230835291

+ 131 - 176
GameClient/Assets/Game/HotUpdate/Data/ShopDataManager.cs

@@ -10,26 +10,12 @@ namespace GFGGame
     {
         public string[] refreshType = { "永久限购", "每日限购", "每周限购", "每月限购" };
 
-        // private Dictionary<int, int> _rechargeDic = new Dictionary<int, int>();
         private Dictionary<int, int> _goodsDic = new Dictionary<int, int>();
-        // private Dictionary<int, int> _exchangeDic = new Dictionary<int, int>();
         public void Clear()
         {
-            // _rechargeDic.Clear();
             _goodsDic.Clear();
-            // _exchangeDic.Clear();
         }
-        // public void UpdateRechargeData(int rechargeId, int num)
-        // {
-        //     if (!_rechargeDic.ContainsKey(rechargeId))
-        //     {
-        //         _rechargeDic.Add(rechargeId, num);
-        //     }
-        //     else
-        //     {
-        //         _rechargeDic[rechargeId] = num;
-        //     }
-        // }
+
         public void UpdateGiftData(int giftId, int num)
         {
             if (!_goodsDic.ContainsKey(giftId))
@@ -41,17 +27,7 @@ namespace GFGGame
                 _goodsDic[giftId] = num;
             }
         }
-        // public void UpdateExchangeData(int exchangeId, int num)
-        // {
-        //     if (!_exchangeDic.ContainsKey(exchangeId))
-        //     {
-        //         _exchangeDic.Add(exchangeId, num);
-        //     }
-        //     else
-        //     {
-        //         _exchangeDic[exchangeId] = num;
-        //     }
-        // }
+
         /************************************************************************************************************/
 
         public List<ShopCfg> GetList(int storeId, int typeIndex, int scoreType)
@@ -117,15 +93,7 @@ namespace GFGGame
 
 
         /**************************************************************************************************************************/
-        // /// <summary>
-        // /// 根据充值id获取购买次数
-        // /// </summary>
-        // /// <param name="rechargeId"></param>
-        // /// <returns></returns>
-        // public int GetRechargeBuyNumById(int rechargeId)
-        // {
-        //     return !_rechargeDic.ContainsKey(rechargeId) ? 0 : _rechargeDic[rechargeId];
-        // }
+
         /// <summary>
         /// 根据商品id获取购买次数
         /// </summary>
@@ -135,33 +103,20 @@ namespace GFGGame
         {
             return !_goodsDic.ContainsKey(goodsId) ? 0 : _goodsDic[goodsId];
         }
-        // /// <summary>
-        // /// 根据充值id获取购买次数
-        // /// </summary>
-        // /// <param name="exchangeId"></param>
-        // /// <returns></returns>
-        // public int GetExchangeBuyNumById(int exchangeId)
-        // {
-        //     return !_exchangeDic.ContainsKey(exchangeId) ? 0 : _exchangeDic[exchangeId];
-        // }
-
 
-        public List<GiftBagCfg> GetGiftBagCfgs()
+        //移除未上架商品
+        public List<ShopCfg> RemoveNotOpenCfg(List<ShopCfg> shop)
         {
-            // List<GiftBagCfg> giftBagCfgs = new List<GiftBagCfg>();
-
-            // List<GiftBagCfg> noneGiftBagCfgs = GetNoneGiftCfg();
-            // giftBagCfgs = giftBagCfgs.Concat(noneGiftBagCfgs).ToList<GiftBagCfg>();
-
-            // GiftBagCfg StoryLvGiftCfg = GetStoryLvGiftCfg();
-            // if (StoryLvGiftCfg != null) giftBagCfgs.Add(StoryLvGiftCfg);
-            // GiftBagCfg RoleLvGiftCfg = GetRoleLvGiftCfg();
-            // if (RoleLvGiftCfg != null) giftBagCfgs.Add(RoleLvGiftCfg);
-            // giftBagCfgs = RemoveNotOpenCfg(giftBagCfgs);
-            // SortGiftBagCfgs(giftBagCfgs);
-            // return giftBagCfgs;
-            return null;
+            for (int i = shop.Count - 1; i >= 0; i--)
+            {
+                if (!string.IsNullOrEmpty(shop[i].startTime) && !TimeUtil.IsBeforeCurTime(shop[i].startTime) || !string.IsNullOrEmpty(shop[i].endTime) && !TimeUtil.IsLaterCurTime(shop[i].endTime))
+                {
+                    shop.RemoveAt(i);
+                }
+            }
+            return shop;
         }
+        //商品排序
         public List<ShopCfg> SortShopGoodsCfgs(List<ShopCfg> shopCfgs)
         {
             shopCfgs.Sort((ShopCfg a, ShopCfg b) =>
@@ -176,6 +131,7 @@ namespace GFGGame
             });
             return shopCfgs;
         }
+        //获取商店所有消耗品id列表
         public List<int> GetShopCostIds(List<ShopCfg> shopCfgs)
         {
             List<int> costIds = new List<int>();
@@ -189,123 +145,6 @@ namespace GFGGame
             }
             return costIds;
         }
-        // public List<ShopCfg> SortGiftBagCfgs(List<ShopCfg> shopCfgs)
-        // {
-        //     shopCfgs.Sort((ShopCfg a, ShopCfg b) =>
-        //     {
-
-        //         //未售罄的>未解锁>已售罄的
-        //         int buyTypeA = (a.maxBuyNum == 0 || a.maxBuyNum - GetGoodsBuyNumById(a.id) > 0) ? 1 : -1;
-        //         int buyTypeB = (b.maxBuyNum == 0 || b.maxBuyNum - GetGoodsBuyNumById(b.id) > 0) ? 1 : -1;
-        //         if (buyTypeA > buyTypeB) return -1;
-        //         if (buyTypeA < buyTypeB) return 1;
-
-        //         //解锁状态
-        //         int lockA = GetShopGoodsStateById(a.id) ? 1 : -1;
-        //         int lockB = GetShopGoodsStateById(b.id) ? 1 : -1;
-        //         if (lockA > lockB) return -1;
-        //         if (lockA < lockB) return 1;
-
-        //         //免费>钻石>现金>道具
-        //         if (a.costType < b.costType) return -1;
-        //         if (a.costType > b.costType) return 1;
-
-        //         //有下架时间的 > 没有下架时间的
-        //         int endTimeA = a.endTime != "" ? 1 : -1;
-        //         int endTimeB = b.endTime != "" ? 1 : -1;
-        //         if (endTimeA > endTimeB) return -1;
-        //         if (endTimeA < endTimeB) return 1;
-
-
-        //         //折扣打的>折扣小的
-        //         int disCountA = GetShopGoodsDiscount(a.id);
-        //         int disCountB = GetShopGoodsDiscount(b.id);
-        //         if (disCountA > disCountB) return -1;
-        //         if (disCountA < disCountB) return 1;
-
-        //         //价格低的>价格高的
-        //         if (a.price != b.price) return a.price - b.price;
-
-
-        //         return 0;
-        //     });
-        //     return shopCfgs;
-        // }
-        //获取商品折扣百分比
-        public int GetShopGoodsDiscount(int goodsId)
-        {
-            ShopCfg shopCfg = ShopCfgArray.Instance.GetCfg(goodsId);
-            if (shopCfg.price == 0) return 0;
-            return (int)(((double)shopCfg.originalPrice / (double)shopCfg.price) * 100);
-        }
-        private List<GiftBagCfg> RemoveNotOpenCfg(List<GiftBagCfg> giftBagCfgs)
-        {
-            for (int i = giftBagCfgs.Count - 1; i >= 0; i--)
-            {
-                if (giftBagCfgs[i].startTime != "" && !TimeUtil.IsBeforeCurTime(giftBagCfgs[i].startTime) || giftBagCfgs[i].endTime != "" && !TimeUtil.IsLaterCurTime(giftBagCfgs[i].endTime))
-                {
-                    giftBagCfgs.RemoveAt(i);
-                }
-            }
-            return giftBagCfgs;
-        }
-        private List<GiftBagCfg> GetNoneGiftCfg()
-        {
-            List<GiftBagCfg> giftBagCfgs = new List<GiftBagCfg>(GiftBagCfgArray.Instance.GetCfgsBylockType(LockType.NONE));
-
-            return giftBagCfgs;
-        }
-        private GiftBagCfg GetStoryLvGiftCfg()
-        {
-            List<GiftBagCfg> giftBagCfgs = GiftBagCfgArray.Instance.GetCfgsBylockType(LockType.STORY_LV);
-            if (giftBagCfgs.Count == 0) return null;
-            giftBagCfgs.Sort((GiftBagCfg a, GiftBagCfg b) =>
-            {
-                if (a.storyLevelId.CompareTo(b.storyLevelId) != 0)
-                {
-                    return a.storyLevelId.CompareTo(b.storyLevelId);
-                }
-                return -1;
-            });
-            for (int i = 0; i < giftBagCfgs.Count; i++)
-            {
-                if (GetShopGoodsStateById(giftBagCfgs[i].id) && (GetGoodsBuyNumById(giftBagCfgs[i].id) < giftBagCfgs[i].maxBuyNum)) return giftBagCfgs[i];
-            }
-            return giftBagCfgs[0];
-        }
-        private GiftBagCfg GetRoleLvGiftCfg()
-        {
-            List<GiftBagCfg> giftBagCfgs = GiftBagCfgArray.Instance.GetCfgsBylockType(LockType.ROLE_LV);
-            if (giftBagCfgs.Count == 0) return null;
-            giftBagCfgs.Sort((GiftBagCfg a, GiftBagCfg b) =>
-            {
-                if (a.lv.CompareTo(b.lv) != 0)
-                {
-                    return a.lv.CompareTo(b.lv);
-                }
-                return -1;
-            });
-            for (int i = 0; i < giftBagCfgs.Count; i++)
-            {
-                if (GetShopGoodsStateById(giftBagCfgs[i].id) && (GetGoodsBuyNumById(giftBagCfgs[i].id) < giftBagCfgs[i].maxBuyNum)) return giftBagCfgs[i];
-            }
-            return giftBagCfgs[0];
-        }
-
-        // public List<ShopExchangeCfg> GetExchangeCfgs()
-        // {
-        //     List<ShopExchangeCfg> shopExchangeCfgs = new List<ShopExchangeCfg>(ShopExchangeCfgArray.Instance.dataArray);
-        //     shopExchangeCfgs.Sort((ShopExchangeCfg a, ShopExchangeCfg b) =>
-        //     {
-        //         //未售罄的>已售罄的
-        //         int buyTypeA = (a.maxLimit == 0 || a.maxLimit - GetExchangeBuyNumById(a.id) > 0) ? 1 : -1;
-        //         int buyTypeB = (b.maxLimit == 0 || b.maxLimit - GetExchangeBuyNumById(b.id) > 0) ? 1 : -1;
-        //         if (buyTypeA > buyTypeB) return -1;
-        //         if (buyTypeA < buyTypeB) return 1;
-        //         return 0;
-        //     });
-        //     return shopExchangeCfgs;
-        // }
         /// <summary>
         /// 根据商品Id获取商品是否已解锁
         /// /// </summary>
@@ -392,5 +231,121 @@ namespace GFGGame
             endTime = TimeUtil.DateTimeToTimestamp(cfg.endTime);
             return TimeUtil.FormattingTime(TimeHelper.ServerNow(), endTime);
         }
+
+        //获取商品折扣百分比
+        public int GetShopGoodsDiscount(int goodsId)
+        {
+            ShopCfg shopCfg = ShopCfgArray.Instance.GetCfg(goodsId);
+            if (shopCfg.price == 0) return 0;
+            return (int)(((double)shopCfg.originalPrice / (double)shopCfg.price) * 100);
+        }
+
+
+
+
+        // public List<ShopCfg> SortGiftBagCfgs(List<ShopCfg> shopCfgs)
+        // {
+        //     shopCfgs.Sort((ShopCfg a, ShopCfg b) =>
+        //     {
+
+        //         //未售罄的>未解锁>已售罄的
+        //         int buyTypeA = (a.maxBuyNum == 0 || a.maxBuyNum - GetGoodsBuyNumById(a.id) > 0) ? 1 : -1;
+        //         int buyTypeB = (b.maxBuyNum == 0 || b.maxBuyNum - GetGoodsBuyNumById(b.id) > 0) ? 1 : -1;
+        //         if (buyTypeA > buyTypeB) return -1;
+        //         if (buyTypeA < buyTypeB) return 1;
+
+        //         //解锁状态
+        //         int lockA = GetShopGoodsStateById(a.id) ? 1 : -1;
+        //         int lockB = GetShopGoodsStateById(b.id) ? 1 : -1;
+        //         if (lockA > lockB) return -1;
+        //         if (lockA < lockB) return 1;
+
+        //         //免费>钻石>现金>道具
+        //         if (a.costType < b.costType) return -1;
+        //         if (a.costType > b.costType) return 1;
+
+        //         //有下架时间的 > 没有下架时间的
+        //         int endTimeA = a.endTime != "" ? 1 : -1;
+        //         int endTimeB = b.endTime != "" ? 1 : -1;
+        //         if (endTimeA > endTimeB) return -1;
+        //         if (endTimeA < endTimeB) return 1;
+
+
+        //         //折扣打的>折扣小的
+        //         int disCountA = GetShopGoodsDiscount(a.id);
+        //         int disCountB = GetShopGoodsDiscount(b.id);
+        //         if (disCountA > disCountB) return -1;
+        //         if (disCountA < disCountB) return 1;
+
+        //         //价格低的>价格高的
+        //         if (a.price != b.price) return a.price - b.price;
+
+
+        //         return 0;
+        //     });
+        //     return shopCfgs;
+        // }
+
+
+        // private List<GiftBagCfg> GetNoneGiftCfg()
+        // {
+        //     List<GiftBagCfg> giftBagCfgs = new List<GiftBagCfg>(GiftBagCfgArray.Instance.GetCfgsBylockType(LockType.NONE));
+
+        //     return giftBagCfgs;
+        // }
+        // private GiftBagCfg GetStoryLvGiftCfg()
+        // {
+        //     List<GiftBagCfg> giftBagCfgs = GiftBagCfgArray.Instance.GetCfgsBylockType(LockType.STORY_LV);
+        //     if (giftBagCfgs.Count == 0) return null;
+        //     giftBagCfgs.Sort((GiftBagCfg a, GiftBagCfg b) =>
+        //     {
+        //         if (a.storyLevelId.CompareTo(b.storyLevelId) != 0)
+        //         {
+        //             return a.storyLevelId.CompareTo(b.storyLevelId);
+        //         }
+        //         return -1;
+        //     });
+        //     for (int i = 0; i < giftBagCfgs.Count; i++)
+        //     {
+        //         if (GetShopGoodsStateById(giftBagCfgs[i].id) && (GetGoodsBuyNumById(giftBagCfgs[i].id) < giftBagCfgs[i].maxBuyNum)) return giftBagCfgs[i];
+        //     }
+        //     return giftBagCfgs[0];
+        // }
+        // private GiftBagCfg GetRoleLvGiftCfg()
+        // {
+        //     List<GiftBagCfg> giftBagCfgs = GiftBagCfgArray.Instance.GetCfgsBylockType(LockType.ROLE_LV);
+        //     if (giftBagCfgs.Count == 0) return null;
+        //     giftBagCfgs.Sort((GiftBagCfg a, GiftBagCfg b) =>
+        //     {
+        //         if (a.lv.CompareTo(b.lv) != 0)
+        //         {
+        //             return a.lv.CompareTo(b.lv);
+        //         }
+        //         return -1;
+        //     });
+        //     for (int i = 0; i < giftBagCfgs.Count; i++)
+        //     {
+        //         if (GetShopGoodsStateById(giftBagCfgs[i].id) && (GetGoodsBuyNumById(giftBagCfgs[i].id) < giftBagCfgs[i].maxBuyNum)) return giftBagCfgs[i];
+        //     }
+        //     return giftBagCfgs[0];
+        // }
+
+        // public List<ShopExchangeCfg> GetExchangeCfgs()
+        // {
+        //     List<ShopExchangeCfg> shopExchangeCfgs = new List<ShopExchangeCfg>(ShopExchangeCfgArray.Instance.dataArray);
+        //     shopExchangeCfgs.Sort((ShopExchangeCfg a, ShopExchangeCfg b) =>
+        //     {
+        //         //未售罄的>已售罄的
+        //         int buyTypeA = (a.maxLimit == 0 || a.maxLimit - GetExchangeBuyNumById(a.id) > 0) ? 1 : -1;
+        //         int buyTypeB = (b.maxLimit == 0 || b.maxLimit - GetExchangeBuyNumById(b.id) > 0) ? 1 : -1;
+        //         if (buyTypeA > buyTypeB) return -1;
+        //         if (buyTypeA < buyTypeB) return 1;
+        //         return 0;
+        //     });
+        //     return shopExchangeCfgs;
+        // }
+
+
+
     }
 }

+ 0 - 9
GameClient/Assets/Game/HotUpdate/Data/ShopViewManager.cs

@@ -126,15 +126,6 @@ namespace GFGGame
                 return;
             }
 
-            // if (cfg.costType == CostType.RMB)
-            // {
-            //     if (!AntiAddictionController.CheckAntiAddictionRecharge(cfg.price))
-            //     {
-            //         ShopSProxy.ReqShopBuy(cfg.id, 1).Coroutine();
-            //         LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);
-            //     }
-            // }
-            // else 
             if (cfg.costType == CostType.FREE)
             {
                 ShopSProxy.ReqShopBuy(cfg.id, 1).Coroutine();

+ 1 - 0
GameClient/Assets/Game/HotUpdate/Views/Store/StoreArenaView.cs

@@ -49,6 +49,7 @@ namespace GFGGame
             base.OnShown();
             int menu2 = (int)this.viewData;
             _shopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.STORE_ARENA, menu2);
+            _shopCfgs = ShopDataManager.Instance.RemoveNotOpenCfg(_shopCfgs);
             _valueBarController.OnShown();
             _valueBarController.UpdateList(ShopDataManager.Instance.GetShopCostIds(_shopCfgs));
             UpdateView();

+ 1 - 0
GameClient/Assets/Game/HotUpdate/Views/Store/StoreExchangeView.cs

@@ -49,6 +49,7 @@ namespace GFGGame
             base.OnShown();
             int menu2 = (int)this.viewData;
             _shopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.STORE_EXCHANGE, menu2);
+            _shopCfgs = ShopDataManager.Instance.RemoveNotOpenCfg(_shopCfgs);
             _valueBarController.OnShown();
             _valueBarController.UpdateList(ShopDataManager.Instance.GetShopCostIds(_shopCfgs));
             UpdateView();

+ 1 - 0
GameClient/Assets/Game/HotUpdate/Views/Store/StoreGiftBagView.cs

@@ -49,6 +49,7 @@ namespace GFGGame
             base.OnShown();
             int menu2 = (int)this.viewData;
             _shopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.STORE_GIFT_BAG, menu2);
+            _shopCfgs = ShopDataManager.Instance.RemoveNotOpenCfg(_shopCfgs);
             _valueBarController.OnShown();
             _valueBarController.UpdateList(ShopDataManager.Instance.GetShopCostIds(_shopCfgs));
             UpdateView();

+ 2 - 0
GameClient/Assets/Game/HotUpdate/Views/Store/StoreMonthView.cs

@@ -74,6 +74,8 @@ namespace GFGGame
         {
             int menu2 = (int)this.viewData;
             _shopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.STORE_MONTH_CARD, menu2);
+            _shopCfgs = ShopDataManager.Instance.RemoveNotOpenCfg(_shopCfgs);
+            _shopCfgs = ShopDataManager.Instance.SortShopGoodsCfgs(_shopCfgs);
             _ui.m_list.numItems = _shopCfgs.Count;
 
             MonthlyCardPrivilegeCfg privilegeCfg = MonthlyCardPrivilegeCfgArray.Instance.GetCfg(MonthCardPrivilegeType.Privilege1);