Commit 4add8c34 authored by qinhaitao's avatar qinhaitao

feat: 🎸 助力流程

parent aa81cb1c
......@@ -108,30 +108,6 @@ export enum STAT_TYPE {
INITE_SUCCESS
}
// 集卡阶梯奖励状态
export enum CARD_PRIZE_STATUS {
LOCK = 1,
UN_LOCK,
SUCCESS
}
// 免费次数赠送类型
export enum FREE_TYPE {
FOERVER = 1,
EVERY_DAY = 2
}
// 功能开启状态
export enum FEATURE_OPEN_STATUS {
CLOSE = 1,
OPEN = 2
}
// 赠送卡片是否开启
export const GIFT_CARD_STATUS = FEATURE_OPEN_STATUS.OPEN
// 任务模块是否开启
export const TASK_OPEN_STATUS = FEATURE_OPEN_STATUS.OPEN
// 每次参与消耗次数
export const JOIN_NEED_TIMES = 1
......
/** @format */
import { GIFT_CARD_STATUS, JOIN_NEED_TIMES, PRIZE_DATA_TYPE, TASK_OPEN_STATUS } from '../constants'
import { services, checkParams, preCheck, preUpdate } from '../decorator/common'
import { CODE_TYPES } from '../errorCode'
import { resultsModel } from '../sdk'
import { CommonCardService, CommonAwardsService } from '../service/common'
import { getToday } from '../utils'
import { checkActivityTime, checkUserInfo, checkVip, checkInviteId, checkInviteUserCard } from '../utils/common/check'
import checkCardGameTimes from '../utils/common/check/checkCardGameTimes'
import { reduceCardGameTimes, updateUserInfo } from '../utils/common/update'
export interface ISumitGameControllerInfos extends IControllerInfos {
joinInfo: IJoinRecord
}
export default class Card {
@checkParams(['activityId'])
@services([CommonCardService, CommonAwardsService])
async getCollectCardInfo(
context: IContext<IParams>,
{ userInfo }: IControllerInfos,
[cardService]: [CommonCardService, CommonAwardsService]
) {
const { activityId } = context.data
const { joinedTimes, gameTimes, gameTimesEverday } = userInfo
const myCardInfo = cardService.getMyCardInfo(userInfo)
const joinedTimesPrizeList = await cardService.getCardPrizeList(
activityId,
PRIZE_DATA_TYPE.JOIN_TIMES,
'needTimes',
joinedTimes
)
const collectedCardTypePrizeList = await cardService.getCardPrizeList(
activityId,
PRIZE_DATA_TYPE.CARD_TYPE_AWARD,
'needCards',
myCardInfo.cardTypeCollectedCount
)
const today = getToday()
return resultsModel.success({
joinedTimes,
gameTimes: gameTimes + (gameTimesEverday?.[today] || 0),
giftCardStatus: GIFT_CARD_STATUS,
taskOpenStatus: TASK_OPEN_STATUS,
...myCardInfo,
joinedTimesPrizeList,
collectedCardTypePrizeList
})
}
@checkParams(['activityId'])
@services([CommonCardService])
@preCheck([checkActivityTime, checkVip, checkCardGameTimes])
@preUpdate([reduceCardGameTimes(JOIN_NEED_TIMES)])
async doJoin(context: IContext<IParams>, { userInfo }: IControllerInfos, [cardService]: [CommonCardService]) {
const { activityId } = context.data
const cardResult = await cardService.collectCard(activityId, userInfo)
await cardService.addCollectRecord(userInfo, cardResult)
return resultsModel.success(cardResult)
}
// 获取中奖轮播
@checkParams(['activityId'])
@services([CommonCardService, CommonAwardsService])
async getAwardsCarouselList(
context: IContext<IParams>,
{ userInfo, activityInfo }: IControllerInfos,
[cardService, awardsService]: [CommonCardService, CommonAwardsService]
) {
const { activityId } = context.data
const list = await cardService.getAwardsCarouselList(activityId)
return resultsModel.success({
list
})
}
// 我的卡牌详情
@checkParams(['activityId'])
@services([CommonCardService, CommonAwardsService])
async getMyCardsInfo(context: IContext<IParams>, { userInfo }: IControllerInfos, [cardService]: [CommonCardService]) {
const { activityId } = context.data
const list = await cardService.getMyCardsInfo(activityId, userInfo)
return resultsModel.success({
list
})
}
// 获取好友赠送卡片
@checkParams(['activityId', 'type', 'inviteId'])
@services([CommonCardService, CommonAwardsService])
@preCheck([checkActivityTime, checkInviteId, checkInviteUserCard])
async getGiftCard(
context: IContext<IParams>,
{ userInfo }: IControllerInfos,
[cardService]: [CommonCardService],
{ inviteUserInfo }: IPreCheckData
) {
const { activityId, type } = context.data
const giftResult = await cardService.getGiftCard(activityId, type, userInfo, inviteUserInfo)
return resultsModel.success(giftResult)
}
}
......@@ -25,7 +25,7 @@ export default class Share {
@registeInfos(['vipInfo'])
@services([CommonTaskService, CommonStatService])
@preCheck([checkActivityTime, checkInviteId, checkNewVip, checkHelpRecord])
@preUpdate([updateVip])
@preUpdate([updateVip, updateHelpRecord])
async doHelp(
context: IContext<IParams>,
{ userInfo, activityInfo }: IControllerInfos,
......@@ -34,7 +34,7 @@ export default class Share {
) {
const result = await taskService.completeTask('invites', activityInfo, inviteUserInfo)
await statService.addStat(STAT_TYPE.INITE_SUCCESS, userInfo)
statService.addStat(STAT_TYPE.INITE_SUCCESS, userInfo)
return resultsModel.success(result)
}
......
/** @format */
import { FREE_TYPE } from './constants'
import { getToday } from './utils'
// login初始化用户信息
export const initCustomUserWhenLogin = (context: IContext<IParams>, activityInfo: IActivityInfo): ICustomUserInfo => {
const { freeTimes, freeType } = activityInfo?.collectCardConfig || {}
return {
gameTimes: freeType === FREE_TYPE.FOERVER ? freeTimes : 0,
gameTimesEverday: {
[getToday()]: freeType === FREE_TYPE.EVERY_DAY ? freeTimes : 0
},
joinedTimes: 0,
cardsCollectedCount: 0,
cardInfo: {}
gameTimes: 0
}
}
......@@ -22,7 +14,6 @@ export const updateUserWhenLogin = (
activityInfo: IActivityInfo,
userInfo: IUserInfo
): IUpdateQuery => {
const { freeTimes, freeType } = activityInfo?.collectCardConfig || {}
const today = getToday()
let projection: IUpdateQuery = {
......@@ -31,8 +22,8 @@ export const updateUserWhenLogin = (
const firstLoginToday = !userInfo?.login?.[today]
if (firstLoginToday && freeType === FREE_TYPE.EVERY_DAY) {
projection.$inc[`gameTimesEverday.${today}`] = freeTimes
if (firstLoginToday) {
}
return projection
}
......@@ -17,9 +17,6 @@ import CustomTest1Controller from './controller/custom/test1.controller'
const CustomTest1ControllerInstance = new CustomTest1Controller()
import CustomTest2Controller from './controller/custom/test2.controller'
const CustomTest2ControllerInstance = new CustomTest2Controller()
import CommonCardController from './controller/card.controller'
const { getAwardsCarouselList, getCollectCardInfo, getGiftCard, getMyCardsInfo, doJoin } = new CommonCardController()
export default {
getVipInfo: CommonUserControllerInstance.getVipInfo,
......@@ -41,11 +38,5 @@ export default {
testAddStat: CustomTest1ControllerInstance.testAddStat,
testGetStats: CustomTest1ControllerInstance.testGetStats,
test2addStat: CustomTest2ControllerInstance.test2addStat,
test2getStats: CustomTest2ControllerInstance.test2getStats,
// 卡牌类
getAwardsCarouselList,
getCollectCardInfo,
getGiftCard,
getMyCardsInfo,
doJoin
test2getStats: CustomTest2ControllerInstance.test2getStats
}
/**
* 基本信息
*
* @format
*/
import { BaseDao, resultsModel, TBAPIS } from '../../sdk'
import { JOIN_DB_NAME } from '../../db'
import { ACTIVITY_STATUS, CARD_PRIZE_STATUS, PRIZE_DATA_TYPE, PRIZE_TYPE } from '../../constants'
import { getToday, logger } from '../../utils'
import UserService from './user.service'
import AwardService from './awards.service'
import { CODE_TYPES } from '../../errorCode'
import { uniq } from 'lodash'
import { setCardPrizeStatus } from '../../utils/custom/card'
export default class CardService extends UserService {
context: IContext<IParams>
joindao: IBaseDao
awardService: AwardService
constructor(context: IContext<IParams>) {
super(context)
this.joindao = new BaseDao(context, JOIN_DB_NAME)
this.awardService = new AwardService(context)
}
// 集卡
async collectCard(activityId: string, userInfo: IUserInfo) {
const cardPool = await this.awardService.getPrizeConfig({
activityId,
prizeDataType: PRIZE_DATA_TYPE.CARD
})
const card = await this.getCard(cardPool)
const { cardType, _id, image, name, type } = card
if (type === PRIZE_TYPE.THANKS) {
await this.updateUser(userInfo._id, {
$inc: {
joinedTimes: 1
}
})
return {
type: PRIZE_TYPE.THANKS,
name: '谢谢参与'
}
}
const reduceResult = await this.awardService.reduceStock(_id)
if ((reduceResult as ICodeType)?.code) return CODE_TYPES.ERROR_NO_STOCK
userInfo.cardInfo = userInfo.cardInfo || {}
userInfo.cardInfo[cardType] = (userInfo.cardInfo?.[cardType] || 0) + 1
const updateResult = await this.updateUser(userInfo._id, {
$inc: {
joinedTimes: 1,
[`cardInfo.${cardType}`]: 1,
cardsCollectedCount: 1
}
})
if (updateResult !== 1) return CODE_TYPES.SYSTEM_ERROR
const myCardInfo = this.getMyCardInfo(userInfo, cardType, cardPool)
const collectedCardTypePrizeList = await this.getCardPrizeList(
activityId,
PRIZE_DATA_TYPE.CARD_TYPE_AWARD,
'needCards',
myCardInfo.cardTypeCollectedCount
)
return {
cardType,
image,
name,
type,
...myCardInfo,
isNewCard: userInfo?.cardInfo?.[cardType] === 1,
drawLotteryStatus:
collectedCardTypePrizeList.find(v => v.needCardTypes === myCardInfo.cardTypeCollectedCount)?.status ||
CARD_PRIZE_STATUS.LOCK
}
}
getMyCardInfo(userInfo: IUserInfo, cardType?: number, cardPool?: IActivityPrize[]) {
const { cardInfo = {} } = userInfo
// 该卡片收集数量
const currCardCollectedCount = cardType ? cardInfo?.[cardType] || 0 : undefined
// 已收集卡片的总数量
const cardQuantityCollectedCount = Object.values(cardInfo).reduce((total, count) => total + count, 0)
// 已收集卡片类型
const cardTypeCollectedCount = Object.keys(cardInfo).length
// 活动配置的卡片类型
const cardTypeConfigCount = cardPool ? cardPool.filter(v => v.type === PRIZE_TYPE.CARD).length : undefined
return {
currCardCollectedCount,
cardQuantityCollectedCount,
cardTypeCollectedCount,
cardTypeConfigCount,
// 未收集的卡片类型
restCardTypeCount: cardPool ? cardTypeConfigCount - cardTypeCollectedCount : undefined
}
}
async addCollectRecord(userInfo: IUserInfo, cardResult: object) {
const { openId } = this.context
const { activityId } = this.context.data
const { userNick } = userInfo
const recordId = await this.joindao.insertOne({
activityId,
userNick,
openId,
...cardResult,
createTime: Date.now(),
createDay: getToday()
})
return { recordId }
}
// 获取卡片
async getCard(cardPool: IActivityPrize[]) {
let card = await this.awardService.getPrizeByProbability(cardPool)
const thanksPrize = cardPool.find(v => v.type === PRIZE_TYPE.THANKS) || {
type: PRIZE_TYPE.THANKS,
prizeDataType: PRIZE_DATA_TYPE.CARD,
name: '谢谢参与'
}
!card && (card = thanksPrize)
return card
}
async getCardPrizeList(activityId: string, prizeDataType: number, needKey: string, userCount: number) {
const { openId } = this.context
const joinedTimesPrizePool = await this.awardService.getPrizeConfig(
{
activityId,
prizeDataType
},
{
projection: { type: 1, image: 1, prizeDataType: 1, name: 1, [needKey]: 1 }
}
)
// 抽奖次数奖池分类 从小到大排列
const category = uniq(joinedTimesPrizePool.map(v => +v[needKey])).sort((a, b) => a - b)
const prizeMapper = category.reduce((prev, curr) => {
return {
...prev,
[`${curr}`]: joinedTimesPrizePool.filter(v => v[needKey] === curr)
}
}, {})
const awardList = await this.awardService.getAwardsInfoList(
{
activityId,
openId,
prizeDataType
},
{
projection: { type: 1, image: 1, prizeDataType: 1, name: 1 }
}
)
const prizeList = category.map(key => {
return {
[needKey]: key,
status: setCardPrizeStatus(userCount, key, awardList),
prizeList: prizeMapper[key]
}
})
return prizeList
}
async getAwardsCarouselList(activityId: string, limit: number = 30) {
const list = await this.awardService.getAwardsInfoList(
{
activityId,
prizeDataType: {
$in: [PRIZE_DATA_TYPE.CARD_TYPE_AWARD, PRIZE_DATA_TYPE.JOIN_TIMES]
}
},
{
sort: {
createTime: 1
},
projection: {
name: 1,
image: 1,
type: 1,
prizeDataType: 1,
avatar: 1,
userNick: 1
},
limit
}
)
return list
}
async getMyCardsInfo(activityId: string, userInfo: IUserInfo) {
const { cardInfo = {} } = userInfo
const cardPool = await this.awardService.getPrizeConfig(
{
activityId,
prizeDataType: PRIZE_DATA_TYPE.CARD
},
{
projection: {
name: 1,
image: 1,
cardType: 1
}
}
)
return cardPool.map(v => {
const { name, image, cardType } = v
return {
type: cardType,
name,
image,
count: cardInfo[cardType] || 0
}
})
}
async getGiftCard(activityId: string, type: number, userInfo: IUserInfo, inviteUserInfo: IUserInfo) {
// 扣除邀请者的对应卡牌
const reduceResult = await this.userdao.update(
{
_id: inviteUserInfo._id,
$where: `this.cardInfo.${type} >= 1`
},
{
$inc: { [`cardInfo.${type}`]: -1 }
}
)
if (!reduceResult) return CODE_TYPES.SYSTEM_ERROR
// 增加受赠者的卡牌
const addResult = await this.updateUser(userInfo._id, {
$inc: { [`cardInfo.${type}`]: -1 }
})
if (!addResult) return CODE_TYPES.SYSTEM_ERROR
const cardInfo =
(await this.awardService.getPrizeConfig({
activityId,
prizeDataType: PRIZE_DATA_TYPE.CARD,
cardType: +type
})?.[0]) || {}
const { name, image } = cardInfo
return {
name,
image,
type
}
}
}
......@@ -7,7 +7,6 @@ import CommonAwardsService from './awards.service'
import CommonTaskService from './task.service'
import CommonStatService from './stat.service'
import CommonGameService from './game.service'
import CommonCardService from './card.service'
const common = {
CommonAccessService,
......@@ -16,8 +15,7 @@ const common = {
CommonAwardsService,
CommonTaskService,
CommonStatService,
CommonGameService,
CommonCardService
CommonGameService
}
export default common
......@@ -29,6 +27,5 @@ export {
CommonAwardsService,
CommonTaskService,
CommonStatService,
CommonGameService,
CommonCardService
CommonGameService
}
......@@ -72,21 +72,15 @@ export default class StatService {
// 新增PV
// const newPV = await this.userdao.count({ activityId, createDay: day })
// 抽卡PV
const joinPV = await this.joindao.count({ activityId, createDay: day })
// 抽卡UV
const joinUV = (
await this.joindao.aggregate([
{ $match: { activityId, createDay: day } },
// 新增UV(通过邀请)
const newUVFromInviteUV = (
await this.accessdao.aggregate([
{ $match: { activityId, createDay: day, inviteId: { $exists: true } } },
{ $project: { openId: true } },
{ $group: { _id: '$openId', count: { $sum: 1 } } }
])
).length
// 新增UV(通过邀请)
const newUVFromInviteUV = await this.userdao.count({ activityId, createDay: day, inviteId: { $exists: true } })
// 已入会(老会员)PV
const vipPV = await this.accessdao.count({
activityId,
......
......@@ -64,7 +64,7 @@ class UserService extends BaseService {
*/
async initUserData(vipInfo: IVipInfo, activityInfo: IActivityInfo, customUserInfo: ICustomUserInfo) {
const { openId, data } = this.context
const { activityId, isFollow, avatar, inviteId, userNick } = data
const { activityId, isFollow, avatar, userNick } = data
const today = getToday()
console.log(`----------${today}----------`, today)
const { tasks } = activityInfo
......@@ -72,13 +72,8 @@ class UserService extends BaseService {
const user: ICommonUserInfo = {
activityId,
avatar,
inviteId,
userNick,
openId,
// gameTimes: 0,
// totalScore: 0,
// maxScore: 0,
// 待领取次数初始化, 根据需自定义添加
remainTimes: {
follow: isFollow ? follow.value : 0,
member: vipInfo.isVip ? member.value : 0,
......@@ -120,7 +115,7 @@ class UserService extends BaseService {
user.taskInfo[today].member = [{ createTime: Date.now() }]
}
await this.userdao.insertOne({
await this.userdao.insertOne<IUserInfo>({
...user,
...customUserInfo
})
......
......@@ -3,14 +3,6 @@
type IActivityInfo = ICommonActivityInfo & ICustomActivityInfo
interface ICustomActivityInfo {
collectCardConfig: {
freeTimes: number
freeType: number
joinLimit: number
}
shareImage: string
shareTitle: string
shareSubtitle: string
}
interface ICommonActivityInfo {
_id?: string
......
......@@ -3,7 +3,6 @@
type IAwards = ICommonAwards & ICustomAwards
interface ICustomAwards {
needTimes?: number
}
interface ICommonAwards {
_id?: string
......
......@@ -7,15 +7,6 @@ interface ICustomUserInfo {
maxScore?: number
totalScore?: number
updateScoreTime?: number
// 集卡
joinedTimes?: number
gameTimesEverday?: {
[key: string]: number
}
cardsCollectedCount?: number
cardInfo: {
[key: string]: number
}
}
interface ICommonUserInfo {
......
/** @format */
import { resultsModel } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode'
import { getToday } from '../getToday'
export default async function checkCardGameTimes(context: IContext<IParams>, { userInfo }: IControllerInfos) {
const { gameTimes, gameTimesEverday } = userInfo
const today = getToday()
if (!gameTimesEverday?.[today] && !gameTimes) {
return resultsModel.error(CODE_TYPES.ERROR_NO_GAME_TIMES)
}
}
......@@ -14,18 +14,13 @@ import { STAT_TYPE } from '../../../constants'
* @param {IContext<{ activityId: string; inviteId: string }>} context
* @return {*}
*/
export default async function checkHelpRecord(context: IContext<{ activityId: string; inviteId: string }>) {
const {
openId,
data: { activityId, inviteId }
} = context
export default async function checkHelpRecord(
context: IContext<{ activityId: string; inviteId: string }>,
{ userInfo }: IControllerInfos
) {
const { inviteId } = userInfo
// 邀请成功有该用户信息
const userInviteSuccessCount = await dbCount(context, STAT_DB_NAME, {
activityId,
openId,
type: STAT_TYPE.INITE_SUCCESS
})
if (userInviteSuccessCount) return resultsModel.error(CODE_TYPES.ERROR_AREADY_INVITE_SUCCESS)
if (inviteId) return resultsModel.error(CODE_TYPES.ERROR_AREADY_INVITE_SUCCESS)
return { userInviteSuccessCount }
return { inviteId }
}
......@@ -4,6 +4,7 @@ import { resultsModel } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode'
import { dbFindOne } from '../../common/mongodb'
import { USER_DB_NAME } from '../../../db'
import { getTodayCompleteTask } from '../task'
/**
* 检查inviteId是否合法 返回邀请人的用户信息
......@@ -12,7 +13,10 @@ import { USER_DB_NAME } from '../../../db'
* @param {IContext<{ activityId: string; inviteId: string }>} context
* @return {*}
*/
export default async function checkInviteId(context: IContext<{ activityId: string; inviteId: string }>) {
export default async function checkInviteId(
context: IContext<{ activityId: string; inviteId: string }>,
{}: IControllerInfos
) {
const {
openId,
data: { activityId, inviteId }
......@@ -30,6 +34,8 @@ export default async function checkInviteId(context: IContext<{ activityId: stri
// inviteId的用户信息查询不到, 则inviteId无效
if (!inviteUserInfo) return resultsModel.error(CODE_TYPES.ERROR_INVALID_INVITE_ID)
const { todayCompleteTimes } = getTodayCompleteTask('invites', inviteUserInfo)
return {
inviteUserInfo
}
......
/** @format */
import { resultsModel } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode'
import { isBoolean } from 'lodash'
export default async function checkInviteUserCard(
context: IContext<{ type: number; activityId: string; inviteId: string }>,
{}: IControllerInfos,
[],
{ inviteUserInfo }: IPreCheckData
): Promise<IPreCheckResult> {
const { type } = context.data
if (!inviteUserInfo) {
console.error(`checkInviteUserCard必须搭配 checkInviteId使用`)
}
const { cardInfo = {} } = inviteUserInfo
if (!cardInfo?.type) return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, '邀请者该卡片不足')
}
......@@ -12,8 +12,6 @@ import checkVip from './checkVip'
import checkUserInfo, { checkGameTimes } from './checkUserInfo'
import checkJoinId from './checkJoinId'
import checkOpenPrizeStatus from './checkOpenPrizeStatus'
import checkInviteUserCard from './checkInviteUserCard'
import checkCardGameTimes from './checkCardGameTimes'
const check = {
checkActivityTime,
......@@ -31,9 +29,7 @@ const check = {
checkUserInfo,
checkJoinId,
checkGameTimes,
checkOpenPrizeStatus,
checkInviteUserCard,
checkCardGameTimes
checkOpenPrizeStatus
}
export default check
......@@ -54,7 +50,5 @@ export {
checkUserInfo,
checkJoinId,
checkGameTimes,
checkOpenPrizeStatus,
checkInviteUserCard,
checkCardGameTimes
checkOpenPrizeStatus
}
......@@ -3,7 +3,7 @@ import updateVip from './updateVip'
import updateSignTask from './updateSignTask'
import updateOrderGoods from './updateOrderGoods'
import updateFirstLoginToday from './updateFirstLoginToday'
import updateUserInfo, { reduceGameTimes, reduceCardGameTimes } from './updateUserInfo'
import updateUserInfo, { reduceGameTimes } from './updateUserInfo'
const update = {
updateVip,
......@@ -11,8 +11,7 @@ const update = {
updateOrderGoods,
updateFirstLoginToday,
updateUserInfo,
reduceGameTimes,
reduceCardGameTimes
reduceGameTimes
}
export default update
......@@ -23,6 +22,5 @@ export {
updateOrderGoods,
updateFirstLoginToday,
updateUserInfo,
reduceGameTimes,
reduceCardGameTimes
reduceGameTimes
}
......@@ -20,26 +20,12 @@ export function reduceGameTimes(needGameTimes: number) {
})
}
export function reduceCardGameTimes(needGameTimes: number) {
return async function (
context: IContext<IParams>,
{ userInfo }: IControllerInfos
): Promise<IPreUpdateQuery | undefined> {
if (!userInfo) return {}
let projection: IPreUpdateQuery = { $inc: {} }
const today = getToday()
const { gameTimes, gameTimesEverday } = userInfo
if (gameTimesEverday?.[today]) {
projection.$inc[`gameTimesEverday.${today}`] = -needGameTimes
projection.$where[`this.gameTimesEverday.${today} >= ${needGameTimes}`] = -needGameTimes
return projection
}
if (gameTimes) {
projection.$inc[`gameTimes`] = -needGameTimes
projection.$where[`this.gameTimes >= ${needGameTimes}`] = -needGameTimes
return projection
export function updateHelpRecord() {
return updateUserInfo({
$where: `!!this.inviteId`,
$set: {
}
}
})
}
/** @format */
import { CARD_PRIZE_STATUS } from '../../constants'
export function setCardPrizeStatus(joinedTimes: number, needTimes: number, joinedTimesAwardList: IAwards[]) {
if (joinedTimes < needTimes) return CARD_PRIZE_STATUS.LOCK
if (joinedTimes >= needTimes && !joinedTimesAwardList.some(v => v.needTimes === needTimes))
return CARD_PRIZE_STATUS.UN_LOCK
if (joinedTimes >= needTimes && joinedTimesAwardList.some(v => v.needTimes === needTimes))
return CARD_PRIZE_STATUS.SUCCESS
}
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