Files
fdesk/app/common/utils/email/InquiryDigestMail.php
T
mzl92 61c34db99e feat: 新增询盘批量分配命令(骨架+Excel解析+code匹配+dry-run)
- InquiryDigestMail: 汇总邮件 HTML 模板
- InquiryBulkAssignCommand: assign 轮询、parseExcel、matchCustomers(code+排除软删除)、dry-run 报告、--self-test

写库/发邮件逻辑见后续提交。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-17 14:56:36 +08:00

56 lines
2.5 KiB
PHP

<?php
namespace app\common\utils\email;
class InquiryDigestMail
{
/**
* 构建汇总邮件 HTML
*
* @param string $userName 收件人姓名
* @param array $inquiries 询盘数组,每项含 code/contact/email/phone/country_cn/channel/remark
* @param string $date 日期串 Y-m-d
* @return string HTML
*/
public static function build(string $userName, array $inquiries, string $date): string
{
$count = count($inquiries);
$rows = '';
$idx = 1;
foreach ($inquiries as $q) {
$remark = mb_substr((string)($q['remark'] ?? ''), 0, 100);
$td = '<td style="border:1px solid #eee;padding:6px;">';
$rows .= '<tr>'
. $td . $idx++ . '</td>'
. $td . htmlspecialchars((string)($q['code'] ?? '')) . '</td>'
. $td . htmlspecialchars((string)($q['contact'] ?? '')) . '</td>'
. $td . htmlspecialchars((string)($q['email'] ?? '')) . '</td>'
. $td . htmlspecialchars((string)($q['phone'] ?? '')) . '</td>'
. $td . htmlspecialchars((string)($q['country_cn'] ?? '')) . '</td>'
. $td . htmlspecialchars((string)($q['channel'] ?? '')) . '</td>'
. $td . htmlspecialchars($remark) . '</td>'
. '</tr>';
}
$thStyle = 'style="border:1px solid #eee;padding:6px;background:#f0f0f0;"';
return '<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"></head>'
. '<body style="margin:0;padding:0;background:#f6f7f9;font-family:Arial,Helvetica,sans-serif;">'
. '<div style="max-width:960px;margin:0 auto;padding:20px;">'
. '<h2 style="color:#111;">询盘分配汇总</h2>'
. '<p>收件人:<strong>' . htmlspecialchars($userName) . '</strong> 日期:' . $date
. ' 共 <strong>' . $count . '</strong> 条</p>'
. '<table style="border-collapse:collapse;width:100%;font-size:13px;color:#333;">'
. '<thead><tr>'
. '<th ' . $thStyle . '>#</th>'
. '<th ' . $thStyle . '>编号</th>'
. '<th ' . $thStyle . '>联系人</th>'
. '<th ' . $thStyle . '>邮箱</th>'
. '<th ' . $thStyle . '>电话</th>'
. '<th ' . $thStyle . '>国家</th>'
. '<th ' . $thStyle . '>渠道</th>'
. '<th ' . $thStyle . '>意向/备注</th>'
. '</tr></thead><tbody>'
. $rows
. '</tbody></table></div></body></html>';
}
}