邮件:定时循环邮件

This commit is contained in:
luying
2022-05-21 16:26:00 +08:00
parent 367208f780
commit 03bb62e60b
11 changed files with 31 additions and 15 deletions
+18 -4
View File
@@ -5,7 +5,7 @@ import { ServerMailModel, ServerMailType } from '../db/ServerMail';
import { getRoleOnlineInfo } from "./redisService";
import { pinus } from "pinus";
import { gameData } from "../pubUtils/data";
import { nowSeconds } from '../pubUtils/timeUtil';
import { getCurDay, nowSeconds } from '../pubUtils/timeUtil';
import { STATUS } from '../consts/statusCode';
import { genCode, resResult } from '../pubUtils/util';
import { GM_MAIL_TYPE, ITID, MAIL_STATUS, MAIL_TIME_TYPE, MAIL_TYPE, PUSH_ROUTE, SEND_NAME, SEND_TITLE } from "../consts";
@@ -106,7 +106,20 @@ class MailTemp {
} else if (gmmail.timeType == MAIL_TIME_TYPE.DELAY) {
this.sendTime = gmmail.startTime;
} else if (gmmail.timeType == MAIL_TIME_TYPE.CIRCLE) {
this.sendTime = moment(moment().format('YYYY-MM-DD ' + gmmail.circleHour)).unix();
let time = moment(moment().format('YYYY-MM-DD ' + gmmail.circleHour)).unix();
if(time < nowSeconds()) {
if(gmmail.circleDay == 0) {
time += 86400;
} else {
let date = getCurDay(true); // 今天星期几
if(date < gmmail.circleDay) {
time += (gmmail.circleDay - date) * 86400;
} else {
time += (7 + date - gmmail.circleDay) * 86400;
}
}
}
this.sendTime = time;
}
this.endTime = this.sendTime + gmmail.expire * 60 * 60;
this.sendName = gmmail.sendName;
@@ -114,7 +127,7 @@ class MailTemp {
this.content = gmmail.content;
this.hasGoods = gmmail.hasGoods;
this.goods = gmmail.goods;
return gmmail;
return true;
}
private getContent(content: string, params: string[] = []) {
@@ -164,7 +177,8 @@ export class SendMailFun {
// 从GMMail表读取数据
public async setWithGmMail(gmmail: GMMailType) {
let mailTemp = new MailTemp();
mailTemp.setWithGmMail(gmmail);
let canSet = mailTemp.setWithGmMail(gmmail);
if(!canSet) return false
this.mailTemps.set(mailTemp.code, mailTemp);
return mailTemp.code;
}