6
0
Fork 0

Merge branch 'develop' of gitee.com:zi-chunsheng-e-commerce/mall-server

release
李静 2022-04-02 15:00:08 +08:00
commit 13e7af3996
5 changed files with 92 additions and 1 deletions

View File

@ -0,0 +1,83 @@
<?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('每月统计')
->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'));
});
}
}

View File

@ -295,6 +295,9 @@ class UserController extends AdminController
$user->update([
'phone'=>null,
]);
//删除当前登录token
$user->tokens()->delete();
// return response('删除成功');
return response()->json([
'status'=> true,

View File

@ -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');

View File

@ -29,7 +29,7 @@ class Kernel extends ConsoleKernel
->runInBackground();
$schedule->command('dealer:purchase-subsidy-settle')
->twiceMonthly(20, '3:00')
->monthlyOn(20, '3:00')
->runInBackground();
$schedule->command('dealer:manager-subsidy-settle')

View File

@ -414,6 +414,10 @@ class AdminPermissionSeeder extends Seeder
'name' =>'活动管理',
'curd' => true,
],
'monthly-statistics' => [
'name' => '每月统计',
'curd' => ['index'],
],
];
// try {
// DB::begintransaction();