diff --git a/app/Admin/Controllers/MonthlyStatisticsController.php b/app/Admin/Controllers/MonthlyStatisticsController.php new file mode 100644 index 00000000..0be6acdd --- /dev/null +++ b/app/Admin/Controllers/MonthlyStatisticsController.php @@ -0,0 +1,84 @@ +header('首页') + ->description('首页') + ->body(function (Row $row) { + if (blank($date = request('date'))) { + $date = date('Y-m'); + } + + $start = Carbon::parse($date)->startOfMonth(); + $end = $start->copy()->endOfMonth(); + + $row->column(12, function (Column $column) use ($date) { + $form = << +
+ +
+ + + + +
+
+ + + HTML; + + $column->row(new Card(null, $form)); + }); + + $totalPreIncome = WalletLog::where('loggable_type', 'distribution_pre_income') + ->whereBetween('created_at', [$start, $end]) + ->sum('change_balance'); + + // 提现总额 + $withdrawAmount = WalletToBankLog::where('status', WalletToBankLog::STATUS_AGREE) + ->whereBetween('updated_at', [$start, $end]) + ->sum('amount'); + + // 余额支付总额 + $totalOrderAmount = Order::where('status', Order::STATUS_COMPLETED) + ->whereBetween('completed_at', [$start, $end]) + ->where('pay_way', PayWay::Balance) + ->sum('total_amount'); + + $row->column(3, new InfoBox('返利总额', bcdiv($totalPreIncome, '100', 2), 'fa fa-cny')); + $row->column(3, new InfoBox('提现总额', bcdiv($withdrawAmount, '100', 2), 'fa fa-cny')); + $row->column(3, new InfoBox('余额支付总额', bcdiv($totalOrderAmount, '100', 2), 'fa fa-cny')); + }); + } +} diff --git a/app/Admin/routes.php b/app/Admin/routes.php index cb521eb3..fcb2e921 100644 --- a/app/Admin/routes.php +++ b/app/Admin/routes.php @@ -168,6 +168,7 @@ Route::group([ ['index'] )->names('sales_value_logs'); + $router->get('monthly-statistics', 'MonthlyStatisticsController@index')->name('monthly-statistics.index'); //经销商 $router->resource('dealer-products', 'DealerProductController')->names('dealer_products'); diff --git a/database/seeders/AdminPermissionSeeder.php b/database/seeders/AdminPermissionSeeder.php index fc5e274f..4c58862d 100644 --- a/database/seeders/AdminPermissionSeeder.php +++ b/database/seeders/AdminPermissionSeeder.php @@ -414,6 +414,10 @@ class AdminPermissionSeeder extends Seeder 'name' =>'活动管理', 'curd' => true, ], + 'monthly-statistics' => [ + 'name' => '每月统计', + 'curd' => ['index'], + ], ]; // try { // DB::begintransaction();