12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- --[[
- author:{zlf}
- time:2019-12-14 14:42:28
- note: web网页充值查询玩家数据
- jira: PK3-1102
- ]]--
- local skynet = require "skynet"
- require "skynet.manager"
- local logger = require "logger"
- local queue = require "skynet.queue"
- local cjson = require "cjson"
- local stringify = require "stringify"
- local pipeline = require "pipeline"
- local loader = require "model.loader"
- local elf = require "model.elf"
- local equipment = require "model.equipment"
- local redisdriver = require "skynet.db.redis"
- local asset = require "model.asset"
- local md5 = require "md5"
- local ti=require "model.title"
- local synchronized = queue()
- local skynet_send = skynet.send
- local skynet_call = skynet.call
- local status = 0
- local db_character
- local authz = {acc = "yytx", pwd = "lee@YY-Games.520"}
- local content = {acc = authz.acc, pwd = authz.pwd, sign = false}
- content.sign = string.sub(md5.sumhexa(content.acc .. content.pwd), 9, 24)
- local whitelist = {
- ["192.168.1.23"] = true,
- ["192.168.1.127"] = true,
- ["192.168.1.50"] = true,
- ["14.29.136.211"] = true,
- ["192.168.1.41"] = true,
- ["222.212.88.4"] = true,
- }
- local function initialize()
- status = 1
- local conf = assert(option.redis)
- db_character = redisdriver.connect(conf)
- db_character:select(0)
- end
- --请求方式1: http://服务器ip地址:端口号/web_recharge_query?code=xxx&玩家uid
- --示例: http://192.168.1.102:8002/web_recharge_query?code=xxx&uid=00-6565406671068221440
- local web_recharge_query = function(args, ipaddr,header)
- return synchronized(function()
- logger.trace("处理来自主机 %s 的获取玩家数据请求", ipaddr)
- logger.trace(" args %s", stringify(args))
- if status == 0 then
- initialize()
- end
- if not whitelist[ipaddr] then
- -- return cjson.encode({state = 403, host = header.host, info = "不信任ip"})
- end
- -- 验证gm账号
- local code=string.sub(args.code,1,16)
- if code ~= content.sign then
- return cjson.encode({state = 403,msg= "账号或密码错误"})
- end
- local uid
- if args.uid then
- uid=args.uid
- elseif not args.uid then
- return cjson.encode({state = 403,msg= "请输入玩家uid或者玩家name"})
- end
- local key = string.format("character:%s", uid)
- local info = db_character:HMGET(key, "nickname", "sid")
- -- return cjson.encode({state = 400,msg = "加载玩家数据失败", content= uid})
- if next(info) then
- local retdata = {
- name = info[1],
- svrid = info[2],
- }
- logger.trace(" retdata.recharge = %s", stringify(retdata))
- return cjson.encode({state=0,msg="success",content=retdata,})
- else
- return cjson.encode({state = 400, msg = "未找到该玩家"})
- end
- end)
- end
- return web_recharge_query
|