123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341 |
- 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 namecenter
- local usercenter
- local synchronized = queue()
- local skynet_send = skynet.send
- local skynet_call = skynet.call
- local status = 0
- local pay_id_init = 0
- local db_character
- local FUND = 2
- local MONTH = 3
- local LIFELONG = 4
- local QUARTER = 5
- local WEEK = 6
- local SUPER_FUND = 8
- local authz = {
- acc="yytx",
- pwd="lee@YY-Games.520"
- }
- local pay_id = {
- }
- local content = {
- acc = authz.acc,
- pwd = authz.pwd,
- sign = false
- }
- content.sign = string.sub(md5.sumhexa(content.acc .. content.pwd),9,24)
- local whitelist = {
- }
- local function init_payid()
- local cfg = assert(asset.recharge_proto)
- for key, value in pairs(cfg) do
- if value.type == FUND then
- pay_id.fund = tonumber(key)
- elseif value.type == MONTH then
- pay_id.month_card = tonumber(key)
- elseif value.type == LIFELONG then
- pay_id.longlife_card = tonumber(key)
- elseif value.type == QUARTER then
- pay_id.quarter_card = tonumber(key)
- elseif value.type == WEEK then
- pay_id.week_card = tonumber(key)
- elseif value.type == SUPER_FUND then
- pay_id.super_fund = tonumber(key)
- end
- end
- pay_id_init = 1
- end
- local function get_id(name)
- return skynet.call(namecenter,"lua","findby", name)
- end
- local function initialize()
- status = 1
- namecenter = skynet.localname(".namecenter")
- usercenter = skynet.localname(".usercenter")
- local conf = assert(option.redis)
- db_character = redisdriver.connect(conf)
- db_character:select(0)
- end
- local function direct_recharge_gift(char2, grade_num)
- local ACTIV_ID = 63
- local activitytimemod_data = skynet.unpack(char2.activitytimemod)
- logger.trace(" #$### activitytimemod_data.activity_token[ACTIV_ID] %s", stringify(activitytimemod_data.activity_token[ACTIV_ID] or {}))
- if activitytimemod_data.activity_token[ACTIV_ID] then
- if activitytimemod_data.activity_token[ACTIV_ID].state ~= 0 then
- local TIME_SID = activitytimemod_data.activity_token[ACTIV_ID].sid
- local c_acti = assert(asset.activity_proto[TIME_SID], "activity_proto:" .. TIME_SID)
- local condition = c_acti.condition
- local parameter4 = c_acti.parameter4
- for k, v in ipairs(condition) do
- grade_num[v] = {sum = parameter4[k] or 0, yet=0}
- end
-
- local direct_recharge_gift_data = skynet.unpack(char2.direct_recharge_gift)
- logger.trace(" ####### direct_recharge_gift_data %s", stringify(direct_recharge_gift_data))
- for key, value in pairs(direct_recharge_gift_data.draw) do
- if condition[key] then
- grade_num[condition[key]].yet = value.can
- end
- end
- end
- end
- end
- local function senior_check_in(char2, grade_num)
- local WEL_KEY = 112
- local order_id = assert(asset.welfare_proto[WEL_KEY].parameter2[3])
- local senior_check_in_data = skynet.unpack(char2.senior_check_in)
- local id = order_id
- grade_num[id] = {sum = 1, yet = 0}
- logger.trace(" ####### senior_check_in_data %s", stringify(senior_check_in_data))
- if senior_check_in_data.state > 0 then
- grade_num[id].yet = 1
- end
- end
- local function senior_check_in2(char2, grade_num)
- local WEL_KEY = 113
- local order_id = assert(asset.welfare_proto[WEL_KEY].parameter2[3])
- local senior_check_in2_data = skynet.unpack(char2.senior_check_in2)
- local id = order_id
- grade_num[id] = {sum = 1, yet = 0}
- logger.trace(" ####### senior_check_in2_data %s", stringify(senior_check_in2_data))
- if senior_check_in2_data.state > 0 then
- grade_num[id].yet = 1
- end
- end
- local function longlife_card(char2,grade_num)
- local appreciation_card = skynet.unpack(char2.appreciation_card)
- local id = pay_id.longlife_card
- grade_num[id] = {sum = 1, yet = 0}
- logger.trace(" ####### longlife_card %s", stringify(appreciation_card))
- appreciation_card.lifelongstate = appreciation_card.lifelongstate or 0
- if tonumber(appreciation_card.lifelongstate) == 1 then
- grade_num[id].yet = 1
- end
- end
- local function week_card(char2,grade_num)
- local appreciation_card = skynet.unpack(char2.appreciation_card)
- local id = pay_id.week_card
- grade_num[id] = {sum = 1, yet = 0}
- logger.trace(" ####### week_card %s", stringify(appreciation_card))
- appreciation_card.weektime = appreciation_card.weektime or 0
- local now = os.time()
- if appreciation_card.weektime > now then
- grade_num[id].yet = 1
- end
- end
- local function month_card(char2,grade_num)
- local appreciation_card = skynet.unpack(char2.appreciation_card)
- local id = pay_id.month_card
- grade_num[id] = {sum = 1, yet = 0}
- logger.trace(" ####### month_card %s", stringify(appreciation_card))
- local now = os.time()
- appreciation_card.monthtime = appreciation_card.monthtime or 0
- if appreciation_card.monthtime > now then
- grade_num[id].yet = 1
- end
- end
- local function quarter_card(char2,grade_num)
- local appreciation_card = skynet.unpack(char2.appreciation_card)
- local id = pay_id.quarter_card
- if not id then
- return
- end
- grade_num[id] = {sum = 1, yet = 0}
- logger.trace(" ####### quarter_card %s", stringify(appreciation_card))
- appreciation_card.quartertime = appreciation_card.quartertime or 0
- local now = os.time()
- if appreciation_card.quartertime > now then
- grade_num[id].yet = 1
- end
- end
- local function fund(char2,grade_num)
- local fund_data = skynet.unpack(char2.fund)
- local id = pay_id.fund
- grade_num[id] = {sum = 1, yet = 0}
- logger.trace(" ####### fund_data %s", stringify(fund_data))
- if fund_data.state and fund_data.state > 0 then
- grade_num[id].yet = 1
- end
- end
- local function super_fund(char2, grade_num)
- local super_fund_data = skynet.unpack(char2.super_fund)
- local id = pay_id.super_fund
- grade_num[id] = {sum = 1, yet = 0}
- logger.trace(" ####### super_fund_data %s", stringify(super_fund_data))
- super_fund_data.isbuy_state = super_fund_data.isbuy_state or 0
- if super_fund_data.isbuy_state > 0 then
- grade_num[id].yet = 1
- end
- end
- local function secret_manual(char2, grade_num)
- local ACTIV_ID = 96
- local cfid = -1
- local secret_manual_data = skynet.unpack(char2.secret_manual)
- if not secret_manual_data then
- return
- end
- logger.trace(" ####### super_fund_data %s", stringify(secret_manual_data))
- if secret_manual_data.state > 0 then
- local activitytimemod = skynet.unpack(char2.activitytimemod)
- if activitytimemod.activity_token[ACTIV_ID] then
- local sid = activitytimemod.activity_token[ACTIV_ID].sid
- local c_acti = assert(asset.activity_proto[sid],"activity_proto:" .. sid)
- cfid = c_acti.condition[1]
- end
- end
- if cfid == -1 then
- return
- end
- local id = cfid
- grade_num[id] = {sum = 1, yet = 0}
- secret_manual_data.levelup = secret_manual_data.levelup or 0
- if secret_manual_data.levelup > 0 then
- grade_num[id].yet = 1
- end
- end
- local function special_gift(char2,grade_num)
- local special_gift = skynet.unpack(char2.special_gift)
- if special_gift.state > 0 then
- local activitytimemod = skynet.unpack(char2.activitytimemod)
- if activitytimemod.activity_token[38] then
- local sid = activitytimemod.activity_token[38].sid
- local c_acti = assert(asset.activity_proto[sid],"activity_proto:" .. sid)
- for k, cfid in ipairs(c_acti.condition) do
- local cnum = c_acti.parameter1[k]
- grade_num[cfid] = {sum = cnum, yet = 0}
- end
- for cfid, value in pairs(special_gift.yet_recharge) do
- grade_num[cfid].yet = value.rnum
- end
- end
- end
- end
- local webplayer = function(args, ipaddr,header)
- return synchronized(function()
- logger.trace("处理来自主机 %s 的获取玩家数据请求", ipaddr)
- if status == 0 then
- initialize()
- end
- if pay_id_init == 0 then
- init_payid()
- end
- if not whitelist[ipaddr] then
-
- end
-
- local code=string.sub(args.code,1,16)
- logger.trace(" ### code %s", args.code)
- if code ~= content.sign then
- return cjson.encode({state = 403,msg= "账号或密码错误"})
- end
- local uid
- if args.name then
- uid =get_id(args.name)
- elseif args.uid then
- uid= args.uid
- elseif (not args.uid) and (not args.name) then
- return cjson.encode({state = 403,msg= "请输入玩家uid或者玩家name"})
- end
- local k = string.format("character:%s", uid)
- local info
- if true == db_character:exists(k) then
- info = loader(uid)
- else
- return cjson.encode({state = 400,msg = "加载玩家数据失败", content= uid})
- end
- if next(info) then
- local player = {}
- player.level = info.level
- player.vip = info.vip
- player.nickname = info.nickname
- player.uid = info.uid
- local grade_num = {}
-
- direct_recharge_gift(info, grade_num)
- senior_check_in(info, grade_num)
- super_fund(info, grade_num)
- senior_check_in2(info, grade_num)
- secret_manual(info,grade_num)
- fund(info,grade_num)
- special_gift(info,grade_num)
- longlife_card(info,grade_num)
- week_card(info,grade_num)
- month_card(info,grade_num)
- quarter_card(info,grade_num)
- player.grade_num = grade_num
- return cjson.encode({state=0,msg="success",content=player})
- else
- return cjson.encode({state = 400, msg = "未找到该玩家"})
- end
- end)
- end
- return webplayer
|