hexiaojie 8 сар өмнө
parent
commit
2f9dd301b7

+ 13 - 7
GameClient/Assets/Game/HotUpdate/FairyGUI/GenCode/Store/UI_StorePayProp.cs → GameClient/Assets/Game/HotUpdate/FairyGUI/GenCode/Store/UI_StorePayPropUI.cs

@@ -4,21 +4,23 @@ using FairyGUI;
 
 namespace UI.Store
 {
-    public partial class UI_StorePayProp
+    public partial class UI_StorePayPropUI
     {
         public GComponent target;
         public GImage m_payClose;
         public GButton m_payVxBtn;
         public GButton m_payAliBtn;
+        public GTextField m_txtXzf;
         public GTextField m_txtTotal;
+        public GTextField m_txtShopName;
         public const string URL = "ui://p9mtgheoq5ritfi";
         public const string PACKAGE_NAME = "Store";
-        public const string RES_NAME = "StorePayProp";
-        private static UI_StorePayProp _proxy;
+        public const string RES_NAME = "StorePayPropUI";
+        private static UI_StorePayPropUI _proxy;
 
-        public static UI_StorePayProp Create(GObject gObject = null)
+        public static UI_StorePayPropUI Create(GObject gObject = null)
         {
-            var ui = new UI_StorePayProp();
+            var ui = new UI_StorePayPropUI();
             if(gObject == null)
             	ui.target =  (GComponent)UIPackage.CreateObject(PACKAGE_NAME, RES_NAME);
             else
@@ -27,11 +29,11 @@ namespace UI.Store
             return ui;
         }
 
-        public static UI_StorePayProp Proxy(GObject gObject = null)
+        public static UI_StorePayPropUI Proxy(GObject gObject = null)
         {
             if(_proxy == null)
             {
-                _proxy = new UI_StorePayProp();
+                _proxy = new UI_StorePayPropUI();
             }
             var ui = _proxy;
             if(gObject == null)
@@ -61,14 +63,18 @@ namespace UI.Store
             m_payClose = (GImage)comp.GetChild("payClose");
             m_payVxBtn = (GButton)comp.GetChild("payVxBtn");
             m_payAliBtn = (GButton)comp.GetChild("payAliBtn");
+            m_txtXzf = (GTextField)comp.GetChild("txtXzf");
             m_txtTotal = (GTextField)comp.GetChild("txtTotal");
+            m_txtShopName = (GTextField)comp.GetChild("txtShopName");
         }
         public void Dispose(bool disposeTarget = false)
         {
             m_payClose = null;
             m_payVxBtn = null;
             m_payAliBtn = null;
+            m_txtXzf = null;
             m_txtTotal = null;
+            m_txtShopName = null;
             if(disposeTarget && target != null)
             {
                 target.RemoveFromParent();

+ 1 - 1
GameClient/Assets/Game/HotUpdate/FairyGUI/GenCode/Store/UI_StorePayProp.cs.meta → GameClient/Assets/Game/HotUpdate/FairyGUI/GenCode/Store/UI_StorePayPropUI.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 7acaa707333d58c458527e226421119f
+guid: ec1c86ccae0c11a4cb0e7b96fae68a4e
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 8 - 0
GameClient/Assets/Game/HotUpdate/Platform/AliPay.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 69fb72229f3626146b2a1f93866ac946
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 26 - 0
GameClient/Assets/Game/HotUpdate/Platform/AliPay/AliManager.cs

@@ -0,0 +1,26 @@
+using System;
+using ET;
+using UnityEngine;
+using GFGGame.Launcher;
+
+namespace GFGGame
+{
+    public class AliManagerr : SingletonBase<AliManagerr>
+    {
+        public void Pay(string orderStr)
+        {
+            AliPayManagerInit.Instance.ShowSwitchPayment(orderStr);
+        }
+    }
+
+    /// <summary>
+    /// SDK回调
+    /// </summary>
+    public class AliPaySDKListener : IAliSDKListener
+    {
+        public void AliPayReceiveAb(string message)
+        {
+            Debug.Log("Game.HotUpdate AliPayReceiveAb: " + message);
+        }
+    }
+}

+ 3 - 0
GameClient/Assets/Game/HotUpdate/Platform/AliPay/AliManager.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 90f107f47ea4407f9f191e43261f9fd3
+timeCreated: 1732530614

+ 2 - 0
GameClient/Assets/Game/HotUpdate/Platform/QDManager.cs

@@ -132,6 +132,8 @@ namespace GFGGame
                     break;
                 case (int)ChannelID.DouYou:
                     QDDouYouManager.Instance.Pay(buyID, count, orderID, price);
+                    //TODO gfg支付跳转
+                    ViewManager.Show<StorePayPropView>(new object[] { buyID, orderID, price });
                     break;
                 case (int)ChannelID.DouYouDev:
                     QDDouYouManager.Instance.Pay(buyID, count, orderID, price);

+ 7 - 1
GameClient/Assets/Game/HotUpdate/ServerProxy/ShopSProxy.cs

@@ -64,7 +64,6 @@ namespace GFGGame
                 if (response.Error == ErrorCode.ERR_Success)
                 {
                     ShopCfg shopCfg = ShopCfgArray.Instance.GetCfg(response.BuyId);
-                    ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId);
                     if (shopCfg.CostTypeReal == CostType.RMB)
                     {
                         QDManager.Pay(response.BuyId, response.Times, response.OrderId, response.Price);
@@ -223,5 +222,12 @@ namespace GFGGame
             return false;
         }
 
+        //创建支付宝订单
+        public static async ETTask<S2C_CreateAliOrder> ReqCreateAliOrder(long tempOrderId)
+        {
+            var response = (S2C_CreateAliOrder)await MessageHelper.SendToServer(new C2S_CreateAliOrder()
+                { OrderTempId = tempOrderId });
+            return response;
+        }
     }
 }

+ 84 - 0
GameClient/Assets/Game/HotUpdate/Views/Store/StorePayPropView.cs

@@ -0,0 +1,84 @@
+using System.Threading.Tasks;
+using ET;
+using FairyGUI;
+using UI.Store;
+
+namespace GFGGame
+{
+    public class StorePayPropView : BaseWindow
+    {
+        private UI_StorePayPropUI _ui;
+
+        //商品id
+        private int _goodsId;
+
+        //临时订单id
+        private long _tempOrderId;
+
+        //订单金额
+        private long _price;
+
+        public override void Dispose()
+        {
+            if (_ui != null)
+            {
+                _ui.Dispose();
+            }
+
+            _ui = null;
+            base.Dispose();
+        }
+
+        protected override void OnHide()
+        {
+            base.OnHide();
+        }
+
+        protected override void OnInit()
+        {
+            base.OnInit();
+            packageName = UI_StorePayPropUI.PACKAGE_NAME;
+            _ui = UI_StorePayPropUI.Create();
+            this.viewCom = _ui.target;
+            this.viewCom.Center();
+            this.modal = true;
+            viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
+
+            _ui.m_payVxBtn.onClick.Add(OnVxBtnBuyClick);
+            _ui.m_payAliBtn.onClick.Add(OnAliBtnBuyClick);
+            _ui.m_payClose.onClick.Add(OnCloseClick);
+        }
+
+        protected override void OnShown()
+        {
+            base.OnShown();
+            _goodsId = (int)(this.viewData as object[])[0];
+            _tempOrderId = (int)(this.viewData as object[])[1];
+            _price = (int)(this.viewData as object[])[2];
+            ShopCfg cfg = ShopCfgArray.Instance.GetCfg(_goodsId);
+            _ui.m_txtTotal.text = _price + "元";
+            _ui.m_txtShopName.text = cfg.productName;
+            _ui.m_txtXzf.text = _price + "元";
+        }
+
+        private async void OnVxBtnBuyClick()
+        {
+            S2C_CreateAliOrder response = await ShopSProxy.ReqCreateAliOrder(_tempOrderId);
+            if (response == null || string.IsNullOrEmpty(response.AliOrderStr))
+            {
+                //TODO 提示调起支付宝失败
+                return;
+            }
+
+            AliManagerr.Instance.Pay(response.AliOrderStr);
+        }
+
+        private async void OnAliBtnBuyClick()
+        {
+        }
+
+        private async void OnCloseClick()
+        {
+        }
+    }
+}

+ 3 - 0
GameClient/Assets/Game/HotUpdate/Views/Store/StorePayPropView.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 737ad6fde790433e8394af1dff873378
+timeCreated: 1733645100

+ 8 - 0
GameClient/Assets/Game/Launcher/Platform/Pay.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 63174eaf331a19a4c8595f7904ed60ea
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 62 - 0
GameClient/Assets/Game/Launcher/Platform/Pay/AliPayManagerInit.cs

@@ -0,0 +1,62 @@
+using DouYouSdk;
+using UniFramework.Event;
+using UnityEngine;
+
+namespace GFGGame.Launcher
+{
+    public class AliPayManagerInit : SingletonBase<AliPayManagerInit>
+    {
+        public IAliSDKListener aliSDKListener;
+        
+        private static AndroidJavaClass _unityPlayerClass;
+
+        private static AndroidJavaObject _mainActivity;
+
+        public void InitSDK()
+        {
+            if (_unityPlayerClass == null)
+            {
+                _unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
+            }
+
+            if (_mainActivity == null)
+            {
+                _mainActivity = _unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
+            }
+
+            AliDKHandler eventHandler = GameObject.Find("AliPayGameObject")?.GetComponent<AliDKHandler>();
+            if (eventHandler == null)
+            {
+                GameObject gameObject = new GameObject("AliPayGameObject");
+                gameObject.AddComponent<AliDKHandler>();
+                GameObject.DontDestroyOnLoad(gameObject);
+            }
+        }
+
+        /// <summary>
+        /// 调起支付
+        /// </summary>
+        public void ShowSwitchPayment(string orderStr, string callBackObjectName = "AliPayGameObject", string callBackFuncName = "AliPayReceive")
+        {
+            Instance.CallDouYouMainActivity("AliPay", orderStr, callBackObjectName, callBackFuncName);
+        }
+
+        private void CallDouYouMainActivity(string functionName, params object[] args)
+        {
+            _mainActivity?.Call(functionName, args);
+        }
+
+        public class AliDKHandler : AliPaySDKHandler
+        {
+            /// <summary>
+            /// 支付回调
+            /// </summary>
+            /// <param name="message">支付回调</param>
+            public override void AliPayReceiveAb(string message)
+            {
+                Debug.Log($"AliPayReceiveAb:{message}");
+                AliPayManagerInit.Instance.aliSDKListener?.AliPayReceiveAb(message);
+            }
+        }
+    }
+}

+ 3 - 0
GameClient/Assets/Game/Launcher/Platform/Pay/AliPayManagerInit.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: dd2b7918ce3642d38dbac76a0a0567f0
+timeCreated: 1732521792

+ 7 - 0
GameClient/Assets/Game/Launcher/Platform/Pay/IAliSDKListener.cs

@@ -0,0 +1,7 @@
+namespace GFGGame.Launcher
+{
+    public interface IAliSDKListener
+    {
+        public void AliPayReceiveAb(string message);
+    }
+}

+ 3 - 0
GameClient/Assets/Game/Launcher/Platform/Pay/IAliSDKListener.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 9587d9fa41fc4bb8a44bf6217f907a4a
+timeCreated: 1732530909

BIN
GameClient/Assets/ResIn/UI/Store/Store_fui.bytes


+ 8 - 0
GameClient/Assets/ThirdParty/AliPay.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: b8b695e48dc67a443b2fa82848f0ad1a
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 19 - 0
GameClient/Assets/ThirdParty/AliPay/AliPaySDKHandler.cs

@@ -0,0 +1,19 @@
+using UnityEngine;
+
+namespace DouYouSdk
+{
+    public abstract class AliPaySDKHandler : MonoBehaviour
+    {
+        public abstract void AliPayReceiveAb(string message);
+        
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="message"></param>
+        public void AliPayReceive(string message)
+        {
+            Debug.Log($"AliPayReceive:{message}");
+            AliPayReceiveAb(message);
+        }
+    }
+}

+ 3 - 0
GameClient/Assets/ThirdParty/AliPay/AliPaySDKHandler.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: d5793ad216414a1d919febf2c17edcae
+timeCreated: 1726489817