问卷
This commit is contained in:
@@ -205,7 +205,6 @@ async function getModuleData(type: string, data: { role: RoleType, session: Fron
|
|||||||
case 'chapter':
|
case 'chapter':
|
||||||
return getMainChapter(role);
|
return getMainChapter(role);
|
||||||
case 'survey':
|
case 'survey':
|
||||||
console.log('******', role.roleId);
|
|
||||||
return await getSurvey(role.roleId);
|
return await getSurvey(role.roleId);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import { MonopolyData } from "../domain/activityField/monopolyField";
|
|||||||
import { ActivityPopUpShopModel, ActivityPopUpShopModelType } from "../db/ActivityPopUpShop";
|
import { ActivityPopUpShopModel, ActivityPopUpShopModelType } from "../db/ActivityPopUpShop";
|
||||||
import { getActivitiesByType } from "./activity/activityService";
|
import { getActivitiesByType } from "./activity/activityService";
|
||||||
import { SurveyModel } from "../db/Survery";
|
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) {
|
export async function getSurvey(roleId: string) {
|
||||||
let surveys = await SurveyModel.findEnableSurvey(SURVEY_SELECT.ENTRY);
|
let surveys = await SurveyModel.findEnableSurvey(SURVEY_SELECT.FIND);
|
||||||
return surveys.filter(cur => cur.receivedRole?.indexOf(roleId) == -1).map(cur => {
|
let recs = await SurveyRecModel.findByRole(roleId);
|
||||||
delete cur.receivedRole;
|
return surveys.filter(survey => {
|
||||||
return cur;
|
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) {
|
export async function sendSurveyMail(code: string) {
|
||||||
|
console.log('***** sendSurveyMail', code);
|
||||||
let rec = await SurveyRecModel.findByCode(code);
|
let rec = await SurveyRecModel.findByCode(code);
|
||||||
if(!rec || rec.hasSentMail) return false;
|
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;
|
if(!survey) return false;
|
||||||
|
console.log('***** sendSurveyMail survey', survey);
|
||||||
|
|
||||||
await sendMailByContent(MAIL_TYPE.SEND_MAIL, rec.roleId, { goods: survey.reward, params: [survey.mailContent] });
|
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 });
|
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 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 {
|
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'
|
FIND = '-__v -_id -surveyId -surveyName -roleIndex -reward -mailContent -receivedRole -createdAt -updatedAt'
|
||||||
}
|
}
|
||||||
@@ -42,9 +42,6 @@ export default class Survey extends BaseModel {
|
|||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
isEnable: boolean; // 是否显示
|
isEnable: boolean; // 是否显示
|
||||||
|
|
||||||
@prop({ required: true, type: String })
|
|
||||||
receivedRole: string[]; // 是否显示
|
|
||||||
|
|
||||||
public static async findEnableSurvey(select = '') {
|
public static async findEnableSurvey(select = '') {
|
||||||
let rec: SurveyType[] = await SurveyModel.find({ isEnable: true, endTime: { $gte: nowSeconds() } }).select(select).lean();
|
let rec: SurveyType[] = await SurveyModel.find({ isEnable: true, endTime: { $gte: nowSeconds() } }).select(select).lean();
|
||||||
return rec;
|
return rec;
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ export default class SurveyRec extends BaseModel {
|
|||||||
return rec;
|
return rec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async findByRole(roleId: string) {
|
||||||
|
let rec: SurveyRecType[] = await SurveyRecModel.find({ roleId }).lean();
|
||||||
|
return rec;
|
||||||
|
}
|
||||||
|
|
||||||
public static async findByCode(code: string) {
|
public static async findByCode(code: string) {
|
||||||
let rec: SurveyRecType = await SurveyRecModel.findOne({ code }).lean();
|
let rec: SurveyRecType = await SurveyRecModel.findOne({ code }).lean();
|
||||||
return rec;
|
return rec;
|
||||||
|
|||||||
Reference in New Issue
Block a user