feat(重阳集会):更新纯净数据存储

This commit is contained in:
zhangxk
2023-09-20 13:36:54 +08:00
parent ecd15628af
commit 6a70896648
2 changed files with 8 additions and 8 deletions

View File

@@ -2,7 +2,7 @@ import { Application, BackendSession, HandlerService, } from 'pinus';
import { genCode, resResult } from '../../../pubUtils/util';
import { ITEM_CHANGE_REASON, STATUS } from '../../../consts';
import { getPlayerChongYangData, getPlayerChongYangDataShow } from '../../../services/activity/chongyangService';
import { ActivityChongYangRecModel } from '../../../db/ActivityChongYangRec';
import { ActivityChongYangRecModel, ChongYangGameRecord } from '../../../db/ActivityChongYangRec';
import { RewardInter } from '../../../pubUtils/interface';
import { stringToConsumeParam, stringToRewardParam } from '../../../services/activity/giftPackageService';
import { addItems, handleCost } from '../../../services/role/rewardService';
@@ -46,9 +46,9 @@ export class ChongYangHandler {
if (dayIndex > playerData.dayIndexUnlock) return resResult(STATUS.ACTIVITY_CHONGYANG_LOCK);
const gameCode = genCode(10);
await ActivityChongYangRecModel.gameRecord(serverId, activityId, playerData.roundIndex, roleId, {
await ActivityChongYangRecModel.gameRecords(serverId, activityId, playerData.roundIndex, roleId, [{
todayIndex: playerData.todayIndex, gameCode, time: new Date(), rewards: '', isSuccess: false, dayIndex, isSkip: false
});
}]);
return resResult(STATUS.SUCCESS, { activityId, gameCode });
}
@@ -143,12 +143,12 @@ export class ChongYangHandler {
if (!isHasPass) return resResult(STATUS.ACTIVITY_CHONGYANG_GAMESWEEP_LOCK);
let rewards: RewardInter[] = [];
let records: ChongYangGameRecord[] = [];
for (let i = 0; i < count; i++) {
await ActivityChongYangRecModel.gameRecord(serverId, activityId, playerData.roundIndex, roleId, {
todayIndex: playerData.todayIndex, gameCode: 'sweep', time: new Date(), rewards: scene.rewards, isSuccess: true, dayIndex, isSkip: true
});
records.push({ todayIndex: playerData.todayIndex, gameCode: 'sweep', time: new Date(), rewards: scene.rewards, isSuccess: true, dayIndex, isSkip: true })
rewards.push(...stringToRewardParam(scene.rewards));
}
await ActivityChongYangRecModel.gameRecords(serverId, activityId, playerData.roundIndex, roleId, records);
let goods = await addItems(roleId, roleName, sid, rewards, ITEM_CHANGE_REASON.CHONGYANG_REWARD)

View File

@@ -55,8 +55,8 @@ export default class Activity_ChongYang_Rec extends BaseModel {
return result;
}
public static async gameRecord(serverId: number, activityId: number, roundIndex: number, roleId: string, gameRecord: ChongYangGameRecord) {
let result: ActivityChongYangRecModelType = await ActivityChongYangRecModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex }, { $push: { gameRecords: gameRecord } }, { new: true, upsert: true }).lean();
public static async gameRecords(serverId: number, activityId: number, roundIndex: number, roleId: string, gameRecord: ChongYangGameRecord[]) {
let result: ActivityChongYangRecModelType = await ActivityChongYangRecModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex }, { $push: { gameRecords: { $each: gameRecord } } }, { new: true, upsert: true }).lean();
return result;
}