This commit is contained in:
wangjinlei
2026-04-17 09:51:09 +08:00
parent e9a354c663
commit 4417a7ea28
5 changed files with 314 additions and 41 deletions

View File

@@ -90,16 +90,23 @@ class PromotionService
$body = $logEntry['body_prepared'];
} else {
$journal = Db::name('journal')->where('journal_id', $task['journal_id'])->find();
$expert_fields = Db::name('expert_fields')->where('expert_id', $expert['expert_id'])->select();
$field_str = '';
foreach ($expert_fields as $field){
if($field_str != ''){
$field_str .= ','.$field['field_name'];
}else{
$field_str = $field['field_name'];
$expert_fields = Db::name('expert_field')
->where('expert_id', $expert['expert_id'])
->where('state', 0)
->select();
$fieldSet = [];
$representativeTitle = '';
foreach ($expert_fields as $ef) {
$fn = trim($ef['field']);
if ($fn !== '' && !in_array($fn, $fieldSet)) {
$fieldSet[] = $fn;
}
if ($representativeTitle === '' && !empty($ef['paper_title'])) {
$representativeTitle = trim($ef['paper_title']);
}
}
$expert['fields'] = $field_str;
$expert['fields'] = implode(',', $fieldSet);
$expert['representative_work_title'] = $representativeTitle;
$expertVars = $this->buildExpertVars($expert);
$journalVars = $this->buildJournalVars($journal);
$vars = array_merge($journalVars, $expertVars);
@@ -204,19 +211,27 @@ class PromotionService
]);
$failed++;
continue;
}else{
$expert_fields = Db::name('expert_field')->where('expert_id', $expert['expert_id'])->select();
$field_str = '';
foreach ($expert_fields as $field){
if($field_str != ''){
$field_str .= ','.$field['field'];
}else{
$field_str = $field['field'];
}
}
$expert['fields'] = $field_str;
}
$expert_fields = Db::name('expert_field')
->where('expert_id', $expert['expert_id'])
->where('state', 0)
->select();
$fieldSet = [];
$representativeTitle = '';
foreach ($expert_fields as $ef) {
$fn = trim($ef['field']);
if ($fn !== '' && !in_array($fn, $fieldSet)) {
$fieldSet[] = $fn;
}
if ($representativeTitle === '' && !empty($ef['paper_title'])) {
$representativeTitle = trim($ef['paper_title']);
}
}
$expert['fields'] = implode(',', $fieldSet);
$expert['representative_work_title'] = $representativeTitle;
$expertVars = $this->buildExpertVars($expert);
$vars = array_merge($journalVars, $expertVars);
$rendered = $this->renderFromTemplate(
@@ -477,11 +492,12 @@ class PromotionService
public function buildExpertVars($expert)
{
return [
'expert_title' => "Ph.D",
'expert_title' => "Ph.D",
'expert_name' => $expert['name'] ?? '',
'expert_email' => $expert['email'] ?? '',
'expert_affiliation' => $expert['affiliation'] ?? '',
'expert_field' => $expert['field'] ?? '',
'expert_field' => $expert['fields'] ?? ($expert['field'] ?? ''),
'representative_work_title' => $expert['representative_work_title'] ?? '',
];
}