活动:月卡权限

This commit is contained in:
luying
2022-03-09 19:47:20 +08:00
parent dafc77954b
commit f440ef2ebe
22 changed files with 295 additions and 220 deletions
@@ -36,13 +36,10 @@ export class DailyBattleHandler {
const curDaily = gameData.daily.find(cur => cur.dailyType == type);
if(!curDaily) return resResult(STATUS.DAILY_TYPE_NOT_FOUND);
let { timesPerDay, timesCanBuy } = curDaily;
let { buyCount = 0 } = await DailyRecordModel.refreshRecord(roleId, type);
let { vLv } = await RoleModel.findByRoleId(roleId);
if(vLv > 0) {
timesCanBuy += 0; // 暂留,用于处理vip等级增加最大购买次数
}
if(buyCount + count > timesCanBuy ) {
if(buyCount + count > curDaily.timesCanBuy ) {
return resResult(STATUS.DAILY_REFRESH_TIMES_LACK)
}
let buyCost = 0;
@@ -50,15 +47,15 @@ export class DailyBattleHandler {
let num = buyCount + i;
buyCost += getDailyBuyCountCost(num);
}
let {gold} = await RoleModel.findByRoleId(roleId);
if(buyCost > gold) {
let role = await RoleModel.findByRoleId(roleId);
if(buyCost > role.gold) {
return resResult(STATUS.DAILY_REFRESH_GOLD_LACK);
}
await handleCost(roleId, sid, [getGoldObject(buyCost)], ITEM_CHANGE_REASON.DAILY_BATTLE_BUY_CNT);
let newDailyRecord = await DailyRecordModel.increseBuyCount(roleId, type, count);
let checkDailyResult = await getDailyNum(newDailyRecord, timesPerDay, timesCanBuy);
let checkDailyResult = await getDailyNum(newDailyRecord, role);
return resResult(STATUS.SUCCESS, { type, ...checkDailyResult, buyCost});
}