首页统计
parent
a6289e2f83
commit
1089e782fd
|
|
@ -6,6 +6,7 @@ use App\Models\Balance;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
use App\Models\UserInfo;
|
use App\Models\UserInfo;
|
||||||
use App\Models\Wallet;
|
use App\Models\Wallet;
|
||||||
|
use Carbon\Carbon;
|
||||||
use Dcat\Admin\Widgets\Metrics\RadialBar;
|
use Dcat\Admin\Widgets\Metrics\RadialBar;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
|
@ -21,6 +22,12 @@ class StatisticsTotal extends RadialBar
|
||||||
$this->title('统计预览');
|
$this->title('统计预览');
|
||||||
$this->height(300);
|
$this->height(300);
|
||||||
$this->contentWidth(12, 0);
|
$this->contentWidth(12, 0);
|
||||||
|
// 设置下拉选项
|
||||||
|
$this->dropdown([
|
||||||
|
'1' => '当天',
|
||||||
|
'7' => '最近7天',
|
||||||
|
'30' => '最近30天',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,7 +39,25 @@ class StatisticsTotal extends RadialBar
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request)
|
public function handle(Request $request)
|
||||||
{
|
{
|
||||||
$order = Order::whereNotIn('status', [Order::STATUS_PENDING, Order::STATUS_CANCELLED])->sum('total_amount');
|
switch ($request->get('option')) {
|
||||||
|
case '30':
|
||||||
|
$start_time = Carbon::now()->subDays(29)->startOfDay();
|
||||||
|
$end_time = Carbon::now()->endOfDay();
|
||||||
|
|
||||||
|
break;
|
||||||
|
case '7':
|
||||||
|
$start_time = Carbon::now()->subDays(6)->startOfDay();
|
||||||
|
$end_time = Carbon::now()->endOfDay();
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$start_time = Carbon::now()->startOfDay();
|
||||||
|
$end_time = Carbon::now()->endOfDay();
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
$order = Order::whereBetween('created_at', [$start_time, $end_time])->whereNotIn('status', [Order::STATUS_PENDING, Order::STATUS_CANCELLED])->sum('total_amount');
|
||||||
// 卡片内容
|
// 卡片内容
|
||||||
$this->withContent([
|
$this->withContent([
|
||||||
'total_points'=> UserInfo::sum('points'),
|
'total_points'=> UserInfo::sum('points'),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue