每月统计
parent
a96e157868
commit
5fd5aebbac
|
|
@ -0,0 +1,84 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Admin\Widgets\InfoBox;
|
||||||
|
use App\Enums\PayWay;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Order;
|
||||||
|
use App\Models\WalletLog;
|
||||||
|
use App\Models\WalletToBankLog;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Dcat\Admin\Admin;
|
||||||
|
use Dcat\Admin\Layout\Column;
|
||||||
|
use Dcat\Admin\Layout\Content;
|
||||||
|
use Dcat\Admin\Layout\Row;
|
||||||
|
use Dcat\Admin\Widgets\Card;
|
||||||
|
|
||||||
|
class MonthlyStatisticsController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Content $content)
|
||||||
|
{
|
||||||
|
Admin::requireAssets(['moment', 'bootstrap-datetimepicker']);
|
||||||
|
|
||||||
|
Admin::script(
|
||||||
|
<<<JS
|
||||||
|
$('#month-picker').datetimepicker({
|
||||||
|
locale: 'zh_CN',
|
||||||
|
viewMode: 'years',
|
||||||
|
format: 'YYYY-MM'
|
||||||
|
});
|
||||||
|
JS
|
||||||
|
);
|
||||||
|
|
||||||
|
return $content
|
||||||
|
->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
|
||||||
|
<form class="form-inline">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>日期</label>
|
||||||
|
<div class="input-group mx-1">
|
||||||
|
<span class="input-group-prepend">
|
||||||
|
<span class="input-group-text bg-white"><i class="fa fa-calendar fa-fw"></i></span>
|
||||||
|
</span>
|
||||||
|
<input type="text" class="form-control" name="date" id='month-picker' placeholder="日期" value="$date" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">查询</button>
|
||||||
|
</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'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -168,6 +168,7 @@ Route::group([
|
||||||
['index']
|
['index']
|
||||||
)->names('sales_value_logs');
|
)->names('sales_value_logs');
|
||||||
|
|
||||||
|
$router->get('monthly-statistics', 'MonthlyStatisticsController@index')->name('monthly-statistics.index');
|
||||||
|
|
||||||
//经销商
|
//经销商
|
||||||
$router->resource('dealer-products', 'DealerProductController')->names('dealer_products');
|
$router->resource('dealer-products', 'DealerProductController')->names('dealer_products');
|
||||||
|
|
|
||||||
|
|
@ -414,6 +414,10 @@ class AdminPermissionSeeder extends Seeder
|
||||||
'name' =>'活动管理',
|
'name' =>'活动管理',
|
||||||
'curd' => true,
|
'curd' => true,
|
||||||
],
|
],
|
||||||
|
'monthly-statistics' => [
|
||||||
|
'name' => '每月统计',
|
||||||
|
'curd' => ['index'],
|
||||||
|
],
|
||||||
];
|
];
|
||||||
// try {
|
// try {
|
||||||
// DB::begintransaction();
|
// DB::begintransaction();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue