-------------------------------------- -- 数据库设计 --[[ 1 超值基金 2 奢华基金 human.db.overflow = {} human.db.overflow.state = {} human.db.overflow.state[1] = time human.db.overflow.state[2] = time human.db.overflow.get = {} human.db.overflow.get[1] = val human.db.overflow.get[2] = val ]] ----------------------------------------- -- 引用文件 local PresentExcel = require("excel.present") local Msg = require("core.Msg") local Util = require("common.Util") local BuyLogic = require("topup.BuyLogic") local BagLogic = require("bag.BagLogic") local Grid = require("bag.Grid") local PanelDefine = require("broadcast.PanelDefine") local YunYingLogic = require("yunying.YunYingLogic") ----------------------------------------- -- 宏定义 OVERFLOW_TYPE_1 = 1 -- 超值基金 OVERFLOW_TYPE_2 = 2 -- 奢华基金 ----------------------------------------- -- 逻辑接口 -- 是否开启 function isOpen(human,YYInfo,funcConfig) if not human.db.nFirstBuy or 1 ~= human.db.nFirstBuy then return false end return true end -- 获取当前基金状态 --return 状态,下次领取天数 状态 0 未购买 1 领取 2 已领取 local function getState(human,type) -- 有数据 if human.db.overflow and human.db.overflow.state and human.db.overflow.state[type] then local day = Util.diffDay(human.db.overflow.state[type]) + 1 human.db.overflow.get = human.db.overflow.get or {} human.db.overflow.get[type] = human.db.overflow.get[type] or 0 local nextDay = human.db.overflow.get[type] if nextDay < day then return 1,nextDay + 1 else return 2,nextDay + 1 end end return 0,0 end -- 基金信息查询 function overflowQuery(human,type) -- 根据类型获得配置 local config = nil if type == OVERFLOW_TYPE_1 then config = PresentExcel.overflowFund elseif type == OVERFLOW_TYPE_2 then config = PresentExcel.luxuryFund end if not config then return end local msgRet = Msg.gc.GC_OVERFLOW_FUND_QUERY msgRet.type = type BuyLogic.fontBuyItem(human, msgRet.buyMsg, config[1].buyID) msgRet.state,msgRet.nextGet = getState(human,type) local len = #config local count = 0 for i = 1,len do Grid.makeItem(msgRet.item[i],config[i].item[1][1],config[i].item[1][2]) if config[i].part == 1 then count = count + 1 msgRet.partItem[count] = i end end msgRet.partItem[0] = count msgRet.item[0] = len msgRet.worth[1] = PresentExcel.overflowFund[1].worth msgRet.worth[2] = PresentExcel.luxuryFund[1].worth msgRet.worth[0] = 2 Msg.send(msgRet,human.fd) end function onBuy(human,type) -- 已购买,不可重复购买 if human.db.overflow and human.db.overflow.state and human.db.overflow.state[type] then return end human.db.overflow = human.db.overflow or {} human.db.overflow.state = human.db.overflow.state or {} human.db.overflow.get = human.db.overflow.get or {} human.db.overflow.state[type] = os.time() human.db.overflow.get[type] = 0 overflowQuery(human,type) for k, v in pairs(funcID) do YunYingLogic.sendGroupUpdate(YYInfo[k], human, PanelDefine.PANEL_ID_3310) break end end function getFundReward(human,type) -- 根据类型获得配置 local config = nil if type == OVERFLOW_TYPE_1 then config = PresentExcel.overflowFund elseif type == OVERFLOW_TYPE_2 then config = PresentExcel.luxuryFund end if not config then return end local state = getState(human,type) if state == 0 then return end local day = Util.diffDay(human.db.overflow.state[type]) + 1 human.db.overflow.get = human.db.overflow.get or {} human.db.overflow.get[type] = human.db.overflow.get[type] or 0 local nextDay = human.db.overflow.get[type] + 1 local item = {} local len = #config for i = nextDay,day do if not config[i] then break end human.db.overflow.get[type] = human.db.overflow.get[type] + 1 item[#item + 1] = {config[i].item[1][1],config[i].item[1][2]} end BagLogic.addItemList(human, item, "overflow_fund") -- 领取完最后一天 if day >= len then human.db.overflow.state[type] = nil human.db.overflow.get[type] = nil end overflowQuery(human,type) for k, v in pairs(funcID) do YunYingLogic.sendGroupUpdate(YYInfo[k], human, PanelDefine.PANEL_ID_3310) break end end function isRed(human) for i = 1,2 do local state = getState(human,i) -- 已购买 if state ~= 0 then local day = Util.diffDay(human.db.overflow.state[i]) + 1 human.db.overflow.get = human.db.overflow.get or {} human.db.overflow.get[i] = human.db.overflow.get[i] or 0 local nextDay = human.db.overflow.get[i] + 1 if day >= nextDay then return true end end end return false end