初始化基金监控系统项目

This commit is contained in:
LL
2025-12-12 11:54:44 +08:00
commit 354133d6e4
104 changed files with 26244 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
<?php
require_once 'api.php';
// 创建API实例
$api = new FundMonitorAPI();
// 获取当前基金数据
$fundData = $api->getFundData();
// 手动格式化监控邮件内容
$subject = "当前基金监控邮件 - " . date('Y年m月d日 H:i');
$body = "<h2>基金情况推送 - " . date('Y年m月d日') . "</h2>";
// 检查数据获取是否成功
if ($fundData['success'] && isset($fundData['data']['fundsData'])) {
$funds = $fundData['data']['fundsData'];
$errors = $fundData['data']['errors'];
$fundChannelMap = $fundData['data']['fundChannelMap'];
// 添加基金数据到邮件中
$body .= "<h3>基金列表</h3>";
$body .= "<table border='1' cellpadding='5' cellspacing='0' style='border-collapse: collapse; width: 100%;'>";
$body .= "<tr style='background-color: #f0f0f0;'><th>基金代码</th><th>基金名称</th><th>最新净值</th><th>涨跌幅</th><th>更新时间</th><th>渠道</th></tr>";
foreach ($funds as $fundCode => $fundInfo) {
$fundName = $fundInfo['name'];
$latestValue = $fundInfo['gsz'];
$changeRate = $fundInfo['gszzl'];
$updateTime = $fundInfo['gztime'];
$channelName = $fundChannelMap[$fundCode] ?? '未知渠道';
// 根据涨跌幅设置颜色
$color = $changeRate >= 0 ? '#ff0000' : '#008000';
$body .= "<tr>";
$body .= "<td>{$fundCode}</td>";
$body .= "<td>{$fundName}</td>";
$body .= "<td>{$latestValue}</td>";
$body .= "<td style='color: {$color};'>{$changeRate}%</td>";
$body .= "<td>{$updateTime}</td>";
$body .= "<td>{$channelName}</td>";
$body .= "</tr>";
}
$body .= "</table>";
// 添加错误信息
if (!empty($errors)) {
$body .= "<h3>错误信息</h3>";
$body .= "<ul>";
foreach ($errors as $error) {
$body .= "<li>{$error}</li>";
}
$body .= "</ul>";
}
// 添加时间戳
$body .= "<p style='text-align: right; font-style: italic;'>生成时间: " . date('Y年m月d日 H:i:s') . "</p>";
} else {
$body .= "<p>获取基金数据失败,请检查系统状态。</p>";
}
// 发送监控邮件
if ($api->testEmail($subject, $body)) {
echo "当前基金监控邮件发送成功!";
} else {
echo "当前基金监控邮件发送失败!";
}
?>