浏览代码

Merge branch 'develop'

xielin 6 年之前
父节点
当前提交
8b9fee754d

+ 1 - 0
app/Console/Commands/apollo.php

@@ -81,6 +81,7 @@ class Apollo extends Command
             if ($error) {
                 Log::info("Apollo Hand error :" . $error);
             }
+            sleep(60);
         } while ($error && $restart);
     }
 }

+ 37 - 15
app/Http/Controllers/UploadController.php

@@ -8,29 +8,51 @@ use Illuminate\Support\Facades\Storage;
 
 class UploadController extends Controller
 {
-    public function uploadImage(Request $request)
-    {
-        if($request->hasFile('image') && $request->file('image')->isValid()){
-            $path = $request->get('path') ? $request->get('path').'/' : date('Ym').'/';
-            //获取文件的原文件名 包括扩展名
-//            $yuanname= $request->file('image')->getClientOriginalName();
+    public function uploadImage(Request $request){
+        if ($request->hasFile('image') && $request->file('image')->isValid()) {
+            $path = $request->get('path') ? $request->get('path') . '/' : date('Ym') . '/';
 //            //获取文件的扩展名
-            $kuoname=$request->file('image')->getClientOriginalExtension();
+            $kuoname = $request->file('image')->getClientOriginalExtension();
 //            //获取文件的类型
 //            $type=$request->file('image')->getClientMimeType();
 //            //获取文件的绝对路径,但是获取到的在本地不能打开
-            $filePath=$request->file('image')->getRealPath();
+            $filePath = $request->file('image')->getRealPath();
             //要保存的文件名 时间+扩展名
-            $filename=time() . '_' . uniqid() .'.'.$kuoname;
-            $imageUrl = Storage::put($path.$filename, file_get_contents($filePath));
-            Log::debug('upload_url:'.$imageUrl);
-            if($imageUrl){
-                return $this->jsonSuccess(['url' => $path.$filename]);
-            }else{
+            $filename = time() . '_' . uniqid() . '.' . $kuoname;
+            $imageUrl = Storage::put($path . $filename, file_get_contents($filePath));
+            Log::debug('upload_url:' . $imageUrl);
+            if ($imageUrl) {
+                return $this->jsonSuccess(['url' => $path . $filename]);
+            } else {
                 return $this->jsonError('图片上传失败,请重试');
             }
-        }else{
+        } else {
             return $this->jsonError('仅支持图片上传,请重试');
         }
     }
+
+    public function uploadImages(Request $request)
+    {
+        $files = $request->file('image');
+        $fileCount = count($files);
+        $urls = [];
+        for ($i = 0; $i < $fileCount; $i++) {
+            $kuoname = $files[$i]->getClientOriginalExtension();
+            $filePath = $files[$i]->getRealPath();
+            //要保存的文件名 时间+扩展名
+            $filename = time() . '_' . uniqid() . '.' . $kuoname;
+            $imageUrl = Storage::put($filename, file_get_contents($filePath));
+            if ($imageUrl) {
+                array_push($urls, $filename);
+            } else {
+                Log::debug('文件上传失败。' . $filename);
+            }
+        }
+        if ($urls) {
+            return $this->jsonSuccess($urls);
+        } else {
+            return $this->jsonError('图片上传失败,请重试');
+        }
+
+    }
 }

+ 1 - 1
app/Http/Middleware/JwtAuthMiddleware.php

@@ -31,7 +31,7 @@ class JwtAuthMiddleware
                 return response()->json($error);
             }
             $data = JWTAuth::decode($token)['user'];
-            if ($data->sign !== md5($data->uid . env('JWT_SECRET'))) {
+            if ($data->sign !== md5($data->uid . config('customer.jwt_secret'))) {
                 $error = [
                     'message' => 'request is not allow',
                     'code' => 401,

+ 1 - 0
bootstrap/app.php

@@ -30,6 +30,7 @@ $app->configure('apollo');
 $app->configure('auth');
 $app->configure('jwt');
 $app->configure('customer');
+$app->configure('database');
 /*
 |--------------------------------------------------------------------------
 | Register Container Bindings

+ 131 - 0
config/database.php

@@ -0,0 +1,131 @@
+<?php
+
+return [
+
+    /*
+    |--------------------------------------------------------------------------
+    | Default Database Connection Name
+    |--------------------------------------------------------------------------
+    |
+    | Here you may specify which of the database connections below you wish
+    | to use as your default connection for all database work. Of course
+    | you may use many connections at once using the Database library.
+    |
+    */
+
+    'default' => env('DB_CONNECTION', 'mysql'),
+
+    /*
+    |--------------------------------------------------------------------------
+    | Database Connections
+    |--------------------------------------------------------------------------
+    |
+    | Here are each of the database connections setup for your application.
+    | Of course, examples of configuring each database platform that is
+    | supported by Laravel is shown below to make development simple.
+    |
+    |
+    | All database work in Laravel is done through the PHP PDO facilities
+    | so make sure you have the driver for your particular database of
+    | choice installed on your machine before you begin development.
+    |
+    */
+
+    'connections' => [
+
+        'sqlite' => [
+            'driver' => 'sqlite',
+            'database' => env('DB_DATABASE', database_path('database.sqlite')),
+            'prefix' => env('DB_PREFIX', ''),
+        ],
+
+        'mysql' => [
+            'driver' => 'mysql',
+            'host' => env('DB_HOST', '127.0.0.1'),
+            'port' => env('DB_PORT', 3306),
+            'database' => env('DB_DATABASE', 'forge'),
+            'username' => env('DB_USERNAME', 'forge'),
+            'password' => env('DB_PASSWORD', ''),
+            'unix_socket' => env('DB_SOCKET', ''),
+            'charset' => env('DB_CHARSET', 'utf8mb4'),
+            'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
+            'prefix' => env('DB_PREFIX', ''),
+            'strict' => env('DB_STRICT_MODE', true),
+            'engine' => env('DB_ENGINE', null),
+            'timezone' => env('DB_TIMEZONE', '+08:00'),
+        ],
+
+        'pgsql' => [
+            'driver' => 'pgsql',
+            'host' => env('DB_HOST', '127.0.0.1'),
+            'port' => env('DB_PORT', 5432),
+            'database' => env('DB_DATABASE', 'forge'),
+            'username' => env('DB_USERNAME', 'forge'),
+            'password' => env('DB_PASSWORD', ''),
+            'charset' => env('DB_CHARSET', 'utf8'),
+            'prefix' => env('DB_PREFIX', ''),
+            'schema' => env('DB_SCHEMA', 'public'),
+            'sslmode' => env('DB_SSL_MODE', 'prefer'),
+        ],
+
+        'sqlsrv' => [
+            'driver' => 'sqlsrv',
+            'host' => env('DB_HOST', 'localhost'),
+            'port' => env('DB_PORT', 1433),
+            'database' => env('DB_DATABASE', 'forge'),
+            'username' => env('DB_USERNAME', 'forge'),
+            'password' => env('DB_PASSWORD', ''),
+            'charset' => env('DB_CHARSET', 'utf8'),
+            'prefix' => env('DB_PREFIX', ''),
+        ],
+
+    ],
+
+    /*
+    |--------------------------------------------------------------------------
+    | Migration Repository Table
+    |--------------------------------------------------------------------------
+    |
+    | This table keeps track of all the migrations that have already run for
+    | your application. Using this information, we can determine which of
+    | the migrations on disk haven't actually been run in the database.
+    |
+    */
+
+    'migrations' => 'migrations',
+
+    /*
+    |--------------------------------------------------------------------------
+    | Redis Databases
+    |--------------------------------------------------------------------------
+    |
+    | Redis is an open source, fast, and advanced key-value store that also
+    | provides a richer set of commands than a typical key-value systems
+    | such as APC or Memcached. Laravel makes it easy to dig right in.
+    |
+    */
+
+    'redis' => [
+
+        'client' => 'predis',
+
+        'cluster' => env('REDIS_CLUSTER', false),
+
+        'default' => [
+            'host' => env('REDIS_HOST', '127.0.0.1'),
+            'password' => env('REDIS_PASSWORD', null),
+            'port' => env('REDIS_PORT', 6379),
+            'database' => env('REDIS_DB', 0),
+            'read_write_timeout' => 0,
+        ],
+
+        'cache' => [
+            'host' => env('REDIS_HOST', '127.0.0.1'),
+            'password' => env('REDIS_PASSWORD', null),
+            'port' => env('REDIS_PORT', 6379),
+            'database' => env('REDIS_CACHE_DB', 1),
+        ],
+
+    ],
+
+];

+ 0 - 32
database/migrations/2019_04_23_064937_create_table_config_store_type.php

@@ -1,32 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class CreateTableConfigStoreType extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::create('config_store_type', function (Blueprint $table) {
-            $table->bigIncrements('id');
-            $table->string('name',20)->nullable();  //储存方式:常温/冷冻/冷藏
-            $table->timestamps();
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::dropIfExists('config_store_type');
-    }
-}

+ 0 - 35
database/migrations/2019_04_23_071015_create_table_config_province.php

@@ -1,35 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class CreateTableConfigProvince extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::create('config_province', function (Blueprint $table) {
-            $table->bigIncrements('id');
-            $table->string('name',30);  //名称
-            $table->integer('parent_id');//父级ID
-            $table->integer('level');//级别
-            $table->tinyInteger('sort');//排序
-            $table->timestamps();
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::dropIfExists('config_province');
-    }
-}

+ 0 - 38
database/migrations/2019_04_23_072002_create_table_config_city_management.php

@@ -1,38 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class CreateTableConfigCityManagement extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::create('config_city_management', function (Blueprint $table) {
-            $table->bigIncrements('id');
-            $table->integer('province_id');//省份ID
-            $table->integer('city_id');//城市ID
-            $table->string('province_name',20);//省份名称
-            $table->string('city_name',30);//城市名称
-            $table->tinyInteger('express_type')->default(0);//快递方式:0.全部;1.自提;2.快递
-            $table->tinyInteger('status')->default(1);        //状态: 0.禁用 1.启用
-            $table->timestamps();
-            $table->softDeletes();
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::dropIfExists('config_city_management');
-    }
-}

+ 0 - 45
database/migrations/2019_04_23_072817_create_table_config_pickup_node.php

@@ -1,45 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class CreateTableConfigPickupNode extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::create('config_pickup_node', function (Blueprint $table) {
-            $table->bigIncrements('id');
-            $table->integer('city_id');     //城市ID
-            $table->integer('pickup_group_id');     //分组ID
-            $table->integer('store_ids');     //储存方式ID
-            $table->string('city_name',20);   //城市名称
-            $table->string('name',20);   //名称
-            $table->string('address',200);  //自提点地址
-            $table->string('longitude',100);  //经度
-            $table->string('latitude',100);  //纬度
-            $table->string('pickup_code',50);    //自提点编码
-            $table->dateTime('work_time');                 //自提时间
-            $table->string('manager_name',50)->nullable();   //负责人
-            $table->string('manager_mobile',20);  //负责人电话
-            $table->tinyInteger('receive_type')->default(1);  // 接货方式:0.信任交付;1.手动确认接货
-            $table->tinyInteger('status')->default(1);        //状态: 0.禁用;1.启用
-            $table->timestamps();
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::dropIfExists('config_pickup_node');
-    }
-}

+ 0 - 32
database/migrations/2019_04_23_074545_create_table_config_pickup_group.php

@@ -1,32 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class CreateTableConfigPickupGroup extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::create('config_pickup_group', function (Blueprint $table) {
-            $table->bigIncrements('id');
-            $table->string('name',20)->nullable();   //名称
-            $table->timestamps();
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::dropIfExists('config_pickup_group');
-    }
-}

+ 0 - 32
database/migrations/2019_04_25_103653_update_config_pickup_node_table.php

@@ -1,32 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class UpdateConfigPickupNodeTable extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::table('config_pickup_node', function (Blueprint $table) {
-            $table->integer('distance')->comment('距离');
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::table('config_pickup_node', function (Blueprint $table) {
-            $table->dropColumn(['distance']);
-        });
-    }
-}

+ 0 - 36
database/migrations/2019_04_25_143536_add_bjcity_id_config_province_table.php

@@ -1,36 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class AddBjcityIdConfigProvinceTable extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::table('config_province', function (Blueprint $table) {
-            $table->renameColumn('name', 'area_name');
-            $table->renameColumn('id', 'bjcity_id',20)->comment('百度城市id');
-            $table->string('area_code',50)->nullable()->comment('地区编码');
-            $table->string('city_code',50)->comment('城市编码');
-            $table->string('center',50)->comment('城市中心点(即:经纬度坐标)');
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::table('config_province', function (Blueprint $table) {
-            $table->dropColumn('bjcity_id','area_name','area_code','city_code','center');
-        });
-    }
-}

+ 0 - 32
database/migrations/2019_04_26_034735_update_express_type_config_city_management_table.php

@@ -1,32 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class UpdateExpressTypeConfigCityManagementTable extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::table('config_city_management', function (Blueprint $table) {
-            $table->string('express_type',50)->comment('快递方式')->change();
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::table('config_city_management', function (Blueprint $table) {
-            //
-        });
-    }
-}

+ 0 - 32
database/migrations/2019_04_26_085923_update_area_id_config_province_table.php

@@ -1,32 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class UpdateAreaIdConfigProvinceTable extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::table('config_province', function (Blueprint $table) {
-            $table->renameColumn('bjcity_id', 'area_id');
-
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::table('config_province', function (Blueprint $table) {
-        });
-    }
-}

+ 0 - 32
database/migrations/2019_04_26_090540_add_bjcity_id_config_province_table.php

@@ -1,32 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class AddBjcityIdConfigProvinceTable extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::table('config_province', function (Blueprint $table) {
-            $table->integer('bjcity_id')->nullable();
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::table('config_province', function (Blueprint $table) {
-            //
-        });
-    }
-}

+ 0 - 32
database/migrations/2019_04_29_024537_delete_distance_config_pickup_node_table.php

@@ -1,32 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class DeleteDistanceConfigPickupNodeTable extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::table('config_pickup_node', function (Blueprint $table) {
-            $table->dropColumn('distance');
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::table('config_pickup_node', function (Blueprint $table) {
-            //
-        });
-    }
-}

+ 0 - 32
database/migrations/2019_04_30_095318_delete_city_code_to_config_province_table.php

@@ -1,32 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class DeleteCityCodeToConfigProvinceTable extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::table('config_province', function (Blueprint $table) {
-            $table->dropColumn('city_code');
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::table('config_province', function (Blueprint $table) {
-            //
-        });
-    }
-}

+ 2 - 1
routes/api.php

@@ -20,6 +20,7 @@ $api->version('v1', [
     //登录
     $api->group(['middleware' => 'chxq_jwt_auth'], function ($api) {
         $api->post('upload', 'UploadController@uploadImage');
+        $api->post('multi_upload', 'UploadController@uploadImages');
     });
     //登录+验签
     $api->group(['middleware' => ['chxq_jwt_auth','chxq_sign']], function ($api) {
@@ -29,7 +30,7 @@ $api->version('v1', [
         //自提点列表
         $api->get('/pickupNode/index','ConfigPickupNodeController@index');
         //获取某自提点
-        $api->post('/pickupNode/getPickupNode','ConfigPickupNodeController@getPickupNode');
+        $api->get('/pickupNode/getPickupNode','ConfigPickupNodeController@getPickupNode');
 
         //已开通城市列表
         $api->get('/cityManagement/index','ConfigCityManagementController@index');