浏览代码

Merge branch 'develop'

caihongxingqiu 6 年之前
父节点
当前提交
b3d48db266
共有 65 个文件被更改,包括 1821 次插入49 次删除
  1. 5 0
      .env.example
  2. 2 1
      .gitignore
  3. 84 0
      .rocketeer/config.php
  4. 40 0
      .rocketeer/hooks.php
  5. 24 0
      .rocketeer/paths.php
  6. 80 0
      .rocketeer/remote.php
  7. 35 0
      .rocketeer/scm.php
  8. 19 0
      .rocketeer/stages.php
  9. 61 0
      .rocketeer/strategies.php
  10. 86 0
      app/Console/Commands/apollo.php
  11. 2 1
      app/Console/Kernel.php
  12. 61 0
      app/Helper/helper.php
  13. 10 0
      app/Http/Controllers/AuthController.php
  14. 9 0
      app/Http/Controllers/BaseController.php
  15. 35 0
      app/Http/Controllers/ConfigCityManagementController.php
  16. 79 0
      app/Http/Controllers/ConfigPickupNodeController.php
  17. 35 0
      app/Http/Controllers/ConfigProvinceController.php
  18. 7 2
      app/Http/Controllers/Controller.php
  19. 35 0
      app/Http/Controllers/StoreTypeController.php
  20. 36 0
      app/Http/Controllers/UploadController.php
  21. 1 1
      app/Http/Middleware/Authenticate.php
  22. 21 6
      app/Http/Middleware/JwtAuthMiddleware.php
  23. 37 0
      app/Http/Middleware/SignAuthMiddleware.php
  24. 12 0
      app/Models/BaseModel.php
  25. 22 0
      app/Models/ConfigCityManagement.php
  26. 19 0
      app/Models/ConfigPickupGroup.php
  27. 53 0
      app/Models/ConfigPickupNode.php
  28. 16 0
      app/Models/ConfigProvince.php
  29. 18 0
      app/Models/ConfigStoreType.php
  30. 32 0
      app/Repositories/ConfigCityManagementRepository.php
  31. 35 0
      app/Repositories/ConfigPickupNodeRepository.php
  32. 26 0
      app/Repositories/ConfigProvinceRepository.php
  33. 27 0
      app/Repositories/ConfigStoreTypeRepository.php
  34. 23 0
      app/Transformers/CityTransformer.php
  35. 18 0
      app/Transformers/ConfigStoreTypeTransformer.php
  36. 40 0
      app/Transformers/PickupNodeTransformer.php
  37. 24 0
      app/Transformers/ProvinceTransformer.php
  38. 1 1
      bin/fswatch
  39. 6 1
      bootstrap/app.php
  40. 4 0
      composer.json
  41. 1 1
      config/api.php
  42. 10 0
      config/apollo.php
  43. 7 0
      config/customer.tpl
  44. 82 0
      config/filesystems.php
  45. 1 1
      config/jwt.php
  46. 1 1
      config/laravels.php
  47. 32 0
      database/migrations/2019_04_23_064937_create_table_config_store_type.php
  48. 35 0
      database/migrations/2019_04_23_071015_create_table_config_province.php
  49. 38 0
      database/migrations/2019_04_23_072002_create_table_config_city_management.php
  50. 45 0
      database/migrations/2019_04_23_072817_create_table_config_pickup_node.php
  51. 32 0
      database/migrations/2019_04_23_074545_create_table_config_pickup_group.php
  52. 32 0
      database/migrations/2019_04_25_103653_update_config_pickup_node_table.php
  53. 36 0
      database/migrations/2019_04_25_143536_add_bjcity_id_config_province_table.php
  54. 32 0
      database/migrations/2019_04_26_034735_update_express_type_config_city_management_table.php
  55. 32 0
      database/migrations/2019_04_26_085923_update_area_id_config_province_table.php
  56. 32 0
      database/migrations/2019_04_26_090540_add_bjcity_id_config_province_table.php
  57. 32 0
      database/migrations/2019_04_29_024537_delete_distance_config_pickup_node_table.php
  58. 32 0
      database/migrations/2019_04_30_095318_delete_city_code_to_config_province_table.php
  59. 20 0
      deploy/nginx/conf.d/app.beta.conf
  60. 20 0
      deploy/nginx/conf.d/app.dev.conf
  61. 2 0
      deploy/php/local.ini
  62. 32 0
      docker-compose-beta.yml
  63. 31 0
      docker-compose-dev.yml
  64. 21 30
      routes/api.php
  65. 3 3
      routes/web.php

+ 5 - 0
.env.example

@@ -19,3 +19,8 @@ CACHE_DRIVER=file
 QUEUE_CONNECTION=sync
 
 JWT_SECRET=chxqyhnjuikm67wshaed8ij3hyf2ndh3
+
+APP_ID=chxq-platform
+CLUSTER=default
+APOLLO_NAMESPACES="application,config-service"
+APOLLO_CONFIG_SERVER=http://127.0.0.1:18080

+ 2 - 1
.gitignore

@@ -4,4 +4,5 @@ Homestead.json
 Homestead.yaml
 .env
 /storage/*
-composer.lock
+composer.lock
+/config/customer.php

+ 84 - 0
.rocketeer/config.php

@@ -0,0 +1,84 @@
+<?php
+
+use Rocketeer\Services\Connections\ConnectionsHandler;
+
+return [
+
+    // The name of the application to deploy
+    // This will create a folder of the same name in the root directory
+    // configured above, so be careful about the characters used
+    'application_name' => 'config-service',
+
+    // Plugins
+    ////////////////////////////////////////////////////////////////////
+
+    // The plugins to load
+    'plugins'          => [// 'Rocketeer\Plugins\Slack\RocketeerSlack',
+    ],
+
+    // Logging
+    ////////////////////////////////////////////////////////////////////
+
+    // The schema to use to name log files
+    'logs'             => function (ConnectionsHandler $connections) {
+        return sprintf('%s-%s-%s.log', $connections->getConnection(), $connections->getStage(), date('Ymd'));
+    },
+
+    // Remote access
+    //
+    // You can either use a single connection or an array of connections
+    ////////////////////////////////////////////////////////////////////
+
+    // The default remote connection(s) to execute tasks on
+    'default'          => ['production'],
+
+    // The various connections you defined
+    // You can leave all of this empty or remove it entirely if you don't want
+    // to track files with credentials : Rocketeer will prompt you for your credentials
+    // and store them locally
+    'connections'      => [
+        'production' => [
+            'host'      => '47.92.174.125:2345',
+            'username'  => 'root',
+            'password'  => '',
+            'key'       => '/root/.ssh/id_rsa',
+            'keyphrase' => '',
+            'agent'     => '',
+            'db_role'   => true,
+        ],
+    ],
+
+    /*
+     * In most multiserver scenarios, migrations must be run in an exclusive server.
+     * In the event of not having a separate database server (in which case it can
+     * be handled through connections), you can assign a 'db_role' => true to the
+     * server's configuration and it will only run the migrations in that specific
+     * server at the time of deployment.
+     */
+    'use_roles'        => false,
+
+    // Contextual options
+    //
+    // In this section you can fine-tune the above configuration according
+    // to the stage or connection currently in use.
+    // Per example :
+    // 'stages' => array(
+    // 	'staging' => array(
+    // 		'scm' => array('branch' => 'staging'),
+    // 	),
+    //  'production' => array(
+    //    'scm' => array('branch' => 'master'),
+    //  ),
+    // ),
+    ////////////////////////////////////////////////////////////////////
+
+    'on'               => [
+
+        // Stages configurations
+        'stages'      => [],
+        // Connections configuration
+        'connections' => [],
+
+    ],
+
+];

