Commit 64737a39 authored by qinhaitao's avatar qinhaitao

fix: 🐛 bug

parent 4add8c34
...@@ -5,7 +5,7 @@ import { resultsModel } from '../sdk' ...@@ -5,7 +5,7 @@ import { resultsModel } from '../sdk'
import { CommonUserService, CommonStatService, CommonTaskService } from '../service/common' import { CommonUserService, CommonStatService, CommonTaskService } from '../service/common'
import { STAT_TYPE } from '../constants' import { STAT_TYPE } from '../constants'
import { checkActivityTime, checkInviteId, checkHelpRecord, checkNewVip } from '../utils/common/check' import { checkActivityTime, checkInviteId, checkHelpRecord, checkNewVip } from '../utils/common/check'
import { updateVip } from '../utils/common/update/' import { updateHelpRecord, updateVip } from '../utils/common/update/'
export default class Share { export default class Share {
/** /**
......
...@@ -87,6 +87,10 @@ export const BusinessError = { ...@@ -87,6 +87,10 @@ export const BusinessError = {
code: `430009`, code: `430009`,
defaultMsg: `只有新会员才能助力哦~` defaultMsg: `只有新会员才能助力哦~`
}, },
ERROR_INVITE_TIMES_LIMIT: {
code: `440001`,
defaultMsg: `今天分享者的助力名额已满,明天再来助力吧`
},
ERROR_DO_TASK: { ERROR_DO_TASK: {
code: `430010`, code: `430010`,
defaultMsg: `任务完成失败~` defaultMsg: `任务完成失败~`
......
...@@ -5,6 +5,7 @@ import { CODE_TYPES } from '../../../errorCode' ...@@ -5,6 +5,7 @@ import { CODE_TYPES } from '../../../errorCode'
import { dbFindOne } from '../../common/mongodb' import { dbFindOne } from '../../common/mongodb'
import { USER_DB_NAME } from '../../../db' import { USER_DB_NAME } from '../../../db'
import { getTodayCompleteTask } from '../task' import { getTodayCompleteTask } from '../task'
import { TASK_RATE_TYPE } from '../../../constants'
/** /**
* 检查inviteId是否合法 返回邀请人的用户信息 * 检查inviteId是否合法 返回邀请人的用户信息
...@@ -15,7 +16,7 @@ import { getTodayCompleteTask } from '../task' ...@@ -15,7 +16,7 @@ import { getTodayCompleteTask } from '../task'
*/ */
export default async function checkInviteId( export default async function checkInviteId(
context: IContext<{ activityId: string; inviteId: string }>, context: IContext<{ activityId: string; inviteId: string }>,
{}: IControllerInfos { activityInfo }: IControllerInfos
) { ) {
const { const {
openId, openId,
...@@ -34,8 +35,18 @@ export default async function checkInviteId( ...@@ -34,8 +35,18 @@ export default async function checkInviteId(
// inviteId的用户信息查询不到, 则inviteId无效 // inviteId的用户信息查询不到, 则inviteId无效
if (!inviteUserInfo) return resultsModel.error(CODE_TYPES.ERROR_INVALID_INVITE_ID) if (!inviteUserInfo) return resultsModel.error(CODE_TYPES.ERROR_INVALID_INVITE_ID)
const {
tasks: { invites }
} = activityInfo
const { taskRateType, times } = invites
const { todayCompleteTimes } = getTodayCompleteTask('invites', inviteUserInfo) const { todayCompleteTimes } = getTodayCompleteTask('invites', inviteUserInfo)
// 助力次数超限制
if (taskRateType === TASK_RATE_TYPE.EVERYDAY && todayCompleteTimes >= times) {
return resultsModel.error(CODE_TYPES.ERROR_INVITE_TIMES_LIMIT)
}
return { return {
inviteUserInfo inviteUserInfo
} }
......
...@@ -3,7 +3,7 @@ import updateVip from './updateVip' ...@@ -3,7 +3,7 @@ import updateVip from './updateVip'
import updateSignTask from './updateSignTask' import updateSignTask from './updateSignTask'
import updateOrderGoods from './updateOrderGoods' import updateOrderGoods from './updateOrderGoods'
import updateFirstLoginToday from './updateFirstLoginToday' import updateFirstLoginToday from './updateFirstLoginToday'
import updateUserInfo, { reduceGameTimes } from './updateUserInfo' import updateUserInfo, { reduceGameTimes, updateHelpRecord } from './updateUserInfo'
const update = { const update = {
updateVip, updateVip,
...@@ -11,7 +11,8 @@ const update = { ...@@ -11,7 +11,8 @@ const update = {
updateOrderGoods, updateOrderGoods,
updateFirstLoginToday, updateFirstLoginToday,
updateUserInfo, updateUserInfo,
reduceGameTimes reduceGameTimes,
updateHelpRecord
} }
export default update export default update
...@@ -22,5 +23,6 @@ export { ...@@ -22,5 +23,6 @@ export {
updateOrderGoods, updateOrderGoods,
updateFirstLoginToday, updateFirstLoginToday,
updateUserInfo, updateUserInfo,
reduceGameTimes reduceGameTimes,
updateHelpRecord
} }
...@@ -20,12 +20,16 @@ export function reduceGameTimes(needGameTimes: number) { ...@@ -20,12 +20,16 @@ export function reduceGameTimes(needGameTimes: number) {
}) })
} }
export function updateHelpRecord() { export async function updateHelpRecord(
return updateUserInfo({ context: IContext<IParams>,
$where: `!!this.inviteId`, { userInfo }: IControllerInfos
): Promise<IPreUpdateQuery | undefined> {
const { inviteId } = context.data
if (inviteId) return {}
if (!userInfo) return {}
return {
$set: { $set: {
inviteId
} }
}) }
} }
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