Crédit automatique de points lorsqu'un défi a été réussi
This commit is contained in:
parent
8681752888
commit
a1b5fccc98
@ -1,7 +1,7 @@
|
|||||||
import { BadRequestException, Injectable, NotFoundException, UnprocessableEntityException } from '@nestjs/common'
|
import { BadRequestException, Injectable, NotFoundException } from '@nestjs/common'
|
||||||
import { CreateChallengeActionDto } from './dto/create-challenge-action.dto'
|
import { CreateChallengeActionDto } from './dto/create-challenge-action.dto'
|
||||||
import { UpdateChallengeActionDto } from './dto/update-challenge-action.dto'
|
import { UpdateChallengeActionDto } from './dto/update-challenge-action.dto'
|
||||||
import { ChallengeAction, Player } from '@prisma/client'
|
import { ChallengeAction, MoneyUpdateType, Player } from '@prisma/client'
|
||||||
import { PrismaService } from 'src/prisma/prisma.service'
|
import { PrismaService } from 'src/prisma/prisma.service'
|
||||||
import { QueryPaginationDto } from 'src/common/dto/pagination-query.dto'
|
import { QueryPaginationDto } from 'src/common/dto/pagination-query.dto'
|
||||||
import { paginate } from 'src/common/utils/pagination.utils'
|
import { paginate } from 'src/common/utils/pagination.utils'
|
||||||
@ -68,6 +68,17 @@ export class ChallengeActionsService {
|
|||||||
active: false,
|
active: false,
|
||||||
end: now,
|
end: now,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Crédit du nombre de points remportés grâce au défi
|
||||||
|
const challenge = await this.prisma.challenge.findUnique({ where: { id: challengeAction.challengeId } })
|
||||||
|
await this.prisma.moneyUpdate.create({
|
||||||
|
data: {
|
||||||
|
playerId: player.id,
|
||||||
|
amount: challenge.reward,
|
||||||
|
reason: MoneyUpdateType.WIN_CHALLENGE,
|
||||||
|
actionId: challengeAction.id,
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
data = {
|
data = {
|
||||||
|
Loading…
Reference in New Issue
Block a user