好友:赠送礼物

This commit is contained in:
luying
2021-02-03 20:17:55 +08:00
parent fe85f0e247
commit 41bf3d96b5
10 changed files with 725 additions and 624 deletions

View File

@@ -3,6 +3,7 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
import { getFriendLvByExp } from '../pubUtils/data';
import * as util from '../pubUtils/friendUtil';
import { nowSeconds } from '../pubUtils/timeUtil';
import { FRIEND } from '../consts';
/**
* 好友直接的亲密值
@@ -144,6 +145,15 @@ export default class FriendShip extends BaseModel {
return result;
}
// 增加亲密度
public static async addFriendValue(roleId: string, hisRoleId: string, inc: number) {
let { roleIds } = util.getRoleIds([roleId, hisRoleId]);
let result: FriendShipType = await FriendShipModel.findOneAndUpdate({ roleIds }, { $inc: { friendValue: inc } }, { new: true })
.select(FRIEND.SEND_PRESENT)
.lean({ virtuals: true });
return result;
}
}
export const FriendShipModel = getModelForClass(FriendShip);