CallFCommand.lua 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. local CallFCommand = class('CallFCommand', framework.SimpleCommand)
  2. function CallFCommand:ctor()
  3. end
  4. function CallFCommand:execute(notification)
  5. local cjson = require("cjson")
  6. local facade = global.Facade
  7. local data = notification:getBody()
  8. local paytype = data.paytype
  9. local channel = data.channel
  10. local product = data.product
  11. local qrcodeCB = data.qrcodeCB
  12. if not product.price or not product.id or not product.name then
  13. releasePrint( "pay product param error!" )
  14. return
  15. end
  16. -- 充值发起给3s菊花转
  17. ShowLoadingBar(3)
  18. local id = product.id
  19. local name = product.name
  20. local price = product.price
  21. local productIndex = product.productIndex
  22. local value = product.exchange
  23. local propertyProxy = facade:retrieveProxy( global.ProxyTable.PlayerProperty )
  24. local loginProxy = facade:retrieveProxy( global.ProxyTable.Login )
  25. local envProxy = facade:retrieveProxy( global.ProxyTable.GameEnvironment )
  26. local AuthProxy = facade:retrieveProxy( global.ProxyTable.AuthProxy )
  27. local currModule = global.L_ModuleManager:GetCurrentModule()
  28. -- 订单号,客户端生成,无法保证全局唯一,但是影响不大
  29. -- 新增productId productIndex
  30. local timeMS = socket.gettime() * 10000
  31. local trade_no = string.format("HEROES_DREAM_%s_%09d|%s_%s", timeMS, Random(1, 999999999), tostring(id), tostring(productIndex or 0))
  32. local jData = {}
  33. jData.gameid = tostring(currModule:GetOperID())
  34. jData.currencyID = tostring( id )
  35. jData.currencyValue = tonumber( value )
  36. jData.productId = tostring( id )
  37. jData.productIndex = tostring( productIndex )
  38. jData.productName = tostring( name )
  39. jData.productPrice = tostring( price )
  40. jData.roleName = loginProxy:GetSelectedRoleName()
  41. jData.roleId = loginProxy:GetSelectedRoleID()
  42. jData.serverId = loginProxy:GetSelectedServerId()
  43. jData.mainServerId = loginProxy:GetMainSelectedServerId() or loginProxy:GetSelectedServerId()
  44. jData.serverName = loginProxy:GetSelectedServerName()
  45. jData.userId = tostring( AuthProxy:GetUID() )
  46. jData.srvDomain = tostring( loginProxy:GetSelectedServerDomain() )
  47. jData.roleJob = tostring( GetJobName(propertyProxy:GetRoleJob()) ) -- 职业 战/法/道
  48. jData.roleSex = tostring( propertyProxy:GetRoleSex() + 1 ) -- 性别 1男 2女
  49. jData.roleLevel = tostring( propertyProxy:GetRoleLevel() ) -- 角色等级
  50. jData.orderid = trade_no
  51. jData.ext = trade_no
  52. jData.channelId = envProxy:GetChannelID()
  53. jData.roleJobId = propertyProxy:GetRoleJob()
  54. -- jData.callbackUrl = string.format("http://%s:8000/payNotify.php?platform=%s_%s", loginProxy:GetSelectedServerIp(), envProxy:GetChannelID(), currModule:GetOperID())
  55. jData.callbackUrl = string.format("%s/payNotify.php/%s?platform=%s_%s", envProxy:GetCustomDataByKey("payNotifyUrl"), currModule:GetOperID(), envProxy:GetChannelID(), currModule:GetOperID())
  56. local selSerInfo = loginProxy:GetSelectedServer()
  57. local main_servid = selSerInfo and selSerInfo.mainServerId
  58. local main_server_name = selSerInfo and selSerInfo.mainServerName
  59. jData.main_servid = tostring(main_servid) or tostring(server_id)
  60. jData.main_server_name = tostring(main_server_name) or tostring(server_name)
  61. -- 请求支付
  62. local currentModule = global.L_ModuleManager:GetCurrentModule()
  63. local moduleGameEnv = currentModule:GetGameEnv()
  64. local loginData = moduleGameEnv:GetLoginData()
  65. -- PC联运
  66. local PCPlatform = global.L_GameEnvManager:GetEnvDataByKey("PCPlatform")
  67. local user_id = global.L_GameEnvManager:GetEnvDataByKey("user_id")
  68. local token = global.L_GameEnvManager:GetEnvDataByKey("token")
  69. -- 接了PC的SDK支付
  70. if global.L_NativeBridgeManager.PCCheckMedthodName and global.L_NativeBridgeManager.PCNoticeRequest then
  71. if global.L_NativeBridgeManager:PCCheckMedthodName("checkSDKPay") then
  72. --价格是按照分计算的
  73. jData.productPrice = tostring(price*100)
  74. global.L_NativeBridgeManager:PCNoticeRequest("GN_onCallOF", jData)
  75. return
  76. end
  77. end
  78. local isPcSdk = global.L_GameEnvManager:GetEnvDataByKey("isPcSdk")
  79. if global.L_GameEnvManager:GetEnvDataByKey("platform") == "mac" then
  80. AuthProxy:RequestPay(paytype, channel, jData, qrcodeCB)
  81. else
  82. if loginData and loginData.username and loginData.password then
  83. -- on call of father
  84. global.L_NativeBridgeManager:GN_onCallOF(jData)
  85. elseif (tonumber(PCPlatform) == 1 and user_id and token) or isPcSdk then
  86. -- pc recharge
  87. AuthProxy:RequestJuhePay(paytype, channel, jData, qrcodeCB)
  88. else
  89. AuthProxy:RequestPay(paytype, channel, jData, qrcodeCB)
  90. end
  91. end
  92. end
  93. return CallFCommand