You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
2.2 KiB
101 lines
2.2 KiB
<?php
|
|
|
|
namespace App\Admin\Metrics\Examples\Order;
|
|
|
|
|
|
use App\Admin\Common\Order;
|
|
use App\Models\ImsCjdcOrder;
|
|
use App\Models\ImsCjdcOrderMain;
|
|
use Dcat\Admin\Widgets\Metrics\Card;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class OrderData extends Card
|
|
{
|
|
protected $params;
|
|
public function __construct($title=null,$data=[])
|
|
{
|
|
$this->params = $data;
|
|
parent::__construct($title, null);
|
|
}
|
|
|
|
public function init()
|
|
{
|
|
parent::init(); // TODO: Change the autogenerated stub
|
|
$this->dropdown([
|
|
'1' => '今日',
|
|
'-1' => '昨日',
|
|
'7' => '最近7天',
|
|
'w' => '本周',
|
|
'lw' => '上周',
|
|
'30' => '本月',
|
|
'-30' => '上月'
|
|
]);
|
|
|
|
}
|
|
|
|
public function handle(Request $request)
|
|
{
|
|
$params = $request->get('params');//参数选项
|
|
$option = $request->get('option');//数据选项
|
|
//获取订单数据
|
|
$result = $this->getOrderData($params,$option);
|
|
$this->content($result);
|
|
}
|
|
|
|
/**
|
|
* 查询结果
|
|
* @param $params
|
|
* @param $option
|
|
* @return int
|
|
*/
|
|
public function getOrderData($params,$option)
|
|
{
|
|
$result = Order::getOrderData($params,$option);
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* 查询时间范围
|
|
* @param $option
|
|
* @return array
|
|
*/
|
|
public function beginAndEnd($option)
|
|
{
|
|
list($beginTime,$endTime) = Order::beginAndEnd($option);
|
|
return [$beginTime,$endTime];
|
|
}
|
|
|
|
/**
|
|
* 构建数据模型
|
|
* @param $condition
|
|
* @return mixed
|
|
*/
|
|
public function buildData()
|
|
{
|
|
$build = Order::buildData();
|
|
return $build;
|
|
}
|
|
|
|
// 传递自定义参数到 handle 方法
|
|
public function parameters(): array
|
|
{
|
|
return [
|
|
'params'=>$this->params
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 渲染卡片内容
|
|
* @return string
|
|
*/
|
|
public function renderContent()
|
|
{
|
|
$content = parent::renderContent();
|
|
return <<<HTML
|
|
<div class="d-flex justify-content-between bg-primary align-items-center mt-1" style="margin-bottom: 2px">
|
|
<h2 class="ml-1 font-large-1">{$content}</h2>
|
|
</div>
|
|
HTML;
|
|
}
|
|
}
|