SCFC 1 год назад
Родитель
Сommit
693bb3701d

+ 4 - 3
script/common/ProtoID.lua

@@ -1322,8 +1322,9 @@ _ENV[1352]="CG_DBQB_TIPS"
 _ENV[1353]="GC_DBQB_TIPS"
 _ENV[1354]="CG_DRAWCARD_GET_RECOMMEND_LINEUP"
 _ENV[1355]="GC_DRAWCARD_GET_RECOMMEND_LINEUP"
+_ENV[1356]="CG_NEW_FIRST_CHARGE_QUERY"
+_ENV[1357]="GC_NEW_FIRST_CHARGE_QUERY"
+_ENV[1358]="CG_NEW_FIRST_CHARGE_GET"
 _ENV[1360]="CG_ONLINEAWARD_QUERY"
 _ENV[1361]="GC_ONLINEAWARD_QUERY"
-_ENV[1362]="CG_ONLINEAWARD_CLAIM"
-
-
+_ENV[1362]="CG_ONLINEAWARD_CLAIM"

+ 5 - 1
script/module/present/FirstChargeLogic.lua

@@ -28,8 +28,10 @@ STATE_CAT_GET = 1       -- 可领
 STATE_HAD_GET = 2       -- 已领
 
 function isOpenByType(human,giftType)
+    -- 老首充只有数据才显示true了
     if not human.db.firstCharge or not human.db.firstCharge[giftType] then 
-        return true
+        -- return true
+        return
     end
 
     for id,config in ipairs(PresentExcel.firstCharge) do
@@ -108,6 +110,8 @@ function sendQuery(human,giftType)
 end
 
 function getItems(human, type)
+
+    -- EquipLogic.addByEquipGrid(human, equipGrid, "battle", true)
     ObjHuman.updateDaily(human)
 
     -- 领取奖励

+ 10 - 1
script/module/present/Handler.lua

@@ -35,6 +35,7 @@ local RichangLibaoLogic = require("present.RichangLibaoLogic")
 local OpenServerActPowerUp = require("present.OpenServerActPowerUp")
 local OpenServerActAddUpCharge = require("present.OpenServerActAddUpCharge")
 local OnlineAwardLogic = require("present.OnlineAwardLogic")
+local NewFirstCharge = require("present.NewFirstChargeLogic")
 
 -- 充值-特权商店
 function CG_TEQUANSHOP_QUERY(human)
@@ -359,7 +360,6 @@ function CG_PRESENT_OPEN_ADDUP_CHARGE_GETPRIZE(human, msg)
     OpenServerActAddUpCharge.ActAddUpCharge_GetPrize(human, msg.nID)
 end
 
-
 -------------------------------在线奖励活动----------------------------------
 function CG_ONLINEAWARD_QUERY(human, msg)
     OnlineAwardLogic.Query(human)
@@ -368,4 +368,13 @@ end
 --领奖
 function CG_ONLINEAWARD_CLAIM(human, msg)
     OnlineAwardLogic.ClaimAward(human)
+end
+
+----- 新首充
+function CG_NEW_FIRST_CHARGE_QUERY(human, msg)
+    NewFirstCharge.NewFirstCharge_Query(human, msg.nType)
+end
+
+function CG_NEW_FIRST_CHARGE_GET(human, msg)
+    NewFirstCharge.NewFirstCharge_Get(human, msg.nType)
 end

+ 380 - 0
script/module/present/NewFirstChargeLogic.lua

