问卷
This commit is contained in:
@@ -4,7 +4,7 @@ import { STATUS } from '../../../consts/statusCode';
|
||||
import { GMMailModel, GMMailType } from '../../../db/GMMail';
|
||||
import { delGuildActivityRank, getRoleOnlineInfo } from '../../../services/redisService';
|
||||
import { SendMailFun } from '../../../services/mailService';
|
||||
import { GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE, REF_CIRCLE_MAIL_TIME } from '../../../consts';
|
||||
import { GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE, PUSH_ROUTE, REF_CIRCLE_MAIL_TIME, SURVEY_SELECT } from '../../../consts';
|
||||
import { checkActivityEditable, checkActivityGroupType, checkActivityGroupTypeWithId } from '../../../services/activity/activityService';
|
||||
import { ActivityModel } from '../../../db/Activity';
|
||||
import { ActivityGroupModel } from '../../../db/ActivityGroup';
|
||||
@@ -17,6 +17,9 @@ import { sendUngotDividend } from '../../../services/auctionService';
|
||||
import { taflush } from '../../../services/sdkService';
|
||||
import { ActivityInRemote } from '../../../domain/activityField/activityField';
|
||||
import { pushCurrentTime } from '../../../services/auctionService';
|
||||
import { SurveyModel } from '../../../db/Survery';
|
||||
import { getSurvey } from '../../../services/gmService';
|
||||
import { sendMessageToAllWithSuc } from '../../../services/pushService';
|
||||
let timer: NodeJS.Timer;
|
||||
export default function (app: Application) {
|
||||
return new GmHandler(app);
|
||||
@@ -384,4 +387,24 @@ export class GmHandler {
|
||||
pinus.app.rpc.systimer.systimerRemote.taflush.broadcast();
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
async updateSurvey(msg: { code: string, surveyId: string, beginTim: number, endTime: number, isEnable: boolean, surverLink: string, surveyName: string, roleIndex: number, goods: string, mailContent: string }, session: BackendSession) {
|
||||
|
||||
let reward = JSON.parse(msg.goods);
|
||||
|
||||
let result = await SurveyModel.updateSurvey(msg.code, {...msg, reward}, SURVEY_SELECT.FIND);
|
||||
if(!result) return resResult(STATUS.WRONG_PARMS);
|
||||
await sendMessageToAllWithSuc(PUSH_ROUTE.UPDATE_SURVEY, { survey: result });
|
||||
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
async deleteSurvey(msg: { code: string }, session: BackendSession) {
|
||||
let { code } = msg;
|
||||
|
||||
await SurveyModel.deleteSurvey(code);
|
||||
await sendMessageToAllWithSuc(PUSH_ROUTE.DELETE_SURVEY, { code });
|
||||
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,8 @@ import { SkinModel } from '../db/Skin';
|
||||
import { getAp } from './actionPointService';
|
||||
import { HeroParam } from '../domain/roleField/hero';
|
||||
import { pick } from 'underscore';
|
||||
import { sendMessageToServerWithSuc, sendMessageToUser, sendMessageToUserWithSuc } from './pushService';
|
||||
import { sendMessageToAllWithSuc, sendMessageToServerWithSuc, sendMessageToUser, sendMessageToUserWithSuc } from './pushService';
|
||||
import { getSurvey } from './gmService';
|
||||
|
||||
/**
|
||||
* init: 初始的时候是否推送 true-推 false-不推
|
||||
@@ -76,6 +77,7 @@ const modules = [
|
||||
{ id: 23, type: 'guildActivity', init: false, refresh: true, guild: true },
|
||||
{ id: 24, type: 'donate', init: false, refresh: true, guild: true },
|
||||
{ id: 25, type: 'shop', init: false, refresh: true, guild: false },
|
||||
{ id: 26, type: 'survey', init: false, refresh: false, guild: false },
|
||||
]
|
||||
|
||||
export async function pushData(hasInit: boolean, role: RoleType, session: FrontendOrBackendSession, pushType: 'entry' | 'refresh' = 'entry') {
|
||||
@@ -202,6 +204,9 @@ async function getModuleData(type: string, data: { role: RoleType, session: Fron
|
||||
return getAllGuildActivityStatus();
|
||||
case 'chapter':
|
||||
return getMainChapter(role);
|
||||
case 'survey':
|
||||
console.log('******', role.roleId);
|
||||
return await getSurvey(role.roleId);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -285,11 +290,8 @@ export async function everydayRefresh() {
|
||||
}
|
||||
|
||||
async function pushRefreshTime() {
|
||||
let servers = await getAllServers();
|
||||
let todayZeroPoint = getZeroPoint();
|
||||
for(let serverId of servers) {
|
||||
await sendMessageToServerWithSuc(serverId, PUSH_ROUTE.REFRESH_TIME, { todayZeroPoint }, true);
|
||||
}
|
||||
await sendMessageToAllWithSuc(PUSH_ROUTE.REFRESH_TIME, { todayZeroPoint });
|
||||
}
|
||||
|
||||
export async function kickUser(app: Application, uid: string, message = STATUS.LOGIN_ERR) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Marquee, { MarqueeType, MarqueeModel } from "../db/Marquee";
|
||||
import { ACTIVITY_TYPE, GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE, MARQUEE_SHOW_TYPE, MARQUEE_TIME_TYPE, REF_CIRCLE_MAIL_TIME, SERVER_STATUS } from "../consts";
|
||||
import { ACTIVITY_TYPE, GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE, MARQUEE_SHOW_TYPE, MARQUEE_TIME_TYPE, REF_CIRCLE_MAIL_TIME, SERVER_STATUS, SURVEY_SELECT } from "../consts";
|
||||
import { scheduleJob, scheduledJobs, Job } from 'node-schedule';
|
||||
import { createMarqueeMsg as sysCreateMarqueeMsg, pushMarqueeMsg as sysPushMarqueeMsg } from './sysChatService';
|
||||
import { GroupMessageType } from "../db/GroupMessage";
|
||||
@@ -30,6 +30,7 @@ import { RoleType } from "../db/Role";
|
||||
import { MonopolyData } from "../domain/activityField/monopolyField";
|
||||
import { ActivityPopUpShopModel, ActivityPopUpShopModelType } from "../db/ActivityPopUpShop";
|
||||
import { getActivitiesByType } from "./activity/activityService";
|
||||
import { SurveyModel } from "../db/Survery";
|
||||
|
||||
// —————————————— 跑马灯 —————————————— //
|
||||
// 初始
|
||||
@@ -335,4 +336,13 @@ export async function getParamStr(activity: ActivityModelType, productID: string
|
||||
break;
|
||||
}
|
||||
return JSON.stringify(param);
|
||||
}
|
||||
|
||||
|
||||
export async function getSurvey(roleId: string) {
|
||||
let surveys = await SurveyModel.findEnableSurvey(SURVEY_SELECT.ENTRY);
|
||||
return surveys.filter(cur => cur.receivedRole?.indexOf(roleId) == -1).map(cur => {
|
||||
delete cur.receivedRole;
|
||||
return cur;
|
||||
});
|
||||
}
|
||||
@@ -2,9 +2,29 @@ import { Channel, pinus } from "pinus";
|
||||
import { CHANNEL_PREFIX, PUSH_BATCH, PUSH_INTERVAL, PUSH_ROUTE, STATUS } from "../consts";
|
||||
import { resResult } from "../pubUtils/util";
|
||||
import { getCityChannelSid, getGuildChannelSid, getWorldChannelSid, groupRoomId } from "./chatService";
|
||||
import { getRoleOnlineInfo } from "./redisService";
|
||||
import { getAllOnlineRoles, getRoleOnlineInfo } from "./redisService";
|
||||
import { errlogger, infologger } from '../util/logger';
|
||||
|
||||
export async function sendMessageToAllWithSuc(route: string, data: any) {
|
||||
await sendMessageToAll(route, resResult(STATUS.SUCCESS, data));
|
||||
}
|
||||
|
||||
export async function sendMessageToAll(route: string, data: any) {
|
||||
let allOnlineUsers = await getAllOnlineRoles();
|
||||
let n = Math.ceil(allOnlineUsers.length / PUSH_BATCH); // 一共多少批
|
||||
|
||||
let i = -1;
|
||||
let interval = setInterval(() => {
|
||||
if (++i < n) {
|
||||
let users = allOnlineUsers.slice(i * PUSH_BATCH, (i + 1) * PUSH_BATCH - 1);
|
||||
let uids = users.map(cur => ({ uid: cur.roleId, sid: cur.sid }));
|
||||
pinus.app.channelService.pushMessageByUids(route, data, uids);
|
||||
} else {
|
||||
clearInterval(interval);
|
||||
}
|
||||
}, PUSH_INTERVAL);
|
||||
}
|
||||
|
||||
export async function sendMessageToServerWithSuc(serverId: number, route: string, data: any, isBatch = false) {
|
||||
await sendMessageToServer(serverId, route, resResult(STATUS.SUCCESS, data), isBatch);
|
||||
}
|
||||
|
||||
@@ -289,9 +289,10 @@ export async function sendSurveyMail(code: string) {
|
||||
let rec = await SurveyRecModel.findByCode(code);
|
||||
if(!rec || rec.hasSentMail) return false;
|
||||
|
||||
let survey = await SurveyModel.findBySurveyId(rec.surveyId);
|
||||
let survey = await SurveyModel.receive(rec.surveyId, rec.roleId);
|
||||
if(!survey) return false;
|
||||
|
||||
await sendMailByContent(MAIL_TYPE.SEND_MAIL, rec.roleId, { goods: survey.reward, params: [survey.mailContent] });
|
||||
await sendMessageToUserWithSuc(rec.roleId, PUSH_ROUTE.DELETE_SURVEY, { code: rec.code });
|
||||
rec = await SurveyRecModel.send(rec.code);
|
||||
}
|
||||
@@ -121,20 +121,6 @@ export default class GameController extends Controller {
|
||||
return
|
||||
}
|
||||
|
||||
public async updateSurvey() {
|
||||
const { ctx } = this;
|
||||
const param = ctx.request.body;
|
||||
ctx.body = await ctx.service.game.updateSurvey(param);
|
||||
return
|
||||
}
|
||||
|
||||
public async deleteSurvey() {
|
||||
const { ctx } = this;
|
||||
const param = ctx.request.body;
|
||||
ctx.body = await ctx.service.game.deleteSurvey(param.code);
|
||||
return
|
||||
}
|
||||
|
||||
public async getAccuse() {
|
||||
const { ctx } = this;
|
||||
const { page, pageSize, sortField, sortOrder, form } = ctx.request.body;
|
||||
|
||||
@@ -52,8 +52,6 @@ export default (app: Application) => {
|
||||
router.post('/api/game/swicthserverstatus', tokenParser, controller.game.switchServerStatus);
|
||||
router.post('/api/game/getorderlist', tokenParser, controller.game.getOrderlist);
|
||||
router.post('/api/game/getsurveylist', controller.game.getSurveylist);
|
||||
router.post('/api/game/updatesurvey', controller.game.updateSurvey);
|
||||
router.post('/api/game/deletesurvey', controller.game.deleteSurvey)
|
||||
|
||||
router.post('/api/dic/getdicgoods', tokenParser, controller.game.getDicGoods);
|
||||
router.post('/api/dic/getdichero', tokenParser, controller.game.getDicHero);
|
||||
|
||||
@@ -263,23 +263,4 @@ export default class Game extends Service {
|
||||
}), total
|
||||
});
|
||||
}
|
||||
|
||||
public async updateSurvey(param: any) {
|
||||
const { ctx } = this;
|
||||
try {
|
||||
let reward = JSON.parse(param.goods);
|
||||
|
||||
let result = await SurveyModel.updateSurvey(param.code, {...param, reward});
|
||||
if(!result) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
} catch(e) {
|
||||
return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
}
|
||||
}
|
||||
|
||||
public async deleteSurvey(code: string) {
|
||||
const { ctx } = this;
|
||||
await SurveyModel.deleteSurvey(code);
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,4 +157,6 @@ export const PUSH_ROUTE = {
|
||||
TASK_UPDATE: 'onTaskUpdate',
|
||||
ACTIVITY_TASK_UPDATE: 'onActivityTaskUpdate',
|
||||
TASK_BOX_REFRESH: 'onTaskBoxRefresh',
|
||||
UPDATE_SURVEY: 'onUpdateSurvey',
|
||||
DELETE_SURVEY: 'onDeleteSurvey',
|
||||
}
|
||||
@@ -41,7 +41,7 @@ export enum FRIEND_SELECT {
|
||||
}
|
||||
|
||||
export enum USER_GUILD_SELECT {
|
||||
ENTRY = '-_id -_v guildCode auth'
|
||||
ENTRY = '-_id -__v guildCode auth'
|
||||
}
|
||||
|
||||
export enum GUILD_SELECT {
|
||||
@@ -57,4 +57,9 @@ 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', 'consumeGoods', 'title', 'teraphs', 'showLineup', 'heads', 'head', 'frames', 'frame', 'spines', 'spine', 'hasGuild', 'guildCode', 'todayZeroPoint', 'apJson', 'skins', 'totalPay', 'guide', 'hasInit', 'renameCnt', 'totalCost', 'guildName', 'isVip'];
|
||||
export const ENTERY_ROLE_PICK = ['roleId', 'roleName', 'serverId', 'ce', 'topLineupCe', 'coin', 'lv', 'exp', 'vLv', 'gold', 'heros', 'jewels', 'consumeGoods', 'title', 'teraphs', 'showLineup', 'heads', 'head', 'frames', 'frame', 'spines', 'spine', 'hasGuild', 'guildCode', 'todayZeroPoint', 'apJson', 'skins', 'totalPay', 'guide', 'hasInit', 'renameCnt', 'totalCost', 'guildName', 'isVip'];
|
||||
|
||||
export enum SURVEY_SELECT {
|
||||
ENTRY = '-__v -_id -surveyId -surveyName -roleIndex -reward -mailContent -createdAt -updatedAt',
|
||||
FIND = '-__v -_id -surveyId -surveyName -roleIndex -reward -mailContent -receivedRole -createdAt -updatedAt'
|
||||
}
|
||||
@@ -33,6 +33,9 @@ export default class Region extends BaseModel {
|
||||
@prop({ required: true })
|
||||
gmPort: number; // 长链接地址
|
||||
|
||||
@prop({ required: true })
|
||||
webHost: string; // 短链接
|
||||
|
||||
@prop({ required: true })
|
||||
latestServer: number; // 最新服
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
|
||||
import { SearchSurveyParam } from '../domain/backEndField/search';
|
||||
import { Reward } from '../domain/battleField/pvp';
|
||||
import { genCode } from '../pubUtils/util';
|
||||
import { nowSeconds } from '../pubUtils/timeUtil';
|
||||
|
||||
@index({ id: 1 })
|
||||
@index({ seasonNum: 1 })
|
||||
@@ -17,6 +18,18 @@ export default class Survey extends BaseModel {
|
||||
@prop({ required: true })
|
||||
surveyName: string; // 问卷标题
|
||||
|
||||
@prop({ required: true })
|
||||
surveyLink: string; // 问卷地址
|
||||
|
||||
@prop({ required: true })
|
||||
beginTime: number; // 开始时间
|
||||
|
||||
@prop({ required: true })
|
||||
endTime: number; // 结束时间
|
||||
|
||||
@prop({ required: true })
|
||||
lv: number; // 限制等级
|
||||
|
||||
@prop({ required: true })
|
||||
roleIndex: number; // 玩家
|
||||
|
||||
@@ -26,14 +39,30 @@ export default class Survey extends BaseModel {
|
||||
@prop({ required: true })
|
||||
mailContent: string; // 邮件文字
|
||||
|
||||
@prop({ required: true })
|
||||
isEnable: boolean; // 是否显示
|
||||
|
||||
@prop({ required: true, type: String })
|
||||
receivedRole: string[]; // 是否显示
|
||||
|
||||
public static async findEnableSurvey(select = '') {
|
||||
let rec: SurveyType[] = await SurveyModel.find({ isEnable: true, endTime: { $gte: nowSeconds() } }).select(select).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
public static async findBySurveyId(surveyId: string) {
|
||||
let rec: SurveyType = await SurveyModel.findOne({ surveyId }).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
public static async updateSurvey(code: string, param: SurveyUpdate) {
|
||||
public static async updateSurvey(code: string, param: SurveyUpdate, select = '') {
|
||||
if(code == 'new') code = genCode(6);
|
||||
let rec: SurveyType = await SurveyModel.findOneAndUpdate({ code }, { $set: {...param, code} }, {new: true, upsert: true}).lean();
|
||||
let rec: SurveyType = await SurveyModel.findOneAndUpdate({ code }, { $set: {...param, code} }, {new: true, upsert: true}).select(select).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
public static async receive(code: string, roleId: string) {
|
||||
let rec: SurveyType = await SurveyModel.findOneAndUpdate({ code }, { $push: { receivedRole: roleId } }, { new: true }).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,6 +126,7 @@ export class CreateRegionParam {
|
||||
env: string = ''; // 环境变量
|
||||
gmLink: string; // 对应后台链接
|
||||
gameHost: string; // 长链接
|
||||
webHost: string; // 短链接
|
||||
gmPort: number; // 后台使用的connector端口
|
||||
|
||||
constructor(obj: any) {
|
||||
@@ -135,7 +136,7 @@ export class CreateRegionParam {
|
||||
}
|
||||
|
||||
checkParams() {
|
||||
if(!this.name || !this.prefix || !this.env || !this.gmLink || !this.gameHost || !this.gmPort || !isNumber(this.gmPort) ) {
|
||||
if(!this.name || !this.prefix || !this.env || !this.gmLink || !this.gameHost || !this.gmPort || !this.webHost || !isNumber(this.gmPort) ) {
|
||||
return false
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -796,5 +796,19 @@
|
||||
"name": "获取订单列表",
|
||||
"module": "order",
|
||||
"type": "get"
|
||||
},
|
||||
{
|
||||
"id": 115,
|
||||
"api": "gm.gmHandler.updateSurvey",
|
||||
"name": "更新问卷",
|
||||
"module": "survey",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 116,
|
||||
"api": "gm.gmHandler.deleteSurvey",
|
||||
"name": "更新问卷",
|
||||
"module": "survey",
|
||||
"type": "delete"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user