--[[ luaide 模板位置位于 Template/FunTemplate/NewFileTemplate.lua 其中 Template 为配置路径 与luaide.luaTemplatesDir luaide.luaTemplatesDir 配置 https://www.showdoc.cc/web/#/luaide?page_id=713062580213505 author:{zlf} time:2019-10-21 16:33:17 jira: PK3-987 note: 确定玩家在本服务器是否有角色 ]] --查询是否建号 local logger = require "logger" local redisdriver = require "skynet.db.redis" local stringify = require "stringify" local skynet = require "skynet" local queue = require "skynet.queue" local synchronized = queue() local trace = logger.trace --local trace = function(...) end local redis local redis_recharge local start local rechargeser local REBATE = "rebate:" local KEYGEN_PAY = "%s:%s" local authz = { lee = "yytx-Games-9527" } local function start_pay() local conf = assert(option.redis) redis = redisdriver.connect(conf) redis_recharge = redisdriver.connect(conf) redis:select(0)--切换到数据库db1 redis_recharge:select(3)--切换到数据库db1 rechargeser = rechargeser or skynet.localname(".recharge") return 1 end local facebook = nil -- 云账号登陆废弃 local function retrieve_facebook_account(account, sid, channel) facebook = facebook or skynet.localname(".facebook") local errno, fb = skynet.call(facebook, "lua", "retrieve", account, channel) local uid = nil if errno == 200 then uid = redis:get(string.format("account:%s:%s:%s", channel, sid, fb)) end return errno, uid end --192.168.1.44:9001/get_server_uid?uid=9999&&channel=185sy&account=1232123 local get_server_uid = function(args, ipaddr) return synchronized(function() start = start or start_pay() trace("处理来自主机 %s 的uid检测请求", ipaddr) local channel = args.channel local account = args.account local serverid = tonumber(args.serverid) trace("开始处理uid检测信息:%s",stringify(args)) -- 验证gm账号 local user = args.user or "" local pwd = args.pwd or "" if authz[user] ~= pwd then return { code=2 } end if not account or not channel then return { code=1 }--数据不足 end local uid if account then local k = string.format("account:%s:%s:%s", channel, serverid, account) uid = redis:get(k) end if not uid then -- 云账号登陆废弃 local errno, val = retrieve_facebook_account(account, serverid, channel) if errno == 200 then uid = val end end if not uid then trace("验证玩家建号数据错误:setuid:%s, uid:%s",setuid, uid) return { code=3 }--未在该服务器创建玩家 end local name local level if uid then local k = string.format("character:%s", uid) if redis:hget(k,"sex") then name = redis:hget(k,"nickname") level = redis:hget(k,"level") else return { code=3 }--未在该服务器创建玩家 end end return { code=0,uid=uid,name=name,level=level } end) end return get_server_uid