diff --git a/application/api/controller/EmailClient.php b/application/api/controller/EmailClient.php index 542e7ba..aebf240 100644 --- a/application/api/controller/EmailClient.php +++ b/application/api/controller/EmailClient.php @@ -299,16 +299,17 @@ class EmailClient extends Base $expert = Db::name('expert')->where('expert_id', $expertId)->find(); if (!$expert) { return jsonError('expert not found'); - } - if (empty($expert['field'])) { - $fieldRow = Db::name('expert_field') - ->where('expert_id', $expertId) - ->where('state', 0) - ->order('expert_field_id asc') - ->find(); - if ($fieldRow) { - $expert['field'] = $fieldRow['field']; + }else{ + $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'] = $field_str; } $expertVars = $service->buildExpertVars($expert); } else { diff --git a/application/common/PromotionService.php b/application/common/PromotionService.php index a9ebc79..e459ff6 100644 --- a/application/common/PromotionService.php +++ b/application/common/PromotionService.php @@ -90,6 +90,16 @@ 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'] = $field_str; $expertVars = $this->buildExpertVars($expert); $journalVars = $this->buildJournalVars($journal); $vars = array_merge($journalVars, $expertVars); @@ -194,6 +204,17 @@ class PromotionService ]); $failed++; continue; + }else{ + $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'] = $field_str; } $expertVars = $this->buildExpertVars($expert);