Browse Source

活动商品--统计,优化图表显示问题

master
liangyuyan 5 years ago
parent
commit
9fc86228b2
  1. 2
      app/Admin/Repositories/v3/GoodsActivityReport.php
  2. 23
      app/Admin/Widgets/Charts/OrderGoodsActivityCountChart.php
  3. 16
      app/Admin/Widgets/Charts/OrderGoodsActivityTotalChart.php

2
app/Admin/Repositories/v3/GoodsActivityReport.php

@ -109,7 +109,7 @@ class GoodsActivityReport extends EloquentRepository
{
$selects = "SUM(lanzu_order_goods.number) as total,SUM((original_price-price)*number) as subsidy_total,FROM_UNIXTIME(lanzu_order_goods.created_at,'%Y-%m-%d') as dtime";
$orderGoodsActivity = $this->getDataModel($selects,$params);
$total = $orderGoodsActivity->groupBy('dtime')->get()->toArray();
$total = $orderGoodsActivity->orderBy('dtime','asc')->groupBy('dtime')->get()->toArray();
return $total ?? [];
}

23
app/Admin/Widgets/Charts/OrderGoodsActivityCountChart.php

@ -18,6 +18,7 @@ class OrderGoodsActivityCountChart extends Line
protected $data = [];
protected $total = [];
protected $valueData = [];
protected $chartData = [];
protected $GoodsActivityReport = null;
protected $showNumber = 7;
@ -30,6 +31,7 @@ class OrderGoodsActivityCountChart extends Line
if(!empty($data) && is_array($data)){
$subsidyTotal = 0;
foreach($data as $key => $value){
if($key < $this->showNumber){
$this->data[] = $value['subsidy_total'];
$this->categories[] = $value['dtime'];
@ -39,22 +41,13 @@ class OrderGoodsActivityCountChart extends Line
$this->total['subsidy_total'] = $subsidyTotal;
}
$data = $this->data;
$categories = $this->categories;
$chartData = [
$this->chartData = [
[
'name' => '金额',
'data' => $data,
'data' => $this->data,
]
];
$this->withContent($this->total);
$this->withChart($chartData);
$this->withCategories($categories);
}
protected function init()
{
parent::init();
$color = Admin::color();
// 设置标题
$this->title('总补贴金额(元)');
@ -84,6 +77,14 @@ class OrderGoodsActivityCountChart extends Line
'xaxis.categories',
$this->categories
);
$this->withContent($this->total);
$this->withChart($this->chartData);
$this->withCategories($this->categories);
}
protected function init()
{
parent::init();
}
/**

16
app/Admin/Widgets/Charts/OrderGoodsActivityTotalChart.php

@ -46,14 +46,7 @@ class OrderGoodsActivityTotalChart extends Bar
'data' => $this->data,
]
];
$this->withContent($this->total);
$this->withChart($chartData);
$this->withCategories($categories);
}
protected function init()
{
parent::init();
$color = Admin::color();
// 设置标题
$this->title('销售总数量(单)');
@ -81,6 +74,15 @@ class OrderGoodsActivityTotalChart extends Bar
'xaxis.categories',
$this->categories
);
$this->withContent($this->total);
$this->withChart($chartData);
$this->withCategories($categories);
}
protected function init()
{
parent::init();
}
/**

Loading…
Cancel
Save