-- 方块玩微信小程序上报
local Config = require("Config")
local Json = require("common.Json")
local Define = require("platform.Define")
local CommonDefine = require("common.CommonDefine")
local PfLogic = require("platform.PfLogic")
local InnerMsg = require("core.InnerMsg")
local Log = require("common.Log")


function login(human)
	if not PfLogic.isFKW(human) then
		return
	end
	api_param = {}
	api_param.type = "login"
    api_param.game_id = 271
    api_param.channel_id = human.db.phpChanelID or ""
    api_param.openid = human.vopenid  
    api_param.server_id = Config.SVR_INDEX
    api_param.roleid = human.db.account
	
	if human.isIOS == 1 then
		api_param.platform = "ios"
    else
		api_param.platform = "android"
    end
	
	--Log.write(Log.LOGID_DEBUG, "report login:"..Define.REPORT_FKW_REPORT_PHP..":"..Json.Encode(api_param)) 
	_G.thread_http.send(Define.REPORT_FKW_REPORT_PHP,Json.Encode(api_param))
end

function register(human)
	if not PfLogic.isFKW(human) then
		return
	end
		
	api_param = {}
	api_param.type = "create"
    api_param.game_id = 271
    api_param.channel_id = human.db.phpChanelID or ""
    api_param.openid = human.vopenid  
    api_param.server_id = Config.SVR_INDEX
    api_param.roleid = human.db.account
    api_param.rolename = human.db.name 
	
	if human.isIOS == 1 then
		api_param.platform = "ios"
    else
		api_param.platform = "android"
    end
	
	api_param.from_openid = human.pf_info.fromOpenID or "" 
    --Log.write(Log.LOGID_DEBUG, "report register:"..Define.REPORT_FKW_REPORT_PHP..":"..Json.Encode(api_param)) 
	_G.thread_http.send(Define.REPORT_FKW_REPORT_PHP,Json.Encode(api_param))
end

function charge(human, orderID, amount)
	if not PfLogic.isFKW(human) then
		return
	end
	api_param = {}
	api_param.type = "pay"
    api_param.game_id = 271
    api_param.channel_id = human.db.phpChanelID or ""
    api_param.openid = human.vopenid  
    api_param.server_id = Config.SVR_INDEX
    api_param.roleid = human.db.account
    api_param.orderid = orderID -- 订单id
    api_param.amount = amount * 100 -- 金额 单位分
    if human.isIOS == 1 then
		api_param.platform = "ios"
    else
		api_param.platform = "android"
    end

    --IOS充值单独上报渠道1398
    if api_param.platform  == "ios" then
		api_param.channel_id = "1398"
    end
    
	 --Log.write(Log.LOGID_DEBUG, "report charge:"..Define.REPORT_FKW_PAY_REPORT_PHP..":"..Json.Encode(api_param)) 
	_G.thread_http.send(Define.REPORT_FKW_PAY_REPORT_PHP,Json.Encode(api_param))
end