| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- --七日豪礼
- local Msg = require("core.Msg")
- local SevenDayGiftExcel = require("excel.present").sevenDayGift
- local BuyExcel = require("excel.buy")
- local BuyLogic = require("topup.BuyLogic")
- local Grid = require("bag.Grid")
- local BagLogic = require("bag.BagLogic")
- local Util = require("common.Util")
- local Lang = require("common.Lang")
- local Broadcast = require("broadcast.Broadcast")
- local CommonDB = require("common.CommonDB")
- local TopupLogic = require("topup.TopupLogic")
- local YunYingLogic = require("yunying.YunYingLogic")
- local PanelDefine = require("broadcast.PanelDefine")
- local SceneHandler = require("scene.Handler")
- SEVENDAYGIFT_BUY_NO = 0 --没买
- SEVENDAYGIFT_BUY_HAD = 1 --已买
- local function isBuy(human,id)
- local godDailyTopup = human.db.godDailyTopup
- local status = 0
- if godDailyTopup and godDailyTopup[id] and godDailyTopup[id].pay then
- status = 1
- end
- return status
- end
- -- 检查活动是否开启
- function check(human,noSend)
- if not SceneHandler.canCharge(human) then
- return
- end
- local openLv = YunYingLogic.getOpenLvByPanelID(PanelDefine.PANEL_ID_62)
- if human.db.lv < openLv then
- if not noSend then
- local str = Util.format(Lang.ROLE_LEV_ERROR,openLv)
- return Broadcast.sendErr(human,str)
- end
- end
- for i=1,#SevenDayGiftExcel do
- local isBuy = isBuy(human,i)
- if isBuy == SEVENDAYGIFT_BUY_NO then
- return true
- end
- end
- end
- function makeGiftMsg(human,net,config,id)
- net.id = config.realId
- local buyID = config.buyID
- net.giftVipExp = config.vipExp
-
- net.item[0] = #config.reward
- for j = 1,#config.reward do
- Grid.makeItem(net.item[j],config.reward[j][1],config.reward[j][2])
- end
- BuyLogic.fontBuyItem(human,net.buyMsg, buyID)
- local godDailyTopup = human.db.godDailyTopup
- local status = 0
- if godDailyTopup and godDailyTopup[id] and godDailyTopup[id].pay then
- status = 1
- end
- net.status = status
- end
- --七日豪礼查询
- function query(human)
- if not check(human) and not SevenLoginDayLogic.isBaseOpen(human) then return end
- local msgRet = Msg.gc.GC_SEVENDAYGIFT_QUERY
- local today = Util.diffDay(human.db.createTime) + 1
- if today > #SevenDayGiftExcel then
- today = #SevenDayGiftExcel + 1
- end
- msgRet.today = today
- msgRet.giftMsg[0] = #SevenDayGiftExcel
- for i=1,#SevenDayGiftExcel do
- makeGiftMsg(human,msgRet.giftMsg[i],SevenDayGiftExcel[i],i)
- end
- --Msg.trace(msgRet)
- Msg.send(msgRet,human.fd)
- end
- function dailyTopupBuy(human,id)
- if not check(human) and not SevenLoginDayLogic.isBaseOpen(human) then return end
- -- 礼包不存在
- local config = SevenDayGiftExcel[id]
- if not config then
- return Broadcast.sendErr(human,Lang.ACT_WAS_OVER)
- end
- local today = Util.diffDay(human.db.createTime) + 1
- if id > today then
- return Broadcast.sendErr(human,Lang.TOMORROW_OPEN)
- end
- -- 礼包已购买
- if human.db.godDailyTopup and human.db.godDailyTopup[id] and human.db.godDailyTopup[id].pay ~= nil then
- return Broadcast.sendErr(human,Lang.COMMON_LIBAO_HADBUY)
- end
- -- 写db
- human.db.godDailyTopup = human.db.godDailyTopup or {}
- human.db.godDailyTopup[id] = human.db.godDailyTopup[id] or {}
- human.db.godDailyTopup[id].pay = 1
- -- 发货
- BagLogic.addItemList(human, config.reward, "seven_DayGift")
- update(human,id)
- for k, v in pairs(funcID) do
- YunYingLogic.updateIcon(YYInfo[k], human)
- YunYingLogic.sendGroupUpdate(YYInfo[k], human, PanelDefine.PANEL_ID_102)
- break
- end
- end
- function update(human,id)
- local msgRet = Msg.gc.GC_SEVENDAYGIFT_UPDATE
- local config = SevenDayGiftExcel[id]
- if not config then return end
- makeGiftMsg(human,msgRet.giftMsg,config,id)
- --Msg.trace(msgRet)
- Msg.send(msgRet,human.fd)
- end
- function isBaseOpen(human,noSend)
- if not SceneHandler.canCharge(human) then
- return
- end
- if check(human,noSend) then
- return true
- end
- end
- function isOpen(human)
- if isBaseOpen(human,true) or SevenLoginDayLogic.isBaseOpen(human,true) then
- return true
- end
- end
|