|
本帖最后由 vForce 于 2018-3-28 08:32 编辑
自己写的,用了挺久了。有个东二的新区没做进去,有点代码基础的朋友自己加一下吧。
两个文件放在同一目录,执行php billingReport.php即可,基于PHP5.6开发,PHP7没试过。
util.php:
[ol]', 'RCPT TO: ', 'DATA', implode("\r\n", $data) ) as $i) { fwrite($s, "$i\r\n"); $m = fgets($s); if ($m[0] > 3) return $m; } fclose($s);}[/ol]复制代码
billingReport.php:
[ol] [ "henry" => [ "Billing" => 0, "Transfer" => 0, ], "pascal" => [ "Billing" => 0, "Transfer" => 0, ], "joule" => [ "Billing" => 0, "Transfer" => 0, ], ], "jp-east-2" => [ "weber" => [ "Billing" => 0, "Transfer" => 0, ], "lux" => [ "Billing" => 0, "Transfer" => 0, ], ], "jp-west" => [ "augusta" => [ "Billing" => 0, "Transfer" => 0, ], "monstera" => [ "Billing" => 0, "Transfer" => 0, ], ]];foreach ($result['data'] as $row) { switch ($row['Category']) { case "VirtualMachine": case "Volume": $regionStatistics[$row['Region']][$row['ZoneName']]['Billing'] += $row['Net']; break; case "Internet Data Transfer": if ($row['Menu'] == "Internet Data Transfer [out]") { $regionStatistics[$row['Region']][$row['ZoneName']]['Transfer'] += $row['Usage']; } }}$mailBody = "
{$month} IDCF消费日报 总消费额:{$totalConsumption}日元(约{$totalConsumptionRMB}人民币) 以下为各区消费情况 大区Zone消费额流出流量 ";foreach ($regionStatistics as $regionName => $data) { foreach ($data as $zone => $detail) { $mailBody .= "{$regionName}$zone{$detail['Billing']}日元{$detail['Transfer']}GB"; }}$mailBody .= " ";sendMail("收件邮箱", "【IDCF】消费日报", $mailBody);[/ol]复制代码 |
|