修改自动推广的相关任务 退订相关

This commit is contained in:
wangjinlei
2026-04-27 14:53:46 +08:00
parent 1ff6bef655
commit 5645b87669
7 changed files with 362 additions and 6 deletions

View File

@@ -411,10 +411,14 @@ class EmailClient extends Base
}
$ids = array_map('intval', explode(',', $expertIds));
$experts = Db::name('expert')->where('expert_id', 'in', $ids)->where('state', 0)->select();
$experts = Db::name('expert')
->where('expert_id', 'in', $ids)
->where('state', 0)
->where('unsubscribed', 0)
->select();
if (empty($experts)) {
return jsonError('No valid experts found (state must be 0)');
return jsonError('No valid experts found (state must be 0 and not unsubscribed)');
}
$sent = 0;
@@ -2475,6 +2479,7 @@ class EmailClient extends Base
$query = Db::name('expert')->alias('e')
->join('t_expert_field ef', 'e.expert_id = ef.expert_id', 'inner')
->where('e.state', 0)
->where('e.unsubscribed', 0)
->where('ef.state', 0);
$query->where(function ($q) use ($fields) {
@@ -2631,11 +2636,20 @@ class EmailClient extends Base
private function buildExpertVars($expert)
{
$unsubUrl = '';
if (!empty($expert['expert_id']) && !empty($expert['email'])) {
$unsubUrl = \app\common\UnsubscribeService::buildUrl(
intval($expert['expert_id']),
(string)$expert['email']
);
}
return [
'name' => $expert['name'] ?? '',
'email' => $expert['email'] ?? '',
'affiliation' => $expert['affiliation'] ?? '',
'field' => $expert['field'] ?? '',
'name' => $expert['name'] ?? '',
'email' => $expert['email'] ?? '',
'affiliation' => $expert['affiliation'] ?? '',
'field' => $expert['field'] ?? '',
'unsubscribe_url' => $unsubUrl,
];
}