YunYingLogic.lua 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909
  1. ---------------------------------------------------------
  2. -- 图标管理
  3. -- updateIcon 刷新图标
  4. -- module接口
  5. -- isOpen 如果模块没有这个函数默认是开启 human, YYInfo, funcConfig
  6. -- isRed 如果模块没这个函数 默认是没红点 human, YYInfo, funcConfig
  7. -- getIcon 如果模块没这个函数 默认从yunying表里面读iconid
  8. -- isActive 跟模块关联的激活状态
  9. -- updateDaily 隔天处理
  10. -- onCharge 充值回调
  11. -- onZero 0点处理
  12. -- onLevelUp 升级回调
  13. -- onLogin 登陆回调
  14. ---------------------------------------------------------
  15. local YunYingExcel = require("excel.yunying")
  16. local Lang = require("common.Lang")
  17. local Config = require("Config")
  18. local Util = require("common.Util")
  19. local Msg = require("core.Msg")
  20. local Broadcast = require("broadcast.Broadcast")
  21. local ObjHuman = require("core.ObjHuman")
  22. local BannerExcel = require("excel.yunying")
  23. local AbsActLogic = require("absAct.AbsActLogic")
  24. local SysParameter = require("common.SysParameter")
  25. local PanelDefine = require("broadcast.PanelDefine")
  26. local HeroGrid = require("hero.HeroGrid")
  27. local HeroUpLogic = require("absAct.HeroUpLogic")
  28. local AbsActExcel = require("excel.absAct")
  29. local HtmlUtil = require("common.HtmlUtil")
  30. local Json = require("common.Json")
  31. local YunYingDefine = require("yunying.YunYingDefine")
  32. local CommonDB = require("common.CommonDB")
  33. local MiddleConnect = require("middle.MiddleConnect")
  34. local InnerMsg = require("core.InnerMsg")
  35. local AbsReachRankDB = require("absAct.AbsReachRankDB")
  36. ID2YYInfo = ID2YYInfo or { } -- 每个id是一个主界面上方运营活动大图标入口
  37. PANELID2OPENLV = PANELID2OPENLV or { }
  38. YYFUNCINFO = YYFUNCINFO or { } -- 活动列表 用于快捷查询
  39. BANNER_LIST_SERVER = {}
  40. YUNYING_POS_TYPE1 = 1 -- 运营活动
  41. YUNYING_POS_TYPE2 = 2 -- abs活动
  42. function inServerIndex(svrIndexs)
  43. for i = 1, #svrIndexs do
  44. local index1 = svrIndexs[i][1]
  45. local index2 = svrIndexs[i][2]
  46. if Config.SVR_INDEX >= index1 and Config.SVR_INDEX <= index2 then
  47. return true
  48. end
  49. end
  50. end
  51. -- 根据funcID确定配置文件
  52. function getFuncConfig(funcID)
  53. local funcConfig = YunYingExcel.func[funcID]
  54. if not funcConfig then
  55. funcConfig = AbsActExcel.absActivity[funcID]
  56. end
  57. return funcConfig
  58. end
  59. -- 根据funcID 确定modouleFn数据
  60. local function getYYFuncInfo(funcID)
  61. if not YYFUNCINFO then return end
  62. return YYFUNCINFO[funcID]
  63. end
  64. -- 是否是运营活动
  65. local function isYYfunc(funcID)
  66. if YunYingExcel.func[funcID] then
  67. return true
  68. end
  69. return false
  70. end
  71. -- 是否是Abs活动
  72. local function isAbsfunc(funcID)
  73. if AbsActExcel.absActivity[funcID] then
  74. return true
  75. end
  76. return false
  77. end
  78. -- 初始化数据
  79. local function initYYInfo(yyID, config)
  80. local YYInfo = ID2YYInfo[yyID] or { }
  81. YYInfo.yyID = yyID
  82. YYInfo.config = config
  83. local moduleList = nil
  84. local openLv = 0
  85. for i = 1, #config.funcs do
  86. local funcID = config.funcs[i]
  87. local funcConfig = getFuncConfig(funcID)
  88. if YYFUNCINFO[funcID] then
  89. assert(nil, "initYYInfo is error!!!!"..yyID.."-"..funcID)
  90. end
  91. if funcConfig then
  92. if funcConfig.moduleFn ~= "" then
  93. moduleList = moduleList or { }
  94. local moduleFn = load("return require(\"" .. funcConfig.moduleFn .. "\")")()
  95. moduleList[funcID] = moduleFn
  96. if moduleFn then
  97. moduleFn.funcID = moduleFn.funcID or {}
  98. moduleFn.funcID[funcID] = funcID
  99. moduleFn.YYInfo = moduleFn.YYInfo or {}
  100. moduleFn.YYInfo[funcID] = YYInfo
  101. moduleFn.pos = moduleFn.pos or {}
  102. moduleFn.pos[funcID] = config.pos
  103. moduleFn.yyID = moduleFn.yyID or {}
  104. moduleFn.yyID[funcID] = yyID
  105. funcConfig.funcID = funcID
  106. YYFUNCINFO[funcID] = moduleFn
  107. PANELID2OPENLV[funcConfig.panelID] = funcConfig.openLv
  108. end
  109. end
  110. -- 取子功能里面最低等级
  111. if openLv > funcConfig.openLv or openLv == 0 then
  112. openLv = funcConfig.openLv
  113. end
  114. end
  115. end
  116. YYInfo.moduleList = moduleList
  117. YYInfo.openLv = openLv
  118. ID2YYInfo[yyID] = YYInfo
  119. return YYInfo
  120. end
  121. -- 初始化
  122. function init()
  123. ID2YYInfo = ID2YYInfo or { }
  124. YYFUNCINFO = {}
  125. BANNER_LIST_SERVER = {}
  126. for yyID, noUse in pairs(ID2YYInfo) do
  127. if YunYingExcel.config[yyID] == nil then
  128. ID2YYInfo[yyID] = nil
  129. end
  130. end
  131. for funcID, info in pairs(YYFUNCINFO) do
  132. if YunYingExcel.func[funcID] == nil then
  133. YYFUNCINFO[funcID] = nil
  134. end
  135. if AbsActExcel.absActivity[funcID] == nil then
  136. YYFUNCINFO[funcID] = nil
  137. end
  138. end
  139. for yyID, config in pairs(YunYingExcel.config) do
  140. if inServerIndex(config.serverIndex) then
  141. initYYInfo(yyID, config)
  142. end
  143. end
  144. -- 广告
  145. for k, config in pairs(BannerExcel.banner) do
  146. if inServerIndex(config.serverIndex) then
  147. BANNER_LIST_SERVER[#BANNER_LIST_SERVER + 1] = k
  148. end
  149. end
  150. handleAbs()
  151. -- 活动初始化后 才能去实始化ABS排名活动
  152. AbsReachRankDB.init()
  153. end
  154. ABS_LOOP_TYPE1 = 1 -- 指定时间的活动
  155. ABS_LOOP_TYPE2 = 2 -- 指定时间的活动 指定间隔天数 循环一次
  156. ABS_LOOP_TYPE3 = 3 -- 按开服时间 指定间隔天数 一直循环 支持间隔时间设置
  157. ABS_LOOP_TYPE4 = 4 -- 按开服时间 指定间隔天数 循环一次
  158. ABS_LOOP_TYPE5 = 5 -- 按合服时间 指定间隔天数 循环一次
  159. ABS_LOOP_TYPE6 = 6 -- 每周周几开
  160. ABS_LOOP_TYPE7 = 7 -- 每月几号开
  161. DAY_SEC = 24 * 3600
  162. -- 指定时间的活动
  163. local function handleAbsInit(openDay, now, config, funcID)
  164. config.actId = config.actId or 0
  165. config.adIcon = 0
  166. config.realStartTime = 0
  167. config.realEndTime = 0
  168. end
  169. function handleAbs7MiddleReturn(fd,msg)
  170. if msg.isOpen == 0 then
  171. return
  172. end
  173. local config = getFuncConfig(msg.funcID)
  174. local openDay = CommonDB.getServerOpenDay()
  175. if openDay == nil then return end
  176. if config.loopType ~= ABS_LOOP_TYPE7 then return end
  177. local now = os.time()
  178. local days = config.days -- 持续几天
  179. local turns = config.turns --
  180. local ad = config.ad --
  181. local eachDays = config.eachDays -- 几号开
  182. local toOpenDay = openDay - config.openDay
  183. local endDay = days + eachDays -- 几号结束
  184. local actStart = false
  185. if days > 0 and #turns > 0 then
  186. local nowMidnight = Util.getDayStartTime(now)
  187. local d = os.date("*t",now)
  188. local monthDay = d.day
  189. -- 生效期
  190. if toOpenDay >= 0 and monthDay >= config.eachDays and monthDay < endDay then
  191. local subDays = monthDay - config.eachDays
  192. local handleBeginTs = nil
  193. handleBeginTs = nowMidnight - subDays * DAY_SEC
  194. config.realStartTime = handleBeginTs
  195. config.realEndTime = handleBeginTs + days * DAY_SEC - 3600 -- 活动23点结束
  196. if now >= config.realStartTime and now < config.realEndTime then
  197. config.actId = turns[1] or 0
  198. config.adIcon = ad[1] or 0
  199. print("handleAbs7 act is started!!",Config.SVR_INDEX,msg.funcID,config.actId)
  200. actStart = true
  201. end
  202. end
  203. else
  204. assert(nil, "handleAbs ABS_LOOP_TYPE7 days or turns err !!!" .. funcID)
  205. end
  206. if actStart then
  207. for _, human in pairs(ObjHuman.onlineUuid) do
  208. print("aaaa actStart")
  209. sendIcons(human)
  210. end
  211. end
  212. end
  213. -- 初始化abs活动 开启的时间
  214. function handleAbs()
  215. local openDay = CommonDB.getServerOpenDay()
  216. if openDay == nil then return end
  217. local mergeDay = CommonDB.getServerMergeDay()
  218. local now = os.time()
  219. for yyID, YYInfo in pairs(ID2YYInfo) do
  220. for i = 1, #YYInfo.config.funcs do
  221. local funcID = YYInfo.config.funcs[i]
  222. if isAbsfunc(funcID) then
  223. local config = getFuncConfig(funcID)
  224. if not config then
  225. assert(nil, "handleAbs config is nil !!!" .. funcID)
  226. end
  227. handleAbsInit(openDay, now, config, funcID)
  228. end
  229. end
  230. end
  231. end
  232. -- panel id -> id
  233. local PANELID_2_ACTID = nil
  234. local function getActIDByPanelID(panelID)
  235. if not PANELID_2_ACTID then
  236. PANELID_2_ACTID = { }
  237. for id, config in pairs(YunYingExcel.config) do
  238. if inServerIndex(config.serverIndex) then
  239. PANELID_2_ACTID[config.panelID] = id
  240. end
  241. end
  242. end
  243. return PANELID_2_ACTID[panelID]
  244. end
  245. function getOpenLvByPanelID(panelID)
  246. return PANELID2OPENLV[panelID] or 0
  247. end
  248. -- 是否开启活动,内部使用
  249. local function isBaseOpen(YYInfo, human)
  250. if not YYInfo then return end
  251. if human.db.lv < YYInfo.openLv then return end
  252. if not YYInfo.moduleList then return end
  253. for k, v in pairs(YYInfo.moduleList) do
  254. local funcConfig = getFuncConfig(k)
  255. if v.isOpen and v.isOpen(human, YYInfo, funcConfig) == true then
  256. return true
  257. end
  258. end
  259. end
  260. -- 未开放提示
  261. local function sendNoOpen(human, noSend)
  262. if noSend then return end
  263. Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
  264. end
  265. -- 是否开启
  266. function isOpen(YYInfo, human, noSend)
  267. if not YYInfo then
  268. return sendNoOpen(human, noSend)
  269. end
  270. if not isBaseOpen(YYInfo, human) then
  271. return sendNoOpen(human, noSend)
  272. end
  273. return true
  274. end
  275. -- 是否显示红点
  276. function isRed(YYInfo, human)
  277. if not YYInfo then return false end
  278. if not YYInfo.moduleList then return false end
  279. for k, v in pairs(YYInfo.moduleList) do
  280. local funcConfig = getFuncConfig(k)
  281. -- 开启了才判断红点
  282. if not v.isOpen or v.isOpen(human, YYInfo, funcConfig) == true then
  283. if v.isRed and v.isRed(human, YYInfo, funcConfig) == true then
  284. return true
  285. end
  286. end
  287. end
  288. return false
  289. end
  290. -- 获得图标 主要是节日活动和绝对时间活动每周的图标都不一样
  291. function getIcon(YYInfo, human)
  292. if not YYInfo then return false end
  293. if not YYInfo.moduleList then return false end
  294. if YYInfo.config.pos ~= YUNYING_POS_TYPE1 then return false end
  295. for k, v in pairs(YYInfo.moduleList) do
  296. local funcConfig = getFuncConfig(k)
  297. if v.getIcon then
  298. return v.getIcon(human, YYInfo, funcConfig)
  299. end
  300. end
  301. end
  302. -- 缓存红点
  303. function setCacheRed(human, yyID, red)
  304. human.yunyings[yyID] = red
  305. end
  306. --
  307. function getCacheRed(human, yyID)
  308. return human.yunyings and human.yunyings[yyID]
  309. end
  310. function getLeftTime(YYInfo, human)
  311. if not YYInfo then return 0 end
  312. if not YYInfo.moduleList then return 0 end
  313. local leftTime = 0
  314. for k, v in pairs(YYInfo.moduleList) do
  315. local funcConfig = getFuncConfig(k)
  316. if v.getLeftTime and funcConfig.actId ~= 0 then
  317. local rest = v.getLeftTime(human, YYInfo, funcConfig)
  318. leftTime = leftTime < rest and rest or leftTime
  319. end
  320. end
  321. return leftTime
  322. end
  323. -- 封装结构体
  324. local function fontIcon(net, YYInfo, human)
  325. local config = YYInfo.config
  326. local red = isRed(YYInfo, human)
  327. net.id = YYInfo.yyID
  328. net.red = red and 1 or 0
  329. net.leftTime = getLeftTime(YYInfo, human) or 0
  330. net.icon = getIcon(YYInfo, human)
  331. if net.icon == nil or net.icon == 0 then
  332. net.icon = config.icon
  333. end
  334. net.sortID = config.sortID
  335. net.panelID = config.panelID
  336. net.pos = config.pos or 0
  337. setCacheRed(human, YYInfo.yyID, red)
  338. end
  339. -- 运营活动列表
  340. function sendIcons(human)
  341. human.yunyings = { }
  342. local msgRet = Msg.gc.GC_YUNYING_LIST
  343. msgRet.list[0] = 0
  344. local maxLen = #msgRet.list
  345. for _, YYInfo in pairs(ID2YYInfo) do
  346. if isOpen(YYInfo, human, true) and
  347. YYInfo.config.pos == YUNYING_POS_TYPE1 then
  348. if msgRet.list[0] >= maxLen then
  349. break
  350. end
  351. msgRet.list[0] = msgRet.list[0] + 1
  352. fontIcon(msgRet.list[msgRet.list[0]], YYInfo, human)
  353. end
  354. end
  355. Msg.send(msgRet, human.fd)
  356. end
  357. -- 刷新图标
  358. function updateIcon(YYInfo, human, nocheckred)
  359. if not YYInfo then return end
  360. if YYInfo.config.pos ~= YUNYING_POS_TYPE1 then return end
  361. if isOpen(YYInfo, human, true) then
  362. if nocheckred or(getCacheRed(human, YYInfo.yyID) ~= isRed(YYInfo, human)) then
  363. sendIconUpdate(YYInfo.yyID, human)
  364. end
  365. else
  366. if nocheckred or getCacheRed(human, YYInfo.yyID) ~= nil then
  367. sendIconDel(YYInfo.yyID, human)
  368. end
  369. end
  370. end
  371. -- 添加或者改变
  372. function sendIconUpdate(yyID, human)
  373. if not human.yunyings then return end
  374. -- 未初始不发
  375. local YYInfo = ID2YYInfo[yyID]
  376. if not YYInfo then return end
  377. if YYInfo.config.pos ~= YUNYING_POS_TYPE1 then return end
  378. local msgRet = Msg.gc.GC_YUNYING_UPDATE
  379. if human then
  380. fontIcon(msgRet.data, YYInfo, human)
  381. Msg.send(msgRet, human.fd)
  382. else
  383. for _, human in pairs(ObjHuman.onlineUuid) do
  384. if human.fd then
  385. fontIcon(msgRet.data, YYInfo, human)
  386. Msg.send(msgRet, human.fd)
  387. end
  388. end
  389. end
  390. end
  391. -- 删除
  392. function sendIconDel(yyID, human)
  393. if not human.yunyings then return end
  394. -- 未初始不发
  395. local YYInfo = ID2YYInfo[yyID]
  396. if not YYInfo then return end
  397. if YYInfo.config.pos ~= YUNYING_POS_TYPE1 then return end
  398. local msgRet = Msg.gc.GC_YUNYING_DEL
  399. msgRet.id = yyID
  400. if human then
  401. Msg.send(msgRet, human.fd)
  402. setCacheRed(human, YYInfo.yyID)
  403. else
  404. for _, human in pairs(ObjHuman.onlineUuid) do
  405. if human.fd then
  406. Msg.send(msgRet, human.fd)
  407. setCacheRed(human, YYInfo.yyID)
  408. end
  409. end
  410. end
  411. end
  412. -- 活动组信息
  413. function sendGroupList(human, panelID)
  414. -- 获取panel运营ID
  415. local actID = getActIDByPanelID(panelID)
  416. if (not actID or actID < 1 ) and panelID ~= PanelDefine.PANEL_ID_3101 then
  417. return
  418. end
  419. -- 通过运营ID获取运营信息
  420. local YYInfo = ID2YYInfo[actID]
  421. if not isOpen(YYInfo, human, true) then
  422. print("============ panel not open ",panelID)
  423. return
  424. end
  425. local msgRet = Msg.gc.GC_YUNYING_GROUP_LIST
  426. msgRet.panelID = panelID
  427. msgRet.list[0] = 0
  428. for i = 1, #YYInfo.config.funcs do
  429. local funcID = YYInfo.config.funcs[i]
  430. local funcConfig = getFuncConfig(funcID)
  431. local state = false
  432. local endTime = nil
  433. local startTime = nil
  434. local leftTime = nil
  435. if human.db.lv >= funcConfig.openLv then
  436. if YYInfo.moduleList[funcID] ~= nil and
  437. YYInfo.moduleList[funcID].isOpen ~= nil then
  438. state, endTime, startTime = YYInfo.moduleList[funcID].isOpen(human, YYInfo, funcConfig)
  439. if endTime then
  440. leftTime = endTime - os.time()
  441. end
  442. else
  443. state = true
  444. end
  445. end
  446. if state then
  447. msgRet.list[0] = msgRet.list[0] + 1
  448. if YYInfo.moduleList[funcID] ~= nil and
  449. YYInfo.moduleList[funcID].getLeftTime ~= nil then
  450. leftTime = YYInfo.moduleList[funcID].getLeftTime(human, YYInfo, funcConfig)
  451. end
  452. local net = msgRet.list[msgRet.list[0]]
  453. net.id = funcID
  454. net.icon = funcConfig.icon
  455. net.red = 0
  456. net.leftTime = leftTime or 0
  457. net.endTime = endTime or 0
  458. net.startTime = startTime or 0
  459. net.name = funcConfig.actName or ""
  460. if YYInfo.moduleList[funcID] and YYInfo.moduleList[funcID].isRed and YYInfo.moduleList[funcID].isRed(human, YYInfo, funcConfig) == true then
  461. net.red = 1
  462. end
  463. net.panelID = funcConfig.panelID
  464. net.effect = funcConfig.effect
  465. net.param = funcID
  466. end
  467. end
  468. Msg.send(msgRet, human.fd)
  469. end
  470. -- 刷新标签页红点
  471. function sendGroupUpdate(YYInfo, human, subPanelID, param)
  472. if not YYInfo then print(" not YYInfo param ", param, " panelID ", subPanelID) return end
  473. local msgRet = Msg.gc.GC_YUNYING_GROUP_UPDATE
  474. msgRet.panelID = YYInfo.config.panelID
  475. local state = false
  476. local endTime = nil
  477. local startTime = nil
  478. local id = nil
  479. local len = 0
  480. for i = 1, #YYInfo.config.funcs do
  481. local funcID = YYInfo.config.funcs[i]
  482. local funcConfig = getFuncConfig(funcID)
  483. if (not param and funcConfig.panelID == subPanelID) or
  484. (param and funcConfig.param == param and funcConfig.panelID == subPanelID) then -- 同一个 面板的 多期活动
  485. if YYInfo.moduleList[funcID] ~= nil and
  486. YYInfo.moduleList[funcID].isOpen ~= nil then
  487. state, endTime, startTime = YYInfo.moduleList[funcID].isOpen(human, YYInfo, funcConfig)
  488. else
  489. state = true
  490. end
  491. if not state then return end
  492. local leftTime = nil
  493. if YYInfo.moduleList[funcID] ~= nil and
  494. YYInfo.moduleList[funcID].getLeftTime ~= nil then
  495. leftTime = YYInfo.moduleList[funcID].getLeftTime(human, YYInfo, funcConfig)
  496. end
  497. len = len + 1
  498. msgRet.data.id = funcID
  499. msgRet.data.icon = funcConfig.icon
  500. msgRet.data.name = funcConfig.actName or ""
  501. msgRet.data.red = 0
  502. msgRet.data.leftTime = leftTime or 0
  503. msgRet.data.endTime = endTime or 0
  504. msgRet.data.startTime = startTime or 0
  505. if YYInfo.moduleList[funcID] and YYInfo.moduleList[funcID].isRed and YYInfo.moduleList[funcID].isRed(human, YYInfo, funcConfig) == true then
  506. msgRet.data.red = 1
  507. end
  508. msgRet.data.panelID = funcConfig.panelID
  509. msgRet.data.effect = funcConfig.effect
  510. msgRet.data.param = funcID
  511. break
  512. end
  513. end
  514. if len == 0 then return end
  515. Msg.send(msgRet, human.fd)
  516. end
  517. -- 推送开放等级
  518. function sendOpenLv(human, panelID)
  519. local openLv = getOpenLvByPanelID(panelID)
  520. if not openLv then return end
  521. local msgRet = Msg.gc.GC_YUNYING_OPEN_LV
  522. msgRet.openLv = openLv
  523. msgRet.panelID = panelID
  524. Msg.send(msgRet, human.fd)
  525. end
  526. -- 一次性广告面板
  527. function sendFirstBanner(human)
  528. local funcID = YunYingDefine.YUNYING_ID_101
  529. local moduleFn = getYYFuncInfo(funcID)
  530. if not moduleFn then return end
  531. local funcConfig = YunYingExcel.func[funcID]
  532. if not funcConfig then return end
  533. if not moduleFn.isOpen(human, moduleFn.YYInfo[funcID], funcConfig) then return end
  534. local dialogLv = SysParameter.getSysParameter(SysParameter.PARAMETER_14)
  535. local firstPanel = nil
  536. if human.db.lv >= dialogLv then
  537. if human.db.guide.firstPanel == nil then
  538. firstPanel = PanelDefine.PANEL_ID_3302
  539. human.db.guide.firstPanel = 1
  540. end
  541. end
  542. if not firstPanel then return end
  543. local msgRet = Msg.gc.GC_YUNYING_FIRST_BANNER_QUERY
  544. msgRet.panelID = firstPanel
  545. Msg.send(msgRet, human.fd)
  546. end
  547. -- 广告面板
  548. local function bannerCmp(a, b)
  549. return a[2] < b[2]
  550. end
  551. local function makeBannerNet(net, bannerID, dot, banner)
  552. print("#### bannerID: ", bannerID)
  553. local config = BannerExcel.banner[bannerID]
  554. if not config then return end
  555. local jSonParam = {}
  556. net.icon = config.icon
  557. net.panelID = config.panelID
  558. local moduleFn = getYYFuncInfo(config.funcID[1])
  559. if moduleFn then
  560. jSonParam.yyID = moduleFn.yyID[config.funcID[1]]
  561. jSonParam.tsStart = banner[4]
  562. jSonParam.tsEnd = banner[5]
  563. jSonParam.leftTs = banner[6]
  564. jSonParam.ad = 0
  565. jSonParam.dot = dot
  566. jSonParam.param = banner[10]
  567. if moduleFn.makeBanner then
  568. moduleFn.makeBanner(jSonParam, banner[9])
  569. end
  570. local funcConfig = getFuncConfig(config.funcID[1])
  571. net.panelID = funcConfig.panelID
  572. end
  573. net.param = Json.Encode(jSonParam)
  574. end
  575. function sendBanner(human)
  576. local bannerList = { }
  577. local len = 0
  578. for k, _id in ipairs(BANNER_LIST_SERVER) do
  579. local config = BannerExcel.banner[_id]
  580. local lenth = #config.funcID
  581. local dot = nil
  582. for i = 1,lenth do
  583. local moduleFn = getYYFuncInfo(config.funcID[i])
  584. if moduleFn and inServerIndex(config.serverIndex) then
  585. local YYInfo = moduleFn.YYInfo[config.funcID[i]]
  586. local funcConfig = getFuncConfig(moduleFn.funcID[config.funcID[i]])
  587. local active = nil
  588. if moduleFn.isActive and
  589. not moduleFn.isActive(human, YYInfo, funcConfig) then
  590. if dot ~= true then
  591. dot = moduleFn.isRed and moduleFn.isRed(human, YYInfo, funcConfig)
  592. end
  593. end
  594. end
  595. end
  596. if _id == 4 or _id == 34 then
  597. dot = nil
  598. end
  599. local moduleFn = getYYFuncInfo(config.funcID[1])
  600. if moduleFn and inServerIndex(config.serverIndex) then
  601. local YYInfo = moduleFn.YYInfo[config.funcID[1]]
  602. local funcConfig = getFuncConfig(moduleFn.funcID[config.funcID[1]])
  603. local active = nil
  604. if moduleFn.isActive and
  605. not moduleFn.isActive(human, YYInfo, funcConfig) then
  606. local leftTime, endTime, startTime = 0
  607. local state = false
  608. if isAbsfunc(moduleFn.funcID[config.funcID[1]]) then
  609. state, endTime, startTime = moduleFn.isOpen(human, YYInfo, funcConfig)
  610. if state then
  611. leftTime = endTime - os.time()
  612. end
  613. end
  614. len = len + 1
  615. bannerList[len] = { _id, config.sortID, dot, startTime, endTime, leftTime, state, YYInfo.yyID, funcConfig.funcID, funcConfig.param }
  616. end
  617. end
  618. end
  619. local bannerID = 1
  620. local dot = 0
  621. local sortID = 0
  622. if len > 0 then
  623. table.sort(bannerList, bannerCmp)
  624. sortID = bannerList[1][2]
  625. end
  626. local msgRet = Msg.gc.GC_BANNER_QUERY
  627. local count = 0
  628. for i = 1,len do
  629. if bannerList[i][2] == sortID then
  630. count = count + 1
  631. bannerID = bannerList[i][1]
  632. if not bannerList[i][3] then
  633. dot = 0
  634. else
  635. dot = 1
  636. end
  637. makeBannerNet(msgRet.bannerList[count], bannerID, dot, bannerList[i])
  638. end
  639. if count >= 6 then
  640. break
  641. end
  642. end
  643. if count == 0 then
  644. count = count + 1
  645. bannerID = 1
  646. dot = 0
  647. makeBannerNet(msgRet.bannerList[count], bannerID, dot, bannerList[1])
  648. end
  649. msgRet.bannerList[0] = count
  650. Msg.send(msgRet, human.fd)
  651. end
  652. -- 登陆处理
  653. function onLogin(human)
  654. for yyID, YYInfo in pairs(ID2YYInfo) do
  655. for i = 1, #YYInfo.config.funcs do
  656. local funcID = YYInfo.config.funcs[i]
  657. if YYInfo.moduleList[funcID] and YYInfo.moduleList[funcID].onLogin then
  658. YYInfo.moduleList[funcID].onLogin(human, funcID)
  659. end
  660. end
  661. end
  662. sendIcons(human)
  663. sendBanner(human)
  664. sendFirstBanner(human)
  665. AbsActLogic.onLogin(human)
  666. end
  667. -- 隔天处理
  668. function updateDaily(human)
  669. for yyID, YYInfo in pairs(ID2YYInfo) do
  670. for i = 1, #YYInfo.config.funcs do
  671. local funcID = YYInfo.config.funcs[i]
  672. if YYInfo.moduleList[funcID] and YYInfo.moduleList[funcID].updateDaily then
  673. YYInfo.moduleList[funcID].updateDaily(human, funcID)
  674. end
  675. end
  676. updateIcon(YYInfo, human, true)
  677. end
  678. sendBanner(human)
  679. end
  680. -- 充值接口
  681. function onCharge(human, price, buyID)
  682. for yyID, YYInfo in pairs(ID2YYInfo) do
  683. for i = 1, #YYInfo.config.funcs do
  684. local funcID = YYInfo.config.funcs[i]
  685. if YYInfo.moduleList[funcID] and YYInfo.moduleList[funcID].onCharge then
  686. YYInfo.moduleList[funcID].onCharge(human, price, funcID, buyID)
  687. end
  688. end
  689. end
  690. sendBanner(human)
  691. end
  692. -- 0点
  693. function onZeroHuman(human)
  694. for yyID, YYInfo in pairs(ID2YYInfo) do
  695. for i = 1, #YYInfo.config.funcs do
  696. local funcID = YYInfo.config.funcs[i]
  697. if YYInfo.moduleList[funcID] and YYInfo.moduleList[funcID].onZero then
  698. YYInfo.moduleList[funcID].onZero(human, funcID)
  699. end
  700. end
  701. end
  702. sendIcons(human)
  703. end
  704. -- 0点
  705. function onZero()
  706. for yyID, YYInfo in pairs(ID2YYInfo) do
  707. for i = 1, #YYInfo.config.funcs do
  708. local funcID = YYInfo.config.funcs[i]
  709. if YYInfo.moduleList[funcID] and YYInfo.moduleList[funcID].onZeroAll then
  710. YYInfo.moduleList[funcID].onZeroAll(funcID)
  711. end
  712. end
  713. end
  714. handleAbs()
  715. end
  716. -- 升级回调
  717. function onLevelUp(human, oldLv, newLv)
  718. for yyID, YYInfo in pairs(ID2YYInfo) do
  719. for i = 1, #YYInfo.config.funcs do
  720. local funcID = YYInfo.config.funcs[i]
  721. if YYInfo.moduleList[funcID] and YYInfo.moduleList[funcID].onLevelUp then
  722. YYInfo.moduleList[funcID].onLevelUp(human, oldLv, newLv, funcID)
  723. end
  724. end
  725. end
  726. for yyID, YYInfo in pairs(ID2YYInfo) do
  727. if oldLv < YYInfo.openLv and YYInfo.openLv <= newLv then
  728. if isOpen(YYInfo, human, true) then
  729. sendIconUpdate(yyID, human)
  730. end
  731. end
  732. end
  733. end
  734. -- 购买礼包的回调
  735. function onBuy(human, buyConf, isFirst, cnt)
  736. for yyID, YYInfo in pairs(ID2YYInfo) do
  737. for i = 1, #YYInfo.config.funcs do
  738. local funcID = YYInfo.config.funcs[i]
  739. if YYInfo.moduleList[funcID] and YYInfo.moduleList[funcID][buyConf.cmd] then
  740. YYInfo.moduleList[funcID][buyConf.cmd](human, funcID, buyConf, isFirst, cnt)
  741. end
  742. end
  743. end
  744. end
  745. function CG_YUNYING_UPDATE(human, yyID)
  746. if not human.yunyings then return end
  747. -- 未初始不发
  748. local YYInfo = ID2YYInfo[yyID]
  749. if not YYInfo then return end
  750. updateIcon(YYInfo, human, true)
  751. end
  752. function onServerOpenTime()
  753. handleAbs()
  754. for _, human in pairs(ObjHuman.onlineUuid) do
  755. sendIcons(human)
  756. end
  757. end
  758. ---
  759. --各个模块回调
  760. function onCallBack(human, cmd, parameter, bNoSend, parameter2)
  761. for yyID, YYInfo in pairs(ID2YYInfo) do
  762. for i = 1, #YYInfo.config.funcs do
  763. local funcID = YYInfo.config.funcs[i]
  764. local funcConfig = getFuncConfig(funcID)
  765. if YYInfo.moduleList[funcID] and YYInfo.moduleList[funcID][cmd] then
  766. local isStart = true
  767. if isAbsfunc(funcID) then
  768. isStart = AbsActLogic.isStarted(human, funcID)
  769. end
  770. if isStart then
  771. local result = YYInfo.moduleList[funcID][cmd](human, funcID, parameter, parameter2)
  772. if result then
  773. updateIcon(YYInfo, human)
  774. sendGroupUpdate(YYInfo, human, funcConfig.panelID)
  775. end
  776. if bNoSend then
  777. return result
  778. end
  779. end
  780. end
  781. end
  782. end
  783. if bNoSend then
  784. return 0
  785. end
  786. end