From 90eff982d2d0e737849ca21fce793585332d0f36 Mon Sep 17 00:00:00 2001 From: xuanchen <122383162@qq.com> Date: Fri, 18 Sep 2020 14:59:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=8D=E7=A7=B0+=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=9F=A5=E7=9C=8B=E6=95=B0=E6=8D=AE=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Activity/IndexController.php | 20 ++++-- app/Admin/Controllers/TestController.php | 72 +++++++++++++++++++ app/Admin/Renderable/Activity/Grants.php | 26 +++++++ app/Admin/routes.php | 2 + config/admin.php | 14 ++-- config/auth.php | 10 +-- config/broadcasting.php | 12 ++-- config/cache.php | 32 ++++----- 8 files changed, 149 insertions(+), 39 deletions(-) create mode 100644 app/Admin/Controllers/TestController.php create mode 100644 app/Admin/Renderable/Activity/Grants.php diff --git a/app/Admin/Controllers/Activity/IndexController.php b/app/Admin/Controllers/Activity/IndexController.php index 0c352cf..9508774 100644 --- a/app/Admin/Controllers/Activity/IndexController.php +++ b/app/Admin/Controllers/Activity/IndexController.php @@ -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') : '---'; }); diff --git a/app/Admin/Controllers/TestController.php b/app/Admin/Controllers/TestController.php new file mode 100644 index 0000000..a38907e --- /dev/null +++ b/app/Admin/Controllers/TestController.php @@ -0,0 +1,72 @@ +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); + } + + } + +} diff --git a/app/Admin/Renderable/Activity/Grants.php b/app/Admin/Renderable/Activity/Grants.php new file mode 100644 index 0000000..c3b38d2 --- /dev/null +++ b/app/Admin/Renderable/Activity/Grants.php @@ -0,0 +1,26 @@ +grants->map(function ($info) { + return [ + 'id' => $info->id, + 'nickname' => $info->user_nickname, + ]; + }); + dd($items->toArray()); + + return new Table(['Id', '渠道'], $items->toArray()); + } + +} \ No newline at end of file diff --git a/app/Admin/routes.php b/app/Admin/routes.php index d6f1bf1..b4d973f 100644 --- a/app/Admin/routes.php +++ b/app/Admin/routes.php @@ -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'); /** diff --git a/config/admin.php b/config/admin.php index 7497e80..e930396 100644 --- a/config/admin.php +++ b/config/admin.php @@ -11,7 +11,7 @@ return [ | login page. | */ - 'name' => '平安接口系统', + 'name' => '平安券核销管理系统', /* |-------------------------------------------------------------------------- @@ -22,7 +22,7 @@ return [ | `img` tag, eg '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', diff --git a/config/auth.php b/config/auth.php index e8ce832..b65ce20 100644 --- a/config/auth.php +++ b/config/auth.php @@ -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', diff --git a/config/broadcasting.php b/config/broadcasting.php index 3bba110..ec2d8a3 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -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', ], diff --git a/config/cache.php b/config/cache.php index 46751e6..d0e7248 100644 --- a/config/cache.php +++ b/config/cache.php @@ -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'), ];