Browse Source

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

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

4
app/Admin/Controllers/v3/GoodsActivityReportController.php

@ -136,7 +136,7 @@ class GoodsActivityReportController extends AdminController
// });
$marketData = $this->GoodsActivityReport->getMarketData($this->newParams);
$totalData = $this->GoodsActivityReport->getCountData($this->newParams);
$totalParams = [
'list' => $totalData,
];
@ -144,7 +144,7 @@ class GoodsActivityReportController extends AdminController
'list' => $marketData,
'markets' => $this->marketList
];
$row->column(4,new OrderGoodsActivityTotalChart($totalParams));
$row->column(4,new OrderGoodsActivityCountChart($totalParams));
$row->column(4,new OrderGoodsActivityMarketChart($marketParams));

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 ?? [];
}

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

@ -18,18 +18,20 @@ class OrderGoodsActivityCountChart extends Line
protected $data = [];
protected $total = [];
protected $valueData = [];
protected $chartData = [];
protected $GoodsActivityReport = null;
protected $showNumber = 7;
public function __construct($params = [])
{
parent::__construct();
$data = $params['list'] ?? [];
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