问卷
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
});
|
||||
}
|
||||
@@ -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 });
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user