|
|
|
@ -7,8 +7,10 @@ namespace App\Admin\Controllers\v3; |
|
|
|
|
|
|
|
use App\Admin\Actions\Tools\DataReportDate; |
|
|
|
use App\Admin\Actions\Tools\DataReportOption; |
|
|
|
use App\Admin\Common\Order; |
|
|
|
use App\Admin\Extensions\Chart\Bar\OrderBar; |
|
|
|
use App\Models\LanzuStore; |
|
|
|
use App\Models\v3\User; |
|
|
|
use Dcat\Admin\Form; |
|
|
|
use Dcat\Admin\Grid; |
|
|
|
use Dcat\Admin\Layout\Column; |
|
|
|
@ -25,9 +27,37 @@ class DataReport |
|
|
|
* @param Content $content |
|
|
|
* @return Content |
|
|
|
*/ |
|
|
|
public function index(Content $content) |
|
|
|
protected $_amount; |
|
|
|
protected $_number; |
|
|
|
protected $_count_user; |
|
|
|
public function __construct() |
|
|
|
{ |
|
|
|
$option = request()->get('option'); |
|
|
|
$this->_amount = Order::getOrderData([ |
|
|
|
'user_type'=>'market_service',//谁取数据 user_type 用户类型
|
|
|
|
'data_type'=>'amount',//取什么数据 data_type 数据类型
|
|
|
|
'market_id'=>'',//取哪个市场数据
|
|
|
|
'condition'=>1,//取数据维度 condition
|
|
|
|
'user_ids'=>null |
|
|
|
],$option); |
|
|
|
$this->_number = Order::getOrderData([ |
|
|
|
'user_type'=>'market_service',//谁取数据 user_type 用户类型
|
|
|
|
'data_type'=>'number',//取什么数据 data_type 数据类型
|
|
|
|
'market_id'=>'',//取哪个市场数据
|
|
|
|
'condition'=>1,//取数据维度 condition
|
|
|
|
'user_ids'=>null |
|
|
|
],$option); |
|
|
|
$this->_count_user = Order::getOrderData([ |
|
|
|
'user_type'=>'market_service',//谁取数据 user_type 用户类型
|
|
|
|
'data_type'=>'count_user',//取什么数据 data_type 数据类型
|
|
|
|
'market_id'=>'',//取哪个市场数据
|
|
|
|
'condition'=>1,//取数据维度 condition
|
|
|
|
'user_ids'=>null |
|
|
|
],$option); |
|
|
|
} |
|
|
|
|
|
|
|
public function index(Content $content) |
|
|
|
{ |
|
|
|
return $content |
|
|
|
->header('数据统计') |
|
|
|
->body(function (Row $row){ |
|
|
|
@ -45,42 +75,47 @@ class DataReport |
|
|
|
})->body('<hr />') |
|
|
|
->body(function (Row $row){ |
|
|
|
$row->column(2,function (Column $column){ |
|
|
|
$title = "营业总额(元)"; |
|
|
|
$value = 0; |
|
|
|
$title = "订单总额(元)"; |
|
|
|
$value = $this->_amount; |
|
|
|
$card = Card::make("<span style='color: #ffffff'>{$title}</span>","<span style='color: #ffffff'>{$value}</span>"); |
|
|
|
$card->style('background-color:#4e9876'); |
|
|
|
$column->row($card); |
|
|
|
}); |
|
|
|
$row->column(2,function (Column $column){ |
|
|
|
$title = "总入账(元)"; |
|
|
|
$value = 0; |
|
|
|
$title = "订单数"; |
|
|
|
$value = $this->_number; |
|
|
|
$card = Card::make("<span style='color: #ffffff'>{$title}</span>","<span style='color: #ffffff'>{$value}</span>"); |
|
|
|
$card->style('background-color:#4e9876'); |
|
|
|
$column->row($card); |
|
|
|
}); |
|
|
|
$row->column(2,function (Column $column) { |
|
|
|
$title = "商户实际收"; |
|
|
|
$value = 0; |
|
|
|
$title = "下单人数"; |
|
|
|
$value =$this->_count_user; |
|
|
|
$card = Card::make("<span style='color: #ffffff'>{$title}</span>","<span style='color: #ffffff'>{$value}</span>"); |
|
|
|
$card->style('background-color:#4e9876'); |
|
|
|
$column->row($card); |
|
|
|
}); |
|
|
|
$row->column(2,function (Column $column){ |
|
|
|
$title = "有效订单量"; |
|
|
|
$title = "人均单价(元)"; |
|
|
|
if ($this->_amount){ |
|
|
|
$value = sprintf("%.2f",$this->_amount/$this->_count_user); |
|
|
|
}else{ |
|
|
|
$value=0; |
|
|
|
} |
|
|
|
|
|
|
|
$card = Card::make("<span style='color: #ffffff'>{$title}</span>","<span style='color: #ffffff'>{$value}</span>"); |
|
|
|
$card->style('background-color:#4e9876'); |
|
|
|
$column->row($card); |
|
|
|
}); |
|
|
|
$row->column(2,function (Column $column){ |
|
|
|
$title = "无效订单量"; |
|
|
|
$value = 0; |
|
|
|
$title = "有效用户总数"; |
|
|
|
$value = User::where('nick_name','!=','')->count(); |
|
|
|
$card = Card::make("<span style='color: #ffffff'>{$title}</span>","<span style='color: #ffffff'>{$value}</span>"); |
|
|
|
$card->style('background-color:#4e9876'); |
|
|
|
$column->row($card); |
|
|
|
}); |
|
|
|
$row->column(2,function (Column $column){ |
|
|
|
$title = "佣金收入"; |
|
|
|
$title = "佣金收入(元)"; |
|
|
|
$value = 0; |
|
|
|
$card = Card::make("<span style='color: #ffffff'>{$title}</span>","<span style='color: #ffffff'>{$value}</span>"); |
|
|
|
$card->style('background-color:#4e9876'); |
|
|
|
@ -109,6 +144,11 @@ class DataReport |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 订单数据 |
|
|
|
* @param array $params |
|
|
|
* @return array[]|string[] |
|
|
|
*/ |
|
|
|
public function orderData($params=[]) |
|
|
|
{ |
|
|
|
$where['type'] = $params['type']; |
|
|
|
@ -130,4 +170,11 @@ class DataReport |
|
|
|
return ['time'=>'','num'=>'','amount'=>'']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getOrderData() |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |