From 4435dad5cb74b7d68f57d4b62f04d3e3de4adbd9 Mon Sep 17 00:00:00 2001
From: lcy <1459594991@qq.com>
Date: 星期四, 28 五月 2026 16:28:31 +0800
Subject: [PATCH] 666 新增代金券 可根据不同渠道配置只显示哪个
---
Main/System/GeneralConfig/GeneralDefine.cs | 50 ++++++++++++++--
Main/System/ItemTip/OwnMoneyCell.cs | 33 ++++++++--
Main/System/Tip/PayMethodConfirmWin.cs | 64 ++++++++++++---------
Main/SDK/SDKUtils.cs | 5 +
4 files changed, 108 insertions(+), 44 deletions(-)
diff --git a/Main/SDK/SDKUtils.cs b/Main/SDK/SDKUtils.cs
index 62ff119..6f8e957 100644
--- a/Main/SDK/SDKUtils.cs
+++ b/Main/SDK/SDKUtils.cs
@@ -958,8 +958,9 @@
long cashVoucher = UIHelper.GetMoneyCnt(97);
long diamond = UIHelper.GetMoneyCnt(99);
- bool hasEnoughVoucher = cashVoucher >= needMoney;
- bool hasEnoughDiamond = diamond >= needMoney;
+ var availableMoneyTypes = GeneralDefine.GetPayMethodAvailableMoneyTypes();
+ bool hasEnoughVoucher = availableMoneyTypes.Contains(97) && cashVoucher >= needMoney;
+ bool hasEnoughDiamond = availableMoneyTypes.Contains(99) && diamond >= needMoney;
if (hasEnoughVoucher || hasEnoughDiamond)
{
diff --git a/Main/System/GeneralConfig/GeneralDefine.cs b/Main/System/GeneralConfig/GeneralDefine.cs
index 9795b71..a2acd25 100644
--- a/Main/System/GeneralConfig/GeneralDefine.cs
+++ b/Main/System/GeneralConfig/GeneralDefine.cs
@@ -8,31 +8,35 @@
public class GeneralDefine
{
+
+ static readonly List<int> DEFAULT_PAY_METHOD_MONEY_TYPES = new List<int> { 97, 99 };
+ static Dictionary<string, int[]> payMethodMoneyTypeByChannel;
+
public static Dictionary<int, int> MoneyDisplayModel { get; private set; }
public static int activityItemID { get; private set; }
-
+
public static int expDisplayId { get; private set; }
-
+
//鍙傛暟int锛宨nt 锛宻tring 鍒嗗埆琛ㄧず鑱屼笟锛岃浆鐢熺瓑绾э紝icon
static Dictionary<int, Dictionary<int, string>> jobHeadPortrait = new Dictionary<int, Dictionary<int, string>>();
static Dictionary<int, Dictionary<int, string>> otherjobHeadPortrait = new Dictionary<int, Dictionary<int, string>>();
-
+
public static int rechargeRedpointLv { get; private set; }
public static int rechargeRedpointMinLv { get; private set; }
-
+
public static List<int> inGameDownLoadLevelCheckPoints = new List<int>();
public static int inGameDownLoadHighLevel { get; private set; }
-
+
public static Dictionary<int, List<int>> itemPutInPackDict { get; private set; }
public static Dictionary<int, int> itemMoneyCountDict { get; private set; } //鑳屽寘涓敤浜庡睍绀鸿揣甯佹暟閲忕殑鐗╁搧
-
+
public static int UISpringDecorate { get; private set; }
public static Dictionary<int, List<int>> skillAttrIDDict { get; private set; }
-
-
+
+
public static int acutionItemHour { get; private set; }
public static float blockRatio;
@@ -52,6 +56,7 @@
public static int[] heroSkinGiftList;
public static void Init()
{
+ payMethodMoneyTypeByChannel = null;
try
{
MoneyDisplayModel = ConfigParse.ParseIntDict(GetInputString("MoneyDisplayModel", 1));
@@ -117,6 +122,8 @@
config = FuncConfigConfig.Get("HeroSkinGift");
heroSkinGiftList = JsonMapper.ToObject<int[]>(config.Numerical1);
+
+ payMethodMoneyTypeByChannel = JsonMapper.ToObject<Dictionary<string, int[]>>(FuncConfigConfig.Get("DJQShow").Numerical1);
}
catch (Exception ex)
{
@@ -323,4 +330,31 @@
{
return playerID < 1000000;
}
+
+ public static List<int> GetPayMethodAvailableMoneyTypes()
+ {
+ if (payMethodMoneyTypeByChannel == null)
+ return new List<int>(DEFAULT_PAY_METHOD_MONEY_TYPES);
+
+ var versionConfig = VersionConfig.Get();
+ string channel = versionConfig != null ? versionConfig.appId : string.Empty;
+ if (string.IsNullOrEmpty(channel) || payMethodMoneyTypeByChannel == null ||
+ !payMethodMoneyTypeByChannel.TryGetValue(channel, out var moneyTypes) || moneyTypes == null || moneyTypes.Length == 0)
+ {
+ return new List<int>(DEFAULT_PAY_METHOD_MONEY_TYPES);
+ }
+
+ var result = new List<int>();
+ for (int i = 0; i < moneyTypes.Length; i++)
+ {
+ if (!result.Contains(moneyTypes[i]))
+ {
+ result.Add(moneyTypes[i]);
+ }
+ }
+
+ return result.Count > 0 ? result : new List<int>(DEFAULT_PAY_METHOD_MONEY_TYPES);
+ }
+
+
}
diff --git a/Main/System/ItemTip/OwnMoneyCell.cs b/Main/System/ItemTip/OwnMoneyCell.cs
index de72c8e..24379bd 100644
--- a/Main/System/ItemTip/OwnMoneyCell.cs
+++ b/Main/System/ItemTip/OwnMoneyCell.cs
@@ -1,4 +1,5 @@
-锘縰sing UnityEngine;
+using UnityEngine;
+using System.Collections.Generic;
using UnityEngine.UI;
//鎷ユ湁鐨勮揣甯侊細鏁伴噺鏄剧ず锛岀偣鍑绘寜閽墦寮�瀵瑰簲鑾峰彇鐣岄潰
@@ -13,9 +14,9 @@
{
if (moneyType != 0)
moneyIcon.SetIconWithMoneyType(moneyType);
-
+
if (wayBtn != null)
- {
+ {
wayBtn.AddListener(()=>
{
switch (moneyType)
@@ -77,8 +78,16 @@
});
}
}
+
void OnEnable()
{
+ bool shouldShow = ShouldShowByChannelConfig();
+ if (!shouldShow)
+ {
+ gameObject.SetActive(false);
+ return;
+ }
+
PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefresh;
Display();
}
@@ -91,10 +100,10 @@
void PlayerDataRefresh(PlayerDataType type)
{
if (type != UIHelper.moneyTypeToPlayerDataType[moneyType])
- {
+ {
return;
}
-
+
Display();
}
@@ -116,9 +125,19 @@
}
numText.text = UIHelper.ReplaceLargeNum(count, decimalPlaces);
if (resetIcon)
- {
+ {
moneyIcon.SetIconWithMoneyType(moneyType);
}
}
-}
+ bool ShouldShowByChannelConfig()
+ {
+ if (moneyType != 97 && moneyType != 99)
+ {
+ return true;
+ }
+
+ List<int> availableMoneyTypes = GeneralDefine.GetPayMethodAvailableMoneyTypes();
+ return availableMoneyTypes.Contains(moneyType);
+ }
+}
diff --git a/Main/System/Tip/PayMethodConfirmWin.cs b/Main/System/Tip/PayMethodConfirmWin.cs
index b835a2f..887e1ef 100644
--- a/Main/System/Tip/PayMethodConfirmWin.cs
+++ b/Main/System/Tip/PayMethodConfirmWin.cs
@@ -1,12 +1,11 @@
using UnityEngine;
using UnityEngine.UI;
-// 鏀粯鏂瑰紡閫夋嫨纭妗嗭細鍙岃揣甯侊紙鐜伴噾绀煎埜/鐜勭帀锛変簩閫変竴
public class PayMethodConfirmWin : UIBase
{
[SerializeField] Text m_Content;
- [SerializeField] Toggle m_Toggle1; //浠i噾绀煎埜
- [SerializeField] Toggle m_Toggle2; //鐜勭帀
+ [SerializeField] Toggle m_Toggle1;
+ [SerializeField] Toggle m_Toggle2;
[SerializeField] Text m_ToggleTxt1;
[SerializeField] Text m_ToggleTxt2;
[SerializeField] Button m_ConfirmBtn;
@@ -15,6 +14,7 @@
[SerializeField] Text moneyText;
int m_SelectedMoneyType;
+ int m_SelectedNeedCount;
int m_NeedMoney1;
int m_NeedMoney2;
@@ -27,14 +27,14 @@
{
if (isOn)
{
- TrySelectMoneyType(ConfirmCancel.moneyType1, ConfirmCancel.moneyNeedCount1);
+ TrySelectMoneyType(ConfirmCancel.moneyType1, m_NeedMoney1);
}
});
m_Toggle2.onValueChanged.AddListener((bool isOn) =>
{
if (isOn)
{
- TrySelectMoneyType(ConfirmCancel.moneyType2, ConfirmCancel.moneyNeedCount2);
+ TrySelectMoneyType(ConfirmCancel.moneyType2, m_NeedMoney2);
}
});
}
@@ -44,11 +44,18 @@
m_NeedMoney1 = ConfirmCancel.moneyNeedCount1;
m_NeedMoney2 = ConfirmCancel.moneyNeedCount2;
- // 璁剧疆涓や釜 Toggle 鐨勬枃瀛�
m_ToggleTxt1.text = ConfirmCancel.toggleText1;
m_ToggleTxt2.text = ConfirmCancel.toggleText2;
- // 鍏堣浜掓枼 ToggleGroup锛岄伩鍏嶅垵濮嬪寲鏃� listener 瑙﹀彂鐘舵�侀敊涔�
+ var availableMoneyTypes = GeneralDefine.GetPayMethodAvailableMoneyTypes();
+ bool showMoney1 = availableMoneyTypes.Contains(ConfirmCancel.moneyType1);
+ bool showMoney2 = availableMoneyTypes.Contains(ConfirmCancel.moneyType2);
+ if (!showMoney1 && !showMoney2)
+ {
+ showMoney1 = true;
+ showMoney2 = true;
+ }
+
var group = gameObject.GetComponent<ToggleGroup>();
if (group == null)
{
@@ -58,32 +65,32 @@
m_Toggle1.group = group;
m_Toggle2.group = group;
- // 鍒ゆ柇鍚勮揣甯佹槸鍚﹀厖瓒�
+ int showCount = (showMoney1 ? 1 : 0) + (showMoney2 ? 1 : 0);
+ bool showToggles = showCount > 1;
+ m_Toggle1.gameObject.SetActive(showToggles && showMoney1);
+ m_Toggle2.gameObject.SetActive(showToggles && showMoney2);
+
long have1 = UIHelper.GetMoneyCnt(ConfirmCancel.moneyType1);
long have2 = UIHelper.GetMoneyCnt(ConfirmCancel.moneyType2);
- bool enough1 = have1 >= m_NeedMoney1;
- bool enough2 = have2 >= m_NeedMoney2;
+ bool enough1 = showMoney1 && have1 >= m_NeedMoney1;
+ bool enough2 = showMoney2 && have2 >= m_NeedMoney2;
- // 鐢� SetIsOnWithoutNotify 閬垮厤瑙﹀彂 listener锛岀劧鍚庢墜鍔ㄥ垵濮嬪寲
- if (enough1)
+ if (enough1 || (!enough2 && showMoney1))
{
- m_Toggle1.SetIsOnWithoutNotify(true);
+ m_Toggle1.SetIsOnWithoutNotify(showToggles);
m_Toggle2.SetIsOnWithoutNotify(false);
m_SelectedMoneyType = ConfirmCancel.moneyType1;
- }
- else if (enough2)
- {
- m_Toggle1.SetIsOnWithoutNotify(false);
- m_Toggle2.SetIsOnWithoutNotify(true);
- m_SelectedMoneyType = ConfirmCancel.moneyType2;
+ m_SelectedNeedCount = m_NeedMoney1;
}
else
{
- m_Toggle1.SetIsOnWithoutNotify(true);
- m_Toggle2.SetIsOnWithoutNotify(false);
- m_SelectedMoneyType = ConfirmCancel.moneyType1;
+ m_Toggle1.SetIsOnWithoutNotify(false);
+ m_Toggle2.SetIsOnWithoutNotify(showToggles);
+ m_SelectedMoneyType = ConfirmCancel.moneyType2;
+ m_SelectedNeedCount = m_NeedMoney2;
}
- UpdateMoneyDisplay(m_SelectedMoneyType, m_SelectedMoneyType == ConfirmCancel.moneyType1 ? m_NeedMoney1 : m_NeedMoney2);
+
+ UpdateMoneyDisplay(m_SelectedMoneyType, m_SelectedNeedCount);
}
void TrySelectMoneyType(int moneyType, int needCount)
@@ -91,10 +98,7 @@
long have = UIHelper.GetMoneyCnt(moneyType);
if (have < needCount)
{
- // 璐у竵涓嶈冻锛屽脊鍑烘彁绀哄苟鍒囧洖鍘熸潵鐨勯�変腑椤�
- string moneyName = ItemConfig.Get(UIHelper.GetItemIDWithMoneyType(moneyType))?.ItemName ?? moneyType.ToString();
SysNotifyMgr.Instance.ShowTip("LackMoney", moneyType);
- // 鎭㈠鍘熸潵鐨勯�変腑
if (m_SelectedMoneyType == ConfirmCancel.moneyType1)
{
m_Toggle1.isOn = true;
@@ -107,6 +111,7 @@
}
m_SelectedMoneyType = moneyType;
+ m_SelectedNeedCount = needCount;
UpdateMoneyDisplay(moneyType, needCount);
}
@@ -114,7 +119,6 @@
{
moneyIcon.SetIconWithMoneyType(moneyType);
moneyText.text = GetPayMethodMoneyText(moneyType, needCount);
- // 鍒囨崲閫夐」鏃跺悓姝ュ埛鏂� Recharge6 鍐呭锛堣揣甯佸浘鏍�+鍚嶇О鍙樺寲锛�
m_Content.text = Language.Get("Recharge6", UIHelper.GetIconNameWithMoneyType(moneyType), ConfirmCancel.payMethodMoney, ConfirmCancel.payMethodTitle);
}
@@ -133,6 +137,12 @@
private void OnConfirm()
{
+ if (UIHelper.GetMoneyCnt(m_SelectedMoneyType) < m_SelectedNeedCount)
+ {
+ SysNotifyMgr.Instance.ShowTip("LackMoney", m_SelectedMoneyType);
+ return;
+ }
+
CloseWindow();
ConfirmCancel.OnDualToggleConfirmEvent?.Invoke(true, m_SelectedMoneyType);
}
--
Gitblit v1.8.0