@@ -0,0 +1,380 @@
+-----------------------------------------------------------------
+-- 文件名       :  NewFirstChargeLogic.lua
+-- 文件说明     :  新首充
+-- 创建时间     :   2025/1/22
+-- 创建人       :   FC
+-----------------------------------------------------------
+
+local Msg = require("core.Msg")
+local Util = require("common.Util")
+local PresentExcel = require("excel.present")
+local Grid = require("bag.Grid")
+local BagLogic = require("bag.BagLogic")
+local Broadcast = require("broadcast.Broadcast")
+local PanelDefine = require("broadcast.PanelDefine")
+local ChatPaoMaLogic = require("chat.ChatPaoMaLogic")
+local YunYingLogic = require("yunying.YunYingLogic")
+local SceneHandler = require("scene.Handler")
+local ObjHuman = require("core.ObjHuman")
+
+local NEWFIRST_CHARGE_TYPE1 = 1         -- 1元
+local NEWFIRST_CHARGE_TYPE2 = 2         -- 8元
+local NEWFIRST_CHARGE_TYPE3 = 3         -- 18元
+
+local tMoneyToType = 
+{
+    [1] = NEWFIRST_CHARGE_TYPE1,
+    [8] = NEWFIRST_CHARGE_TYPE2,
+    [18] = NEWFIRST_CHARGE_TYPE3,
+}
+
+local NEWFIRST_DAY = 3          -- 奖励天数,策划也没配置,直接写死吧
+local OPENBATTLEID = 12         -- 主线12关
+
+-- 状态
+NEWFIRST_STATE_CANT_GET = 0      -- 不可领
+NEWFIRST_STATE_CAT_GET = 1       -- 可领
+NEWFIRST_STATE_HAD_GET = 2       -- 已领
+
+local tNewFirstChargeCof = nil      -- 配置 Key = nBuyID
+local tPrizeDataByTypeDay = nil     -- 具体奖励配置 [nType] = {[nDay] = v}
+
+local function getNeedList()
+    if not tNewFirstChargeCof then
+        tNewFirstChargeCof = {}
+
+        for nID, v in pairs(PresentExcel.newfirstCharge) do
+            local nBuyID = v.nBuyID
+            tNewFirstChargeCof[nBuyID] = v
+            if tMoneyToType[v.nMoney] then
+                tNewFirstChargeCof.nType = tMoneyToType[v.nMoney]
+            else
+                print("[getNeedList] 配置了不正确的金额 nMoney = "..v.nMoney.." nID = "..nID)
+            end
+        end
+    end
+
+    if not tPrizeDataByTypeDay then
+        tPrizeDataByTypeDay = {}
+
+        for nID, v in pairs(tNewFirstChargeCof) do
+            local nType = v.nType
+            tPrizeDataByTypeDay[nType] = {}
+            for i = 1, NEWFIRST_DAY, 1 do
+                local tItem = i == 1 and v.tPrize1 or ( i == 2 and v.tPrize2 or v.tPrize3)
+                tPrizeDataByTypeDay[nType][i] = tItem
+            end
+        end
+    end
+
+    return tNewFirstChargeCof, tPrizeDataByTypeDay
+end
+
+-- 初始化对应类型的DB类型数据
+local function NewFirstCharge_InitDBByType(human, nType)
+    if not human.db.newFirstCharge then
+        human.db.newFirstCharge = {}
+    end
+
+    human.db.newFirstCharge[nType] = 
+    {
+        nBuyTime = 0,
+        nSatus = NEWFIRST_STATE_CANT_GET,
+        tDayStatus = {},
+    }
+
+    for i = 1, NEWFIRST_DAY, 1 do
+        human.db.newFirstCharge[nType].tDayStatus[i] = NEWFIRST_STATE_CANT_GET
+    end
+end
+
+-- 创建DB数据
+local function NewFirstCharge_CreateDB(human)
+    if not human then
+        return
+    end
+
+    if not human.db.newFirstCharge then
+        human.db.newFirstCharge = {}
+    end
+
+    for i = NEWFIRST_CHARGE_TYPE1, NEWFIRST_CHARGE_TYPE3, 1 do
+        if not human.db.newFirstCharge[i] then
+            NewFirstCharge_InitDBByType(human, i)
+        end
+    end
+end
+
+-- 设置对应天数领取了奖励
+local function NewFirstCharge_SetPrizeStauts(human, nType, nDay, nValue)
+    if not human.db.newFirstCharge or not human.db.newFirstCharge[nType] then
+        return
+    end
+
+    human.db.newFirstCharge[nType].tDayStatus[nDay] = nValue
+end
+
+-- 获取对应类型对应天数奖励状态
+local function NewFirstCharge_GetPrizeStauts(human, nType, nDay)
+    if not human.db.newFirstCharge or not human.db.newFirstCharge[nType] then
+        return NEWFIRST_STATE_CANT_GET
+    end
+
+    return human.db.newFirstCharge[nType].tDayStatus[nDay]
+end
+
+-- 设置购买状态
+local function NewFirstCharge_SetBuyStatus(human, nType)
+    if not human.db.newFirstCharge then
+        NewFirstCharge_InitDBByType(human, nType)
+    end
+
+    human.db.newFirstCharge[nType].nBuyTime = os.time()
+    human.db.newFirstCharge[nType].nSatus = NEWFIRST_STATE_HAD_GET
+    NewFirstCharge_SetPrizeStauts(human, 1, NEWFIRST_STATE_CAT_GET)
+end
+
+-- 获取购买状态
+local function NewFirstCharge_GetBuyStatus(human, nType)
+    if not human.db.newFirstCharge then
+        NewFirstCharge_InitDBByType(human, nType)
+    end
+
+    return human.db.newFirstCharge[nType].nSatus
+end
+
+-- 设置时间
+local function NewFirstCharge_SetTime(human, nType, nTime)
+    if not human.db.newFirstCharge then
+        NewFirstCharge_InitDBByType(human, nType)
+    end
+
+    human.db.newFirstCharge[nType].nBuyTime = nTime
+end
+
+-- 获取时间
+local function NewFirstCharge_GetTime(human, nType)
+    if not human.db.newFirstCharge then
+        NewFirstCharge_InitDBByType(human, nType)
+    end
+
+    return human.db.newFirstCharge[nType].nBuyTime
+end
+
+local function isOpenByType(human,giftType)
+    if not human.db.newfirstCharge or not human.db.newfirstCharge[giftType] then 
+        return true
+    end
+
+    -- 未购买,显示
+    if NEWFIRST_STATE_CANT_GET == human.db.newfirstCharge[giftType].nSatus then
+        return true
+    end
+
+    -- 购买了
+    for nDay = 1, NEWFIRST_DAY, 1 do
+       local nDayStatus = NewFirstCharge_GetPrizeStauts(human, giftType, nDay)
+
+       -- 只要没领取,都是开启的
+       if NEWFIRST_STATE_HAD_GET ~= nDayStatus then
+            return true
+       end
+    end
+
+    return false
+end
+
+-- 根据类型判断是否有红点
+local function isRedByType(human, giftType)
+    if not human.db.newfirstCharge or not human.db.newfirstCharge[giftType] then 
+        return false
+    end
+
+    -- 未购买
+    if NEWFIRST_STATE_CANT_GET == human.db.newfirstCharge[giftType].nSatus then
+        return false
+    end
+
+    for i = 1, NEWFIRST_DAY,  1  do
+        local nDayStatus = NewFirstCharge_GetPrizeStauts(human, giftType, i)
+        if NEWFIRST_STATE_CAT_GET == nDayStatus then
+            return true
+        end
+    end
+
+    return false
+end
+
+function isOpen(human,YYInfo,funcConfig)
+	if not SceneHandler.canCharge(human) then
+		return false
+	end
+
+    if not human.db.battleID then
+        return false
+    end
+
+    if OPENBATTLEID < human.db.battleID  then
+        return false
+    end
+
+    for i = NEWFIRST_CHARGE_TYPE1, NEWFIRST_CHARGE_TYPE3, 1 do
+        if true == isOpenByType(human,i) then
+           return true
+        end
+    end
+   
+    return false
+end
+
+function isRed(human,YYInfo,funcConfig)
+    for i = NEWFIRST_CHARGE_TYPE1, NEWFIRST_CHARGE_TYPE3, 1 do
+        if true == isRedByType(human,i) then
+           return true
+        end
+    end
+
+    return false
+end
+
+function NewFirstCharge_Query(human, nType)
+    local tAllConf, tItemConfByType = getNeedList()
+    local tTypeConf = nil
+    for _, v in pairs(tAllConf) do
+        if v.nType == nType then
+            tTypeConf = v
+            break
+        end
+    end
+
+    if not tTypeConf then
+        print("[NewFirstCharge_Query] 不存在对应类型的配置 nType = "..nType)
+        return
+    end
+
+    if not human.db.newFirstCharge then
+        NewFirstCharge_CreateDB(human)
+    end
+
+    local tMsgData = Msg.gc.GC_NEW_FIRST_CHARGE_QUERY
+    tMsgData.nType = nType
+    tMsgData.nState = NewFirstCharge_GetBuyStatus(human, nType)
+    tMsgData.nMoney = tTypeConf.nMoney
+
+    tMsgData.list[0] = 0
+    for i = 1, NEWFIRST_DAY, 1 do
+        tMsgData.list[0] = tMsgData.list[0] + 1
+        local tNodeData =  tMsgData.list[tMsgData.list[0]]
+        tNodeData.nState = NewFirstCharge_GetPrizeStauts(human, nType, i)
+        tNodeData.nDay = i
+        tNodeData.item[0] = 0
+
+        local tItemConf = tItemConfByType[nType][i]
+
+        if not tItemConf then
+            print("[NewFirstCharge_Query] 居然不存在对应的奖励配置")
+        else
+            for _, v in ipairs(tItemConf) do
+                tNodeData.item[0] = tNodeData.item[0] + 1
+
+                Grid.makeItem(tNodeData.item[tNodeData.item[0]], v[1], v[2])
+                if v[3] then
+                    tNodeData.item[tNodeData.item[0]].rare = v[3]
+                end
+            end
+        end
+    end
+
+    Msg.send(tMsgData, human.fd)
+end
+
+function NewFirstCharge_Get(human, nType)
+    local tAllConf, tItemConfByType = getNeedList()
+    local tTypeConf = nil
+    for _, v in pairs(tAllConf) do
+        if v.nType == nType then
+            tTypeConf = v
+            break
+        end
+    end
+
+    if not tTypeConf or not tItemConfByType[nType] then
+        print("[NewFirstCharge_Get] 不存在对应类型的配置 nType = "..nType)
+        return
+    end
+
+    local tItems = {}
+    for nDay, value in pairs(tItemConfByType[nType]) do
+        local nStatus = NewFirstCharge_GetPrizeStauts(human, nType, nDay)
+        if NEWFIRST_STATE_CAT_GET == nStatus then
+            for _, v in pairs(value) do
+                table.insert(tItems, v)
+            end
+
+            NewFirstCharge_SetPrizeStauts(human, nType, nDay, NEWFIRST_STATE_HAD_GET)
+        end
+    end
+
+    if nil ~= _G.next(tItems) then
+        BagLogic.addItemList(human, tItems, "shouchong")
+
+       for k, v in pairs(funcID) do
+          YunYingLogic.updateIcon(YYInfo[k], human)
+          YunYingLogic.sendGroupUpdate(YYInfo[k], human, PanelDefine.PANEL_ID_3302)
+          break
+       end
+
+       NewFirstCharge_Query(human, type)
+    end
+end
+
+-- 充值回调
+function onCharge(human, nBuyID)
+    local tConfByBuyid = getNeedList()
+    local isChange = false
+    if tConfByBuyid[nBuyID] then
+        NewFirstCharge_SetBuyStatus(human, tConfByBuyid[nBuyID].nType)
+    else
+        print("[onCharge] 不存在对应的礼包id nBuyID = "..nBuyID)
+        return
+    end
+
+    if isChange then
+        for k, v in pairs(funcID) do
+            print("[NewFirstChargeLogic - onCharge], k = "..k)
+            YunYingLogic.updateIcon(YYInfo[k], human)
+            break
+        end
+    end
+end
+
+function updateDaily(human, funcID)
+    if human.db.newfirstCharge then
+        local nNowTime = os.time()
+        for i = NEWFIRST_CHARGE_TYPE1, NEWFIRST_CHARGE_TYPE3, 1 do
+            local nBuyStatus = NewFirstCharge_GetBuyStatus(human, i)
+            local nLastTime = NewFirstCharge_GetTime(human)
+            local bIsDay = Util.isSameDayByTimes(nNowTime, nLastTime)
+            
+            -- 遍历该类型全部天数
+            if NEWFIRST_STATE_HAD_GET == nBuyStatus and true ~= bIsDay then
+                for nDay = 1, NEWFIRST_DAY, 1 do
+                    local nDayStatus = NewFirstCharge_GetPrizeStauts(human, i, nDay)
+                    -- 当天奖励未领取
+                    if NEWFIRST_STATE_CANT_GET == nDayStatus then
+                        NewFirstCharge_SetPrizeStauts(human, i, nDay, NEWFIRST_STATE_CAT_GET)
+                        NewFirstCharge_SetTime(human, i, nNowTime)
+                        print("[NewFirstChargeLogic - updateDaily] 隔天刷新 奖励 nType = "..i.." nDay = "..nDay)
+                        break
+                    end
+                end
+            end
+        end
+    end
+end
+
+
+-- 是否已激活首充
+function isActive(human, YYInfo, funcConfig)
+    return not isOpen(human, YYInfo, funcConfig)
+end

