<?php
/**
 * Created by PhpStorm.
 * User: 陈武杰
 * Date: 2021/1/13
 * Time: 17:34
 */

namespace App\Admin\Controllers\DataCenter;
use App\Admin\Controllers\Chart\OrderChart;
use App\Admin\Controllers\Sta;
use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\Dashboard;
use Encore\Admin\Layout\Column;
use Encore\Admin\Layout\Content;
use Encore\Admin\Layout\Row;
use Encore\Admin\Widgets\InfoBox;


class FinancialOverview
{
    public function index(Content $content)
    {
        return $content
            ->title('欢迎进入后台管理系统')
            ->description('后台数据中心')
            ->row('<h1 text-align="center">财务概况</h1>')
            ->row(function (Row $row) {
                // 产品类型(1.电话咨询 2.图文咨询 3.门诊预约 4.疫苗接种预约 5.儿保预约 6.服务包 7.充值)
                $row->column(3, function (Column $column) {
                    $column->append(infoBox('收入总金额', 'dropbox', '', 'green', FinancialSta::getTotalIncome()));
                });
                $row->column(3, function (Column $column) {
                    $column->append(infoBox('退款总金额', 'dropbox', '', 'green', FinancialSta::getTotalRefund()));
                });
                $row->column(3, function (Column $column) {
                    $column->append(infoBox('用户充值总金额', 'dropbox', '', 'green', FinancialSta::getTotalRecharge()));
                });
                $row->column(3, function (Column $column) {
                    $column->append(infoBox('用户总余额', 'dropbox', '', 'green', FinancialSta::getTotalUserBalance()));
                });
            })
            ->row('<h1 text-align="center">充值记录</h1>')
            ->row(function (Row $row){
                $row->column(3,function (Column $column){
                    $column->append(infoBox('当日充值金额', 'dropbox', '', 'green', FinancialSta::getTodayReCharge()));
                });
                $row->column(3,function (Column $column){
                    $column->append(infoBox('近七日充值金额', 'dropbox', '', 'green', FinancialSta::getSevenDayReCharge()));
                });
                $row->column(3,function (Column $column){
                    $column->append(infoBox('近三十日充值金额', 'dropbox', '', 'green', FinancialSta::getOneMonthReCharge()));
                });
            })
            ->row(function (Row $row){
                (new FinancialRechargeChart())->chart($row);
            })
            ;
    }

}
/**
 * 消息框
 * @param $name
 * @param $icon
 * @param $link
 * @param $color
 * @param $info
 * @return string HTML
 */

function infoBox($name, $icon, $link, $color, $info)
{
    return (new InfoBox($name, $icon, $color, $link, $info))->render();
}
