fix:1、添加支付,使用sdk的支付方案
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -39,7 +39,7 @@ namespace RedHotRoast
|
||||
public static uint RefreshGame = ++Cursor_BASE;
|
||||
public static uint RewardUIClosed = ++Cursor_BASE;
|
||||
public static uint H5ViewClickBtn = ++Cursor_BASE;
|
||||
public static uint apple_pay_success = ++Cursor_BASE;
|
||||
public static uint IAP_PAY_SUCCESS = ++Cursor_BASE;
|
||||
public static uint ExitGame = ++Cursor_BASE;
|
||||
|
||||
public static uint UpdateNoads = ++Cursor_BASE;
|
||||
|
||||
@@ -1404,7 +1404,7 @@ namespace RedHotRoast
|
||||
/// <returns>true:广告兑换 -- false:三方支付</returns>
|
||||
public static bool IsAdModelOfPay()
|
||||
{
|
||||
return true;//zhushi
|
||||
// return true;//zhushi
|
||||
var isAd = GetLoginModel().Enwp != 1;
|
||||
return isAd;
|
||||
}
|
||||
@@ -1750,7 +1750,20 @@ namespace RedHotRoast
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public static string getTrackEvenName()
|
||||
{
|
||||
string event_ = ADEventTrack.Event;
|
||||
if (GetLoginModel().Enwp == 1)
|
||||
{
|
||||
int rate = GetCommonModel().PayRate;
|
||||
if (!IsGiftSwitch() || GetCommonModel().PayRate == 100)
|
||||
{
|
||||
MaxPayManager.isIOSPay = true;
|
||||
}
|
||||
event_ = MaxPayManager.isIOSPay ? ADEventTrack.IOS_Pay_Event : ADEventTrack.MaxPayEvent;
|
||||
}
|
||||
return event_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,10 @@ namespace RedHotRoast
|
||||
shopName = "",
|
||||
type = ""
|
||||
};
|
||||
List<ApplePay2> listA = ConfigSystem.GetConfig<ApplePay2>();
|
||||
// List<ApplePay2> listA = ConfigSystem.GetConfig<ApplePay2>();
|
||||
|
||||
//更新map中的value,与配置表的id对应
|
||||
PurchasingManager.SetShopMapValue();
|
||||
|
||||
// // 方式一:LINQ Select
|
||||
// List<ProductConfig> listB = listA
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 470 KiB After Width: | Height: | Size: 502 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1893,6 +1893,50 @@ SpriteRenderer:
|
||||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!1 &1659410217
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1659410219}
|
||||
- component: {fileID: 1659410218}
|
||||
m_Layer: 0
|
||||
m_Name: IAPPayManager
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &1659410218
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1659410217}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f4b5c2a375fb4610a0417b408c252104, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!4 &1659410219
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1659410217}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -21.708763, y: 1.0219306, z: 3152.2478}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1667672678
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -2342,3 +2386,4 @@ SceneRoots:
|
||||
- {fileID: 392099410}
|
||||
- {fileID: 29401442}
|
||||
- {fileID: 292594112}
|
||||
- {fileID: 1659410219}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class AdExchangeManager
|
||||
|
||||
DOVirtual.DelayedCall(0.1f, () =>
|
||||
{
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, _data.type);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, _data.type);
|
||||
|
||||
});
|
||||
|
||||
@@ -140,8 +140,8 @@ public class AdExchangeManager
|
||||
var lastTimes = SaveData.GetSaveObject()._watch_ad_cd;
|
||||
foreach (var item in btn_WatchAd)
|
||||
{
|
||||
bool is_get = item.Key == PurchasingManager.GetPaySku(PayType.pack_reward) && SaveData.GetSaveObject().is_get_packreward;
|
||||
bool is_get1 = item.Key == PurchasingManager.GetPaySku(PayType.remove_ad) && SaveData.GetSaveObject().is_get_removead;
|
||||
bool is_get = item.Key == IAPPayManager.PRODUCT_FIRST_GIFT && SaveData.GetSaveObject().is_get_packreward;
|
||||
bool is_get1 = item.Key == IAPPayManager.PRODUCT_REMOVE_ADS && SaveData.GetSaveObject().is_get_removead;
|
||||
if (is_get || is_get1)
|
||||
{
|
||||
item.Value.enabled = false;
|
||||
@@ -170,7 +170,7 @@ public class AdExchangeManager
|
||||
{
|
||||
|
||||
int needAds = -1;
|
||||
if (name == PurchasingManager.GetPaySku(PayType.buy_one))
|
||||
if (name == IAPPayManager.PRODUCT_SPACE_BONUS)
|
||||
{
|
||||
double addspace = config.addspace;
|
||||
needAds = (int)Math.Ceiling(addspace);
|
||||
@@ -180,43 +180,43 @@ public class AdExchangeManager
|
||||
// double addspace1 = config.AddDiscount;
|
||||
// needAds = (int)Math.Ceiling(addspace1);
|
||||
// }
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.battle_pass))
|
||||
else if (name == IAPPayManager.PRODUCT_PASS_BONUS)
|
||||
{
|
||||
double Passportgift = config.Passportgift;
|
||||
needAds = (int)Math.Ceiling(Passportgift);
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.pack_reward))
|
||||
else if (name == IAPPayManager.PRODUCT_FIRST_GIFT)
|
||||
{
|
||||
double Paid_price = packdata[0].Paid_price;
|
||||
needAds = (int)Math.Ceiling(Paid_price);
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.remove_ad))
|
||||
else if (name == IAPPayManager.PRODUCT_REMOVE_ADS)
|
||||
{
|
||||
double move_price = packdata[1].Paid_price;
|
||||
needAds = (int)Math.Ceiling(move_price);
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
{
|
||||
double move_price = threeDayData[2].Paid_price;
|
||||
needAds = (int)Math.Ceiling(move_price);
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.buy_gold_1))
|
||||
// else if (name == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
// {
|
||||
// double move_price = threeDayData[2].Paid_price;
|
||||
// needAds = (int)Math.Ceiling(move_price);
|
||||
// }
|
||||
else if (name == IAPPayManager.PRODUCT_SHOP_1)
|
||||
{
|
||||
needAds = (int)Math.Ceiling(getCoinNeedAds(name));
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.buy_gold_2))
|
||||
else if (name == IAPPayManager.PRODUCT_SHOP_2)
|
||||
{
|
||||
needAds = (int)Math.Ceiling(getCoinNeedAds(name));
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.buy_gold_3))
|
||||
else if (name == IAPPayManager.PRODUCT_SHOP_3)
|
||||
{
|
||||
needAds = (int)Math.Ceiling(getCoinNeedAds(name));
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.buy_gold_4))
|
||||
else if (name == IAPPayManager.PRODUCT_SHOP_4)
|
||||
{
|
||||
needAds = (int)Math.Ceiling(getCoinNeedAds(name));
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.buy_gold_5))
|
||||
else if (name == IAPPayManager.PRODUCT_SHOP_5)
|
||||
{
|
||||
needAds = (int)Math.Ceiling(getCoinNeedAds(name));
|
||||
}
|
||||
@@ -265,8 +265,8 @@ public class AdExchangeManager
|
||||
else
|
||||
{
|
||||
item.buy_state.selectedIndex = btn_watchAd.Buy_state_ad;
|
||||
bool is_get = key == PurchasingManager.GetPaySku(PayType.pack_reward) && SaveData.GetSaveObject().is_get_packreward;
|
||||
bool is_get1 = key == PurchasingManager.GetPaySku(PayType.remove_ad) && SaveData.GetSaveObject().is_get_removead;
|
||||
bool is_get = key == IAPPayManager.PRODUCT_FIRST_GIFT && SaveData.GetSaveObject().is_get_packreward;
|
||||
bool is_get1 = key == IAPPayManager.PRODUCT_REMOVE_ADS && SaveData.GetSaveObject().is_get_removead;
|
||||
|
||||
if (is_get || is_get1)
|
||||
{
|
||||
@@ -341,22 +341,22 @@ public class AdExchangeManager
|
||||
{
|
||||
string eventClickName = "";
|
||||
string eventSuccName = "";
|
||||
if (name == PurchasingManager.GetPaySku(PayType.pack_reward))
|
||||
if (name == IAPPayManager.PRODUCT_FIRST_GIFT)
|
||||
{
|
||||
eventClickName = ADEventTrack.Property.lucky_gift_click;
|
||||
eventSuccName = ADEventTrack.Property.lucky_gift_receive;
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.remove_ad))
|
||||
else if (name == IAPPayManager.PRODUCT_REMOVE_ADS)
|
||||
{
|
||||
eventClickName = ADEventTrack.Property.remove_ad_click;
|
||||
eventSuccName = ADEventTrack.Property.remove_ad_receive;
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.battle_pass))
|
||||
else if (name == IAPPayManager.PRODUCT_PASS_BONUS)
|
||||
{
|
||||
eventClickName = ADEventTrack.Property.master_pass_click;
|
||||
eventSuccName = ADEventTrack.Property.master_pass_receive;
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.buy_one))
|
||||
else if (name == IAPPayManager.PRODUCT_SPACE_BONUS)
|
||||
{
|
||||
eventClickName = ADEventTrack.Property.buy_one_click;
|
||||
eventSuccName = ADEventTrack.Property.buy_one_success;
|
||||
@@ -366,17 +366,15 @@ public class AdExchangeManager
|
||||
// eventClickName = ADEventTrack.Property.BuyOneOffClick;
|
||||
// eventSuccName = ADEventTrack.Property.BuyOneOffSuccess;
|
||||
// }
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
// else if (name == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
// {
|
||||
// eventClickName = ADEventTrack.Property.three_days_gift_click;
|
||||
// eventSuccName = ADEventTrack.Property.three_days_gift_buy_success;
|
||||
// }
|
||||
else if (PurchasingManager.ShopProductMap.TryGetValue(name, out var idx))
|
||||
{
|
||||
eventClickName = ADEventTrack.Property.three_days_gift_click;
|
||||
eventSuccName = ADEventTrack.Property.three_days_gift_buy_success;
|
||||
}
|
||||
else if (name.StartsWith("buy_gold"))
|
||||
{
|
||||
int startIndex = "buy_gold".Length;
|
||||
string suffix = name[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
eventClickName = ADEventTrack.Property.gold_click_ + suffix;
|
||||
eventSuccName = ADEventTrack.Property.shop_receive_ + suffix;
|
||||
eventClickName = ADEventTrack.Property.gold_click_ + idx;
|
||||
eventSuccName = ADEventTrack.Property.shop_receive_ + idx;
|
||||
}
|
||||
|
||||
if (type == "success" && eventSuccName != "")
|
||||
|
||||
@@ -0,0 +1,601 @@
|
||||
// ============================================================
|
||||
// IAPPayManager.cs
|
||||
// IAP 接入使用(MonoBehaviour)
|
||||
//
|
||||
// 将此脚本挂到场景中的任意 GameObject 即可运行示例。
|
||||
// 请将商品 ID 替换为你在 App Store Connect / Google Play Console 中配置的真实 ID。
|
||||
// ============================================================
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using RedHotRoast;
|
||||
using SDK_IAP;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Purchasing;
|
||||
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public class IAPPayManager : MonoBehaviour
|
||||
{
|
||||
// ──────────────────────────────────────────────────────────
|
||||
// 单例实例
|
||||
// ──────────────────────────────────────────────────────────
|
||||
private static IAPPayManager _instance;
|
||||
public static IAPPayManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = FindObjectOfType<IAPPayManager>();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────────────
|
||||
// 商品 ID 常量(替换为真实 ID)
|
||||
// ──────────────────────────────────────────────────────────
|
||||
|
||||
public static string PRODUCT_FIRST_GIFT = "comtronwingameredhotroastgift199"; //首充 消耗品
|
||||
public static string PRODUCT_REMOVE_ADS = "comtronwingameredhotroastremove299"; //移除广告 消耗品
|
||||
public static string PRODUCT_PASS_BONUS = "comtronwingameredhotroastpass999"; //通行证礼包 消耗品
|
||||
public static string PRODUCT_SPACE_BONUS = "comtronwingameredhotroastspace24999"; //加一格礼包 非消耗品
|
||||
public static string PRODUCT_SHOP_1 = "comtronwingameredhotroastshop199"; //商店档位1 消耗品
|
||||
public static string PRODUCT_SHOP_2 = "comtronwingameredhotroastshop399"; //商店档位2 消耗品
|
||||
public static string PRODUCT_SHOP_3= "comtronwingameredhotroastshop999"; //商店档位3 消耗品
|
||||
public static string PRODUCT_SHOP_4 = "comtronwingameredhotroastshop1999"; //商店档位4 消耗品
|
||||
public static string PRODUCT_SHOP_5 = "comtronwingameredhotroastshop3999"; //商店档位5 消耗品
|
||||
// public static string PRODUCT_THREE_DAY = "comwackyllamagamethreeday399"; //三天礼包 消耗品
|
||||
|
||||
public static string PRODUCT_VIP_WEEK = "comtronwingameredhotroastsub999"; // 周订阅 Subscription
|
||||
public static string PRODUCT_VIP_MONTH = "comtronwingameredhotroastsub2999"; // 月订阅 Subscription
|
||||
public static string PRODUCT_VIP_YEAR = "comtronwingameredhotroastsub9999"; // 年订阅 Subscription
|
||||
|
||||
// ──────────────────────────────────────────────────────────
|
||||
// 生命周期
|
||||
// ──────────────────────────────────────────────────────────
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// 确保单例唯一性
|
||||
if (_instance != null && _instance != this)
|
||||
{
|
||||
Debug.LogWarning("[IAP IOS] 检测到多个 IAPGoogleManager 实例,销毁重复对象");
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
_instance = this;
|
||||
|
||||
// 订阅发货事件(持续监听,全局处理发货逻辑)
|
||||
IAPManager.OnDeliver += HandleDeliver;
|
||||
IAPManager.OnInitialized += HandleInitialized;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
InitIAP();
|
||||
//StartCoroutine(Test());
|
||||
}
|
||||
|
||||
//private IEnumerator Test()
|
||||
//{
|
||||
// int index = 0;
|
||||
// while (true)
|
||||
// {
|
||||
// yield return new WaitForSeconds(1f);
|
||||
|
||||
// Analytics.OnTrackEvent?.Invoke($"test{index}", new Dictionary<string, string>());
|
||||
// index++;
|
||||
// }
|
||||
//}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
IAPManager.OnDeliver -= HandleDeliver;
|
||||
IAPManager.OnInitialized -= HandleInitialized;
|
||||
IAPManager.Dispose();
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────────────
|
||||
// 初始化
|
||||
// ──────────────────────────────────────────────────────────
|
||||
|
||||
private void InitIAP()
|
||||
{
|
||||
var products = new List<ProductDefine>
|
||||
{
|
||||
// 消耗品
|
||||
ProductDefine.Simple(PRODUCT_FIRST_GIFT, ProductType.Consumable),
|
||||
ProductDefine.Simple(PRODUCT_REMOVE_ADS, ProductType.Consumable),
|
||||
ProductDefine.Simple(PRODUCT_PASS_BONUS, ProductType.Consumable),
|
||||
ProductDefine.Simple(PRODUCT_SHOP_1, ProductType.Consumable),
|
||||
ProductDefine.Simple(PRODUCT_SHOP_2, ProductType.Consumable),
|
||||
ProductDefine.Simple(PRODUCT_SHOP_3, ProductType.Consumable),
|
||||
ProductDefine.Simple(PRODUCT_SHOP_4, ProductType.Consumable),
|
||||
ProductDefine.Simple(PRODUCT_SHOP_5, ProductType.Consumable),
|
||||
// ProductDefine.Simple(PRODUCT_THREE_DAY, ProductType.Consumable),
|
||||
|
||||
// 非消耗品
|
||||
ProductDefine.Simple(PRODUCT_SPACE_BONUS, ProductType.NonConsumable),
|
||||
|
||||
// 订阅
|
||||
ProductDefine.Simple(PRODUCT_VIP_WEEK, ProductType.Subscription),
|
||||
ProductDefine.Simple(PRODUCT_VIP_MONTH, ProductType.Subscription),
|
||||
ProductDefine.Simple(PRODUCT_VIP_YEAR, ProductType.Subscription),
|
||||
};
|
||||
|
||||
Debug.Log("[IAP IOS] 开始初始化...");
|
||||
IAPManager.Init(products, OnInitCallback);
|
||||
}
|
||||
|
||||
// Init 完成回调(与 OnInitialized 事件等价,二选一即可)
|
||||
private void OnInitCallback(bool success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
Debug.Log("[IAP IOS] 初始化成功!");
|
||||
ShowProductPrices();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("[IAP IOS] 初始化失败,请检查网络或 App Store / Google Play 配置。");
|
||||
}
|
||||
}
|
||||
|
||||
// 也可以通过静态事件监听(适合多个 Manager 分散处理)
|
||||
private void HandleInitialized(bool success)
|
||||
{
|
||||
// 此处可做更新 UI 等操作
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────────────
|
||||
// 显示商品价格(初始化成功后调用)
|
||||
// ──────────────────────────────────────────────────────────
|
||||
|
||||
public void ShowProductPrices()
|
||||
{
|
||||
var products = IAPManager.GetProducts();
|
||||
foreach (var p in products)
|
||||
{
|
||||
Debug.Log($"[IAP IOS] 商品: {p.definition.id} | 价格: {p.metadata.localizedPriceString}");
|
||||
}
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────────────
|
||||
// 购买
|
||||
// ──────────────────────────────────────────────────────────
|
||||
/// <summary>通用购买方法 - 适用于消耗品和非消耗品</summary>
|
||||
/// <param name="productId">商品ID</param>
|
||||
/// <param name="productName">商品名称(用于日志)</param>
|
||||
/// <param name="onSuccess">购买成功后的回调</param>
|
||||
public void BuyProduct(string productId, string productName, System.Action onSuccess = null)
|
||||
{
|
||||
IAPManager.Buy(productId, result =>
|
||||
{
|
||||
if (result.success)
|
||||
{
|
||||
Debug.Log($"[IAP IOS] 购买成功: {productName} ({result.productId}) | tid={result.transactionId}");
|
||||
onSuccess?.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[IAP IOS] 购买失败: {productName} ({result.productId}) - {result.error}");
|
||||
PurchasingManager.SendEventClickByName(productId, "open");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>通用订阅方法 - 适用于订阅类型商品</summary>
|
||||
/// <param name="productId">商品ID</param>
|
||||
/// <param name="subscriptionName">订阅名称(用于日志)</param>
|
||||
/// <param name="onSuccess">订阅成功后的回调</param>
|
||||
public void SubscribeProduct(string productId, string subscriptionName, System.Action onSuccess = null)
|
||||
{
|
||||
IAPManager.Buy(productId, result =>
|
||||
{
|
||||
if (result.success)
|
||||
{
|
||||
Debug.Log($"[IAP IOS] 订阅成功: {subscriptionName} ({result.productId}) | tid={result.transactionId}");
|
||||
// ShowSubscriptionInfo();
|
||||
onSuccess?.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[IAP IOS] 订阅失败: {subscriptionName} ({result.productId}) - {result.error}");
|
||||
PurchasingManager.SendEventClickByName(productId, "open");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────────────
|
||||
// 恢复购买(iOS 界面上必须提供此按钮)
|
||||
// ──────────────────────────────────────────────────────────
|
||||
public void OnRestoreButtonClicked()
|
||||
{
|
||||
// UI 控制:仅在需要时显示此按钮
|
||||
// if (!IAPManager.NeedShowRestoreButton()) return;
|
||||
|
||||
IAPManager.Restore(result =>
|
||||
{
|
||||
if (result.success)
|
||||
{
|
||||
Debug.Log("[IAP IOS] 恢复购买流程完成(实际恢复内容通过 OnDeliver 发放)");
|
||||
Debug.Log("[IAP IOS] restore success: " + result.success);
|
||||
GameHelper.ShowTips("Restore_pur", true);
|
||||
// SaveData.GetSaveObject().have_slot = success;
|
||||
// DataMgr.VipLevel.Value = 3;
|
||||
// DataMgr.VipExpirationTime.Value = ServerClock.GetCurrentServerTime() + 7 * 24 * 60 * 60;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[IAP IOS] 恢复购买失败: {result.error}");
|
||||
GameHelper.ShowTips("recoverable_tips", true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────────────
|
||||
// 权益检查
|
||||
// ──────────────────────────────────────────────────────────
|
||||
/// <summary>通用权益检查方法 - 适用于非消耗品和订阅</summary>
|
||||
/// <param name="productId">商品ID</param>
|
||||
/// <param name="productName">商品名称(用于日志)</param>
|
||||
/// <param name="onResult">检查结果回调</param>
|
||||
public void CheckEntitlement(string productId, string productName, System.Action<EntitlementStatus> onResult = null)
|
||||
{
|
||||
IAPManager.CheckEntitlement(productId, status =>
|
||||
{
|
||||
Debug.Log($"[IAP IOS] {productName} 权益状态: {status}");
|
||||
onResult?.Invoke(status);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>检查加一格礼包权益</summary>
|
||||
public void CheckSpaceBonusEntitlement()
|
||||
{
|
||||
CheckEntitlement(PRODUCT_SPACE_BONUS, "加一格礼包", state =>
|
||||
{
|
||||
if (state == EntitlementStatus.FullyEntitled)
|
||||
{
|
||||
// 激活加一格权限
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>检查VIP订阅权益</summary>
|
||||
public void CheckVipEntitlement()
|
||||
{
|
||||
CheckEntitlement(PRODUCT_VIP_MONTH, "VIP月卡", status =>
|
||||
{
|
||||
if (status == EntitlementStatus.FullyEntitled)
|
||||
{
|
||||
// 激活VIP权限
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ──────────────────────────────────────────────────────────
|
||||
// 订阅信息查询
|
||||
// ──────────────────────────────────────────────────────────
|
||||
/// <summary>显示指定商品的订阅信息</summary>
|
||||
/// <param name="productId">商品ID</param>
|
||||
public void ShowSubscriptionInfo(string productId)
|
||||
{
|
||||
var info = IAPManager.GetSubscriptionInfo(productId);
|
||||
Debug.Log($"[IAP IOS] VIP 订阅状态 ({productId}):");
|
||||
Debug.Log($" isSubscribed = {info.isSubscribed}");
|
||||
Debug.Log($" isExpired = {info.isExpired}");
|
||||
Debug.Log($" expireDate = {info.expireDate}");
|
||||
Debug.Log($" isAutoRenewing= {info.isAutoRenewing}");
|
||||
|
||||
if (info.isSubscribed && !info.isExpired)
|
||||
{
|
||||
int vipLevel = GetVipLevelByProductId(productId);
|
||||
if (vipLevel > 0)
|
||||
{
|
||||
DataMgr.VipLevel.Value = vipLevel;
|
||||
Debug.Log($"[IAP IOS] 设置 VIP 等级: {vipLevel}");
|
||||
}
|
||||
|
||||
if (info.expireDate.Year > 1970 && info.expireDate.Year < 10000)
|
||||
{
|
||||
var expireTimestamp = ((DateTimeOffset)info.expireDate).ToUnixTimeSeconds();
|
||||
Debug.Log($"Expire timestamp: {expireTimestamp}");
|
||||
DataMgr.VipExpirationTime.Value = Math.Max(DataMgr.VipExpirationTime.Value, expireTimestamp);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[IAP IOS] 无效的到期时间: {info.expireDate}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"[IAP IOS] 用户未订阅或订阅已过期");
|
||||
}
|
||||
}
|
||||
/// <summary>根据商品ID获取VIP等级</summary>
|
||||
/// <param name="productId">商品ID</param>
|
||||
/// <returns>VIP等级:周订阅=1,月订阅=2,年订阅=3,其他=0</returns>
|
||||
private int GetVipLevelByProductId(string productId)
|
||||
{
|
||||
if (productId == PRODUCT_VIP_WEEK)
|
||||
return 1;
|
||||
else if (productId == PRODUCT_VIP_MONTH)
|
||||
return 2;
|
||||
else if (productId == PRODUCT_VIP_YEAR)
|
||||
return 3;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────────────
|
||||
// 全局发货处理(OnDeliver 事件接收)
|
||||
// ──────────────────────────────────────────────────────────
|
||||
/// <summary>
|
||||
/// 统一发货处理入口。
|
||||
/// 无论是新购买、补单、还是恢复购买,都会触发此方法。
|
||||
/// ⚠️ 幂等保护已由 DeliverGuardLite 处理,此处无需再判重。
|
||||
/// </summary>
|
||||
private void HandleDeliver(string productId)
|
||||
{
|
||||
Debug.Log($"[IAP IOS] 收到统一发货通知: {productId}");
|
||||
|
||||
if (!IsValidProduct(productId))
|
||||
{
|
||||
Debug.LogWarning($"[IAP IOS] 非法商品ID,拒绝发货: {productId}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (productId == PRODUCT_VIP_WEEK || productId == PRODUCT_VIP_MONTH || productId == PRODUCT_VIP_YEAR)
|
||||
{
|
||||
// 订阅商品:需要先获取有效的订阅信息,成功后才会分发支付成功消息
|
||||
StartCoroutine(DelayedGetSubscriptionInfo(productId));
|
||||
}
|
||||
else
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
|
||||
|
||||
// 非订阅商品(消耗品):直接发货
|
||||
Debug.Log($"[IAP IOS] 发货通知: {productId}");
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, productId);
|
||||
PurchasingManager.SendEventClickByName(productId, "open");
|
||||
PurchasingManager.SendEventClickByName(productId, "success");
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator DelayedGetSubscriptionInfo(string productId)
|
||||
{
|
||||
Debug.Log($"[IAP IOS] 开始获取订阅信息: {productId}");
|
||||
|
||||
// 先尝试立即获取一次
|
||||
var immediateInfo = IAPManager.GetSubscriptionInfo(productId);
|
||||
|
||||
// 检查是否是无效数据
|
||||
bool isInvalid = immediateInfo.expireDate == default(DateTime) ||
|
||||
(immediateInfo.expireDate.Year == 1 && !immediateInfo.isSubscribed);
|
||||
|
||||
if (!isInvalid && immediateInfo.isSubscribed)
|
||||
{
|
||||
// 立即获取到了有效数据,直接处理
|
||||
bool success = ProcessSubscriptionInfo(immediateInfo, productId);
|
||||
if (success)
|
||||
{
|
||||
DispatchPaySuccess(productId);
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
// 无效数据,开始重试
|
||||
Debug.Log($"[IAP IOS] 订阅信息未就绪,开始重试...");
|
||||
|
||||
int maxRetries = 5;
|
||||
float waitTime = 1.5f;
|
||||
for (int i = 0; i < maxRetries; i++)
|
||||
{
|
||||
yield return new WaitForSeconds(waitTime); // 每次等待0.5秒
|
||||
|
||||
var info = IAPManager.GetSubscriptionInfo(productId);
|
||||
|
||||
if (info.isSubscribed && !info.isExpired && info.expireDate.Year > 1970)
|
||||
{
|
||||
Debug.Log($"[IAP IOS] 订阅信息获取成功 (重试 {i + 1} 次)");
|
||||
bool success = ProcessSubscriptionInfo(info, productId);
|
||||
if (success)
|
||||
{
|
||||
DispatchPaySuccess(productId);
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
Debug.Log($"[IAP IOS] 第 {i + 1} 次重试: isSubscribed={info.isSubscribed}, isExpired={info.isExpired}, expireDate={info.expireDate}");
|
||||
}
|
||||
|
||||
// 所有重试都失败了,使用降级方案
|
||||
Debug.LogError($"[IAP IOS] 无法获取订阅信息,使用降级方案");
|
||||
bool fallbackSuccess = ProcessFallbackSubscription(productId);
|
||||
if (fallbackSuccess)
|
||||
{
|
||||
DispatchPaySuccess(productId);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 降级也失败了,上报错误,不分发支付成功
|
||||
Debug.LogError($"[IAP IOS] 降级方案也失败,支付成功消息将不分发,请检查配置");
|
||||
PurchasingManager.SendEventClickByName(productId, "open");
|
||||
// 可选:向用户显示错误提示
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理订阅信息,设置VIP等级和过期时间
|
||||
/// </summary>
|
||||
/// <returns>是否设置成功</returns>
|
||||
private bool ProcessSubscriptionInfo(SubscriptionInfoLite info, string productId)
|
||||
{
|
||||
try
|
||||
{
|
||||
Debug.Log($"[IAP IOS] VIP 订阅状态 ({productId}):");
|
||||
Debug.Log($" isSubscribed = {info.isSubscribed}");
|
||||
Debug.Log($" isExpired = {info.isExpired}");
|
||||
Debug.Log($" expireDate = {info.expireDate}");
|
||||
Debug.Log($" isAutoRenewing= {info.isAutoRenewing}");
|
||||
|
||||
// 获取VIP等级
|
||||
int vipLevel = GetVipLevelByProductId(productId);
|
||||
if (vipLevel <= 0)
|
||||
{
|
||||
Debug.LogError($"[IAP IOS] 无法获取VIP等级,商品ID: {productId}");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取过期时间戳
|
||||
long expireTimestamp = 0;
|
||||
if (info.expireDate.Year > 1970 && info.expireDate.Year < 10000)
|
||||
{
|
||||
expireTimestamp = ((DateTimeOffset)info.expireDate).ToUnixTimeSeconds();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[IAP IOS] 无效的到期时间: {info.expireDate},使用预估时间");
|
||||
expireTimestamp = GetEstimatedExpireTimestamp(productId);
|
||||
}
|
||||
|
||||
if (expireTimestamp <= 0)
|
||||
{
|
||||
Debug.LogError($"[IAP IOS] 无法获取有效的过期时间戳");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 保存数据(使用前后对比,确保设置成功)
|
||||
int oldVipLevel = DataMgr.VipLevel.Value;
|
||||
long oldExpireTime = DataMgr.VipExpirationTime.Value;
|
||||
|
||||
DataMgr.VipLevel.Value = Math.Max(DataMgr.VipLevel.Value, vipLevel);
|
||||
DataMgr.VipExpirationTime.Value = Math.Max(DataMgr.VipExpirationTime.Value, expireTimestamp);
|
||||
|
||||
// 验证设置是否成功
|
||||
bool vipLevelSuccess = DataMgr.VipLevel.Value >= vipLevel;
|
||||
bool expireTimeSuccess = DataMgr.VipExpirationTime.Value >= expireTimestamp;
|
||||
|
||||
if (vipLevelSuccess && expireTimeSuccess)
|
||||
{
|
||||
Debug.Log($"[IAP IOS] VIP设置成功 - 等级: {vipLevel} (原:{oldVipLevel}), 过期时间: {expireTimestamp} (原:{oldExpireTime})");
|
||||
|
||||
// 可选:触发VIP状态更新事件
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"[IAP IOS] VIP设置失败 - 等级设置: {vipLevelSuccess}, 过期时间设置: {expireTimeSuccess}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"[IAP IOS] 处理订阅信息时发生异常: {e.Message}\n{e.StackTrace}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 降级方案:当无法从商店获取订阅信息时,根据商品类型估算VIP信息
|
||||
/// </summary>
|
||||
private bool ProcessFallbackSubscription(string productId)
|
||||
{
|
||||
try
|
||||
{
|
||||
Debug.LogWarning($"[IAP IOS] 执行降级方案: {productId}");
|
||||
|
||||
int vipLevel = GetVipLevelByProductId(productId);
|
||||
if (vipLevel <= 0)
|
||||
{
|
||||
Debug.LogError($"[IAP IOS] 降级方案失败 - 无法获取VIP等级");
|
||||
return false;
|
||||
}
|
||||
|
||||
long expireTimestamp = GetEstimatedExpireTimestamp(productId);
|
||||
if (expireTimestamp <= 0)
|
||||
{
|
||||
Debug.LogError($"[IAP IOS] 降级方案失败 - 无法获取预估过期时间");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 设置VIP信息
|
||||
DataMgr.VipLevel.Value = Math.Max(DataMgr.VipLevel.Value, vipLevel);
|
||||
DataMgr.VipExpirationTime.Value = Math.Max(DataMgr.VipExpirationTime.Value, expireTimestamp);
|
||||
|
||||
Debug.Log($"[IAP IOS] 降级方案成功 - 等级: {vipLevel}, 过期时间: {expireTimestamp}");
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"[IAP IOS] 降级方案异常: {e.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取预估的过期时间戳
|
||||
/// </summary>
|
||||
private long GetEstimatedExpireTimestamp(string productId)
|
||||
{
|
||||
TimeSpan duration;
|
||||
if (productId == PRODUCT_VIP_WEEK)
|
||||
{
|
||||
duration = TimeSpan.FromDays(7);
|
||||
}
|
||||
else if (productId == PRODUCT_VIP_MONTH)
|
||||
{
|
||||
duration = TimeSpan.FromDays(30);
|
||||
}
|
||||
else if (productId == PRODUCT_VIP_YEAR)
|
||||
{
|
||||
duration = TimeSpan.FromDays(365);
|
||||
}
|
||||
else
|
||||
{
|
||||
duration = TimeSpan.FromDays(30);
|
||||
}
|
||||
|
||||
var expireDate = DateTime.UtcNow.Add(duration);
|
||||
return ((DateTimeOffset)expireDate).ToUnixTimeSeconds();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分发支付成功消息(统一出口)
|
||||
/// </summary>
|
||||
private void DispatchPaySuccess(string productId)
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
|
||||
|
||||
Debug.Log($"[IAP IOS] 支付成功并完成发货: {productId}");
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, productId);
|
||||
PurchasingManager.SendEventClickByName(productId, "open");
|
||||
PurchasingManager.SendEventClickByName(productId, "success");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>验证商品ID是否为已定义的有效商品</summary>
|
||||
/// <param name="productId">商品ID</param>
|
||||
/// <returns>是否为有效商品</returns>
|
||||
private bool IsValidProduct(string productId)
|
||||
{
|
||||
return productId == PRODUCT_FIRST_GIFT ||
|
||||
productId == PRODUCT_REMOVE_ADS ||
|
||||
productId == PRODUCT_PASS_BONUS ||
|
||||
productId == PRODUCT_SPACE_BONUS ||
|
||||
productId == PRODUCT_SHOP_1 ||
|
||||
productId == PRODUCT_SHOP_2 ||
|
||||
productId == PRODUCT_SHOP_3 ||
|
||||
productId == PRODUCT_SHOP_4 ||
|
||||
productId == PRODUCT_SHOP_5 ||
|
||||
// productId == PRODUCT_THREE_DAY ||
|
||||
productId == PRODUCT_VIP_WEEK ||
|
||||
productId == PRODUCT_VIP_MONTH ||
|
||||
productId == PRODUCT_VIP_YEAR;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4b5c2a375fb4610a0417b408c252104
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -97,15 +97,17 @@ public class MaxPayManager
|
||||
// Debug.Log("barry ios pay");
|
||||
// 调用官方支付逻辑
|
||||
isIOSPay = true;
|
||||
// var appleData = new ApplePayData
|
||||
// {
|
||||
// sku = _data.sku,
|
||||
// amount = _data.amount,
|
||||
// currency = _data.currency,
|
||||
// shopName = _data.shopName,
|
||||
// type = _data.type
|
||||
// };
|
||||
// PurchasingManager.Purchase(appleData);
|
||||
#if UNITY_IOS
|
||||
var appleData = new ApplePayData
|
||||
{
|
||||
sku = _data.sku,
|
||||
amount = _data.amount,
|
||||
currency = _data.currency,
|
||||
shopName = _data.shopName,
|
||||
type = _data.type
|
||||
};
|
||||
PurchasingManager.Purchase(appleData);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -128,52 +130,47 @@ public class MaxPayManager
|
||||
ApplePayClass paydata = data_;
|
||||
SaveData.pay_time = Time.time;
|
||||
|
||||
if (data_.sku == PurchasingManager.GetPaySku(PayType.buy_one))
|
||||
if (data_.sku == IAPPayManager.PRODUCT_SPACE_BONUS)
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.buy_one_click);
|
||||
}
|
||||
else if (data_.sku == PurchasingManager.GetPaySku(PayType.buy_one_off))
|
||||
{
|
||||
// TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.BuyOneOffClick);
|
||||
}
|
||||
else if (data_.sku != null && data_.sku == PurchasingManager.GetPaySku(PayType.remove_ad))
|
||||
// else if (data_.sku == PurchasingManager.GetPaySku(PayType.buy_one_off))
|
||||
// {
|
||||
// // TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.BuyOneOffClick);
|
||||
// }
|
||||
else if (data_.sku != null && data_.sku == IAPPayManager.PRODUCT_REMOVE_ADS)
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.remove_ad_click);
|
||||
}
|
||||
else if (data_.sku == PurchasingManager.GetPaySku(PayType.pack_reward))
|
||||
else if (data_.sku == IAPPayManager.PRODUCT_FIRST_GIFT)
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.lucky_gift_click);
|
||||
}
|
||||
else if (data_.shopName != null && data_.shopName.StartsWith("buy_gold"))
|
||||
else if (data_.sku != null && PurchasingManager.ShopProductMap.TryGetValue(data_.sku, out var idx))
|
||||
{
|
||||
int startIndex = "buy_gold".Length;
|
||||
string suffix = paydata.shopName[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
string eventClickName = $"gold_click_{suffix}";
|
||||
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.gold_click_ + suffix);
|
||||
|
||||
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.gold_click_ + idx);
|
||||
}
|
||||
else if (data_.sku.StartsWith("secret_albnums"))
|
||||
{
|
||||
string suffix = data_.sku["secret_albnums".Length..];
|
||||
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.secret_albums_click_ + suffix);
|
||||
}
|
||||
else if (data_.sku.StartsWith("vip_club"))
|
||||
else if (data_.sku != null && PurchasingManager.VipProductMap.TryGetValue(data_.sku, out var vipIdx))
|
||||
{
|
||||
string suffix = data_.sku["vip_club".Length..];
|
||||
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.vip_click_ + suffix);
|
||||
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.vip_click_ + vipIdx);
|
||||
}
|
||||
else if (data_.sku == PurchasingManager.GetPaySku(PayType.battle_pass))
|
||||
else if (data_.sku == IAPPayManager.PRODUCT_PASS_BONUS)
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.master_pass_click);
|
||||
}
|
||||
else if (data_.sku == PurchasingManager.GetPaySku(PayType.fail_pack))
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.fail_click);
|
||||
}
|
||||
else if (data_.sku == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.three_days_gift_click);
|
||||
}
|
||||
// else if (data_.sku == PurchasingManager.GetPaySku(PayType.fail_pack))
|
||||
// {
|
||||
// TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.fail_click);
|
||||
// }
|
||||
// else if (data_.sku == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
// {
|
||||
// TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.three_days_gift_click);
|
||||
// }
|
||||
|
||||
PayerData requestData = new PayerData()
|
||||
{
|
||||
@@ -348,7 +345,7 @@ public class MaxPayManager
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
|
||||
|
||||
bool isOpen = false;
|
||||
if (paydata.sku == PurchasingManager.GetPaySku(PayType.buy_one))
|
||||
if (paydata.sku == IAPPayManager.PRODUCT_SPACE_BONUS)
|
||||
{
|
||||
isOpen = HandleSku(paydata.sku, UIConst.AddViewUI, ADEventTrack.Property.buy_one_success);
|
||||
}
|
||||
@@ -356,35 +353,33 @@ public class MaxPayManager
|
||||
// {
|
||||
// isOpen = HandleSku(paydata.sku, UIConst.AddViewUI, ADEventTrack.Property.BuyOneOffSuccess);
|
||||
// }
|
||||
else if (paydata.sku != null && paydata.sku == PurchasingManager.GetPaySku(PayType.remove_ad))
|
||||
else if (paydata.sku != null && paydata.sku == IAPPayManager.PRODUCT_REMOVE_ADS)
|
||||
{
|
||||
isOpen = HandleSku(paydata.sku, UIConst.PackrewardUI, ADEventTrack.Property.remove_ad_receive);
|
||||
}
|
||||
else if (paydata.sku == PurchasingManager.GetPaySku(PayType.pack_reward))
|
||||
else if (paydata.sku == IAPPayManager.PRODUCT_FIRST_GIFT)
|
||||
{
|
||||
isOpen = HandleSku(paydata.sku, UIConst.PackrewardUI, ADEventTrack.Property.lucky_gift_receive);
|
||||
}
|
||||
else if (paydata.shopName != null && paydata.shopName.StartsWith("buy_gold"))
|
||||
else if (paydata.sku != null && PurchasingManager.ShopProductMap.TryGetValue(paydata.sku, out var idx))
|
||||
{
|
||||
int startIndex = "buy_gold".Length;
|
||||
string suffix = paydata.shopName[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
string eventSuccessName = ADEventTrack.Property.shop_receive_ + suffix;
|
||||
string eventSuccessName = ADEventTrack.Property.shop_receive_ + idx;
|
||||
|
||||
isOpen = HandleSku(paydata.sku, UIConst.BuygoldUI, eventSuccessName);
|
||||
|
||||
}
|
||||
else if (paydata.sku == PurchasingManager.GetPaySku(PayType.battle_pass))
|
||||
else if (paydata.sku == IAPPayManager.PRODUCT_PASS_BONUS)
|
||||
{
|
||||
isOpen = HandleSku(paydata.sku, UIConst.PassViewUI, ADEventTrack.Property.master_pass_receive);
|
||||
}
|
||||
else if (paydata.sku == PurchasingManager.GetPaySku(PayType.fail_pack))
|
||||
{
|
||||
isOpen = HandleSku(paydata.sku, UIConst.PackrewardUI, ADEventTrack.Property.fail_buy_success);
|
||||
}
|
||||
else if (paydata.sku == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
{
|
||||
isOpen = HandleSku(paydata.sku, UIConst.ThreeDaysGiftUI, ADEventTrack.Property.three_days_gift_buy_success);
|
||||
}
|
||||
// else if (paydata.sku == PurchasingManager.GetPaySku(PayType.fail_pack))
|
||||
// {
|
||||
// isOpen = HandleSku(paydata.sku, UIConst.PackrewardUI, ADEventTrack.Property.fail_buy_success);
|
||||
// }
|
||||
// else if (paydata.sku == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
// {
|
||||
// isOpen = HandleSku(paydata.sku, UIConst.ThreeDaysGiftUI, ADEventTrack.Property.three_days_gift_buy_success);
|
||||
// }
|
||||
else if (paydata.sku.StartsWith("secret_albnums"))
|
||||
{
|
||||
int startIndex = "secret_albnums".Length;
|
||||
@@ -393,11 +388,9 @@ public class MaxPayManager
|
||||
|
||||
isOpen = HandleSku(paydata.sku, UIConst.SecretAlbumsNextUI, eventSuccessName);
|
||||
}
|
||||
else if (paydata.shopName != null && paydata.shopName.StartsWith("vip_club"))
|
||||
else if (paydata.sku != null && PurchasingManager.VipProductMap.TryGetValue(paydata.sku, out var vipIdx))
|
||||
{
|
||||
int startIndex = "vip_club".Length;
|
||||
string suffix = paydata.shopName[startIndex..]; // 截取 "vip_club" 后的所有字符
|
||||
string eventSuccessName = ADEventTrack.Property.vip_success_ + suffix;
|
||||
string eventSuccessName = ADEventTrack.Property.vip_success_ + vipIdx;
|
||||
isOpen = HandleSku(paydata.sku, UIConst.VipClubViewUI, eventSuccessName);
|
||||
}
|
||||
else
|
||||
@@ -408,16 +401,16 @@ public class MaxPayManager
|
||||
}
|
||||
|
||||
string sku = "";
|
||||
if (paydata.sku.Contains("shop") || paydata.sku.Contains("sub"))
|
||||
{
|
||||
sku = paydata.shopName;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if (paydata.sku.Contains("shop") || paydata.sku.Contains("sub"))
|
||||
// {
|
||||
// sku = paydata.shopName;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
sku = paydata.sku;
|
||||
}
|
||||
// }
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, sku);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, sku);
|
||||
|
||||
DOVirtual.DelayedCall(1, () =>
|
||||
{
|
||||
@@ -466,7 +459,7 @@ public class MaxPayManager
|
||||
{
|
||||
sku = paydata.sku;
|
||||
}
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, paydata.sku);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, paydata.sku);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -567,18 +560,27 @@ public class MaxPayManager
|
||||
|
||||
public class maxOrder
|
||||
{
|
||||
[JsonProperty("order_id")]
|
||||
public string order_id;
|
||||
}
|
||||
|
||||
public class ApplePayClass
|
||||
{
|
||||
[JsonProperty("innerOrderId")]
|
||||
public string innerOrderId;
|
||||
[JsonProperty("transactionId")]
|
||||
public string transactionId;
|
||||
[JsonProperty("amount")]
|
||||
public int amount;
|
||||
[JsonProperty("sku")]
|
||||
public string sku;
|
||||
[JsonProperty("currency")]
|
||||
public string currency = "USD";
|
||||
[JsonProperty("status")]
|
||||
public int status;
|
||||
[JsonProperty("shopName")]
|
||||
public string shopName;
|
||||
[JsonProperty("type")]
|
||||
public string type;
|
||||
}
|
||||
|
||||
@@ -594,9 +596,13 @@ public class ApplePayClass
|
||||
|
||||
public class PayerData
|
||||
{
|
||||
[JsonProperty("name")]
|
||||
public string name;
|
||||
[JsonProperty("tel")]
|
||||
public string tel;
|
||||
[JsonProperty("email")]
|
||||
public string email;
|
||||
[JsonProperty("amount")]
|
||||
public int amount;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace RedHotRoast
|
||||
// btn_WatchAd = ui.btn_watch as btn_watchAd;
|
||||
if (GameHelper.IsAdModelOfPay())
|
||||
{
|
||||
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.buy_one), ui.btn_watch as btn_watchAd, SetTextString);
|
||||
AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_SPACE_BONUS, ui.btn_watch as btn_watchAd, SetTextString);
|
||||
ui.pay_type.selectedIndex = 0;
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace RedHotRoast
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)Math.Round(price * 100),
|
||||
sku =PurchasingManager.GetPaySku(PayType.buy_one),
|
||||
sku =IAPPayManager.PRODUCT_SPACE_BONUS,
|
||||
currency = "USD"
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
@@ -102,12 +102,12 @@ namespace RedHotRoast
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
|
||||
}
|
||||
#endregion
|
||||
@@ -115,7 +115,7 @@ namespace RedHotRoast
|
||||
{
|
||||
string type = (string)str;
|
||||
|
||||
if (type == PurchasingManager.GetPaySku(PayType.buy_one))
|
||||
if (type == IAPPayManager.PRODUCT_SPACE_BONUS)
|
||||
{
|
||||
CtrlCloseUI();
|
||||
}
|
||||
@@ -147,7 +147,7 @@ namespace RedHotRoast
|
||||
|
||||
public void SetTextString()
|
||||
{
|
||||
var need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.buy_one));
|
||||
var need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_SPACE_BONUS);
|
||||
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
|
||||
|
||||
ui.text_watch_ad.SetVar("needNum", need.ToString()).FlushVars();
|
||||
|
||||
@@ -161,8 +161,8 @@ namespace RedHotRoast
|
||||
void timeEvent()
|
||||
{
|
||||
time_count++;
|
||||
Debug.Log(time_count);
|
||||
Debug.Log(MaxTime);
|
||||
// Debug.Log(time_count);
|
||||
// Debug.Log(MaxTime);
|
||||
if (time_count > MaxTime)
|
||||
{
|
||||
time_count = 0;
|
||||
|
||||
@@ -511,8 +511,9 @@ namespace RedHotRoast
|
||||
|
||||
ui.btn_live.SetClick(() =>
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretUnlockUI_Open);
|
||||
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LiveUI_Open);
|
||||
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LiveUI_Open);
|
||||
|
||||
});
|
||||
ui.btn_secret.title = "LV." + GameHelper.GetCommonModel().UnlockSecret[1];
|
||||
@@ -593,6 +594,8 @@ namespace RedHotRoast
|
||||
ui.btn_task.SetClick(() => { OnClickTask(false); });
|
||||
ui.btn_restore.SetClick(() =>
|
||||
{
|
||||
IAPPayManager.Instance.OnRestoreButtonClicked();
|
||||
|
||||
// ApplePayManager.Instance.AppleRestore((success, message) =>
|
||||
// {
|
||||
// Debug.Log($"[barry] restore success message: {message}---- {JsonConvert.SerializeObject(message)}");
|
||||
|
||||
@@ -73,8 +73,8 @@ namespace RedHotRoast
|
||||
if (GameHelper.IsAdModelOfPay())
|
||||
{
|
||||
|
||||
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.pack_reward), ui.btn_buypack as btn_watchAd, SetTextString1);
|
||||
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.remove_ad), ui.btn_buyremovead as btn_watchAd, SetTextString1);
|
||||
AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_FIRST_GIFT, ui.btn_buypack as btn_watchAd, SetTextString1);
|
||||
AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_REMOVE_ADS, ui.btn_buyremovead as btn_watchAd, SetTextString1);
|
||||
}
|
||||
|
||||
ui.btn_go_ad.SetClick(() =>
|
||||
@@ -122,18 +122,18 @@ namespace RedHotRoast
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
}
|
||||
#endregion
|
||||
void pay_success(object str)
|
||||
{
|
||||
string type = (string)str;
|
||||
Debug.Log($"pay_success type================{type}");
|
||||
if (type == PurchasingManager.GetPaySku(PayType.remove_ad))
|
||||
if (type == IAPPayManager.PRODUCT_REMOVE_ADS)
|
||||
{
|
||||
var gold = list[1].coins_quantity;
|
||||
var start = GameHelper.GetUICenterPosition(ui.text_goldnum2);
|
||||
@@ -168,7 +168,7 @@ namespace RedHotRoast
|
||||
|
||||
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.pack_reward))
|
||||
else if (type == IAPPayManager.PRODUCT_FIRST_GIFT)
|
||||
{
|
||||
var start = GameHelper.GetUICenterPosition(ui.text_goldnum);
|
||||
var end = GameHelper.GetUICenterPosition(ui.gold.GetChild("icon"));
|
||||
@@ -249,7 +249,7 @@ namespace RedHotRoast
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)Math.Round(price_pack * 100),
|
||||
sku = PurchasingManager.GetPaySku(PayType.pack_reward),
|
||||
sku = IAPPayManager.PRODUCT_FIRST_GIFT,
|
||||
currency = "USD"
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
@@ -281,7 +281,7 @@ namespace RedHotRoast
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)Math.Round(price_remove * 100),
|
||||
sku = PurchasingManager.GetPaySku(PayType.remove_ad),
|
||||
sku = IAPPayManager.PRODUCT_REMOVE_ADS,
|
||||
currency = "USD"
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
@@ -350,8 +350,8 @@ namespace RedHotRoast
|
||||
|
||||
public void SetTextString1()
|
||||
{
|
||||
var remove_need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.remove_ad));
|
||||
var pack_need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.pack_reward));
|
||||
var remove_need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_REMOVE_ADS);
|
||||
var pack_need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_FIRST_GIFT);
|
||||
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
|
||||
|
||||
ui.ads.SetVar("num", myAd.ToString()).FlushVars();
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace RedHotRoast
|
||||
ui.com_gold.y += Screen.safeArea.y;
|
||||
|
||||
}
|
||||
ui.gift_switch.selectedIndex = 1;
|
||||
ui.gift_switch.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0;
|
||||
|
||||
total_item = 8;
|
||||
selectIndex = DataMgr.PlayerAvatarId.Value;
|
||||
@@ -143,6 +143,8 @@ namespace RedHotRoast
|
||||
// ui.btn_credits.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 2); });
|
||||
ui.btn_restore.SetClick(() =>
|
||||
{
|
||||
//恢复购买按钮
|
||||
IAPPayManager.Instance.OnRestoreButtonClicked();
|
||||
// ApplePayManager.Instance.AppleRestore((success, message) =>
|
||||
// {
|
||||
// if (success)
|
||||
|
||||
@@ -82,12 +82,12 @@ namespace RedHotRoast {
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener() {
|
||||
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.Update101, SetTopCurr);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.Gold_refresh, SetTopCurr);
|
||||
}
|
||||
protected override void RemoveListener() {
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.Update101, SetTopCurr);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.Gold_refresh, SetTopCurr);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ namespace RedHotRoast {
|
||||
|
||||
private void pay_success(object a) {
|
||||
string type = (string) a;
|
||||
if (type == PurchasingManager.GetPaySku(PayType.battle_pass)){
|
||||
if (type == IAPPayManager.PRODUCT_PASS_BONUS){
|
||||
DOVirtual.DelayedCall(0.5f, () => {
|
||||
SaveData.GetSaveObject().is_get_battlepass = true;
|
||||
int gold = 0;
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace RedHotRoast
|
||||
{
|
||||
if (GameHelper.IsAdModelOfPay()) {
|
||||
ui.pay_type.selectedIndex = 0;
|
||||
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.battle_pass), ui.btn_buypass as btn_watchAd,SetTextString);
|
||||
AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_PASS_BONUS, ui.btn_buypass as btn_watchAd,SetTextString);
|
||||
|
||||
AdExchangeManager.Instance.Start();
|
||||
SetTextString();
|
||||
@@ -64,7 +64,7 @@ namespace RedHotRoast
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)Math.Round(price * 100),
|
||||
sku = PurchasingManager.GetPaySku(PayType.battle_pass),
|
||||
sku = IAPPayManager.PRODUCT_PASS_BONUS,
|
||||
currency = "USD"
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
@@ -95,11 +95,11 @@ namespace RedHotRoast
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
}
|
||||
#endregion
|
||||
void pay_success(object str)
|
||||
@@ -107,7 +107,7 @@ namespace RedHotRoast
|
||||
string type = (string)str;
|
||||
string purch_number = "";
|
||||
|
||||
if (type == PurchasingManager.GetPaySku(PayType.battle_pass))
|
||||
if (type == IAPPayManager.PRODUCT_PASS_BONUS)
|
||||
{
|
||||
CtrlCloseUI();
|
||||
}
|
||||
@@ -136,7 +136,7 @@ namespace RedHotRoast
|
||||
|
||||
public void SetTextString()
|
||||
{
|
||||
var need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.battle_pass));
|
||||
var need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_PASS_BONUS);
|
||||
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
|
||||
|
||||
ui.tips.SetVar("num", need.ToString()).FlushVars();
|
||||
|
||||
@@ -60,14 +60,14 @@ namespace RedHotRoast
|
||||
{
|
||||
uiCtrlDispatcher.AddListener(openUIMsg, OpenUI);
|
||||
uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI);
|
||||
uiCtrlDispatcher.RemoveListener(closeUIMsg, CloseUI);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
|
||||
}
|
||||
|
||||
@@ -102,13 +102,9 @@ namespace RedHotRoast
|
||||
bool is_maxPay = false; // 第三方支付
|
||||
string type = (string)str;
|
||||
string purch_number = "";
|
||||
if (type.Contains("buy_gold"))
|
||||
if (PurchasingManager.ShopProductMap.TryGetValue(type, out var shopIdx))
|
||||
{
|
||||
if (type.StartsWith("buy_gold"))
|
||||
{
|
||||
int startIndex = "buy_gold".Length;
|
||||
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
int suffix_num = int.Parse(suffix);
|
||||
int suffix_num = int.Parse(shopIdx);
|
||||
|
||||
purch_number = ConfigSystem.GetConfig<Paidcoins>()[suffix_num].Payment_amount2.ToString();
|
||||
|
||||
@@ -123,9 +119,7 @@ namespace RedHotRoast
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.battle_pass))
|
||||
else if (type == IAPPayManager.PRODUCT_PASS_BONUS)
|
||||
{
|
||||
SaveData.GetSaveObject().is_get_battlepass = true;
|
||||
int gold = 0;
|
||||
@@ -158,7 +152,7 @@ namespace RedHotRoast
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
}
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.buy_one))
|
||||
else if (type == IAPPayManager.PRODUCT_SPACE_BONUS)
|
||||
{
|
||||
SaveData.GetSaveObject().have_slot = true;
|
||||
SaveData.SaveDataFunc();
|
||||
@@ -167,7 +161,7 @@ namespace RedHotRoast
|
||||
|
||||
purch_number = GameHelper.GetCommonModel().addspace2.ToString();
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.remove_ad))
|
||||
else if (type == IAPPayManager.PRODUCT_REMOVE_ADS)
|
||||
{
|
||||
SaveData.GetSaveObject().remove_ad_time = (int)GameHelper.GetNowTime() + GameHelper.GetCommonModel().RemoveADsPackDuration * 3600;
|
||||
SaveData.GetSaveObject().is_get_removead = true;
|
||||
@@ -179,7 +173,7 @@ namespace RedHotRoast
|
||||
GameHelper.ShowTips("purchase_succ", true);
|
||||
purch_number = ConfigSystem.GetConfig<Paidgift>()[1].Paid_price2.ToString();
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.pack_reward))
|
||||
else if (type == IAPPayManager.PRODUCT_FIRST_GIFT)
|
||||
{
|
||||
List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
|
||||
int gold_num = list[0].coins_quantity;
|
||||
@@ -199,40 +193,38 @@ namespace RedHotRoast
|
||||
GameHelper.ShowTips("purchase_succ", true);
|
||||
purch_number = ConfigSystem.GetConfig<Paidgift>()[0].Paid_price2.ToString();
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.fail_pack))
|
||||
{
|
||||
List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
|
||||
purch_number = ConfigSystem.GetConfig<Paidgift>()[2].Paid_price2.ToString();
|
||||
//ui?.setBtnAds();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.resurgence);
|
||||
|
||||
// DataMgr.Coin.Value += ConfigSystem.GetConfig<PaidgiftModel>().DataList[1].coins_quantity;
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
int back_num = list[2].props_quantity[1];
|
||||
int out_num = list[2].props_quantity[0];
|
||||
int refresh_num = list[2].props_quantity[2];
|
||||
//GameHelper.addGoldNumber(gold_num);
|
||||
int gold_num = list[2].coins_quantity;
|
||||
if (!UIManager.Instance.IsExistUI(UIConst.ResurgenceUI)) DataMgr.Coin.Value += gold_num;
|
||||
GameHelper.AddItemNumber(0, out_num);
|
||||
GameHelper.AddItemNumber(1, back_num);
|
||||
GameHelper.AddItemNumber(2, refresh_num);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
|
||||
SaveData.SaveDataFunc();
|
||||
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
{
|
||||
SaveData.GetSaveObject().is_get_ThreeDaysGift = true;
|
||||
SaveData.SaveDataFunc();
|
||||
purch_number = ConfigSystem.GetConfig<Multigift>()[0].Paid_price2.ToString();
|
||||
}
|
||||
else if (type.StartsWith("vip_club"))
|
||||
// else if (type == PurchasingManager.GetPaySku(PayType.fail_pack))
|
||||
// {
|
||||
// List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
|
||||
// purch_number = ConfigSystem.GetConfig<Paidgift>()[2].Paid_price2.ToString();
|
||||
// //ui?.setBtnAds();
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.resurgence);
|
||||
//
|
||||
// // DataMgr.Coin.Value += ConfigSystem.GetConfig<PaidgiftModel>().DataList[1].coins_quantity;
|
||||
// // GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
// int back_num = list[2].props_quantity[1];
|
||||
// int out_num = list[2].props_quantity[0];
|
||||
// int refresh_num = list[2].props_quantity[2];
|
||||
// //GameHelper.addGoldNumber(gold_num);
|
||||
// int gold_num = list[2].coins_quantity;
|
||||
// if (!UIManager.Instance.IsExistUI(UIConst.ResurgenceUI)) DataMgr.Coin.Value += gold_num;
|
||||
// GameHelper.AddItemNumber(0, out_num);
|
||||
// GameHelper.AddItemNumber(1, back_num);
|
||||
// GameHelper.AddItemNumber(2, refresh_num);
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
|
||||
// SaveData.SaveDataFunc();
|
||||
//
|
||||
// }
|
||||
// else if (type == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
// {
|
||||
// SaveData.GetSaveObject().is_get_ThreeDaysGift = true;
|
||||
// SaveData.SaveDataFunc();
|
||||
// purch_number = ConfigSystem.GetConfig<Multigift>()[0].Paid_price2.ToString();
|
||||
// }
|
||||
else if (PurchasingManager.VipProductMap.TryGetValue(type, out var vipIdx))
|
||||
{
|
||||
is_maxPay = true;
|
||||
int startIndex = "vip_club".Length;
|
||||
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
int suffixNum = int.Parse(suffix);
|
||||
int suffixNum = int.Parse(vipIdx);
|
||||
|
||||
if (!MaxPayManager.isIOSPay)
|
||||
{
|
||||
@@ -287,16 +279,36 @@ namespace RedHotRoast
|
||||
// 付费上报BI
|
||||
BIManager.Instance.TrackPurchase(purch_number.As<double>(), "USD", payType.ToString(), type, "paid");
|
||||
|
||||
Debug.Log("付费收益上报AF----------- " + revenue);
|
||||
adCallbackInfo.Clear();
|
||||
adCallbackInfo.Add("appsflyer_id", AppsFlyer.getAppsFlyerId());
|
||||
adCallbackInfo.Add("customer_user_id", GameHelper.GetLoginModel().Uid.ToString());
|
||||
adCallbackInfo.Add("af_currency", "USD");
|
||||
adCallbackInfo.Add("af_revenue", revenue.ToString(CultureInfo.InvariantCulture));
|
||||
AppsFlyer.sendEvent("af_purchase", adCallbackInfo);
|
||||
// Debug.Log("付费收益上报AF----------- " + revenue);
|
||||
// adCallbackInfo.Clear();
|
||||
// adCallbackInfo.Add("appsflyer_id", AppsFlyer.getAppsFlyerId());
|
||||
// adCallbackInfo.Add("customer_user_id", GameHelper.GetLoginModel().Uid.ToString());
|
||||
// adCallbackInfo.Add("af_currency", "USD");
|
||||
// adCallbackInfo.Add("af_revenue", revenue.ToString(CultureInfo.InvariantCulture));
|
||||
// AppsFlyer.sendEvent("af_purchase", adCallbackInfo);
|
||||
|
||||
TrackKit.SendEvent(AfPurchaseTrack.Event, AfPurchaseTrack.Property.af_revenue, (int)(purch_number.As<decimal>() * 10000));
|
||||
|
||||
|
||||
|
||||
|
||||
var payData = new ApplePayData
|
||||
{
|
||||
sku = type,
|
||||
currency = "USD",
|
||||
amount = (int)(purch_number.As<decimal>() * 100),
|
||||
isCompleted = true
|
||||
};
|
||||
//上报给服务器,用来做数据分析
|
||||
PurchasingManager.ApplePayCreate<ApplePayData>(payData, (response) =>
|
||||
{
|
||||
Debug.Log($"[付费收益] Purchase-----type--{type}----{response.IsSuccess}");
|
||||
|
||||
if (response.IsSuccess)
|
||||
{
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -307,9 +307,9 @@ namespace RedHotRoast
|
||||
{
|
||||
if (Screen.safeArea.y != 0)
|
||||
{
|
||||
ui.btn_gold.y += 68;
|
||||
ui.btn_close.y += 68;
|
||||
ui.sc_list.y += 68;
|
||||
ui.btn_gold.y += 58;
|
||||
ui.btn_close.y += 58;
|
||||
ui.sc_list.y += 38;
|
||||
}
|
||||
|
||||
var eventName = GameHelper.IsAdModelOfPay() ? ADEventTrack.Event : ADEventTrack.MaxPayEvent;
|
||||
|
||||
@@ -109,13 +109,13 @@ namespace RedHotRoast
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, InitView);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, InitView);
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ namespace RedHotRoast
|
||||
if (GameHelper.Get101() >= _albumPreviewData.GoldCoins)
|
||||
{
|
||||
GameHelper.AddGold(-_albumPreviewData.GoldCoins);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, _type);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, _type);
|
||||
|
||||
string eventName = ADEventTrack.Property.secret_albums_success_ + (_albumPreviewData.Index + 1);
|
||||
TrackKit.SendEvent(ADEventTrack.SecretAlbums, eventName);
|
||||
@@ -258,7 +258,7 @@ namespace RedHotRoast
|
||||
|
||||
if (AdCount >= _albumPreviewData.AD)
|
||||
{
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, _type);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, _type);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -288,7 +288,7 @@ namespace RedHotRoast
|
||||
if (GameHelper.GetVipLevel() > 0)
|
||||
{
|
||||
GameHelper.isVipUnlock = true;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, _type);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, _type);
|
||||
|
||||
string eventName = ADEventTrack.Property.vip_secret_albums_unclock_ + (_albumPreviewData.Index + 1);
|
||||
TrackKit.SendEvent(ADEventTrack.VipSecretAlbums, eventName);
|
||||
|
||||
@@ -108,12 +108,12 @@ namespace RedHotRoast
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -150,72 +150,15 @@ namespace RedHotRoast
|
||||
string type = (string)str;
|
||||
string purch_number = "";
|
||||
|
||||
if (type.StartsWith("buy_gold"))
|
||||
if (PurchasingManager.ShopProductMap.TryGetValue(type, out var idx))
|
||||
{
|
||||
int startIndex = "buy_gold".Length;
|
||||
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
int suffix_num = int.Parse(suffix);
|
||||
|
||||
int suffix_num = int.Parse(idx);
|
||||
SaveData.GetSaveObject()._goldtime[suffix_num] = (int)GameHelper.GetNowTime();
|
||||
SaveData.SaveDataFunc();
|
||||
GetAward(list[suffix_num].Actual_coins, suffix_num);
|
||||
purch_number = list[suffix_num].Payment_amount.ToString();
|
||||
Isbuysuccess = true;
|
||||
}
|
||||
// else if (type == AdExchangeManager.pack_reward)
|
||||
// {
|
||||
// var end = GameHelper.GetUICenterPosition(ui.top_gold.GetChild("icon"));
|
||||
// var gold = (decimal)_paidGiftList[0].coins_quantity;
|
||||
|
||||
// var rewardData = new RewardData();
|
||||
// var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
|
||||
// {
|
||||
// endPosition = end,
|
||||
// };
|
||||
// rewardData.AddReward(rewardSingleData);
|
||||
// rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
||||
// rewardData.AddCompleted((isScu) =>
|
||||
// {
|
||||
// DOVirtual.DelayedCall(0.5f, () =>
|
||||
// {
|
||||
// var startNum = DataMgr.Coin.Value - gold;
|
||||
// DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 1f,
|
||||
// value => { ui.top_gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); });
|
||||
// });
|
||||
// });
|
||||
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
||||
// SaveData.GetSaveObject().is_get_packreward = true;
|
||||
// Isbuysuccess = true;
|
||||
// }
|
||||
// else if (type == AdExchangeManager.remove_ad)
|
||||
// {
|
||||
// var end = GameHelper.GetUICenterPosition(ui.top_gold.GetChild("icon"));
|
||||
// var gold = (decimal)_paidGiftList[1].coins_quantity;
|
||||
|
||||
// var rewardData = new RewardData();
|
||||
// var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
|
||||
// {
|
||||
// endPosition = new Vector2(end.x, end.y)
|
||||
// };
|
||||
// rewardData.AddReward(rewardSingleData);
|
||||
// rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
||||
// rewardData.AddCompleted(isScu =>
|
||||
// {
|
||||
// DOVirtual.DelayedCall(0.5f, () =>
|
||||
// {
|
||||
// var startNum = DataMgr.Coin.Value - gold;
|
||||
// DOVirtual.Float((float)startNum, GameHelper.GetGoldNumber(), 1f,
|
||||
// value => { ui.top_gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); });
|
||||
// });
|
||||
// });
|
||||
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
||||
// SaveData.GetSaveObject().is_get_removead = true;
|
||||
// Isbuysuccess = true;
|
||||
// }
|
||||
|
||||
|
||||
InitView();
|
||||
}
|
||||
|
||||
@@ -288,192 +231,6 @@ namespace RedHotRoast
|
||||
private SkeletonAnimation no_ad_anims = null;
|
||||
private Action closeCallback = null;
|
||||
|
||||
|
||||
// private void UpdatePack(int index, GObject obj)
|
||||
// {
|
||||
// item_gift item_gift = (item_gift)obj;
|
||||
//
|
||||
// var gold_num = _paidGiftList[0].coins_quantity;
|
||||
// var back_num = _paidGiftList[0].props_quantity[1];
|
||||
// var out_num = _paidGiftList[0].props_quantity[0];
|
||||
// var refresh_num = _paidGiftList[0].props_quantity[2];
|
||||
//
|
||||
// item_gift.text_goldnum.text = "x" + GameHelper.Get101Str(gold_num);
|
||||
// item_gift.text_backnum1.text = "x" + back_num;
|
||||
// item_gift.text_outnum.text = "x" + out_num;
|
||||
// item_gift.text_refreshnum.text = "x" + refresh_num;
|
||||
//
|
||||
// item_gift.text_goldnum2.text = "x" + GameHelper.Get101Str(_paidGiftList[1].coins_quantity);
|
||||
//
|
||||
// switch (index)
|
||||
// {
|
||||
// case 0:
|
||||
// item_gift.anim_gold.visible = true;
|
||||
// item_gift.anim_no_ad.visible = false;
|
||||
// item_gift.type.selectedIndex = 0;
|
||||
// pack_anims ??= FXManager.Instance.SetFx<SkeletonAnimation>(item_gift.anim_gold, Fx_Type.fx_pack_gold, ref closeCallback);
|
||||
// pack_anims.state.SetAnimation(0, "animation2", true);
|
||||
// break;
|
||||
// case 1:
|
||||
// item_gift.anim_gold.visible = false;
|
||||
// item_gift.anim_no_ad.visible = true;
|
||||
// no_ad_anims ??= FXManager.Instance.SetFx<SkeletonAnimation>(item_gift.anim_no_ad, Fx_Type.fx_no_ad, ref closeCallback);
|
||||
// item_gift.type.selectedIndex = 1;
|
||||
// no_ad_anims.state.SetAnimation(0, "wait", true);
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// btn_remove_get = item_gift.btn_remove_get;
|
||||
//
|
||||
// if (GameHelper.IsGiftSwitch()) {
|
||||
// item_gift.lab_time.visible = true;
|
||||
// item_gift.lab_time.SetVar("num", ConfigSystem.GetConfig<CommonModel>().RemoveADsPackDuration.ToString()).FlushVars();
|
||||
// }
|
||||
// else {
|
||||
// item_gift.lab_time.visible = false;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if (!GameHelper.IsAdModelOfPay())
|
||||
// {
|
||||
// decimal price_pack = (decimal)_paidGiftList[0].Paid_price2;
|
||||
// item_gift.btn_pack_get.title = GameHelper.Get102Str(price_pack);
|
||||
// bool is_get = SaveData.GetSaveObject().is_get_packreward;
|
||||
// if (is_get)
|
||||
// {
|
||||
// item_gift.btn_pack_get.enabled = false;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// item_gift.btn_pack_get.SetClick(() =>
|
||||
// {
|
||||
// ApplePayClass maxPayData = new ApplePayClass
|
||||
// {
|
||||
// amount = (int)Math.Round(price_pack * 100),
|
||||
// sku = MaxPayManager.pack_reward,
|
||||
// currency = "USD"
|
||||
// };
|
||||
// MaxPayManager.Instance.Buy(maxPayData);
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// decimal price_remove = (decimal)_paidGiftList[1].Paid_price2;
|
||||
// bool is_get1 = SaveData.GetSaveObject().is_get_removead;
|
||||
//
|
||||
// if (is_get1)
|
||||
// {
|
||||
// btn_remove_get.enabled = false;
|
||||
//
|
||||
// btn_remove_get.SetClick(() => { });
|
||||
// HallManager.Instance.UpdateSecondEvent += RemoveAdCountDown;
|
||||
//
|
||||
// int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
|
||||
// if (cd > 24 * 3600) {
|
||||
// btn_remove_get.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
|
||||
// }
|
||||
// else {
|
||||
// btn_remove_get.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// btn_remove_get.title = GameHelper.Get102Str(price_remove);
|
||||
// btn_remove_get.enabled = true;
|
||||
// btn_remove_get.SetClick(() =>
|
||||
// {
|
||||
// ApplePayClass maxPayData = new ApplePayClass
|
||||
// {
|
||||
// amount = (int)Math.Round(price_remove * 100),
|
||||
// sku = MaxPayManager.remove_ad,
|
||||
// currency = "USD"
|
||||
// };
|
||||
// MaxPayManager.Instance.Buy(maxPayData);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// int myAds = AdExchangeManager.Instance.GetLookRewardADNum();
|
||||
// int pack_reward_ad_count = AdExchangeManager.Instance.GetCeilingNeedAds(AdExchangeManager.pack_reward);
|
||||
// var remove_need = AdExchangeManager.Instance.GetCeilingNeedAds(AdExchangeManager.remove_ad);
|
||||
// item_gift.btn_pack_get.title = pack_reward_ad_count + "ADs";
|
||||
// btn_remove_get.title = remove_need + "ADs";
|
||||
//
|
||||
// bool is_get = SaveData.GetSaveObject().is_get_packreward;
|
||||
// if (is_get)
|
||||
// {
|
||||
// item_gift.btn_pack_get.enabled = false;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (myAds >= pack_reward_ad_count)
|
||||
// {
|
||||
// item_gift.btn_pack_get.state.selectedIndex = 0;
|
||||
// item_gift.btn_pack_get.title = "Redeem";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// item_gift.btn_pack_get.state.selectedIndex = 1;
|
||||
// item_gift.btn_pack_get.title = pack_reward_ad_count + " ADs";
|
||||
// }
|
||||
//
|
||||
// item_gift.btn_pack_get.SetClick(() =>
|
||||
// {
|
||||
// AdExchangeData test = new AdExchangeData
|
||||
// {
|
||||
// ad_count = pack_reward_ad_count,
|
||||
// type = AdExchangeManager.pack_reward
|
||||
// };
|
||||
// AdExchangeManager.Instance.Exchange(test);
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// is_get = SaveData.GetSaveObject().is_get_removead;
|
||||
// if (is_get)
|
||||
// {
|
||||
//
|
||||
//
|
||||
// HallManager.Instance.UpdateSecondEvent += RemoveAdCountDown;
|
||||
// btn_remove_get.enabled = false;
|
||||
// btn_remove_get.SetClick(() => { });
|
||||
// int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
|
||||
// if (cd > 24 * 3600) {
|
||||
// btn_remove_get.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
|
||||
// }
|
||||
// else {
|
||||
// btn_remove_get.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// btn_remove_get.enabled = true;
|
||||
//
|
||||
// if (myAds >= remove_need)
|
||||
// {
|
||||
// btn_remove_get.state.selectedIndex = 0;
|
||||
// btn_remove_get.title = "Redeem";
|
||||
//
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// btn_remove_get.state.selectedIndex = 1;
|
||||
// btn_remove_get.title = remove_need + " ADs";
|
||||
// }
|
||||
//
|
||||
// btn_remove_get.SetClick(() =>
|
||||
// {
|
||||
// AdExchangeData test = new AdExchangeData
|
||||
// {
|
||||
// ad_count = AdExchangeManager.Instance.GetCeilingNeedAds(AdExchangeManager.remove_ad),
|
||||
// type = AdExchangeManager.remove_ad
|
||||
// };
|
||||
// AdExchangeManager.Instance.Exchange(test);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
void setRemaintime(int index, GObject obj)
|
||||
{
|
||||
buygold_item item = (buygold_item)obj;
|
||||
@@ -491,73 +248,93 @@ namespace RedHotRoast
|
||||
//
|
||||
// if (list[index].Discount_rate != 0) item.off_text.text = list[index].Discount_rate + "%";
|
||||
|
||||
if (AdExchangeManager.Instance.GetLookRewardADNum() >= list[index].Payment_amount)
|
||||
if (time + list[index].receive_CD < GameHelper.GetNowTime())
|
||||
{
|
||||
if (!GameHelper.IsAdModelOfPay())
|
||||
item.btn_buy.can_buy.selectedIndex = 0;
|
||||
if (!GameHelper.IsAdModelOfPay()){
|
||||
item.btn_buy.index.selectedIndex = 1;
|
||||
item.text_ads.visible = false;
|
||||
|
||||
if (!is_paid)
|
||||
{
|
||||
item.btn_buy.btn_text.text = "Free";
|
||||
// item.discount.visible = false;
|
||||
item.index.selectedIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//支付
|
||||
decimal price = (decimal)list[index].Payment_amount2;
|
||||
item.btn_buy.btn_text.text = GameHelper.getPrice(price);
|
||||
}
|
||||
item.btn_buy.SetClick(() =>
|
||||
{
|
||||
rm_Gold(index);
|
||||
});
|
||||
} else {
|
||||
int myAds = AdExchangeManager.Instance.GetLookRewardADNum();
|
||||
int count = (int)list[index].Payment_amount;
|
||||
if (is_paid)
|
||||
{
|
||||
item.text_ads.SetVar("num", count.ToString()).FlushVars();
|
||||
}
|
||||
if (myAds >= count)
|
||||
{
|
||||
item.btn_buy.index.selectedIndex = 1;
|
||||
if (!is_paid)
|
||||
{
|
||||
item.btn_buy.btn_text.text = Language.GetContent("free");
|
||||
// item.discount.visible = false;
|
||||
item.index.selectedIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.btn_buy.btn_text.text = Language.GetContent("exchange");
|
||||
}
|
||||
|
||||
item.btn_buy.SetClick(() =>
|
||||
{
|
||||
rm_Gold(index);
|
||||
});
|
||||
}
|
||||
// else if (SaveData.GetSaveObject()._watch_ad_cd > GameHelper.GetNowTime())
|
||||
// {
|
||||
// item.btn_buy.can_buy.selectedIndex = 1;
|
||||
// item.btn_buy.index.selectedIndex = 1;
|
||||
// item.btn_buy.btn_text.text = CommonHelper.TimeFormat(SaveData.GetSaveObject()._watch_ad_cd - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
|
||||
// item.btn_buy.SetClick(() => { });
|
||||
// }
|
||||
else
|
||||
{
|
||||
item.btn_buy.can_buy.selectedIndex = 0;
|
||||
item.btn_buy.index.selectedIndex = 0;
|
||||
item.btn_buy.btn_text.text = count + " ADs";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!is_paid)
|
||||
{
|
||||
// item.discount.visible = false;
|
||||
item.index.selectedIndex = 0;
|
||||
}
|
||||
if (!GameHelper.IsAdModelOfPay())
|
||||
{
|
||||
item.text_ads.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//广告
|
||||
double gold_price1 = list[index].Payment_amount;
|
||||
int needAds = (int)Math.Ceiling(gold_price1);
|
||||
// item.text_ads.SetVar("num", needAds.ToString()).FlushVars();
|
||||
item.btn_buy.btn_text.text = needAds + " AD";
|
||||
if (is_paid)
|
||||
{
|
||||
int count = (int)list[index].Payment_amount;
|
||||
item.text_ads.SetVar("num", count.ToString()).FlushVars();
|
||||
}
|
||||
}
|
||||
|
||||
item.btn_buy.can_buy.selectedIndex = 1;
|
||||
item.btn_buy.index.selectedIndex = 1;
|
||||
|
||||
item.btn_buy.can_buy.selectedIndex = 0;
|
||||
item.btn_buy.SetClick(() =>
|
||||
{
|
||||
if (!is_paid)
|
||||
{
|
||||
SaveData.GetSaveObject()._goldtime[index] = (int)GameHelper.GetNowTime();
|
||||
SaveData.SaveDataFunc();
|
||||
GetAward(list[index].Actual_coins, index);
|
||||
|
||||
InitView();
|
||||
}
|
||||
else
|
||||
{
|
||||
rm_Gold(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
item.btn_buy.can_buy.selectedIndex = 1;
|
||||
if (!GameHelper.IsAdModelOfPay())
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
double gold_price1 = list[index].Payment_amount;
|
||||
int needAds = (int)Math.Ceiling(gold_price1);
|
||||
item.btn_buy.btn_text.text = needAds + " AD";
|
||||
}
|
||||
|
||||
item.btn_buy.btn_text.text = CommonHelper.TimeFormat(time + list[index].receive_CD - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
|
||||
item.btn_buy.SetClick(() =>{});
|
||||
}
|
||||
|
||||
if (!is_paid)
|
||||
{
|
||||
if(time + list[index].receive_CD < GameHelper.GetNowTime())
|
||||
{
|
||||
item.btn_buy.btn_text.text = Language.GetContent("free");
|
||||
}
|
||||
else
|
||||
{
|
||||
item.btn_buy.can_buy.selectedIndex = 1;
|
||||
item.btn_buy.btn_text.text = CommonHelper.TimeFormat(
|
||||
time + list[index].receive_CD - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void rm_Gold(int index)
|
||||
@@ -584,12 +361,24 @@ namespace RedHotRoast
|
||||
// Debug.Log($"amount============={maxPayData.amount}");
|
||||
// MaxPayManager.Instance.Buy(maxPayData);
|
||||
// }
|
||||
string _type = getShopName(index);
|
||||
|
||||
var isPaid = list[index].is_paid;
|
||||
if (!isPaid)
|
||||
{
|
||||
SaveData.GetSaveObject()._goldtime[index] = (int)GameHelper.GetNowTime();
|
||||
SaveData.SaveDataFunc();
|
||||
GetAward(list[index].Actual_coins, index);
|
||||
|
||||
InitView();
|
||||
return;
|
||||
}
|
||||
|
||||
var skuType = GetShopName(index);
|
||||
if (GameHelper.IsAdModelOfPay())
|
||||
{
|
||||
AdExchangeData test = new AdExchangeData()
|
||||
var test = new AdExchangeData()
|
||||
{
|
||||
ad_count = AdExchangeManager.Instance.GetCeilingNeedAds(_type),
|
||||
ad_count = AdExchangeManager.Instance.GetCeilingNeedAds(skuType),
|
||||
type = $"buy_gold{index}",
|
||||
shopName = $"buy_gold{index}"
|
||||
};
|
||||
@@ -597,21 +386,20 @@ namespace RedHotRoast
|
||||
}
|
||||
else
|
||||
{
|
||||
decimal price = (decimal)list[index].Payment_amount2;
|
||||
ApplePayClass maxPayData = new ApplePayClass()
|
||||
var price = (decimal)list[index].Payment_amount2;
|
||||
var maxPayData = new ApplePayClass()
|
||||
{
|
||||
amount = (int)Math.Round(price * 100),
|
||||
sku = _type,
|
||||
sku = skuType,
|
||||
currency = "USD",
|
||||
shopName = $"buy_gold{index}"
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
}
|
||||
}
|
||||
public string getShopName(int index)
|
||||
private string GetShopName(int index)
|
||||
{
|
||||
string name;
|
||||
name = list[index].SKU;
|
||||
var name = list[index].SKU;
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace RedHotRoast
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)System.Math.Round(vip_list[0].DiscountPrice * 100),
|
||||
sku = PurchasingManager.GetPaySku(PayType.weekly_subscription),
|
||||
sku = IAPPayManager.PRODUCT_VIP_WEEK,
|
||||
currency = "USD",
|
||||
shopName = _type
|
||||
};
|
||||
@@ -119,7 +119,7 @@ namespace RedHotRoast
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)System.Math.Round(vip_list[1].DiscountPrice * 100),
|
||||
sku = PurchasingManager.GetPaySku(PayType.monthly_subscription),
|
||||
sku = IAPPayManager.PRODUCT_VIP_MONTH,
|
||||
currency = "USD",
|
||||
shopName = _type
|
||||
};
|
||||
@@ -137,7 +137,7 @@ namespace RedHotRoast
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)System.Math.Round(vip_list[2].DiscountPrice * 100),
|
||||
sku = PurchasingManager.GetPaySku(PayType.yearly_subscription),
|
||||
sku = IAPPayManager.PRODUCT_VIP_YEAR,
|
||||
currency = "USD",
|
||||
shopName = _type
|
||||
};
|
||||
|
||||
@@ -98,60 +98,60 @@ namespace RedHotRoast
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.rewardMul_close, rewardMul_close);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
// GameDispatcher.Instance.AddListener(GameMsg.rewardMul_close, rewardMul_close);
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.rewardMul_close, rewardMul_close);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
// GameDispatcher.Instance.RemoveListener(GameMsg.rewardMul_close, rewardMul_close);
|
||||
}
|
||||
#endregion
|
||||
void pay_success(object str)
|
||||
{
|
||||
string type = (string)str;
|
||||
if (type == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
{
|
||||
|
||||
// var start = Vector2.zero;
|
||||
// if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day1) {
|
||||
// start = GameHelper.GetUICenterPosition(ui.day1.item1.lab_num);
|
||||
// } else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day2) {
|
||||
// start = GameHelper.GetUICenterPosition(ui.day2.item1.lab_num);
|
||||
// } else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day3) {
|
||||
// start = GameHelper.GetUICenterPosition(ui.day3.item1.lab_num);
|
||||
// }
|
||||
//
|
||||
// var rewardData = new RewardData();
|
||||
// var end = GameHelper.GetUICenterPosition(ui.node_end);
|
||||
//
|
||||
// var rewardSingleData = new RewardSingleData(101, list[1].coins_quantity, RewardOrigin.AdTask)
|
||||
// string type = (string)str;
|
||||
// if (type == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
// {
|
||||
// startPosition = start,
|
||||
// endPosition = end
|
||||
// };
|
||||
//
|
||||
// rewardData.AddReward(rewardSingleData);
|
||||
// rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
||||
// rewardData.AddCompleted(success =>
|
||||
// {
|
||||
// // if (success)
|
||||
// // {
|
||||
// // RefreshGold(awardNum);
|
||||
// // var start = Vector2.zero;
|
||||
// // if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day1) {
|
||||
// // start = GameHelper.GetUICenterPosition(ui.day1.item1.lab_num);
|
||||
// // } else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day2) {
|
||||
// // start = GameHelper.GetUICenterPosition(ui.day2.item1.lab_num);
|
||||
// // } else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day3) {
|
||||
// // start = GameHelper.GetUICenterPosition(ui.day3.item1.lab_num);
|
||||
// // }
|
||||
// });
|
||||
// //
|
||||
// // var rewardData = new RewardData();
|
||||
// // var end = GameHelper.GetUICenterPosition(ui.node_end);
|
||||
// //
|
||||
// // var rewardSingleData = new RewardSingleData(101, list[1].coins_quantity, RewardOrigin.AdTask)
|
||||
// // {
|
||||
// // startPosition = start,
|
||||
// // endPosition = end
|
||||
// // };
|
||||
// //
|
||||
// // rewardData.AddReward(rewardSingleData);
|
||||
// // rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
||||
// // rewardData.AddCompleted(success =>
|
||||
// // {
|
||||
// // // if (success)
|
||||
// // // {
|
||||
// // // RefreshGold(awardNum);
|
||||
// // // }
|
||||
// // });
|
||||
// //
|
||||
// // GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
||||
// // // DataMgr.Coin.Value -= list[1].coins_quantity;
|
||||
// //
|
||||
// // UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AdcomingUI_Close);
|
||||
// // SaveData.GetSaveObject().is_get_removead = true;
|
||||
// // InitView();
|
||||
//
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
||||
// // DataMgr.Coin.Value -= list[1].coins_quantity;
|
||||
// ui.pay_type.selectedIndex = 2;
|
||||
// }
|
||||
// // GameDispatcher.Instance.Dispatch(GameMsg.noads_refresh);
|
||||
//
|
||||
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AdcomingUI_Close);
|
||||
// SaveData.GetSaveObject().is_get_removead = true;
|
||||
// InitView();
|
||||
|
||||
ui.pay_type.selectedIndex = 2;
|
||||
}
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.noads_refresh);
|
||||
|
||||
}
|
||||
|
||||
void rewardMul_close(object str)
|
||||
@@ -237,13 +237,13 @@ namespace RedHotRoast
|
||||
|
||||
ui.btn_max_pack.SetClick(() =>
|
||||
{
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)Math.Round(price_pack * 100),
|
||||
sku =PurchasingManager.GetPaySku(PayType.three_days_gift),
|
||||
currency = "USD"
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
// ApplePayClass maxPayData = new ApplePayClass
|
||||
// {
|
||||
// amount = (int)Math.Round(price_pack * 100),
|
||||
// sku =PurchasingManager.GetPaySku(PayType.three_days_gift),
|
||||
// currency = "USD"
|
||||
// };
|
||||
// MaxPayManager.Instance.Buy(maxPayData);
|
||||
|
||||
|
||||
});
|
||||
@@ -276,7 +276,7 @@ namespace RedHotRoast
|
||||
int adNums = AdExchangeManager.Instance.GetLookRewardADNum();
|
||||
adNums -= (int)list[0].Paid_price;
|
||||
AdExchangeManager.Instance.SetLookRewardADNum(adNums);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, PurchasingManager.GetPaySku(PayType.three_days_gift));
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, PurchasingManager.GetPaySku(PayType.three_days_gift));
|
||||
|
||||
// getReward();
|
||||
ui.btn_buypack.SetClick(() => { });
|
||||
|
||||
@@ -182,13 +182,13 @@ namespace RedHotRoast
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, InitView);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, InitView);
|
||||
}
|
||||
|
||||
@@ -221,6 +221,8 @@ namespace RedHotRoast
|
||||
ui.btn_restore.visible = !GameHelper.IsGiftSwitch();
|
||||
ui.btn_restore.SetClick(() =>
|
||||
{
|
||||
IAPPayManager.Instance.OnRestoreButtonClicked();
|
||||
|
||||
// ApplePayManager.Instance.AppleRestore((success, message) =>
|
||||
// {
|
||||
// Debug.Log($"[barry] restore success message: {message}---- {JsonConvert.SerializeObject(message)}");
|
||||
@@ -258,7 +260,7 @@ namespace RedHotRoast
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)System.Math.Round(vip_list[_level].DiscountPrice * 100),
|
||||
sku = PurchasingManager.GetPaySku(GetTypeByIndex(_level)),
|
||||
sku = GetTypeByIndex(_level),
|
||||
currency = "USD",
|
||||
shopName = _type
|
||||
};
|
||||
@@ -278,14 +280,14 @@ namespace RedHotRoast
|
||||
ui.vip_icon_loader.url = $"ui://LG_Common/vip_{lv}";
|
||||
}
|
||||
|
||||
private PayType GetTypeByIndex(int index)
|
||||
private string GetTypeByIndex(int index)
|
||||
{
|
||||
return index switch
|
||||
{
|
||||
0 => PayType.weekly_subscription,
|
||||
1 => PayType.monthly_subscription,
|
||||
2 => PayType.yearly_subscription,
|
||||
_ => PayType.weekly_subscription
|
||||
0 => IAPPayManager.PRODUCT_VIP_WEEK,
|
||||
1 => IAPPayManager.PRODUCT_VIP_MONTH,
|
||||
2 => IAPPayManager.PRODUCT_VIP_YEAR,
|
||||
_ => IAPPayManager.PRODUCT_VIP_WEEK
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+170
-113
@@ -1,30 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
// using SGModule.ApplePay;
|
||||
using SGModule.NetKit;
|
||||
using UnityEngine;
|
||||
using RedHotRoast;
|
||||
// using UnityEngine.Purchasing;
|
||||
using Newtonsoft.Json;
|
||||
using SGModule.Net;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public enum PayType
|
||||
{
|
||||
buy_one,
|
||||
buy_one_off,
|
||||
buy_gold_1,
|
||||
buy_gold_2,
|
||||
buy_gold_3,
|
||||
buy_gold_4,
|
||||
buy_gold_5,
|
||||
remove_ad,
|
||||
battle_pass,
|
||||
pack_reward,
|
||||
fail_pack,
|
||||
three_days_gift,
|
||||
weekly_subscription,
|
||||
monthly_subscription,
|
||||
yearly_subscription,
|
||||
}
|
||||
// public enum PayType
|
||||
// {
|
||||
// buy_one,
|
||||
// buy_one_off,
|
||||
// buy_gold_1,
|
||||
// buy_gold_2,
|
||||
// buy_gold_3,
|
||||
// buy_gold_4,
|
||||
// buy_gold_5,
|
||||
// remove_ad,
|
||||
// battle_pass,
|
||||
// pack_reward,
|
||||
// fail_pack,
|
||||
// three_days_gift,
|
||||
// weekly_subscription,
|
||||
// monthly_subscription,
|
||||
// yearly_subscription,
|
||||
// }
|
||||
|
||||
public class PurchasingManager
|
||||
{
|
||||
@@ -32,42 +31,42 @@ public class PurchasingManager
|
||||
private static readonly List<ApplePay> PayConfig = ConfigSystem.GetConfig<ApplePay>();
|
||||
private static readonly List<ApplePay2> PayConfig2 = ConfigSystem.GetConfig<ApplePay2>();
|
||||
|
||||
public static string GetPaySku(PayType key)
|
||||
{
|
||||
string keys = "";
|
||||
|
||||
if (PayConfig != null)
|
||||
{
|
||||
foreach (var data in PayConfig)
|
||||
{
|
||||
if (data.payKey != key.ToString()) continue;
|
||||
keys = data.sku;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
public static int GetVipLvFormConfig(string sku)
|
||||
{
|
||||
var lv = 1;
|
||||
|
||||
if (GetPaySku(PayType.weekly_subscription) == sku)
|
||||
{
|
||||
lv = 1;
|
||||
}
|
||||
else if (GetPaySku(PayType.monthly_subscription) == sku)
|
||||
{
|
||||
lv = 2;
|
||||
}
|
||||
else if (GetPaySku(PayType.yearly_subscription) == sku)
|
||||
{
|
||||
lv = 3;
|
||||
}
|
||||
|
||||
return lv;
|
||||
}
|
||||
// public static string GetPaySku(PayType key)
|
||||
// {
|
||||
// string keys = "";
|
||||
//
|
||||
// if (PayConfig != null)
|
||||
// {
|
||||
// foreach (var data in PayConfig)
|
||||
// {
|
||||
// if (data.payKey != key.ToString()) continue;
|
||||
// keys = data.sku;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return keys;
|
||||
// }
|
||||
//
|
||||
// public static int GetVipLvFormConfig(string sku)
|
||||
// {
|
||||
// var lv = 1;
|
||||
//
|
||||
// if (GetPaySku(PayType.weekly_subscription) == sku)
|
||||
// {
|
||||
// lv = 1;
|
||||
// }
|
||||
// else if (GetPaySku(PayType.monthly_subscription) == sku)
|
||||
// {
|
||||
// lv = 2;
|
||||
// }
|
||||
// else if (GetPaySku(PayType.yearly_subscription) == sku)
|
||||
// {
|
||||
// lv = 3;
|
||||
// }
|
||||
//
|
||||
// return lv;
|
||||
// }
|
||||
|
||||
|
||||
public static void Purchase(ApplePayData payData)
|
||||
@@ -82,6 +81,21 @@ public class PurchasingManager
|
||||
// {
|
||||
// Debug.Log("purchase fail------- reason: " + message);
|
||||
// });
|
||||
|
||||
if (payData.sku.Contains("sub"))
|
||||
{
|
||||
IAPPayManager.Instance.SubscribeProduct(payData.sku, "",() =>
|
||||
{
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
IAPPayManager.Instance.BuyProduct(payData.sku, "",() =>
|
||||
{
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// public static Action<ApplePayBackType, AppleResponseData> ApplePaySuccessCallback(ApplePayData payData)
|
||||
@@ -112,7 +126,7 @@ public class PurchasingManager
|
||||
// var sku = SetSku(payData);
|
||||
//
|
||||
// Debug.Log($"[Apple Pay] Check sku===2===== {sku}");
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, sku);
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, sku);
|
||||
// Debug.Log($"[Apple Pay] Check sku===3===== {sku}");
|
||||
//
|
||||
// SendEventClickByName(sku, "open");
|
||||
@@ -148,31 +162,69 @@ public class PurchasingManager
|
||||
// ApplePayManager.Instance.ApplePayTest(types, payData.sku, tranId, ApplePaySuccessCallback(payData));
|
||||
// }
|
||||
|
||||
private static string SetSku(ApplePayData data)
|
||||
// private static string SetSku(ApplePayData data)
|
||||
// {
|
||||
// string sku = "";
|
||||
// if (data.type != null && data.type == GetPaySku(PayType.remove_ad))
|
||||
// {
|
||||
// sku = data.type;
|
||||
// }
|
||||
// else if (data.sku.Contains("shop"))
|
||||
// {
|
||||
// sku = data.shopName;
|
||||
// }
|
||||
// else if (data.sku.Contains("sub"))
|
||||
// {
|
||||
// sku = data.shopName;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// sku = data.sku;
|
||||
// }
|
||||
//
|
||||
// return sku;
|
||||
// }
|
||||
|
||||
// 商店商品映射表
|
||||
public static readonly Dictionary<string, string> ShopProductMap = new Dictionary<string, string>
|
||||
{
|
||||
string sku = "";
|
||||
if (data.type != null && data.type == GetPaySku(PayType.remove_ad))
|
||||
{ IAPPayManager.PRODUCT_SHOP_1, "0" },
|
||||
{ IAPPayManager.PRODUCT_SHOP_2, "1" },
|
||||
{ IAPPayManager.PRODUCT_SHOP_3, "2" },
|
||||
{ IAPPayManager.PRODUCT_SHOP_4, "3" },
|
||||
{ IAPPayManager.PRODUCT_SHOP_5, "4" }
|
||||
};
|
||||
|
||||
// 订阅商品映射表
|
||||
public static readonly Dictionary<string, string> VipProductMap = new Dictionary<string, string>
|
||||
{
|
||||
sku = data.type;
|
||||
{ IAPPayManager.PRODUCT_VIP_WEEK, "0" },
|
||||
{ IAPPayManager.PRODUCT_VIP_MONTH, "1" },
|
||||
{ IAPPayManager.PRODUCT_VIP_YEAR, "2" },
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 更新map中的value,与配置表的id对应
|
||||
/// _shopProductMap
|
||||
/// </summary>
|
||||
public static void SetShopMapValue()
|
||||
{
|
||||
var list = ConfigSystem.GetConfig<Paidcoins>();
|
||||
if (list is not { Count: > 0 }) return;
|
||||
foreach (var paidcoin in list)
|
||||
{
|
||||
if (string.IsNullOrEmpty(paidcoin.SKU))
|
||||
continue;
|
||||
|
||||
if (ShopProductMap.ContainsKey(paidcoin.SKU))
|
||||
{
|
||||
ShopProductMap[paidcoin.SKU] = (paidcoin.id - 1).ToString();
|
||||
|
||||
}
|
||||
else if (data.sku.Contains("shop"))
|
||||
{
|
||||
sku = data.shopName;
|
||||
}
|
||||
else if (data.sku.Contains("sub"))
|
||||
{
|
||||
sku = data.shopName;
|
||||
}
|
||||
else
|
||||
{
|
||||
sku = data.sku;
|
||||
}
|
||||
|
||||
return sku;
|
||||
}
|
||||
|
||||
|
||||
private static void SendEventClickByName(string name, string type)
|
||||
public static void SendEventClickByName(string name, string type)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
@@ -183,64 +235,60 @@ public class PurchasingManager
|
||||
string successTrackKey = null;
|
||||
string openTrackKey = null;
|
||||
|
||||
if (name == GetPaySku(PayType.pack_reward))
|
||||
if (name == IAPPayManager.PRODUCT_FIRST_GIFT)
|
||||
{
|
||||
clickTrackKey = ADEventTrack.Property.lucky_gift_click;
|
||||
successTrackKey = ADEventTrack.Property.lucky_gift_receive;
|
||||
openTrackKey = ADEventTrack.Property.first_pack_show;
|
||||
}
|
||||
else if (name == GetPaySku(PayType.remove_ad))
|
||||
else if (name == IAPPayManager.PRODUCT_REMOVE_ADS)
|
||||
{
|
||||
clickTrackKey = ADEventTrack.Property.remove_ad_click;
|
||||
successTrackKey = ADEventTrack.Property.remove_ad_receive;
|
||||
openTrackKey = ADEventTrack.Property.gift_show;
|
||||
}
|
||||
else if (name == GetPaySku(PayType.battle_pass))
|
||||
else if (name == IAPPayManager.PRODUCT_PASS_BONUS)
|
||||
{
|
||||
clickTrackKey = ADEventTrack.Property.master_pass_click;
|
||||
successTrackKey = ADEventTrack.Property.master_pass_receive;
|
||||
openTrackKey = ADEventTrack.Property.master_pass_show;
|
||||
}
|
||||
else if (name == GetPaySku(PayType.buy_one))
|
||||
else if (name == IAPPayManager.PRODUCT_SPACE_BONUS)
|
||||
{
|
||||
clickTrackKey = ADEventTrack.Property.buy_one_click;
|
||||
successTrackKey = ADEventTrack.Property.buy_one_success;
|
||||
openTrackKey = ADEventTrack.Property.buy_one_show;
|
||||
}
|
||||
else if (name == GetPaySku(PayType.buy_one_off))
|
||||
{
|
||||
// clickTrackKey = ADEventTrack.Property.BuyOneOffClick;
|
||||
// successTrackKey = ADEventTrack.Property.BuyOneOffSuccess;
|
||||
// openTrackKey = ADEventTrack.Property.BuyOneOffShow;
|
||||
}
|
||||
else if (name == GetPaySku(PayType.fail_pack))
|
||||
{
|
||||
clickTrackKey = ADEventTrack.Property.fail_click;
|
||||
successTrackKey = ADEventTrack.Property.fail_buy_success;
|
||||
openTrackKey = ADEventTrack.Property.fail_show;
|
||||
}
|
||||
else if (name == GetPaySku(PayType.three_days_gift))
|
||||
{
|
||||
clickTrackKey = ADEventTrack.Property.three_days_gift_click;
|
||||
successTrackKey = ADEventTrack.Property.three_days_gift_buy_success;
|
||||
openTrackKey = ADEventTrack.Property.three_days_gift_show;
|
||||
}
|
||||
// else if (name == GetPaySku(PayType.buy_one_off))
|
||||
// {
|
||||
// // clickTrackKey = ADEventTrack.Property.BuyOneOffClick;
|
||||
// // successTrackKey = ADEventTrack.Property.BuyOneOffSuccess;
|
||||
// // openTrackKey = ADEventTrack.Property.BuyOneOffShow;
|
||||
// }
|
||||
// else if (name == GetPaySku(PayType.fail_pack))
|
||||
// {
|
||||
// clickTrackKey = ADEventTrack.Property.fail_click;
|
||||
// successTrackKey = ADEventTrack.Property.fail_buy_success;
|
||||
// openTrackKey = ADEventTrack.Property.fail_show;
|
||||
// }
|
||||
// else if (name == GetPaySku(PayType.three_days_gift))
|
||||
// {
|
||||
// clickTrackKey = ADEventTrack.Property.three_days_gift_click;
|
||||
// successTrackKey = ADEventTrack.Property.three_days_gift_buy_success;
|
||||
// openTrackKey = ADEventTrack.Property.three_days_gift_show;
|
||||
// }
|
||||
|
||||
if (name.StartsWith("buy_gold"))
|
||||
else if (ShopProductMap.TryGetValue(name, out var idx))
|
||||
{
|
||||
int startIndex = "buy_gold".Length;
|
||||
string suffix = name[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
clickTrackKey = ADEventTrack.Property.gold_click_ + suffix;
|
||||
successTrackKey = ADEventTrack.Property.shop_receive_ + suffix;
|
||||
clickTrackKey = ADEventTrack.Property.gold_click_ + idx;
|
||||
successTrackKey = ADEventTrack.Property.shop_receive_ + idx;
|
||||
openTrackKey = ADEventTrack.Property.shop_show;
|
||||
}
|
||||
|
||||
if (name.StartsWith("vip_club"))
|
||||
else if (VipProductMap.TryGetValue(name, out var vipIdx))
|
||||
{
|
||||
int startIndex = "vip_club".Length;
|
||||
string suffix = name[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
clickTrackKey = ADEventTrack.Property.vip_click_ + suffix;
|
||||
successTrackKey = ADEventTrack.Property.vip_success_ + suffix;
|
||||
clickTrackKey = ADEventTrack.Property.vip_click_ + vipIdx;
|
||||
successTrackKey = ADEventTrack.Property.vip_success_ + vipIdx;
|
||||
openTrackKey = ADEventTrack.Property.buy_one_show;
|
||||
}
|
||||
|
||||
@@ -254,12 +302,19 @@ public class PurchasingManager
|
||||
}
|
||||
else if (type == "open" && openTrackKey != null)
|
||||
{
|
||||
// TrackKit.SendEvent(ADEventTrack.IOS_Pay_Event, openTrackKey);
|
||||
TrackKit.SendEvent(ADEventTrack.IOS_Pay_Event, openTrackKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ios支付创建订单接口,改一下用来上传数据给后台统计支付数据
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="onCompleted"></param>
|
||||
public static void ApplePayCreate<T>(ApplePayData data, UnityAction<ResponseData<T>> onCompleted = null)
|
||||
{
|
||||
NetKit.Instance.Post<T>("shop/applePayCreate", data,
|
||||
response => { onCompleted?.Invoke(response); });
|
||||
}
|
||||
|
||||
}
|
||||
public class ApplePayData
|
||||
@@ -276,6 +331,8 @@ public class ApplePayData
|
||||
public string shopName;
|
||||
[JsonProperty("type")]
|
||||
public string type;
|
||||
[JsonProperty("isCompleted")]
|
||||
public bool isCompleted;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace RedHotRoast {
|
||||
b = GetCommonConf().IsOrganic == 1;
|
||||
}
|
||||
|
||||
Debug.Log($"下载---------开关:{b}");
|
||||
// Debug.Log($"下载---------开关:{b}");
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
+36
-9
File diff suppressed because one or more lines are too long
@@ -1009,11 +1009,11 @@ PlayerSettings:
|
||||
apiCompatibilityLevel: 6
|
||||
activeInputHandler: 0
|
||||
windowsGamepadBackendHint: 0
|
||||
cloudProjectId:
|
||||
cloudProjectId: 3fce7f77-ba31-4650-89e2-ae642f62eb2c
|
||||
framebufferDepthMemorylessMode: 0
|
||||
qualitySettingsNames: []
|
||||
projectName:
|
||||
organizationId:
|
||||
projectName: Red-Hot Roast
|
||||
organizationId: ipfang
|
||||
cloudEnabled: 0
|
||||
legacyClampBlendShapeWeights: 0
|
||||
hmiLoadingImage: {fileID: 0}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AJsonPropertyAttribute_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003F97354_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F761cf2a144514d2291a678c334d49e9baa000_003Fd2_003F103dd213_003FJsonPropertyAttribute_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AResources_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003F97354_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F37cc348edc804f4cb176b63962c716e7177200_003Fea_003Ffcad8965_003FResources_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASettingsUI_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003F97354_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F6e53694256e748aaa40387bd9aae590a19400_003F8f_003F4404ef43_003FSettingsUI_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASetupCoroutine_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2026_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Feaa93d1ff51f46939e13cc06b5754f3d177000_003F3a_003F4f590d28_003FSetupCoroutine_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
|
||||
Reference in New Issue
Block a user