+ 40 - 0
.rocketeer/hooks.php

@@ -0,0 +1,40 @@
+<?php
+
+return [
+
+    // Tasks
+    //
+    // Here you can define in the `before` and `after` array, Tasks to execute
+    // before or after the core Rocketeer Tasks. You can either put a simple command,
+    // a closure which receives a $task object, or the name of a class extending
+    // the Rocketeer\Abstracts\AbstractTask class
+    //
+    // In the `custom` array you can list custom Tasks classes to be added
+    // to Rocketeer. Those will then be available in the command line
+    // with all the other tasks
+    //////////////////////////////////////////////////////////////////////
+
+    // Tasks to execute before the core Rocketeer Tasks
+    'before' => [
+        'setup'   => [],
+        'deploy'  => [],
+        'cleanup' => [],
+    ],
+
+    // Tasks to execute after the core Rocketeer Tasks
+    'after'  => [
+        'setup'   => [],
+        'deploy'  => [
+            'composer dumpautoload',
+            'php artisan route:clear',
+            'chmod -R 777 bootstrap',
+            'chmod -R 777 storage',
+            'chmod -R 777 public'
+        ],
+        'cleanup' => [],
+    ],
+
+    // Custom Tasks to register with Rocketeer
+    'custom' => [],
+
+];

+ 24 - 0
.rocketeer/paths.php

@@ -0,0 +1,24 @@
+<?php
+
+return [
+
+    // Configurable paths
+    //
+    // Here you can manually set paths to some commands Rocketeer
+    // might try to use, if you leave those empty it will try to find them
+    // manually or assume they're in the root folder
+    //
+    // You can also add in this file custom paths for any command or binary
+    // Rocketeer might go looking for
+    ////////////////////////////////////////////////////////////////////
+
+    // Path to the PHP binary
+    'php'      => '/usr/local/php/bin/php',
+
+    // Path to Composer
+    'composer' => '/usr/local/bin/composer',
+
+    // Path to the Artisan CLI
+    'artisan'  => 'artisan',
+
+];

+ 80 - 0
.rocketeer/remote.php

@@ -0,0 +1,80 @@
+<?php
+
+return [
+
+    // Remote server
+    //////////////////////////////////////////////////////////////////////
+
+    // Variables about the servers. Those can be guessed but in
+    // case of problem it's best to input those manually
+    'variables'      => [
+        'directory_separator' => '/',
+        'line_endings'        => "\n",
+    ],
+
+    // The number of releases to keep at all times
+    'keep_releases'  => 4,
+
+    // Folders
+    ////////////////////////////////////////////////////////////////////
+
+    // The root directory where your applications will be deployed
+    // This path *needs* to start at the root, ie. start with a /
+    'root_directory' => '/data/wwwroot/beta',
+
+    // The folder the application will be cloned in
+    // Leave empty to use `application_name` as your folder name
+    'app_directory'  => '',
+
+    // A list of folders/file to be shared between releases
+    // Use this to list folders that need to keep their state, like
+    // user uploaded data, file-based databases, etc.
+    'shared'         => [
+        'storage',
+        'vendor',
+        '.env',
+    ],
+
+    // Execution
+    //////////////////////////////////////////////////////////////////////
+
+    // If enabled will force a shell to be created
+    // which is required for some tools like RVM or NVM
+    'shell'          => false,
+
+    // An array of commands to run under shell
+    'shelled'        => ['which', 'ruby', 'npm', 'bower', 'bundle', 'grunt'],
+
+    // Enable use of sudo for some commands
+    // You can specify a sudo user by doing
+    // 'sudo' => 'the_user'
+    'sudo' => false,
+
+    // An array of commands to run under sudo
+    'sudoed' => [],
+
+    // Permissions$
+    ////////////////////////////////////////////////////////////////////
+
+    'permissions'    => [
+
+        // The folders and files to set as web writable
+        'files'    => [
+            'bootstrap/cache',
+            'storage',
+        ],
+
+        // Here you can configure what actions will be executed to set
+        // permissions on the folder above. The Closure can return
+        // a single command as a string or an array of commands
+        'callback' => function ($task, $file) {
+            return [
+                sprintf('chmod -R 777 %s', $file),
+                sprintf('chmod -R g+s %s', $file),
+                sprintf('chown -R www:www %s', $file),
+            ];
+        },
+
+    ],
+
+];

+ 35 - 0
.rocketeer/scm.php

@@ -0,0 +1,35 @@
+<?php
+
+return [
+
+    // SCM repository
+    //////////////////////////////////////////////////////////////////////
+
+    // The SCM used (supported: "git", "svn")
+    'scm'        => 'git',
+
+    // The SSH/HTTPS address to your repository
+    // Example: https://github.com/vendor/website.git
+    'repository' => 'http://caihongxingqiu:Ch20151002@git.caihongxingqiu.net/rainbow/config-service.git',
+
+    // The repository credentials : you can leave those empty
+    // if you're using SSH or if your repository is public
+    // In other cases you can leave this empty too, and you will
+    // be prompted for the credentials on deploy. If you don't want
+    // to be prompted (public repo, etc) set the values to null
+    'username'   => 'null',
+    'password'   => 'null',
+
+    // The branch to deploy
+    'branch'     => 'master',
+
+    // Whether your SCM should do a "shallow" clone of the repository
+    // or not – this means a clone with just the latest state of your
+    // application (no history)
+    // If you're having problems cloning, try setting this to false
+    'shallow'    => true,
+
+    // Recursively pull in submodules. Works only with GIT.
+    'submodules' => true,
+
+];

+ 19 - 0
.rocketeer/stages.php

@@ -0,0 +1,19 @@
+<?php
+
+return [
+
+    // Stages
+    //
+    // The multiples stages of your application
+    // if you don't know what this does, then you don't need it
+    //////////////////////////////////////////////////////////////////////
+
+    // Adding entries to this array will split the remote folder in stages
+    // Like /var/www/yourapp/staging and /var/www/yourapp/production
+    'stages'  => [],
+
+    // The default stage to execute tasks on when --stage is not provided
+    // Falsey means all of them
+    'default' => '',
+
+];

+ 61 - 0
.rocketeer/strategies.php

