🐞 fix(gvg): 修复农场种子更新后没有奖励

This commit is contained in:
luying
2023-02-08 20:27:20 +08:00
parent 66490bcb4e
commit 66f7d87055
2 changed files with 3 additions and 1 deletions

View File

@@ -135,10 +135,11 @@ export default class GVGLeagueFarm extends BaseModel {
public static async harvest(configId: number, leagueCode: string, farmId: number, fieldIds: number[], roleId: string) {
const batchCode = genCode(10);
const result = await GVGLeagueFarmModel.bulkWrite(fieldIds.map(fieldId => {
return { updateOne: { filter: { configId, leagueCode, farmId, fieldId, lockRoleId: roleId, harvestTime: { $lt: nowSeconds() } }, update: { $set: { unlockTime: 0, harvestTime: 0, seedType: 0, lockRoleId: '', lockRoleName: '', batchCode }} } }
return { updateOne: { filter: { configId, leagueCode, farmId, fieldId, lockRoleId: roleId, harvestTime: { $lt: nowSeconds() } }, update: { $set: { unlockTime: 0, harvestTime: 0, lockRoleId: '', lockRoleName: '', batchCode }} } }
}));
if(result.modifiedCount == 0) return [];
const fieldResult: GVGLeagueFarmType[] = await GVGLeagueFarmModel.find({ batchCode }).sort({ fieldId: 1 }).select('-_id -createdAt -updatedAt -__v -configId -leagueCode').lean();
await GVGLeagueFarmModel.updateMany({ batchCode }, { $set: { seedType: 0 } })
return fieldResult;
}

View File

@@ -5,6 +5,7 @@ import { RewardInter } from '../pubUtils/interface';
import { genCode } from '../pubUtils/util';
@index({ leagueCode: 1, roleId: 1, configId: 1, status: 1 })
@index({ batchCode: 1 })
export default class GVGUserItem extends BaseModel {
@prop({ required: true })