活动:月卡权限
This commit is contained in:
@@ -11,6 +11,7 @@ import { DicWar } from '../pubUtils/dictionary/DicWar';
|
||||
import { WarStar } from '../domain/dbGeneral';
|
||||
import * as dicParam from '../pubUtils/dicParam';
|
||||
import { calculateWarStar } from './normalBattleService';
|
||||
import { getVipDailyCnt } from './activity/monthlyTicketService';
|
||||
|
||||
/**
|
||||
* 获取全部每日关卡列表
|
||||
@@ -29,7 +30,7 @@ export async function getDailyBattleList(role: RoleType) {
|
||||
let war = getDailyWarStatus(dic, warStar);
|
||||
wars.push(war);
|
||||
}
|
||||
let checkDailyResult = await getDailyNum(refreshResult, timesPerDay, timesCanBuy);
|
||||
let checkDailyResult = await getDailyNum(refreshResult, role);
|
||||
result.push({
|
||||
type, name, ...checkDailyResult,
|
||||
wars
|
||||
@@ -75,7 +76,7 @@ export async function checkDaily(roleId: string, battleId: number, inc: number)
|
||||
if(count + inc > curDaily.timesPerDay + buyCount ) {
|
||||
return { status: -1, resResult: resResult(STATUS.DAILY_TIMES_LACK) }
|
||||
}
|
||||
let checkDailyResult = await getDailyNum(dailyRecord, curDaily.timesPerDay, curDaily.timesCanBuy);
|
||||
let checkDailyResult = await getDailyNum(dailyRecord);
|
||||
return {status: 1, data: {type, ...checkDailyResult }};
|
||||
}
|
||||
|
||||
@@ -109,21 +110,20 @@ export async function checkDailyAndIncrease(roleId: string, warStar: WarStar[],
|
||||
return { status: -1, resResult: resResult(STATUS.DAILY_TIMES_LACK) }
|
||||
}
|
||||
let result = await DailyRecordModel.increseDailyCount(roleId, type, inc);
|
||||
let checkDailyResult = await getDailyNum(result, curDaily.timesPerDay, curDaily.timesCanBuy);
|
||||
let checkDailyResult = await getDailyNum(result);
|
||||
return {status: 1, data: {type, ...checkDailyResult, war}};
|
||||
}
|
||||
|
||||
export async function getDailyNum(dailyRecord: DailyRecord, timesPerDay?: number, timesCanBuy?: number) {
|
||||
export async function getDailyNum(dailyRecord: DailyRecord, role?: RoleType) {
|
||||
let {roleId, type, count = 0, buyCount = 0} = dailyRecord;
|
||||
if(!timesPerDay || !timesCanBuy) {
|
||||
const curDaily = gameData.daily.find(cur => cur.dailyType == type);
|
||||
timesPerDay = curDaily.timesPerDay;
|
||||
timesCanBuy = curDaily.timesCanBuy;
|
||||
}
|
||||
let {vLv} = await RoleModel.findByRoleId(roleId);
|
||||
if(vLv > 0) {
|
||||
timesCanBuy += 0; // 暂留,用于处理vip等级增加最大购买次数
|
||||
const curDaily = gameData.daily.find(cur => cur.dailyType == type);
|
||||
let {timesPerDay, timesCanBuy} = curDaily;
|
||||
|
||||
if(!role) {
|
||||
role = await RoleModel.findByRoleId(roleId, 'vipStartTime');
|
||||
}
|
||||
timesPerDay = getVipDailyCnt(timesPerDay, role);
|
||||
|
||||
return {count: timesPerDay - count + buyCount, buyCount: timesCanBuy - buyCount}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user