+ 29 - 2
script/module/present/Proto.lua

@@ -969,8 +969,6 @@ GC_PRESEN_OPEN_ADDUP_CHARGE_QUERY =
 CG_PRESENT_OPEN_ADDUP_CHARGE_GETPRIZE = {
     {"nID",             1,      "int"},         -- 领取奖励ID
 }
-
-
 ---------------------------在线奖励-------------------------
 SINGLE_AWARD_INFO = {
     {"itemInfo",       1,  ItemData},
@@ -993,3 +991,32 @@ GC_ONLINEAWARD_QUERY = {
 --领取
 CG_ONLINEAWARD_CLAIM = {
 }
+
+--------------------------------------------- 新首充
+NewFirstChargePrize = 
+{
+    {"nDay",        1,          "int"},
+    {"nState",      1,          "int"},     -- 0  不可领, 1可领, 2 已领
+    {"item",        5,          ItemData},
+}
+
+-- 请求礼包信息
+CG_NEW_FIRST_CHARGE_QUERY = 
+{
+    {"nType",       1,      "int"},             -- 请求类型(1:一元,2:8元,3:18元)
+}
+
+-- 请求礼包信息-回包
+GC_NEW_FIRST_CHARGE_QUERY = 
+{
+    {"nType",       1,      "int"}, 
+    {"nState",      1,      "byte"},            -- 是否购买(0 未购买,2 已购买)
+    {"nMoney",      1,      "int"},
+    {"list",        4,      NewFirstChargePrize},
+}
+
+-- 请求领取礼包
+CG_NEW_FIRST_CHARGE_GET = 
+{
+    {"nType",       1,      "int"},             -- 请求类型(1:一元,2:8元,3:18元)
+}

+ 2 - 1
script/module/role/RoleDBLogic.lua

@@ -285,6 +285,7 @@ function createDefaultRole(account)
 		topupAcountDaily = nil,					-- 玩家每日充值总额
 		topupAccountMonth = nil,				-- 玩家每月充值总额
         firstCharge = nil,        	           	-- 超值首充 6元 100元
+		newFirstCharge = nil,					-- 新首充
 		godDailyTopup = nil,                    -- 成神之路每日礼包
 		kingworld = nil,                        -- 国王君临       
        	superFund = nil, 						-- 超值基金 大小基金 [type] = {}
@@ -425,7 +426,7 @@ function createDefaultRole(account)
 		nFirstBuy = nil,						--第一次购买
 		talismanData = nil,						--秘宝
 		OnlineRewardData = nil,					--在线奖励
-
+		
         mergeInfo = {},   --融合信息 {mergeStartTime: 0 , mergeTime: 0, mergeEndTime: 0, heroId: 0}
 		gift = {
 			unlock = {},

+ 6 - 0
script/module/topup/BuyLogic.lua

@@ -43,6 +43,7 @@ local GiftExcel = require("excel.buy").gift
 local GiftLogic = require("topup.GiftLogic")
 local MaiDianDefine = require("MaiDian.MaiDianDefine")
 local MainDianLogic = require("MaiDian.MaiDianLogic")
+local NewFirstCharge = require("present.NewFirstChargeLogic")
 
 BUY_CODE_NORMAL = 0   -- 正常调平台的充值接口
 BUY_CODE_WX_KEFU = 1  -- 微信小程序客服充值接口
@@ -258,6 +259,11 @@ function cmd.warOrder(human,buyConf)
 	end
 end
 
+function cmd.newfirstCharge(human, buyConf, isFirst, buyCnt)
+	local nBuyID = buyConf.id
+	NewFirstCharge.onCharge(human, nBuyID)
+end
+
 -------------------------------- cmd结束 ----------------------------------
 
 function checkBuy(human, ret)