Commit 71a295eb authored by qinhaitao's avatar qinhaitao

fix: 🐛 follow task

parent e6b2c904
...@@ -121,14 +121,20 @@ export default class TaskService extends UserService { ...@@ -121,14 +121,20 @@ export default class TaskService extends UserService {
} = this.context } = this.context
const record = { itemId, openId: taskType === 'invites' ? openId : undefined, ...customRecord } const record = { itemId, openId: taskType === 'invites' ? openId : undefined, ...customRecord }
const result = await this.updateUser(userInfo._id, { let updateQuery: IUpdateQuery = {
$inc: { $inc: {
[`remainTimes.${taskType}`]: rewards [`remainTimes.${taskType}`]: rewards
}, },
$push: { $push: {
[`taskInfo.${today}.${taskType}`]: { ...record, createTime: Date.now() } [`taskInfo.${today}.${taskType}`]: { ...record, createTime: Date.now() }
} }
}) }
if (taskType === 'follow') {
updateQuery.$set = {
follow: setNewFollowUserData(userInfo.follow)
}
}
const result = await this.updateUser(userInfo._id, updateQuery)
return result ? { ok: 1 } : CODE_TYPES.ERROR_DO_TASK return result ? { ok: 1 } : CODE_TYPES.ERROR_DO_TASK
} }
......
...@@ -32,7 +32,11 @@ export function setNewVipUserData(member: IMemberInfo): IMemberInfo { ...@@ -32,7 +32,11 @@ export function setNewVipUserData(member: IMemberInfo): IMemberInfo {
} }
export function setNewFollowUserData(follow: IFollowInfo): IFollowInfo { export function setNewFollowUserData(follow: IFollowInfo): IFollowInfo {
const followBefore = follow.flag
const today = getToday() const today = getToday()
if (followBefore || follow.newFollow) {
return follow
}
return { return {
...follow, ...follow,
newFollow: true, newFollow: true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment