✨ feat(37需求): 推送添加开关
This commit is contained in:
@@ -57,7 +57,7 @@ export enum FRIEND_SHIP_SELECT {
|
||||
GET_FRIEND_VALUE = 'friendValue friendLv'
|
||||
}
|
||||
|
||||
export const ENTERY_ROLE_PICK = ['roleId', 'roleName', 'serverId', 'ce', 'topLineupCe', 'coin', 'lv', 'exp', 'vLv', 'gold', 'heros', 'jewels', 'artifacts', 'consumeGoods', 'title', 'teraphs', 'showLineup', 'heads', 'head', 'frames', 'frame', 'spines', 'spine', 'hasGuild', 'guildCode', 'todayZeroPoint', 'apJson', 'skins', 'totalPay', 'guide', 'hasInit', 'renameCnt', 'totalCost', 'guildName', 'isVip', 'createTime', 'ipLocation', 'activityItems', 'customerLink'];
|
||||
export const ENTERY_ROLE_PICK = ['roleId', 'roleName', 'serverId', 'ce', 'topLineupCe', 'coin', 'lv', 'exp', 'vLv', 'gold', 'heros', 'jewels', 'artifacts', 'consumeGoods', 'title', 'teraphs', 'showLineup', 'heads', 'head', 'frames', 'frame', 'spines', 'spine', 'hasGuild', 'guildCode', 'todayZeroPoint', 'apJson', 'skins', 'totalPay', 'guide', 'hasInit', 'renameCnt', 'totalCost', 'guildName', 'isVip', 'createTime', 'ipLocation', 'activityItems', 'customerLink', 'isClosePush'];
|
||||
|
||||
export enum SURVEY_SELECT {
|
||||
FIND = '-__v -_id -surveyName -roleIndex -reward -mailContent -receivedRole -createdAt -updatedAt'
|
||||
|
||||
+11
-3
@@ -348,6 +348,9 @@ export default class Role extends BaseModel {
|
||||
// 是否发送过推送
|
||||
@prop({ required: false })
|
||||
hasPushMsg: boolean;
|
||||
// 是否打开推送
|
||||
@prop({ required: false })
|
||||
isClosePush: boolean;
|
||||
|
||||
public static async findAllByUid(uid: number, getters = false, virtuals = true) {
|
||||
const role: RoleType[] = await RoleModel.find({ 'userInfo.uid': uid }).select('roleId roleName serverId head frame spine heads frames spines lv updatedAt createTime').lean({ getters, virtuals });
|
||||
@@ -826,22 +829,27 @@ export default class Role extends BaseModel {
|
||||
|
||||
public static async findHasGuildPlayers(createdAt?: Date) {
|
||||
let filter = createdAt? { createdAt: { $gt: createdAt } }: {};
|
||||
let roles: RoleType[] = await RoleModel.find({ loginTime: { $gte: nowSeconds() - 24 * 60 * 60 }, ...filter, hasGuild: true }).sort({ createdAt: 1 }).select('userInfo.channelInfo quitTime loginTime createdAt').lean();
|
||||
let roles: RoleType[] = await RoleModel.find({ loginTime: { $gte: nowSeconds() - 24 * 60 * 60 }, ...filter, hasGuild: true }).sort({ createdAt: 1 }).select('userInfo.channelInfo quitTime loginTime isClosePush createdAt').lean();
|
||||
return roles;
|
||||
}
|
||||
|
||||
public static async findAfkPlayers(createdAt?: Date) {
|
||||
let filter = createdAt? { createdAt: { $gt: createdAt } }: {};
|
||||
let roles: RoleType[] = await RoleModel.find({ loginTime: { $lt: nowSeconds() - 48 * 60 * 60 }, lv: { $gte: 20 }, hasPushMsg: { $exists: false }, ...filter }).sort({ createdAt: 1 }).select('userInfo.channelInfo quitTime loginTime createdAt').lean();
|
||||
let roles: RoleType[] = await RoleModel.find({ loginTime: { $lt: nowSeconds() - 48 * 60 * 60 }, lv: { $gte: 20 }, hasPushMsg: { $exists: false }, ...filter }).sort({ createdAt: 1 }).select('userInfo.channelInfo quitTime loginTime isClosePush createdAt').lean();
|
||||
await RoleModel.updateMany({ _id: roles.map(cur => cur._id) }, { $set: { hasPushMsg: true } });
|
||||
return roles;
|
||||
}
|
||||
|
||||
public static async findActivePlayers(createdAt?: Date) {
|
||||
let filter = createdAt? { createdAt: { $gt: createdAt } }: {};
|
||||
let roles: RoleType[] = await RoleModel.find({ loginTime: { $gte: nowSeconds() - 24 * 60 * 60 }, ...filter }).sort({ createdAt: 1 }).select('userInfo.channelInfo quitTime loginTime createdAt').lean();
|
||||
let roles: RoleType[] = await RoleModel.find({ loginTime: { $gte: nowSeconds() - 24 * 60 * 60 }, ...filter }).sort({ createdAt: 1 }).select('userInfo.channelInfo quitTime loginTime isClosePush createdAt').lean();
|
||||
return roles;
|
||||
}
|
||||
|
||||
public static async setPushMsgOpen(roleId: string, isClosePush: boolean) {
|
||||
let role: RoleType = await RoleModel.findOneAndUpdate({ roleId }, { $set: { isClosePush } }, { new: true }).select('-_id roleId isClosePush').lean();
|
||||
return role;
|
||||
}
|
||||
}
|
||||
|
||||
export const RoleModel = getModelForClass(Role);
|
||||
|
||||
@@ -397,11 +397,11 @@ export class PushMsg37Param {
|
||||
source: number; // 推送来源表
|
||||
type: string; // 推送内容
|
||||
|
||||
constructor(time: number) {
|
||||
this.notify_id = time.toString();
|
||||
constructor(code: string) {
|
||||
this.notify_id = code;
|
||||
this.game_id = SDK_37_CONST.PUSH_GAME_ID;
|
||||
// this.c_game_id = SDK_37_CONST.FX_C_GAME_ID;
|
||||
this.time = Math.floor(time/1000).toString();
|
||||
this.time = Math.floor(Date.now()/1000).toString();
|
||||
this.source = 0; // 0: 游戏内
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user