Commit d610ca85 authored by 郝聪敏's avatar 郝聪敏

添加多个邮箱

parent bdbb828d
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
const Controller = require('egg').Controller; const Controller = require('egg').Controller;
const path = require('path'); const path = require('path');
// const mockMails = `vn1sahsubs@163.com----anncprv // let mockMails = `vn1sahsubs@163----anncprv
// hwm32fxuix@163.com----qfagkir // hwm32fxuix@163.com----qfagkir
// df2srdvgeex@163.com----wvl0ku6 // df2srdvgeex@163.com----wvl0ku6
// heidrck9@163.com----a5isadj // heidrck9@163.com----a5isadj
...@@ -406,7 +406,7 @@ const path = require('path'); ...@@ -406,7 +406,7 @@ const path = require('path');
// mo3q4qv6@163.com----va7ijir50 // mo3q4qv6@163.com----va7ijir50
// tsr8sfk0@163.com----bncs9hs6`.split(/[\s\n]/).map((v, index) => ({ // tsr8sfk0@163.com----bncs9hs6`.split(/[\s\n]/).map((v, index) => ({
// email: v.split('----')[0], id: index, subject: '债权转让通知<公司内测>', // email: v.split('----')[0], id: index, subject: '债权转让通知<公司内测>',
// content: '债权转让通知\r\n\r\n债权转让通知«姓名»,«身份证号»,您通过“«产品名称»”签订的编号为“«channel_order_no»”的《借款合同》(下称“合同”),借款合同编号为“«借款合同编号»”因您逾期未还,我公司已将享有对您的前述债权转让给衡阳市申宏资产经营管理有限公司,债权转让后的权力义务,按原协议约定处理。您应自收到本债转通知之日起向衡阳市申宏资产经营管理有限公司履行还款义务。\r\n\r\n本通知自形成之日即发生法律效力,特此通知!\r\n “«产品名称»”\r\n 鹰潭市信江广达小额贷款股份有限公司2020年 4月 26日\r\n\r\n\r\n\r\n附:债权受让人名称:衡阳市申宏资产经营管理有限公司\r\n开户行:衡阳市农村商业银行高铁支行\r\n账号:82011150001332046\r\n联系电话:0734-8168652\r\n18684909588', // emailContent: '债权转让通知\r\n\r\n债权转让通知«姓名»,«身份证号»,您通过“«产品名称»”签订的编号为“«channel_order_no»”的《借款合同》(下称“合同”),借款合同编号为“«借款合同编号»”因您逾期未还,我公司已将享有对您的前述债权转让给衡阳市申宏资产经营管理有限公司,债权转让后的权力义务,按原协议约定处理。您应自收到本债转通知之日起向衡阳市申宏资产经营管理有限公司履行还款义务。\r\n\r\n本通知自形成之日即发生法律效力,特此通知!\r\n “«产品名称»”\r\n 鹰潭市信江广达小额贷款股份有限公司2020年 4月 26日\r\n\r\n\r\n\r\n附:债权受让人名称:衡阳市申宏资产经营管理有限公司\r\n开户行:衡阳市农村商业银行高铁支行\r\n账号:82011150001332046\r\n联系电话:0734-8168652\r\n18684909588',
// })); // }));
class HomeController extends Controller { class HomeController extends Controller {
...@@ -415,15 +415,23 @@ class HomeController extends Controller { ...@@ -415,15 +415,23 @@ class HomeController extends Controller {
const resource = 'locks:puppeteer'; const resource = 'locks:puppeteer';
const ttl = 60 * 1000; const ttl = 60 * 1000;
let lock = null; let lock = null;
ctx.logger.info('发送任务开始');
const excute = async () => {
try { try {
ctx.logger.info('发送任务开始');
await new Promise(resolve => setTimeout(() => resolve(), 10000));
lock = await app.redlock9.lock(resource, ttl); lock = await app.redlock9.lock(resource, ttl);
ctx.logger.info('获取锁成功'); ctx.logger.info('获取锁成功');
const accounts = await service.home.getMailsAccount();
if (accounts.length) {
this.ctx.logger.info(accounts);
const mails = await service.home.getMails(); const mails = await service.home.getMails();
const result = await service.home.sendMail(mails); const divideMailLength = Math.ceil(mails.length / accounts.length);
this.ctx.logger.info(result); const divideMails = accounts.map((v, index) => ({ ...v, mails: mails.slice(divideMailLength * index, divideMailLength * (index + 1)) }));
await service.home.updateStatus(result); const results = await Promise.all(divideMails.map(v => service.home.sendMail(v)));
this.ctx.logger.info(results.flat());
await service.home.updateStatus(results.flat());
}
if (lock) lock.unlock(); if (lock) lock.unlock();
ctx.logger.info('解锁成功'); ctx.logger.info('解锁成功');
} catch (e) { } catch (e) {
...@@ -435,6 +443,13 @@ class HomeController extends Controller { ...@@ -435,6 +443,13 @@ class HomeController extends Controller {
lock.unlock(); lock.unlock();
ctx.logger.info('解锁成功'); ctx.logger.info('解锁成功');
} }
};
ctx.runInBackground(async () => {
excute();
});
ctx.body = { code: 0, message: '邮件发送触发成功' };
} }
async publisher() { async publisher() {
......
[{"name":"timezone_offset","value":"-480","domain":".exmail.qq.com","path":"/","expires":-1,"size":19,"httpOnly":false,"secure":false,"session":true},{"name":"tinfo","value":"1591165734.0000","domain":".exmail.qq.com","path":"/","expires":-1,"size":20,"httpOnly":false,"secure":false,"session":true},{"name":"pcache","value":"10dcff48f3cdec9MTU5Mzc1NzczNA@763349601@7","domain":".exmail.qq.com","path":"/","expires":1591597734.394307,"size":47,"httpOnly":false,"secure":false,"session":false},{"name":"sid","value":"763349601&60ee52a1ec33522f6a624d7dde2a9c24,cPNmPQyOSqH4.","domain":".exmail.qq.com","path":"/","expires":-1,"size":59,"httpOnly":true,"secure":false,"session":true},{"name":"","value":"0.37248957559032125","domain":"exmail.qq.com","path":"/","expires":-1,"size":19,"httpOnly":false,"secure":false,"session":true},{"name":"qylevel","value":"2","domain":".exmail.qq.com","path":"/","expires":-1,"size":8,"httpOnly":false,"secure":false,"session":true},{"name":"dm_login_weixin_rem","value":"","domain":".qq.com","path":"/","expires":1591252133,"size":19,"httpOnly":false,"secure":false,"session":false},{"name":"_gid","value":"GA1.3.1788287499.1591165733","domain":".exmail.qq.com","path":"/","expires":1591252133,"size":31,"httpOnly":false,"secure":false,"session":false},{"name":"logout_page","value":"dm_loginpage","domain":".qq.com","path":"/","expires":1591252133,"size":23,"httpOnly":false,"secure":false,"session":false},{"name":"qm_authimgs_id","value":"0","domain":".qq.com","path":"/","expires":-1,"size":15,"httpOnly":false,"secure":false,"session":true},{"name":"Hm_lpvt_bdfb0d7298c0c5a5a2475c291ac7aca2","value":"1591165733","domain":".exmail.qq.com","path":"/","expires":-1,"size":50,"httpOnly":false,"secure":false,"session":true},{"name":"qm_username","value":"763349601","domain":".exmail.qq.com","path":"/","expires":-1,"size":20,"httpOnly":false,"secure":false,"session":true},{"name":"username","value":"763349601&763349601","domain":".exmail.qq.com","path":"/","expires":-1,"size":27,"httpOnly":false,"secure":false,"session":true},{"name":"_ga","value":"GA1.3.189918274.1588043915","domain":".exmail.qq.com","path":"/","expires":1654237733,"size":29,"httpOnly":false,"secure":false,"session":false},{"name":"ssl_edition","value":"sail.qq.com","domain":".exmail.qq.com","path":"/","expires":-1,"size":22,"httpOnly":false,"secure":false,"session":true},{"name":"qm_flag","value":"3","domain":".exmail.qq.com","path":"/","expires":-1,"size":8,"httpOnly":false,"secure":false,"session":true},{"name":"Hm_lvt_bdfb0d7298c0c5a5a2475c291ac7aca2","value":"1591165733","domain":".exmail.qq.com","path":"/","expires":1622701733,"size":49,"httpOnly":false,"secure":false,"session":false},{"name":"qm_sk","value":"763349601&yKamb4b5","domain":".exmail.qq.com","path":"/","expires":-1,"size":23,"httpOnly":false,"secure":false,"session":true},{"name":"qm_sid","value":"60ee52a1ec33522f6a624d7dde2a9c24,cPNmPQyOSqH4.","domain":".exmail.qq.com","path":"/","expires":-1,"size":52,"httpOnly":true,"secure":false,"session":true},{"name":"qqmail_alias","value":"tiange.zeng@lkbang.com","domain":".exmail.qq.com","path":"/","expires":-1,"size":34,"httpOnly":false,"secure":false,"session":true},{"name":"qm_ssum","value":"763349601&c56545ad12b06cffaec9393df41ee15f","domain":".exmail.qq.com","path":"/","expires":-1,"size":49,"httpOnly":false,"secure":false,"session":true},{"name":"_gat","value":"1","domain":".exmail.qq.com","path":"/","expires":1591165792,"size":5,"httpOnly":false,"secure":false,"session":false},{"name":"qm_verifyimagesession","value":"h015ba60771a1cc312c3e9a009a389d9fdb41abde02ea86dbb88bc1f0d72dbb78cab1da95b1f93db4fb","domain":".qq.com","path":"/","expires":-1,"size":104,"httpOnly":false,"secure":false,"session":true},{"name":"biz_username","value":"763349601","domain":".exmail.qq.com","path":"/","expires":-1,"size":21,"httpOnly":false,"secure":false,"session":true},{"name":"CCSHOW","value":"0000","domain":".exmail.qq.com","path":"/","expires":1606717734.394209,"size":10,"httpOnly":false,"secure":false,"session":false}]
\ No newline at end of file
[{"name":"timezone_offset","value":"-480","domain":".exmail.qq.com","path":"/","expires":-1,"size":19,"httpOnly":false,"secure":false,"session":true},{"name":"dm_login_weixin_rem","value":"","domain":".qq.com","path":"/","expires":1593766597,"size":19,"httpOnly":false,"secure":false,"session":false},{"name":"qylevel","value":"2","domain":".exmail.qq.com","path":"/","expires":-1,"size":8,"httpOnly":false,"secure":false,"session":true},{"name":"tinfo","value":"1593680197.0000","domain":".exmail.qq.com","path":"/","expires":-1,"size":20,"httpOnly":false,"secure":false,"session":true},{"name":"pcache","value":"ee2f540061e5773MTU5NjI3MjE5Nw@763349601@7","domain":".exmail.qq.com","path":"/","expires":1594112198.087946,"size":47,"httpOnly":false,"secure":false,"session":false},{"name":"username","value":"763349601&763349601","domain":".exmail.qq.com","path":"/","expires":-1,"size":27,"httpOnly":false,"secure":false,"session":true},{"name":"CCSHOW","value":"0000","domain":".exmail.qq.com","path":"/","expires":1609232198.08782,"size":10,"httpOnly":false,"secure":false,"session":false},{"name":"sid","value":"763349601&ec0ff02cd2ec8f3fc2d6f2ace9a0dc56,cPNmPQ60JD1o.","domain":".exmail.qq.com","path":"/","expires":-1,"size":59,"httpOnly":true,"secure":false,"session":true},{"name":"qm_sid","value":"ec0ff02cd2ec8f3fc2d6f2ace9a0dc56,cPNmPQ60JD1o.","domain":".exmail.qq.com","path":"/","expires":-1,"size":52,"httpOnly":true,"secure":false,"session":true},{"name":"qqmail_alias","value":"tiange.zeng@lkbang.com","domain":".exmail.qq.com","path":"/","expires":-1,"size":34,"httpOnly":false,"secure":false,"session":true},{"name":"","value":"0.6909253932795885","domain":"exmail.qq.com","path":"/","expires":-1,"size":18,"httpOnly":false,"secure":false,"session":true},{"name":"_gid","value":"GA1.3.457217771.1593680196","domain":".exmail.qq.com","path":"/","expires":1593766597,"size":30,"httpOnly":false,"secure":false,"session":false},{"name":"logout_page","value":"dm_loginpage","domain":".qq.com","path":"/","expires":1593766597,"size":23,"httpOnly":false,"secure":false,"session":false},{"name":"biz_username","value":"763349601","domain":".exmail.qq.com","path":"/","expires":-1,"size":21,"httpOnly":false,"secure":false,"session":true},{"name":"qm_verifyimagesession","value":"h01666db4ebb3a0b2d480f49abb1c0b2cc7061e91a095bcf86a86bc83981950188df6236ec4acb1bdf6","domain":".qq.com","path":"/","expires":-1,"size":104,"httpOnly":false,"secure":false,"session":true},{"name":"qm_username","value":"763349601","domain":".exmail.qq.com","path":"/","expires":-1,"size":20,"httpOnly":false,"secure":false,"session":true},{"name":"Hm_lpvt_bdfb0d7298c0c5a5a2475c291ac7aca2","value":"1593680197","domain":".exmail.qq.com","path":"/","expires":-1,"size":50,"httpOnly":false,"secure":false,"session":true},{"name":"qm_authimgs_id","value":"2","domain":".qq.com","path":"/","expires":-1,"size":15,"httpOnly":false,"secure":false,"session":true},{"name":"ssl_edition","value":"sail.qq.com","domain":".exmail.qq.com","path":"/","expires":-1,"size":22,"httpOnly":false,"secure":false,"session":true},{"name":"qm_flag","value":"3","domain":".exmail.qq.com","path":"/","expires":-1,"size":8,"httpOnly":false,"secure":false,"session":true},{"name":"_ga","value":"GA1.3.708090953.1593680196","domain":".exmail.qq.com","path":"/","expires":1656752197,"size":29,"httpOnly":false,"secure":false,"session":false},{"name":"qm_ssum","value":"763349601&76ab52ce191d5cf250859eed5ad15c44","domain":".exmail.qq.com","path":"/","expires":-1,"size":49,"httpOnly":false,"secure":false,"session":true},{"name":"_gat","value":"1","domain":".exmail.qq.com","path":"/","expires":1593680256,"size":5,"httpOnly":false,"secure":false,"session":false},{"name":"qm_sk","value":"763349601&yKamb4b5","domain":".exmail.qq.com","path":"/","expires":-1,"size":23,"httpOnly":false,"secure":false,"session":true},{"name":"Hm_lvt_bdfb0d7298c0c5a5a2475c291ac7aca2","value":"1593680196","domain":".exmail.qq.com","path":"/","expires":1625216197,"size":49,"httpOnly":false,"secure":false,"session":false}]
\ No newline at end of file
[{"name":"dm_login_weixin_scan","value":"","domain":".qq.com","path":"/","expires":1593766602,"size":20,"httpOnly":false,"secure":false,"session":false},{"name":"timezone_offset","value":"-480","domain":".exmail.qq.com","path":"/","expires":-1,"size":19,"httpOnly":false,"secure":false,"session":true},{"name":"dm_login_weixin_rem","value":"","domain":".qq.com","path":"/","expires":1593766599,"size":19,"httpOnly":false,"secure":false,"session":false},{"name":"qylevel","value":"2","domain":".exmail.qq.com","path":"/","expires":-1,"size":8,"httpOnly":false,"secure":false,"session":true},{"name":"tinfo","value":"1593680199.0000","domain":".exmail.qq.com","path":"/","expires":-1,"size":20,"httpOnly":false,"secure":false,"session":true},{"name":"pcache","value":"9e200301a45aa39MTU5NjI3MjE5OQ@748969964@7","domain":".exmail.qq.com","path":"/","expires":1594112199.934633,"size":47,"httpOnly":false,"secure":false,"session":false},{"name":"username","value":"748969964&748969964","domain":".exmail.qq.com","path":"/","expires":-1,"size":27,"httpOnly":false,"secure":false,"session":true},{"name":"CCSHOW","value":"0000","domain":".exmail.qq.com","path":"/","expires":1609232199.934506,"size":10,"httpOnly":false,"secure":false,"session":false},{"name":"sid","value":"748969964&0ea77b980d8a43601c410cffdb202f1a,cp94b2VUBBYY.","domain":".exmail.qq.com","path":"/","expires":-1,"size":59,"httpOnly":true,"secure":false,"session":true},{"name":"qm_sid","value":"0ea77b980d8a43601c410cffdb202f1a,cp94b2VUBBYY.","domain":".exmail.qq.com","path":"/","expires":-1,"size":52,"httpOnly":true,"secure":false,"session":true},{"name":"qqmail_alias","value":"notification@lkbang.net","domain":".exmail.qq.com","path":"/","expires":-1,"size":35,"httpOnly":false,"secure":false,"session":true},{"name":"","value":"0.08985075836680734","domain":"exmail.qq.com","path":"/","expires":-1,"size":19,"httpOnly":false,"secure":false,"session":true},{"name":"_gid","value":"GA1.3.1013660193.1593680196","domain":".exmail.qq.com","path":"/","expires":1593766598,"size":31,"httpOnly":false,"secure":false,"session":false},{"name":"logout_page","value":"dm_loginpage","domain":".qq.com","path":"/","expires":1593766599,"size":23,"httpOnly":false,"secure":false,"session":false},{"name":"biz_username","value":"748969964","domain":".exmail.qq.com","path":"/","expires":-1,"size":21,"httpOnly":false,"secure":false,"session":true},{"name":"qm_verifyimagesession","value":"h012fea99abab769af71fb0d7b74deb22c2b6949b95e581127bdd4adb526abae589b06e5e9a4fc4a271","domain":".qq.com","path":"/","expires":-1,"size":104,"httpOnly":false,"secure":false,"session":true},{"name":"qm_username","value":"748969964","domain":".exmail.qq.com","path":"/","expires":-1,"size":20,"httpOnly":false,"secure":false,"session":true},{"name":"Hm_lpvt_bdfb0d7298c0c5a5a2475c291ac7aca2","value":"1593680199","domain":".exmail.qq.com","path":"/","expires":-1,"size":50,"httpOnly":false,"secure":false,"session":true},{"name":"qm_authimgs_id","value":"2","domain":".qq.com","path":"/","expires":-1,"size":15,"httpOnly":false,"secure":false,"session":true},{"name":"ssl_edition","value":"sail.qq.com","domain":".exmail.qq.com","path":"/","expires":-1,"size":22,"httpOnly":false,"secure":false,"session":true},{"name":"qm_flag","value":"3","domain":".exmail.qq.com","path":"/","expires":-1,"size":8,"httpOnly":false,"secure":false,"session":true},{"name":"_ga","value":"GA1.3.231478991.1593680196","domain":".exmail.qq.com","path":"/","expires":1656752198,"size":29,"httpOnly":false,"secure":false,"session":false},{"name":"qm_ssum","value":"748969964&3e7acdd3ea2d2a28d81a61dfa799c3bc","domain":".exmail.qq.com","path":"/","expires":-1,"size":49,"httpOnly":false,"secure":false,"session":true},{"name":"_gat","value":"1","domain":".exmail.qq.com","path":"/","expires":1593680256,"size":5,"httpOnly":false,"secure":false,"session":false},{"name":"qm_sk","value":"748969964&yKamb4b5","domain":".exmail.qq.com","path":"/","expires":-1,"size":23,"httpOnly":false,"secure":false,"session":true},{"name":"Hm_lvt_bdfb0d7298c0c5a5a2475c291ac7aca2","value":"1593680196","domain":".exmail.qq.com","path":"/","expires":1625216198,"size":49,"httpOnly":false,"secure":false,"session":false}]
\ No newline at end of file
[{"name":"qm_ssum","value":"792529744&b3761a8f7272af95d7f6038e44ac86e9","domain":".exmail.qq.com","path":"/","expires":-1,"size":49,"httpOnly":false,"secure":false,"session":true},{"name":"tinfo","value":"1593766445.0000","domain":".exmail.qq.com","path":"/","expires":-1,"size":20,"httpOnly":false,"secure":false,"session":true},{"name":"pcache","value":"3fffb96b247ba11MTU5NjM1ODQ0NQ@792529744@7","domain":".exmail.qq.com","path":"/","expires":1594198445.581441,"size":47,"httpOnly":false,"secure":false,"session":false},{"name":"sid","value":"792529744&d50f3701971c3a8cd1f77d4389f9de9a,c_y9uT-vswyo.","domain":".exmail.qq.com","path":"/","expires":-1,"size":59,"httpOnly":true,"secure":false,"session":true},{"name":"qqmail_alias","value":"notification@lkbang.cn","domain":".exmail.qq.com","path":"/","expires":-1,"size":34,"httpOnly":false,"secure":false,"session":true},{"name":"qm_sid","value":"d50f3701971c3a8cd1f77d4389f9de9a,c_y9uT-vswyo.","domain":".exmail.qq.com","path":"/","expires":-1,"size":52,"httpOnly":true,"secure":false,"session":true},{"name":"_gat","value":"1","domain":".exmail.qq.com","path":"/","expires":1593766504,"size":5,"httpOnly":false,"secure":false,"session":false},{"name":"qm_authimgs_id","value":"1","domain":".qq.com","path":"/","expires":-1,"size":15,"httpOnly":false,"secure":false,"session":true},{"name":"Hm_lvt_bdfb0d7298c0c5a5a2475c291ac7aca2","value":"1593680416","domain":".exmail.qq.com","path":"/","expires":1625302444,"size":49,"httpOnly":false,"secure":false,"session":false},{"name":"qm_sk","value":"792529744&yKamb4b5","domain":".exmail.qq.com","path":"/","expires":-1,"size":23,"httpOnly":false,"secure":false,"session":true},{"name":"_ga","value":"GA1.3.2113948605.1593680416","domain":".exmail.qq.com","path":"/","expires":1656838444,"size":30,"httpOnly":false,"secure":false,"session":false},{"name":"ssl_edition","value":"sail.qq.com","domain":".exmail.qq.com","path":"/","expires":-1,"size":22,"httpOnly":false,"secure":false,"session":true},{"name":"qm_flag","value":"3","domain":".exmail.qq.com","path":"/","expires":-1,"size":8,"httpOnly":false,"secure":false,"session":true},{"name":"logout_page","value":"dm_loginpage","domain":".qq.com","path":"/","expires":1593852845,"size":23,"httpOnly":false,"secure":false,"session":false},{"name":"_gid","value":"GA1.3.2009892514.1593680416","domain":".exmail.qq.com","path":"/","expires":1593852844,"size":31,"httpOnly":false,"secure":false,"session":false},{"name":"","value":"0.3914092651849508","domain":"exmail.qq.com","path":"/","expires":-1,"size":18,"httpOnly":false,"secure":false,"session":true},{"name":"qm_verifyimagesession","value":"h0195522ac52f3c54a46301036da028690bd0090d7e1357f44952fbc5f393ad0953fe9ef598133995ff","domain":".qq.com","path":"/","expires":-1,"size":104,"httpOnly":false,"secure":false,"session":true},{"name":"biz_username","value":"792529744","domain":".exmail.qq.com","path":"/","expires":-1,"size":21,"httpOnly":false,"secure":false,"session":true},{"name":"dm_login_weixin_rem","value":"","domain":".qq.com","path":"/","expires":1593852845,"size":19,"httpOnly":false,"secure":false,"session":false},{"name":"qylevel","value":"3","domain":".exmail.qq.com","path":"/","expires":-1,"size":8,"httpOnly":false,"secure":false,"session":true},{"name":"CCSHOW","value":"0000","domain":".exmail.qq.com","path":"/","expires":1609318445.581392,"size":10,"httpOnly":false,"secure":false,"session":false},{"name":"username","value":"792529744&792529744","domain":".exmail.qq.com","path":"/","expires":-1,"size":27,"httpOnly":false,"secure":false,"session":true},{"name":"Hm_lpvt_bdfb0d7298c0c5a5a2475c291ac7aca2","value":"1593766445","domain":".exmail.qq.com","path":"/","expires":-1,"size":50,"httpOnly":false,"secure":false,"session":true},{"name":"qm_username","value":"792529744","domain":".exmail.qq.com","path":"/","expires":-1,"size":20,"httpOnly":false,"secure":false,"session":true},{"name":"timezone_offset","value":"-480","domain":".exmail.qq.com","path":"/","expires":-1,"size":19,"httpOnly":false,"secure":false,"session":true}]
\ No newline at end of file
{"MAX_AMOUNT":450,"CURRENT_AMOUNT":0}
\ No newline at end of file
{"MAX_AMOUNT":450,"CURRENT_AMOUNT":0}
\ No newline at end of file
{"MAX_AMOUNT":450,"CURRENT_AMOUNT":0}
\ No newline at end of file
'use strict';
module.exports = {
schedule: {
cron: '0 0 0 * * *',
type: 'worker',
},
async task(ctx) {
ctx.logger.info('重置发信数: 定时任务开始');
await ctx.service.home.refreshMailsAmount();
ctx.logger.info('重置发信数: 定时任务结束');
},
};
...@@ -2,13 +2,12 @@ ...@@ -2,13 +2,12 @@
module.exports = { module.exports = {
schedule: { schedule: {
cron: '0 0 10,11,12,15,16,17,18,19,20 * * *', cron: '0 */30 * * * *',
type: 'worker', type: 'worker',
immediate: true,
}, },
async task(ctx) { async task(ctx) {
ctx.logger.info('定时任务开始'); ctx.logger.info('发送邮件: 定时任务开始');
await ctx.service.home.schedule(); await ctx.service.home.schedule();
ctx.logger.info('定时任务结束'); ctx.logger.info('发送邮件: 定时任务结束');
}, },
}; };
'use strict'; 'use strict';
// const mockMails = `vn1sahsubs@163.com----anncprv
// hwm32fxuix@163.com----qfagkir
// df2srdvgeex@163.com----wvl0ku6
// heidrck9@163.com----a5isadj
// tfj62n1i@163.com----vko8gst
// c5gst97u2o@163.com----m7yzf6s
// k3a5n0l7n@163.com----c50k8vc
// r4re5vzp@163.com----o7hguhx
// songshi21698@163.com----n44n3hf0
// tuopanzi16403@163.com----prdv49tn6
// hongluxuan93@126.com----f5nwe0ody
// xingyu2288070@126.com----btscv4gr
// baichenqiao9703@126.com----e86gh8mc
// guluzhuo09@126.com----vlaj02fv
// hantunhui915950@126.com----qok8qzh1
// nongzhanqin4@126.com----bokeycvsl
// yi8193851@126.com----ageosqpwl
// xieju7623067193@126.com----m4z7lavl
// yueshun05731@126.com----g0w962mu
// jicong81628519@126.com----jgctfprg
// weiweitou795@21cn.com----wQKAbDs8iO29
// zuchunteng@21cn.com----hS54eh0W3Pm3
// zhannuo89271@21cn.com----nNo5Aj0a1Q3
// fufengsu1931@21cn.com----pLnn423E9
// gaozhao97@21cn.com----hL98J04R7
// fumei85213@21cn.com----nSZZ4HVv9
// ekao5296017@21cn.com----wGt6KM2o58
// houxian0567@21cn.com----rBi6dGJk1l5
// wenque2497@21cn.com----hMA45elG0
// lengjiao8700@21cn.com----pGQ2UwLE15
// lcg0zfnk@163.com----s1vzma5
// o2rdfy54ycf@163.com----fb2grl18
// y5ihh62@163.com----ut8i20jep
// dq9j4i3of80@163.com----yr2deeuo0
// b577gztu@163.com----wwekfpwqg
// fliqcole1tj@163.com----v2iau1jr
// u5ihtahu48@163.com----a71skxm3
// aklkpcyz@163.com----ccgnu121
// z031lovv87l@163.com----kdgr30w
// o3togtoo@163.com----zmz1zhn
// ba79my1h@163.com----czt4o80m
// qtefd9k4noc@163.com----r6p5m9g
// nw6tmpv@163.com----g7w9cee
// vmaga83r@163.com----y520h103n
// kves05n@163.com----d78eat5
// io70c3g@163.com----b8m40r5
// o0tylu2r3@163.com----gf83eu3lm
// n1iz8hax@163.com----bbxss0m
// l4nh6ciaiya@163.com----pd44u98v
// ugkl625v53@163.com----w8oui6dz4
// znz7y89x@163.com----tnsabg3kp
// q8expvuc80y@163.com----k2c66e4v
// umk2wp9qn@163.com----pqkf3bni7
// dnn50s6t@163.com----wjx0zhs
// boxze91l57@163.com----g21l5vg
// pznf6caiuus@163.com----wh492qb
// i8i0tfeltee@163.com----i62ljcj
// d1ajap1@163.com----jq6s2zxy
// wnmz40owbg8@163.com----c3728p6x
// teodpv8y4pd@163.com----ma64c9at
// ag2in4v71m@163.com----t8niwjq
// tdwoc1ob@163.com----jpfu8or1k
// sxdrp16a@163.com----ae57zvm1
// hr3uge1n@163.com----ebucpx2
// f1k796d9m0s@163.com----m31584d0
// ubbut0pg@163.com----pwsurpx
// a0hbwjwdku@163.com----dpj3p9rry
// u5kp2mte6p@163.com----ye3088ypc
// z2nfemnnp@163.com----vc6jese
// jd1djbr@163.com----ohpenrgzk
// nngn4ssks@163.com----dvf63dlmt
// mk85cyrt@163.com----lnh2j0v5m
// khd8fbwekh9@163.com----b24h4w7ep
// wmjxcx6j5sf@163.com----k7bz2ip6d
// uw4t72xx@163.com----kdxkfoh
// f7478xo4v@163.com----ujpxskrsg
// fo7rkci196v@163.com----u3l13jqq2
// f1f5lj3@163.com----urj4g1a
// w8a468on8q@163.com----iipd9y8
// ttax5x64@163.com----abbio2j7
// qmlkfxe828h@163.com----mwc0jx5y
// l14grd8xcx0@163.com----gefk6esym
// wd9s7sm5@163.com----lizo08jqj
// j76ql4qtuk@163.com----v9x0432
// ffxmf0d6@163.com----unft2oh
// suz1jj844l@163.com----m9mre2z
// ej2h2wt4mtd@163.com----ev960j7ry
// oft7xsdq6z@163.com----vgedpxee
// aqk1z8vcn3t@163.com----w5zna4c3
// gc58yo0b@163.com----etghoh8
// gv41g339c7@163.com----v2nmghh7
// zubnw1m89n@163.com----jsv9bwo3
// lz7e1plbd7@163.com----vr67fk9ui
// l3ag9g6@163.com----c231jw0w
// jvbp5h4hzp8@163.com----wutgvzu4
// g2vu9tify@163.com----n8rb803u
// q8y7yszi0y@163.com----hk587vmc4
// il19c8bab@163.com----x7vce9r9
// un4wu5zp9@163.com----kzz56kw
// g2y76ez2va@163.com----v7zd4d6
// l95xv0jwz6@163.com----pjpn0ju
// h124wnat@163.com----zxugkyd
// zxsi1o3tf6@163.com----z9h8sjwl
// jibi4ur@163.com----ydstk4kx
// cyh1hsqgex@163.com----ofjr5133f
// dtzt6r1yfh9@163.com----my7ed3s
// d0qbwiddrwc@163.com----vtmqj6r
// r4g2a6w@163.com----y9wm6l6n
// q87x80t0@163.com----qho9xz6av
// pl1ziwa@163.com----i4gndd6pp
// ws4i0t7u88b@163.com----ntnb9r5sa
// l4w29db@163.com----syuvv4fs9
// p73w54oq70@163.com----in6elo14r
// ir17n4n0@163.com----dw1i8a41
// uz7yq0i@163.com----y4yu0ic3q
// tvrdcw9@163.com----r7p6v8g
// glyo7i0e@163.com----us06b82s
// b6dnmrp2h@163.com----ivbrfhy81
// pgqkwy5a5@163.com----a2zdwa1a
// j3h1rzpcm@163.com----hcpvcnv9
// ablz3l332rp@163.com----r4rddr7
// thea44qm@163.com----s1nbjay
// q3k353xfe@163.com----cdbcpcji
// tonezzp@163.com----d276ehm
// x6f0ldc@163.com----k56m2gic2
// f36842jcl@163.com----we4smcm7
// kp0ex62yc@163.com----v240534wr
// upnjsw5@163.com----i4514z2
// el99e776@163.com----kfs2e468
// x6bhndjq@163.com----xoh7p5wx
// lengpubi661063@126.com----a76q7f55
// huanai094841@126.com----y5c8k893
// mique1941@126.com----sk1y7agvp
// linfuna709506@126.com----xeox0hw6p
// kebizhong44@126.com----i0fgie8w
// wuzi934746@126.com----v4tl0f8g3
// guyouxian23045@126.com----jck0qcjik
// rongou67758@126.com----i1xloqhm
// shuzai230@126.com----o50rt3qwv
// zhuangyongchou8@126.com----ee39m66cp
// choujuran@126.com----g00hr3wn1
// lirenghe8507403@126.com----pbsyp164
// douzhuo617@126.com----icbn3c5an
// zanliang5787849@126.com----ylmml919
// maohang65@126.com----dcl6g3nq7
// chongyefei@126.com----gek1x9v2x
// baizhanggou@126.com----ak2k9wen
// houyue8733@126.com----yp83l44i
// bandi2049395965@126.com----daojkub4
// maoguan70595406@126.com----mrese1ry
// quqinmi88@126.com----w5wmiixm
// shengbi3840372@126.com----cbovf0gd
// xiongxia169059@126.com----k6br09t9
// sang231324877@126.com----g9vwiucx
// guanhuang56705@126.com----e8sd5i12
// zhonglang460416@126.com----vdnb5j0w3
// zhousou1701@126.com----p55jg3t0w
// yukuangchi637@126.com----lbjhv970
// quyan247173@126.com----ejo43ay1q
// qijie5190950@126.com----hr1nv8b5
// huangyi1982461@126.com----ymczkhv85
// yangtugan@126.com----yw3cff8l
// huaguren687207@126.com----v0b250r7y
// zanyi1683014@126.com----rae60x1k
// huhai017137@126.com----eb58o25ky
// ligongyan33@126.com----t43e0etn
// tantang82986@126.com----zp0xsq5js
// guizhongdu253@126.com----jsw7m753u
// shaoji5507284@126.com----brftvs1b
// hefenzhi4211077@126.com----s7k5h4y0
// nihekan51@126.com----b8p6zno3p
// judun25400@126.com----mc9bbr3z
// fengqunfen31@126.com----wr9jyyd3
// suoweideng09300@126.com----rzmzqjj8p
// jiabei24854@126.com----z768rv3p
// xukong099@126.com----n8jzz45j
// guanlandong2871@126.com----cb44789ux
// daiwei326@126.com----z035bbvf
// tuyiwei298@126.com----moe8rz87o
// hemen68040494@126.com----mc5oidxw9
// fengci3358@126.com----zyg5hofh
// xukeqi888169360@126.com----m55oalflb
// huaiji9984197@126.com----v4l9sb2w
// luyunwo9338012@126.com----nguv47in
// dangjiaya662235@126.com----v0l6a3tr
// songzhidu1@126.com----xjfeabhgy
// pushai0941@126.com----n7kt4irl
// dengdaowo169@126.com----y7fnj9os
// shenye929@126.com----qs7xnh560
// cengmei5271727@126.com----z2b7nzza
// shenuoyan093850@126.com----ebc0tffns
// yangshangya2986@126.com----j9puhqmu
// ruanyuan2@126.com----sj7jle5so
// shenshangshuo35@126.com----y6ntzi94i
// xuwei883663@126.com----coemdt3ds
// balianxi057743@126.com----zfh97wwy
// liangqiang64628@126.com----acf2w16x
// xiezi57498495@126.com----s3wghyzs
// dangju690491@126.com----of69reur
// tuyi35172974@126.com----hgemvp5u
// luguanjiu501@126.com----l3zs9gstn
// xiazhi5608642@126.com----csm43ul88
// manqiao5698@126.com----u31suy7zf
// pengwen09360@126.com----ilndma0jm
// luleiliao9781@126.com----tbrwiiby
// biranyue5@126.com----qil8b6s1
// daian4939@126.com----v6d00u30
// wengzong51@126.com----r41ci6637
// chouxie21@126.com----l8s5wr74
// che76926942479@126.com----a9x1qlmta
// mieshi442350@126.com----wkskx19cr
// wutong341@126.com----ceomo091w
// yuanhan8194242@126.com----cb89uaikp
// zhongpu3619@126.com----yq1zg1wo
// wanlin90852@126.com----tx0n3z7fx
// yuyu6054280008@126.com----n6lrfitl3
// zulangnuo702@126.com----aayg5j95
// chapu99015957@126.com----o7m0f4f76
// quganle759426@126.com----w4vimjlq
// ronglao26177667@126.com----b8sgf3s3a
// yubi3718664084@126.com----g4nfcx3cb
// feimei19057070@126.com----mxlej429k
// cheyiqi69441@126.com----oh8dnbv69
// heyou505308@126.com----y2e4urb1
// zonglu2922@126.com----vi0kh5nv
// jique33599387@126.com----wkv7zql5
// haoqiao91516226@126.com----znbias0u
// lianji560370354@126.com----qzhy75sd
// yongmei5570@126.com----m71c647ji
// yanyuancai11@126.com----e1d4td9nl
// a3y6958eyw@163.com----bo3lfzu
// rd1b8o8y0q5@163.com----xy400g2cs
// uyxjcc3w@163.com----f72ycq77
// ev5smwqn@163.com----wgwabzcc
// gi6lq8b@163.com----xnfxs9y
// n0qtgcl2@163.com----iu64naxt1
// j92h1c7@163.com----dnyq94c
// kfqg1m2ebq@163.com----rng9osm69
// z1xriz4am@163.com----joinzq68
// nx151vh@163.com----x70yfqm4
// y355agfzuh@163.com----d1j4k8l
// w7xzirxvxlg@163.com----imx73kp
// serrl6kv@163.com----yg6182w
// z747bhjd@163.com----fdry4ly
// ibte67q@163.com----fmblo2bw
// wf459jzpyuq@163.com----r7z5wvq7b
// t5zdjwcq6@163.com----vj678ycq
// dcfup0ru9c@163.com----dl3ns9z1
// xfzkey1r1@163.com----h8js7l00p
// q0e8y6g28@163.com----rq88jwn2
// csz8u9hfmr@163.com----e5kk2ruiy
// bz26mi2cjqe@163.com----vy6ehn1iz
// l1345dslu@163.com----g4sdw67j
// ne91xy5@163.com----ui70q6o6
// py44b4ho8g@163.com----qzow29h0v
// pfe1xtbc1g@163.com----k0drr6x8
// fk0wo5ptakc@163.com----bznuk2wtb
// xfp4b41q@163.com----nuwm0myx
// yhretro60q4@163.com----t8t6wrx
// us5y1nummjx@163.com----xdo89zn
// rfwoi2d3074@163.com----j0s7gfst3
// bdcfd11ts@163.com----mrpkbjbe
// o7bn713n@163.com----ntiom70q
// xmjctnk7if9@163.com----j8olt504
// rimhtaih7xp@163.com----izggc9i2
// appcau6@163.com----zv1a8i959
// wt1sqt9@163.com----yuoi916hc
// hn8u5vw7i@163.com----oarty4wxf
// ai07ytbm@163.com----qicvwdr
// cjmagt2@163.com----merc4ky
// imr52lcv@163.com----hiun779
// g8t1434b@163.com----x8sn6i9ci
// xlmfz2r@163.com----j5hk6yr6
// hmvvno01u0@163.com----h1av0jp
// xiuustop@163.com----e2xq5lz
// ivs0cepd7xw@163.com----w32s683ze
// garl6cqk@163.com----l31w98y
// a92oaus65u@163.com----o8et5wic4
// qsqczsrty@163.com----jtt3iy338
// cdz24tsal@163.com----kj683s2
// j02p9y0asu@163.com----v9qrvcp93
// jfwy1xe3zkl@163.com----nh6ivvd
// nqca42h2qr8@163.com----dvbzrc6
// alacx9jeo@163.com----w8uajrk56
// jx9rmevhyl@163.com----zkre0pr
// sgkl721694@163.com----o67mmej
// wwn1sasm1@163.com----pvq2z68
// ypt33deqyaw@163.com----s8c5hk8n9
// j6ovqc65qc@163.com----rhewg3nb
// ziudye4@163.com----b8526nub
// ykksd1io3ai@163.com----xn60kvh
// st9xk2j@163.com----llq7wjd1
// f1u7xa2@163.com----kb009a5di
// leuf3uh@163.com----mhj7aruqk
// ller136eci6@163.com----on83jb3i9
// g3g4m0al@163.com----d70qy3y
// sf50jc986@163.com----lavbv2xv
// rcbf7rt@163.com----ow1wq4cp
// axvnhi4oc@163.com----zbbnag1
// xcuitam2kip@163.com----jfg7fg19
// rc2rkt7d@163.com----j1cvx9se2
// d41s21asag@163.com----l5uyy9rzn
// ba7lg31x1@163.com----l9che90
// s3yc7qo3nf@163.com----gefyj0iv
// ilejw87o3by@163.com----j6024wa7
// mo544jr@163.com----pxtsgv5
// n9c29j87xr7@163.com----y6ji4uc
// nyjoghpjxcp@163.com----xesq4qdah
// lnddyz9rj@163.com----rzxmxreo
// d6r7y57@163.com----qc8l54w
// gounuo089257651@126.com----ny5n8hq3k
// guanjuju26@126.com----ia01bj2o
// mohua81683082@126.com----aece2t9s
// changpinjiu682@126.com----uj2qnki23
// herong63078@126.com----h80u4noef
// suca83965@126.com----ir52uk8q
// lugua827972@126.com----v0q22j9se
// aiza592350284@126.com----eovgbnqn1
// lianmeiyue66@126.com----feena09w6
// zoujiao38328964@126.com----xt49m23l0
// miejiushao1134@126.com----k7k5mcso
// danchao91382874@126.com----iok36kf7a
// bianzhituan300@126.com----ftc6w1ma
// gongouchen03262@126.com----qltqyh5jj
// ruxie2287438@126.com----o7lzg3h18
// shulanshan0115@126.com----doi5v2r1s
// nenglian504006@126.com----vb2wji0r
// chusuyuan541494@126.com----cm91kqtd
// fenghanmu@126.com----ef3x3gj9t
// naganci27922333@126.com----xaaa2bbx
// mengbagu62@126.com----f715yr62l
// bapaoxin87201@126.com----a9ik30l93
// zongguju42655@126.com----el074kyae
// kounaoyun211@126.com----xi2rzrx2q
// duyehuai72259@126.com----cwf15680
// yushi6333755867@126.com----z38v33bg
// yangwuliao8@126.com----e8plsmju
// xiachen2262@126.com----tcq50jrhb
// jingpiao9948429@126.com----i7cvaz6l
// yangpang9383849@126.com----hmrqwpsd
// shuijia2093@126.com----qm8ju447
// caihui0167305@126.com----kevdeohv
// yishixing5@126.com----q1ba42dm
// weiwoshi9@126.com----ww880n5g
// rankan589@126.com----f4vzxtpme
// caiqielu25524@126.com----iuu3saujg
// xiebaji4768037@126.com----wsq4p4dnp
// lushang507441@126.com----izxqcsia
// yufutu81349@126.com----yb525qwy4
// woweiping5@126.com----nlcor3ng4
// pudibu6136194@126.com----alua5emv
// yangshi69218887@126.com----rr9z97xq5
// niubajia792@126.com----ee8v3029
// cengtang0168713@126.com----u2hw75do
// feishoushi80@126.com----eyjn034p3
// gengguai8916134@126.com----qw989gb8
// luoulu486@126.com----fv9mi6dml
// putuijia4985645@126.com----f0xku79gr
// dibayi56187643@126.com----l49269383
// maosha5902@126.com----kfkqivc9
// zoujiaoju@126.com----sg4h1tso
// honggua002971@126.com----soipn3oe
// qiumeina69157@126.com----yv7e8ytcq
// wangsusha8@126.com----b8qkr54tb
// yinggaibei0@126.com----uzi3135e
// shubituo9381605@126.com----jowcut9wn
// quyun91087639@126.com----b0d43xjn
// fuwenke839529@126.com----tthrzt3io
// yiben20706117@126.com----pmgql5xt
// jiannatang9615@126.com----aj1qsrqv
// pengyan200@126.com----twe4srni
// jiasizhi07@126.com----t5lm2one
// langyun3997153@126.com----jt240fqlw
// xian5846046@126.com----zn1r7lk2
// luping08944800@126.com----lxg9fl5o
// kanyanye69@126.com----o77fw7j04
// jiliao106431293@126.com----a8e0e85rb
// caokaoqiao1@126.com----ep2dtgsy
// fangque22892@126.com----l5q2q44wa
// yuanmie3813814@126.com----y18jeh6z
// yangshixia07@126.com----j1bwplvyj
// xikangsu70@126.com----wgaz2kg3p
// nongdun022592@126.com----ycw34cux
// jingua45523@126.com----q3wr2ngj
// hupo8795573081@126.com----muer00y4
// hongxia57378739@126.com----f8gva57z
// laomeng43@126.com----wszie11sb
// gengchao24@126.com----jpa9t1wa
// ruantui5117@126.com----j5kmzca4e
// huoping38@126.com----g2973c2h
// np7sdr7@163.com----we35r29ry
// rtqjrkzm5@163.com----rk7iy0tsf
// ylz59fi@163.com----oeo8e42m
// pze5kes9@163.com----amz6gjku
// v6j0g14tv@163.com----v4hh2ay
// um6c44r@163.com----xruwroe
// p45t0w2j@163.com----ibnk90j
// y3umsz985@163.com----u4dry5lm2
// mo3q4qv6@163.com----va7ijir50
// tsr8sfk0@163.com----bncs9hs6`.split(/[\s\n]/).map((v, index) => ({
// email: v.split('----')[0], id: index, subject: '债权转让通知<公司内测>',
// content: '债权转让通知\r\n\r\n债权转让通知«姓名»,«身份证号»,您通过“«产品名称»”签订的编号为“«channel_order_no»”的《借款合同》(下称“合同”),借款合同编号为“«借款合同编号»”因您逾期未还,我公司已将享有对您的前述债权转让给衡阳市申宏资产经营管理有限公司,债权转让后的权力义务,按原协议约定处理。您应自收到本债转通知之日起向衡阳市申宏资产经营管理有限公司履行还款义务。\r\n\r\n本通知自形成之日即发生法律效力,特此通知!\r\n “«产品名称»”\r\n 鹰潭市信江广达小额贷款股份有限公司2020年 4月 26日\r\n\r\n\r\n\r\n附:债权受让人名称:衡阳市申宏资产经营管理有限公司\r\n开户行:衡阳市农村商业银行高铁支行\r\n账号:82011150001332046\r\n联系电话:0734-8168652\r\n18684909588',
// }));
const Service = require('egg').Service; const Service = require('egg').Service;
const puppeteer = require('puppeteer'); const puppeteer = require('puppeteer');
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const queueName = 'test';
const cookiePath = '../public/data/cookies.json';
const validate = result => { const validate = result => {
if (result.code !== 2000) throw new Error(result && result.msg || '服务器异常'); if (result.code !== 2000) throw new Error(result && result.msg || '服务器异常');
...@@ -419,7 +13,7 @@ const validate = result => { ...@@ -419,7 +13,7 @@ const validate = result => {
class HomeService extends Service { class HomeService extends Service {
async getMails() { async getMails() {
const { ctx } = this; const { ctx } = this;
const limit = 50; const limit = 1200;
ctx.logger.info(`${ctx.app.config.legal.host}/api/email/get/${limit}`); ctx.logger.info(`${ctx.app.config.legal.host}/api/email/get/${limit}`);
const { data: result } = await ctx.curl(`${ctx.app.config.legal.host}/api/email/get/${limit}`, { const { data: result } = await ctx.curl(`${ctx.app.config.legal.host}/api/email/get/${limit}`, {
dataType: 'json', dataType: 'json',
...@@ -454,10 +48,15 @@ class HomeService extends Service { ...@@ -454,10 +48,15 @@ class HomeService extends Service {
try { try {
lock = await app.redlock9.lock(resource, ttl); lock = await app.redlock9.lock(resource, ttl);
ctx.logger.info('获取锁成功'); ctx.logger.info('获取锁成功');
const accounts = await this.getMailsAccount();
if (accounts.length) {
const mails = await this.getMails(); const mails = await this.getMails();
const result = await this.sendMail(mails); const divideMailLength = Math.ceil(mails.length / accounts.length);
this.ctx.logger.info(result); const divideMails = accounts.map((v, index) => ({ ...v, mails: mails.slice(divideMailLength * index, divideMailLength * (index + 1)) }));
await this.updateStatus(result); const results = await Promise.all(divideMails.map(v => this.sendMail(v)));
this.ctx.logger.info(results.flat());
await this.updateStatus(results.flat());
}
if (lock) lock.unlock(); if (lock) lock.unlock();
} catch (e) { } catch (e) {
ctx.logger.error((e && e.message) || '出现未知错误'); ctx.logger.error((e && e.message) || '出现未知错误');
...@@ -469,10 +68,21 @@ class HomeService extends Service { ...@@ -469,10 +68,21 @@ class HomeService extends Service {
} }
} }
async sendMail(mails = []) { async getMailsAccount() {
const { ctx } = this;
return ctx.app.config.tecent.filter(account => {
const mailsAmountPath = `../public/data/mails_amount_${account.index}.json`;
const { MAX_AMOUNT, CURRENT_AMOUNT } = JSON.parse(fs.readFileSync(path.join(__dirname, mailsAmountPath)).toString());
return CURRENT_AMOUNT < MAX_AMOUNT;
});
}
async sendMail({ mails = [], account, password, index }) {
const { ctx, service } = this; const { ctx, service } = this;
const result = []; const result = [];
let browser = null; let browser = null;
const cookiePath = `../public/data/cookies_account_${index}.json`;
const mailsAmountPath = `../public/data/mails_amount_${index}.json`;
const browserConfig = { const browserConfig = {
args: [ '--no-sandbox', '--disable-setuid-sandbox' ], args: [ '--no-sandbox', '--disable-setuid-sandbox' ],
headless: true, headless: true,
...@@ -482,7 +92,21 @@ class HomeService extends Service { ...@@ -482,7 +92,21 @@ class HomeService extends Service {
}, },
}; };
if (!mails.length) return result; if (!mails.length) return result;
// 超额限制
const { MAX_AMOUNT, CURRENT_AMOUNT } = JSON.parse(fs.readFileSync(path.join(__dirname, mailsAmountPath)).toString());
if (CURRENT_AMOUNT > MAX_AMOUNT) {
ctx.logger.error('发信数量已超额');
return result;
}
if (CURRENT_AMOUNT + mails.length > MAX_AMOUNT) {
mails = mails.slice(0, MAX_AMOUNT - CURRENT_AMOUNT);
}
// 获取cookie
let cookie = fs.readFileSync(path.join(__dirname, cookiePath)).toString(); let cookie = fs.readFileSync(path.join(__dirname, cookiePath)).toString();
try { try {
browser = await puppeteer.launch(browserConfig); browser = await puppeteer.launch(browserConfig);
const page = await browser.newPage(); const page = await browser.newPage();
...@@ -500,8 +124,8 @@ class HomeService extends Service { ...@@ -500,8 +124,8 @@ class HomeService extends Service {
await page.click('.js_show_pwd_panel'); await page.click('.js_show_pwd_panel');
} }
await page.$eval('#inputuin', input => { input.value = ''; }); await page.$eval('#inputuin', input => { input.value = ''; });
await page.type('#inputuin', ctx.app.config.tecent.account); await page.type('#inputuin', account);
await page.type('#pp', ctx.app.config.tecent.password); await page.type('#pp', password);
await page.click('#auto_login_in_five_days_pwd'); await page.click('#auto_login_in_five_days_pwd');
await page.click('#btlogin'); await page.click('#btlogin');
await page.waitForNavigation({ waitUntil: 'load' }); // 等待页面加载出来,等同于window.onload await page.waitForNavigation({ waitUntil: 'load' }); // 等待页面加载出来,等同于window.onload
...@@ -524,7 +148,7 @@ class HomeService extends Service { ...@@ -524,7 +148,7 @@ class HomeService extends Service {
ctx.logger.info('tecent mail: 已登录'); ctx.logger.info('tecent mail: 已登录');
for (let i = 0; i < mails.length; i++) { for (let i = 0; i < mails.length; i++) {
const email = mails[i].email; const email = mails[i].email;
ctx.logger.info(`tecent mail: 准备发送第${i + 1}封邮件 mail: ${email}, id: ${mails[i].id}`); ctx.logger.info(`tecent mail: 准备发送第${i + 1}封邮件 mail: ${email}, id: ${mails[i].id}, account: ${account}`);
await page.click('#composebtn'); await page.click('#composebtn');
const mainFrame = await page.frames().find(f => f.name() === 'mainFrame'); const mainFrame = await page.frames().find(f => f.name() === 'mainFrame');
await mainFrame.waitFor(3000); await mainFrame.waitFor(3000);
...@@ -540,6 +164,18 @@ class HomeService extends Service { ...@@ -540,6 +164,18 @@ class HomeService extends Service {
const isNeedCode = await page.$('#QMVerify_s_vfcode'); const isNeedCode = await page.$('#QMVerify_s_vfcode');
if (isNeedCode) throw new Error('发送邮件需要输入验证码!'); if (isNeedCode) throw new Error('发送邮件需要输入验证码!');
const isAccountValid = await page.$('#QMconfirm_s__title_');
if (isAccountValid) {
const dialogInfo = await page.$eval('.dialog_f_c', el => el.innerHTML);
await page.click('#QMconfirm_s_confirm');
result.push({ id: mails[i].id, code: 1, msg: '投递失败' });
await page.click('#composebtn');
await page.waitFor(3000);
await page.click('#composeExitAlert_s_btn_delete_save');
ctx.logger.error(dialogInfo || '邮件地址不正确');
continue;
}
await mainFrame.waitFor('#readSendbox>a'); await mainFrame.waitFor('#readSendbox>a');
await mainFrame.click('#readSendbox>a'); await mainFrame.click('#readSendbox>a');
await mainFrame.waitFor(5000); await mainFrame.waitFor(5000);
...@@ -562,14 +198,11 @@ class HomeService extends Service { ...@@ -562,14 +198,11 @@ class HomeService extends Service {
await mailSendStatusFrame.click('#statusbtn'); await mailSendStatusFrame.click('#statusbtn');
if (sendStatus !== '投递成功') { if (sendStatus !== '投递成功') {
if (sendStatus === '投递失败') {
result.push({ id: mails[i].id, code: 1, msg: '投递失败' }); result.push({ id: mails[i].id, code: 1, msg: '投递失败' });
}
ctx.logger.error(sendStatus || '投递失败'); ctx.logger.error(sendStatus || '投递失败');
continue; continue;
} }
ctx.logger.info(receiver, email, !receiver.includes(email) || !receiver.includes(email.toLowerCase()));
if (!receiver.includes(email) && !receiver.includes(email.toLowerCase())) { if (!receiver.includes(email) && !receiver.includes(email.toLowerCase())) {
ctx.logger.error('收件箱不一致, 投递失败'); ctx.logger.error('收件箱不一致, 投递失败');
continue; continue;
...@@ -587,6 +220,8 @@ class HomeService extends Service { ...@@ -587,6 +220,8 @@ class HomeService extends Service {
ctx.logger.error(e); ctx.logger.error(e);
} }
fs.writeFileSync(path.join(__dirname, mailsAmountPath), JSON.stringify({ MAX_AMOUNT, CURRENT_AMOUNT: CURRENT_AMOUNT + result.length }));
if (browser) await browser.close(); if (browser) await browser.close();
return result; return result;
...@@ -624,6 +259,14 @@ class HomeService extends Service { ...@@ -624,6 +259,14 @@ class HomeService extends Service {
// if (ch) ch.close(); // if (ch) ch.close();
// } // }
} }
async refreshMailsAmount() {
this.ctx.app.config.tecent.forEach(v => {
const mailsAmountPath = `../public/data/mails_amount_${v.index}.json`;
const { MAX_AMOUNT } = JSON.parse(fs.readFileSync(path.join(__dirname, mailsAmountPath)).toString());
fs.writeFileSync(path.join(__dirname, mailsAmountPath), JSON.stringify({ MAX_AMOUNT, CURRENT_AMOUNT: 0 }));
});
}
} }
module.exports = HomeService; module.exports = HomeService;
...@@ -48,7 +48,11 @@ module.exports = appInfo => { ...@@ -48,7 +48,11 @@ module.exports = appInfo => {
aliyun: [ aliyun: [
{ account: 'xyqb@liangkebang.net', password: 'Ztg202020' }, { account: 'xyqb@liangkebang.net', password: 'Ztg202020' },
], ],
tecent: { account: 'Tiange.zeng@lkbang.com', password: 'Ztg2020' }, tecent: [
{ account: 'Tiange.zeng@lkbang.com', password: 'Ztg2020', index: 1 },
{ account: 'notification@lkbang.net', password: 'LHPlhp123', index: 2 },
// { account: 'notification@lkbang.cn', password: 'LHPlhp123', index: 3 },
],
smtp: { smtp: {
host: 'smtp.mxhichina.com', host: 'smtp.mxhichina.com',
port: 465, port: 465,
...@@ -59,7 +63,8 @@ module.exports = appInfo => { ...@@ -59,7 +63,8 @@ module.exports = appInfo => {
}, },
}, },
legal: { legal: {
host: 'http://back-law-urge.q-gp.com', // host: 'http://back-law-urge.q-gp.com',
host: 'https://back-law-urge-fe.liangkebang.net',
}, },
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment