问卷
This commit is contained in:
@@ -34,4 +34,6 @@ export enum SDK_TA_CONST {
|
||||
APPID = '74120ffc6f2945448cc60bf1540c5ad4',
|
||||
SERVER_URL = 'https://shushu.xyplay.cn',
|
||||
LOG_PATH = '/root/zyz/game-server/logs/ta',
|
||||
}
|
||||
}
|
||||
|
||||
export const WJX_KEY = "f98551ef-4c7a-4ae2-abda-b7cca2684fe6"
|
||||
@@ -242,6 +242,7 @@ export enum REDIS_KEY {
|
||||
TREAT_GUILD_CHANNEL = 'treatGuild', // 处理公会账号名频道
|
||||
GUILD_FUND = 'guildFund', // 限时排行
|
||||
SUM_CE_SNAPSHOT = "sumCeTL", // 限时战力排行榜
|
||||
SURVEY_CHANNEL = 'survey', // 文件频道
|
||||
}
|
||||
|
||||
// 各排行榜对应hash的key
|
||||
|
||||
32
shared/db/Survery.ts
Normal file
32
shared/db/Survery.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
|
||||
@index({ id: 1 })
|
||||
@index({ seasonNum: 1 })
|
||||
export default class Survey extends BaseModel {
|
||||
|
||||
@prop({ required: true })
|
||||
surveyId: string; // 问卷id
|
||||
|
||||
@prop({ required: true })
|
||||
surveyName: string; // 问卷id
|
||||
|
||||
@prop({ required: true })
|
||||
roleIndex: number; // 问卷id
|
||||
|
||||
@prop({ required: true })
|
||||
reward: string; // 奖励
|
||||
|
||||
@prop({ required: true })
|
||||
mailContent: string; // 邮件文字
|
||||
|
||||
public static async findBySurveyId(surveyId: string) {
|
||||
let rec: SurveyType = await SurveyModel.findOne({ surveyId }).lean();
|
||||
return rec;
|
||||
}
|
||||
}
|
||||
|
||||
export const SurveyModel = getModelForClass(Survey);
|
||||
|
||||
export interface SurveyType extends Pick<DocumentType<Survey>, keyof Survey> {};
|
||||
export type SurveyUpdate = Partial<SurveyType>; // 将所有字段变成可选项
|
||||
52
shared/db/SurveyRec.ts
Normal file
52
shared/db/SurveyRec.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
import { genCode } from '../pubUtils/util';
|
||||
|
||||
@index({ id: 1 })
|
||||
@index({ seasonNum: 1 })
|
||||
export default class SurveyRec extends BaseModel {
|
||||
|
||||
@prop({ required: true, default: 1 })
|
||||
code: string; // 编码
|
||||
|
||||
@prop({ required: true, default: 1 })
|
||||
roleId: string; // 玩家id
|
||||
|
||||
@prop({ required: true })
|
||||
surveyId: string; // 问卷id
|
||||
|
||||
@prop({ required: true })
|
||||
index: string; // 有没有发邮件
|
||||
|
||||
@prop({ required: true })
|
||||
hasSentMail: boolean; // 有没有发邮件
|
||||
|
||||
@prop({ required: true })
|
||||
json: string; // 整个回调
|
||||
|
||||
public static async findByRoleIdAndId(roleId: string, surveyId: string) {
|
||||
let rec: SurveyRecType = await SurveyRecModel.findOne({ roleId, surveyId }).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
public static async findByCode(code: string) {
|
||||
let rec: SurveyRecType = await SurveyRecModel.findOne({ code }).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
public static async createSurveyRec(roleId: string, surveyId: string, index: string, json: string) {
|
||||
let code = genCode(8);
|
||||
let rec: SurveyRecType = await SurveyRecModel.findOneAndUpdate({ roleId, surveyId }, { $set: { hasSentMail: false, json, index, code } }, { upsert: true, new: true }).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
public static async send(code: string) {
|
||||
let rec: SurveyRecType = await SurveyRecModel.findOneAndUpdate({ code }, { $set: { hasSentMail: true } }).lean();
|
||||
return rec;
|
||||
}
|
||||
}
|
||||
|
||||
export const SurveyRecModel = getModelForClass(SurveyRec);
|
||||
|
||||
export interface SurveyRecType extends Pick<DocumentType<SurveyRec>, keyof SurveyRec> {};
|
||||
export type SurveyRecUpdate = Partial<SurveyRecType>; // 将所有字段变成可选项
|
||||
@@ -1,4 +1,4 @@
|
||||
import { REDIS_KEY, SDK_37_ADDR, SDK_37_CONST } from '../consts';
|
||||
import { REDIS_KEY, SDK_37_ADDR, SDK_37_CONST, WJX_KEY } from '../consts';
|
||||
import { request37 } from './httpUtil';
|
||||
import { nowSeconds } from './timeUtil';
|
||||
import { LoginValidataReturn37, Chat37Params, GetServerListParam } from '../domain/sdk';
|
||||
@@ -12,6 +12,12 @@ export function md5(str: string, treatStr?: (str: string) => string) {
|
||||
return crypto.createHash('md5').update(str, 'utf8').digest("hex");
|
||||
};
|
||||
|
||||
export function sha1(str: string, treatStr?: (str: string) => string) {
|
||||
if(treatStr) str = treatStr(str);
|
||||
// console.log('*****str', str)
|
||||
return crypto.createHash('sha1').update(str, 'utf8').digest("hex");
|
||||
}
|
||||
|
||||
export function getMd5ObjSign(obj: any, joinMark: string, treatStr?: (str: string) => string) {
|
||||
const str = [];
|
||||
Object.keys(obj).sort().forEach((key) => {
|
||||
@@ -36,7 +42,6 @@ export async function checkMd5Sign(obj: any, treatStr?: (str: string) => string)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/************** 37sdk **************/
|
||||
|
||||
export function get37Md5SignA(body: any, key: string) {
|
||||
@@ -123,4 +128,14 @@ function treatVid(str) {
|
||||
|
||||
export function getRedisSubChannel(key: REDIS_KEY, env: string) {
|
||||
return `${key}:${env}`;
|
||||
}
|
||||
|
||||
/********* 问卷星加密 *********/
|
||||
|
||||
export function checkWjxSign(activity: string, index: string, sign: string) {
|
||||
const str = `${activity}${index}${WJX_KEY}`;
|
||||
let signResult = sha1(str);
|
||||
console.log('##### checkWjxSign', str, signResult, sign);
|
||||
if(signResult != sign) return false;
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user