Commit 64737a39 authored by qinhaitao's avatar qinhaitao

fix: 🐛 bug

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