<?php

namespace Manage\Plugin;

use Dever;

class Console
{
    public function data()
    {
        $where['start'] = Dever::maketime(date('Y-m-d 00:00:00'));
        $where['end'] = Dever::maketime(date('Y-m-d 23:59:59'));

        $where['status'] = '1,2,3,4,5,6';
        $today_sell_cash = Dever::db('shop/sell_order')->getCashNum($where);
        $today_sell_order = Dever::db('shop/sell_order')->getOrderNum($where);

        $where['status'] = '1,2,3,4,5,6';
        $today_buy_cash = Dever::db('shop/buy_order')->getCashNum($where);
        $today_buy_order = Dever::db('shop/buy_order')->getOrderNum($where);

        $today_user = Dever::db('passport/user')->total($where);
        $user = Dever::db('passport/user')->total();
        $shop = Dever::db('shop/info')->total();
        $factory = Dever::db('factory/info')->total();
        $store = Dever::db('store/info')->total();

        $total = 0;
        $data[] = array
        (
            'name' => '当日销售额',
            'num' => $today_sell_cash['total'] ? round($today_sell_cash['total'], 2) : 0,
            'href' => '#',
        );

        $data[] = array
        (
            'name' => '销售订单量',
            'num' => $today_sell_order,
            'href' => '#',
        );

        $data[] = array
        (
            'name' => '采购额',
            'num' => $today_buy_cash['total'] ? round($today_buy_cash['total'], 2) : 0,
            'href' => '#',
        );

        $data[] = array
        (
            'name' => '采购订单量',
            'num' => $today_buy_order,
            'href' => '#',
        );

        $data[] = array
        (
            'name' => '当日用户新增',
            'num' => $today_user,
            'href' => '#',
        );

        $data[] = array
        (
            'name' => '用户总量',
            'num' => $user,
            'href' => '#',
        );

        $data[] = array
        (
            'name' => '门店数',
            'num' => $shop,
            'href' => '#',
        );

        $data[] = array
        (
            'name' => '仓库数/工厂数',
            'num' => $store . ' / ' . $factory,
            'href' => '#',
        );


        return $data;
    }
}