Просмотр исходного кода

1.批量导出卡券
2.注册时默认加密方式、协议、混淆取系统默认值

zhangjiangbin 8 лет назад
Родитель
Сommit
ad0c8b7a1a

+ 39 - 0
app/Http/Controllers/CouponController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
 
 use App\Http\Models\Coupon;
 use Illuminate\Http\Request;
+use Maatwebsite\Excel\Facades\Excel;
 use Response;
 use Redirect;
 use DB;
@@ -109,4 +110,42 @@ class CouponController extends BaseController
 
         return Response::json(['status' => 'success', 'data' => '', 'message' => '删除成功']);
     }
+
+    // 导出优惠券
+    public function exportCoupon(Request $request)
+    {
+        $cashCouponList = Coupon::where('is_del', 0)->where('status', 0)->where('type', 1)->get();
+        $discountCouponList = Coupon::where('is_del', 0)->where('status', 0)->where('type', 2)->get();
+
+        $filename = '卡券' . date('Ymd');
+        Excel::create($filename, function($excel) use($cashCouponList, $discountCouponList) {
+            $excel->sheet('现金券', function($sheet) use($cashCouponList) {
+                $sheet->row(1, array(
+                    '名称', '用途', '有效期', '券码'
+                ));
+
+                if (!$cashCouponList->isEmpty()) {
+                    foreach ($cashCouponList as $k => $vo) {
+                        $sheet->row($k + 2, array(
+                            $vo->name, $vo->type == 1 ? '一次性' : '可重复', date('Y-m-d', $vo->available_start) . ' ~ ' . date('Y-m-d', $vo->available_end), $vo->sn
+                        ));
+                    }
+                }
+            });
+
+            $excel->sheet('折扣券', function($sheet) use($discountCouponList) {
+                $sheet->row(1, array(
+                    '名称', '用途', '有效期', '券码'
+                ));
+
+                if (!$discountCouponList->isEmpty()) {
+                    foreach ($discountCouponList as $k => $vo) {
+                        $sheet->row($k + 2, array(
+                            $vo->name, $vo->type == 1 ? '一次性' : '可重复', date('Y-m-d', $vo->available_start) . ' ~ ' . date('Y-m-d', $vo->available_end), $vo->sn
+                        ));
+                    }
+                }
+            });
+        })->export('xls');
+    }
 }

+ 9 - 1
app/Http/Controllers/RegisterController.php

@@ -2,8 +2,8 @@
 
 namespace App\Http\Controllers;
 
-use App\Http\Models\EmailLog;
 use App\Http\Models\Invite;
+use App\Http\Models\SsConfig;
 use App\Http\Models\User;
 use App\Http\Models\Verify;
 use Illuminate\Http\Request;
@@ -102,6 +102,11 @@ class RegisterController extends BaseController
             $last_user = User::orderBy('id', 'desc')->first();
             $port = self::$config['is_rand_port'] ? $this->getRandPort() : $last_user->port + 1;
 
+            // 默认加密方式、协议、混淆
+            $method = SsConfig::where('type', 1)->where('is_default', 1)->first();
+            $protocol = SsConfig::where('type', 2)->where('is_default', 1)->first();
+            $obfs = SsConfig::where('type', 3)->where('is_default', 1)->first();
+
             // 创建新用户
             $transfer_enable = $referral_uid ? (self::$config['default_traffic'] + self::$config['referral_traffic']) * 1048576 : self::$config['default_traffic'] * 1048576;
             $user = new User();
@@ -110,6 +115,9 @@ class RegisterController extends BaseController
             $user->port = $port;
             $user->passwd = $this->makeRandStr();
             $user->transfer_enable = $transfer_enable;
+            $user->method = $method ? $method->name : 'aes-192-ctr';
+            $user->protocol = $protocol ? $protocol->name : 'auth_chain_a';
+            $user->obfs = $obfs ? $obfs->name : 'tls1.2_ticket_auth';
             $user->enable_time = date('Y-m-d H:i:s');
             $user->expire_time = date('Y-m-d H:i:s', strtotime("+" . self::$config['default_days'] . " days"));
             $user->reg_ip = $request->getClientIp();

