diff --git a/game-server/app/services/connectorService.ts b/game-server/app/services/connectorService.ts index 0dd79a553..c1fe0da48 100644 --- a/game-server/app/services/connectorService.ts +++ b/game-server/app/services/connectorService.ts @@ -205,7 +205,6 @@ async function getModuleData(type: string, data: { role: RoleType, session: Fron case 'chapter': return getMainChapter(role); case 'survey': - console.log('******', role.roleId); return await getSurvey(role.roleId); default: return null; diff --git a/game-server/app/services/gmService.ts b/game-server/app/services/gmService.ts index 65ef98317..a8f0a5365 100644 --- a/game-server/app/services/gmService.ts +++ b/game-server/app/services/gmService.ts @@ -31,6 +31,7 @@ import { MonopolyData } from "../domain/activityField/monopolyField"; import { ActivityPopUpShopModel, ActivityPopUpShopModelType } from "../db/ActivityPopUpShop"; import { getActivitiesByType } from "./activity/activityService"; import { SurveyModel } from "../db/Survery"; +import { SurveyRecModel } from "../db/SurveyRec"; // —————————————— 跑马灯 —————————————— // // 初始 @@ -340,9 +341,10 @@ export async function getParamStr(activity: ActivityModelType, productID: string 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; + let surveys = await SurveyModel.findEnableSurvey(SURVEY_SELECT.FIND); + let recs = await SurveyRecModel.findByRole(roleId); + return surveys.filter(survey => { + let index = recs.findIndex(rec => rec.surveyId == survey.surveyId); + return index == -1 }); } \ No newline at end of file diff --git a/game-server/app/services/sdkService.ts b/game-server/app/services/sdkService.ts index 881f4b9ab..4a23c6a17 100644 --- a/game-server/app/services/sdkService.ts +++ b/game-server/app/services/sdkService.ts @@ -286,11 +286,14 @@ export async function checkFilterWords(word: string) { } export async function sendSurveyMail(code: string) { + console.log('***** sendSurveyMail', code); let rec = await SurveyRecModel.findByCode(code); if(!rec || rec.hasSentMail) return false; + console.log('***** sendSurveyMail hasSentMail', rec.hasSentMail); - let survey = await SurveyModel.receive(rec.surveyId, rec.roleId); + let survey = await SurveyModel.findBySurveyId(rec.surveyId); if(!survey) return false; + console.log('***** sendSurveyMail survey', survey); 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 }); diff --git a/shared/consts/constModules/selectConst.ts b/shared/consts/constModules/selectConst.ts index 6ec102c19..c900d8d13 100644 --- a/shared/consts/constModules/selectConst.ts +++ b/shared/consts/constModules/selectConst.ts @@ -60,6 +60,5 @@ export enum FRIEND_SHIP_SELECT { 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' } \ No newline at end of file diff --git a/shared/db/Survery.ts b/shared/db/Survery.ts index 5dc8db726..768180180 100644 --- a/shared/db/Survery.ts +++ b/shared/db/Survery.ts @@ -42,9 +42,6 @@ export default class Survey extends BaseModel { @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; diff --git a/shared/db/SurveyRec.ts b/shared/db/SurveyRec.ts index c0a850d38..074a60898 100644 --- a/shared/db/SurveyRec.ts +++ b/shared/db/SurveyRec.ts @@ -29,6 +29,11 @@ export default class SurveyRec extends BaseModel { return rec; } + public static async findByRole(roleId: string) { + let rec: SurveyRecType[] = await SurveyRecModel.find({ roleId }).lean(); + return rec; + } + public static async findByCode(code: string) { let rec: SurveyRecType = await SurveyRecModel.findOne({ code }).lean(); return rec;