Commit d81a56f6 by 胡悦

添加邮件发送

1 parent 90699bc4
...@@ -26,6 +26,8 @@ export class EmailQueryDto { ...@@ -26,6 +26,8 @@ export class EmailQueryDto {
sales_content?: string; sales_content?: string;
training_materials?: string; training_materials?: string;
scene_market?: string; scene_market?: string;
reportData?: string;
template?: string;
} }
class MentorshipPage { class MentorshipPage {
count: number; count: number;
......
...@@ -21,4 +21,9 @@ export class EmailController { ...@@ -21,4 +21,9 @@ export class EmailController {
return 'Email sending failed: ' + error; return 'Email sending failed: ' + error;
} }
} }
@Post('preview')
@Render('template')
getIndex(@Body() query: EmailQueryDto) {
return { ...query };
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -19,35 +19,8 @@ export class EmailService { ...@@ -19,35 +19,8 @@ export class EmailService {
// }); // });
// } // }
async sendMail(query: EmailQueryDto): Promise<void> { async sendMail(query: EmailQueryDto): Promise<void> {
const { to, subject, mentorship_page, supervisor_daily_page, extraction, sales_content, training_materials, scene_market } = query const { to, subject, mentorship_page, supervisor_daily_page, extraction, reportData, template, sales_content, training_materials, scene_market } = query
Logger.log(supervisor_daily_page, 'supervisor_daily_page') Logger.log(supervisor_daily_page, 'supervisor_daily_page')
// 模拟数据
const weeklyData = [
{
date: '5.20 - 5.26',
totalPeople: 11,
validClicks: 2,
clickCount: 2,
activeItems: 8,
createdTasks: 1,
peakDay: '5.21、5.23 / 1',
highlight: true
},
];
const reportData = [
{
title: '区域运营考核模版',
content: '用于提交督导当天店面的业绩、招聘、培训、客户接待和工作小结情况。',
discript: '每日提交份数(与店面上班人数有关) / 填报人数(所有关联该模版的员工数,包括当天请假或者休息的员工)(数据如下①)',
time: '2025/1/21'
},
{
title: '督导培训日报模版',
content: '用于提交督导给新员工培训记录(通过腾讯会议进行培训,然后填写该模版,模版内容包括培训类型、主题、人员、形式、腾讯会议连接、照片)。',
discript: '5.6-5.11,有 0 份提交记录。 / 填报人数(所有关联该模版的员工数,包括当天请假或者休息的员工)(数据如下①)',
time: '2025/2025/04/16/21'
}
]
const assessmentList = [ const assessmentList = [
{ {
date: '5.20(周二)', date: '5.20(周二)',
...@@ -83,15 +56,21 @@ export class EmailService { ...@@ -83,15 +56,21 @@ export class EmailService {
code: 1, //验证码 code: 1, //验证码
date: '2025-05-28', //日期 date: '2025-05-28', //日期
sign: '系统邮件,回复无效。', //发送的签名,当然也可以不要 sign: '系统邮件,回复无效。', //发送的签名,当然也可以不要
weeklyData,
reportData,
assessmentList, assessmentList,
mentorship_page: JSON.parse(mentorship_page), mentorship_page,
supervisor_daily_page: JSON.parse(supervisor_daily_page), supervisor_daily_page,
extraction: JSON.parse(extraction), extraction,
sales_content: JSON.parse(sales_content), sales_content,
training_materials: JSON.parse(training_materials), training_materials,
scene_market: JSON.parse(scene_market) scene_market,
reportData,
template
// mentorship_page: mentorship_page,
// supervisor_daily_page: JSON.parse(supervisor_daily_page),
// extraction: JSON.parse(extraction),
// sales_content: JSON.parse(sales_content),
// training_materials: JSON.parse(training_materials),
// scene_market: JSON.parse(scene_market)
} }
}; };
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
border-collapse: collapse; border-collapse: collapse;
width: 100%; width: 100%;
max-width: 1200px; max-width: 1200px;
margin: 20px auto; margin: 20px 0;
} }
th, th,
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<body> <body>
<div> <div>
<p>各位领导、同事:</p> <p>各位领导、同事:</p>
<p style="text-indent: 2em;">以下是重点功能上线后的使用情况,邮件中仅展示 5/20-5/26 的数据。</p> <p style="text-indent: 2em;">以下是重点功能上线后的使用情况,邮件中仅展示 <%= locals.mentorship_page[0].formattedStart + ' 至 ' + locals.mentorship_page[0].formattedEnd %> 的数据。</p>
<p style="text-indent: 2em;">所有的数据汇总文档:<a <p style="text-indent: 2em;">所有的数据汇总文档:<a
href="https://mcnywc2tcye7.feishu.cn/wiki/IOxow8gSUijONfkntpVcp7Wbnph">所有数据汇总在线文档</a></p> href="https://mcnywc2tcye7.feishu.cn/wiki/IOxow8gSUijONfkntpVcp7Wbnph">所有数据汇总在线文档</a></p>
...@@ -59,10 +59,10 @@ ...@@ -59,10 +59,10 @@
<% locals.mentorship_page.forEach(row=> { %> <% locals.mentorship_page.forEach(row=> { %>
<tr class="highlight"> <tr class="highlight">
<td> <td>
<%= row.date %> <%= row.formattedStart + ' 至 ' + row.formattedEnd %>
</td> </td>
<td> <td>
<%= row.count %> <%= row.totalPopulation %>
</td> </td>
<td> <td>
<%= row.uniqueAccounts %> <%= row.uniqueAccounts %>
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
<%= row.count %> <%= row.count %>
</td> </td>
<td> <td>
<%= row.peakDay.date + ' / ' + row.peakDay.count %> <%= row.peakDay && row.peakDay.date && row.peakDay.count ? `${row.peakDay.date} / ${row.peakDay.count}` : '-' %>
</td> </td>
</tr> </tr>
<% }); %> <% }); %>
...@@ -94,10 +94,10 @@ ...@@ -94,10 +94,10 @@
<% locals.supervisor_daily_page.forEach(row=> { %> <% locals.supervisor_daily_page.forEach(row=> { %>
<tr class="highlight"> <tr class="highlight">
<td> <td>
<%= row.date %> <%= row.formattedStart + ' 至 ' + row.formattedEnd %>
</td> </td>
<td> <td>
<%= row.count %> <%= row.totalPopulation %>
</td> </td>
<td> <td>
<%= row.uniqueAccounts %> <%= row.uniqueAccounts %>
...@@ -116,6 +116,7 @@ ...@@ -116,6 +116,7 @@
</tbody> </tbody>
</table> </table>
<br /> <br />
<% if (locals.reportData && locals.reportData.length > 0) { %>
<p>pc数据分析如下:</p> <p>pc数据分析如下:</p>
<p>目前,建了三种日报模版(区域运营考核模版,督导培训日报模版,导师培训日报模版)。</p> <p>目前,建了三种日报模版(区域运营考核模版,督导培训日报模版,导师培训日报模版)。</p>
<table> <table>
...@@ -124,6 +125,7 @@ ...@@ -124,6 +125,7 @@
<th></th> <th></th>
<th>模版内容</th> <th>模版内容</th>
<th>填写情况</th> <th>填写情况</th>
<th>填报人数</th>
<th>上线时间</th> <th>上线时间</th>
</tr> </tr>
</thead> </thead>
...@@ -131,22 +133,27 @@ ...@@ -131,22 +133,27 @@
<% locals.reportData.forEach(row=> { %> <% locals.reportData.forEach(row=> { %>
<tr> <tr>
<td> <td>
<%= row.title %> <%= row.templateName %>
</td> </td>
<td> <td>
<%= row.content %> <%= row.templateContent %>
</td> </td>
<td> <td>
<%= row.discript %> <%= row.total %>
</td> </td>
<td> <td>
<%= row.time %> <%= row.descript %>
</td>
<td>
<%= row.oinlineTime %>
</td> </td>
</tr> </tr>
<% }); %> <% }); %>
</tbody> </tbody>
</table> </table>
<br /> <br />
<% } %>
<% if (locals.template && locals.template.length > 0) { %>
<p>① 区域运营考核模版数据计算</p> <p>① 区域运营考核模版数据计算</p>
<table> <table>
<thead> <thead>
...@@ -158,19 +165,19 @@ ...@@ -158,19 +165,19 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% locals.assessmentList.forEach(row=> { %> <% locals.template.forEach(row=> { %>
<tr class="highlight"> <tr class="highlight">
<td> <td>
<%= row.date %> <%= row.date %>
</td> </td>
<td> <td>
<%= row.submit %> <%= row.finishCount %>
</td> </td>
<td> <td>
<%= row.fill %> <%= row.totalCount %>
</td> </td>
<td> <td>
<%= row.submitRate %>% <%= row.rate %>
</td> </td>
</tr> </tr>
<% }); %> <% }); %>
...@@ -178,6 +185,7 @@ ...@@ -178,6 +185,7 @@
</table> </table>
<p>导师模版 上线时间(4.16) - 目前,业务端没开始用</p> <p>导师模版 上线时间(4.16) - 目前,业务端没开始用</p>
<br /> <br />
<% } %>
<h3>2、<span style="text-decoration: underline;">话术萃取 上线时间(4.16)</span></h3> <h3>2、<span style="text-decoration: underline;">话术萃取 上线时间(4.16)</span></h3>
<p>数据库统计(浏览时长得是 60s以上 才会记录)</p> <p>数据库统计(浏览时长得是 60s以上 才会记录)</p>
<table> <table>
...@@ -193,7 +201,7 @@ ...@@ -193,7 +201,7 @@
<% locals.extraction.forEach(row=> { %> <% locals.extraction.forEach(row=> { %>
<tr> <tr>
<td> <td>
<%= row.title %> <%= row.formattedStart + ' - ' + row.formattedEnd %>
</td> </td>
<td> <td>
<%= row.count %> <%= row.count %>
...@@ -228,7 +236,7 @@ ...@@ -228,7 +236,7 @@
<% locals.sales_content.forEach(row=> { %> <% locals.sales_content.forEach(row=> { %>
<tr class="highlight"> <tr class="highlight">
<td> <td>
<%= row.date %> <%= row.formattedStart + ' - ' + row.formattedEnd %>
</td> </td>
<td> <td>
<%= row.count %> <%= row.count %>
...@@ -237,9 +245,13 @@ ...@@ -237,9 +245,13 @@
<%= row.uniqueAccounts %> <%= row.uniqueAccounts %>
</td> </td>
<td> <td>
<% if (row.remark && row.remark.length > 0) { %>
<% row.remark.forEach(i=> { %> <% row.remark.forEach(i=> { %>
<div><%= i.name + ': ' + i.count %></div> <div><%= i.name + ': ' + i.count %></div>
<% }); %> <% }); %>
<% } else { %>
-
<% } %>
</td> </td>
</tr> </tr>
<% }); %> <% }); %>
...@@ -260,7 +272,7 @@ ...@@ -260,7 +272,7 @@
<% locals.scene_market.forEach(row=> { %> <% locals.scene_market.forEach(row=> { %>
<tr class="highlight"> <tr class="highlight">
<td> <td>
<%= row.date %> <%= row.formattedStart + ' - ' + row.formattedEnd %>
</td> </td>
<td> <td>
<%= row.count %> <%= row.count %>
...@@ -269,9 +281,13 @@ ...@@ -269,9 +281,13 @@
<%= row.uniqueAccounts %> <%= row.uniqueAccounts %>
</td> </td>
<td> <td>
<% if (row.remark && row.remark.length > 0) { %>
<% row.remark.forEach(i=> { %> <% row.remark.forEach(i=> { %>
<div><%= i.name + ': ' + i.count %></div> <div><%= i.name + ': ' + i.count %></div>
<% }); %> <% }); %>
<% } else { %>
-
<% } %>
</td> </td>
</tr> </tr>
<% }); %> <% }); %>
...@@ -292,7 +308,7 @@ ...@@ -292,7 +308,7 @@
<% locals.training_materials.forEach(row=> { %> <% locals.training_materials.forEach(row=> { %>
<tr class="highlight"> <tr class="highlight">
<td> <td>
<%= row.date %> <%= row.formattedStart + ' - ' + row.formattedEnd %>
</td> </td>
<td> <td>
<%= row.count %> <%= row.count %>
...@@ -301,9 +317,13 @@ ...@@ -301,9 +317,13 @@
<%= row.uniqueAccounts %> <%= row.uniqueAccounts %>
</td> </td>
<td> <td>
<% if (row.remark && row.remark.length > 0) { %>
<% row.remark.forEach(i=> { %> <% row.remark.forEach(i=> { %>
<div><%= i.name + ': ' + i.count %></div> <div><%= i.name + ': ' + i.count %></div>
<% }); %> <% }); %>
<% } else { %>
-
<% } %>
</td> </td>
</tr> </tr>
<% }); %> <% }); %>
...@@ -317,7 +337,7 @@ ...@@ -317,7 +337,7 @@
<li>2、表格中底色的用于标识当天提问最高人次、当天提问最高次数</li> <li>2、表格中底色的用于标识当天提问最高人次、当天提问最高次数</li>
<li>3、表格中空白处代表 0人、0次</li> <li>3、表格中空白处代表 0人、0次</li>
</ul> </ul>
<table class="last-bg"> <!-- <table class="last-bg">
<thead> <thead>
<tr> <tr>
<th></th> <th></th>
...@@ -334,7 +354,7 @@ ...@@ -334,7 +354,7 @@
<% locals.assessmentList.forEach(row=> { %> <% locals.assessmentList.forEach(row=> { %>
<tr> <tr>
<td> <td>
<%= row.date %> <%= row.formattedStart + ' - ' + row.formattedEnd %>
</td> </td>
<td> <td>
<%= row.submit %> <%= row.submit %>
...@@ -360,7 +380,7 @@ ...@@ -360,7 +380,7 @@
</tr> </tr>
<% }); %> <% }); %>
</tbody> </tbody>
</table> </table> -->
</div> </div>
</body> </body>
......
...@@ -2,9 +2,18 @@ import { NestFactory } from '@nestjs/core' ...@@ -2,9 +2,18 @@ import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module' import { AppModule } from './app.module'
import { NestExpressApplication } from '@nestjs/platform-express' import { NestExpressApplication } from '@nestjs/platform-express'
import Initializer from './initor' import Initializer from './initor'
import * as ejs from 'ejs';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(AppModule) const app = await NestFactory.create<NestExpressApplication>(AppModule)
app.useStaticAssets('public', {
prefix: "/static/" //设置虚拟路径
});
app.setBaseViewsDir('views');
app.setViewEngine('ejs');
app.engine('ejs', ejs.renderFile);
app.set('view engine', 'ejs');
await Initializer.use(app) await Initializer.use(app)
await app.listen(process.env.APP_PORT) await app.listen(process.env.APP_PORT)
} }
bootstrap() bootstrap()
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>数据统计表格</title>
<style>
table {
border-collapse: collapse;
width: 100%;
max-width: 1200px;
margin: 20px 0;
}
th,
td {
border: 1px solid #ddd;
padding: 10px 15px;
text-align: center;
}
th {
font-weight: bold;
}
tr.highlight {
background-color: #e8f5e9;
}
.last-bg td:last-child {
background-color: #f1f4fe;
}
.last-bg tr td:last-child {
background-color: #f1f4fe;
}
</style>
</head>
<body>
<div>
<p>各位领导、同事:</p>
<p style="text-indent: 2em;">以下是重点功能上线后的使用情况,邮件中仅展示 <%= locals.mentorship_page[0].formattedStart + ' 至 ' + locals.mentorship_page[0].formattedEnd %> 的数据。</p>
<p style="text-indent: 2em;">所有的数据汇总文档:<a
href="https://mcnywc2tcye7.feishu.cn/wiki/IOxow8gSUijONfkntpVcp7Wbnph">所有数据汇总在线文档</a></p>
<h3>1、<span style="text-decoration: underline;">带教管理&填写带教任务&飞行督导工作日报&群推送</span></h3>
<h4>带教管理 上线时间(4.16)小程序(入口埋点)</h4>
<table>
<thead>
<tr>
<th>日期</th>
<th>总数(人)</th>
<th>有效点击人员数(人)</th>
<th>点击量(次)</th>
<th>最高点击日 / 次数(原因)</th>
</tr>
</thead>
<tbody>
<% locals.mentorship_page.forEach(row=> { %>
<tr class="highlight">
<td>
<%= row.formattedStart + ' 至 ' + row.formattedEnd %>
</td>
<td>
<%= row.totalPopulation %>
</td>
<td>
<%= row.uniqueAccounts %>
</td>
<td>
<%= row.count %>
</td>
<td>
<%= row.peakDay && row.peakDay.date && row.peakDay.count ? `${row.peakDay.date} / ${row.peakDay.count}` : '-' %>
</td>
</tr>
<% }); %>
</tbody>
</table>
<br />
<h4>工作日报(督导) 上线时间(4.16)小程序(入口埋点)</h4>
<table>
<thead>
<tr>
<th>日期</th>
<th>总数(人)</th>
<th>有效点击人员数(人)</th>
<th>点击量(次)</th>
<th>精品升级入口(次)</th>
<th>会员权益入口(次)</th>
</tr>
</thead>
<tbody>
<% locals.supervisor_daily_page.forEach(row=> { %>
<tr class="highlight">
<td>
<%= row.formattedStart + ' 至 ' + row.formattedEnd %>
</td>
<td>
<%= row.totalPopulation %>
</td>
<td>
<%= row.uniqueAccounts %>
</td>
<td>
<%= row.count %>
</td>
<td>
<%= row.equityCount %>
</td>
<td>
<%= row.upgradeCount %>
</td>
</tr>
<% }); %>
</tbody>
</table>
<br />
<% if (locals.reportData && locals.reportData.length > 0) { %>
<p>pc数据分析如下:</p>
<p>目前,建了三种日报模版(区域运营考核模版,督导培训日报模版,导师培训日报模版)。</p>
<table>
<thead>
<tr>
<th></th>
<th>模版内容</th>
<th>填写情况</th>
<th>填报人数</th>
<th>上线时间</th>
</tr>
</thead>
<tbody>
<% locals.reportData.forEach(row=> { %>
<tr>
<td>
<%= row.templateName %>
</td>
<td>
<%= row.templateContent %>
</td>
<td>
<%= row.total %>
</td>
<td>
<%= row.descript %>
</td>
<td>
<%= row.oinlineTime %>
</td>
</tr>
<% }); %>
</tbody>
</table>
<br />
<% } %>
<% if (locals.template && locals.template.length > 0) { %>
<p>① 区域运营考核模版数据计算</p>
<table>
<thead>
<tr>
<th>日期</th>
<th>每日提交份数</th>
<th>填报人数(所有关联该模版的督导人数,包括当天请假或者休息的员工)</th>
<th>提交率</th>
</tr>
</thead>
<tbody>
<% locals.template.forEach(row=> { %>
<tr class="highlight">
<td>
<%= row.date %>
</td>
<td>
<%= row.finishCount %>
</td>
<td>
<%= row.totalCount %>
</td>
<td>
<%= row.rate %>
</td>
</tr>
<% }); %>
</tbody>
</table>
<p>导师模版 上线时间(4.16) - 目前,业务端没开始用</p>
<br />
<% } %>
<h3>2、<span style="text-decoration: underline;">话术萃取 上线时间(4.16)</span></h3>
<p>数据库统计(浏览时长得是 60s以上 才会记录)</p>
<table>
<thead>
<tr>
<th>日期</th>
<th>总浏览次数(次)①</th>
<th>总浏览人数(人)②</th>
<th>总浏览批次(次)③</th>
</tr>
</thead>
<tbody>
<% locals.extraction.forEach(row=> { %>
<tr>
<td>
<%= row.formattedStart + ' - ' + row.formattedEnd %>
</td>
<td>
<%= row.count %>
</td>
<td>
<%= row.peopleTotal %>
</td>
<td>
<%= row.batchTotal %>
</td>
</tr>
<% }); %>
</tbody>
</table>
<p>① 总浏览次数:在时间周期内,所有话术的总浏览次数。</p>
<p>② 总浏览人次:在时间周期内,浏览话术的所有人次。</p>
<p>③ 总浏览批次:在时间周期内,批量浏览话术的总次数,即一次性批量浏览多条话术。</p>
<p>话术萃取推送已关闭(4月21停止推送 )</p>
<br />
<h3>3、<span style="text-decoration: underline;">营销素材 上线时间(3.12)</span></h3>
<p>数据库统计(点击素材浏览算一次点击)</p>
<table>
<thead>
<tr>
<th>日期</th>
<th>有效点击(次)</th>
<th>点击人数(人)</th>
<th>备注</th>
</tr>
</thead>
<tbody>
<% locals.sales_content.forEach(row=> { %>
<tr class="highlight">
<td>
<%= row.formattedStart + ' - ' + row.formattedEnd %>
</td>
<td>
<%= row.count %>
</td>
<td>
<%= row.uniqueAccounts %>
</td>
<td>
<% if (row.remark && row.remark.length > 0) { %>
<% row.remark.forEach(i=> { %>
<div><%= i.name + ': ' + i.count %></div>
<% }); %>
<% } else { %>
-
<% } %>
</td>
</tr>
<% }); %>
</tbody>
</table>
<br />
<h3>4、<span style="text-decoration: underline;">场景集市 上线时间(4.16)</span></h3>
<table>
<thead>
<tr>
<th>日期</th>
<th>有效点击(次)</th>
<th>点击人数(人)</th>
<th>备注</th>
</tr>
</thead>
<tbody>
<% locals.scene_market.forEach(row=> { %>
<tr class="highlight">
<td>
<%= row.formattedStart + ' - ' + row.formattedEnd %>
</td>
<td>
<%= row.count %>
</td>
<td>
<%= row.uniqueAccounts %>
</td>
<td>
<% if (row.remark && row.remark.length > 0) { %>
<% row.remark.forEach(i=> { %>
<div><%= i.name + ': ' + i.count %></div>
<% }); %>
<% } else { %>
-
<% } %>
</td>
</tr>
<% }); %>
</tbody>
</table>
<br />
<h3>5、<span style="text-decoration: underline;">培训资料</span></h3>
<table>
<thead>
<tr>
<th>日期</th>
<th>有效点击(次)</th>
<th>点击人数(人)</th>
<th>备注</th>
</tr>
</thead>
<tbody>
<% locals.training_materials.forEach(row=> { %>
<tr class="highlight">
<td>
<%= row.formattedStart + ' - ' + row.formattedEnd %>
</td>
<td>
<%= row.count %>
</td>
<td>
<%= row.uniqueAccounts %>
</td>
<td>
<% if (row.remark && row.remark.length > 0) { %>
<% row.remark.forEach(i=> { %>
<div><%= i.name + ': ' + i.count %></div>
<% }); %>
<% } else { %>
-
<% } %>
</td>
</tr>
<% }); %>
</tbody>
</table>
<br />
<h3>6、<span style="text-decoration: underline;">AI助手 上线时间(5.16)</span></h3>
<h4>智能体使用情况</h4>
<ul>
<li>1、表格中统计的数据为:提问人数(人)、提问次数(次)</li>
<li>2、表格中底色的用于标识当天提问最高人次、当天提问最高次数</li>
<li>3、表格中空白处代表 0人、0次</li>
</ul>
</div>
</body>
</html>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!