+ 0 - 3
app/Http/Controllers/SubscribeController.php

@@ -6,13 +6,10 @@ use App\Http\Models\SsGroup;
 use App\Http\Models\SsGroupNode;
 use App\Http\Models\SsNode;
 use App\Http\Models\User;
-use App\Http\Models\UserScoreLog;
 use App\Http\Models\UserSubscribe;
 use App\Http\Models\UserSubscribeLog;
 use Illuminate\Http\Request;
-use Response;
 use Redirect;
-use Cache;
 
 /**
  * 订阅控制器

+ 0 - 1
app/Http/Controllers/TicketController.php

@@ -6,7 +6,6 @@ use App\Http\Models\Ticket;
 use App\Http\Models\TicketReply;
 use Illuminate\Http\Request;
 use Response;
-use Redirect;
 
 /**
  * 工单控制器

+ 0 - 2
app/Http/Controllers/UserController.php

@@ -5,14 +5,12 @@ namespace App\Http\Controllers;
 use App\Http\Models\Article;
 use App\Http\Models\Coupon;
 use App\Http\Models\CouponLog;
-use App\Http\Models\EmailLog;
 use App\Http\Models\Goods;
 use App\Http\Models\Invite;
 use App\Http\Models\Order;
 use App\Http\Models\OrderGoods;
 use App\Http\Models\ReferralApply;
 use App\Http\Models\ReferralLog;
-use App\Http\Models\SsNode;
 use App\Http\Models\SsNodeInfo;
 use App\Http\Models\SsNodeOnlineLog;
 use App\Http\Models\Ticket;

+ 2 - 1
composer.json

@@ -9,7 +9,8 @@
         "barryvdh/laravel-ide-helper": "^2.4",
         "guzzlehttp/guzzle": "^6.3",
         "laravel/framework": "5.4.*",
-        "laravel/tinker": "~1.0"
+        "laravel/tinker": "~1.0",
+        "maatwebsite/excel": "~2.1.0"
     },
     "require-dev": {
         "fzaninotto/faker": "~1.4",

+ 305 - 4
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "content-hash": "d39736f4299c71aee7e0ece1e5ff5414",
+    "content-hash": "1db545b9e18088f18d459d1563a53042",
     "packages": [
         {
             "name": "barryvdh/laravel-ide-helper",
@@ -538,6 +538,64 @@
             ],
             "time": "2015-04-20T18:58:01+00:00"
         },
+        {
+            "name": "jeremeamia/SuperClosure",
+            "version": "2.3.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/jeremeamia/super_closure.git",
+                "reference": "443c3df3207f176a1b41576ee2a66968a507b3db"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://files.phpcomposer.com/files/jeremeamia/super_closure/443c3df3207f176a1b41576ee2a66968a507b3db.zip",
+                "reference": "443c3df3207f176a1b41576ee2a66968a507b3db",
+                "shasum": ""
+            },
+            "require": {
+                "nikic/php-parser": "^1.2|^2.0|^3.0",
+                "php": ">=5.4",
+                "symfony/polyfill-php56": "^1.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^4.0|^5.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "2.3-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "SuperClosure\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Jeremy Lindblom",
+                    "email": "[email protected]",
+                    "homepage": "https://github.com/jeremeamia",
+                    "role": "Developer"
+                }
+            ],
+            "description": "Serialize Closure objects, including their context and binding",
+            "homepage": "https://github.com/jeremeamia/super_closure",
+            "keywords": [
+                "closure",
+                "function",
+                "lambda",
+                "parser",
+                "serializable",
+                "serialize",
+                "tokenizer"
+            ],
+            "time": "2016-12-07T09:37:55+00:00"
+        },
         {
             "name": "laravel/framework",
             "version": "v5.4.30",
@@ -813,6 +871,84 @@
             ],
             "time": "2017-04-28T10:15:08+00:00"
         },
+        {
+            "name": "maatwebsite/excel",
+            "version": "2.1.23",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/Maatwebsite/Laravel-Excel.git",
+                "reference": "8682c955601b6de15a8c7d6e373b927cc8380627"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://files.phpcomposer.com/files/Maatwebsite/Laravel-Excel/8682c955601b6de15a8c7d6e373b927cc8380627.zip",
+                "reference": "8682c955601b6de15a8c7d6e373b927cc8380627",
+                "shasum": ""
+            },
+            "require": {
+                "illuminate/cache": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*",
+                "illuminate/config": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*",
+                "illuminate/filesystem": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*",
+                "illuminate/support": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*",
+                "jeremeamia/superclosure": "^2.3",
+                "nesbot/carbon": "~1.0",
+                "php": ">=5.5",
+                "phpoffice/phpexcel": "1.8.*",
+                "tijsverkoyen/css-to-inline-styles": "~2.0"
+            },
+            "require-dev": {
+                "mockery/mockery": "~0.9",
+                "orchestra/testbench": "3.1.*|3.2.*|3.3.*|3.4.*|3.5.*",
+                "phpseclib/phpseclib": "~1.0",
+                "phpunit/phpunit": "~4.0"
+            },
+            "suggest": {
+                "illuminate/http": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*",
+                "illuminate/queue": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*",
+                "illuminate/routing": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*",
+                "illuminate/view": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*"
+            },
+            "type": "library",
+            "extra": {
+                "laravel": {
+                    "providers": [
+                        "Maatwebsite\\Excel\\ExcelServiceProvider"
+                    ],
+                    "aliases": {
+                        "Excel": "Maatwebsite\\Excel\\Facades\\Excel"
+                    }
+                }
+            },
+            "autoload": {
+                "classmap": [
+                    "src/Maatwebsite/Excel"
+                ],
+                "psr-0": {
+                    "Maatwebsite\\Excel\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "LGPL"
+            ],
+            "authors": [
+                {
+                    "name": "Maatwebsite.nl",
+                    "email": "[email protected]"
+                }
+            ],
+            "description": "An eloquent way of importing and exporting Excel and CSV in Laravel 4 with the power of PHPExcel",
+            "keywords": [
+                "PHPExcel",
+                "batch",
+                "csv",
+                "excel",
+                "export",
+                "import",
+                "laravel"
+            ],
+            "time": "2017-09-19T19:36:48+00:00"
+        },
         {
             "name": "monolog/monolog",
             "version": "1.23.0",
@@ -1087,6 +1223,63 @@
             ],
             "time": "2017-03-13T16:27:32+00:00"
         },
+        {
+            "name": "phpoffice/phpexcel",
+            "version": "1.8.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/PHPOffice/PHPExcel.git",
+                "reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://files.phpcomposer.com/files/PHPOffice/PHPExcel/372c7cbb695a6f6f1e62649381aeaa37e7e70b32.zip",
+                "reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32",
+                "shasum": ""
+            },
+            "require": {
+                "ext-xml": "*",
+                "ext-xmlwriter": "*",
+                "php": ">=5.2.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-0": {
+                    "PHPExcel": "Classes/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "LGPL"
+            ],
+            "authors": [
+                {
+                    "name": "Maarten Balliauw",
+                    "homepage": "http://blog.maartenballiauw.be"
+                },
+                {
+                    "name": "Mark Baker"
+                },
+                {
+                    "name": "Franck Lefevre",
+                    "homepage": "http://blog.rootslabs.net"
+                },
+                {
+                    "name": "Erik Tilt"
+                }
+            ],
+            "description": "PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
+            "homepage": "http://phpexcel.codeplex.com",
+            "keywords": [
+                "OpenXML",
+                "excel",
+                "php",
+                "spreadsheet",
+                "xls",
+                "xlsx"
+            ],
+            "time": "2015-05-01T07:00:55+00:00"
+        },
         {
             "name": "psr/http-message",
             "version": "1.0.1",
@@ -1555,7 +1748,7 @@
             ],
             "authors": [
                 {
-                    "name": "Jean-François Simon",
+                    "name": "Jean-Francois Simon",
                     "email": "[email protected]"
                 },
                 {
@@ -1937,6 +2130,114 @@
             ],
             "time": "2017-06-09T14:24:12+00:00"
         },
+        {
+            "name": "symfony/polyfill-php56",
+            "version": "v1.6.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/polyfill-php56.git",
+                "reference": "265fc96795492430762c29be291a371494ba3a5b"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://files.phpcomposer.com/files/symfony/polyfill-php56/265fc96795492430762c29be291a371494ba3a5b.zip",
+                "reference": "265fc96795492430762c29be291a371494ba3a5b",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.3",
+                "symfony/polyfill-util": "~1.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.6-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Symfony\\Polyfill\\Php56\\": ""
+                },
+                "files": [
+                    "bootstrap.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Nicolas Grekas",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions",
+            "homepage": "https://symfony.com",
+            "keywords": [
+                "compatibility",
+                "polyfill",
+                "portable",
+                "shim"
+            ],
+            "time": "2017-10-11T12:05:26+00:00"
+        },
+        {
+            "name": "symfony/polyfill-util",
+            "version": "v1.6.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/polyfill-util.git",
+                "reference": "6e719200c8e540e0c0effeb31f96bdb344b94176"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://files.phpcomposer.com/files/symfony/polyfill-util/6e719200c8e540e0c0effeb31f96bdb344b94176.zip",
+                "reference": "6e719200c8e540e0c0effeb31f96bdb344b94176",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.3"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.6-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Symfony\\Polyfill\\Util\\": ""
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Nicolas Grekas",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony utilities for portability of PHP codes",
+            "homepage": "https://symfony.com",
+            "keywords": [
+                "compat",
+                "compatibility",
+                "polyfill",
+                "shim"
+            ],
+            "time": "2017-10-11T12:05:26+00:00"
+        },
         {
             "name": "symfony/process",
             "version": "v3.3.5",
@@ -2387,7 +2688,7 @@
             ],
             "authors": [
                 {
-                    "name": "François Zaninotto"
+                    "name": "Francois Zaninotto"
                 }
             ],
             "description": "Faker is a PHP library that generates fake data for you.",
@@ -2482,7 +2783,7 @@
             ],
             "authors": [
                 {
-                    "name": "Pádraic Brady",
+                    "name": "Padraic Brady",
                     "email": "[email protected]",
                     "homepage": "http://blog.astrumfutura.com"
                 },

+ 2 - 1
config/app.php

@@ -178,7 +178,7 @@ return [
         App\Providers\RouteServiceProvider::class,
 
         Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
-
+        Maatwebsite\Excel\ExcelServiceProvider::class,
     ],
 
     /*
@@ -227,6 +227,7 @@ return [
         'URL' => Illuminate\Support\Facades\URL::class,
         'Validator' => Illuminate\Support\Facades\Validator::class,
         'View' => Illuminate\Support\Facades\View::class,
+        'Excel' => Maatwebsite\Excel\Facades\Excel::class,
 
     ],
 

+ 704 - 0
config/excel.php

@@ -0,0 +1,704 @@
+<?php
+
+return array(
+
+    'cache'      => [
+
+        /*
+        |--------------------------------------------------------------------------
+        | Enable/Disable cell caching
+        |--------------------------------------------------------------------------
+        */
+        'enable'   => true,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Caching driver
+        |--------------------------------------------------------------------------
+        |
+        | Set the caching driver
+        |
+        | Available methods:
+        | memory|gzip|serialized|igbinary|discISAM|apc|memcache|temp|wincache|sqlite|sqlite3
+        |
+        */
+        'driver'   => 'memory',
+
+        /*
+        |--------------------------------------------------------------------------
+        | Cache settings
+        |--------------------------------------------------------------------------
+        */
+        'settings' => [
+
+            'memoryCacheSize' => '32MB',
+            'cacheTime'       => 600
+
+        ],
+
+        /*
+        |--------------------------------------------------------------------------
+        | Memcache settings
+        |--------------------------------------------------------------------------
+        */
+        'memcache' => [
+
+            'host' => 'localhost',
+            'port' => 11211,
+
+        ],
+
+        /*
+        |--------------------------------------------------------------------------
+        | Cache dir (for discISAM)
+        |--------------------------------------------------------------------------
+        */
+
+        'dir'      => storage_path('cache')
+    ],
+
+    'properties' => [
+        'creator'        => 'Maatwebsite',
+        'lastModifiedBy' => 'Maatwebsite',
+        'title'          => 'Spreadsheet',
+        'description'    => 'Default spreadsheet export',
+        'subject'        => 'Spreadsheet export',
+        'keywords'       => 'maatwebsite, excel, export',
+        'category'       => 'Excel',
+        'manager'        => 'Maatwebsite',
+        'company'        => 'Maatwebsite',
+    ],
+
+    /*
+    |--------------------------------------------------------------------------
+    | Sheets settings
+    |--------------------------------------------------------------------------
+    */
+    'sheets'     => [
+
+        /*
+        |--------------------------------------------------------------------------
+        | Default page setup
+        |--------------------------------------------------------------------------
+        */
+        'pageSetup' => [
+            'orientation'           => 'portrait',
+            'paperSize'             => '9',
+            'scale'                 => '100',
+            'fitToPage'             => false,
+            'fitToHeight'           => true,
+            'fitToWidth'            => true,
+            'columnsToRepeatAtLeft' => ['', ''],
+            'rowsToRepeatAtTop'     => [0, 0],
+            'horizontalCentered'    => false,
+            'verticalCentered'      => false,
+            'printArea'             => null,
+            'firstPageNumber'       => null,
+        ],
+    ],
+
+    /*
+    |--------------------------------------------------------------------------
+    | Creator
+    |--------------------------------------------------------------------------
+    |
+    | The default creator of a new Excel file
+    |
+    */
+
+    'creator'    => 'Maatwebsite',
+
+    'csv'        => [
+        /*
+       |--------------------------------------------------------------------------
+       | Delimiter
+       |--------------------------------------------------------------------------
+       |
+       | The default delimiter which will be used to read out a CSV file
+       |
+       */
+
+        'delimiter'   => ',',
+
+        /*
+        |--------------------------------------------------------------------------
+        | Enclosure
+        |--------------------------------------------------------------------------
+        */
+
+        'enclosure'   => '"',
+
+        /*
+        |--------------------------------------------------------------------------
+        | Line endings
+        |--------------------------------------------------------------------------
+        */
+
+        'line_ending' => "\r\n",
+
+        /*
+        |--------------------------------------------------------------------------
+        | setUseBom
+        |--------------------------------------------------------------------------
+        */
+
+        'use_bom' => false
+    ],
+
+    'export'     => [
+
+        /*
+        |--------------------------------------------------------------------------
+        | Autosize columns
+        |--------------------------------------------------------------------------
+        |
+        | Disable/enable column autosize or set the autosizing for
+        | an array of columns ( array('A', 'B') )
+        |
+        */
+        'autosize'                    => true,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Autosize method
+        |--------------------------------------------------------------------------
+        |
+        | --> PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX
+        | The default is based on an estimate, which does its calculation based
+        | on the number of characters in the cell value (applying any calculation
+        | and format mask, and allowing for wordwrap and rotation) and with an
+        | "arbitrary" adjustment based on the font (Arial, Calibri or Verdana,
+        | defaulting to Calibri if any other font is used) and a proportional
+        | adjustment for the font size.
+        |
+        | --> PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT
+        | The second method is more accurate, based on actual style formatting as
+        | well (bold, italic, etc), and is calculated by generating a gd2 imagettf
+        | bounding box and using its dimensions to determine the size; but this
+        | method is significantly slower, and its accuracy is still dependent on
+        | having the appropriate fonts installed.
+        |
+        */
+        'autosize-method'             => PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Auto generate table heading
+        |--------------------------------------------------------------------------
+        |
+        | If set to true, the array indices (or model attribute names)
+        | will automatically be used as first row (table heading)
+        |
+        */
+        'generate_heading_by_indices' => true,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Auto set alignment on merged cells
+        |--------------------------------------------------------------------------
+        */
+        'merged_cell_alignment'       => 'left',
+
+        /*
+        |--------------------------------------------------------------------------
+        | Pre-calculate formulas during export
+        |--------------------------------------------------------------------------
+        */
+        'calculate'                   => false,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Include Charts during export
+        |--------------------------------------------------------------------------
+        */
+        'includeCharts'               => false,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Default sheet settings
+        |--------------------------------------------------------------------------
+        */
+        'sheets'                      => [
+
+            /*
+            |--------------------------------------------------------------------------
+            | Default page margin
+            |--------------------------------------------------------------------------
+            |
+            | 1) When set to false, default margins will be used
+            | 2) It's possible to enter a single margin which will
+            |    be used for all margins.
+            | 3) Alternatively you can pass an array with 4 margins
+            |    Default order: array(top, right, bottom, left)
+            |
+            */
+            'page_margin'          => false,
+
+            /*
+            |--------------------------------------------------------------------------
+            | Value in source array that stands for blank cell
+            |--------------------------------------------------------------------------
+            */
+            'nullValue'            => null,
+
+            /*
+            |--------------------------------------------------------------------------
+            | Insert array starting from this cell address as the top left coordinate
+            |--------------------------------------------------------------------------
+            */
+            'startCell'            => 'A1',
+
+            /*
+            |--------------------------------------------------------------------------
+            | Apply strict comparison when testing for null values in the array
+            |--------------------------------------------------------------------------
+            */
+            'strictNullComparison' => false
+        ],
+
+        /*
+        |--------------------------------------------------------------------------
+        | Store settings
+        |--------------------------------------------------------------------------
+        */
+
+        'store'                       => [
+
+            /*
+            |--------------------------------------------------------------------------
+            | Path
+            |--------------------------------------------------------------------------
+            |
+            | The path we want to save excel file to
+            |
+            */
+            'path'       => storage_path('exports'),
+
+            /*
+            |--------------------------------------------------------------------------
+            | Return info
+            |--------------------------------------------------------------------------
+            |
+            | Whether we want to return information about the stored file or not
+            |
+            */
+            'returnInfo' => false
+
+        ],
+
+        /*
+        |--------------------------------------------------------------------------
+        | PDF Settings
+        |--------------------------------------------------------------------------
+        */
+        'pdf'                         => [
+
+            /*
+            |--------------------------------------------------------------------------
+            | PDF Drivers
+            |--------------------------------------------------------------------------
+            | Supported: DomPDF, tcPDF, mPDF
+            */
+            'driver'  => 'DomPDF',
+
+            /*
+            |--------------------------------------------------------------------------
+            | PDF Driver settings
+            |--------------------------------------------------------------------------
+            */
+            'drivers' => [
+
+                /*
+                |--------------------------------------------------------------------------
+                | DomPDF settings
+                |--------------------------------------------------------------------------
+                */
+                'DomPDF' => [
+                    'path' => base_path('vendor/dompdf/dompdf/')
+                ],
+
+                /*
+                |--------------------------------------------------------------------------
+                | tcPDF settings
+                |--------------------------------------------------------------------------
+                */
+                'tcPDF'  => [
+                    'path' => base_path('vendor/tecnick.com/tcpdf/')
+                ],
+
+                /*
+                |--------------------------------------------------------------------------
+                | mPDF settings
+                |--------------------------------------------------------------------------
+                */
+                'mPDF'   => [
+                    'path' => base_path('vendor/mpdf/mpdf/')
+                ],
+            ]
+        ]
+    ],
+
+    'filters'    => [
+        /*
+        |--------------------------------------------------------------------------
+        | Register read filters
+        |--------------------------------------------------------------------------
+        */
+
+        'registered' => [
+            'chunk' => 'Maatwebsite\Excel\Filters\ChunkReadFilter'
+        ],
+
+        /*
+        |--------------------------------------------------------------------------
+        | Enable certain filters for every file read
+        |--------------------------------------------------------------------------
+        */
+
+        'enabled'    => []
+    ],
+
+    'import'     => [
+
+        /*
+        |--------------------------------------------------------------------------
+        | Has heading
+        |--------------------------------------------------------------------------
+        |
+        | The sheet has a heading (first) row which we can use as attribute names
+        |
+        | Options: true|false|slugged|slugged_with_count|ascii|numeric|hashed|trans|original
+        |
+        */
+
+        'heading'                 => 'slugged',
+
+        /*
+        |--------------------------------------------------------------------------
+        | First Row with data or heading of data
+        |--------------------------------------------------------------------------
+        |
+        | If the heading row is not the first row, or the data doesn't start
+        | on the first row, here you can change the start row.
+        |
+        */
+
+        'startRow'                => 1,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Cell name word separator
+        |--------------------------------------------------------------------------
+        |
+        | The default separator which is used for the cell names
+        | Note: only applies to 'heading' settings 'true' && 'slugged'
+        |
+        */
+
+        'separator'               => '_',
+
+        /*
+        |--------------------------------------------------------------------------
+        | Slug whitelisting
+        |--------------------------------------------------------------------------
+        |
+        | Here you can whitelist certain characters in the slug.
+        | E.g. user.last_name will not remove . and _
+        | Note: only applies to 'heading' settings 'true' && 'slugged'
+        |
+        */
+
+        'slug_whitelist'       => '._',
+
+        /*
+        |--------------------------------------------------------------------------
+        | Include Charts during import
+        |--------------------------------------------------------------------------
+        */
+
+        'includeCharts'           => false,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Sheet heading conversion
+        |--------------------------------------------------------------------------
+        |
+        | Convert headings to ASCII
+        | Note: only applies to 'heading' settings 'true' && 'slugged'
+        |
+        */
+
+        'to_ascii'                => true,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Import encoding
+        |--------------------------------------------------------------------------
+        */
+
+        'encoding'                => [
+
+            'input'  => 'UTF-8',
+            'output' => 'UTF-8'
+
+        ],
+
+        /*
+        |--------------------------------------------------------------------------
+        | Calculate
+        |--------------------------------------------------------------------------
+        |
+        | By default cells with formulas will be calculated.
+        |
+        */
+
+        'calculate'               => true,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Ignore empty cells
+        |--------------------------------------------------------------------------
+        |
+        | By default empty cells are not ignored
+        |
+        */
+
+        'ignoreEmpty'             => false,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Force sheet collection
+        |--------------------------------------------------------------------------
+        |
+        | For a sheet collection even when there is only 1 sheets.
+        | When set to false and only 1 sheet found, the parsed file will return
+        | a row collection instead of a sheet collection.
+        | When set to true, it will return a sheet collection instead.
+        |
+        */
+        'force_sheets_collection' => false,
+
+        /*
+        |--------------------------------------------------------------------------
+        | Date format
+        |--------------------------------------------------------------------------
+        |
+        | The format dates will be parsed to
+        |
+        */
+
+        'dates'                   => [
+
+            /*
+            |--------------------------------------------------------------------------
+            | Enable/disable date formatting
+            |--------------------------------------------------------------------------
+            */
+            'enabled' => true,
+
+            /*
+            |--------------------------------------------------------------------------
+            | Default date format
+            |--------------------------------------------------------------------------
+            |
+            | If set to false, a carbon object will return
+            |
+            */
+            'format'  => false,
+
+            /*
+            |--------------------------------------------------------------------------
+            | Date columns
+            |--------------------------------------------------------------------------
+            */
+            'columns' => []
+        ],
+
+        /*
+        |--------------------------------------------------------------------------
+        | Import sheets by config
+        |--------------------------------------------------------------------------
+        */
+        'sheets'                  => [
+
+            /*
+            |--------------------------------------------------------------------------
+            | Example sheet
+            |--------------------------------------------------------------------------
+            |
+            | Example sheet "test" will grab the firstname at cell A2
+            |
+            */
+
+            'test' => [
+
+                'firstname' => 'A2'
+
+            ]
+
+        ]
+    ],
+
+    'views'      => [
+
+        /*
+        |--------------------------------------------------------------------------
+        | Styles
+        |--------------------------------------------------------------------------
+        |
+        | The default styles which will be used when parsing a view
+        |
+        */
+
+        'styles' => [
+
+            /*
+            |--------------------------------------------------------------------------
+            | Table headings
+            |--------------------------------------------------------------------------
+            */
+            'th'     => [
+                'font' => [
+                    'bold' => true,
+                    'size' => 12,
+                ]
+            ],
+
+            /*
+            |--------------------------------------------------------------------------
+            | Strong tags
+            |--------------------------------------------------------------------------
+            */
+            'strong' => [
+                'font' => [
+                    'bold' => true,
+                    'size' => 12,
+                ]
+            ],
+
+            /*
+            |--------------------------------------------------------------------------
+            | Bold tags
+            |--------------------------------------------------------------------------
+            */
+            'b'      => [
+                'font' => [
+                    'bold' => true,
+                    'size' => 12,
+                ]
+            ],
+
+            /*
+            |--------------------------------------------------------------------------
+            | Italic tags
+            |--------------------------------------------------------------------------
+            */
+            'i'      => [
+                'font' => [
+                    'italic' => true,
+                    'size'   => 12,
+                ]
+            ],
+
+            /*
+            |--------------------------------------------------------------------------
+            | Heading 1
+            |--------------------------------------------------------------------------
+            */
+            'h1'     => [
+                'font' => [
+                    'bold' => true,
+                    'size' => 24,
+                ]
+            ],
+
+            /*
+            |--------------------------------------------------------------------------
+            | Heading 2
+            |--------------------------------------------------------------------------
+            */
+            'h2'     => [
+                'font' => [
+                    'bold' => true,
+                    'size' => 18,
+                ]
+            ],
+
+            /*
+            |--------------------------------------------------------------------------
+            | Heading 3
+            |--------------------------------------------------------------------------
+            */
+            'h3'     => [
+                'font' => [
+                    'bold' => true,
+                    'size' => 13.5,
+                ]
+            ],
+
+            /*
+             |--------------------------------------------------------------------------
+             | Heading 4
+             |--------------------------------------------------------------------------
+             */
+            'h4'     => [
+                'font' => [
+                    'bold' => true,
+                    'size' => 12,
+                ]
+            ],
+
+            /*
+             |--------------------------------------------------------------------------
+             | Heading 5
+             |--------------------------------------------------------------------------
+             */
+            'h5'     => [
+                'font' => [
+                    'bold' => true,
+                    'size' => 10,
+                ]
+            ],
+
+            /*
+             |--------------------------------------------------------------------------
+             | Heading 6
+             |--------------------------------------------------------------------------
+             */
+            'h6'     => [
+                'font' => [
+                    'bold' => true,
+                    'size' => 7.5,
+                ]
+            ],
+
+            /*
+             |--------------------------------------------------------------------------
+             | Hyperlinks
+             |--------------------------------------------------------------------------
+             */
+            'a'      => [
+                'font' => [
+                    'underline' => true,
+                    'color'     => ['argb' => 'FF0000FF'],
+                ]
+            ],
+
+            /*
+             |--------------------------------------------------------------------------
+             | Horizontal rules
+             |--------------------------------------------------------------------------
+             */
+            'hr'     => [
+                'borders' => [
+                    'bottom' => [
+                        'style' => 'thin',
+                        'color' => ['FF000000']
+                    ],
+                ]
+            ]
+        ]
+
+    ]
+
+);

+ 1 - 1
resources/views/coupon/couponList.blade.php

@@ -126,7 +126,7 @@
     <script type="text/javascript">
         // 批量导出卡券
         function exportCoupon() {
-            bootbox.alert('开发中');
+            window.location.href = '{{url('coupon/exportCoupon')}}';
         }
 
         // 添加卡券

+ 1 - 0
routes/web.php

@@ -62,6 +62,7 @@ Route::group(['middleware' => ['user', 'admin']], function() {
     Route::any('coupon/couponList', 'CouponController@couponList'); // 优惠券列表
     Route::any('coupon/addCoupon', 'CouponController@addCoupon'); // 添加优惠券
     Route::post('coupon/delCoupon', 'CouponController@delCoupon'); // 删除优惠券
+    Route::get('coupon/exportCoupon', 'CouponController@exportCoupon'); // 导出优惠券
     Route::get('emailLog/list', 'EmailLogController@list'); // 邮件发送日志
 });