This commit is contained in:
张成
2025-12-10 09:58:22 +08:00
parent e77f004dcc
commit 5d1e34ff65
2 changed files with 60 additions and 7 deletions

View File

@@ -56,6 +56,48 @@ class TaskHandlers {
const pla_account = db.getModel('pla_account');
const resume_info = db.getModel('resume_info');
const job_types = db.getModel('job_types');
const apply_records = db.getModel('apply_records');
const Sequelize = require('sequelize');
const { op } = Sequelize;
// 检查今日投递次数限制
const currentPlatform = platform || 'boss';
const dailyLimit = config.getDailyLimit('apply', currentPlatform);
// 获取今日开始时间00:00:00
const today = new Date();
today.setHours(0, 0, 0, 0);
// 查询今日已投递次数
const todayApplyCount = await apply_records.count({
where: {
sn_code: sn_code,
platform: currentPlatform,
applyTime: {
[op.gte]: today
}
}
});
console.log(`[任务处理器] 今日已投递 ${todayApplyCount} 次,限制: ${dailyLimit}`);
// 如果已达到每日投递上限,则跳过
if (todayApplyCount >= dailyLimit) {
console.log(`[任务处理器] 已达到每日投递上限(${dailyLimit}次),跳过投递`);
return {
success: false,
deliveredCount: 0,
message: `已达到每日投递上限(${dailyLimit}次),今日已投递 ${todayApplyCount}`
};
}
// 计算本次可投递的数量(不超过剩余限额)
const remainingQuota = dailyLimit - todayApplyCount;
const actualMaxCount = Math.min(maxCount || 10, remainingQuota);
if (actualMaxCount < (maxCount || 10)) {
console.log(`[任务处理器] 受每日投递上限限制,本次最多投递 ${actualMaxCount} 个职位(剩余限额: ${remainingQuota}`);
}
// 1. 检查并获取在线简历如果2小时内没有获取
const twoHoursAgo = new Date(Date.now() - 2 * 60 * 60 * 1000);
@@ -167,7 +209,7 @@ class TaskHandlers {
applyStatus: 'pending'
},
order: [['create_time', 'DESC']],
limit: (maxCount || 10) * 3 // 获取更多职位用于筛选
limit: actualMaxCount * 3 // 获取更多职位用于筛选(受每日投递上限限制)
});
if (!pendingJobs || pendingJobs.length === 0) {
@@ -199,8 +241,7 @@ class TaskHandlers {
const maxSalary = filterRules.maxSalary || 0;
// 获取一个月内已投递的公司列表(用于过滤)
const apply_records = db.getModel('apply_records');
const Sequelize = require('sequelize');
// 注意:apply_records 和 Sequelize 已在方法开头定义
const oneMonthAgo = new Date();
oneMonthAgo.setMonth(oneMonthAgo.getMonth() - 1);
@@ -287,8 +328,8 @@ class TaskHandlers {
// 按总分降序排序
scoredJobs.sort((a, b) => b.matchScore - a.matchScore);
// 取前 maxCount 个职位
const jobsToDeliver = scoredJobs.slice(0, maxCount || 10);
// 取前 actualMaxCount 个职位(受每日投递上限限制)
const jobsToDeliver = scoredJobs.slice(0, actualMaxCount);
console.log(`[任务处理器] 职位评分完成,共 ${pendingJobs.length} 个职位,评分后 ${scoredJobs.length} 个符合条件,将投递 ${jobsToDeliver.length}`);