修改名称+增加查看数据脚本

This commit is contained in:
2020-09-18 14:59:40 +08:00
parent 6be99a2655
commit 90eff982d2
8 changed files with 149 additions and 39 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Admin\Controllers\Activity;
use App\Admin\Renderable\Activity\Grants;
use App\Models\Activity;
use App\Models\ActivityGrant;
use App\Models\ActivityRule;
@@ -86,7 +87,6 @@ class IndexController extends AdminController
$query->where('identity_id', 1);
})->get()->pluck('nickname', 'id');
$filter->equal('user_id', '渠道')->select($users);
});
$filter->column(1 / 2, function ($filter) {
@@ -100,10 +100,6 @@ class IndexController extends AdminController
$grid->column('title', '活动名称');
$grid->column('code', '活动编号');
$grid->column('rule.code', '卡券规则');
$grid->column('所属')->display(function () {
return $this->user_id ? $this->user->nickname : '系统';
});
$grid->column('类型')->display(function () {
return $this->type_text;
});
@@ -111,6 +107,20 @@ class IndexController extends AdminController
$grid->column('days', '延期(天)');
$grid->column('rule.full', '满足金额');
$grid->column('rule.take', '扣除金额');
$grid->column('发券')
->display(function () {
return $this->grants->pluck('user_nickname');
})
->label()
->hide();
$grid->column('核券')
->display(function () {
return $this->verifications->pluck('user_nickname');
})
->label()
->hide();
$grid->column('开始时间')->display(function () {
return $this->type == Activity::TYPE_SCOPE ? $this->start_at->format('Y-m-d') : '---';
});

View File

@@ -0,0 +1,72 @@
<?php
namespace App\Admin\Controllers;
use App\Models\Coupon;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class TestController
{
public function index(Request $request)
{
$date = $request->date ?? date('Y-m-d');
$time = Carbon::parse($date);
$all = Coupon::where('status', 2)
->whereBetween('created_at', [
$time->startOfDay()->toDateTimeString(),
$time->endOfDay()->toDateTimeString(),
])
->count();
$self = Coupon::where('status', 2)
->where('type', Coupon::TYPE_YSD)
->whereBetween('created_at', [
$time->startOfDay()->toDateTimeString(),
$time->endOfDay()->toDateTimeString(),
])
->count();
$pingan = Coupon::where('status', 2)
->where('type', Coupon::TYPE_PINGAN)
->whereBetween('created_at', [
$time->startOfDay()->toDateTimeString(),
$time->endOfDay()->toDateTimeString(),
])
->count();
$error = Coupon::where('status', 3)
->whereBetween('created_at', [
$time->startOfDay()->toDateTimeString(),
$time->endOfDay()->toDateTimeString(),
])
->count();
$lists = DB::table('coupons')
->where('status', 2)
->whereBetween('created_at', [
$time->startOfDay()->toDateTimeString(),
$time->endOfDay()->toDateTimeString(),
])
->select('redemptionCode', DB::raw('COUNT(*) as code_count'))
->groupBy('redemptionCode')
->having('code_count', '>', 1)
->get();
$data = [
' 日期为:' . $time->format('Y-m-d'),
' 核销总数为:' . $all,
' 自有卡券总数为:' . $self,
' 平安卡券总数为:' . $pingan,
' 核销错误总数为:' . $error,
' 核销重复数据数为:' . $lists->count(),
];
foreach ($data as $info) {
dump($info);
}
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Admin\Renderable\Activity;
use App\Models\Activity;
use Encore\Admin\Widgets\Table;
use Illuminate\Contracts\Support\Renderable;
class Grants implements Renderable
{
public function render($key = null)
{
$activity = Activity::find($key);
$items = $activity->grants->map(function ($info) {
return [
'id' => $info->id,
'nickname' => $info->user_nickname,
];
});
dd($items->toArray());
return new Table(['Id', '渠道'], $items->toArray());
}
}

View File

@@ -11,6 +11,8 @@ Route::group([
], function (Router $router) {
$router->get('/', 'HomeController@index')->name('admin.home');
$router->get('test', 'TestController@index')->name('test.index');
$router->post('uploads/editor', 'UploadController@editor')->name('uploads.editor');
/**

View File

@@ -11,7 +11,7 @@ return [
| login page.
|
*/
'name' => '平安接口系统',
'name' => '平安券核销管理系统',
/*
|--------------------------------------------------------------------------
@@ -22,7 +22,7 @@ return [
| `img` tag, eg '<img src="http://logo-url" alt="Admin logo">'.
|
*/
'logo' => '平安接口系统',
'logo' => '平安券核销管理系统',
/*
|--------------------------------------------------------------------------
@@ -58,9 +58,9 @@ return [
*/
'route' => [
'prefix' => env('ADMIN_ROUTE_PREFIX', 'admin'),
'prefix' => env('ADMIN_ROUTE_PREFIX', 'admin'),
'namespace' => 'App\\Admin\\Controllers',
'namespace' => 'App\\Admin\\Controllers',
'middleware' => ['web', 'admin'],
],
@@ -110,11 +110,11 @@ return [
*/
'auth' => [
'controller' => App\Admin\Controllers\AuthController::class,
'controller' => App\Admin\Controllers\AuthController::class,
'guard' => 'admin',
'guard' => 'admin',
'guards' => [
'guards' => [
'admin' => [
'driver' => 'session',
'provider' => 'admin',

View File

@@ -13,7 +13,7 @@ return [
|
*/
'defaults' => [
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
@@ -35,8 +35,8 @@ return [
|
*/
'guards' => [
'web' => [
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
@@ -69,7 +69,7 @@ return [
|
*/
'providers' => [
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
@@ -96,7 +96,7 @@ return [
|
*/
'passwords' => [
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',

View File

@@ -31,18 +31,18 @@ return [
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'useTLS' => true,
'useTLS' => true,
],
],
'redis' => [
'driver' => 'redis',
'driver' => 'redis',
'connection' => 'default',
],

View File

@@ -42,46 +42,46 @@ return [
],
'database' => [
'driver' => 'database',
'table' => 'cache',
'driver' => 'database',
'table' => 'cache',
'connection' => null,
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
'path' => storage_path('framework/cache/data'),
],
'memcached' => [
'driver' => 'memcached',
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'redis',
'driver' => 'redis',
'connection' => 'cache',
],
'dynamodb' => [
'driver' => 'dynamodb',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
'driver' => 'dynamodb',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
'endpoint' => env('DYNAMODB_ENDPOINT'),
],
@@ -98,6 +98,6 @@ return [
|
*/
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache'),
];