@@ -0,0 +1,61 @@
+<?php
+
+/*
+ * This file is part of Rocketeer
+ *
+ * (c) Maxime Fabre <ehtnam6@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+use Rocketeer\Binaries\PackageManagers\Composer;
+use Rocketeer\Tasks\Subtasks\Primer;
+
+return [
+
+    // Task strategies
+    //
+    // Here you can configure in a modular way which tasks to use to
+    // execute various core parts of your deployment's flow
+    //////////////////////////////////////////////////////////////////////
+
+    // Which strategy to use to check the server
+    'check'        => 'Php',
+
+    // Which strategy to use to create a new release
+    'deploy'       => 'Clone',
+
+    // Which strategy to use to test your application
+    'test'         => 'Phpunit',
+
+    // Which strategy to use to migrate your database
+    'migrate'      => 'Artisan',
+
+    // Which strategy to use to install your application's dependencies
+    'dependencies' => 'Composer',
+
+    // Execution hooks
+    //////////////////////////////////////////////////////////////////////
+
+    'composer'     => [
+        'install' => function (Composer $composer, $task) {
+            return $composer->install([], ['--no-interaction' => null, '--prefer-dist' => null]);
+        },
+        'update'  => function (Composer $composer) {
+            return $composer->update();
+        },
+    ],
+
+    // Here you can configure the Primer tasks
+    // which will run a set of commands on the local
+    // machine, determining whether the deploy can proceed
+    // or not
+    'primer'       => function (Primer $task) {
+        return [
+            // $task->executeTask('Test'),
+            // $task->binary('grunt')->execute('lint'),
+        ];
+    },
+
+];

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

@@ -0,0 +1,86 @@
+<?php
+
+namespace App\Console\Commands;
+
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Log;
+use Org\Multilinguals\Apollo\Client\ApolloClient;
+
+class Apollo extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'apollo';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'Apollo配置服务';
+
+
+    private $apollo;
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+
+        $this->save_dir = storage_path('apollo');
+        $this->config_tpl = config_path() . '/customer.tpl';
+        $this->config_file = config_path() . '/customer.php';
+
+        $this->apollo = new ApolloClient(
+            config('apollo.config_server'),
+            config('apollo.app_id'),
+            config('apollo.namespaces')
+        );
+        $this->apollo->save_dir = $this->save_dir;
+        if(!is_dir($this->save_dir)){
+            mkdir($this->save_dir);
+        }
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return mixed
+     */
+    public function handle()
+    {
+        Log::debug('apollo test');
+        $this->line('apollo配置服务开启');
+        $restart = true; //失败自动重启
+        do {
+            $error = $this->apollo->start(function () {
+                $list = glob($this->save_dir . DIRECTORY_SEPARATOR . 'apolloConfig.*');
+                $apollo = [];
+                foreach ($list as $l) {
+                    $config = require $l;
+                    if (is_array($config) && isset($config['configurations'])) {
+                        $apollo = array_merge($apollo, $config['configurations']);
+                    }
+                }
+                if (!$apollo) {
+                    Log::error('Load Apollo Config Failed, no config available');
+                }
+                $tpl = file_get_contents($this->config_tpl);
+                foreach ($apollo as $key =>$value){
+                    $tpl = str_replace('{'.$key.'}',$value,$tpl);
+                }
+                file_put_contents($this->config_file,$tpl);
+            }); //此处传入回调
+            if ($error) {
+                Log::info("Apollo Hand error :" . $error);
+            }
+        } while ($error && $restart);
+    }
+}

+ 2 - 1
app/Console/Kernel.php

@@ -2,6 +2,7 @@
 
 namespace App\Console;
 
+use App\Console\Commands\Apollo;
 use Illuminate\Console\Scheduling\Schedule;
 use Laravel\Lumen\Console\Kernel as ConsoleKernel;
 
@@ -13,7 +14,7 @@ class Kernel extends ConsoleKernel
      * @var array
      */
     protected $commands = [
-        //
+        Apollo::class
     ];
 
     /**

+ 61 - 0
app/Helper/helper.php

@@ -3,6 +3,20 @@
  * 添加自定义辅助函数
  */
 
+if ( ! function_exists('config_path'))
+{
+    /**
+     * Get the configuration path.
+     *
+     * @param string $path
+     * @return string
+     */
+    function config_path($path = '')
+    {
+        return app()->basePath() . '/config' . ($path ? '/' . $path : $path);
+    }
+}
+
 /**
  * 参数签名校验
  * @param array $params
@@ -22,6 +36,8 @@ function generateSign(array $params, $secret_key)
 
     // 生成 URL-encode 之后的请求字符串
     $str = http_build_query($params);
+
+    $str = urldecode($str);
     // 将请求字符串使用MD5加密后,再转换成大写,并返回
     return strtoupper(MD5($str));
 }
@@ -40,4 +56,49 @@ function verifySign($sign, $params, $secret_key)
         return false;
     };
 
+
 }
+
+     function jsonSuccess($data = [], $msg = "成功")
+    {
+        $response = array(
+            'code' => 0,
+            'msg' => $msg,
+            'data' => []
+        );
+        if ($data) {
+            if (is_array($data)) {
+                //带有分页格式转换
+                if (isset($data['meta'])) {
+                    // 更改元数据格式,全部包含在data下
+                    $temp = array(
+                        'data' => array(
+                            'data' => $data['data'],
+                            'pagination' => $data['meta']['pagination']
+                        )
+                    );
+                    $response = array_merge($response, $temp);
+                } elseif(isset($data['data'])) {
+                    $response = array_merge($response, $data);
+                }else{
+                    $temp = array(
+                        'data' => $data
+                    );
+                    $response = array_merge($response, $temp);
+                }
+            } else {
+                $response['data'] = $data;
+            }
+        }
+        return $response;
+    }
+
+        function jsonError($msg)
+        {
+            $response = array(
+                'code' => 1,
+                'msg' => $msg,
+                'data' => ""
+            );
+            return $response;
+        }

+ 10 - 0
app/Http/Controllers/AuthController.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Http\Controllers;
+
+
+class  AuthController extends BaseController
+{
+
+
+}

+ 9 - 0
app/Http/Controllers/BaseController.php

@@ -0,0 +1,9 @@
+<?php
+
+namespace App\Http\Controllers;
+
+
+class BaseController extends Controller
+{
+
+}

+ 35 - 0
app/Http/Controllers/ConfigCityManagementController.php

@@ -0,0 +1,35 @@
+<?php
+namespace App\Http\Controllers;
+use App\Repositories\ConfigCityManagementRepository;
+use App\Transformers\CityTransformer;
+use Illuminate\Http\Request;
+use League\Fractal\Resource\Collection;
+use League\Fractal\Manager;
+use League\Fractal\Pagination\IlluminatePaginatorAdapter;
+/**
+ * Created by PhpStorm.
+ * User: qinyaer
+ * Date: 2019/4/26
+ * Time: 下午14:36
+ */
+
+class ConfigCityManagementController extends BaseController
+{
+    public function __construct(ConfigCityManagementRepository $configCityManagementRepository) {
+
+        $this->configCityManagementRepository = $configCityManagementRepository;
+    }
+
+    //已开通城市列表
+    public function index(Request $request)
+    {
+        $cityList = $this->configCityManagementRepository->index($request->all());
+
+        $fractal = new Manager();
+        $resource = new Collection($cityList , new CityTransformer());
+        $resource->setPaginator(new IlluminatePaginatorAdapter($cityList));
+        $data = $fractal->createData($resource)->toArray();
+        return $this->jsonSuccess($data);
+    }
+
+}

