|
|
@@ -1764,6 +1764,31 @@ local function getWeekProgress(field)
|
|
|
return weekTotal
|
|
|
end
|
|
|
|
|
|
+-- 检查账号下是否有任何角色已领取指定游戏圈任务(账号级别判断)
|
|
|
+local function checkAccountYouxiTaskClaimed(account, taskId)
|
|
|
+ if not account then return false end
|
|
|
+ local config = YOUXI_TASK_CONFIG[taskId]
|
|
|
+ if not config then return false end
|
|
|
+ LuaMongo.find(DB.db_char, {account = account}, {zhuanpan = 1})
|
|
|
+ while true do
|
|
|
+ local data = {}
|
|
|
+ if not LuaMongo.next(data) then break end
|
|
|
+ local yt = data.zhuanpan and data.zhuanpan.youxiTask
|
|
|
+ if yt then
|
|
|
+ if config.taskType == "once" then
|
|
|
+ if yt.joinGetTime then return true end
|
|
|
+ elseif config.taskType == "daily" then
|
|
|
+ local field = (taskId == 2) and yt.dailyLike or yt.dailyComment
|
|
|
+ if field and field.getTime and Util.isSameDay(field.getTime) then return true end
|
|
|
+ elseif config.taskType == "weekly" then
|
|
|
+ local field = (taskId == 4) and yt.dailyLike or yt.dailyComment
|
|
|
+ if field and field.weekGetTime and isCurrentWeek(field.weekGetTime) then return true end
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
+ return false
|
|
|
+end
|
|
|
+
|
|
|
-- 游戏圈任务查询(前端上传 SDK 数据,后端存储并计算进度)
|
|
|
function youxiTaskQuery(human, msg)
|
|
|
local msgRet = Msg.gc.GC_ZHUANPAN_YOUXI_TASK_QUERY
|
|
|
@@ -1802,7 +1827,8 @@ function youxiTaskQuery(human, msg)
|
|
|
|
|
|
if config.taskType == "once" then
|
|
|
taskData.progress = yt.joined and 1 or 0
|
|
|
- if yt.joinGetTime then
|
|
|
+ local claimed = yt.joinGetTime or checkAccountYouxiTaskClaimed(human.db.account, taskId)
|
|
|
+ if claimed then
|
|
|
taskData.status = 2
|
|
|
elseif yt.joined then
|
|
|
taskData.status = 1
|
|
|
@@ -1815,7 +1841,8 @@ function youxiTaskQuery(human, msg)
|
|
|
local dayCount = (field and field.dayTime and Util.isSameDay(field.dayTime)) and (field.count or 0) or 0
|
|
|
taskData.progress = math.min(dayCount, config.target)
|
|
|
local getTime = field and field.getTime
|
|
|
- if getTime and Util.isSameDay(getTime) then
|
|
|
+ local claimed = (getTime and Util.isSameDay(getTime)) or checkAccountYouxiTaskClaimed(human.db.account, taskId)
|
|
|
+ if claimed then
|
|
|
taskData.status = 2
|
|
|
elseif dayCount >= config.target then
|
|
|
taskData.status = 1
|
|
|
@@ -1828,7 +1855,8 @@ function youxiTaskQuery(human, msg)
|
|
|
local weekCount = getWeekProgress(field)
|
|
|
taskData.progress = math.min(weekCount, config.target)
|
|
|
local weekGetTime = field and field.weekGetTime
|
|
|
- if weekGetTime and isCurrentWeek(weekGetTime) then
|
|
|
+ local claimed = (weekGetTime and isCurrentWeek(weekGetTime)) or checkAccountYouxiTaskClaimed(human.db.account, taskId)
|
|
|
+ if claimed then
|
|
|
taskData.status = 2
|
|
|
elseif weekCount >= config.target then
|
|
|
taskData.status = 1
|
|
|
@@ -1864,9 +1892,12 @@ function youxiTaskGetReward(human, taskId)
|
|
|
local yt = human.db.zhuanpan.youxiTask
|
|
|
local now = os.time()
|
|
|
|
|
|
- -- 校验条件 & 重复领取
|
|
|
+ -- 校验条件 & 重复领取(账号级别判断,同账号多角色共享)
|
|
|
+ -- 先查当前角色内存,没有再查 DB 其他角色(与美团订阅奖励模式一致)
|
|
|
+ local account = human.db.account
|
|
|
if config.taskType == "once" then
|
|
|
- if yt.joinGetTime then
|
|
|
+ local claimed = yt.joinGetTime or checkAccountYouxiTaskClaimed(account, taskId)
|
|
|
+ if claimed then
|
|
|
return Broadcast.sendErr(human, "已领取过")
|
|
|
end
|
|
|
if not yt.joined then
|
|
|
@@ -1875,7 +1906,9 @@ function youxiTaskGetReward(human, taskId)
|
|
|
|
|
|
elseif config.taskType == "daily" then
|
|
|
local field = (taskId == 2) and yt.dailyLike or yt.dailyComment
|
|
|
- if field and field.getTime and Util.isSameDay(field.getTime) then
|
|
|
+ local getTime = field and field.getTime
|
|
|
+ local claimed = (getTime and Util.isSameDay(getTime)) or checkAccountYouxiTaskClaimed(account, taskId)
|
|
|
+ if claimed then
|
|
|
return Broadcast.sendErr(human, "今日已领取")
|
|
|
end
|
|
|
local dayCount = (field and field.dayTime and Util.isSameDay(field.dayTime)) and (field.count or 0) or 0
|
|
|
@@ -1885,7 +1918,9 @@ function youxiTaskGetReward(human, taskId)
|
|
|
|
|
|
elseif config.taskType == "weekly" then
|
|
|
local field = (taskId == 4) and yt.dailyLike or yt.dailyComment
|
|
|
- if field and field.weekGetTime and isCurrentWeek(field.weekGetTime) then
|
|
|
+ local weekGetTime = field and field.weekGetTime
|
|
|
+ local claimed = (weekGetTime and isCurrentWeek(weekGetTime)) or checkAccountYouxiTaskClaimed(account, taskId)
|
|
|
+ if claimed then
|
|
|
return Broadcast.sendErr(human, "本周已领取")
|
|
|
end
|
|
|
if getWeekProgress(field) < config.target then
|