🐞 fix(gvg): 修复农场种子更新后没有奖励
This commit is contained in:
@@ -135,10 +135,11 @@ export default class GVGLeagueFarm extends BaseModel {
|
|||||||
public static async harvest(configId: number, leagueCode: string, farmId: number, fieldIds: number[], roleId: string) {
|
public static async harvest(configId: number, leagueCode: string, farmId: number, fieldIds: number[], roleId: string) {
|
||||||
const batchCode = genCode(10);
|
const batchCode = genCode(10);
|
||||||
const result = await GVGLeagueFarmModel.bulkWrite(fieldIds.map(fieldId => {
|
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 [];
|
if(result.modifiedCount == 0) return [];
|
||||||
const fieldResult: GVGLeagueFarmType[] = await GVGLeagueFarmModel.find({ batchCode }).sort({ fieldId: 1 }).select('-_id -createdAt -updatedAt -__v -configId -leagueCode').lean();
|
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;
|
return fieldResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { RewardInter } from '../pubUtils/interface';
|
|||||||
import { genCode } from '../pubUtils/util';
|
import { genCode } from '../pubUtils/util';
|
||||||
|
|
||||||
@index({ leagueCode: 1, roleId: 1, configId: 1, status: 1 })
|
@index({ leagueCode: 1, roleId: 1, configId: 1, status: 1 })
|
||||||
|
@index({ batchCode: 1 })
|
||||||
export default class GVGUserItem extends BaseModel {
|
export default class GVGUserItem extends BaseModel {
|
||||||
|
|
||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
|
|||||||
Reference in New Issue
Block a user