+ 79 - 0
app/Http/Controllers/ConfigPickupNodeController.php

@@ -0,0 +1,79 @@
+<?php
+namespace App\Http\Controllers;
+use App\Models\ConfigPickupNode;
+use App\Repositories\ConfigPickupNodeRepository;
+use App\Transformers\PickupNodeTransformer;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+use JeroenDesloovere\Distance\Distance;
+use League\Fractal\Resource\Collection;
+use League\Fractal\Manager;
+use League\Fractal\Pagination\IlluminatePaginatorAdapter;
+use Illuminate\Support\Facades\Validator;
+/**
+ * Created by PhpStorm.
+ * User: qinyaer
+ * Date: 2019/4/25
+ * Time: 上午10:09
+ */
+
+class ConfigPickupNodeController extends BaseController
+{
+    public function __construct(ConfigPickupNodeRepository $configPickupNodeRepository) {
+
+        $this->configPickupNodeRepository = $configPickupNodeRepository;
+    }
+
+    public function index(Request $request)
+    {
+        //自提点列表
+        $configPickupNode = $this->configPickupNodeRepository->index($request->all());
+
+        if (count($configPickupNode)>0) {
+
+            foreach ($configPickupNode as $k => $v) {
+                $configPickupNode[$k]->receive_type = $v->receive_type == 0 ? '信任交付' : '手动确认接货';
+
+                $configPickupNode[$k]->status = $v->status == 0 ? '禁用' : '启用';
+
+                $configPickupNode[$k]->store_ids = $v->getStoreNameAttribute();//储存方式名称
+                $configPickupNode[$k]->pickup_group_id = $v->getGroupNameAttribute();//自提点分组名称
+                $configPickupNode[$k]->distance = Distance::between(
+                    $request['latitude'], $request['longitude'], $v->latitude, $v->longitude
+                );
+            }
+        }
+
+        $fractal = new Manager();
+        $resource = new Collection($configPickupNode , new PickupNodeTransformer());
+        $resource->setPaginator(new IlluminatePaginatorAdapter($configPickupNode));
+        $data = $fractal->createData($resource)->toArray();
+        return $this->jsonSuccess($data);
+    }
+
+    //查看某自提点
+    public function getPickupNode(Request $request)
+    {
+        $all = $request->all();
+        $validator = Validator::make($all, [
+            'id' => 'required|integer',
+        ]);
+
+        $getPickup = ConfigPickupNode::where('id',$all['id'])->first();
+
+        if(!$getPickup){
+            return $this->jsonError('该自提点不存在或已删除');
+        }
+        if($validator->fails()) {
+            return $this->jsonError($validator->errors()->first());
+        }
+        $getPickup->receive_type = $getPickup->receive_type == 0 ? '信任交付':'手动确认接货';
+        $getPickup->status = $getPickup->status == 0 ? '禁用':'启用';
+        $getPickup->store_ids = $getPickup->getStoreNameAttribute();
+        $getPickup->pickup_group_id = $getPickup->getGroupNameAttribute();
+
+        return $this->jsonSuccess($getPickup);
+
+    }
+
+}

+ 35 - 0
app/Http/Controllers/ConfigProvinceController.php

@@ -0,0 +1,35 @@
+<?php
+namespace App\Http\Controllers;
+use App\Repositories\ConfigProvinceRepository;
+use App\Transformers\ProvinceTransformer;
+use Illuminate\Http\Request;
+use League\Fractal\Resource\Collection;
+use League\Fractal\Manager;
+use League\Fractal\Pagination\IlluminatePaginatorAdapter;
+/**
+ * Created by PhpStorm.
+ * User: qinyaer
+ * Date: 2019/4/26
+ * Time: 下午15:09
+ */
+
+class ConfigProvinceController extends BaseController
+{
+    public function __construct(ConfigProvinceRepository $configProvinceRepository) {
+
+        $this->configProvinceRepository = $configProvinceRepository;
+    }
+
+    //获取省市区
+    public function index(Request $request)
+    {
+        $cityList = $this->configProvinceRepository->index($request->all());
+
+        $fractal = new Manager();
+        $resource = new Collection($cityList , new ProvinceTransformer());
+        $resource->setPaginator(new IlluminatePaginatorAdapter($cityList));
+        $data = $fractal->createData($resource)->toArray();
+        return $this->jsonSuccess($data);
+    }
+
+}

+ 7 - 2
app/Http/Controllers/Controller.php

@@ -20,7 +20,7 @@ class Controller extends BaseController
         if ($data) {
             if (is_array($data)) {
                 //带有分页格式转换
-                if (isset($data['meta'], $data['data'])) {
+                if (isset($data['meta'])) {
                     // 更改元数据格式,全部包含在data下
                     $temp = array(
                         'data' => array(
@@ -29,8 +29,13 @@ class Controller extends BaseController
                         )
                     );
                     $response = array_merge($response, $temp);
-                } else {
+                } elseif(isset($data['data'])) {
                     $response = array_merge($response, $data);
+                }else{
+                    $temp = array(
+                        'data' => $data
+                    );
+                    $response = array_merge($response, $temp);
                 }
             } else {
                 $response['data'] = $data;

+ 35 - 0
app/Http/Controllers/StoreTypeController.php

@@ -0,0 +1,35 @@
+<?php
+namespace App\Http\Controllers;
+use App\Repositories\ConfigStoreTypeRepository;
+use App\Transformers\ConfigStoreTypeTransformer;
+use Illuminate\Http\Request;
+use League\Fractal\Resource\Collection;
+use League\Fractal\Manager;
+use League\Fractal\Pagination\IlluminatePaginatorAdapter;
+/**
+ * Created by PhpStorm.
+ * User: qinyaer
+ * Date: 2019/4/26
+ * Time: 下午15:09
+ */
+
+class StoreTypeController extends BaseController
+{
+    public function __construct(ConfigStoreTypeRepository $configStoreTypeRepository) {
+
+        $this->configStoreTypeRepository = $configStoreTypeRepository;
+    }
+
+    //储存方式列表
+    public function index(Request $request)
+    {
+        $cityList = $this->configStoreTypeRepository->index($request->all());
+
+        $fractal = new Manager();
+        $resource = new Collection($cityList , new ConfigStoreTypeTransformer());
+        $resource->setPaginator(new IlluminatePaginatorAdapter($cityList));
+        $data = $fractal->createData($resource)->toArray();
+        return $this->jsonSuccess($data);
+    }
+
+}

+ 36 - 0
app/Http/Controllers/UploadController.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Log;
+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();
+//            //获取文件的扩展名
+            $kuoname=$request->file('image')->getClientOriginalExtension();
+//            //获取文件的类型
+//            $type=$request->file('image')->getClientMimeType();
+//            //获取文件的绝对路径,但是获取到的在本地不能打开
+            $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{
+                return $this->jsonError('图片上传失败,请重试');
+            }
+        }else{
+            return $this->jsonError('仅支持图片上传,请重试');
+        }
+    }
+}

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

