|
@@ -5,66 +5,53 @@ using ET;
|
|
|
|
|
|
namespace GFGGame
|
|
namespace GFGGame
|
|
{
|
|
{
|
|
- public class LockType
|
|
|
|
- {
|
|
|
|
- public static int NONE = 0;
|
|
|
|
- public static int STORY_LV = 1;
|
|
|
|
- public static int ROLE_LV = 2;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public class CostType
|
|
|
|
- {
|
|
|
|
- public static int FREE = 0;
|
|
|
|
- public static int ITEM = 1;
|
|
|
|
- public static int RMB = 2;
|
|
|
|
- }
|
|
|
|
|
|
|
|
public class ShopDataManager : SingletonBase<ShopDataManager>
|
|
public class ShopDataManager : SingletonBase<ShopDataManager>
|
|
{
|
|
{
|
|
public string[] refreshType = { "永久限购", "每日限购", "每周限购", "每月限购" };
|
|
public string[] refreshType = { "永久限购", "每日限购", "每周限购", "每月限购" };
|
|
|
|
|
|
- private Dictionary<int, int> _rechargeDic = new Dictionary<int, int>();
|
|
|
|
- private Dictionary<int, int> _giftDic = new Dictionary<int, int>();
|
|
|
|
- private Dictionary<int, int> _exchangeDic = new Dictionary<int, int>();
|
|
|
|
|
|
+ // 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()
|
|
public void Clear()
|
|
{
|
|
{
|
|
- _rechargeDic.Clear();
|
|
|
|
- _giftDic.Clear();
|
|
|
|
- _exchangeDic.Clear();
|
|
|
|
- }
|
|
|
|
- public void UpdateRechargeData(int rechargeId, int num)
|
|
|
|
- {
|
|
|
|
- if (!_rechargeDic.ContainsKey(rechargeId))
|
|
|
|
- {
|
|
|
|
- _rechargeDic.Add(rechargeId, num);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- _rechargeDic[rechargeId] = num;
|
|
|
|
- }
|
|
|
|
|
|
+ // _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)
|
|
public void UpdateGiftData(int giftId, int num)
|
|
{
|
|
{
|
|
- if (!_giftDic.ContainsKey(giftId))
|
|
|
|
- {
|
|
|
|
- _giftDic.Add(giftId, num);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- _giftDic[giftId] = num;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- public void UpdateExchangeData(int exchangeId, int num)
|
|
|
|
- {
|
|
|
|
- if (!_exchangeDic.ContainsKey(exchangeId))
|
|
|
|
|
|
+ if (!_goodsDic.ContainsKey(giftId))
|
|
{
|
|
{
|
|
- _exchangeDic.Add(exchangeId, num);
|
|
|
|
|
|
+ _goodsDic.Add(giftId, num);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- _exchangeDic[exchangeId] = num;
|
|
|
|
|
|
+ _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)
|
|
public List<ShopCfg> GetList(int storeId, int typeIndex, int scoreType)
|
|
@@ -130,65 +117,66 @@ namespace GFGGame
|
|
|
|
|
|
|
|
|
|
/**************************************************************************************************************************/
|
|
/**************************************************************************************************************************/
|
|
|
|
+ // /// <summary>
|
|
|
|
+ // /// 根据充值id获取购买次数
|
|
|
|
+ // /// </summary>
|
|
|
|
+ // /// <param name="rechargeId"></param>
|
|
|
|
+ // /// <returns></returns>
|
|
|
|
+ // public int GetRechargeBuyNumById(int rechargeId)
|
|
|
|
+ // {
|
|
|
|
+ // return !_rechargeDic.ContainsKey(rechargeId) ? 0 : _rechargeDic[rechargeId];
|
|
|
|
+ // }
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// 根据充值id获取购买次数
|
|
|
|
|
|
+ /// 根据商品id获取购买次数
|
|
/// </summary>
|
|
/// </summary>
|
|
- /// <param name="rechargeId"></param>
|
|
|
|
|
|
+ /// <param name="goodsId"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- public int GetRechargeBuyNumById(int rechargeId)
|
|
|
|
|
|
+ public int GetGoodsBuyNumById(int goodsId)
|
|
{
|
|
{
|
|
- return !_rechargeDic.ContainsKey(rechargeId) ? 0 : _rechargeDic[rechargeId];
|
|
|
|
- }
|
|
|
|
- /// <summary>
|
|
|
|
- /// 根据礼包id获取购买次数
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="giftId"></param>
|
|
|
|
- /// <returns></returns>
|
|
|
|
- public int GetGiftBuyNumById(int giftId)
|
|
|
|
- {
|
|
|
|
- return !_giftDic.ContainsKey(giftId) ? 0 : _giftDic[giftId];
|
|
|
|
- }
|
|
|
|
- /// <summary>
|
|
|
|
- /// 根据充值id获取购买次数
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="exchangeId"></param>
|
|
|
|
- /// <returns></returns>
|
|
|
|
- public int GetExchangeBuyNumById(int exchangeId)
|
|
|
|
- {
|
|
|
|
- return !_exchangeDic.ContainsKey(exchangeId) ? 0 : _exchangeDic[exchangeId];
|
|
|
|
|
|
+ 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<GiftBagCfg> GetGiftBagCfgs()
|
|
{
|
|
{
|
|
- List<GiftBagCfg> giftBagCfgs = new List<GiftBagCfg>();
|
|
|
|
|
|
+ // List<GiftBagCfg> giftBagCfgs = new List<GiftBagCfg>();
|
|
|
|
|
|
- List<GiftBagCfg> noneGiftBagCfgs = GetNoneGiftCfg();
|
|
|
|
- giftBagCfgs = giftBagCfgs.Concat(noneGiftBagCfgs).ToList<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;
|
|
|
|
|
|
+ // 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;
|
|
}
|
|
}
|
|
|
|
|
|
- private List<GiftBagCfg> SortGiftBagCfgs(List<GiftBagCfg> giftBagCfgs)
|
|
|
|
|
|
+ public List<ShopCfg> SortGiftBagCfgs(List<ShopCfg> shopCfgs)
|
|
{
|
|
{
|
|
- giftBagCfgs.Sort((GiftBagCfg a, GiftBagCfg b) =>
|
|
|
|
|
|
+ shopCfgs.Sort((ShopCfg a, ShopCfg b) =>
|
|
{
|
|
{
|
|
|
|
|
|
//未售罄的>未解锁>已售罄的
|
|
//未售罄的>未解锁>已售罄的
|
|
- int buyTypeA = (a.maxBuyNum == 0 || a.maxBuyNum - GetGiftBuyNumById(a.id) > 0) ? 1 : -1;
|
|
|
|
- int buyTypeB = (b.maxBuyNum == 0 || b.maxBuyNum - GetGiftBuyNumById(b.id) > 0) ? 1 : -1;
|
|
|
|
|
|
+ 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;
|
|
if (buyTypeA < buyTypeB) return 1;
|
|
if (buyTypeA < buyTypeB) return 1;
|
|
|
|
|
|
//解锁状态
|
|
//解锁状态
|
|
- int lockA = GetGiftStateById(a.id) ? 1 : -1;
|
|
|
|
- int lockB = GetGiftStateById(b.id) ? 1 : -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 (lockA < lockB) return 1;
|
|
if (lockA < lockB) return 1;
|
|
|
|
|
|
@@ -204,16 +192,23 @@ namespace GFGGame
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- int descA = a.desc == "" ? 0 : int.Parse(a.desc);
|
|
|
|
- int descB = b.desc == "" ? 0 : int.Parse(b.desc);
|
|
|
|
- if (descA != descB) return descA - descB;
|
|
|
|
|
|
+ int disCountA = GetShopGoodsDiscount(a.id);
|
|
|
|
+ int disCountB = GetShopGoodsDiscount(b.id);
|
|
|
|
+ if (disCountA != disCountB) return disCountA - disCountB;
|
|
|
|
|
|
if (a.price != b.price) return a.price - b.price;
|
|
if (a.price != b.price) return a.price - b.price;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
});
|
|
});
|
|
- return giftBagCfgs;
|
|
|
|
|
|
+ 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)
|
|
private List<GiftBagCfg> RemoveNotOpenCfg(List<GiftBagCfg> giftBagCfgs)
|
|
{
|
|
{
|
|
@@ -246,7 +241,7 @@ namespace GFGGame
|
|
});
|
|
});
|
|
for (int i = 0; i < giftBagCfgs.Count; i++)
|
|
for (int i = 0; i < giftBagCfgs.Count; i++)
|
|
{
|
|
{
|
|
- if (GetGiftStateById(giftBagCfgs[i].id) && (GetGiftBuyNumById(giftBagCfgs[i].id) < giftBagCfgs[i].maxBuyNum)) return giftBagCfgs[i];
|
|
|
|
|
|
+ if (GetShopGoodsStateById(giftBagCfgs[i].id) && (GetGoodsBuyNumById(giftBagCfgs[i].id) < giftBagCfgs[i].maxBuyNum)) return giftBagCfgs[i];
|
|
}
|
|
}
|
|
return giftBagCfgs[0];
|
|
return giftBagCfgs[0];
|
|
}
|
|
}
|
|
@@ -264,33 +259,33 @@ namespace GFGGame
|
|
});
|
|
});
|
|
for (int i = 0; i < giftBagCfgs.Count; i++)
|
|
for (int i = 0; i < giftBagCfgs.Count; i++)
|
|
{
|
|
{
|
|
- if (GetGiftStateById(giftBagCfgs[i].id) && (GetGiftBuyNumById(giftBagCfgs[i].id) < giftBagCfgs[i].maxBuyNum)) return giftBagCfgs[i];
|
|
|
|
|
|
+ if (GetShopGoodsStateById(giftBagCfgs[i].id) && (GetGoodsBuyNumById(giftBagCfgs[i].id) < giftBagCfgs[i].maxBuyNum)) return giftBagCfgs[i];
|
|
}
|
|
}
|
|
return giftBagCfgs[0];
|
|
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;
|
|
|
|
- }
|
|
|
|
|
|
+ // 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>
|
|
/// <summary>
|
|
- /// 根据礼包Id获取礼包解锁状态
|
|
|
|
|
|
+ /// 根据商品Id获取商品是否解锁解锁
|
|
/// /// </summary>
|
|
/// /// </summary>
|
|
- /// <param name="giftId"></param>
|
|
|
|
|
|
+ /// <param name="goodsId"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- public bool GetGiftStateById(int giftId)
|
|
|
|
|
|
+ public bool GetShopGoodsStateById(int goodsId)
|
|
{
|
|
{
|
|
- GiftBagCfg cfg = GiftBagCfgArray.Instance.GetCfg(giftId);
|
|
|
|
|
|
+ ShopCfg cfg = ShopCfgArray.Instance.GetCfg(goodsId);
|
|
|
|
|
|
if (cfg.lockType == LockType.NONE)
|
|
if (cfg.lockType == LockType.NONE)
|
|
{
|
|
{
|
|
@@ -298,22 +293,58 @@ namespace GFGGame
|
|
}
|
|
}
|
|
else if (cfg.lockType == LockType.STORY_LV)
|
|
else if (cfg.lockType == LockType.STORY_LV)
|
|
{
|
|
{
|
|
- return InstanceZonesDataManager.CheckLevelPass(cfg.storyLevelId);
|
|
|
|
|
|
+ return InstanceZonesDataManager.CheckLevelPass(cfg.lockValue);
|
|
}
|
|
}
|
|
- else
|
|
|
|
|
|
+ else if (cfg.lockType == LockType.ROLE_LV)
|
|
|
|
+ {
|
|
|
|
+ return GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= cfg.lockValue;
|
|
|
|
+ }
|
|
|
|
+ else if (cfg.lockType == LockType.MONTH_CARD_TYPE)
|
|
|
|
+ {
|
|
|
|
+ return RoleDataManager.CheckIsMonthCardOpenByType(cfg.lockValue);
|
|
|
|
+ }
|
|
|
|
+ else if (cfg.lockType == LockType.AREND_GRADE)
|
|
|
|
+ {
|
|
|
|
+ return ArenaDataManager.Instance.Grade >= cfg.lockValue;
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 根据商品Id获取商品解锁提示
|
|
|
|
+ /// /// </summary>
|
|
|
|
+ /// <param name="goodsId"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public string GetShopGoodsStateTips(int goodsId)
|
|
|
|
+ {
|
|
|
|
+ ShopCfg shopCfg = ShopCfgArray.Instance.GetCfg(goodsId);
|
|
|
|
+ if (shopCfg.lockType == LockType.STORY_LV)
|
|
|
|
+ {
|
|
|
|
+ StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(shopCfg.lockValue);
|
|
|
|
+ return string.Format("通关{0}-{1}解锁", StoryUtil.GetChapterOrder(storyLevelCfg.chapterId), storyLevelCfg.order);
|
|
|
|
+ }
|
|
|
|
+ else if (shopCfg.lockType == LockType.ROLE_LV)
|
|
|
|
+ {
|
|
|
|
+ return string.Format("角色达到{0}级解锁", shopCfg.lockValue);
|
|
|
|
+ }
|
|
|
|
+ else if (shopCfg.lockType == LockType.MONTH_CARD_TYPE)
|
|
|
|
+ {
|
|
|
|
+ return string.Format("开通{0}解锁", shopCfg.lockValue == MonthCardType.Gold ? "金卡" : "黑金卡");
|
|
|
|
+ }
|
|
|
|
+ else if (shopCfg.lockType == LockType.AREND_GRADE)
|
|
{
|
|
{
|
|
- return GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= cfg.lv;
|
|
|
|
|
|
+ return string.Format("飞花令达到{0}段位解锁", shopCfg.lockValue);
|
|
}
|
|
}
|
|
|
|
+ return "";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// 根据礼包id获取下架时间
|
|
|
|
|
|
+ /// 根据商品id获取下架时间
|
|
/// </summary>
|
|
/// </summary>
|
|
- /// <param name="giftId"></param>
|
|
|
|
|
|
+ /// <param name="goodsId"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- public string GetEndTime(int giftId)
|
|
|
|
|
|
+ public string GetEndTime(int goodsId)
|
|
{
|
|
{
|
|
long endTime = 0;
|
|
long endTime = 0;
|
|
- GiftBagCfg cfg = GiftBagCfgArray.Instance.GetCfg(giftId);
|
|
|
|
|
|
+ ShopCfg cfg = ShopCfgArray.Instance.GetCfg(goodsId);
|
|
if (cfg.endTime == "") return "";
|
|
if (cfg.endTime == "") return "";
|
|
|
|
|
|
endTime = TimeUtil.DateTimeToTimestamp(cfg.endTime);
|
|
endTime = TimeUtil.DateTimeToTimestamp(cfg.endTime);
|