🐞 fix(活动): 修复活动商店记录bug

This commit is contained in:
luying
2022-11-21 15:07:43 +08:00
parent ff10ff4c7d
commit 4e8d785bea
3 changed files with 8 additions and 4 deletions

View File

@@ -240,7 +240,7 @@ export class ActivityMonopolyHandler {
let rewardArray = stringToRewardParam(item.reward) let rewardArray = stringToRewardParam(item.reward)
let result = await addReward(roleId, roleName, sid, serverId, rewardArray, ITEM_CHANGE_REASON.MONOPOLY_BUY_GOODS); let result = await addReward(roleId, roleName, sid, serverId, rewardArray, ITEM_CHANGE_REASON.MONOPOLY_BUY_GOODS);
await ActivityRefreshShopModel.addRecord(shopActivityId, roleId, roundIndex, pageIndex, id); await ActivityRefreshShopModel.addRecord(shopActivityId, roleId, roundIndex, pageIndex, id, 1);
item.buyCount += 1; item.buyCount += 1;
return resResult(STATUS.SUCCESS, Object.assign(result, { return resResult(STATUS.SUCCESS, Object.assign(result, {

View File

@@ -145,7 +145,7 @@ export async function makeRefreshShopReward(roleId: string, roleName: string, si
let rewardArray = stringToRewardParam(item.reward) let rewardArray = stringToRewardParam(item.reward)
let result = await addReward(roleId, roleName, sid, serverId, rewardArray, ITEM_CHANGE_REASON.BUY_REFRESH_SHOP); let result = await addReward(roleId, roleName, sid, serverId, rewardArray, ITEM_CHANGE_REASON.BUY_REFRESH_SHOP);
await ActivityRefreshShopModel.addRecord(activityId, roleId, playerData.roundIndex, item.pageIndex, item.id); await ActivityRefreshShopModel.addRecord(activityId, roleId, playerData.roundIndex, item.pageIndex, item.id, 1);
item.buyCount += 1; item.buyCount += 1;
return { return {

View File

@@ -45,9 +45,13 @@ export default class Activity_Refresh_Shop extends BaseModel {
goods: GoodsInfo[]; // 可购买商品 goods: GoodsInfo[]; // 可购买商品
//购买领取奖励的记录 //购买领取奖励的记录
public static async addRecord(activityId: number, roleId: string, roundIndex: number, pageIndex: number, id: number) { public static async addRecord(activityId: number, roleId: string, roundIndex: number, pageIndex: number, id: number, count: number) {
let records = [];
for(let i = 0; i < count; i++) {
records.push({ id, pageIndex, time: new Date() });
}
let result: ActivityRefreshShopModelType = await ActivityRefreshShopModel.findOneAndUpdate({ roleId, activityId, roundIndex }, let result: ActivityRefreshShopModelType = await ActivityRefreshShopModel.findOneAndUpdate({ roleId, activityId, roundIndex },
{ $push: { records: { pageIndex, id, time: new Date() } } }, { upsert: true, new: true }).lean(true); { $push: { records: { $each: records } } }, { upsert: true, new: true }).lean(true);
return result; return result;
} }