@@ -43,7 +43,7 @@ class Authenticate
             return response()->json($error)->setStatusCode(401);
         }
         $user = $this->auth->user();
-        if (!verifySign($request->get('sign'), $request->all(), md5($user['id']))) {
+        if (!verifySign($request->get('sign'), $request->all(), config('customer.app_secret'))) {
             $error = [
                 'message' => '数据验签失败',
                 'code' => 401,

+ 21 - 6
app/Http/Middleware/JwtAuthMiddleware.php

@@ -3,10 +3,11 @@
 namespace App\Http\Middleware;
 
 use Closure;
+use function FastRoute\TestFixtures\empty_options_cached;
 use Tymon\JWTAuth\Exceptions\JWTException;
 use Tymon\JWTAuth\Exceptions\TokenExpiredException;
+use Tymon\JWTAuth\Exceptions\TokenInvalidException;
 use Tymon\JWTAuth\Facades\JWTAuth;
-use Tymon\JWTAuth\Http\Middleware\BaseMiddleware;
 
 class JwtAuthMiddleware
 {
@@ -21,15 +22,22 @@ class JwtAuthMiddleware
     {
 
         try {
-            $user = JWTAuth::parseToken()->authenticate();
-            if (!verifySign($request->get('sign'), $request->all(), md5($user['id']))) {
+            $token = JWTAuth::getToken();
+            if(empty($token)){
                 $error = [
-                    'message' => '数据验签失败',
+                    'message' => 'token is required',
                     'code' => 401,
                 ];
-                return response()->json($error)->setStatusCode(401);
+                return response()->json($error);
+            }
+            $data = JWTAuth::decode($token)['user'];
+            if ($data->sign !== md5($data->uid . env('JWT_SECRET'))) {
+                $error = [
+                    'message' => 'request is not allow',
+                    'code' => 401,
+                ];
+                return response()->json($error);
             }
-
         } catch (TokenExpiredException $e) {
             $error = [
                 'message' => 'Token is Expired',
@@ -47,6 +55,13 @@ class JwtAuthMiddleware
                 'message' => $e->getMessage(),
                 'code' => 401,
             ];
+
+            return response()->json($error)->setStatusCode(401);
+        }catch (\Exception $e){
+            $error = [
+                'message' => $e->getMessage(),
+                'code' => 401,
+            ];
             return response()->json($error)->setStatusCode(401);
         }
         return $next($request);

+ 37 - 0
app/Http/Middleware/SignAuthMiddleware.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Closure;
+
+class SignAuthMiddleware
+{
+    /**
+     * Handle an incoming request.
+     *
+     * @param  \Illuminate\Http\Request $request
+     * @param  \Closure $next
+     * @return mixed
+     */
+    public function handle($request, Closure $next)
+    {
+
+        try {
+            if (!verifySign($request->get('sign'), $request->all(), config('customer.app_secret'))) {
+                $error = [
+                    'message' => '数据验签失败',
+                    'code' => 401,
+                ];
+                return response()->json($error)->setStatusCode(401);
+            }
+
+        } catch (\Exception $e) {
+            $error = [
+                'message' => $e->getMessage(),
+                'code' => 401,
+            ];
+            return response()->json($error)->setStatusCode(401);
+        }
+        return $next($request);
+    }
+}

+ 12 - 0
app/Models/BaseModel.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class BaseModel extends Model
+{
+    protected $guarded = ['id'];
+
+    protected $hidden = ['deleted_at'];
+}

+ 22 - 0
app/Models/ConfigCityManagement.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Models;
+
+
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+class ConfigCityManagement extends BaseModel
+{
+    use SoftDeletes;
+
+    protected $dates = ['deleted_at'];
+    protected  $table = 'config_city_management';
+
+    /**
+     * 可被批量赋值的字段
+     * @var array
+     */
+    protected $fillable = ['province_id','city_id','province_name','city_name','express_type'];
+
+
+}

+ 19 - 0
app/Models/ConfigPickupGroup.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Models;
+
+
+class ConfigPickupGroup extends BaseModel
+{
+    protected  $table = 'config_pickup_group';
+
+    /**
+     * 相对关联到自提点表
+     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+     */
+    public function configPickupNode(){
+        return $this->belongsTo('App\Models\ConfigPickupNode', 'pickup_group_id');
+    }
+
+
+}

+ 53 - 0
app/Models/ConfigPickupNode.php

@@ -0,0 +1,53 @@
+<?php
+
+namespace App\Models;
+
+
+class ConfigPickupNode extends BaseModel
+{
+    protected  $table = 'config_pickup_node';
+
+    /**
+     * 可被批量赋值的字段
+     * @var array
+     */
+    protected $fillable = ['pickup_group_id','store_ids','city_name','city_id','name','address','longitude','latitude','pickup_code','distance','work_time','manager_name','manager_mobile','store_ids','receive_type'];
+
+    //一对多关联储存方式表
+    public function configStoreType()
+    {
+        return $this->hasMany('App\Models\ConfigStoreType','store_ids');
+    }
+
+    //一对多关联自提点分组表
+    public function configPickupGroup()
+    {
+        return $this->hasMany('App\Models\configPickupGroup','pickup_group_id');
+    }
+
+    //获取储存方式名称
+    public function getStoreNameAttribute()
+    {
+        $storeId = ConfigStoreType::find($this->store_ids);
+
+        if($storeId){
+            return $storeId->name;
+        }
+        return '';
+
+    }
+
+    //获取自提点分组名称
+    public function getGroupNameAttribute()
+    {
+        $groupName = ConfigPickupGroup::find($this->pickup_group_id);
+
+        if($groupName){
+            return $groupName->name;
+        }
+        return '';
+
+    }
+
+
+}

+ 16 - 0
app/Models/ConfigProvince.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Models;
+
+
+class ConfigProvince extends BaseModel
+{
+    protected  $table = 'config_province';
+
+    /**
+     * 可被批量赋值的字段
+     * @var array
+     */
+    protected $fillable = ['area_id','area_code','area_name','level','city_code','center','parent_id','sort','bjcity_id'];
+
+}

+ 18 - 0
app/Models/ConfigStoreType.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace App\Models;
+
+
+class ConfigStoreType extends BaseModel
+{
+    protected  $table = 'config_store_type';
+
+    /**
+     * 相对关联到自提点表
+     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+     */
+    public function configPickupNode(){
+        return $this->belongsTo('App\Models\ConfigPickupNode', 'store_ids');
+    }
+
+}

+ 32 - 0
app/Repositories/ConfigCityManagementRepository.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace App\Repositories;
+
+use App\Models\ConfigCityManagement;
+
+class ConfigCityManagementRepository
+{
+    public function __construct(ConfigCityManagement $configCityManagement)
+    {
+        $this->configCityManagement = $configCityManagement;
+    }
+
+
+    public function index($request)
+    {
+        $perPage = isset($request['per_page']) ? $request['per_page'] : env('PER_PAGE');
+        if (isset($request['city_id'])) {
+
+            $this->configCityManagement = $this->configCityManagement
+                ->orderBy('id', 'desc')
+                ->where(['status' => 1,'city_id' => $request['city_id']]);
+        }else{
+            $this->configCityManagement = $this->configCityManagement
+                ->orderBy('id', 'desc')
+                ->where('status',1);
+        }
+
+            return $this->configCityManagement->paginate($perPage);
+
+    }
+}

+ 35 - 0
app/Repositories/ConfigPickupNodeRepository.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace App\Repositories;
+
+
+
+use App\Models\ConfigPickupNode;
+
+class ConfigPickupNodeRepository
+{
+    public function __construct(ConfigPickupNode $configPickupNode)
+    {
+        $this->configPickupNode = $configPickupNode;
+    }
+
+    //列表
+    public function index($request)
+    {
+        $perPage = isset($request['per_page']) ? $request['per_page'] : env('PER_PAGE');
+        if (isset($request['keyword'])) {
+            $this->configPickupNode = $this->configPickupNode
+                ->orderBy('id', 'desc')
+                ->where('city_id', $request['city_id'])
+                ->where(function ($query) use ($request) {
+                        $query->where('status', 1)
+                        ->orWhere('name', 'like', "{$request['keyword']}%");
+                });
+        }else{
+            $this->configPickupNode = $this->configPickupNode
+                ->orderBy('id', 'desc')->where(['status' => 1,'city_id' => $request['city_id']]);
+        }
+            return $this->configPickupNode->paginate($perPage);
+
+    }
+}

+ 26 - 0
app/Repositories/ConfigProvinceRepository.php

@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Repositories;
+
+
+use App\Models\ConfigProvince;
+
+class ConfigProvinceRepository
+{
+    public function __construct(ConfigProvince $configProvince)
+    {
+        $this->configProvince = $configProvince;
+    }
+
+
+    public function index($request)
+    {
+        $perPage = isset($request['per_page']) ? $request['per_page'] : env('PER_PAGE');
+
+        $this->configProvince = $this->configProvince
+                ->orderBy('bjcity_id', 'desc');
+
+            return $this->configProvince->paginate($perPage);
+
+    }
+}

+ 27 - 0
app/Repositories/ConfigStoreTypeRepository.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace App\Repositories;
+
+
+
+use App\Models\ConfigStoreType;
+
+class ConfigStoreTypeRepository
+{
+    public function __construct(ConfigStoreType $configStoreType)
+    {
+        $this->configStoreType = $configStoreType;
+    }
+
+
+    public function index($request)
+    {
+        $perPage = isset($request['per_page']) ? $request['per_page'] : env('PER_PAGE');
+
+        $this->configStoreType = $this->configStoreType
+                ->orderBy('id', 'desc');
+
+            return $this->configStoreType->paginate($perPage);
+
+    }
+}

+ 23 - 0
app/Transformers/CityTransformer.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace App\Transformers;
+
+use App\Models\ConfigCityManagement;
+use League\Fractal\TransformerAbstract;
+
+class CityTransformer extends TransformerAbstract
+{
+
+    public function transform(ConfigCityManagement $city)
+    {
+        return [
+            'id'  => $city['id'],
+            'province_id'  => $city['province_id'],
+            'province_name'    => $city['province_name'],
+            'city_name'    => $city['city_name'],
+            'city_id'    => $city['city_id'],
+            'express_type'    => $city['express_type'],
+            'status'    => $city['status'],
+        ];
+    }
+}

+ 18 - 0
app/Transformers/ConfigStoreTypeTransformer.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace App\Transformers;
+
+use App\Models\ConfigStoreType;
+use League\Fractal\TransformerAbstract;
+
+class ConfigStoreTypeTransformer extends TransformerAbstract
+{
+
+    public function transform(ConfigStoreType $ConfigStoreType)
+    {
+        return [
+            'id'  => $ConfigStoreType['id'],
+            'name'    => $ConfigStoreType['name'],
+        ];
+    }
+}

+ 40 - 0
app/Transformers/PickupNodeTransformer.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace App\Transformers;
+
+use App\Models\ConfigPickupNode;
+use League\Fractal\TransformerAbstract;
+
+class PickupNodeTransformer extends TransformerAbstract
+{
+
+    public function transform(ConfigPickupNode $ConfigPickupNode)
+    {
+        $distance = number_format($ConfigPickupNode['distance'], 1);
+        if ($distance == 0) {
+            $distance_str = "附近";
+        } elseif ($distance >= 1) {
+            $distance_str = $distance . " km";
+        } else {
+            $distance_str = ($distance * 100) . " m";
+        }
+        return [
+            'id' => $ConfigPickupNode['id'],
+            'city_id' => $ConfigPickupNode['city_id'],
+            'city_name' => $ConfigPickupNode['city_name'],
+            'name' => $ConfigPickupNode['name'],
+            'address' => $ConfigPickupNode['address'],
+            'work_time' => $ConfigPickupNode['work_time'],
+            'manager_name' => $ConfigPickupNode['manager_name'],
+            'manager_mobile' => $ConfigPickupNode['manager_mobile'],
+            'receive_type' => $ConfigPickupNode['receive_type'],
+            'longitude' => $ConfigPickupNode['longitude'],
+            'latitude' => $ConfigPickupNode['latitude'],
+            'store_ids' => $ConfigPickupNode['store_ids'],
+            'pickup_group_id' => $ConfigPickupNode['pickup_group_id'],
+            'status' => $ConfigPickupNode['status'],
+            'distance' => $distance_str,
+        ];
+
+    }
+}

+ 24 - 0
app/Transformers/ProvinceTransformer.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Transformers;
+
+use App\Models\ConfigProvince;
+use League\Fractal\TransformerAbstract;
+
+class ProvinceTransformer extends TransformerAbstract
+{
+
+    public function transform(ConfigProvince $province)
+    {
+        return [
+            'bjcity_id'  => $province['bjcity_id'],
+            'parent_id'  => $province['parent_id'],
+            'area_name'    => $province['area_name'],
+            'level'    => $province['level'],
+            'sort'    => $province['sort'],
+            'area_code'    => $province['area_code'],
+            'city_code'    => $province['city_code'],
+            'center'    => $province['center'],
+        ];
+    }
+}

+ 1 - 1
bin/fswatch

@@ -9,7 +9,7 @@ echo "Restarting LaravelS..."
 
 echo "Starting fswatch..."
 LOCKING=0
-fswatch -r -e ".*" -i "\\.php$" ${WORK_DIR} | while read file
+fswatch -e ".*" -i "\\.php$" -m poll_monitor -r ${WORK_DIR} | while read file
 do
     if [[ ! ${file} =~ .php$ ]] ;then
         continue

+ 6 - 1
bootstrap/app.php

@@ -26,8 +26,10 @@ $app->withFacades();
 $app->withEloquent();
 
 $app->configure('api');
+$app->configure('apollo');
 $app->configure('auth');
 $app->configure('jwt');
+$app->configure('customer');
 /*
 |--------------------------------------------------------------------------
 | Register Container Bindings
@@ -49,6 +51,7 @@ $app->singleton(
     App\Console\Kernel::class
 );
 
+
 /*
 |--------------------------------------------------------------------------
 | Register Middleware
@@ -62,7 +65,8 @@ $app->singleton(
 
 $app->routeMiddleware([
     'auth' => App\Http\Middleware\Authenticate::class,
-    'jwt.chxq_auth' => App\Http\Middleware\SignMiddleware::class,
+    'chxq_jwt_auth' => App\Http\Middleware\JwtAuthMiddleware::class,
+    'chxq_sign' => App\Http\Middleware\SignAuthMiddleware::class,
 ]);
 
 /*
@@ -81,6 +85,7 @@ $app->register(App\Providers\AuthServiceProvider::class);
 
 $app->register(Dingo\Api\Provider\LumenServiceProvider::class);
 $app->register(Tymon\JWTAuth\Providers\LumenServiceProvider::class);
+$app->register(\Junliuxian\AliOSS\AliOssServiceProvider::class);
 
 /*
 |--------------------------------------------------------------------------

+ 4 - 0
composer.json

@@ -7,10 +7,14 @@
     "require": {
         "php": ">=7.1.3",
         "dingo/api": "^2.2",
+        "doctrine/dbal": "^2.9",
         "hhxsv5/laravel-s": "~3.4.0",
+        "jeroendesloovere/distance": "1.0.2.1",
+        "junliuxian/ali-oss-storage": "~2.0",
         "laravel/lumen-framework": "5.8.*",
         "league/fractal": "^0.17.0",
         "tymon/jwt-auth": "1.0.0-rc.4.1",
+        "multilinguals/apollo-client": "^0.1.2",
         "vlucas/phpdotenv": "^3.3"
     },
     "require-dev": {

+ 1 - 1
config/api.php

@@ -57,7 +57,7 @@ return [
     |
     */
 
-    'prefix' => env('API_PREFIX', 'api'),
+    'prefix' => env('API_PREFIX', '/'),
 
     /*
     |--------------------------------------------------------------------------

+ 10 - 0
config/apollo.php

@@ -0,0 +1,10 @@
+<?php
+
+return [
+    'namespaces' => explode(',', env('APOLLO_NAMESPACES')),
+    'cluster' => env('APOLLO_CLUSTER'),
+    'save_dir' => storage_path('apollo'),
+    'config_server' => env('APOLLO_CONFIG_SERVER'),
+    'app_id' => env('APP_ID'),
+    'timeout_interval' => 70
+];

+ 7 - 0
config/customer.tpl

@@ -0,0 +1,7 @@
+<?php
+//此文件为apollo配置文件模板,禁止修改移动
+return [
+    'app_secret' => '{app_secret}',
+    'jwt_secret' => '{jwt_secret}',
+    'app_service_url' => '{app_service_url}',
+];

+ 82 - 0
config/filesystems.php

@@ -0,0 +1,82 @@
+<?php
+
+return [
+
+    /*
+    |--------------------------------------------------------------------------
+    | Default Filesystem Disk
+    |--------------------------------------------------------------------------
+    |
+    | Here you may specify the default filesystem disk that should be used
+    | by the framework. The "local" disk, as well as a variety of cloud
+    | based disks are available to your application. Just store away!
+    |
+    */
+
+    'default' => env('FILESYSTEM_DRIVER', 'oss'),
+
+    /*
+    |--------------------------------------------------------------------------
+    | Default Cloud Filesystem Disk
+    |--------------------------------------------------------------------------
+    |
+    | Many applications store files both locally and in the cloud. For this
+    | reason, you may specify a default "cloud" driver here. This driver
+    | will be bound as the Cloud disk implementation in the container.
+    |
+    */
+
+    'cloud' => env('FILESYSTEM_CLOUD', 's3'),
+
+    /*
+    |--------------------------------------------------------------------------
+    | Filesystem Disks
+    |--------------------------------------------------------------------------
+    |
+    | Here you may configure as many filesystem "disks" as you wish, and you
+    | may even configure multiple disks of the same driver. Defaults have
+    | been setup for each driver as an example of the required options.
+    |
+    | Supported Drivers: "local", "ftp", "sftp", "s3", "rackspace"
+    |
+    */
+
+    'disks' => [
+
+        'local' => [
+            'driver' => 'local',
+            'root' => storage_path('app'),
+        ],
+
+        'public' => [
+            'driver' => 'local',
+            'root' => storage_path('app/public'),
+            'url' => env('APP_URL') . '/storage',
+            'visibility' => 'public',
+        ],
+
+        's3' => [
+            'driver' => 's3',
+            'key' => env('AWS_ACCESS_KEY_ID'),
+            'secret' => env('AWS_SECRET_ACCESS_KEY'),
+            'region' => env('AWS_DEFAULT_REGION'),
+            'bucket' => env('AWS_BUCKET'),
+            'url' => env('AWS_URL'),
+        ],
+
+        'oss' => [
+            'driver' => 'oss',
+            'access_id' => 'LTAIGTDKUOVQf2Ln',
+            'access_key' => 'HzY9r2gDPbURQ0Vp69A7THV0RmxMkb',
+            'bucket' => 'rainbowstar',
+            'endpoint' => 'oss-cn-zhangjiakou.aliyuncs.com', // OSS 外网节点或自定义外部域名
+//            'endpoint_internal' => '<internal endpoint [OSS内网节点] 如:oss-cn-shenzhen-internal.aliyuncs.com>', // v2.0.4 新增配置属性,如果为空,则默认使用 endpoint 配置(由于内网上传有点小问题未解决,请大家暂时不要使用内网节点上传,正在与阿里技术沟通中)
+            'cdnDomain' => '', // 如果isCName为true, getUrl会判断cdnDomain是否设定来决定返回的url,如果cdnDomain未设置,则使用endpoint来生成url,否则使用cdn
+            'ssl' => false, // true to use 'https://' and false to use 'http://'. default is false,
+            'isCName' => false, // 是否使用自定义域名,true: 则Storage.url()会使用自定义的cdn或域名生成文件url, false: 则使用外部节点生成url
+            'debug' => true,
+        ],
+
+    ],
+
+];

+ 1 - 1
config/jwt.php

@@ -25,7 +25,7 @@ return [
     |
     */
 
-    'secret' => env('JWT_SECRET'),
+    'secret' => env('JWT_SECRET',config('customer.jwt_secret')),
 
     /*
     |--------------------------------------------------------------------------

+ 1 - 1
config/laravels.php

@@ -8,7 +8,7 @@ return [
     'listen_port'              => env('LARAVELS_LISTEN_PORT', 18208),
     'socket_type'              => defined('SWOOLE_SOCK_TCP') ? SWOOLE_SOCK_TCP : 1,
     'enable_coroutine_runtime' => false,
-    'server'                   => env('LARAVELS_SERVER', 'LaravelS'),
+    'server'                   => env('LARAVELS_SERVER', 'config-service'),
     'handle_static'            => env('LARAVELS_HANDLE_STATIC', false),
     'laravel_base_path'        => env('LARAVEL_BASE_PATH', base_path()),
     'inotify_reload'           => [

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

@@ -0,0 +1,32 @@
+<?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');
+    }
+}

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

@@ -0,0 +1,35 @@
+<?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');
+    }
+}

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

@@ -0,0 +1,38 @@
+<?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');
+    }
+}

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

@@ -0,0 +1,45 @@
+<?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');
+    }
+}

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

@@ -0,0 +1,32 @@
+<?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');
+    }
+}

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

@@ -0,0 +1,32 @@
+<?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']);
+        });
+    }
+}

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

@@ -0,0 +1,36 @@
+<?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');
+        });
+    }
+}

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

@@ -0,0 +1,32 @@
+<?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) {
+            //
+        });
+    }
+}

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

@@ -0,0 +1,32 @@
+<?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) {
+        });
+    }
+}

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

@@ -0,0 +1,32 @@
+<?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) {
+            //
+        });
+    }
+}

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

@@ -0,0 +1,32 @@
+<?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) {
+            //
+        });
+    }
+}

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

@@ -0,0 +1,32 @@
+<?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) {
+            //
+        });
+    }
+}

+ 20 - 0
deploy/nginx/conf.d/app.beta.conf

@@ -0,0 +1,20 @@
+server {
+    listen 80;
+    index index.php index.html;
+    error_log  /var/log/nginx/error.log;
+    access_log /var/log/nginx/access.log;
+    root /var/www/public;
+    location ~ \.php$ {
+        try_files $uri =404;
+        fastcgi_split_path_info ^(.+\.php)(/.+)$;
+        fastcgi_pass app_config_service_beta:9000;
+        fastcgi_index index.php;
+        include fastcgi_params;
+        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+        fastcgi_param PATH_INFO $fastcgi_path_info;
+    }
+    location / {
+        try_files $uri $uri/ /index.php?$query_string;
+        gzip_static on;
+    }
+}

+ 20 - 0
deploy/nginx/conf.d/app.dev.conf

@@ -0,0 +1,20 @@
+server {
+    listen 80;
+    index index.php index.html;
+    error_log  /var/log/nginx/error.log;
+    access_log /var/log/nginx/access.log;
+    root /var/www/public;
+    location ~ \.php$ {
+        try_files $uri =404;
+        fastcgi_split_path_info ^(.+\.php)(/.+)$;
+        fastcgi_pass app_config_service_dev:9000;
+        fastcgi_index index.php;
+        include fastcgi_params;
+        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+        fastcgi_param PATH_INFO $fastcgi_path_info;
+    }
+    location / {
+        try_files $uri $uri/ /index.php?$query_string;
+        gzip_static on;
+    }
+}

+ 2 - 0
deploy/php/local.ini

@@ -0,0 +1,2 @@
+upload_max_filesize=40M
+post_max_size=40M

+ 32 - 0
docker-compose-beta.yml

@@ -0,0 +1,32 @@
+version: '3'
+
+services:
+  app_config_service_beta:
+    image: harbor.caihongxingqiu.com:9401/library/php:latest
+    tty: true
+    working_dir: /var/www
+    volumes:
+      - ./:/var/www
+      - ./deploy/php/local.ini:/usr/local/etc/php/conf.d/local.ini
+      - /data/wwwroot/beta/config-service:/data/wwwroot/beta/config-service
+    networks:
+      - chxq
+
+  server_config_service_beta:
+    image: harbor.caihongxingqiu.com:9401/library/nginx:latest
+    tty: true
+    depends_on:
+      - app_config_service_beta
+    ports:
+      - "28208:80"
+    volumes:
+      - ./:/var/www
+      - ./deploy/nginx/conf.d/app.beta.conf:/etc/nginx/conf.d/app.beta.conf
+    networks:
+      - chxq
+
+#docker networks
+#docker network create --driver overlay chxq
+networks:
+  chxq:
+    external: true

+ 31 - 0
docker-compose-dev.yml

@@ -0,0 +1,31 @@
+version: '3'
+
+services:
+  app_config_service_dev:
+    image: harbor.caihongxingqiu.com:9401/library/php:latest
+    tty: true
+    working_dir: /var/www
+    volumes:
+      - ./:/var/www
+      - ./deploy/php/local.ini:/usr/local/etc/php/conf.d/local.ini
+    networks:
+      - chxq
+
+  server_config_service_dev:
+    image: harbor.caihongxingqiu.com:9401/library/nginx:latest
+    tty: true
+    depends_on:
+      - app_config_service_dev
+    ports:
+      - "18208:80"
+    volumes:
+      - ./:/var/www
+      - ./deploy/nginx/conf.d/app.dev.conf:/etc/nginx/conf.d/app.dev.conf
+    networks:
+      - chxq
+
+#docker networks
+#docker network create --driver overlay chxq
+networks:
+  chxq:
+    external: true

+ 21 - 30
routes/api.php

@@ -16,37 +16,28 @@ $api = app('Dingo\Api\Routing\Router');
 $api->version('v1', [
     'namespace' => 'App\Http\Controllers',
 ], function ($api) {
-    //登录
-    $api->post('login', 'AuthController@authenticate');
-    //测试签名
-    $api->post('sign', 'IndexController@index4');
-    //测试支付宝 支付
-    $api->post('alipay', 'AlipayController@index');
-    //回调
-    $api->post('return', 'AlipayController@return');
-    //异步回调
-    $api->post('notify', 'AlipayController@notify');
-    //测试微信支付
-    $api->post('weixin', 'WeixinPayController@index');
-    //微信回调
-    $api->post('wxin_notify', 'WeixinPayController@notify');
-
 
-
-    $api->group(['middleware' => 'auth:api'], function ($api) {
-        //登出
-        $api->post('logout', 'AuthController@logout');
-        //刷新身份令牌
-        $api->post('refresh', 'AuthController@refresh');
-        //测试
-        $api->post('products', 'ProductsController@index');
+    //登录
+    $api->group(['middleware' => 'chxq_jwt_auth'], function ($api) {
+        $api->post('upload', 'UploadController@uploadImage');
     });
-
-    $api->group(['middleware' => 'jwt.chxq_auth'], function ($api) {
-        $api->get('user', 'IndexController@index');
-        $api->get('user2', 'IndexController@index2');
-        $api->get('user3', 'IndexController@index3');
-        $api->get('error', 'IndexController@error');
-
+    //登录+验签
+    $api->group(['middleware' => ['chxq_jwt_auth','chxq_sign']], function ($api) {
     });
+    //仅验签
+    $api->group(['middleware' => 'chxq_sign'], function ($api) {
+        //自提点列表
+        $api->get('/pickupNode/index','ConfigPickupNodeController@index');
+        //获取某自提点
+        $api->post('/pickupNode/getPickupNode','ConfigPickupNodeController@getPickupNode');
+
+        //已开通城市列表
+        $api->get('/cityManagement/index','ConfigCityManagementController@index');
+        //获取省市区
+        $api->get('/configProvince/index', 'ConfigProvinceController@index');
+
+        //储存方式列表
+        $api->get('/storeType/index', 'StoreTypeController@index');
+    });
+
 });

+ 3 - 3
routes/web.php

@@ -16,6 +16,6 @@ $router->get('/', function () use ($router) {
 });
 
 
-$router->get('/test', function () use ($router) {
-    return 'test';
-});
+//add in header   Accept:application/vnd.lumen.v1+json
+$api = app('Dingo\Api\Routing\Router');
+