From c2b9dacf80c27d7ebf384b8fce54c42bce6e7de2 Mon Sep 17 00:00:00 2001 From: vurtne14 Date: Mon, 13 Jan 2025 17:13:46 +0800 Subject: [PATCH] 1 --- .../~Lua/Common/GlobalDefine.lua | 3 +- .../~Lua/Modules/Common/MoneyUtil.lua | 3 + .../~Lua/Modules/Pay/PayManager.lua | 116 ++++++++++-------- .../~Lua/Modules/Setting/SettingInfo.lua | 6 +- 4 files changed, 70 insertions(+), 58 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Common/GlobalDefine.lua b/Assets/ManagedResources/~Lua/Common/GlobalDefine.lua index e4b962edae..904def37de 100644 --- a/Assets/ManagedResources/~Lua/Common/GlobalDefine.lua +++ b/Assets/ManagedResources/~Lua/Common/GlobalDefine.lua @@ -3376,7 +3376,8 @@ PlayerTitleRideSkinRedPointTypeStr = { MoneyType = { RMB = 1, -- 人民币 USD = 2, -- 美元 - MM = 9 -- 美元 + MM = 9, -- 越南盾 + THAI = 4 --泰铢 } -- 金钱文字界面相关常量----------------- diff --git a/Assets/ManagedResources/~Lua/Modules/Common/MoneyUtil.lua b/Assets/ManagedResources/~Lua/Modules/Common/MoneyUtil.lua index 677d16827b..c3b926c981 100644 --- a/Assets/ManagedResources/~Lua/Modules/Common/MoneyUtil.lua +++ b/Assets/ManagedResources/~Lua/Modules/Common/MoneyUtil.lua @@ -14,6 +14,8 @@ function this.Initialize() this.MT = MoneyType.USD elseif GetCurLanguage() == 2 then this.MT = MoneyType.MM + elseif GetCurLanguage() == 3 then + this.MT = MoneyType.THAI else this.MT = MoneyType.USD end @@ -33,6 +35,7 @@ function this.GetMoney(_rmbp) LogError("表 ExchangeRate 错误: 不包含档位:"..tostring(rmbp)) return 0 end + LogError("当前挡位:"..this.MT) local m = this.RMB2O[rmbp]["Price_"..this.MT] if not m then LogError("表 ExchangeRate 错误: 档位:"..tostring(rmbp).." , 未找到对应的货币类型 "..this.MT) diff --git a/Assets/ManagedResources/~Lua/Modules/Pay/PayManager.lua b/Assets/ManagedResources/~Lua/Modules/Pay/PayManager.lua index 3dd70df60c..8bbca2d5c5 100644 --- a/Assets/ManagedResources/~Lua/Modules/Pay/PayManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Pay/PayManager.lua @@ -12,6 +12,7 @@ local this = PayManager function this.Initialize() Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.onSdkPayResult) end + ----- 请求支付 ----- @param context ---- { @@ -23,7 +24,7 @@ end this.EventTrigger = {} function this.onSdkPayResult(id) - LogRed("收到sdk支付成功回调,商品id = "..id) + LogRed("收到sdk支付成功回调,商品id = " .. id) if this.EventTrigger[id] then this.EventTrigger[id](id) this.EventTrigger[id] = nil @@ -31,24 +32,24 @@ function this.onSdkPayResult(id) local rechargeConfig = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig, id) if rechargeConfig then local Price = tostring(rechargeConfig.Price) - CustomEventManager.SendCustomEvent("mhtPay", Price ,"4") + CustomEventManager.SendCustomEvent("mhtPay", Price, "4") end end -- 这里发过来的是sdk的orderID function this.RechargeSuccessOrder(msg) - LogRed("充值成功,orderId = "..tostring(msg.orderId)) + LogRed("充值成功,orderId = " .. tostring(msg.orderId)) -- 订单id特殊传值 - CustomEventManager.SendCustomEvent("PayOrderId", tostring(msg.orderId) ,"0") + CustomEventManager.SendCustomEvent("PayOrderId", tostring(msg.orderId), "0") end function this.Pay(id, func) if not RECHARGEABLE then - return + return end - LogRed("发起购买商品的请求,商品id = "..id) + LogRed("发起购买商品的请求,商品id = " .. id) if not func then - func = function()end + func = function() end end -- 请求游戏服务器的orderId @@ -56,21 +57,21 @@ function this.Pay(id, func) -- if this.EventTrigger[id] then -- LogError("重复发起购买商品的请求,商品id = "..id..", uid = "..PlayerManager.uid) -- PopupTipPanel.ShowTip("您有一个相同的订单正在处理,请稍后再试") - -- return + -- return -- end - LogRed("发起购买商品的请求,订单id = "..orderId) + LogRed("发起购买商品的请求,订单id = " .. orderId) this.EventTrigger[id] = func - CheckRedPointStatus(RedPointType.GrowthPackage)--成长礼包的红点检测 + CheckRedPointStatus(RedPointType.GrowthPackage) --成长礼包的红点检测 --直购商品 local rechargeConfig = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig, id) --现金点券购买 - local xjdqNum=BagManager.GetItemCountById(131) - if xjdqNum>=rechargeConfig.Price and rechargeConfig.Price>0 and rechargeConfig.OtherBuy1 and #rechargeConfig.OtherBuy1>0 and rechargeConfig.OtherBuy1[1][1]==131 then - local sureFunc=function() + local xjdqNum = BagManager.GetItemCountById(131) + if xjdqNum >= rechargeConfig.Price and rechargeConfig.Price > 0 and rechargeConfig.OtherBuy1 and #rechargeConfig.OtherBuy1 > 0 and rechargeConfig.OtherBuy1[1][1] == 131 then + local sureFunc = function() NetManager.MoneyBuyGiftRequest(id) end - local cancelFunc=function() + local cancelFunc = function() if AppConst.isSDKLogin and rechargeConfig.Price > 0 then PayManager.SdkPay({ Id = id, orderId = orderId }) else @@ -79,22 +80,22 @@ function this.Pay(id, func) end) end end - local args={} - args[1]=Language[12029] - args[2]=Language[12030] - args[3]=Language[12031] - args[4]=sureFunc - args[5]=cancelFunc - UIManager.OpenPanel(UIName.GMCommonConfirmPanel,args) + local args = {} + args[1] = Language[12029] + args[2] = Language[12030] + args[3] = Language[12031] + args[4] = sureFunc + args[5] = cancelFunc + UIManager.OpenPanel(UIName.GMCommonConfirmPanel, args) return end - local yhqNum=BagManager.GetItemCountById(108) - if yhqNum>=rechargeConfig.Price and rechargeConfig.Price>0 then - local sureFunc=function() + local yhqNum = BagManager.GetItemCountById(108) + if yhqNum >= rechargeConfig.Price and rechargeConfig.Price > 0 then + local sureFunc = function() NetManager.SendYHQBuyGoodRequest(id) end - local cancelFunc=function() + local cancelFunc = function() if AppConst.isSDKLogin and rechargeConfig.Price > 0 then PayManager.SdkPay({ Id = id, orderId = orderId }) else @@ -103,16 +104,16 @@ function this.Pay(id, func) end) end end - local args={} - args[1]=Language[12032] - args[2]=Language[12033] - args[3]=Language[12031] - args[4]=sureFunc - args[5]=cancelFunc - UIManager.OpenPanel(UIName.GMCommonConfirmPanel,args) + local args = {} + args[1] = Language[12032] + args[2] = Language[12033] + args[3] = Language[12031] + args[4] = sureFunc + args[5] = cancelFunc + UIManager.OpenPanel(UIName.GMCommonConfirmPanel, args) return end - if rechargeConfig.BuyType==1 then --人民币 + if rechargeConfig.BuyType == 1 then --人民币 if AppConst.isSDKLogin and rechargeConfig.Price > 0 then PayManager.SdkPay({ Id = id, orderId = orderId }) else @@ -120,13 +121,13 @@ function this.Pay(id, func) this.onSdkPayResult(id) end) end - elseif rechargeConfig.BuyType==2 then --gm余额购买 + elseif rechargeConfig.BuyType == 2 then --gm余额购买 NetManager.SendGmBuyGoodRequest(id) - elseif rechargeConfig.BuyType==3 then --rmb/gm余额购买 - local sureFunc=function() + elseif rechargeConfig.BuyType == 3 then --rmb/gm余额购买 + local sureFunc = function() NetManager.SendGmBuyGoodRequest(id) end - local cancelFunc=function() + local cancelFunc = function() if AppConst.isSDKLogin and rechargeConfig.Price > 0 then PayManager.SdkPay({ Id = id, orderId = orderId }) else @@ -135,19 +136,17 @@ function this.Pay(id, func) end) end end - local args={} - args[1]=Language[12034] - args[2]=Language[12035] - args[3]=Language[12031] - args[4]=sureFunc - args[5]=cancelFunc - UIManager.OpenPanel(UIName.GMCommonConfirmPanel,args) + local args = {} + args[1] = Language[12034] + args[2] = Language[12035] + args[3] = Language[12031] + args[4] = sureFunc + args[5] = cancelFunc + UIManager.OpenPanel(UIName.GMCommonConfirmPanel, args) end - end) end - function this.SdkPay(context) local rechargeConfig = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig, context.Id) local payData = table.clone(context) @@ -163,23 +162,22 @@ function this.SdkPay(context) else payData.RechargeId = rechargeConfig.Id end - LogError("paydata.RechargeId=="..payData.RechargeId) + LogError("paydata.RechargeId==" .. payData.RechargeId) this.RequestPay(payData) end function this.RequestPay(context) - local price = MoneyUtil.GetMoney(context.Price) SDKMgr.onPayCallback = function(payResp) - Log("onPayCallback::"..payResp) + Log("onPayCallback::" .. payResp) local str = string.split(payResp, "#") local result = tonumber(str[1]) -- local orderId = str[2] if result == SDK_RESULT.SUCCESS then elseif result == SDK_RESULT.FAILED then - + else --PopupTipPanel.ShowTip("取消充值" .. result) -- DataCenterManager.CommitPayStatus( @@ -203,17 +201,27 @@ function this.RequestPay(context) params.serverID = PlayerManager.serverInfo.server_id params.serverName = PlayerManager.serverInfo.name -- 角色相关 - params.roleID = tostring(PlayerManager.uid).."_"..tostring(context.Id).."_"..PackageManager.GetCCCode().."_"..AppConst.Platform--.."_"..tostring(context.orderId or "0").."_"..tostring(LoginManager.ServerId) + params.roleID = tostring(PlayerManager.uid) .. + "_" .. + tostring(context.Id) .. + "_" .. + PackageManager.GetCCCode() .. + "_" .. AppConst.Platform --.."_"..tostring(context.orderId or "0").."_"..tostring(LoginManager.ServerId) params.roleName = PlayerManager.nickName params.roleLevel = PlayerManager.level params.vip = tostring(VipManager.GetVipLevel()) params.guildID = PlayerManager.familyId -- 其他 params.payNotifyUrl = "" - params.extension = tostring(PlayerManager.uid).."_"..tostring(context.Id).."_"..PackageManager.GetCCCode().."_"..AppConst.Platform--.."_"..tostring(context.orderId or "0").."_"..tostring(LoginManager.ServerId) + params.extension = tostring(PlayerManager.uid) .. + "_" .. + tostring(context.Id) .. + "_" .. + PackageManager.GetCCCode() .. + "_" .. AppConst.Platform --.."_"..tostring(context.orderId or "0").."_"..tostring(LoginManager.ServerId) SDKMgr:Pay(params) - -- + -- -- ThinkingAnalyticsManager.Track("create_order", { -- goods_id = context.Id, -- goods_name = context.Name, @@ -222,4 +230,4 @@ function this.RequestPay(context) -- }) end -return this \ No newline at end of file +return this diff --git a/Assets/ManagedResources/~Lua/Modules/Setting/SettingInfo.lua b/Assets/ManagedResources/~Lua/Modules/Setting/SettingInfo.lua index 7e7d4d2b4b..37fc193a47 100644 --- a/Assets/ManagedResources/~Lua/Modules/Setting/SettingInfo.lua +++ b/Assets/ManagedResources/~Lua/Modules/Setting/SettingInfo.lua @@ -82,7 +82,7 @@ function SettingInfo:SetTipShow() elseif flag == 1 then this.dropDownText.text = "English" end - this.dropDown.value = flag + this.dropDown.value = flag - 1 if GetCurLanguage() ~= flag then this.dropDownTip.gameObject:SetActive(true) else @@ -112,9 +112,9 @@ function SettingInfo:BindEvent() if IsLanguagePack then this.dropDown.onValueChanged:AddListener( function(value) - PlayerPrefs.SetInt("language_flag", value) + PlayerPrefs.SetInt("language_flag", value + 1) this:SetTipShow() - if value == GetCurLanguage() then + if (value + 1) == GetCurLanguage() then return end MsgPanel.ShowTwo(Language[12814], function() end, function()