From 1af1e9cc1bbd5d387cd46ab2336257763d4b494e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Tue, 26 Jul 2022 20:05:14 +0800 Subject: [PATCH 01/68] =?UTF-8?q?feat:=20#20220726=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E6=A8=A1=E5=9E=8B=E6=9E=84=E5=BB=BA=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 14 +- .../Controllers/Auth/RegisterController.php | 4 +- app/Models/DailyStockRecord.php | 8 + app/Models/FailedJob.php | 8 + app/Models/Goods.php | 8 + app/Models/GoodsBrand.php | 8 + app/Models/GoodsSku.php | 8 + app/Models/GoodsType.php | 8 + app/Models/Log.php | 8 + app/Models/Model.php | 23 +++ app/Models/ModelHasPermissions.php | 8 + app/Models/ModelHasRoles.php | 8 + app/Models/PasswordReset.php | 8 + app/Models/Permission.php | 8 + app/Models/Role.php | 8 + app/Models/RoleHasPermission.php | 8 + app/{ => Models}/User.php | 3 +- composer.json | 3 +- composer.lock | 84 ++++++++- config/app.php | 4 +- config/auth.php | 2 +- config/permission.php | 161 ++++++++++++++++++ database/factories/UserFactory.php | 2 +- ..._07_25_060932_create_permission_tables.php | 141 +++++++++++++++ ..._07_26_061712_create_goods_types_table.php | 35 ++++ ...07_26_085847_create_goods_brands_table.php | 35 ++++ .../2022_07_26_090143_create_goods_table.php | 38 +++++ ...2_07_26_090150_create_goods_skus_table.php | 43 +++++ ...03559_create_daily_stock_records_table.php | 36 ++++ .../2022_07_26_105818_create_logs_table.php | 39 +++++ 30 files changed, 756 insertions(+), 15 deletions(-) create mode 100644 app/Models/DailyStockRecord.php create mode 100644 app/Models/FailedJob.php create mode 100644 app/Models/Goods.php create mode 100644 app/Models/GoodsBrand.php create mode 100644 app/Models/GoodsSku.php create mode 100644 app/Models/GoodsType.php create mode 100644 app/Models/Log.php create mode 100644 app/Models/Model.php create mode 100644 app/Models/ModelHasPermissions.php create mode 100644 app/Models/ModelHasRoles.php create mode 100644 app/Models/PasswordReset.php create mode 100644 app/Models/Permission.php create mode 100644 app/Models/Role.php create mode 100644 app/Models/RoleHasPermission.php rename app/{ => Models}/User.php (91%) create mode 100644 config/permission.php create mode 100644 database/migrations/2022_07_25_060932_create_permission_tables.php create mode 100644 database/migrations/2022_07_26_061712_create_goods_types_table.php create mode 100644 database/migrations/2022_07_26_085847_create_goods_brands_table.php create mode 100644 database/migrations/2022_07_26_090143_create_goods_table.php create mode 100644 database/migrations/2022_07_26_090150_create_goods_skus_table.php create mode 100644 database/migrations/2022_07_26_103559_create_daily_stock_records_table.php create mode 100644 database/migrations/2022_07_26_105818_create_logs_table.php diff --git a/README.md b/README.md index 1e0745e..a25de4b 100644 --- a/README.md +++ b/README.md @@ -2,21 +2,25 @@ #### 介绍 +主要为鲜花售卖提供一个统一的商品管理平台,支持对接第三方平台,包括商品管理,库存同步,订单管理,发货等 + #### 软件架构 - laravel 6.* - vue2.* - element-ui -#### 安装教程 +#### 本地开发安装教程 -1. xxxx -2. xxxx -3. xxxx +1. `composer install` +2. `cp .env.example .env` +3. 创建数据库 `CREATE DATABASE IF NOT EXISTS `erp` DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;` +4. 修改 .env 配置项为本地配置 +5. `php artisan migration` #### 使用说明 -1. xxxx +1. 阅读并遵守<<[Laravel项目开发规范](https://learnku.com/docs/laravel-specification/9.x/whats-the-use-of-standards/12720)>> 2. xxxx 3. xxxx diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index c6a6de6..69efd5f 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -3,8 +3,8 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; +use App\Models\User; use App\Providers\RouteServiceProvider; -use App\User; use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; @@ -60,7 +60,7 @@ class RegisterController extends Controller * Create a new user instance after a valid registration. * * @param array $data - * @return \App\User + * @return \App\Models\User */ protected function create(array $data) { diff --git a/app/Models/DailyStockRecord.php b/app/Models/DailyStockRecord.php new file mode 100644 index 0000000..7f609c6 --- /dev/null +++ b/app/Models/DailyStockRecord.php @@ -0,0 +1,8 @@ +orderBy('id', 'desc'); + } + + public function scopeOlder($query) + { + return $query->orderBy('id', 'asc'); + } + + public function scopeByUser($query, User $user) + { + return $query->where('user_id', $user->id); + } +} diff --git a/app/Models/ModelHasPermissions.php b/app/Models/ModelHasPermissions.php new file mode 100644 index 0000000..a4fca01 --- /dev/null +++ b/app/Models/ModelHasPermissions.php @@ -0,0 +1,8 @@ + env('APP_NAME', 'Laravel'), + 'name' => env('APP_NAME', 'CFen Erp'), /* |-------------------------------------------------------------------------- @@ -52,7 +52,7 @@ return [ | */ - 'url' => env('APP_URL', 'http://localhost'), + 'url' => env('APP_URL', 'http://erp.ii090.com'), 'asset_url' => env('ASSET_URL', null), diff --git a/config/auth.php b/config/auth.php index aaf982b..068a52b 100644 --- a/config/auth.php +++ b/config/auth.php @@ -68,7 +68,7 @@ return [ 'providers' => [ 'users' => [ 'driver' => 'eloquent', - 'model' => App\User::class, + 'model' => \App\Models\User::class, ], // 'users' => [ diff --git a/config/permission.php b/config/permission.php new file mode 100644 index 0000000..5b6e184 --- /dev/null +++ b/config/permission.php @@ -0,0 +1,161 @@ + [ + + /* + * When using the "HasPermissions" trait from this package, we need to know which + * Eloquent model should be used to retrieve your permissions. Of course, it + * is often just the "Permission" model but you may use whatever you like. + * + * The model you want to use as a Permission model needs to implement the + * `Spatie\Permission\Contracts\Permission` contract. + */ + + 'permission' => Spatie\Permission\Models\Permission::class, + + /* + * When using the "HasRoles" trait from this package, we need to know which + * Eloquent model should be used to retrieve your roles. Of course, it + * is often just the "Role" model but you may use whatever you like. + * + * The model you want to use as a Role model needs to implement the + * `Spatie\Permission\Contracts\Role` contract. + */ + + 'role' => Spatie\Permission\Models\Role::class, + + ], + + 'table_names' => [ + + /* + * When using the "HasRoles" trait from this package, we need to know which + * table should be used to retrieve your roles. We have chosen a basic + * default value but you may easily change it to any table you like. + */ + + 'roles' => 'roles', + + /* + * When using the "HasPermissions" trait from this package, we need to know which + * table should be used to retrieve your permissions. We have chosen a basic + * default value but you may easily change it to any table you like. + */ + + 'permissions' => 'permissions', + + /* + * When using the "HasPermissions" trait from this package, we need to know which + * table should be used to retrieve your models permissions. We have chosen a + * basic default value but you may easily change it to any table you like. + */ + + 'model_has_permissions' => 'model_has_permissions', + + /* + * When using the "HasRoles" trait from this package, we need to know which + * table should be used to retrieve your models roles. We have chosen a + * basic default value but you may easily change it to any table you like. + */ + + 'model_has_roles' => 'model_has_roles', + + /* + * When using the "HasRoles" trait from this package, we need to know which + * table should be used to retrieve your roles permissions. We have chosen a + * basic default value but you may easily change it to any table you like. + */ + + 'role_has_permissions' => 'role_has_permissions', + ], + + 'column_names' => [ + /* + * Change this if you want to name the related pivots other than defaults + */ + 'role_pivot_key' => null, //default 'role_id', + 'permission_pivot_key' => null, //default 'permission_id', + + /* + * Change this if you want to name the related model primary key other than + * `model_id`. + * + * For example, this would be nice if your primary keys are all UUIDs. In + * that case, name this `model_uuid`. + */ + + 'model_morph_key' => 'model_id', + + /* + * Change this if you want to use the teams feature and your related model's + * foreign key is other than `team_id`. + */ + + 'team_foreign_key' => 'team_id', + ], + + /* + * When set to true, the method for checking permissions will be registered on the gate. + * Set this to false, if you want to implement custom logic for checking permissions. + */ + + 'register_permission_check_method' => true, + + /* + * When set to true the package implements teams using the 'team_foreign_key'. If you want + * the migrations to register the 'team_foreign_key', you must set this to true + * before doing the migration. If you already did the migration then you must make a new + * migration to also add 'team_foreign_key' to 'roles', 'model_has_roles', and + * 'model_has_permissions'(view the latest version of package's migration file) + */ + + 'teams' => false, + + /* + * When set to true, the required permission names are added to the exception + * message. This could be considered an information leak in some contexts, so + * the default setting is false here for optimum safety. + */ + + 'display_permission_in_exception' => false, + + /* + * When set to true, the required role names are added to the exception + * message. This could be considered an information leak in some contexts, so + * the default setting is false here for optimum safety. + */ + + 'display_role_in_exception' => false, + + /* + * By default wildcard permission lookups are disabled. + */ + + 'enable_wildcard_permission' => false, + + 'cache' => [ + + /* + * By default all permissions are cached for 24 hours to speed up performance. + * When permissions or roles are updated the cache is flushed automatically. + */ + + 'expiration_time' => \DateInterval::createFromDateString('24 hours'), + + /* + * The cache key used to store all permissions. + */ + + 'key' => 'spatie.permission.cache', + + /* + * You may optionally indicate a specific cache driver to use for permission and + * role caching using any of the `store` drivers listed in the cache.php config + * file. Using 'default' here means to use the `default` set in cache.php. + */ + + 'store' => 'default', + ], +]; diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 741edea..fa9360e 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -2,7 +2,7 @@ /** @var \Illuminate\Database\Eloquent\Factory $factory */ -use App\User; +use App\Models\User; use Faker\Generator as Faker; use Illuminate\Support\Str; diff --git a/database/migrations/2022_07_25_060932_create_permission_tables.php b/database/migrations/2022_07_25_060932_create_permission_tables.php new file mode 100644 index 0000000..f20ef75 --- /dev/null +++ b/database/migrations/2022_07_25_060932_create_permission_tables.php @@ -0,0 +1,141 @@ +bigIncrements('id'); + $table->string('name'); // For MySQL 8.0 use string('name', 125); + $table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125); + $table->timestamps(); + + $table->unique(['name', 'guard_name']); + }); + + Schema::create($tableNames['roles'], function (Blueprint $table) use ($teams, $columnNames) { + $table->bigIncrements('id'); + if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing + $table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable(); + $table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index'); + } + $table->string('name'); // For MySQL 8.0 use string('name', 125); + $table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125); + $table->timestamps(); + if ($teams || config('permission.testing')) { + $table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']); + } else { + $table->unique(['name', 'guard_name']); + } + }); + + Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) { + $table->unsignedBigInteger(PermissionRegistrar::$pivotPermission); + + $table->string('model_type'); + $table->unsignedBigInteger($columnNames['model_morph_key']); + $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index'); + + $table->foreign(PermissionRegistrar::$pivotPermission) + ->references('id') + ->on($tableNames['permissions']) + ->onDelete('cascade'); + if ($teams) { + $table->unsignedBigInteger($columnNames['team_foreign_key']); + $table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index'); + + $table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'], + 'model_has_permissions_permission_model_type_primary'); + } else { + $table->primary([PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'], + 'model_has_permissions_permission_model_type_primary'); + } + + }); + + Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) { + $table->unsignedBigInteger(PermissionRegistrar::$pivotRole); + + $table->string('model_type'); + $table->unsignedBigInteger($columnNames['model_morph_key']); + $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index'); + + $table->foreign(PermissionRegistrar::$pivotRole) + ->references('id') + ->on($tableNames['roles']) + ->onDelete('cascade'); + if ($teams) { + $table->unsignedBigInteger($columnNames['team_foreign_key']); + $table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index'); + + $table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'], + 'model_has_roles_role_model_type_primary'); + } else { + $table->primary([PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'], + 'model_has_roles_role_model_type_primary'); + } + }); + + Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) { + $table->unsignedBigInteger(PermissionRegistrar::$pivotPermission); + $table->unsignedBigInteger(PermissionRegistrar::$pivotRole); + + $table->foreign(PermissionRegistrar::$pivotPermission) + ->references('id') + ->on($tableNames['permissions']) + ->onDelete('cascade'); + + $table->foreign(PermissionRegistrar::$pivotRole) + ->references('id') + ->on($tableNames['roles']) + ->onDelete('cascade'); + + $table->primary([PermissionRegistrar::$pivotPermission, PermissionRegistrar::$pivotRole], 'role_has_permissions_permission_id_role_id_primary'); + }); + + app('cache') + ->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null) + ->forget(config('permission.cache.key')); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + $tableNames = config('permission.table_names'); + + if (empty($tableNames)) { + throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.'); + } + + Schema::drop($tableNames['role_has_permissions']); + Schema::drop($tableNames['model_has_roles']); + Schema::drop($tableNames['model_has_permissions']); + Schema::drop($tableNames['roles']); + Schema::drop($tableNames['permissions']); + } +} diff --git a/database/migrations/2022_07_26_061712_create_goods_types_table.php b/database/migrations/2022_07_26_061712_create_goods_types_table.php new file mode 100644 index 0000000..7ba17c9 --- /dev/null +++ b/database/migrations/2022_07_26_061712_create_goods_types_table.php @@ -0,0 +1,35 @@ +bigIncrements('id'); + $table->string('name')->nullable(false); + $table->unsignedTinyInteger('is_delete')->default(0); + $table->timestamps(); + // 索引 + $table->unique('name'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('goods_types'); + } +} diff --git a/database/migrations/2022_07_26_085847_create_goods_brands_table.php b/database/migrations/2022_07_26_085847_create_goods_brands_table.php new file mode 100644 index 0000000..ed85d2a --- /dev/null +++ b/database/migrations/2022_07_26_085847_create_goods_brands_table.php @@ -0,0 +1,35 @@ +bigIncrements('id'); + $table->string('name')->nullable(false); + $table->unsignedTinyInteger('is_delete')->default(0); + $table->timestamps(); + // 索引 + $table->unique('name'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('goods_brands'); + } +} diff --git a/database/migrations/2022_07_26_090143_create_goods_table.php b/database/migrations/2022_07_26_090143_create_goods_table.php new file mode 100644 index 0000000..c82e352 --- /dev/null +++ b/database/migrations/2022_07_26_090143_create_goods_table.php @@ -0,0 +1,38 @@ +bigIncrements('id'); + $table->string('title')->nullable(false); + $table->string('img_url')->nullable(false)->comment('商品图片'); + $table->unsignedBigInteger('type_id')->nullable(false)->comment('商品种类id'); + $table->unsignedBigInteger('brand_id')->nullable()->comment('商品品牌id'); + $table->string('goods_code', 32)->nullable(false)->comment('商品编码'); + $table->timestamps(); + // 索引 + $table->unique('goods_code'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('goods'); + } +} diff --git a/database/migrations/2022_07_26_090150_create_goods_skus_table.php b/database/migrations/2022_07_26_090150_create_goods_skus_table.php new file mode 100644 index 0000000..af6bd93 --- /dev/null +++ b/database/migrations/2022_07_26_090150_create_goods_skus_table.php @@ -0,0 +1,43 @@ +bigIncrements('id'); + $table->string('title')->nullable(false)->comment('商品规格'); + $table->string('sku_code', 32)->nullable(false)->comment('规格编码'); + $table->unsignedTinyInteger('status')->default(0)->comment('规格状态(0-下架,1在售,2预警)'); + $table->unsignedInteger('num')->default(0)->comment('总量'); + $table->unsignedInteger('stock')->default(0)->comment('库存'); + $table->unsignedDecimal('cost')->default(0)->comment('成本'); + $table->unsignedInteger('two_days_ago_num')->default(0)->comment('2天前库存'); + $table->unsignedInteger('yesterday_num')->default(0)->comment('1天前库存'); + $table->unsignedDecimal('reference_price')->default(0)->comment('参考售价'); + $table->unsignedInteger('reserve')->default(0)->comment('预留量'); + $table->timestamps(); + // 索引 + $table->unique('sku_code'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('goods_skus'); + } +} diff --git a/database/migrations/2022_07_26_103559_create_daily_stock_records_table.php b/database/migrations/2022_07_26_103559_create_daily_stock_records_table.php new file mode 100644 index 0000000..1c4706d --- /dev/null +++ b/database/migrations/2022_07_26_103559_create_daily_stock_records_table.php @@ -0,0 +1,36 @@ +bigIncrements('id'); + $table->bigInteger('sku_id')->nullable(false); + $table->date('day')->nullable(false); + $table->unsignedInteger('arrived_today_num')->default(0)->comment('今日到货'); + $table->unsignedInteger('loss_num')->default(0)->comment('损耗'); + $table->unsignedInteger('inventory')->default(0)->comment('库存盘点'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('daily_stock_records'); + } +} diff --git a/database/migrations/2022_07_26_105818_create_logs_table.php b/database/migrations/2022_07_26_105818_create_logs_table.php new file mode 100644 index 0000000..6f0820c --- /dev/null +++ b/database/migrations/2022_07_26_105818_create_logs_table.php @@ -0,0 +1,39 @@ +bigIncrements('id'); + $table->string('module')->comment('模块'); + $table->string('action')->comment('操作'); + $table->string('target_type')->comment('目标类型'); + $table->bigInteger('target_id')->comment('目标id'); + $table->string('target_field')->comment('目标字段'); + $table->text('before_update')->comment('更新前数据'); + $table->text('after_update')->comment('更新后数据'); + $table->bigInteger('user_id')->comment('操作人id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('logs'); + } +} From 554105e7662d00cf2bc1912d6914a6200e52d1b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Wed, 27 Jul 2022 19:06:16 +0800 Subject: [PATCH 02/68] =?UTF-8?q?feat:=20#20220727=20=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Auth/LoginController.php | 14 ++++ .../Controllers/Auth/RegisterController.php | 14 ++-- .../Goods/GoodsBrandsController.php | 44 ++++++++++++ .../Goods/GoodsTypesController.php | 10 +++ app/Http/Controllers/User/UsersController.php | 43 +++++++++++ app/Http/Resources/GoodsBrandResource.php | 19 +++++ app/Http/Resources/GoodsTypeResource.php | 19 +++++ app/Models/ModelHasPermissions.php | 8 --- app/Models/ModelHasRoles.php | 8 --- app/Models/Permission.php | 8 --- app/Models/Role.php | 8 --- app/Models/RoleHasPermission.php | 8 --- app/Models/User.php | 10 ++- database/factories/UserFactory.php | 3 +- .../2014_10_12_000000_create_users_table.php | 1 + database/seeds/DatabaseSeeder.php | 1 + resources/views/home.blade.php | 71 +++++++++++++++++++ routes/api.php | 24 +++++-- routes/web.php | 12 ++++ 19 files changed, 275 insertions(+), 50 deletions(-) create mode 100644 app/Http/Controllers/Goods/GoodsBrandsController.php create mode 100644 app/Http/Controllers/Goods/GoodsTypesController.php create mode 100644 app/Http/Controllers/User/UsersController.php create mode 100644 app/Http/Resources/GoodsBrandResource.php create mode 100644 app/Http/Resources/GoodsTypeResource.php delete mode 100644 app/Models/ModelHasPermissions.php delete mode 100644 app/Models/ModelHasRoles.php delete mode 100644 app/Models/Permission.php delete mode 100644 app/Models/Role.php delete mode 100644 app/Models/RoleHasPermission.php create mode 100644 resources/views/home.blade.php diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 18a0d08..993bc4b 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -4,6 +4,8 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; use App\Providers\RouteServiceProvider; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; use Illuminate\Foundation\Auth\AuthenticatesUsers; class LoginController extends Controller @@ -37,4 +39,16 @@ class LoginController extends Controller { $this->middleware('guest')->except('logout'); } + + public function login(Request $request) + { + $credentials = $request->only('name', 'password'); + + if (Auth::attempt($credentials)) { + // 通过认证.. + return response()->json(['token' => '']); + }else { + return response()->json(['error' => 'auth login fail']); + } + } } diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 69efd5f..e48e455 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -8,6 +8,8 @@ use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; +use Faker\Generator as Faker; +use Illuminate\Support\Str; class RegisterController extends Controller { @@ -50,9 +52,10 @@ class RegisterController extends Controller protected function validator(array $data) { return Validator::make($data, [ - 'name' => ['required', 'string', 'max:255'], - 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], + 'name' => ['required', 'string', 'unique:users', 'max:255'], + 'email' => ['string', 'email', 'max:255', 'unique:users'], 'password' => ['required', 'string', 'min:8', 'confirmed'], + 'role_id' => ['required', 'numeric', 'exists:roles,id'], ]); } @@ -60,14 +63,17 @@ class RegisterController extends Controller * Create a new user instance after a valid registration. * * @param array $data - * @return \App\Models\User + * @return User */ protected function create(array $data) { + $faker = new Faker(); + return User::create([ 'name' => $data['name'], - 'email' => $data['email'], + 'email' => $data['email'] ?? $faker->unique()->safeEmail, 'password' => Hash::make($data['password']), + 'api_token' => Str::random(60), ]); } } diff --git a/app/Http/Controllers/Goods/GoodsBrandsController.php b/app/Http/Controllers/Goods/GoodsBrandsController.php new file mode 100644 index 0000000..f147810 --- /dev/null +++ b/app/Http/Controllers/Goods/GoodsBrandsController.php @@ -0,0 +1,44 @@ +paginate(); + + return GoodsBrandResource::collection($goodsBrands); + } + + public function store(Request $request) + { + $request->validate([ + 'name' => 'required|string|unique:users|max:255', + ]); + + GoodsBrand::created(); + } + + public function show($id) + { + $columns = ['*']; + $goodsBrand = GoodsBrand::query()->find($id, $columns); + + return GoodsBrandResource::collection($goodsBrand); + } + + public function update() + { + + } + + public function destory() + { + + } +} diff --git a/app/Http/Controllers/Goods/GoodsTypesController.php b/app/Http/Controllers/Goods/GoodsTypesController.php new file mode 100644 index 0000000..55b0a76 --- /dev/null +++ b/app/Http/Controllers/Goods/GoodsTypesController.php @@ -0,0 +1,10 @@ +validate([ + 'name' => 'required|string|unique:users|max:255', + 'password' => 'required|string|min:8|confirmed', + ]); + $user = new User(); + $user->name = $request->name; + $user->password = $request->password; + } + + public function show($id) + { + return User::query()->find($id); + } + + public function update() + { + + } + + public function destory() + { + + } +} diff --git a/app/Http/Resources/GoodsBrandResource.php b/app/Http/Resources/GoodsBrandResource.php new file mode 100644 index 0000000..9d73b57 --- /dev/null +++ b/app/Http/Resources/GoodsBrandResource.php @@ -0,0 +1,19 @@ + 'datetime', ]; + + public function setPasswordAttribute($value) + { + $this->attributes['password'] = Hash::make($value); + } } diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index fa9360e..fa3372e 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -19,10 +19,11 @@ use Illuminate\Support\Str; $factory->define(User::class, function (Faker $faker) { return [ - 'name' => $faker->name, + 'name' => 'erpAdmin', 'email' => $faker->unique()->safeEmail, 'email_verified_at' => now(), 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password + 'api_token' => Str::random(60), 'remember_token' => Str::random(10), ]; }); diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index a91e1d3..5a3b4fa 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -19,6 +19,7 @@ class CreateUsersTable extends Migration $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); + $table->string('api_token', 80)->unique()->nullable()->default(null); $table->rememberToken(); $table->timestamps(); }); diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 91cb6d1..a58fc82 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -12,5 +12,6 @@ class DatabaseSeeder extends Seeder public function run() { // $this->call(UsersTableSeeder::class); + factory(\App\Models\User::class)->create(); } } diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php new file mode 100644 index 0000000..06755ee --- /dev/null +++ b/resources/views/home.blade.php @@ -0,0 +1,71 @@ + + +
+ + + +Rz$KlnO_H2c< z(XX#lPuW_%H#Q+c&(nRyX1-Ia dKR-%$4FYC0fsCmL9ky3 zKpxyjd^JFR+vg2!=HWf}2Z?@Td`0EG`kU?{8zKrvtsm)|7>pPk9nu@2^z96aU2<#` z2QhvH5w&V;wER?mopu+nqu*n8p~(%Q kwSs&*0eJwa zMXR05`OSFpfyRb! Y_+H@O%Y z0=K^y6B8Gcbl?SA)qMP3Z+=C(?8zL@=74R=EVnE?vY!1BQy2@q*RUgRx4yJ$k}MnL zs!?74QciNb-LcG*&o<9=DSL>1n}ZNd)w1z3-0Pd^4ED1{qd=9|!!N?xnXjM!EuylY z5=!H>&hSofh8V?Jofyd!h`xDI1fYAuV(sZwwN~{$a}MX^=+0TH*SFp$vyxmUv7C*W zv^3Gl0+eTFgBi3FVD;$nhcp)ka*4gSskYIqQ&+M}xP9yLAkWzBI^I%zR^l1e?bW_6 zIn{mo{dD=)9@V?s^fa55jh78rP*Ze<3`tRCN4*mpO$@7a^*2B*7N_|A(Ve2VB|)_o z$=#_=aBkhe(ifX}MLT()@5? OV+~7cXC3r!%{QJxriXo9I%*3q4KT4Xxzyd{ z9;_%=W%q!Vw$Z7F3lUnY+1HZ*lO;4;VR2+i4+D(m#01OYq|L_fbnT;KN<^dkkCwtd zF7n+O7KvAw8c`JUh6LmeIrk4`F3o|AagKSMK3))_5Cv~y2Bb2!Ibg9BO7Vkz?pAYX zoI=B}+$R22&IL`NCYUYjrdhwjnM x_v=-Qcx-jmtN>!Zqf|n1^SWrHy zK|MwJ?Z#^>)rfT5YSY{qjZ&`Fjd;^vv&gF-Yj6$9-Dy$<6zeP4s+78gS2|t%Z309b z0^fp~ue_}i`U9j!<|qF92_3oB09NqgAoehQ`)<)dSfKoJl_A6Ec#*Mx9Cpd-p#$Ez z={AM*r-bQs6*z$!*V A4|QE7bf@-4vb?Q+pPKLkY2{yKsw{&udv_2v8{Dbd zm~8VAv!G~s)`O3|Q6vFUV%8%+?ZSVUa(;fhPNg#vab@J*9XE4#D%)$UU-T5`fwjz! z6&gA^`OGu6aUk{l*h9eB?opVdrHK>Q@U>&JQ_2pR%}TyOXGq_6s56_`U(WoOaAb+K zXQr#6H}>a-GYs9^bG P2Y&hSP5gEtW+GVC4=wy0wQk=~%CSXj=GH6q z-T#s!BV`xZVxm{~jr_ezYRpqqIcXC=Oq`b{lu`Rt(IYr4B91hhVC?yg{ol4WUr3v9 zOAk2LG>CIECZ-WIs0$N}F#eoIUEtZudc7DPYIjzGqDLWk_A4#( LgacooD z2K4IWs@N`Bddm-{%oy}!k0^i6Yh)uJ1S*90>|bm3TOZxcV|ywHUb(+CeX-o1|LTZM zwU>dY3R&U)T(}5#Neh?-CWT~@{6Ke@sI)uSuzoah8COy)w)B)aslJmp`WUcjdia-0 zl2Y}&L~XfA`uYQboAJ1;J{XLhYjH){cObH3FDva+^8ioOQy%Z=xyjGLmWMrzfFoH; zEi3AG`_v+%)&lDJE;iJWJDI@-X9K5O)LD~j*PBe(wu+|%ar~C+LK1+-+lK =t# z+Xc+J7qp~5q=B~rD!x78)?1+KUIbYr^5rcl&tB-cTtj+e%{gpZZ4G~6r15+d|J(ky zjg@@UzMW0k9@S#W(1H{u;Nq(7llJbq;;4t$awM;l&(2s+$l!Ay9^Ge|34CVhr7|BG z?dAR83smef^frq9V(OH+a+ki#q&-7TkWfFM=5bsGbU(8mC;>QTCWL5ydz9s6k@?+V zcjiH`VI=59P-(-DWXZ~5DH>B^_H~;4$)KUhnmGo*G!Tq8^LjfUDO)lASN*=#AY_yS zqW9UX(VOCO&p@kHdUUgsBO0KhXxn1sprK5h8}+>IhX(nSXZKwlNsjk^M|RAaqmCZB zHBol OHYBas@&{PT=R+?d8pZu zUHfyucQ`(umXSW7o?HQ3H21M`ZJal+%*)SH1B1j6rxTlG3hx1IGJN^M7{$j(9V;MZ zRKybgVuxKo#XVM+?*yTy{W+XHaU5Jbt-UG33x{u(N-2wmw;zzPH&4DE103HV@ER86 z|FZEmQb|&1s5#`$4!Cm}&`^{(4V}OP$bk`}v6q6rm;P!H)W|2i^e{7lTk2W@jo_9q z*aw|U7#+g59Fv(5qI`#O-qPj#@_P>PC#I(GSp3DLv7x-dmYK=C7lPF8a)bxb=@)B1 zUZ`EqpXV2dR}B&r`uM}N(TS99ZT0UB%IN|0H%DcVO#T%L_chrgn#m6%x4KE*IMfjX zJ%4veCEqbXZ`H`F_+fELMC@wuy_ch%t*+Z+1I}wN#C+dRrf2X{1C8=yZ_%Pt6wL_~ zZ2NN-hXOT4P4n$QFO7yYHS-4wF1Xfr-meG9Pn;uK51?hfel`d38k{W)F*|gJLT2#T z<~>spMu4(mul-8Q3*pf=N4DcI)zzjqAgbE2eOT7~&f1W3VsdD44Ffe;3mJp-V@8UC z)|qnPc12o~$X-+U@L_lWqv-RtvB~%hLF($%Ew5w>^NR82qC_0F B z)=hP1-OEx?lLi#jnLzH}a;Nvr@JDO-zQWd}#k^an$Kwml;MrD&)sC5b`s0ZkVyPkb zt}-jOq^%_9>YZe7Y}PhW{a)c39G`kg(P4@kxjcYfgB4XOOcmezdUI7j-!gs7oAo2o zx(Ph{G+YZ`a%~kzK!HTAA5NXE-7vOFRr5oqY$rH>WI6SFvWmahFav!CfRMM3%8J&c z*p+%|-fNS_@QrFr(at!JY9jCg9F-%5{nb5Bo~z@Y9m&SHYV`49GAJjA5h~h4(G!Se zZmK{Bo7ivCfvl}@A-ptkFGcWXAzj3xfl{evi-OG(TaCn1FAHxRc{}B|x+Ua1D=I6M z!C^ZIvK6aS_c&(=OQDZfm>O`Nxsw{ta&yiYPA~@e#c%N>>#rq)k6Aru-qD4(D^v)y z*>Rs;YUbD1S8^D(ps6Jbj0K3wJw>L4m)0e(6Pee3Y?gy9i0^bZO?$*sv+xKV?WBlh zAp*;v6w!a8;A7sLB*g-^<$Z4L7|5jXxxP1}hQZ<55f9<^KJ>^mKlWSGaLcO0=$jem zWyZkRwe~u{{tU63DlCaS9$Y4CP4f?+wwa(&1ou)b>72yd rFvm`R j-0`kBJgK@nd(*Eh!(NC{F-@=FnF&Y!q`7){YsLLHf0_B6aHc# z>WIuHTyJwIH{BJ4)2RtEauC7Yq7Cytc|S )4^*t8Va3HR zg=~sN^tp9re@w=GTx$;zOWMjcg-7X3Wk^N$n;&Kf1RgVG2}2L-(0o)54C509C&77i zrjSi{X*WV=%C17((N^6R4Ya*4#6s_L99RtQ>m(%#nQ#wrRC8Y%yxkH;d!MdY+Tw@r zjpSnK`;C-U{ATcgaxoEpP0Gf+tx);buOM lK=01D|J+ROu37qc*rD(w`#O=3*O*w9?biwNoq3WN1`&Wp8TvKj3C z3HR9ssH7a&Vr<6waJrUzdLg!ieYz%U^bmpn%;(V%%ugMk92&?_XX1K@mwnVSE6!&%P%Wdi7_h`CpScvspMx?N zQUR>oadnG17#hNc$pkTp+9 lW+MBKHRZ~7 4XWUryd)4yd zj98$%XmIL4(9OnoeO5Fnyn&fpQ9b0h4e6EHHw*l68j;>(ya`g^S&y2{O8U>1*>4zR zq*WSI_2o$CHQ?x0!wl9bpx|Cm2+kFMR)oMud1%n2=qn5nE&t@Fgr#=Zv2?}wtEz^T z9rrj=?I H*qI5{G@Rn&}^Z{+TW}mQe b9=8b<_a`&Cm#n%n~ zU47MvCBsdXFB1+adOO)03+nczfWa#vwk #r{o{dF)QWya9v2nv43Zp3%Ps}($lA02*_g25t;|T{A5snSY?3A zrRQ~(Ygh_ebltHo1VC bJb*eOAr;4cnlXLvI>*$-#AVsGg6B1r7@;g^L zFlJ_th0vxO7;-opU@WAFe;<}?!2q?RBrFK5U{ *ai@NLKZ^};Ul}beukveh?TQn;$%9=R+DX07m82gP$=}Uo_%&ngV`}Hyv8g{u z3SWzTGV|cwQuFIs7ZDOqO_fGf8Q`8MwL}eUp>q?4eqCmOTcwQuXtQckPy|4F1on8l zP*h>d+cH#XQf|+6c|S{7SF(Lg>bR~l(0uY?O{OEVlaxa5@e%T&xju=o1`=OD#qc16 zSvyH*my(dcp6~VqR;o(#@m44Lug@~_qw+HA=mS#Z^ 4reBy8iV?H~I;{LQWk3aKK8$bLRyt$g?- + ++ + + + + diff --git a/resources/frontend/src/css/style.css b/resources/frontend/src/css/style.css new file mode 100644 index 0000000..ec6bae8 --- /dev/null +++ b/resources/frontend/src/css/style.css @@ -0,0 +1,12 @@ +* { + padding: 0 0; + margin: 0 0; +} +body,html { + width: 100%; + height: 100%; + overflow-y: hidden; +} +ul { + list-style: none; +} \ No newline at end of file diff --git a/resources/frontend/src/main.js b/resources/frontend/src/main.js new file mode 100644 index 0000000..047ff6a --- /dev/null +++ b/resources/frontend/src/main.js @@ -0,0 +1,25 @@ +import Vue from 'vue' +import App from './App.vue' +import router from './router' +import store from './store' +import ElementUI from 'element-ui' +import 'element-ui/lib/theme-chalk/index.css' +import '@/css/style.css' +import './router/index2' + + +// import Router from 'vue-router' +// const routerPush = Router.prototype.push +// Router.prototype.push = function push(location) { +// return routerPush.call(this, location).catch(error=> error) +// } + +Vue.use(ElementUI) + +Vue.config.productionTip = false + +new Vue({ + router, + store, + render: h => h(App) +}).$mount('#app') diff --git a/resources/frontend/src/router/index.js b/resources/frontend/src/router/index.js new file mode 100644 index 0000000..b9b8f45 --- /dev/null +++ b/resources/frontend/src/router/index.js @@ -0,0 +1,12 @@ +import Vue from 'vue' +import VueRouter from 'vue-router' + +Vue.use(VueRouter) + +const createRouter = () => + new VueRouter({ + scrollBehavior: () => ({ y: 0 }) + }) + +const router = createRouter() +export default router diff --git a/resources/frontend/src/router/index1.js b/resources/frontend/src/router/index1.js new file mode 100644 index 0000000..96e376b --- /dev/null +++ b/resources/frontend/src/router/index1.js @@ -0,0 +1,77 @@ +/* + * @Description: + * @Author: czw (725551805@qq.com) + * @Date: 2022-02-25 10:40:17 + * @LastEditors: czw (725551805@qq.com) + * @LastEditTime: 2022-03-01 20:29:32 + * @FilePath: /glxt/src/router/index1.js + */ + +const list = [ + { + path: '/logo', + name: 'logo', + component: () => import('../views/logo.vue') + }, + { + path: '/', + component: () => import('../views/index.vue'), + children: [ + { + path: 'GOODS_LIST', + name: '商品列表', + component: () => import('../views/yingyeting/yingyeting.vue') + }, + { + path: 'GOODS_TYPE', + name: '商品种类', + component: () => import('../views/home/home.vue') + }, + { + path: 'GOODS_BRAND', + name: '商品品牌', + component: () => import('../views/brand/brand.vue') + }, + { + path: 'SHOP_MANAGE', + name: '店铺管理', + component: () => import('../views/store/store.vue') + }, + { + path: 'USER_MANAGE', + name: '用户管理', + component: () => import('../views/users/users.vue') + }, + { + path: 'ROLE_MANAGE', + name: '角色管理', + component: () => import('../views/system/role.vue') + }, + { + path: 'PERMISSION_MANAGE', + name: '权限管理', + component: () => import('../views/system/authority.vue') + }, + { + path: 'SYSTEM_LOG', + name: '商品记录', + component: () => import('../views/shuju/shuju.vue') + }, + { + path: '/index/yingyeting/addgoods', + name: '新建商品', + component: () => import('../views/yingyeting/addgoods/addgoods.vue') + }, + { + path: '/', + redirect: 'GOODS_LIST' + } + ] + }, + { + path: '/', + redirect: '/index' + } +] + +export default list diff --git a/resources/frontend/src/router/index2.js b/resources/frontend/src/router/index2.js new file mode 100644 index 0000000..a9ef295 --- /dev/null +++ b/resources/frontend/src/router/index2.js @@ -0,0 +1,18 @@ +/* + * @Description: + * @Author: czw (725551805@qq.com) + * @Date: 2022-02-25 10:40:25 + * @LastEditors: czw (725551805@qq.com) + * @LastEditTime: 2022-02-25 12:18:31 + * @FilePath: /glxt/src/router/index2.js + */ + +import router from './index' +import Home from './index1' +// console.log(...Home); + +Home.forEach(element => { + router.addRoute(element) // 动态添加更多的路由规则 +}) + +// 菜单路由数据 diff --git a/resources/frontend/src/store/index.js b/resources/frontend/src/store/index.js new file mode 100644 index 0000000..332b916 --- /dev/null +++ b/resources/frontend/src/store/index.js @@ -0,0 +1,15 @@ +import Vue from 'vue' +import Vuex from 'vuex' + +Vue.use(Vuex) + +export default new Vuex.Store({ + state: { + }, + mutations: { + }, + actions: { + }, + modules: { + } +}) diff --git a/resources/frontend/src/util/auth.js b/resources/frontend/src/util/auth.js new file mode 100644 index 0000000..9f228e9 --- /dev/null +++ b/resources/frontend/src/util/auth.js @@ -0,0 +1,13 @@ +const TokenKey = 'admin_token' +// 获取token +export function getToken () { + return localStorage.getItem(TokenKey) +} +// 设置token +export function setToken (token) { + return localStorage.setItem(TokenKey, token) +} +// 删除token +export function removeToken () { + return localStorage.removeItem(TokenKey) +} diff --git a/resources/frontend/src/util/http.js b/resources/frontend/src/util/http.js new file mode 100644 index 0000000..01b9817 --- /dev/null +++ b/resources/frontend/src/util/http.js @@ -0,0 +1,82 @@ +/* + * @Description: api请求 + * @Author: chenzhiwei (725551805@qq.com) + * @Date: 2021-08-02 15:52:34 + * @LastEditors: czw (725551805@qq.com) + * @LastEditTime: 2022-03-13 11:05:08 + * @FilePath: /glxt/src/util/http.js + */ +import axios from 'axios' +import { getToken } from '@/util/auth' +import NProgress from 'nprogress' +import 'nprogress/nprogress.css' +import { Message } from 'element-ui' +import router from '@/router' +var instance = axios.create({ + + timeout: 10000 +}) + +instance.interceptors.request.use( + config => { + // config.headers['content-type'] = 'application/json' + + // config.headers['Shop-Id'] = localStorage.getItem('shopId') || 1 + + // 在发送请求之前做些什么 + // config.headers.Authorization = 'Bearer' + getToken() // 请求头 + // config.headers['content-type'] = 'application/json' + config.headers.Authorization = 'Bearer ' + getToken() // 请求头 + NProgress.start() + console.log(config, '1111') // for debug + + return config + }, + error => { + // 对请求错误做些什么 + console.log(error, '222222') // for debug + return Promise.reject(error) + } +) + +// 添加响应拦截器 +instance.interceptors.response.use( + response => { + NProgress.done() + const res = response.status + // 对响应数据做点什么 + console.log(response, '33333') // for debug + if (res === 200 || res === 201) { + return response + } else { + Message({ + message: 'Error', + type: 'error' + + }) + } + }, + error => { + // 对响应错误做点什么 + + console.log(error, '44444') // for debug + // if (error.response.status === 401) { + // Message({ + // message: '账户登录过期,请重新登录', + // type: 'error' + + // }) + // router.push('/login') + // } else { + // Message({ + // message: error.response || 'Error', + // type: 'error' + + // }) + // } + + return Promise.reject(error) + } +) + +export default instance diff --git a/resources/frontend/src/util/remoteLoad.js b/resources/frontend/src/util/remoteLoad.js new file mode 100644 index 0000000..cbf3257 --- /dev/null +++ b/resources/frontend/src/util/remoteLoad.js @@ -0,0 +1,64 @@ +/* + * @Author: 陈智伟 9459156+chen-kaitao@user.noreply.gitee.com + * @Date: 2021-10-05 11:34:34 + * @LastEditors: 陈智伟 9459156+chen-kaitao@user.noreply.gitee.com + * @LastEditTime: 2022-07-23 10:20:28 + * @FilePath: /glxt/src/util/remoteLoad.js + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +export default function remoteLoad (url, hasCallback) { + return createScript(url) + /** + * 创建script + * @param url + * @returns {Promise} + */ + function createScript (url) { + const scriptElement = document.createElement('script') + document.body.appendChild(scriptElement) + const promise = new Promise((resolve, reject) => { + scriptElement.addEventListener( + 'load', + (e) => { + removeScript(scriptElement) + if (!hasCallback) { + resolve(e) + } + }, + false + ) + + scriptElement.addEventListener( + 'error', + (e) => { + removeScript(scriptElement) + reject(e) + }, + false + ) + + if (hasCallback) { + window.____callback____ = function () { + resolve() + window.____callback____ = null + } + } + }) + + if (hasCallback) { + url += '&callback=____callback____' + } + + scriptElement.src = url + + return promise + } + + /** + * 移除script标签 + * @param scriptElement script dom + */ + function removeScript (scriptElement) { + document.body.removeChild(scriptElement) + } +} diff --git a/resources/frontend/src/views/brand/brand.vue b/resources/frontend/src/views/brand/brand.vue new file mode 100644 index 0000000..d30fe53 --- /dev/null +++ b/resources/frontend/src/views/brand/brand.vue @@ -0,0 +1,199 @@ + ++ ++正在加载数据 ...+++ + + + + diff --git a/resources/frontend/src/views/home/home.vue b/resources/frontend/src/views/home/home.vue new file mode 100644 index 0000000..2c66ceb --- /dev/null +++ b/resources/frontend/src/views/home/home.vue @@ -0,0 +1,206 @@ + ++ +新增 ++ ++ ++ ++ + +编辑 +删除 + + ++ + ++ + ++ + ++ ++ + ++ + ++ ++ ++ + + + + \ No newline at end of file diff --git a/resources/frontend/src/views/home/home/cesi.vue b/resources/frontend/src/views/home/home/cesi.vue new file mode 100644 index 0000000..d04f4e2 --- /dev/null +++ b/resources/frontend/src/views/home/home/cesi.vue @@ -0,0 +1,40 @@ + + ++ +新增 ++ ++ ++ ++ + +编辑 +删除 + + ++ + ++ + ++ + ++ ++ + ++ + ++ ++ + ++ + + diff --git a/resources/frontend/src/views/home/home/index.vue b/resources/frontend/src/views/home/home/index.vue new file mode 100644 index 0000000..d8293ed --- /dev/null +++ b/resources/frontend/src/views/home/home/index.vue @@ -0,0 +1,221 @@ + + +++ + + + + + diff --git a/resources/frontend/src/views/index.vue b/resources/frontend/src/views/index.vue new file mode 100644 index 0000000..b2a0c56 --- /dev/null +++ b/resources/frontend/src/views/index.vue @@ -0,0 +1,375 @@ + ++ + + +++{{list}} ++ +++ + + diff --git a/resources/frontend/src/views/logo.vue b/resources/frontend/src/views/logo.vue new file mode 100644 index 0000000..55ed68f --- /dev/null +++ b/resources/frontend/src/views/logo.vue @@ -0,0 +1,74 @@ + + ++ ++ ++ ++ ++++ {{item.name}} + ++ + {{item.name}} + + +{{items.name}} ++ ++++
+- +
++ + +++++ +{{item.name}} +- +
++ 退出 +++++
+- +
- + + + +
+- +
+++ ++ + + + + diff --git a/resources/frontend/src/views/shuju/shuju.vue b/resources/frontend/src/views/shuju/shuju.vue new file mode 100644 index 0000000..b23f4be --- /dev/null +++ b/resources/frontend/src/views/shuju/shuju.vue @@ -0,0 +1,164 @@ + ++ ++ ++ + ++ + +登录 +++ + + + + diff --git a/resources/frontend/src/views/store/store.vue b/resources/frontend/src/views/store/store.vue new file mode 100644 index 0000000..49c5006 --- /dev/null +++ b/resources/frontend/src/views/store/store.vue @@ -0,0 +1,57 @@ + ++ +++ ++ + ++ ++ ++ ++ ++ ++ ++ ++ ++ + +查询 ++ ++ + 历史记录 + (共800条) + ——玫瑰花 +++ + ++ ++ ++ ++ ++ ++ ++ ++ + + + + + diff --git a/resources/frontend/src/views/system/authority.vue b/resources/frontend/src/views/system/authority.vue new file mode 100644 index 0000000..852ebd6 --- /dev/null +++ b/resources/frontend/src/views/system/authority.vue @@ -0,0 +1,22 @@ + ++ ++ ++ ++ ++ + + + + diff --git a/resources/frontend/src/views/system/role.vue b/resources/frontend/src/views/system/role.vue new file mode 100644 index 0000000..5dccecb --- /dev/null +++ b/resources/frontend/src/views/system/role.vue @@ -0,0 +1,22 @@ + ++ ++ + + + + diff --git a/resources/frontend/src/views/users/users.vue b/resources/frontend/src/views/users/users.vue new file mode 100644 index 0000000..637d61d --- /dev/null +++ b/resources/frontend/src/views/users/users.vue @@ -0,0 +1,22 @@ + ++ ++ + + + + diff --git a/resources/frontend/src/views/yingyeting/addgoods/addgoods.vue b/resources/frontend/src/views/yingyeting/addgoods/addgoods.vue new file mode 100644 index 0000000..48010a3 --- /dev/null +++ b/resources/frontend/src/views/yingyeting/addgoods/addgoods.vue @@ -0,0 +1,220 @@ + +++ + + + + diff --git a/resources/frontend/src/views/yingyeting/yingyeting.vue b/resources/frontend/src/views/yingyeting/yingyeting.vue new file mode 100644 index 0000000..62f9e95 --- /dev/null +++ b/resources/frontend/src/views/yingyeting/yingyeting.vue @@ -0,0 +1,363 @@ + + ++ +++ ++ 商品图片: +++ ++ +
+ + ++++ ++ ++ ++ ++ ++ ++ ++ ++ ++ {{i+1}}. +++ + + ++ + ++ ++ + ++ ++ + ++++ ++ + ++ ++ + +删除 +++ ++ +保存 +取消 +++ + + + + diff --git a/resources/frontend/vue.config.js b/resources/frontend/vue.config.js new file mode 100644 index 0000000..c43d458 --- /dev/null +++ b/resources/frontend/vue.config.js @@ -0,0 +1,22 @@ +module.exports = { + lintOnSave: false, + publicPath: './', // 配置打包之后的相对路径 + devServer: { + open: true, // 设置浏览器自动打开项目 + port: 8080, // 开发服务器运行端口号 + overlay: { + warnings: false, + errors: true + }, + proxy: { // 配置代理 + '/api': { + // target: 'http://doc.ii090.com/mock/267/', + target: 'http://erp.staging.miaoxuan66.cn', + changeOrigin: true, // 开启代理 + pathRewrite: { // 重命名 + '^/api': 'api' + } + } + } + } +} From ec7ef4969e391453b80d4e9f23f9bcd5dbf855f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Tue, 2 Aug 2022 11:43:46 +0800 Subject: [PATCH 15/68] =?UTF-8?q?feat:=20#20220802=20=E5=BA=97=E9=93=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Goods/GoodsSkusController.php | 104 ++++++++++++++++++ app/Http/Controllers/Shop/ShopsController.php | 45 ++++++++ app/Http/Resources/ShopsResource.php | 19 ++++ app/Models/Shop.php | 42 +++++++ .../2014_10_12_000000_create_users_table.php | 1 + .../2022_08_02_022448_create_shops_table.php | 45 ++++++++ database/seeds/MenusTableSeeder.php | 2 +- 7 files changed, 257 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/Shop/ShopsController.php create mode 100644 app/Http/Resources/ShopsResource.php create mode 100644 app/Models/Shop.php create mode 100644 database/migrations/2022_08_02_022448_create_shops_table.php diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index edf81ce..cf40820 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -8,6 +8,8 @@ use Illuminate\Http\Request; use App\Models\GoodsSku; use App\Http\Resources\GoodsSkuResource; use App\Imports\GoodsSkusImport; +use Illuminate\Support\Facades\Validator; +use Illuminate\Validation\Rule; use Illuminate\Validation\ValidationException; use Maatwebsite\Excel\Facades\Excel; @@ -35,7 +37,109 @@ class GoodsSkusController extends Controller public function update($id, Request $request) { + $data = $request->all(); + $this->validateUpdate($data); + $sku = GoodsSku::query()->find($id); + $this->setBeforeUpdate($sku->toArray()); + $sku->save($data); + $this->setAfterUpdate($sku->toArray()); + $this->addLog($id, 'update'); + return new GoodsSkuResource($sku); + } + + public function batchUpdate(Request $request) + { + $appendRules = [ + '*.id' => [ + 'required', + Rule::exists('goods_skus', 'id'), + ], + ]; + } + + public function updateField($id, Request $request) + { + $appendRules = [ + 'updateField' => [ + 'required', + Rule::in(['reference_price', 'reserve', 'loss_num', 'status']) + ], + ]; + if ($request->has('loss_num')) { + $appendRules['reason'] = ['required', 'string']; + } + $this->validateUpdate($request->all(), $appendRules); + $updateField = \request('updateField'); + $sku = GoodsSku::query()->find($id); + $this->setBeforeUpdate($sku->$updateField); + $sku->$updateField = $request->$updateField; + $sku->save(); + $this->setAfterUpdate($sku->$updateField); + $this->addLog($id, $updateField); + + return new GoodsSkuResource($sku); + } + + public function updateStock($id, Request $request) + { + $this->validateUpdate($request->all()); + $sku = GoodsSku::query()->where('id', $id)->get(['id', 'two_days_ago_num', 'yesterday_num']); + if ($sku->two_days_ago_num != \request('t wo_days_ago_num') || $sku->yesterday_num != \request('yesterday_num')) { + $this->setBeforeUpdate($sku->toArray()); + } + + } + + private function validateUpdate($data, $appendRules = []) + { + $rules = [ + '*.two_days_ago_num' => [ + 'sometimes', + 'integer', + ], + '*.yesterday_num' => [ + 'sometimes', + 'integer', + ], + '*.arrived_today_num' => [ + 'sometimes', + 'integer', + ], + '*.cost' => [ + 'sometimes', + 'numeric', + 'gt:0' + ], + '*.reference_price' => [ + 'sometimes', + 'numeric', + 'gt:0' + ], + '*.reserve' => [ + 'sometimes', + 'integer', + ], + '*.loss_num' => [ + 'sometimes', + 'integer', + ], + '*.inventory' => [ + 'sometimes', + 'integer', + ], + '*.status' => [ + 'sometimes', + 'integer', + Rule::in([0, 1, 2]) + ], + ]; + $validator = Validator::make($data, array_merge($rules, $appendRules)); + if ($validator->fails()) { + $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); + + return response($this->res, $this->res['httpCode']); + } } public function store(Request $request) diff --git a/app/Http/Controllers/Shop/ShopsController.php b/app/Http/Controllers/Shop/ShopsController.php new file mode 100644 index 0000000..f4fd384 --- /dev/null +++ b/app/Http/Controllers/Shop/ShopsController.php @@ -0,0 +1,45 @@ +paginate(); + + return ShopsResource::collection($shops); + } + + public function getPlatList() + { + $shop = new Shop(); + + return new ShopsResource($shop->getPlatList()); + } + + public function store(Request $request) + { + $validator = Validator::make($request->all(), [ + 'name' => 'required|string|max:255|unique:shops,name', + 'plat_id' => 'required|integer', + ]); + if ($validator->fails()) { + $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); + + return response($this->res, $this->res['httpCode']); + } + $shop = new Shop(); + $shop->name = $request->name; + $shop->plat_id = $request->plat_id; + $shop->save(); + + return response($this->res, $this->res['httpCode']); + } +} diff --git a/app/Http/Resources/ShopsResource.php b/app/Http/Resources/ShopsResource.php new file mode 100644 index 0000000..33fdcbf --- /dev/null +++ b/app/Http/Resources/ShopsResource.php @@ -0,0 +1,19 @@ + '未授权', + 1 => '已授权', + 2 => '无需授权', + 3 => '停用', + ]; + + return $map[$value]; + } + + public function getPlatList() + { + return ['妙选', '快团团']; + } + + public function getPlatIdAttribute($value) + { + $map = $this->getPlatList(); + + return $map[$value]; + } +} diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index fc36207..03b4dc9 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -20,6 +20,7 @@ class CreateUsersTable extends Migration $table->timestamp('email_verified_at')->nullable(); $table->string('password'); $table->string('api_token', 80)->unique()->nullable(false); + $table->softDeletes(); $table->rememberToken(); $table->timestamps(); }); diff --git a/database/migrations/2022_08_02_022448_create_shops_table.php b/database/migrations/2022_08_02_022448_create_shops_table.php new file mode 100644 index 0000000..7fddb77 --- /dev/null +++ b/database/migrations/2022_08_02_022448_create_shops_table.php @@ -0,0 +1,45 @@ +bigIncrements('id'); + $table->string('name')->unique(); + $table->unsignedTinyInteger('plat_id')->comment('平台id'); + $table->string('access_token')->nullable(); + $table->unsignedMediumInteger('expires_at')->nullable()->comment('access_token过期时间点'); + $table->unsignedInteger('expires_in')->nullable()->comment('access_token过期时间段,10(表示10秒后过期)'); + $table->string('owner_id')->nullable()->comment('商家店铺id'); + $table->string('owner_name')->nullable()->comment('商家账号名称'); + $table->string('refresh_token')->nullable()->comment('refresh token,可用来刷新access_token'); + $table->unsignedMediumInteger('refresh_token_expires_at')->nullable()->comment('Refresh token过期时间点'); + $table->unsignedInteger('refresh_token_expires_in')->nullable()->comment('refresh_token过期时间段,10表示10秒后过期'); + $table->text('scope')->nullable()->comment('接口列表'); + $table->text('pop_auth_token_create_response')->nullable()->comment('授权认证信息'); + $table->string('status')->default(0)->comment('状态'); + $table->softDeletes(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('shops'); + } +} diff --git a/database/seeds/MenusTableSeeder.php b/database/seeds/MenusTableSeeder.php index 3aff505..d968742 100644 --- a/database/seeds/MenusTableSeeder.php +++ b/database/seeds/MenusTableSeeder.php @@ -30,6 +30,6 @@ class MenusTableSeeder extends Seeder ['parent_id' => $id,'code' => 'PERMISSION_MANAGE', 'name' => '权限管理', 'seq' => 1], ]); // 系统日志 - DB::table('menus')->insertGetId(['parent_id' => 0,'code' => 'SYSTEM_LOG', 'name' => '系统管理', 'seq' => 4]); + DB::table('menus')->insertGetId(['parent_id' => 0,'code' => 'SYSTEM_LOG', 'name' => '系统日志', 'seq' => 4]); } } From ad4f38fcbe45729c1fdd4b099e5dd7e1aedf0038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Tue, 2 Aug 2022 16:28:22 +0800 Subject: [PATCH 16/68] =?UTF-8?q?feat:=20#20220802=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=A2=9E=E5=8A=A0=E8=A7=92=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/User/UsersController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Http/Controllers/User/UsersController.php b/app/Http/Controllers/User/UsersController.php index f2f4f30..dd69dc0 100644 --- a/app/Http/Controllers/User/UsersController.php +++ b/app/Http/Controllers/User/UsersController.php @@ -35,6 +35,7 @@ class UsersController extends Controller 'name' => 'required|string|unique:users,name|max:255', 'password' => 'required|string|min:8|confirmed', 'email' => 'email', + 'role_name' => 'required|string|exists:roles,name' ]); if ($validator->fails()) { $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); @@ -49,6 +50,7 @@ class UsersController extends Controller $user->save(); $this->setAfterUpdate($user->toArray()); $this->addLog($user->id, 'add'); + $user->assignRole($request->role_name); return new UsersResource($user); } From e83421ea5b6dee5db3b6ec7ee7d0332a75bf2bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Tue, 2 Aug 2022 18:20:06 +0800 Subject: [PATCH 17/68] =?UTF-8?q?feat:=20#20220802=20=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Role/RolesController.php | 2 +- app/Http/Controllers/User/UsersController.php | 46 +++++++++++++++++-- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Role/RolesController.php b/app/Http/Controllers/Role/RolesController.php index caca780..93ecc3d 100644 --- a/app/Http/Controllers/Role/RolesController.php +++ b/app/Http/Controllers/Role/RolesController.php @@ -45,7 +45,7 @@ class RolesController extends Controller $this->setAfterUpdate($role->name); $this->addLog($role->id, 'add'); - return response($this->res, $this->res['httpCode']); + return new RolesResource($role); } public function addPermissions($id, Request $request) diff --git a/app/Http/Controllers/User/UsersController.php b/app/Http/Controllers/User/UsersController.php index dd69dc0..e341bae 100644 --- a/app/Http/Controllers/User/UsersController.php +++ b/app/Http/Controllers/User/UsersController.php @@ -10,6 +10,7 @@ use Faker\Generator as Faker; use Illuminate\Support\Facades\Validator; use Illuminate\Support\Str; use App\Http\Resources\UsersResource; +use Illuminate\Validation\Rule; class UsersController extends Controller { @@ -24,7 +25,7 @@ class UsersController extends Controller public function index() { - $users = User::query()->where('id', '<>', 1)->paginate(); + $users = User::query()->where('id', '<>', 1)->with('roles:id,name,guard_name')->paginate(); return UsersResource::collection($users); } @@ -32,7 +33,7 @@ class UsersController extends Controller public function store(Request $request, Faker $faker) { $validator = Validator::make($request->all(), [ - 'name' => 'required|string|unique:users,name|max:255', + 'name' => 'required|string|max:255|unique:users,name', 'password' => 'required|string|min:8|confirmed', 'email' => 'email', 'role_name' => 'required|string|exists:roles,name' @@ -57,16 +58,51 @@ class UsersController extends Controller public function show($id) { - return new UsersResource(User::query()->find($id)); + return new UsersResource(User::query()->with('roles:id,name,guard_name')->find($id)); } - public function update() + public function update($id, Request $request) { + $validator = Validator::make($request->all(), [ + 'name' => [ + 'required', + 'string', + 'max:255', + Rule::unique('users')->ignore($id), + ], +// 'old_password' => 'sometimes|required|string|min:8', + 'password' => 'sometimes|string|min:8|confirmed', + 'email' => 'sometimes|email', + 'role_name' => 'sometimes|required|string|exists:roles,name' + ]); + if ($validator->fails()) { + $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); + return response($this->res, $this->res['httpCode']); + } + $user = User::query()->find($id); + $user->update($request->toArray()); + if ($request->has('role_name')) { + $user->syncRoles($request->role_name); + } + + return new UsersResource($user); } - public function destory() + public function destory($id) { + $user = User::query()->find($id); + try { + $user->delete(); + $this->addLog($id, 'status'); + } catch (\Exception $e) { + $this->res = [ + 'httpCode' => 500, + 'errorCode' => 500416, + 'errorMessage' => $e->getMessage(), + ]; + } + return response($this->res, $this->res['httpCode']); } } From 1ae21f041f170d63aad8a01d3974facf4936ff59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Tue, 2 Aug 2022 18:56:04 +0800 Subject: [PATCH 18/68] =?UTF-8?q?feat:=20#20220802=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/UploadController.php | 33 +++ app/Utils/UploadUtils.php | 123 +++++++++ composer.json | 2 + composer.lock | 290 +++++++++++++++++++++- config/filesystems.php | 13 +- routes/api.php | 2 + 6 files changed, 461 insertions(+), 2 deletions(-) create mode 100644 app/Http/Controllers/UploadController.php create mode 100644 app/Utils/UploadUtils.php diff --git a/app/Http/Controllers/UploadController.php b/app/Http/Controllers/UploadController.php new file mode 100644 index 0000000..59773ce --- /dev/null +++ b/app/Http/Controllers/UploadController.php @@ -0,0 +1,33 @@ +log = new LogModel([ + 'module' => 'file', + 'action' => $request->getMethod(), + 'target_type' => 'upload', + ]); + } + + public function store(Request $request) + { + if (!$request->hasFile('uploadFile')) { + $this->res = [ + 'httpCode' => 404, + 'errorCode' => 404404, + 'errorMessage' => 'not found file', + ]; + } + $this->addLog(0, 'add'); + + return UploadUtils::putForUploadedFile('image', $request->uploadFile); + } +} diff --git a/app/Utils/UploadUtils.php b/app/Utils/UploadUtils.php new file mode 100644 index 0000000..caaba2c --- /dev/null +++ b/app/Utils/UploadUtils.php @@ -0,0 +1,123 @@ +extension() != 'gif') { + // 压缩图片 + $originalName = static::randomFileName($extension ?: $upload->getClientOriginalExtension()); + $storagePath = storage_path('app/public/file/') . $originalName; + $img = Image::make($upload->getRealPath()); + + // 未传宽度 大于800压缩至800 否则按照原宽度 + $width = $img->width() >= 800 ? 800 : $img->width(); + // 高度自适应 + $img->resize($width, null, function ($constraint) { + $constraint->aspectRatio(); + }); + $img->save($storagePath); + $upload = new UploadedFile($storagePath, $originalName); + } + + // 上传并删除压缩图片 + try { + $filePath = static::put($bucketPath, $upload->getRealPath(), $upload->getClientOriginalExtension()); + } catch (OssException $e) { + throw $e; + } finally { + if (isset($storagePath)) { + unlink($storagePath); + } + } + + return $filePath; + } + + //上传图片 + public static function putForUploadedFile($bucketPath, UploadedFile $upload) + { + return static::put($bucketPath, $upload->getRealPath(), $upload->getClientOriginalExtension()); + } + + public static function put($bucketPath, $filepath, $ext) + { + static::init(); + try { + $filePath = static::$prefix . $bucketPath . '/' . static::randomFileName($ext); + static::$ossClient->uploadFile(static::$bucket, $filePath, $filepath); + } catch (OssException $e) { + throw $e; + } + return $filePath; + } + + public static function buildFilePath() + { + return date('Y') . '/' . date('m') . '/' . date('d'); + } + + public static function randomFileName($ext, $len = 40) + { + return Str::random($len) . '.' . $ext; + } + + //删除修改前,上传修改后图片 + public static function delAndUploadImage($file, $filePath, UploadedFile $upload) + { + static::delFile($file); + return static::putForUploadedFile($filePath, $upload); + } + + //删除修改前,上传修改后视频 + public static function delAndUploadVideo($file, $filePath, UploadedFile $upload) + { + static::delFile($file); + return static::putForUploadedFile($filePath, $upload); + } + + public static function delFile($file) + { + static::init(); + if (static::exist($file)) { + return static::$ossClient->deleteObject(static::$bucket, $file); + } + return false; + } + + public static function exist($file) + { + static::init(); + return static::$ossClient->doesObjectExist(static::$bucket, $file); + } + + public static function getFullImgUrl($filePath) + { + return config('filesystems.disks.aliyun.url') . $filePath; + } + +} diff --git a/composer.json b/composer.json index 63a511a..e442ecc 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,9 @@ "license": "MIT", "require": { "php": "^7.2.5|^8.0", + "aliyuncs/oss-sdk-php": "^2.5", "fideloper/proxy": "^4.4", + "intervention/image": "^2.7", "laravel/framework": "^6.20.26", "laravel/tinker": "^2.5", "maatwebsite/excel": "^3.1", diff --git a/composer.lock b/composer.lock index 6c4e88e..b66292d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,53 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "486f251784470138e7bd835f6ea84ce3", + "content-hash": "87b78d5c6e1dfc1285abb501c7eb8372", "packages": [ + { + "name": "aliyuncs/oss-sdk-php", + "version": "v2.5.0", + "source": { + "type": "git", + "url": "https://github.com/aliyun/aliyun-oss-php-sdk.git", + "reference": "f0413667d765855eb0aaa728b596801464ffdb06" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/f0413667d765855eb0aaa728b596801464ffdb06", + "reference": "f0413667d765855eb0aaa728b596801464ffdb06", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "*", + "satooshi/php-coveralls": "*" + }, + "type": "library", + "autoload": { + "psr-4": { + "OSS\\": "src/OSS" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aliyuncs", + "homepage": "http://www.aliyun.com" + } + ], + "description": "Aliyun OSS SDK for PHP", + "homepage": "http://www.aliyun.com/product/oss/", + "support": { + "issues": "https://github.com/aliyun/aliyun-oss-php-sdk/issues", + "source": "https://github.com/aliyun/aliyun-oss-php-sdk/tree/v2.5.0" + }, + "time": "2022-05-13T07:41:28+00:00" + }, { "name": "doctrine/inflector", "version": "2.0.4", @@ -414,6 +459,205 @@ }, "time": "2022-02-09T13:33:34+00:00" }, + { + "name": "guzzlehttp/psr7", + "version": "2.4.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "13388f00956b1503577598873fffb5ae994b5737" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/13388f00956b1503577598873fffb5ae994b5737", + "reference": "13388f00956b1503577598873fffb5ae994b5737", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "http-interop/http-factory-tests": "^0.9", + "phpunit/phpunit": "^8.5.8 || ^9.3.10" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.4.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "time": "2022-06-20T21:43:11+00:00" + }, + { + "name": "intervention/image", + "version": "2.7.2", + "source": { + "type": "git", + "url": "https://github.com/Intervention/image.git", + "reference": "04be355f8d6734c826045d02a1079ad658322dad" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Intervention/image/zipball/04be355f8d6734c826045d02a1079ad658322dad", + "reference": "04be355f8d6734c826045d02a1079ad658322dad", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "guzzlehttp/psr7": "~1.1 || ^2.0", + "php": ">=5.4.0" + }, + "require-dev": { + "mockery/mockery": "~0.9.2", + "phpunit/phpunit": "^4.8 || ^5.7 || ^7.5.15" + }, + "suggest": { + "ext-gd": "to use GD library based image processing.", + "ext-imagick": "to use Imagick based image processing.", + "intervention/imagecache": "Caching extension for the Intervention Image library" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + }, + "laravel": { + "providers": [ + "Intervention\\Image\\ImageServiceProvider" + ], + "aliases": { + "Image": "Intervention\\Image\\Facades\\Image" + } + } + }, + "autoload": { + "psr-4": { + "Intervention\\Image\\": "src/Intervention/Image" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Oliver Vogel", + "email": "oliver@intervention.io", + "homepage": "https://intervention.io/" + } + ], + "description": "Image handling and manipulation library with support for Laravel integration", + "homepage": "http://image.intervention.io/", + "keywords": [ + "gd", + "image", + "imagick", + "laravel", + "thumbnail", + "watermark" + ], + "support": { + "issues": "https://github.com/Intervention/image/issues", + "source": "https://github.com/Intervention/image/tree/2.7.2" + }, + "funding": [ + { + "url": "https://paypal.me/interventionio", + "type": "custom" + }, + { + "url": "https://github.com/Intervention", + "type": "github" + } + ], + "time": "2022-05-21T17:30:32+00:00" + }, { "name": "laravel/framework", "version": "v6.20.44", @@ -2131,6 +2375,50 @@ }, "time": "2022-07-07T13:49:11+00:00" }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "time": "2019-03-08T08:55:37+00:00" + }, { "name": "ramsey/uuid", "version": "3.9.6", diff --git a/config/filesystems.php b/config/filesystems.php index 220c010..9df9941 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -64,7 +64,18 @@ return [ 'url' => env('AWS_URL'), 'endpoint' => env('AWS_ENDPOINT'), ], - + 'aliyun' => [ + 'driver' => 'oss', + 'access_id' => 'LTAI6do39W9jINpe', + 'access_key' => 'XLhp5w4WnRcqji204GYOm7hZsoXSB6', + 'bucket' => 'ct-upimg', + 'endpoint' => 'oss-cn-hangzhou.aliyuncs.com', // OSS 外网节点或自定义外部域名 +// 'cdnDomain' => 'cdn-xiangma.yx090.com', // 如果isCName为true, getUrl会判断cdnDomain是否设定来决定返回的url,如果cdnDomain未设置,则使用endpoint来生成url,否则使用cdn + 'url' => 'https://ct-upimg.yx090.com/', + 'ssl' => true, + 'isCName' => false, // 是否使用自定义域名,true: 则Storage.url()会使用自定义的cdn或域名生成文件url, false: 则使用外部节点生成url + 'debug' => true + ], ], ]; diff --git a/routes/api.php b/routes/api.php index e97d2a3..2ce75fd 100644 --- a/routes/api.php +++ b/routes/api.php @@ -2,6 +2,7 @@ use App\Http\Controllers\Auth\LoginController; use App\Http\Controllers\Role\RolesController; +use App\Http\Controllers\UploadController; /* |-------------------------------------------------------------------------- @@ -37,6 +38,7 @@ Route::middleware('auth:api')->group(function () { Route::resource('menus', 'Menu\MenusController', ['only' => ['index', // 'store', 'show', 'update', 'destroy' ]]); + Route::post('upload', [UploadController::class, 'store'])->name('upload.file'); }); Route::post('/auth/login', [LoginController::class, 'login'])->name('auth.login'); From 92c95b529691976931a904234f67e2e15462969e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Tue, 2 Aug 2022 19:01:47 +0800 Subject: [PATCH 19/68] =?UTF-8?q?feat:=20#20220802=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/UploadController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/UploadController.php b/app/Http/Controllers/UploadController.php index 59773ce..38ede3f 100644 --- a/app/Http/Controllers/UploadController.php +++ b/app/Http/Controllers/UploadController.php @@ -27,7 +27,8 @@ class UploadController extends Controller ]; } $this->addLog(0, 'add'); + $this->res['resource'] = UploadUtils::putForUploadedFile('image', $request->uploadFile); - return UploadUtils::putForUploadedFile('image', $request->uploadFile); + return response($this->res, $this->res['httpCode']); } } From 4e7d24e0151437c83b2fd833b0a7925370b899c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Tue, 2 Aug 2022 20:02:48 +0800 Subject: [PATCH 20/68] =?UTF-8?q?feat:=20#20220802=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=BA=97=E9=93=BA=E5=B9=B3=E5=8F=B0=E5=88=97=E8=A1=A8=E8=B7=AF?= =?UTF-8?q?=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/api.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/routes/api.php b/routes/api.php index 2ce75fd..7ae0b39 100644 --- a/routes/api.php +++ b/routes/api.php @@ -3,6 +3,7 @@ use App\Http\Controllers\Auth\LoginController; use App\Http\Controllers\Role\RolesController; use App\Http\Controllers\UploadController; +use App\Http\Controllers\Shop\ShopsController; /* |-------------------------------------------------------------------------- @@ -29,6 +30,7 @@ Route::middleware('auth:api')->group(function () { Route::resource('goods_skus', 'Goods\GoodsSkusController', ['only' => ['index', 'show', 'update', 'store']]); // 店铺 Route::resource('shops', 'Shop\ShopsController', ['only' => ['index', 'store', 'show', 'update', 'destroy']]); + Route::get('shop_platforms', [ShopsController::class, 'getPlatList'])->name('plat.list'); // 角色 Route::resource('roles', 'Role\RolesController', ['only' => ['index', 'store', 'show', 'update']]); Route::post('roles/{id}/permissions', [RolesController::class, 'addPermissions'])->name('role.permission'); From 2d59a6f9da9788bf34be9ae9d5defc604e5c7299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Tue, 2 Aug 2022 20:15:57 +0800 Subject: [PATCH 21/68] =?UTF-8?q?feat:=20#20220802=20=E8=A7=84=E6=A0=BC?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=9F=A5=E7=9C=8B=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Goods/GoodsSkusController.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index cf40820..ff4a3fa 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -32,7 +32,11 @@ class GoodsSkusController extends Controller public function show($id) { - return new GoodsSkuResource(GoodsSku::query()->with(['goods', 'brand'])->find($id)); + return new GoodsSkuResource(GoodsSku::query() + ->with(['goods' => function ($query) { + $query->with(['type:id,name', 'brand:id,name']); + }]) + ->find($id)); } public function update($id, Request $request) @@ -41,7 +45,7 @@ class GoodsSkusController extends Controller $this->validateUpdate($data); $sku = GoodsSku::query()->find($id); $this->setBeforeUpdate($sku->toArray()); - $sku->save($data); + $sku->update($data); $this->setAfterUpdate($sku->toArray()); $this->addLog($id, 'update'); From ada42eaae66641ea3d3d38a438dd4c71e4c20b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Wed, 3 Aug 2022 11:14:08 +0800 Subject: [PATCH 22/68] =?UTF-8?q?feat:=20#20220803=20=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Goods/GoodsController.php | 53 ++++++++++--------- .../Controllers/Goods/GoodsSkusController.php | 31 ++++++++--- routes/api.php | 2 + 3 files changed, 53 insertions(+), 33 deletions(-) diff --git a/app/Http/Controllers/Goods/GoodsController.php b/app/Http/Controllers/Goods/GoodsController.php index 4498091..b50aa0f 100644 --- a/app/Http/Controllers/Goods/GoodsController.php +++ b/app/Http/Controllers/Goods/GoodsController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Goods; use App\Http\Controllers\Controller; +use App\Http\Resources\GoodsResource; use App\Http\Resources\GoodsSkuResource; use App\Models\Log as LogModel; use Illuminate\Http\Request; @@ -25,39 +26,35 @@ class GoodsController extends Controller public function index(Request $request) { - $goods = Goods::query()->filter()->get()->toArray(); - $goodsIds = array_column($goods, 'id'); - // 状态变更时间查询,日志 - $day = date('Y-m-d'); //早上7点之前是昨天,7点之后是今天 - $goodsSkus = GoodsSku::query() - ->whereIn('goods_id', $goodsIds) - ->filter() - ->with(['goods' => function ($query) { - $query->with(['type:id,name', 'brand:id,name']); - }]) - ->with(['daily' => function ($query) use ($day){ - $query->where('day', $day)->with(['daily:id,sku_id,day,arrived_today_num,loss_num,inventory']); - }]) - ->paginate(); + $goods = Goods::query()->get(['id', 'title', 'img_url', 'type_id', 'brand_id', 'goods_code']); - return GoodsSkuResource::collection($goodsSkus); + return GoodsResource::collection($goods); } public function store(Request $request) { - $validator = Validator::make($request->all(), [ + $goodsRules = [ 'title' => ['required', 'string', 'max:255'], 'img_url' => ['required', 'string', 'max:255'], 'type_id' => ['required', 'integer', 'exists:goods_types,id'], 'brand_id' => ['integer', 'exists:goods_brands,id'], 'goods_code' => ['required', 'alpha_dash', 'max:32', 'unique:goods,goods_code'], + ]; + + if ($useGoods = !empty($request->goods_id)) { + $goodsRules = [ + 'goods_id' => ['required', 'integer', 'exists:goods,id'], + ]; + } + $skuRules = [ 'skus' => ['required', 'array'], 'skus.*.title' => ['required', 'string', 'max:255'], 'skus.*.sku_code' => ['required', 'distinct', 'alpha_dash', 'max:32'], 'skus.*.status' => ['required', 'integer', Rule::in([0, 1, 2])], - 'skus.*.num' => ['required', 'integer', 'max:10'], - 'skus.*.cost' => ['required', 'numeric', 'max:10'], - ]); + 'skus.*.num' => ['required', 'integer'], + 'skus.*.cost' => ['required', 'numeric'], + ]; + $validator = Validator::make($request->all(), array_merge($goodsRules, $skuRules)); if ($validator->fails()) { $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); @@ -65,13 +62,17 @@ class GoodsController extends Controller } DB::beginTransaction(); try { - $goods = new Goods(); - $goods->title = $request->title; - $goods->img_url = $request->img_url; - $goods->type_id = $request->type_id; - $goods->brand_id = $request->brand_id; - $goods->goods_code = $request->goods_code; - $goods->save(); + if ($useGoods) { + $goods = Goods::query()->find($request->goods_id); + } else { + $goods = new Goods(); + $goods->title = $request->title; + $goods->img_url = $request->img_url; + $goods->type_id = $request->type_id; + $goods->brand_id = $request->brand_id; + $goods->goods_code = $request->goods_code; + $goods->save(); + } $goodsSkus = []; foreach ($request->skus as $item) { $item['goods_id'] = $goods->id; diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index ff4a3fa..fa8af86 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Goods; use App\Http\Controllers\Controller; +use App\Models\Goods; use App\Models\Log as LogModel; use Illuminate\Http\Request; use App\Models\GoodsSku; @@ -27,7 +28,22 @@ class GoodsSkusController extends Controller public function index(Request $request) { - return new GoodsSkuResource(GoodsSku::query()->get(['id', 'title'])); + $goods = Goods::query()->filter()->get()->toArray(); + $goodsIds = array_column($goods, 'id'); + // 状态变更时间查询,日志 + $day = date('Y-m-d'); //早上7点之前是昨天,7点之后是今天 + $goodsSkus = GoodsSku::query() + ->whereIn('goods_id', $goodsIds) + ->filter() + ->with(['goods' => function ($query) { + $query->with(['type:id,name', 'brand:id,name']); + }]) + ->with(['daily' => function ($query) use ($day){ + $query->where('day', $day)->with(['daily:id,sku_id,day,arrived_today_num,loss_num,inventory']); + }]) + ->paginate(); + + return GoodsSkuResource::collection($goodsSkus); } public function show($id) @@ -55,11 +71,16 @@ class GoodsSkusController extends Controller public function batchUpdate(Request $request) { $appendRules = [ - '*.id' => [ + 'skus' => ['required', 'array'], + 'skus.*.id' => [ 'required', Rule::exists('goods_skus', 'id'), ], ]; + $data = $request->all(); + $this->validateUpdate($data, $appendRules); + GoodsSku::whereIn('id', array_column($data, 'id')) + ->update($data); } public function updateField($id, Request $request) @@ -138,12 +159,8 @@ class GoodsSkusController extends Controller Rule::in([0, 1, 2]) ], ]; +// $validator = Validator::make($data, array_merge($rules, $appendRules))->validate(); $validator = Validator::make($data, array_merge($rules, $appendRules)); - if ($validator->fails()) { - $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); - - return response($this->res, $this->res['httpCode']); - } } public function store(Request $request) diff --git a/routes/api.php b/routes/api.php index 7ae0b39..c6b756b 100644 --- a/routes/api.php +++ b/routes/api.php @@ -4,6 +4,7 @@ use App\Http\Controllers\Auth\LoginController; use App\Http\Controllers\Role\RolesController; use App\Http\Controllers\UploadController; use App\Http\Controllers\Shop\ShopsController; +use App\Http\Controllers\Goods\GoodsSkusController; /* |-------------------------------------------------------------------------- @@ -28,6 +29,7 @@ Route::middleware('auth:api')->group(function () { Route::resource('goods', 'Goods\GoodsController', ['only' => ['index', 'store']]); // 商品规格 Route::resource('goods_skus', 'Goods\GoodsSkusController', ['only' => ['index', 'show', 'update', 'store']]); + Route::patch('batch/goods_skus', [GoodsSkusController::class, 'batchUpdate'])->name('goods_sku.batch_update'); // 店铺 Route::resource('shops', 'Shop\ShopsController', ['only' => ['index', 'store', 'show', 'update', 'destroy']]); Route::get('shop_platforms', [ShopsController::class, 'getPlatList'])->name('plat.list'); From 1ee5c5eb8571a76c2986fc8939d5e9b451ded581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Wed, 3 Aug 2022 16:41:15 +0800 Subject: [PATCH 23/68] =?UTF-8?q?feat:=20#20220803=20=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Goods/GoodsController.php | 36 ++++---------- .../Controllers/Goods/GoodsSkusController.php | 43 +++++++++++++---- app/Http/Requests/GoodsRequest.php | 47 ++++++++++++++++++ app/Http/Requests/GoodsSkuPost.php | 30 ------------ app/Http/Requests/GoodsSkuRequest.php | 48 +++++++++++++++++++ app/Models/Goods.php | 2 + 6 files changed, 140 insertions(+), 66 deletions(-) create mode 100644 app/Http/Requests/GoodsRequest.php delete mode 100644 app/Http/Requests/GoodsSkuPost.php create mode 100644 app/Http/Requests/GoodsSkuRequest.php diff --git a/app/Http/Controllers/Goods/GoodsController.php b/app/Http/Controllers/Goods/GoodsController.php index b50aa0f..9a114dd 100644 --- a/app/Http/Controllers/Goods/GoodsController.php +++ b/app/Http/Controllers/Goods/GoodsController.php @@ -3,15 +3,14 @@ namespace App\Http\Controllers\Goods; use App\Http\Controllers\Controller; +use App\Http\Requests\GoodsSkuRequest; use App\Http\Resources\GoodsResource; -use App\Http\Resources\GoodsSkuResource; use App\Models\Log as LogModel; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Validator; -use Illuminate\Validation\Rule; use App\Models\Goods; -use App\Models\GoodsSku; +use App\Http\Requests\GoodsRequest; class GoodsController extends Controller { @@ -33,28 +32,9 @@ class GoodsController extends Controller public function store(Request $request) { - $goodsRules = [ - 'title' => ['required', 'string', 'max:255'], - 'img_url' => ['required', 'string', 'max:255'], - 'type_id' => ['required', 'integer', 'exists:goods_types,id'], - 'brand_id' => ['integer', 'exists:goods_brands,id'], - 'goods_code' => ['required', 'alpha_dash', 'max:32', 'unique:goods,goods_code'], - ]; - - if ($useGoods = !empty($request->goods_id)) { - $goodsRules = [ - 'goods_id' => ['required', 'integer', 'exists:goods,id'], - ]; - } - $skuRules = [ - 'skus' => ['required', 'array'], - 'skus.*.title' => ['required', 'string', 'max:255'], - 'skus.*.sku_code' => ['required', 'distinct', 'alpha_dash', 'max:32'], - 'skus.*.status' => ['required', 'integer', Rule::in([0, 1, 2])], - 'skus.*.num' => ['required', 'integer'], - 'skus.*.cost' => ['required', 'numeric'], - ]; - $validator = Validator::make($request->all(), array_merge($goodsRules, $skuRules)); + $goodsRules = (new GoodsRequest())->rules(); + $skuRules = (new GoodsSkuRequest())->arrayRules('skus.*.'); + $validator = Validator::make($request->all(), array_merge($goodsRules, ['skus' => ['required', 'array']], $skuRules)); if ($validator->fails()) { $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); @@ -62,8 +42,8 @@ class GoodsController extends Controller } DB::beginTransaction(); try { - if ($useGoods) { - $goods = Goods::query()->find($request->goods_id); + if (!empty($request->id)) { + $goods = Goods::query()->find($request->id); } else { $goods = new Goods(); $goods->title = $request->title; @@ -79,9 +59,9 @@ class GoodsController extends Controller $goodsSkus[] = $item; } $collection = $goods->skus()->createMany($goodsSkus); - DB::commit(); $this->setAfterUpdate($collection->toArray()); $this->addLog(0, 'add'); + DB::commit(); } catch (\Exception $exception) { DB::rollBack(); $this->res = [ diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index fa8af86..d3344c8 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -3,12 +3,15 @@ namespace App\Http\Controllers\Goods; use App\Http\Controllers\Controller; +use App\Http\Requests\GoodsRequest; +use App\Http\Requests\GoodsSkuRequest; use App\Models\Goods; use App\Models\Log as LogModel; use Illuminate\Http\Request; use App\Models\GoodsSku; use App\Http\Resources\GoodsSkuResource; use App\Imports\GoodsSkusImport; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Validator; use Illuminate\Validation\Rule; use Illuminate\Validation\ValidationException; @@ -57,15 +60,39 @@ class GoodsSkusController extends Controller public function update($id, Request $request) { - $data = $request->all(); - $this->validateUpdate($data); - $sku = GoodsSku::query()->find($id); - $this->setBeforeUpdate($sku->toArray()); - $sku->update($data); - $this->setAfterUpdate($sku->toArray()); - $this->addLog($id, 'update'); + $goodsRules = (new GoodsRequest())->arrayRules('goods.'); + $skuRules = (new GoodsSkuRequest())->arrayRules('sku.'); + $validator = Validator::make($request->all(), array_merge($goodsRules, $skuRules)); + if ($validator->fails()) { + $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); - return new GoodsSkuResource($sku); + return response($this->res, $this->res['httpCode']); + } + DB::beginTransaction(); + try { + // 商品规格更新 + $sku = GoodsSku::query()->find($id); + $this->setBeforeUpdate($sku->toArray()); + $sku->update($request->sku); + $this->setAfterUpdate($sku->toArray()); + $this->addLog($id, 'update'); + // 商品更新 + $goods = Goods::query()->find($sku->goods_id); + $this->setBeforeUpdate($goods->toArray()); + $goods->update($request->goods); + $this->setAfterUpdate($goods->toArray()); + $this->addLog($sku->goods_id, 'update', 'goods'); + DB::commit(); + } catch (\Exception $exception) { + DB::rollBack(); + $this->res = [ + 'httpCode' => 400, + 'errorCode' => 400416, + 'errorMessage' => $exception->getMessage(), + ]; + } + + return response($this->res, $this->res['httpCode']); } public function batchUpdate(Request $request) diff --git a/app/Http/Requests/GoodsRequest.php b/app/Http/Requests/GoodsRequest.php new file mode 100644 index 0000000..e0ecc5f --- /dev/null +++ b/app/Http/Requests/GoodsRequest.php @@ -0,0 +1,47 @@ + ['sometimes', 'required', 'integer', 'exists:goods,id'], + 'title' => ['required', 'string', 'max:255'], + 'img_url' => ['required', 'string', 'max:255'], + 'type_id' => ['required', 'integer', 'exists:goods_types,id'], + 'brand_id' => ['integer', 'exists:goods_brands,id'], + 'goods_code' => ['required', 'alpha_dash', 'max:32', Rule::unique('goods')->ignore(request('goods_id'))], + ]; + } + + public function arrayRules($arrayName) + { + $arrayRules = []; + $rules = $this->rules(); + foreach ($rules as $key => $val) { + $arrayRules[$arrayName . $key] = $val; + } + + return $arrayRules; + } +} diff --git a/app/Http/Requests/GoodsSkuPost.php b/app/Http/Requests/GoodsSkuPost.php deleted file mode 100644 index cabbf76..0000000 --- a/app/Http/Requests/GoodsSkuPost.php +++ /dev/null @@ -1,30 +0,0 @@ - ['sometimes', 'required', 'integer', 'exists:goods_skus,id'], + 'goods_id' => ['sometimes', 'required', 'integer', 'exists:goods,id'], + 'title' => ['required', 'string', 'max:255'], + 'sku_code' => ['required', 'distinct', 'alpha_dash', 'max:32'], + 'status' => ['required', 'integer', Rule::in([0, 1, 2])], + 'num' => ['required', 'integer'], + 'cost' => ['required', 'numeric'], + ]; + } + + public function arrayRules($arrayName) + { + $arrayRules = []; + $rules = $this->rules(); + foreach ($rules as $key => $val) { + $arrayRules[$arrayName . $key] = $val; + } + + return $arrayRules; + } +} diff --git a/app/Models/Goods.php b/app/Models/Goods.php index 3498be6..f9f9ff2 100644 --- a/app/Models/Goods.php +++ b/app/Models/Goods.php @@ -15,6 +15,8 @@ class Goods extends Model 'brand_id', ]; + protected $guarded = []; + /** * 多规格 */ From dc013d9ae5f9b8e604aaa1dc0d873977f4cf199e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Wed, 3 Aug 2022 20:28:42 +0800 Subject: [PATCH 24/68] =?UTF-8?q?feat:=20#20220803=20=E5=95=86=E5=93=81?= =?UTF-8?q?=E8=A7=84=E6=A0=BC=E7=BC=96=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Goods/GoodsController.php | 20 +- .../Controllers/Goods/GoodsSkusController.php | 251 +++++++++++++----- app/Http/Requests/GoodsSkuRequest.php | 17 ++ app/Utils/FormatUtils.php | 21 +- .../2022_07_26_105818_create_logs_table.php | 1 + routes/api.php | 1 + 6 files changed, 232 insertions(+), 79 deletions(-) diff --git a/app/Http/Controllers/Goods/GoodsController.php b/app/Http/Controllers/Goods/GoodsController.php index 9a114dd..234752e 100644 --- a/app/Http/Controllers/Goods/GoodsController.php +++ b/app/Http/Controllers/Goods/GoodsController.php @@ -6,11 +6,13 @@ use App\Http\Controllers\Controller; use App\Http\Requests\GoodsSkuRequest; use App\Http\Resources\GoodsResource; use App\Models\Log as LogModel; +use App\Utils\FormatUtils; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Validator; use App\Models\Goods; use App\Http\Requests\GoodsRequest; +use App\Models\DailyStockRecord; class GoodsController extends Controller { @@ -42,8 +44,8 @@ class GoodsController extends Controller } DB::beginTransaction(); try { - if (!empty($request->id)) { - $goods = Goods::query()->find($request->id); + if (!empty($request->goods_id)) { + $goods = Goods::query()->find($request->goods_id); } else { $goods = new Goods(); $goods->title = $request->title; @@ -56,11 +58,21 @@ class GoodsController extends Controller $goodsSkus = []; foreach ($request->skus as $item) { $item['goods_id'] = $goods->id; + $item['reference_price'] = $item['cost'] * 1.5; $goodsSkus[] = $item; } - $collection = $goods->skus()->createMany($goodsSkus); - $this->setAfterUpdate($collection->toArray()); + $collection = $goods->skus()->createMany($goodsSkus)->toArray(); + $this->setAfterUpdate($collection); $this->addLog(0, 'add'); + $newRecords = []; + foreach ($collection as $sku) { + $newRecords[] = [ + 'sku_id' => $sku['id'], + 'day' => FormatUtils::date(), + ]; + } + $record = new DailyStockRecord(); + $record->batchInsert($newRecords); DB::commit(); } catch (\Exception $exception) { DB::rollBack(); diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index d3344c8..1798db4 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -7,6 +7,7 @@ use App\Http\Requests\GoodsRequest; use App\Http\Requests\GoodsSkuRequest; use App\Models\Goods; use App\Models\Log as LogModel; +use App\Utils\FormatUtils; use Illuminate\Http\Request; use App\Models\GoodsSku; use App\Http\Resources\GoodsSkuResource; @@ -16,6 +17,7 @@ use Illuminate\Support\Facades\Validator; use Illuminate\Validation\Rule; use Illuminate\Validation\ValidationException; use Maatwebsite\Excel\Facades\Excel; +use App\Models\DailyStockRecord; class GoodsSkusController extends Controller { @@ -34,14 +36,14 @@ class GoodsSkusController extends Controller $goods = Goods::query()->filter()->get()->toArray(); $goodsIds = array_column($goods, 'id'); // 状态变更时间查询,日志 - $day = date('Y-m-d'); //早上7点之前是昨天,7点之后是今天 + $day = FormatUtils::date(); $goodsSkus = GoodsSku::query() ->whereIn('goods_id', $goodsIds) ->filter() ->with(['goods' => function ($query) { $query->with(['type:id,name', 'brand:id,name']); }]) - ->with(['daily' => function ($query) use ($day){ + ->with(['daily' => function ($query) use ($day) { $query->where('day', $day)->with(['daily:id,sku_id,day,arrived_today_num,loss_num,inventory']); }]) ->paginate(); @@ -98,96 +100,199 @@ class GoodsSkusController extends Controller public function batchUpdate(Request $request) { $appendRules = [ + 'updateType' => ['required', 'string', Rule::in(['newest', 'inventory', 'stock'])], 'skus' => ['required', 'array'], 'skus.*.id' => [ 'required', Rule::exists('goods_skus', 'id'), ], ]; - $data = $request->all(); - $this->validateUpdate($data, $appendRules); - GoodsSku::whereIn('id', array_column($data, 'id')) - ->update($data); + $validator = $this->validateUpdate($request->all(), $appendRules); + if ($validator->fails()) { + $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); + + return response($this->res, $this->res['httpCode']); + } + $function = $request->updateType; + + return $this->$function($request); + } + + private function newest($request) + { + DB::beginTransaction(); + try { + $logs = []; + foreach ($request->skus as $sku) { + $costLog = $arrivedLog = [ + 'module' => 'goods', + 'action' => $request->getMethod(), + 'target_type' => 'goods_sku', + 'target_id' => $sku['id'], + 'user_id' => $request->user()->id + ]; + // 成本 + $goodsSku = GoodsSku::query()->where('id', $sku['id'])->first(['id', 'cost']); + $costLog['target_field'] = 'cost'; + $costLog['before_update'] = $goodsSku->cost; + $goodsSku->cost = $sku['cost']; + $goodsSku->reference_price = $sku['cost'] * 1.5; + $goodsSku->save(); + $costLog['after_update'] = $goodsSku->cost; + $logs[] = $costLog; + // 今日到货 + $record = DailyStockRecord::query()->where('sku_id', $sku['id'])->where('day', FormatUtils::date())->first(['id', 'arrived_today_num']); + $arrivedLog['target_field'] = 'arrived_today_num'; + $arrivedLog['before_update'] = $record->arrived_today_num; + $record->arrived_today_num = $sku['arrived_today_num']; + $record->save(); + $arrivedLog['after_update'] = $record->arrived_today_num; + $logs[] = $arrivedLog; + } + $log = new LogModel(); + $log->batchInsert($logs); + DB::commit(); + } catch (\Exception $exception) { + DB::rollBack(); + $this->res = [ + 'httpCode' => 400, + 'errorCode' => 400500, + 'errorMessage' => $exception->getMessage(), + ]; + } + + return response($this->res, $this->res['httpCode']); + } + + private function inventory($request) + { + DB::beginTransaction(); + try { + $logs = []; + foreach ($request->skus as $sku) { + $inventoryLog = [ + 'module' => 'goods', + 'action' => $request->getMethod(), + 'target_type' => 'goods_sku', + 'target_id' => $sku['id'], + 'user_id' => $request->user()->id + ]; + // 今日到货 + $record = DailyStockRecord::query()->where('sku_id', $sku['id'])->where('day', FormatUtils::date())->first(['id', 'inventory']); + $inventoryLog['target_field'] = 'inventory'; + $inventoryLog['before_update'] = $record->inventory; + $record->inventory = $sku['inventory']; + $record->save(); + $inventoryLog['after_update'] = $record->inventory; + $logs[] = $inventoryLog; + } + $log = new LogModel(); + $log->batchInsert($logs); + DB::commit(); + } catch (\Exception $exception) { + DB::rollBack(); + $this->res = [ + 'httpCode' => 400, + 'errorCode' => 400500, + 'errorMessage' => $exception->getMessage(), + ]; + } + + return response($this->res, $this->res['httpCode']); + } + + private function stock($skus) + { + $update = reset($skus); + DB::beginTransaction(); + try { + $sku = GoodsSku::query()->where('id', $update['id'])->get(['id', 'two_days_ago_num', 'yesterday_num']); + $record = DailyStockRecord::query() + ->where('sku_id', $sku->id) + ->where('day', FormatUtils::date()) + ->first(); + $this->setBeforeUpdate([ + 'two_days_ago_num' => $sku->two_days_ago_num, + 'yesterday_num' => $sku->yesterday_num, + 'arrived_today_num' => $record->arrived_today_num, + ]); + $sku->two_days_ago_num = $update['two_days_ago_num']; + $sku->yesterday_num = $update['two_days_ago_num']; + $sku->save(); + $record->arrived_today_num = $update['arrived_today_num']; + $record->save(); + $this->setAfterUpdate([ + 'two_days_ago_num' => $sku->two_days_ago_num, + 'yesterday_num' => $sku->yesterday_num, + 'arrived_today_num' => $record->arrived_today_num, + ]); + $this->addLog($sku->id, 'stock'); + DB::commit(); + } catch (\Exception $exception) { + DB::rollBack(); + $this->res = [ + 'httpCode' => 400, + 'errorCode' => 400416, + 'errorMessage' => $exception->getMessage(), + ]; + } + + return response($this->res, $this->res['httpCode']); } public function updateField($id, Request $request) { - $appendRules = [ + $rules = [ 'updateField' => [ 'required', Rule::in(['reference_price', 'reserve', 'loss_num', 'status']) ], + 'reference_price' => [ + 'sometimes', + 'numeric', + 'gt:0' + ], + 'reserve' => [ + 'sometimes', + 'integer', + ], + 'loss_num' => [ + 'sometimes', + 'integer', + ], + 'inventory' => [ + 'sometimes', + 'integer', + ], + 'reason' => [ + 'sometimes', + 'required', + 'string' + ] ]; - if ($request->has('loss_num')) { - $appendRules['reason'] = ['required', 'string']; + $validator = Validator::make($request->all(), $rules); + if ($validator->fails()) { + $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); + + return response($this->res, $this->res['httpCode']); } - $this->validateUpdate($request->all(), $appendRules); $updateField = \request('updateField'); - $sku = GoodsSku::query()->find($id); - $this->setBeforeUpdate($sku->$updateField); - $sku->$updateField = $request->$updateField; - $sku->save(); - $this->setAfterUpdate($sku->$updateField); + if ('loss_num' === $updateField) { + $model = DailyStockRecord::query() + ->where('sku_id', $id) + ->where('day', FormatUtils::date()) + ->first(['id', 'loss_num']); + $this->log->message = $request->input('reason', ''); + } else { + $model = GoodsSku::query()->find($id); + } + $this->setBeforeUpdate($model->$updateField); + $model->$updateField = $request->$updateField; + $model->save(); + $this->setAfterUpdate($model->$updateField); $this->addLog($id, $updateField); - return new GoodsSkuResource($sku); - } - - public function updateStock($id, Request $request) - { - $this->validateUpdate($request->all()); - $sku = GoodsSku::query()->where('id', $id)->get(['id', 'two_days_ago_num', 'yesterday_num']); - if ($sku->two_days_ago_num != \request('t wo_days_ago_num') || $sku->yesterday_num != \request('yesterday_num')) { - $this->setBeforeUpdate($sku->toArray()); - } - - } - - private function validateUpdate($data, $appendRules = []) - { - $rules = [ - '*.two_days_ago_num' => [ - 'sometimes', - 'integer', - ], - '*.yesterday_num' => [ - 'sometimes', - 'integer', - ], - '*.arrived_today_num' => [ - 'sometimes', - 'integer', - ], - '*.cost' => [ - 'sometimes', - 'numeric', - 'gt:0' - ], - '*.reference_price' => [ - 'sometimes', - 'numeric', - 'gt:0' - ], - '*.reserve' => [ - 'sometimes', - 'integer', - ], - '*.loss_num' => [ - 'sometimes', - 'integer', - ], - '*.inventory' => [ - 'sometimes', - 'integer', - ], - '*.status' => [ - 'sometimes', - 'integer', - Rule::in([0, 1, 2]) - ], - ]; -// $validator = Validator::make($data, array_merge($rules, $appendRules))->validate(); - $validator = Validator::make($data, array_merge($rules, $appendRules)); + return response($this->res, $this->res['httpCode']); } public function store(Request $request) diff --git a/app/Http/Requests/GoodsSkuRequest.php b/app/Http/Requests/GoodsSkuRequest.php index d6824e0..c403df0 100644 --- a/app/Http/Requests/GoodsSkuRequest.php +++ b/app/Http/Requests/GoodsSkuRequest.php @@ -32,6 +32,23 @@ class GoodsSkuRequest extends FormRequest 'status' => ['required', 'integer', Rule::in([0, 1, 2])], 'num' => ['required', 'integer'], 'cost' => ['required', 'numeric'], + 'reference_price' => [ + 'sometimes', + 'numeric', + 'gt:0' + ], + 'reserve' => [ + 'sometimes', + 'integer', + ], + 'loss_num' => [ + 'sometimes', + 'integer', + ], + 'inventory' => [ + 'sometimes', + 'integer', + ], ]; } diff --git a/app/Utils/FormatUtils.php b/app/Utils/FormatUtils.php index 667f332..a0a98d5 100644 --- a/app/Utils/FormatUtils.php +++ b/app/Utils/FormatUtils.php @@ -7,8 +7,11 @@ class FormatUtils /** * 格式化为树形结构 * @param $menus - * @param $parentId - * @param $juniorTitle //下级标题 + * @param $parentValue + * @param string $juniorTitle //下级标题 + * @param string $parentKey + * @param string $subKey + * @param string $useKey * @return array */ public static function formatTreeData($menus, $parentValue, $juniorTitle = 'children', $parentKey = 'parent_id', $subKey = 'id', $useKey = '') @@ -30,4 +33,18 @@ class FormatUtils } return $data; } + + /** + * 今天7点到明天7点算作今天 + */ + public static function date() + { + $time = time(); + $inventoryTime = strtotime(date('Y-m-d 07:00:00')); + if ($time < $inventoryTime) { + $time = strtotime('-1 day'); + } + + return date('Y-m-d', $time); + } } diff --git a/database/migrations/2022_07_26_105818_create_logs_table.php b/database/migrations/2022_07_26_105818_create_logs_table.php index 1ca6436..1530d0c 100644 --- a/database/migrations/2022_07_26_105818_create_logs_table.php +++ b/database/migrations/2022_07_26_105818_create_logs_table.php @@ -22,6 +22,7 @@ class CreateLogsTable extends Migration $table->string('target_field')->nullable()->comment('目标字段'); $table->text('before_update')->nullable()->comment('更新前数据'); $table->text('after_update')->nullable()->comment('更新后数据'); + $table->text('message')->nullable()->comment('备注信息'); $table->bigInteger('user_id')->comment('操作人id'); $table->timestamps(); }); diff --git a/routes/api.php b/routes/api.php index c6b756b..5c5adc8 100644 --- a/routes/api.php +++ b/routes/api.php @@ -30,6 +30,7 @@ Route::middleware('auth:api')->group(function () { // 商品规格 Route::resource('goods_skus', 'Goods\GoodsSkusController', ['only' => ['index', 'show', 'update', 'store']]); Route::patch('batch/goods_skus', [GoodsSkusController::class, 'batchUpdate'])->name('goods_sku.batch_update'); + Route::patch('single/goods_skus/{id}', [GoodsSkusController::class, 'updateField'])->name('goods_sku.single_update'); // 店铺 Route::resource('shops', 'Shop\ShopsController', ['only' => ['index', 'store', 'show', 'update', 'destroy']]); Route::get('shop_platforms', [ShopsController::class, 'getPlatList'])->name('plat.list'); From c45c004ad8545c54f2743cddb359f2e777b5ef48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Wed, 3 Aug 2022 20:41:04 +0800 Subject: [PATCH 25/68] =?UTF-8?q?feat:=20#20220803=20=E5=8D=95=E4=B8=AA?= =?UTF-8?q?=E5=95=86=E5=93=81=E4=BF=A1=E6=81=AF=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Goods/GoodsSkusController.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index 1798db4..d47c1cb 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -260,15 +260,16 @@ class GoodsSkusController extends Controller 'sometimes', 'integer', ], - 'inventory' => [ - 'sometimes', - 'integer', - ], 'reason' => [ 'sometimes', 'required', 'string' - ] + ], + 'status' => [ + 'sometimes', + 'required', + 'integer', + Rule::in([0, 1, 2])], ]; $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { From 9553c73c427de976192a5ec90041c721eeb642db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Thu, 4 Aug 2022 13:21:45 +0800 Subject: [PATCH 26/68] =?UTF-8?q?feat:=20#20220804=207=E7=82=B9=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E7=9B=98=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/Inventory.php | 79 +++++++++++++++++++ .../Controllers/Goods/GoodsSkusController.php | 1 + app/Models/Log.php | 2 +- ...03559_create_daily_stock_records_table.php | 1 + .../2022_07_26_105818_create_logs_table.php | 1 + 5 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 app/Console/Commands/Inventory.php diff --git a/app/Console/Commands/Inventory.php b/app/Console/Commands/Inventory.php new file mode 100644 index 0000000..59ad9f9 --- /dev/null +++ b/app/Console/Commands/Inventory.php @@ -0,0 +1,79 @@ +get(['id', 'stock', 'two_days_ago_num', 'yesterday_num']); + $data = []; + $date = date('Y-m-d'); + foreach ($skus as $sku) { + $data[] = [ + 'sku_id' => $sku->id, + 'day' => $date, + ]; + GoodsSku::where('id', $sku->id)->update([ + 'stock' => $sku->stock + $sku->two_days_ago_num + $sku->yesterday_num, + 'yesterday_num' => $sku->stock, + 'two_days_ago_num' => $sku->two_days_ago_num + $sku->yesterday_num, + ]); + } + $log = new Log(); + $log->module = 'goods'; + $log->action = 'PATCH'; + $log->target_type = 'goods_sku'; + $log->target_id = 0; + $log->target_field = 'timingInventory'; + $log->user_id = 1; + $record = new DailyStockRecord(); + $record->batchInsert($data); + $log->message = '成功'; + DB::commit(); + } catch (\Exception $exception) { + $log->message = '失败'; + DB::rollBack(); + } + $log->save(); + $this->info($log->message); + } +} diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index d47c1cb..f72f1a7 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -36,6 +36,7 @@ class GoodsSkusController extends Controller $goods = Goods::query()->filter()->get()->toArray(); $goodsIds = array_column($goods, 'id'); // 状态变更时间查询,日志 + $day = FormatUtils::date(); $goodsSkus = GoodsSku::query() ->whereIn('goods_id', $goodsIds) diff --git a/app/Models/Log.php b/app/Models/Log.php index 2b09204..75c1cd7 100644 --- a/app/Models/Log.php +++ b/app/Models/Log.php @@ -87,7 +87,7 @@ class Log extends Model public function setUserIdAttribute($value) { - $this->attributes['user_id'] = Auth::id(); + $this->attributes['user_id'] = Auth::id() ?: $value; } public function add($targetId = 0, $targetField = '') diff --git a/database/migrations/2022_07_26_103559_create_daily_stock_records_table.php b/database/migrations/2022_07_26_103559_create_daily_stock_records_table.php index 1c4706d..7d97f34 100644 --- a/database/migrations/2022_07_26_103559_create_daily_stock_records_table.php +++ b/database/migrations/2022_07_26_103559_create_daily_stock_records_table.php @@ -20,6 +20,7 @@ class CreateDailyStockRecordsTable extends Migration $table->unsignedInteger('arrived_today_num')->default(0)->comment('今日到货'); $table->unsignedInteger('loss_num')->default(0)->comment('损耗'); $table->unsignedInteger('inventory')->default(0)->comment('库存盘点'); + $table->unique('sku_id', 'day'); $table->timestamps(); }); } diff --git a/database/migrations/2022_07_26_105818_create_logs_table.php b/database/migrations/2022_07_26_105818_create_logs_table.php index 1530d0c..2a30d1c 100644 --- a/database/migrations/2022_07_26_105818_create_logs_table.php +++ b/database/migrations/2022_07_26_105818_create_logs_table.php @@ -24,6 +24,7 @@ class CreateLogsTable extends Migration $table->text('after_update')->nullable()->comment('更新后数据'); $table->text('message')->nullable()->comment('备注信息'); $table->bigInteger('user_id')->comment('操作人id'); + $table->index('target_type', 'target_id', 'target_field'); $table->timestamps(); }); } From 088c41cee9cb2c5a5d7e0e2a2ba81947294e8976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Thu, 4 Aug 2022 13:55:28 +0800 Subject: [PATCH 27/68] =?UTF-8?q?feat:=20#20220804=20=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E6=B5=8B=E8=AF=95=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Goods/GoodsSkusController.php | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index f72f1a7..044d95e 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -6,6 +6,7 @@ use App\Http\Controllers\Controller; use App\Http\Requests\GoodsRequest; use App\Http\Requests\GoodsSkuRequest; use App\Models\Goods; +use App\Models\Log; use App\Models\Log as LogModel; use App\Utils\FormatUtils; use Illuminate\Http\Request; @@ -36,10 +37,20 @@ class GoodsSkusController extends Controller $goods = Goods::query()->filter()->get()->toArray(); $goodsIds = array_column($goods, 'id'); // 状态变更时间查询,日志 - + $ids = []; + if ($request->get('keyword_type', '') && $request->get('keyword_value', '')) { + $ids = Log::query()->where('target_type', 'sku') + ->where('target_field', $request->keyword_type) + ->whereBetween('created_at', explode(' - ', $request->keyword_value)) + ->pluck('sku_id') + ->toArray(); + } $day = FormatUtils::date(); $goodsSkus = GoodsSku::query() ->whereIn('goods_id', $goodsIds) + ->when($ids, function ($query, $ids) { + return $query->whereIn('id', $ids); + }) ->filter() ->with(['goods' => function ($query) { $query->with(['type:id,name', 'brand:id,name']); @@ -133,11 +144,13 @@ class GoodsSkusController extends Controller 'user_id' => $request->user()->id ]; // 成本 - $goodsSku = GoodsSku::query()->where('id', $sku['id'])->first(['id', 'cost']); + $goodsSku = GoodsSku::query()->where('id', $sku['id'])->first(['id', 'cost', 'stock', 'num']); $costLog['target_field'] = 'cost'; $costLog['before_update'] = $goodsSku->cost; $goodsSku->cost = $sku['cost']; $goodsSku->reference_price = $sku['cost'] * 1.5; + $goodsSku->stock += $sku['arrived_today_num']; + $goodsSku->num += $sku['arrived_today_num']; $goodsSku->save(); $costLog['after_update'] = $goodsSku->cost; $logs[] = $costLog; @@ -145,7 +158,7 @@ class GoodsSkusController extends Controller $record = DailyStockRecord::query()->where('sku_id', $sku['id'])->where('day', FormatUtils::date())->first(['id', 'arrived_today_num']); $arrivedLog['target_field'] = 'arrived_today_num'; $arrivedLog['before_update'] = $record->arrived_today_num; - $record->arrived_today_num = $sku['arrived_today_num']; + $record->arrived_today_num += $sku['arrived_today_num']; $record->save(); $arrivedLog['after_update'] = $record->arrived_today_num; $logs[] = $arrivedLog; @@ -207,7 +220,7 @@ class GoodsSkusController extends Controller $update = reset($skus); DB::beginTransaction(); try { - $sku = GoodsSku::query()->where('id', $update['id'])->get(['id', 'two_days_ago_num', 'yesterday_num']); + $sku = GoodsSku::query()->where('id', $update['id'])->get(['id', 'two_days_ago_num', 'yesterday_num', 'num', 'stock']); $record = DailyStockRecord::query() ->where('sku_id', $sku->id) ->where('day', FormatUtils::date()) @@ -215,10 +228,12 @@ class GoodsSkusController extends Controller $this->setBeforeUpdate([ 'two_days_ago_num' => $sku->two_days_ago_num, 'yesterday_num' => $sku->yesterday_num, + 'num' => $sku->num, 'arrived_today_num' => $record->arrived_today_num, ]); $sku->two_days_ago_num = $update['two_days_ago_num']; - $sku->yesterday_num = $update['two_days_ago_num']; + $sku->yesterday_num = $update['yesterday_num']; + $sku->num = $update['two_days_ago_num'] + $update['yesterday_num'] + $sku->stock; $sku->save(); $record->arrived_today_num = $update['arrived_today_num']; $record->save(); @@ -284,12 +299,21 @@ class GoodsSkusController extends Controller ->where('sku_id', $id) ->where('day', FormatUtils::date()) ->first(['id', 'loss_num']); - $this->log->message = $request->input('reason', ''); + $this->log->message = $request->get('reason'); + $this->setBeforeUpdate($model->loss_num); + $model->loss_num += $request->loss_num; } else { $model = GoodsSku::query()->find($id); + $this->setBeforeUpdate($model->$updateField); + if ('reserve' === $updateField) { + $changeNum = $model->reserve - $request->reserve; + $model->stock += $changeNum; + $model->reserve = $request->reserve; + $model->num += $changeNum; + } else { + $model->$updateField = $request->$updateField; + } } - $this->setBeforeUpdate($model->$updateField); - $model->$updateField = $request->$updateField; $model->save(); $this->setAfterUpdate($model->$updateField); $this->addLog($id, $updateField); From 2dc13086751143861460f057189d8df7cd0a716b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Thu, 4 Aug 2022 14:25:12 +0800 Subject: [PATCH 28/68] =?UTF-8?q?feat:=20#20220804=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Exports/GoodsSkusExport.php | 75 +++++++++++++++++++ .../Controllers/Goods/GoodsSkusController.php | 8 ++ routes/web.php | 4 + 3 files changed, 87 insertions(+) create mode 100644 app/Exports/GoodsSkusExport.php diff --git a/app/Exports/GoodsSkusExport.php b/app/Exports/GoodsSkusExport.php new file mode 100644 index 0000000..d9316a8 --- /dev/null +++ b/app/Exports/GoodsSkusExport.php @@ -0,0 +1,75 @@ +type = $type; + $this->data = $this->createData(); + } + + /** + * @return \Illuminate\Support\Collection + */ + public function collection() + { + return new Collection($this->data); + } + + private function createData() + { + $headTitle = [ + '商品编码', + '商品名称', + '商品种类', + '商品品牌', + '规格编码', + '规格名称', + '成本', + '库存', + ]; + $inventoryTime = strtotime(date('Y-m-d 07:00:00')); + $ids = Log::query()->where('target_type', 'sku') + ->where('target_field', $this->type) + ->where('created_at', '>', $inventoryTime) + ->pluck('sku_id') + ->toArray(); + $data = GoodsSku::query() + ->when($ids, function ($query, $ids) { + return $query->whereIn('id', $ids); + }) + ->with(['goods' => function ($query) { + $query->with(['type:id,name', 'brand:id,name']); + }]) + ->get() + ->toArray(); + if (empty($data)) { + return [$headTitle]; + } + $bodyData = []; + foreach ($data as $item) { + $arr[0] = $item['goods']['goods_code']; + $arr[1] = $item['goods']['title']; + $arr[2] = $item['goods']['type']['name']; + $arr[3] = $item['goods']['brand']['name']; + $arr[4] = $item['goods']['sku_code']; + $arr[5] = $item['goods']['title']; + $arr[6] = $item['goods']['cost']; + $arr[7] = $item['goods']['stock']; + $bodyData[] = $arr; + } + unset($arr); + return [$headTitle, $bodyData]; + } +} diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index 044d95e..97053f1 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Goods; +use App\Exports\GoodsSkusExport; use App\Http\Controllers\Controller; use App\Http\Requests\GoodsRequest; use App\Http\Requests\GoodsSkuRequest; @@ -340,4 +341,11 @@ class GoodsSkusController extends Controller return response($this->res, $this->res['httpCode']); } + + public function export(Request $request) + { + $type = $request->get('exportType'); + ob_end_clean(); + return Excel::download(new GoodsSkusExport($type), $type, '.xlsx'); + } } diff --git a/routes/web.php b/routes/web.php index 4f8529e..0af6dd8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,5 +1,7 @@ name('register'); + +Route::get('goods_skus/export', [GoodsSkusController::class, 'export'])->name('goods_skus.export'); From 6520d8bd6f5485cdd85e7270af61541d1f392a9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Thu, 4 Aug 2022 18:13:00 +0800 Subject: [PATCH 29/68] =?UTF-8?q?feat:=20#20220804=20=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E6=9D=83=E9=99=90=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/UpdateSuperPermissions.php | 6 +- .../Controllers/Goods/GoodsSkusController.php | 1 - app/Http/Controllers/Menu/MenusController.php | 16 +- .../Permission/PermissionsController.php | 12 +- app/Http/Kernel.php | 1 + app/Http/Middleware/CheckPermissions.php | 38 +++ app/Models/User.php | 5 + config/filesystems.php | 4 + .../2022_07_26_105818_create_logs_table.php | 2 +- database/seeds/PermissionsTableSeeder.php | 18 +- resources/lang/zh-CN/permission.php | 234 ++++++++++++++++++ resources/templates/goods_skus_import.xlsx | Bin 0 -> 10134 bytes routes/api.php | 13 +- routes/web.php | 2 +- 14 files changed, 326 insertions(+), 26 deletions(-) create mode 100644 app/Http/Middleware/CheckPermissions.php create mode 100644 resources/lang/zh-CN/permission.php create mode 100644 resources/templates/goods_skus_import.xlsx diff --git a/app/Console/Commands/UpdateSuperPermissions.php b/app/Console/Commands/UpdateSuperPermissions.php index 637d6f8..c662b0b 100644 --- a/app/Console/Commands/UpdateSuperPermissions.php +++ b/app/Console/Commands/UpdateSuperPermissions.php @@ -2,6 +2,7 @@ namespace App\Console\Commands; +use App\Models\User; use Illuminate\Console\Command; use Spatie\Permission\Models\Permission; use Spatie\Permission\Models\Role; @@ -39,9 +40,12 @@ class UpdateSuperPermissions extends Command */ public function handle() { - $role = Role::query()->where('name', '超级管理员')->find(1); + $roleName = '超级管理员'; + $role = Role::query()->where('name', $roleName)->find(1); $permissions = Permission::query()->get(); $role->syncPermissions($permissions); + $user = User::query()->find(1); + $user->assignRole($role); $this->info('更新成功'); } } diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index 97053f1..e04ad52 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -25,7 +25,6 @@ class GoodsSkusController extends Controller { public function __construct(Request $request) { -// $this->middleware(['role:super-admin','permission:publish articles|edit articles']); $this->log = new LogModel([ 'module' => 'goods', 'action' => $request->getMethod(), diff --git a/app/Http/Controllers/Menu/MenusController.php b/app/Http/Controllers/Menu/MenusController.php index ee53406..dd50b68 100644 --- a/app/Http/Controllers/Menu/MenusController.php +++ b/app/Http/Controllers/Menu/MenusController.php @@ -6,6 +6,8 @@ use App\Http\Controllers\Controller; use App\Models\Log as LogModel; use App\Models\Menu; use App\Http\Resources\MenusResource; +use App\Models\User; +use App\Utils\ArrayUtils; use Illuminate\Http\Request; use Illuminate\Support\Facades\Validator; use Illuminate\Validation\Rule; @@ -22,10 +24,18 @@ class MenusController extends Controller ]); } - public function index() + public function index(Request $request) { - $menus = Menu::query()->get(); - $menus = FormatUtils::formatTreeData($menus, 0); + $permissions = $request->user()->getPermissionsViaRoles()->toArray(); + $permissions = array_column($permissions, 'name'); + $menus = Menu::query()->get()->toArray(); + $hasPermissionMenus = []; + foreach ($menus as $menu) { + if (in_array($menu['code'], $permissions, true)) { + $hasPermissionMenus[] = $menu; + } + } + $menus = FormatUtils::formatTreeData($hasPermissionMenus, 0); return MenusResource::collection($menus); } diff --git a/app/Http/Controllers/Permission/PermissionsController.php b/app/Http/Controllers/Permission/PermissionsController.php index 7507489..112f82b 100644 --- a/app/Http/Controllers/Permission/PermissionsController.php +++ b/app/Http/Controllers/Permission/PermissionsController.php @@ -4,6 +4,8 @@ namespace App\Http\Controllers\Permission; use App\Http\Controllers\Controller; use App\Models\Log as LogModel; +use App\Utils\ArrayUtils; +use App\Utils\FormatUtils; use Spatie\Permission\Models\Permission; use Illuminate\Http\Request; use Illuminate\Support\Facades\Validator; @@ -23,9 +25,15 @@ class PermissionsController extends Controller public function index() { - $permissions = Permission::query()->get(); + $permissions = Permission::query()->get()->toArray(); + $permissions = ArrayUtils::index($permissions, 'name'); + $routes = include(resource_path('lang/zh-CN/permission.php')); + foreach ($routes as $key => &$route) { + $route['id'] = $permissions[$key]['id']; + } + $routes = FormatUtils::formatTreeData($routes, 0); - return PermissionsResource::collection($permissions); + return PermissionsResource::collection($routes); } public function store(Request $request) diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index b1c73d6..cf52c70 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -63,6 +63,7 @@ class Kernel extends HttpKernel 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class, 'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class, + 'check.permissions' => \App\Http\Middleware\CheckPermissions::class, ]; /** diff --git a/app/Http/Middleware/CheckPermissions.php b/app/Http/Middleware/CheckPermissions.php new file mode 100644 index 0000000..b8f8ae4 --- /dev/null +++ b/app/Http/Middleware/CheckPermissions.php @@ -0,0 +1,38 @@ +user()->getPermissionsViaRoles()->toArray(); + $permissions = array_column($permissions, 'name'); + if (in_array($currentRouteName, $permissions, true)) { + return $next($request); + } + } + + $res = [ + 'httpCode' => 403, + 'errorCode' => 403403, + 'errorMessage' => '您没有使用此功能的权限', + ]; + return response($res, 403); + } +} diff --git a/app/Models/User.php b/app/Models/User.php index b6d8d5e..88194f2 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -43,4 +43,9 @@ class User extends Authenticatable { $this->attributes['password'] = Hash::make($value); } + + public function isRoot() + { + return $this->name === 'erpAdmin'; + } } diff --git a/config/filesystems.php b/config/filesystems.php index 9df9941..b2f1d2f 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -76,6 +76,10 @@ return [ 'isCName' => false, // 是否使用自定义域名,true: 则Storage.url()会使用自定义的cdn或域名生成文件url, false: 则使用外部节点生成url 'debug' => true ], + 'root' => [ + 'driver' => 'local', + 'root' => '/' + ] ], ]; diff --git a/database/migrations/2022_07_26_105818_create_logs_table.php b/database/migrations/2022_07_26_105818_create_logs_table.php index 2a30d1c..da9c3c2 100644 --- a/database/migrations/2022_07_26_105818_create_logs_table.php +++ b/database/migrations/2022_07_26_105818_create_logs_table.php @@ -24,7 +24,7 @@ class CreateLogsTable extends Migration $table->text('after_update')->nullable()->comment('更新后数据'); $table->text('message')->nullable()->comment('备注信息'); $table->bigInteger('user_id')->comment('操作人id'); - $table->index('target_type', 'target_id', 'target_field'); + $table->index(['target_type', 'target_id', 'target_field']); $table->timestamps(); }); } diff --git a/database/seeds/PermissionsTableSeeder.php b/database/seeds/PermissionsTableSeeder.php index 0df8a79..c0aa0f7 100644 --- a/database/seeds/PermissionsTableSeeder.php +++ b/database/seeds/PermissionsTableSeeder.php @@ -12,17 +12,11 @@ class PermissionsTableSeeder extends Seeder */ public function run() { - DB::table('permissions')->insert([ - ['name' => 'GOODS_MANAGE', 'guard_name' => 'api'], - ['name' => 'GOODS_LIST', 'guard_name' => 'api'], - ['name' => 'GOODS_TYPE', 'guard_name' => 'api'], - ['name' => 'GOODS_BRAND', 'guard_name' => 'api'], - ['name' => 'SHOP_MANAGE', 'guard_name' => 'api'], - ['name' => 'USER_MANAGE', 'guard_name' => 'api'], - ['name' => 'SYSTEM_MANAGE', 'guard_name' => 'api'], - ['name' => 'ROLE_MANAGE', 'guard_name' => 'api'], - ['name' => 'PERMISSION_MANAGE', 'guard_name' => 'api'], - ['name' => 'SYSTEM_LOG', 'guard_name' => 'api'], - ]); + $routes = include(resource_path('lang/zh-CN/permission.php')); + $data = []; + foreach ($routes as $key => $route) { + $data[] = ['name' => $key, 'guard_name' => 'api']; + } + DB::table('permissions')->insert($data); } } diff --git a/resources/lang/zh-CN/permission.php b/resources/lang/zh-CN/permission.php new file mode 100644 index 0000000..7493111 --- /dev/null +++ b/resources/lang/zh-CN/permission.php @@ -0,0 +1,234 @@ + [ + 'id' => 1, + 'name' => '商品管理', + 'parent_id' => 0, + ], + 'GOODS_LIST' => [ + 'id' => 2, + 'name' => '商品列表', + 'parent_id' => 1, + ], + 'goods.index' => [ + 'id' => 20, + 'name' => '商品列表', + 'parent_id' => 2, + ], + 'goods.store' => [ + 'id' => 21, + 'name' => '新增商品', + 'parent_id' => 2, + ], + 'goods_skus.index' => [ + 'id' => 22, + 'name' => '规格列表', + 'parent_id' => 2, + ], + 'goods_skus.store' => [ + 'id' => 23, + 'name' => '新增规格', + 'parent_id' => 2, + ], + 'goods_skus.show' => [ + 'id' => 24, + 'name' => '规格查看', + 'parent_id' => 2, + ], + 'goods_skus.udpate' => [ + 'id' => 25, + 'name' => '规格更新', + 'parent_id' => 2, + ], + 'goods_sku.batch_update' => [ + 'id' => 26, + 'name' => '上新/盘点', + 'parent_id' => 2, + ], + 'goods_sku.single_update' => [ + 'id' => 27, + 'name' => '字段更新', + 'parent_id' => 2, + ], + 'GOODS_TYPE' => [ + 'id' => 3, + 'name' => '商品种类', + 'parent_id' => 1, + ], + 'goods_types.index' => [ + 'id' => 30, + 'name' => '列表', + 'parent_id' => 3, + ], + 'goods_types.store' => [ + 'id' => 31, + 'name' => '新增', + 'parent_id' => 3, + ], + 'goods_types.show' => [ + 'id' => 32, + 'name' => '查看', + 'parent_id' => 3, + ], + 'goods_types.update' => [ + 'id' => 33, + 'name' => '更新', + 'parent_id' => 3, + ], + 'goods_types.destroy' => [ + 'id' => 34, + 'name' => '删除', + 'parent_id' => 3, + ], + 'GOODS_BRAND' => [ + 'id' => 4, + 'name' => '商品品牌', + 'parent_id' => 1, + ], + 'goods_brands.index' => [ + 'id' => 40, + 'name' => '列表', + 'parent_id' => 4, + ], + 'goods_brands.store' => [ + 'id' => 41, + 'name' => '新增', + 'parent_id' => 4, + ], + 'goods_brands.show' => [ + 'id' => 42, + 'name' => '查看', + 'parent_id' => 4, + ], + 'goods_brands.update' => [ + 'id' => 43, + 'name' => '更新', + 'parent_id' => 4, + ], + 'goods_brands.destroy' => [ + 'id' => 44, + 'name' => '删除', + 'parent_id' => 4, + ], + // 店铺管理 + 'SHOP_MANAGE' => [ + 'id' => 5, + 'name' => '店铺管理', + 'parent_id' => 0, + ], + 'shops.index' => [ + 'id' => 50, + 'name' => '列表', + 'parent_id' => 5, + ], + 'shops.store' => [ + 'id' => 51, + 'name' => '新增', + 'parent_id' => 5, + ], + 'shops.show' => [ + 'id' => 52, + 'name' => '查看', + 'parent_id' => 5, + ], + 'shops.update' => [ + 'id' => 53, + 'name' => '更新', + 'parent_id' => 5, + ], + 'shops.destroy' => [ + 'id' => 54, + 'name' => '删除', + 'parent_id' => 5, + ], + // 用户管理 + 'USER_MANAGE' => [ + 'id' => 6, + 'name' => '用户管理', + 'parent_id' => 0, + ], + 'user.index' => [ + 'id' => 60, + 'name' => '列表', + 'parent_id' => 6, + ], + 'user.store' => [ + 'id' => 61, + 'name' => '新增', + 'parent_id' => 6, + ], + 'user.show' => [ + 'id' => 62, + 'name' => '查看', + 'parent_id' => 6, + ], + 'user.update' => [ + 'id' => 63, + 'name' => '更新', + 'parent_id' => 6, + ], + 'user.destroy' => [ + 'id' => 64, + 'name' => '删除', + 'parent_id' => 6, + ], + // 系统管理 + 'SYSTEM_MANAGE' => [ + 'id' => 7, + 'name' => '系统管理', + 'parent_id' => 0, + ], + 'ROLE_MANAGE' => [ + 'id' => 8, + 'name' => '角色管理', + 'parent_id' => 7, + ], + 'role.index' => [ + 'id' => 80, + 'name' => '列表', + 'parent_id' => 8, + ], + 'role.store' => [ + 'id' => 81, + 'name' => '新增', + 'parent_id' => 8, + ], + 'role.show' => [ + 'id' => 82, + 'name' => '查看', + 'parent_id' => 8, + ], + 'role.update' => [ + 'id' => 83, + 'name' => '更新', + 'parent_id' => 8, + ], + 'role.permission' => [ + 'id' => 84, + 'name' => '设置权限', + 'parent_id' => 8, + ], + 'PERMISSION_MANAGE' => [ + 'id' => 9, + 'name' => '权限管理', + 'parent_id' => 7, + ], + 'permissions.index' => [ + 'id' => 90, + 'name' => '列表', + 'parent_id' => 9, + ], + // 系统日志 + 'SYSTEM_LOG' => [ + 'id' => 10, + 'name' => '系统日志', + 'parent_id' => 0, + ], + 'logs.index' => [ + 'id' => 100, + 'name' => '列表', + 'parent_id' => 10, + ], +]; diff --git a/resources/templates/goods_skus_import.xlsx b/resources/templates/goods_skus_import.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..16d6c963a0bdbbd2c24f7e0173f6c6857bfe9ae4 GIT binary patch literal 10134 zcmeHtg;yNe_I2a#E(z{Vkl-FH5D38`1a~L6ySuxG-~@NK#$6f@1PP%D1h-!&Gw;g` zGv8nEURAG>Rdx2NzW3~V_c`Y($-}_n0^k9N004jjAja!IVFLvKz`_9lH~>UwZ3$Z& zCu18Yy*F-l#*VtIuGUuM`LNLRxd3R$`~Tbii(8=l&9F@mJ7&B3frw;>T3B94X(=LU z3#m5s9zv>Xyasi{4iWvW7oCZ+Y7JsHjk48*Htne(VZ}17rnu;5E7ohxSJdxNK15YG zd>6Wt$&vCeELV%Fjg8>WB}4;*;b-a*UN$Wouv$<)P}1OY*C9XK?LJZ57cUDHk)Ua3 z{89>iwfI$NxJMIOp5Z;A!E@Ju*DS+ + +++ ++ + ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + +筛选 +重置筛选 ++ + ++ +++ + 全部商品(共800条) + ++ +++新建商品 +上新 +库存盘点 +导入商品 +表格导出 ++ ++ ++ {{ scope.row.date }} + ++ ++ ++ ++ ++ ++ + +++ + ++ + + +++ + ++ + + ++ ++ ++ ++ + +66+++ +损耗数量:++ + +备选项 +备选项 +备选项 ++ ++ ++ + ++ + +++修改 +++编辑 +++ + + +记录 +确定 ++ +i9249mqDRj@e;$*$3`lX&Cy1-$ zKSPD}Lp_vmFk3v2B)uvFp|57;i;-<4e@7>|hw$v-0S2J-H=5R~vQzzl_})v%QxphI z^&E_?9NAcZ9{)$r|6)%5<*%2=E4=DuM-2wc+=dKY%&o>^ip#r*$+S|u@%EKn!KjZa zpe9-Eq$9 ZAHRFWq@yiWCE=DTDK<^-!cF%nJ@X)wM}nxEEyg65jRWhK;{ zxXQPR;Oa)++=GOP44;MM;(aucP`;Ok(`k4^js~Vnm7YUZ6lYh&sw!rD=G6w-4*ZmE zdPY`Vr;-_+ICq{bikU;NDY>vOIVYqCX>!kewCcFNk7T*^@gnt>4IK~rN061QL1wIf zk_6QU+G7zykUDq(00Yu8u2yU=whopCwzif(=dp5CkWB$Qrk9@i1JqTPzh5kD(wk;X z>%vvl*{|}2Kqxv5sL|zOS=F<37gP%K^c0&``tR>z_=KN160%k~yO{_oQxLI<2eMfi zO;UbAVw$IDY0XL(GLn%B4>W4arEo9C) XHw}gPf7H z)9VH^w_B{H%uof@bdCvmUyV =ivy9(!>@8RydrYy@hXU&;n+%VJmA3 z9Pm+CujF(Ab#t-85o93z0Xl}otlbSmnQWRpoEdJxYV3PD%_{`v2gKlSYz6wUY86R< z_zT&(alecJ_!Oq(shbxq@C+mC)C)<#*f^|@`GE}Sfh8y^9Yuq1p>l6_N(_ixv!cH) z4-u1Y3lgyVEn_^Bk`lvxaw_gOdp_IASVruT>3~^duki5ZrIM?Qs5mBiBsKcb>+vwT zC^;hvVuT0*BrI0XiGBA7q$HC5k$#f>ILEAqfJ>Qj!$$J8U=_y)Vdq?0f3 qA7_xUDf#%+R-&TU$q5p9((ip9kyCket2vQY{iW`gWn=rnho6 z?fOm~@x`UssBF=+7dN+4s384n+E;?5`lnV1c=FL)Zx8Q`EpBYgysG%$tu`JJtpW{K z&t?~eswp=?m}weiXID-w6 6)R6gbKtjRGMB2 zWwL)-Qz{jpRw}Ddo-OT|(#4Trnr~3#EO|a@8mj64m9inGpE_c &0Pr&Q&;EB@* zZ#h+MB?1`t#o9b%uZcRUMnm`Z4#RW71&+bBzA*k(Gwdk-7U7m&golEOIZBM>S0N^8 z*m*W^VZ6uP&BbL{apWbm pd73BLMx(4Mwgxw{>84qj8iH-75^(zMAa2*4Pmg1TBk988p z7F~^bc{Ui^U^npCpz{Sc`W6h%SvONjI5w<1jult{&UWl{3 d+iI8Lk(cA!2d$SZwm)%n5h$n5gCJJujmfZ!{s5_)( z@=r^-g*=0u$U}yt$$S{%9e486T2;ZDPU1H}hEC84^T-dd$@cKz+&ZME|LHRKcHHm{ zFaSU&5&%F5dE?J<)6vY>*vXOY*NNlj0GgSg5VOpV84OOkCSzU?!+F;zFR7ubmFG}) z?dF_`RC6qCA%IeH-~(P1)d)jbrmw*PfuDi _Wx5_gYnv73h%>O{nXvaB!-m?XE*dfmdzaN`efW4vQxvFm-y(=g) zrm_z)RO=Jdo|=$qPE%>nD!#s=(Fd=$C3JlS=ZeC15yH{b2wGaY*l)szI8a~Lkz?QG z#A!;>lH}R0vq8;&4DRHg79Byr>sY!Yhy}5}E95i5moKo2X4`<9ryc;BU@?}9LpMl{ zxHeQ5UgqWJOlDe%t51D6^ou9<)EEiPmqZoTxVz!Xh>Wrj43>?$(`;|jj$lf_zp3R} z?m!!e|NQW)?|&T<6SZvu*fFIV{o4Sf2=uZ>v086Uh=!yTMAF}I6n#6gl!JBrfWhFi zmmRm`K{$D|cp 86HG|`4J+I!X6%wqkP=!wehYpUyC^7~gSNybdc^}a(5(xcgi zS_wzBuY+5%ai>7^@L%V)4)~T6YZ86+qj=^(S8<4MU6wEI%qiDCbCWsc5D#A?#Yda{ zfYFoTT){7+W#u+!p$I*G`0CbVQue%9w{3&B2)UM&+9!UD*^R^EV4qua!Yw$irOS#e z8#D4oKTG#V$0|izMC;2kV)}Zc2=_knu&OQI3rTO~$wDK#d*sV!{)8&$+kRC_{VUi4 z;#}c9=7NmUZ;vlXD=N%=I$FcMMq%O>{+;UzBEHOl5PjrJ{4?JF#dRk$V{2o!U&miG zKh&JC1@Yi^U@Sh6?;UA1&@7=J;5Jy%Stc}?t)L4{^H|s9NlFwZ5KH;#x)8DFk~kAp zgV1|@p+V*;cf2eOM=^_3G}=ZldGF$&S0@P(sSiA2$ksisFC`Xi1r S6Y{hBWue!wVo z0Cbt(iF^duyLP>V$aT!eFv5{HRs^O>wAsf8MTGPPrWE9wPq@0TP&3B!*X2qNZ@bO9 zEwL+HID_n~#>uysJo#s4ys< I7 asboiRc`06*4>TLe93A09-NQ=<~eQs5yI zinU NX(K}Y5SKeMR?tvFE`9eYoroe!x%p(L?lKl=H z#G`=ngG3;7+^gg?niPc8H1Ox}aZEKvm{QwNH}Prtq&xp&1Tw9eZwH=m7B()o!u)Gv zp=Z|oZMkc$b`N4>M+L_21ihA@giO8S4`0Q9y9d*FEVO!_iR)TC8**+IRxdj<+BNWc zK`(^G6du#0Rppo(S1e)nh6JfTW5sF>pF;;<8wQ4VBKDI#Cv68crEu63H2xWP{aNN| z&snAb%7A`FRr(w)q26(YGwR58s=}#|MFs6eL9?qJHPD%Dv99-Ce0#52^Qe{QXim|& z@_f(|diva2#w;t1niwB@>^+sy=6mYdp~^rhP)|P1YL!a;_!cd$sC5FK1}9(j HLMNS)vP@#MOrDpNAuG<* zOQ>M4oOP`~too%zw|F*}PNK$}M2>iDK4hpKHx6Z4R7ID;>>$%+r5dZtZ4s7*{|NQ` z+AfVb*SSgOfRaB1rZ#Nogy3E`(Kyb2N?LFnrc#nlJs=P z0XZTWOEb?9aPS3sybUeUgo!KVk2*^h&gm-_de2I{`47O`)$Zwd7K&B6?>| &LNEMq6yzDa>Yp RxLO~|c)i1VmO}(pIHR>Jw zHL93YH_Kw4Twfsac*AZ@g(R%g;OP`$ckmb?;(J{!*|U-yhYRBO6Ju3o8o%H_!eQIH zRu&3ne9J`m<~A6tswLK_ybmu{z=LS 3*|O=)=3_4eyB@cs4{CT13$zSp8noriwW>K;0icjrQBT|u?_eu#3d$f2}Y znULoJzbW#e3rQRqx>iy(z7(Fw59&L$*6AN#&nnjs8{oY!%xfb3;&xAz`=EQuT)#b_ z{F^|HsYi{+h6q$30sw&a$E4-x <7d*fCcL_MRXf;dxm#H&8Hyenv!$ zg@%iVUY*7^#@Uq4HIr7H(&ZJBRbNF|{lO*W9*IuFrxu%U{y9nkeVEsF%@g;@f`0+p z9G(j2z AY +rdZ?=2^_h*SH9@?pI<#q{KyQ?J#v9X6g^I aId z?<05u1NsMTu#Ll+qEHLb6D^tJ5trAR9?o~}Z!kQ{$o;=tTcVZc$vV3zu*a?u>&h3< z)Ve&Yp_|Z0CuU^IXQD4lUVV3&nKPgZcTc$6zM(CFEtW)BYK;7$L|e~VKJ>M?SfkVC z-V#V&p}`yT{Ap8EFSQnZmITZ 1vP9Fp(a l{Syo#*wMDNg+NmpcIR#G zxswezIjRqEnvRZVc7&hru35&Gw7O#VY}yS;jEO@D!3zWpPIqx BOkf9)3PTVZ$W9G z@@a1DZ)!B(=aqu4yIG;@9uh$Envg}v2BS(F9Y#tAOv*}#q{al-*0Q5{tn?B@n@*hF zIZtYzY|gTa@g=nCeB+#L6pw#*lS00tOS^I>{rn2TjekaWM%O()myjSI4MHB=KgnaJ z?_g}C;^bg%WBQ9j<*E~}aKs4PdG{aK$2D7L;G-B?NAki3V8RfhcE_A^Gn`BpvKZpD z
wovS6 z`7Fh@^Rpg_r=za(E31fRXB}lZjSZ1kUE-39wV$TZptPft1hJDSIc*TMDy>)TUY-se zwFtIz?Gn9T4`1~|iZO`|c+w1Ng2}GWF3C7v5j2S#$ga|PQzd2pDKHPEPOiqw;qE@6 zS#D|t_nY3AqcXo(GA$Q&w1J}$aOciI-mMi^db)m{v&D4W9_dgLl_SULD=fxT#5A!Y zw}k7E;Ik@BV8%+-LDV%_whwMr_LN=2#npTqR_`3+x YJz`EZ_Z&%SsZ^xSzB*O z8N+qB-3{NX``{?e`Z8HS0<5sc?%(a?-&@fUxcPY)ymL`GZdFEO_+pUx!%%YfkxY zh=+(nyoKryPx+ZN`ZEvkM;7UKHsDtdDKMrxyoViE>H_9o!qp>TJ_uDpg_p8Pbr;6q zdKn&+5_^Gr=TS>)+_ke~H?hN$aU=MV!~{K#dA0>QXxos$toqnvnWa;#=J~-2E)t7i zto{sZM>>q6qFmTutOg!RO^`D69bvC`-%?F9(#KfgFH5pvZtTNX5hRo4r54sFdI)uF ziuGXTZ7=lzexcWz_lMD5WP&yYo#Qem6M?dPvG0WQW%!1qzMc3Qh<$ZA&$jeJhb^`q z9XUOR Ht>t(vx87t+c`oXlH!bv oU(gj(Pi#}w; zpNfgz<@JqI`r*Mgs8Aa2`d{Lp_m3x!GBtAcuJqTrVS9x1<_)>&lYdE7fmXiVK)xUh zWkT=6yE*1TuMWo1Ob$BbPbg+lZCzjq&*v#4_n9ox`3#~ 6UiPUI2>3{6l%P%n0f zqzjnb6V3EWX>k_y4qi{a%6%};Ayn|wvUE<7vGfMxN=>mb4fd0H*|fCu6DLWW<27XF zE)Km#>0Z6;x(mg<;S_#u{uC(|@SmUP0HWQ+DOlIx6oEDpnU5}4*~r0{q?Y2;4)?)n zsp;4&r$Y)_1v>L^4~1G3+DDB1PUF;~9USP0U7=-C|8d$-#uxUJ)CMHh{bzS?`5joR zLAu)z67*w1a-~MLhDr{$c8+X@whqRBmcIX&B8Bk4Gaix(VJ8d%!>#9ScPPxX@JWFD zfR&_(inw6$6I&)8bJ={*TDP`Wf*%I;o?&W(cE!uKQ6I&Q%+my;w&b7-)aC6WIV>dc zZNIIep*c#a#@a9u@$8zHNNS15uj`-!29~}n_b>tF(H2_DMM0#IyD~tfw?$^=)>0fi zo=EX&U3`f+yG6;PEd_5k!oN#507!#2G3BdYvX9uI{V0nLb(ZNCFgh!YfG2+*3{6dM z$&Q40|6OZx`qnK^* o=ztLd#ZARO(O0}|gc)T1s-u~bZ>bwf7BI;+A z&vTivG9A!HllgC!ZA8}Ah4u8XS2E^Fm{V(18V}vjw>)QfpN2;-;+oZv3lfAiz?}ni zJ?;52a+#5byD&n$pQpxQ(U@`xyOpfpzweA*MBirZ?(CyK=~WS-<>sJGM0M{IB9}kz zZXD`>xZFRTkze-*RyyPfCPe6B{?!@v?d<;Nix4OLbIXkHhUk4rofGaFJ@_ap(}q4+ zR86^%$$haJAnUGf%#Y6~@83r}oNb))1pW}sc^Tx?^|YWas#p=EVoU9_wIKa^%M-L% z9+VpC0+*raknA_p!DXXTeRgoLjWdGHsLuHH39c1FSk}mAs+v$?QArpEDwGstHL75u zUD<`n5-y6RxYt*U^o3kDO;wBqo6}!!;7Lzr1VuhqOWDyR(&^g{!4GOifVo-Pk1nUj zEC>)a!Xq%tr;yF%uIBdk5~|p5+UDNDkwy6LCFg<*y0b>%$UYc+ObX&78j)Lq^%o)N z<1Vo=M=>^t&+penA@&-Lzf!amFkY&Vo7}`LSDm5{37o4(lO+SivIBj5yoGM>zCY~R zcFU4kcs;jyGWew+^BfJAl*bt!1_3D~kSPFvy3rz!vI9!+3Csm5%#m+xIh38N <`#=sBOPx1RdsbR_ScX@+u{F{oUUVzd@Eq8d7gwNXW zTR`imWIBoyv{xaS gsw~qlH2hYC&itv8{{0^lbn?4R5ew%I){bBkzkan zSW^B*KqY {$Z1pxk`3LcyPedPYD ec{s&i%>Nw6mE_?dJ_rDyLUvk+8*5Sjy!$`8Sa~J@ literal 0 HcmV?d00001 diff --git a/routes/api.php b/routes/api.php index 5c5adc8..4a047f0 100644 --- a/routes/api.php +++ b/routes/api.php @@ -16,7 +16,7 @@ use App\Http\Controllers\Goods\GoodsSkusController; | is assigned the "api" middleware group. Enjoy building your API! | */ -Route::middleware('auth:api')->group(function () { +Route::middleware(['auth:api', 'check.permissions'])->group(function () { // 用户 Route::resource('users', 'User\UsersController', ['only' => ['index', 'store', 'show', 'update', 'destroy']]); // 商品种类 @@ -33,17 +33,20 @@ Route::middleware('auth:api')->group(function () { Route::patch('single/goods_skus/{id}', [GoodsSkusController::class, 'updateField'])->name('goods_sku.single_update'); // 店铺 Route::resource('shops', 'Shop\ShopsController', ['only' => ['index', 'store', 'show', 'update', 'destroy']]); - Route::get('shop_platforms', [ShopsController::class, 'getPlatList'])->name('plat.list'); // 角色 Route::resource('roles', 'Role\RolesController', ['only' => ['index', 'store', 'show', 'update']]); Route::post('roles/{id}/permissions', [RolesController::class, 'addPermissions'])->name('role.permission'); // 权限 - Route::resource('permissions', 'Permission\PermissionsController', ['only' => ['index', 'store', 'show', 'update', 'destroy']]); - // 菜单 - Route::resource('menus', 'Menu\MenusController', ['only' => ['index', + Route::resource('permissions', 'Permission\PermissionsController', ['only' => ['index', // 'store', 'show', 'update', 'destroy' ]]); Route::post('upload', [UploadController::class, 'store'])->name('upload.file'); }); Route::post('/auth/login', [LoginController::class, 'login'])->name('auth.login'); + +// 菜单 +Route::resource('menus', 'Menu\MenusController', ['only' => ['index', +// 'store', 'show', 'update', 'destroy' +]])->middleware('auth:api'); +Route::get('shop_platforms', [ShopsController::class, 'getPlatList'])->name('plat.list')->middleware('auth:api'); diff --git a/routes/web.php b/routes/web.php index 0af6dd8..b342af8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -29,4 +29,4 @@ Route::get('/register', function () { return view('welcome'); })->name('register'); -Route::get('goods_skus/export', [GoodsSkusController::class, 'export'])->name('goods_skus.export'); +Route::get('goods_skus/export', [GoodsSkusController::class, 'export'])->name('goods_skus.export')->middleware('check.permissions'); From 7ada42695ac683ba75bfa944e2a79ee7a03dc42e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Thu, 4 Aug 2022 18:20:59 +0800 Subject: [PATCH 30/68] =?UTF-8?q?feat:=20#20220804=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=AF=BC=E5=85=A5=E6=A8=A1=E6=9D=BF=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Goods/GoodsController.php | 6 ++++++ routes/web.php | 3 +++ 2 files changed, 9 insertions(+) diff --git a/app/Http/Controllers/Goods/GoodsController.php b/app/Http/Controllers/Goods/GoodsController.php index 234752e..1d25ed8 100644 --- a/app/Http/Controllers/Goods/GoodsController.php +++ b/app/Http/Controllers/Goods/GoodsController.php @@ -13,6 +13,7 @@ use Illuminate\Support\Facades\Validator; use App\Models\Goods; use App\Http\Requests\GoodsRequest; use App\Models\DailyStockRecord; +use Illuminate\Support\Facades\Storage; class GoodsController extends Controller { @@ -85,4 +86,9 @@ class GoodsController extends Controller return response($this->res, $this->res['httpCode']); } + + public function download() + { + return Storage::download(resource_path('templates/goods_skus_import.xlsx')); + } } diff --git a/routes/web.php b/routes/web.php index b342af8..20cc097 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,6 +1,7 @@ name('register'); Route::get('goods_skus/export', [GoodsSkusController::class, 'export'])->name('goods_skus.export')->middleware('check.permissions'); + +Route::get('goods/import/template', [GoodsController::class, 'download'])->name('download.goods_import.template'); From d586d31228caddb451b977c6a5000a5f2b60d5fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Fri, 5 Aug 2022 10:36:55 +0800 Subject: [PATCH 31/68] =?UTF-8?q?feat:=20#20220805=20=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E6=9D=83=E9=99=90=E8=BF=94=E5=9B=9E=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Role/RolesController.php | 10 +++++++++- app/Http/Middleware/CheckPermissions.php | 2 +- app/Models/Shop.php | 2 ++ resources/lang/zh-CN/permission.php | 20 +++++++++---------- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/Role/RolesController.php b/app/Http/Controllers/Role/RolesController.php index 93ecc3d..2f861c2 100644 --- a/app/Http/Controllers/Role/RolesController.php +++ b/app/Http/Controllers/Role/RolesController.php @@ -24,7 +24,15 @@ class RolesController extends Controller public function index() { - $roles = Role::query()->get(); + $roles = Role::query()->with('permissions')->get()->toArray(); + $routes = include(resource_path('lang/zh-CN/permission.php')); + foreach ($roles as &$role) { + $permissions = []; + foreach ($role['permissions'] as $item) { + $permissions[] = $routes[$item['name']]['name']; + } + $role['permissions'] = $permissions; + } return RolesResource::collection($roles); } diff --git a/app/Http/Middleware/CheckPermissions.php b/app/Http/Middleware/CheckPermissions.php index b8f8ae4..0973abd 100644 --- a/app/Http/Middleware/CheckPermissions.php +++ b/app/Http/Middleware/CheckPermissions.php @@ -31,7 +31,7 @@ class CheckPermissions $res = [ 'httpCode' => 403, 'errorCode' => 403403, - 'errorMessage' => '您没有使用此功能的权限', + 'errorMessage' => '您没有使用此功能的权限' . $currentRouteName, ]; return response($res, 403); } diff --git a/app/Models/Shop.php b/app/Models/Shop.php index bd806c3..cee46e5 100644 --- a/app/Models/Shop.php +++ b/app/Models/Shop.php @@ -16,6 +16,8 @@ class Shop extends Model 'pop_auth_token_create_response', ]; + protected $guarded = []; + public function getStatusAttribute($value) { $map = [ diff --git a/resources/lang/zh-CN/permission.php b/resources/lang/zh-CN/permission.php index 7493111..7ac3875 100644 --- a/resources/lang/zh-CN/permission.php +++ b/resources/lang/zh-CN/permission.php @@ -149,27 +149,27 @@ return [ 'name' => '用户管理', 'parent_id' => 0, ], - 'user.index' => [ + 'users.index' => [ 'id' => 60, 'name' => '列表', 'parent_id' => 6, ], - 'user.store' => [ + 'users.store' => [ 'id' => 61, 'name' => '新增', 'parent_id' => 6, ], - 'user.show' => [ + 'users.show' => [ 'id' => 62, 'name' => '查看', 'parent_id' => 6, ], - 'user.update' => [ + 'users.update' => [ 'id' => 63, 'name' => '更新', 'parent_id' => 6, ], - 'user.destroy' => [ + 'users.destroy' => [ 'id' => 64, 'name' => '删除', 'parent_id' => 6, @@ -185,27 +185,27 @@ return [ 'name' => '角色管理', 'parent_id' => 7, ], - 'role.index' => [ + 'roles.index' => [ 'id' => 80, 'name' => '列表', 'parent_id' => 8, ], - 'role.store' => [ + 'roles.store' => [ 'id' => 81, 'name' => '新增', 'parent_id' => 8, ], - 'role.show' => [ + 'roles.show' => [ 'id' => 82, 'name' => '查看', 'parent_id' => 8, ], - 'role.update' => [ + 'roles.update' => [ 'id' => 83, 'name' => '更新', 'parent_id' => 8, ], - 'role.permission' => [ + 'roles.permission' => [ 'id' => 84, 'name' => '设置权限', 'parent_id' => 8, From b68d9626c0138ac40219d2fab6e5bcfae97c6d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Sat, 6 Aug 2022 15:25:13 +0800 Subject: [PATCH 32/68] =?UTF-8?q?feat:=20#20220806=20=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E6=8E=88=E6=9D=83,=E5=AF=B9=E6=8E=A5=E5=95=86=E5=9F=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Auth/LoginController.php | 4 +- app/Http/Controllers/Shop/ShopsController.php | 50 +++++++ app/Models/BusinessGoodsSku.php | 13 ++ app/Models/BusinessOrder.php | 13 ++ app/Models/BusinessOrderItem.php | 13 ++ app/Services/Business/BusinessClient.php | 88 +++++++++++ app/Services/Business/BusinessFactory.php | 25 ++++ app/Services/Business/KuaiTuanTuan/Goods.php | 63 ++++++++ .../Business/KuaiTuanTuan/KuaiTuanTuan.php | 137 ++++++++++++++++++ app/Services/Business/KuaiTuanTuan/Order.php | 70 +++++++++ app/Services/Business/MiaoXuan/Goods.php | 30 ++++ app/Services/Business/MiaoXuan/MiaoXuan.php | 49 +++++++ app/Services/Business/MiaoXuan/Order.php | 26 ++++ database/factories/UserFactory.php | 2 +- ...30834_create_business_goods_skus_table.php | 56 +++++++ ...05_093629_create_business_orders_table.php | 71 +++++++++ ...3658_create_business_order_items_table.php | 54 +++++++ routes/api.php | 5 +- routes/web.php | 3 + 19 files changed, 768 insertions(+), 4 deletions(-) create mode 100644 app/Models/BusinessGoodsSku.php create mode 100644 app/Models/BusinessOrder.php create mode 100644 app/Models/BusinessOrderItem.php create mode 100644 app/Services/Business/BusinessClient.php create mode 100644 app/Services/Business/BusinessFactory.php create mode 100644 app/Services/Business/KuaiTuanTuan/Goods.php create mode 100644 app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php create mode 100644 app/Services/Business/KuaiTuanTuan/Order.php create mode 100644 app/Services/Business/MiaoXuan/Goods.php create mode 100644 app/Services/Business/MiaoXuan/MiaoXuan.php create mode 100644 app/Services/Business/MiaoXuan/Order.php create mode 100644 database/migrations/2022_08_05_030834_create_business_goods_skus_table.php create mode 100644 database/migrations/2022_08_05_093629_create_business_orders_table.php create mode 100644 database/migrations/2022_08_05_093658_create_business_order_items_table.php diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index df2f808..ea52a85 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -52,8 +52,8 @@ class LoginController extends Controller if (Auth::attempt($credentials)) { // 通过认证.. return response()->json(['token' => $request->user()->api_token]); - }else { - return response()->json(['error' => 'auth login fail']); } + + return response()->json(['error' => 'auth login fail']); } } diff --git a/app/Http/Controllers/Shop/ShopsController.php b/app/Http/Controllers/Shop/ShopsController.php index f4fd384..5ec522d 100644 --- a/app/Http/Controllers/Shop/ShopsController.php +++ b/app/Http/Controllers/Shop/ShopsController.php @@ -7,12 +7,20 @@ use App\Models\Shop; use App\Http\Resources\ShopsResource; use Illuminate\Http\Request; use Illuminate\Support\Facades\Validator; +use App\Services\Business\BusinessFactory; +use Illuminate\Validation\Rule; class ShopsController extends Controller { public function index() { $shops = Shop::query()->paginate(); + foreach ($shops as $shop) { + $shop->authUrl = ''; + if ('妙选' !== $shop->plat_id && '未授权' === $shop->status) { + $shop->authUrl = BusinessFactory::init()->make($shop->plat_id)->getAuthUrl($shop->id, $shop->getOriginal('plat_id')); + } + } return ShopsResource::collection($shops); } @@ -42,4 +50,46 @@ class ShopsController extends Controller return response($this->res, $this->res['httpCode']); } + + public function authBind(Request $request) + { + [$shopId, $platId] = explode('_', $request->get('state')); + $shop = new Shop(); + $platList = $shop->getPlatList(); + $shop = $shop->find($shopId); + if ($platList[$platId] === $shop->plat_id) { + BusinessFactory::init()->make($shop->plat_id)->authCallback($request->get('code'), $shop->id); + } else { + $this->res = [ + 'httpCode' => 403, + 'errorCode' => 403400, + 'errorMessage' => '信息不匹配', + ]; + } + + return response($this->res, $this->res['httpCode']); + } + + public function business(Request $request) + { + $validator = Validator::make($request->all(), [ + 'type' => ['required', 'string', Rule::in(['goods', 'orders'])], + 'erp_shop_id' => ['required', 'integer', 'exists:shops,id'], + ]); + if ($validator->fails()) { + $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); + + return response($this->res, $this->res['httpCode']); + } + $shop = new Shop(); + $shop = $shop->find($request->get('erp_shop_id')); + $business = BusinessFactory::init()->make($shop->plat_id); + $business->setShop($shop); + if ('goods' === $request->get('type')) { + $business->downloadGoodsAndBind($request->get('data')); + } + if ('orders' === $request->get('type')) { + $business->downloadOrders(); + } + } } diff --git a/app/Models/BusinessGoodsSku.php b/app/Models/BusinessGoodsSku.php new file mode 100644 index 0000000..468332d --- /dev/null +++ b/app/Models/BusinessGoodsSku.php @@ -0,0 +1,13 @@ +setCode($code); + $this->setShop($shopId); + $this->auth(); + + return $this; + } + + public function setShopWithId($shopId) + { + $this->shop = Shop::query()->find($shopId); + + return $this; + } + + public function setShop(Shop $shop) + { + $this->shop = $shop; + + return $this; + } + + public function getShop() + { + return $this->shop; + } + + protected function setCode($code) + { + $this->code = $code; + + return $this; + } + + protected function getCode() + { + return $this->code; + } + + public function formDataPostRequest($url, $params) + { + $headers = [ + 'headers' => ['Content-type' => 'multipart/form-data;charset=UTF-8'], + 'form_params' => $params + ]; + $res = (new Client())->makeCurlRequest('POST', $url, $headers); + $res = json_decode($res->getBody()->getContents(), true); + if (isset($res['error_response'])) { + $log = new Log(); + $log->module = 'plat'; + $log->action = 'POST'; + $log->target_type = 'kuaituantuan'; + $log->target_id = 0; + $log->target_field = '更新库存'; + $log->user_id = 1; + $log->message = json_encode($res, 256); + $log->save(); + + throw new \Exception($res['error_response']['error_msg'], $res['error_response']['error_code']); + } + + return $res; + } +} diff --git a/app/Services/Business/BusinessFactory.php b/app/Services/Business/BusinessFactory.php new file mode 100644 index 0000000..b34277c --- /dev/null +++ b/app/Services/Business/BusinessFactory.php @@ -0,0 +1,25 @@ +platList['快团团'] = KuaiTuanTuan::class; + } + + public function make($platName) + { + return new $this->platList[$platName]; + } + + public static function init() + { + return new self(); + } +} diff --git a/app/Services/Business/KuaiTuanTuan/Goods.php b/app/Services/Business/KuaiTuanTuan/Goods.php new file mode 100644 index 0000000..7f4e540 --- /dev/null +++ b/app/Services/Business/KuaiTuanTuan/Goods.php @@ -0,0 +1,63 @@ + $activityNo, // 非必填,团号(团号和创建时间只能传一个) + 'page' => $page, + 'size' => $size, +// 'update_time_end' => '', // 非必填,结束最后更新时间(毫秒级时间戳) +// 'update_time_start' => '', // 非必填,起始最后更新时间(毫秒级时间戳) +// 'create_time_end' => '', // 非必填,开始时间结束(毫秒级时间戳) +// 'create_time_start' => '' // 非必填, 开始时间起始(毫秒级时间戳) + ]; + + return [$type, $appendParams]; + } + + public static function bindGoods(array $goodsList, $shopId) + { + foreach ($goodsList as $businessGood) { + $skuList = $businessGood['sku_list']; + unset($businessGood['sku_list']); + foreach ($skuList as $sku) { + $sku['spec_list'] = json_encode($sku['spec_list'], 256); + $data = array_merge($businessGood, $sku); + BusinessGoodsSku::updateOrCreate( + ['shop_id' => $shopId, 'activity_no' => $businessGood['activity_no'], 'goods_id' => $businessGood['goods_id'], 'sku_id' => $sku['sku_id']], + $data + ); + } + } + } + + public function downloadSingle($goodsId) + { + $type = 'pdd.ktt.goods.query.single'; + $appendParams = [ + 'goods_id' => $goodsId + ]; + } + + public static function incrQuantity($goodsId, $quantity, $skuId, $modifyType = 2) + { + $type = 'pdd.ktt.goods.incr.quantity'; + $appendParams = [ + 'goods_id' => $goodsId, + 'quantity_delta' => $quantity, + 'sku_id' => $skuId, + // 非必填 + 'modify_quantity_type' => $modifyType, // 修改库存的类型,不传或1代表增量修改,2代表全量修改 + ]; + + return [$type, $appendParams]; + } +} + diff --git a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php new file mode 100644 index 0000000..60dd313 --- /dev/null +++ b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php @@ -0,0 +1,137 @@ + '', + 'client_id' => '', + 'access_token' => '', // 非必填,通过code获取的access_token + 'timestamp' => '', + 'data_type' => '', // 非必填,响应格式,即返回数据的格式,JSON或者XML(二选一),默认JSON,注意是大写 + 'version' => '', // 非必填, API协议版本号,默认为V1,可不填 + 'sign' => '' + ]; + + public function __construct() + { + } + + public function getAuthUrl($shopId, $platId) + { + $state = $shopId . '_' . $platId; + + return "https://oauth.pinduoduo.com/authorize/ktt?client_id={$this->clientId}&redirect_uri={$this->redirectUri}&state={$state}"; + } + + public function auth() + { + $accessToken = $this->getAccessTokenWithCode(); + $accessToken['pop_auth_token_create_response'] = json_encode($accessToken, 256); + $this->shop->update($accessToken); + + return $this->shop; + } + + public function getAccessTokenWithCode() + { + $type = 'pdd.pop.auth.token.create'; + $res = $this->request($type, ['code' => $this->code]); + + return $res['pop_auth_token_create_response']; + } + + public function getAccessToken() + { + return ''; + } + + public function getSign($params) + { + $params = ksort($params); + $str = ''; + foreach ($params as $key => $val) { + $str .= $key . $val; + } + $str = $this->clientSecret . $str . $this->clientSecret; + + return strtoupper(md5($str)); + } + + public function request($type, $appendParams = [], $url = 'http://gw-api.pinduoduo.com/api/router') + { + $publicParams = [ + 'type' => $type, + 'client_id' => $this->clientId, + 'timestamp' => time() + ]; + if ('pdd.pop.auth.token.create' !== $type) { + $publicParams['access_token'] = $this->getAccessToken(); + } + $publicParams = array_merge($publicParams, $appendParams); + $publicParams['sign'] = $this->getSign($publicParams); + + return $this->formDataPostRequest($url, $publicParams); + } + + public function downloadGoodsAndBind($page = 1) + { + [$type, $appendParams] = Goods::downloadGoods($this->shop->owner_name, $page); + $res = $this->formDataPostRequest($type, $appendParams); + $goods = $res['ktt_goods_query_list_response']['goods_list']; + Goods::bindGoods($goods, $this->shop->id); + $pageNum = ceil($res['total'] / $appendParams['size']); + if ($pageNum > $page && 10 >= $page) { + $this->downloadGoodsAndBind($page + 1); + } + } + + public function incrQuantity($skuId) + { + $goodsSku = GoodsSku::query()->find($skuId); + $business = BusinessGoodsSku::query()->where('shop_id', $this->shop->id)->where('self_sku_id', $skuId)->first(['goods_id', 'sku_id']); + [$type, $appendParams] = Goods::incrQuantity($business->goodsId, $goodsSku->stock, $business->sku_id); + $this->formDataPostRequest($type, $appendParams); + $log = new Log(); + $log->module = 'plat'; + $log->action = 'POST'; + $log->target_type = 'kuaituantuan'; + $log->target_id = 0; + $log->target_field = $type; + $log->user_id = 1; + $log->message = 'success'; + $log->save(); + } + + public function downloadOrders($beginTime, $endTime, $activityNo, $downloadType = 'default') + { + if ('increment' === $downloadType) { + [$type, $appendParams] = Order::downloadIncrementOrders($beginTime, $endTime, $activityNo); + } else { + [$type, $appendParams] = Order::downloadOrders($beginTime, $endTime, $activityNo); + } + $res = $this->formDataPostRequest($type, $appendParams); + + + return $res['ktt_order_list_response']['order_list']; + } + + public function bindGoods($goods) + { + // TODO: Implement bindGoods() method. + } +} diff --git a/app/Services/Business/KuaiTuanTuan/Order.php b/app/Services/Business/KuaiTuanTuan/Order.php new file mode 100644 index 0000000..fed5f51 --- /dev/null +++ b/app/Services/Business/KuaiTuanTuan/Order.php @@ -0,0 +1,70 @@ + $beginTime, // 成交启始时间, 必填,毫秒时间戳 + 'confirm_at_end' => $endTime, // 成交结束时间,必填, 毫秒时间戳,成交结束时间 - 成交启始时间 <= 24h + 'page_number' => 1, // 页码, 必填 + 'page_size' => 100, // 数量, 必填, 1~100 + // 非必填 + 'activity_no' => $activityNo, // 团号 + 'after_sales_status' => 0, // 售后状态, 可选 0-未发起售后 1-退款中 2-退款成功 3-待处理 4-拒绝退款 6-待(顾客)退货 7-待(团长)确认退货 8-(顾客)撤销 9-(系统)关闭 + 'cancel_status' => 0, // 取消状态, 可选 0-未取消 1-已取消 +// 'shipping_status' => '', // 发货状态 0-未发货 1-已发货 2-部分发货 3-已收货 +// 'verification_status' => '', // 核销状态, 可选 0-未核销 1-已核销 2-部分核销 + ]; + + return [$type, $appendParams]; + } + + /** + * 快团团增量查订单 + */ + public static function downloadIncrementOrders($beginTime, $endTime, $activityNo) + { + $type = 'pdd.ktt.increment.order.query'; + $appendParams = [ + 'start_updated_at' => $beginTime, // 更新起始时间 + 'end_updated_at' => $endTime, // 更新结束时间 + 'page_number' => 1, // 页码 + 'page_size' => 100, // 数量 + // 非必填 + 'activity_no' => $activityNo, // 团号 + 'after_sales_status' => 0, // 售后状态, 可选 0-未发起售后 1-退款中 2-退款成功 3-待处理 4-拒绝退款 6-待(顾客)退货 7-待(团长)确认退货 8-(顾客)撤销 9-(系统)关闭 + 'cancel_status' => 0, // 取消状态, 可选 0-未取消 1-已取消 +// 'shipping_status' => '', // 发货状态 0-未发货 1-已发货 2-部分发货 3-已收货 +// 'verification_status' => '', // 核销状态, 可选 0-未核销 1-已核销 2-部分核销 + ]; + + return [$type, $appendParams]; + } + + // 下载订单事件之后去统计 然后更新库存 + public static function saveOrders(array $orders, $shopId) + { + foreach ($orders as $order) { + $orderRecord = BusinessOrder::updateOrCreate( + ['shop_id' => $shopId, 'order_sn' => $order['order_sn']], + $order + ); + foreach ($order['sub_order_list'] as $item) { + $orderRecord = BusinessOrder::updateOrCreate( + ['shop_id' => $shopId, 'business_order_id' => $orderRecord->id, 'goods_id' => $item['goods_id'], 'sku_id' => $item['sku_id']], + $item + ); + } + } + } +} + diff --git a/app/Services/Business/MiaoXuan/Goods.php b/app/Services/Business/MiaoXuan/Goods.php new file mode 100644 index 0000000..06ceddf --- /dev/null +++ b/app/Services/Business/MiaoXuan/Goods.php @@ -0,0 +1,30 @@ + $shopId, 'goods_id' => $item['goods_id'], 'sku_id' => $item['sku_id']], + $item + ); + } + } + + public static function incrQuantity($shopId, $quantity, $businessGoods) + { + return [ + 'stock' => $quantity, + 'business_sku_id' => $businessGoods['sku_id'], + 'business_goods_id' => $businessGoods['goods_id'], + 'erp_shop_id' => $shopId, + 'erp_sku_id' => $businessGoods['external_sku_id'] + ]; + } +} + diff --git a/app/Services/Business/MiaoXuan/MiaoXuan.php b/app/Services/Business/MiaoXuan/MiaoXuan.php new file mode 100644 index 0000000..041d2de --- /dev/null +++ b/app/Services/Business/MiaoXuan/MiaoXuan.php @@ -0,0 +1,49 @@ +find($skuId); + $business = BusinessGoodsSku::query()->where('shop_id', $this->shop->id)->where('self_sku_id', $skuId)->first(['goods_id', 'sku_id', 'external_sku_id'])->toArray(); + $appendParams = Goods::incrQuantity($this->shop->id, $goodsSku->stock, $business); + + $this->formDataPostRequest($type, $appendParams); + $log = new Log(); + $log->module = 'plat'; + $log->action = 'POST'; + $log->target_type = 'miaoxuan'; + $log->target_id = 0; + $log->target_field = '更新库存'; + $log->user_id = 1; + $log->message = 'success'; + $log->save(); + } + + public function downloadOrders($beginTime, $endTime, $activityNo, $downloadType = 'default') + { + Order::saveOrders($beginTime, $endTime, $activityNo); + } + + public function bindGoods($goods) + { + Goods::bindGoods($goods, $this->shop->id); + } +} diff --git a/app/Services/Business/MiaoXuan/Order.php b/app/Services/Business/MiaoXuan/Order.php new file mode 100644 index 0000000..c8489a4 --- /dev/null +++ b/app/Services/Business/MiaoXuan/Order.php @@ -0,0 +1,26 @@ + $shopId, 'order_sn' => $order['order_sn']], + $order + ); + foreach ($order['sub_order_list'] as $item) { + $orderRecord = BusinessOrder::updateOrCreate( + ['shop_id' => $shopId, 'business_order_id' => $orderRecord->id, 'goods_id' => $item['goods_id'], 'sku_id' => $item['sku_id']], + $item + ); + } + } + } +} + diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index fa3372e..cb1446a 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -22,7 +22,7 @@ $factory->define(User::class, function (Faker $faker) { 'name' => 'erpAdmin', 'email' => $faker->unique()->safeEmail, 'email_verified_at' => now(), - 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password + 'password' => 'password', // password 'api_token' => Str::random(60), 'remember_token' => Str::random(10), ]; diff --git a/database/migrations/2022_08_05_030834_create_business_goods_skus_table.php b/database/migrations/2022_08_05_030834_create_business_goods_skus_table.php new file mode 100644 index 0000000..8dce10b --- /dev/null +++ b/database/migrations/2022_08_05_030834_create_business_goods_skus_table.php @@ -0,0 +1,56 @@ +bigIncrements('id'); + $table->bigInteger('shop_id'); + $table->bigInteger('self_sku_id')->nullable(); + $table->string('activity_no')->nullable(); + $table->string('category_name')->nullable(); + $table->mediumInteger('create_time')->nullable(); + $table->text('goods_desc')->nullable(); + $table->string('goods_id')->nullable(); + $table->text('goods_image_list')->nullable(); + $table->string('goods_name')->nullable(); + $table->integer('is_activity_delete')->nullable(); + $table->integer('limit_buy')->nullable(); + $table->mediumInteger('market_price')->nullable(); + $table->mediumInteger('update_time')->nullable(); + $table->string('external_sku_id')->nullable(); + $table->mediumInteger('goods_purchase_price')->nullable(); + $table->mediumInteger('price_in_fen')->nullable(); + $table->mediumInteger('quantity')->nullable(); + $table->integer('quantity_type')->nullable(); + $table->mediumInteger('reserve_quantity')->nullable(); + $table->mediumInteger('sku_id')->nullable(); + $table->mediumInteger('sold_quantity')->nullable(); + $table->text('spec_list')->nullable(); + $table->string('spec_name')->nullable(); + $table->string('thumb_url')->nullable(); + $table->mediumInteger('total_quantity')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('business_goods'); + } +} diff --git a/database/migrations/2022_08_05_093629_create_business_orders_table.php b/database/migrations/2022_08_05_093629_create_business_orders_table.php new file mode 100644 index 0000000..b5b0311 --- /dev/null +++ b/database/migrations/2022_08_05_093629_create_business_orders_table.php @@ -0,0 +1,71 @@ +bigIncrements('id'); + $table->integer('shop_id'); + $table->bigInteger('activity_no')->nullable(); + $table->string('activity_title')->nullable(); + $table->mediumInteger('after_sales_status')->nullable(); + $table->string('business_note')->nullable(); + $table->string('buyer_memo')->nullable(); + $table->integer('cancel_status')->nullable(); + $table->mediumInteger('confirm_at')->nullable(); + $table->mediumInteger('discount_amount')->nullable(); + $table->string('help_sell_nickname')->nullable(); + $table->string('inner_transaction_id')->nullable(); + $table->boolean('is_supplier')->nullable(); + $table->integer('logistics_type')->nullable(); + $table->integer('mall_activity_type')->nullable(); + $table->string('nick_name')->nullable(); + $table->mediumInteger('order_amount')->nullable(); + $table->string('order_sn')->nullable(); + $table->integer('participate_no')->nullable(); + $table->mediumInteger('platform_discount_amount')->nullable(); + $table->string('receiver_address_city')->nullable(); + $table->string('receiver_address_detail')->nullable(); + $table->string('receiver_address_district')->nullable(); + $table->string('receiver_address_province')->nullable(); + $table->string('receiver_mobile')->nullable(); + $table->string('receiver_name')->nullable(); + $table->string('secret_remark')->nullable(); + $table->string('self_pick_site_no')->nullable(); + $table->string('self_pick_up_address')->nullable(); + $table->string('self_pick_up_contact_mobile')->nullable(); + $table->string('self_pick_up_contact_name')->nullable(); + $table->string('self_pick_up_site_name')->nullable(); + $table->mediumInteger('service_amount')->nullable(); + $table->mediumInteger('shipping_amount')->nullable(); + $table->integer('shipping_status')->nullable(); + $table->string('supply_activity_no')->nullable(); + $table->integer('supply_participate_no')->nullable(); + $table->mediumInteger('theoretical_refund_amount')->nullable(); + $table->string('transaction_id')->nullable(); + $table->mediumInteger('updated_at')->nullable(); + $table->integer('verification_status')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('business_orders'); + } +} diff --git a/database/migrations/2022_08_05_093658_create_business_order_items_table.php b/database/migrations/2022_08_05_093658_create_business_order_items_table.php new file mode 100644 index 0000000..325103c --- /dev/null +++ b/database/migrations/2022_08_05_093658_create_business_order_items_table.php @@ -0,0 +1,54 @@ +bigIncrements('id'); + $table->bigInteger('shop_id'); + $table->bigInteger('business_order_id'); + $table->integer('already_cancel_number')->nullable(); + $table->integer('cancel_status')->nullable(); + $table->string('category_name')->nullable(); + $table->string('external_sku_id')->nullable(); + $table->mediumInteger('goods_amount')->nullable(); + $table->mediumInteger('goods_cost_price')->nullable(); + $table->mediumInteger('goods_id')->nullable(); + $table->string('goods_name')->nullable(); + $table->integer('goods_number')->nullable(); + $table->mediumInteger('goods_price')->nullable(); + $table->mediumInteger('goods_purchase_price')->nullable(); + $table->string('goods_specification')->nullable(); + $table->mediumInteger('help_sell_amount')->nullable(); + $table->boolean('is_supplier')->nullable(); + $table->integer('need_verification_number')->nullable(); + $table->integer('shipping_status')->nullable(); + $table->mediumInteger('sku_id')->nullable(); + $table->string('sub_order_sn')->nullable(); + $table->mediumInteger('theoretically_refund_amount')->nullable(); + $table->string('thumb_url')->nullable(); + $table->integer('verification_number')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('business_order_items'); + } +} diff --git a/routes/api.php b/routes/api.php index 4a047f0..b322c4f 100644 --- a/routes/api.php +++ b/routes/api.php @@ -35,7 +35,7 @@ Route::middleware(['auth:api', 'check.permissions'])->group(function () { Route::resource('shops', 'Shop\ShopsController', ['only' => ['index', 'store', 'show', 'update', 'destroy']]); // 角色 Route::resource('roles', 'Role\RolesController', ['only' => ['index', 'store', 'show', 'update']]); - Route::post('roles/{id}/permissions', [RolesController::class, 'addPermissions'])->name('role.permission'); + Route::post('roles/{id}/permissions', [RolesController::class, 'addPermissions'])->name('roles.permission'); // 权限 Route::resource('permissions', 'Permission\PermissionsController', ['only' => ['index', // 'store', 'show', 'update', 'destroy' @@ -49,4 +49,7 @@ Route::post('/auth/login', [LoginController::class, 'login'])->name('auth.login' Route::resource('menus', 'Menu\MenusController', ['only' => ['index', // 'store', 'show', 'update', 'destroy' ]])->middleware('auth:api'); + Route::get('shop_platforms', [ShopsController::class, 'getPlatList'])->name('plat.list')->middleware('auth:api'); + +Route::post('business', [ShopsController::class, 'business'])->name('shop.put.business'); diff --git a/routes/web.php b/routes/web.php index 20cc097..17deaf8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -2,6 +2,7 @@ use App\Http\Controllers\Goods\GoodsSkusController; use App\Http\Controllers\Goods\GoodsController; +use App\Http\Controllers\Shop\ShopsController; /* |-------------------------------------------------------------------------- @@ -33,3 +34,5 @@ Route::get('/register', function () { Route::get('goods_skus/export', [GoodsSkusController::class, 'export'])->name('goods_skus.export')->middleware('check.permissions'); Route::get('goods/import/template', [GoodsController::class, 'download'])->name('download.goods_import.template'); + +Route::get('callback', [ShopsController::class, 'authBind'])->name('shop.auth_bind.callback'); From 0c3fd316cbe99e46bc193b8910971b55ec56dfe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Sat, 6 Aug 2022 16:10:14 +0800 Subject: [PATCH 33/68] =?UTF-8?q?feat:=20#00000=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Goods/GoodsSkusController.php | 2 +- app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index e04ad52..71a6e25 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -56,7 +56,7 @@ class GoodsSkusController extends Controller $query->with(['type:id,name', 'brand:id,name']); }]) ->with(['daily' => function ($query) use ($day) { - $query->where('day', $day)->with(['daily:id,sku_id,day,arrived_today_num,loss_num,inventory']); + return $query->where('day', $day)->first(['id', 'sku_id', 'day', 'arrived_today_num', 'loss_num', 'inventory']); }]) ->paginate(); diff --git a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php index 60dd313..706a81c 100644 --- a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php +++ b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php @@ -55,11 +55,6 @@ class KuaiTuanTuan extends BusinessClient return $res['pop_auth_token_create_response']; } - public function getAccessToken() - { - return ''; - } - public function getSign($params) { $params = ksort($params); From 5b628380ce379185b52ec7c1e99089113d00e73b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Sat, 6 Aug 2022 16:38:04 +0800 Subject: [PATCH 34/68] =?UTF-8?q?feat:=20#00000=20=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/BusinessOrderItem.php | 5 + app/Models/GoodsSku.php | 5 + app/Services/Business/BusinessClient.php | 4 +- .../Business/KuaiTuanTuan/KuaiTuanTuan.php | 106 +++++++++--------- app/Services/Business/MiaoXuan/MiaoXuan.php | 16 ++- app/Services/Business/MiaoXuan/Order.php | 2 +- 6 files changed, 78 insertions(+), 60 deletions(-) diff --git a/app/Models/BusinessOrderItem.php b/app/Models/BusinessOrderItem.php index b8f5423..daa3675 100644 --- a/app/Models/BusinessOrderItem.php +++ b/app/Models/BusinessOrderItem.php @@ -10,4 +10,9 @@ class BusinessOrderItem extends Model * @var array */ protected $guarded = []; + + public function order() + { + return $this->hasOne(BusinessOrder::class, 'id', 'business_order_id'); + } } diff --git a/app/Models/GoodsSku.php b/app/Models/GoodsSku.php index 36a612a..19c1770 100644 --- a/app/Models/GoodsSku.php +++ b/app/Models/GoodsSku.php @@ -54,4 +54,9 @@ class GoodsSku extends Model { return $this->hasOne(DailyStockRecord::class, 'sku_id', 'id'); } + + public function order() + { + return $this->hasOne(BusinessOrderItem::class, 'external_sku_id', 'id'); + } } diff --git a/app/Services/Business/BusinessClient.php b/app/Services/Business/BusinessClient.php index 48772e6..cc36aeb 100644 --- a/app/Services/Business/BusinessClient.php +++ b/app/Services/Business/BusinessClient.php @@ -13,7 +13,7 @@ abstract class BusinessClient abstract public function auth(); - abstract public function downloadGoodsAndBind(); + abstract public function downloadGoods(); abstract public function bindGoods($goods); @@ -21,6 +21,8 @@ abstract class BusinessClient abstract public function downloadOrders($beginTime, $endTime, $activityNo, $downloadType = 'default'); + abstract public function saveOrders($orders); + public function authCallback($code, $shopId) { $this->setCode($code); diff --git a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php index 706a81c..9b588be 100644 --- a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php +++ b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php @@ -27,17 +27,6 @@ class KuaiTuanTuan extends BusinessClient 'sign' => '' ]; - public function __construct() - { - } - - public function getAuthUrl($shopId, $platId) - { - $state = $shopId . '_' . $platId; - - return "https://oauth.pinduoduo.com/authorize/ktt?client_id={$this->clientId}&redirect_uri={$this->redirectUri}&state={$state}"; - } - public function auth() { $accessToken = $this->getAccessTokenWithCode(); @@ -47,54 +36,23 @@ class KuaiTuanTuan extends BusinessClient return $this->shop; } - public function getAccessTokenWithCode() - { - $type = 'pdd.pop.auth.token.create'; - $res = $this->request($type, ['code' => $this->code]); - - return $res['pop_auth_token_create_response']; - } - - public function getSign($params) - { - $params = ksort($params); - $str = ''; - foreach ($params as $key => $val) { - $str .= $key . $val; - } - $str = $this->clientSecret . $str . $this->clientSecret; - - return strtoupper(md5($str)); - } - - public function request($type, $appendParams = [], $url = 'http://gw-api.pinduoduo.com/api/router') - { - $publicParams = [ - 'type' => $type, - 'client_id' => $this->clientId, - 'timestamp' => time() - ]; - if ('pdd.pop.auth.token.create' !== $type) { - $publicParams['access_token'] = $this->getAccessToken(); - } - $publicParams = array_merge($publicParams, $appendParams); - $publicParams['sign'] = $this->getSign($publicParams); - - return $this->formDataPostRequest($url, $publicParams); - } - - public function downloadGoodsAndBind($page = 1) + public function downloadGoods($page = 1) { [$type, $appendParams] = Goods::downloadGoods($this->shop->owner_name, $page); $res = $this->formDataPostRequest($type, $appendParams); $goods = $res['ktt_goods_query_list_response']['goods_list']; - Goods::bindGoods($goods, $this->shop->id); + $this->bindGoods($goods); $pageNum = ceil($res['total'] / $appendParams['size']); if ($pageNum > $page && 10 >= $page) { - $this->downloadGoodsAndBind($page + 1); + $this->downloadGoods($page + 1); } } + public function bindGoods($goods) + { + Goods::bindGoods($goods, $this->shop->id); + } + public function incrQuantity($skuId) { $goodsSku = GoodsSku::query()->find($skuId); @@ -125,8 +83,52 @@ class KuaiTuanTuan extends BusinessClient return $res['ktt_order_list_response']['order_list']; } - public function bindGoods($goods) + public function saveOrders($orders) { - // TODO: Implement bindGoods() method. + Order::saveOrders($orders, $this->shop->id); + } + + protected function getAccessTokenWithCode() + { + $type = 'pdd.pop.auth.token.create'; + $res = $this->doRequest($type, ['code' => $this->code]); + + return $res['pop_auth_token_create_response']; + } + + protected function getSign($params) + { + $params = ksort($params); + $str = ''; + foreach ($params as $key => $val) { + $str .= $key . $val; + } + $str = $this->clientSecret . $str . $this->clientSecret; + + return strtoupper(md5($str)); + } + + public function doRequest($type, $appendParams = [], $url = 'http://gw-api.pinduoduo.com/api/router') + { + $publicParams = [ + 'type' => $type, + 'client_id' => $this->clientId, + 'timestamp' => time() + ]; + if ('pdd.pop.auth.token.create' !== $type) { + $publicParams['access_token'] = $this->getAccessToken(); + } + $publicParams = array_merge($publicParams, $appendParams); + $publicParams['sign'] = $this->getSign($publicParams); + + return $this->formDataPostRequest($url, $publicParams); + } + + + public function getAuthUrl($shopId, $platId) + { + $state = $shopId . '_' . $platId; + + return "https://oauth.pinduoduo.com/authorize/ktt?client_id={$this->clientId}&redirect_uri={$this->redirectUri}&state={$state}"; } } diff --git a/app/Services/Business/MiaoXuan/MiaoXuan.php b/app/Services/Business/MiaoXuan/MiaoXuan.php index 041d2de..3415a33 100644 --- a/app/Services/Business/MiaoXuan/MiaoXuan.php +++ b/app/Services/Business/MiaoXuan/MiaoXuan.php @@ -15,17 +15,22 @@ class MiaoXuan extends BusinessClient // TODO: Implement auth() method. } - public function downloadGoodsAndBind() + public function downloadGoods() { } + public function bindGoods($goods) + { + Goods::bindGoods($goods, $this->shop->id); + } + public function incrQuantity($skuId) { $goodsSku = GoodsSku::query()->find($skuId); $business = BusinessGoodsSku::query()->where('shop_id', $this->shop->id)->where('self_sku_id', $skuId)->first(['goods_id', 'sku_id', 'external_sku_id'])->toArray(); $appendParams = Goods::incrQuantity($this->shop->id, $goodsSku->stock, $business); - - $this->formDataPostRequest($type, $appendParams); + $url = ''; // http://shop.chutang66.com/miaoxuan/stock + $this->formDataPostRequest($url, $appendParams); $log = new Log(); $log->module = 'plat'; $log->action = 'POST'; @@ -39,11 +44,10 @@ class MiaoXuan extends BusinessClient public function downloadOrders($beginTime, $endTime, $activityNo, $downloadType = 'default') { - Order::saveOrders($beginTime, $endTime, $activityNo); } - public function bindGoods($goods) + public function saveOrders($orders) { - Goods::bindGoods($goods, $this->shop->id); + Order::saveOrders($orders, $this->shop->id); } } diff --git a/app/Services/Business/MiaoXuan/Order.php b/app/Services/Business/MiaoXuan/Order.php index c8489a4..07278fa 100644 --- a/app/Services/Business/MiaoXuan/Order.php +++ b/app/Services/Business/MiaoXuan/Order.php @@ -7,7 +7,7 @@ use App\Models\BusinessOrder; class Order { // 下载订单事件之后去统计 然后更新库存 - public static function saveOrders(array $orders) + public static function saveOrders(array $orders, $shopId) { foreach ($orders as $order) { $orderRecord = BusinessOrder::updateOrCreate( From e0f68a2d4da4cdb6585bcbbc0e09e2a994dedb39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Mon, 8 Aug 2022 10:43:59 +0800 Subject: [PATCH 35/68] =?UTF-8?q?feat:=20#20220808=20=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=AF=A6=E7=BB=86=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Shop/ShopsController.php | 8 +++-- app/Listeners/BindBusinessGoods.php | 34 +++++++++++++++++++ app/Listeners/SendDatabaseNotification.php | 31 +++++++++++++++++ app/Listeners/UpdateBusinessGoodsStock.php | 34 +++++++++++++++++++ app/Models/Log.php | 8 +++++ app/Providers/EventServiceProvider.php | 6 ++++ .../Business/KuaiTuanTuan/KuaiTuanTuan.php | 1 + 7 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 app/Listeners/BindBusinessGoods.php create mode 100644 app/Listeners/SendDatabaseNotification.php create mode 100644 app/Listeners/UpdateBusinessGoodsStock.php diff --git a/app/Http/Controllers/Shop/ShopsController.php b/app/Http/Controllers/Shop/ShopsController.php index 5ec522d..d32528c 100644 --- a/app/Http/Controllers/Shop/ShopsController.php +++ b/app/Http/Controllers/Shop/ShopsController.php @@ -3,6 +3,8 @@ namespace App\Http\Controllers\Shop; use App\Http\Controllers\Controller; +use App\Listeners\BindBusinessGoods; +use App\Listeners\UpdateBusinessGoodsStock; use App\Models\Shop; use App\Http\Resources\ShopsResource; use Illuminate\Http\Request; @@ -86,10 +88,12 @@ class ShopsController extends Controller $business = BusinessFactory::init()->make($shop->plat_id); $business->setShop($shop); if ('goods' === $request->get('type')) { - $business->downloadGoodsAndBind($request->get('data')); + $business->bindGoods($request->get('data')); + event(new BindBusinessGoods($shop)); } if ('orders' === $request->get('type')) { - $business->downloadOrders(); + $business->saveOrders(); + event(new UpdateBusinessGoodsStock($shop)); } } } diff --git a/app/Listeners/BindBusinessGoods.php b/app/Listeners/BindBusinessGoods.php new file mode 100644 index 0000000..b6c3ed8 --- /dev/null +++ b/app/Listeners/BindBusinessGoods.php @@ -0,0 +1,34 @@ +shop = $shop; + } + + /** + * Handle the event. + * + * @param Registered $event + * @return void + */ + public function handle(Registered $event) + { + // + } +} diff --git a/app/Listeners/SendDatabaseNotification.php b/app/Listeners/SendDatabaseNotification.php new file mode 100644 index 0000000..ce0cbee --- /dev/null +++ b/app/Listeners/SendDatabaseNotification.php @@ -0,0 +1,31 @@ +shop = $shop; + } + + /** + * Handle the event. + * + * @param Registered $event + * @return void + */ + public function handle(Registered $event) + { + // + } +} diff --git a/app/Models/Log.php b/app/Models/Log.php index 75c1cd7..06bc265 100644 --- a/app/Models/Log.php +++ b/app/Models/Log.php @@ -38,6 +38,8 @@ class Log extends Model 'permission' => '权限', 'role' => '角色', 'user' => '用户', + 'plat' => '平台', + 'file' => '文件', ]; return $map[$value]; @@ -65,6 +67,9 @@ class Log extends Model 'role' => '角色', 'menu' => '菜单', 'user' => '用户', + 'upload' => '上传', + 'kuaituantuan' => '快团团', + 'miaoxuan' => '妙选', ]; return $map[$value]; @@ -80,6 +85,9 @@ class Log extends Model 'import' => '导入', 'export' => '导出', 'set' => '设置', + 'cost' => '成本', + 'stock' => '库存', + 'inventory' => '库存盘点', ]; return $map[$value]; diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 723a290..b975ef6 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -6,6 +6,9 @@ use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Listeners\SendEmailVerificationNotification; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; use Illuminate\Support\Facades\Event; +use App\Listeners\SendDatabaseNotification; +use App\Listeners\BindBusinessGoods; +use App\Listeners\UpdateBusinessGoodsStock; class EventServiceProvider extends ServiceProvider { @@ -17,6 +20,9 @@ class EventServiceProvider extends ServiceProvider protected $listen = [ Registered::class => [ SendEmailVerificationNotification::class, + SendDatabaseNotification::class, + BindBusinessGoods::class, + UpdateBusinessGoodsStock::class, ], ]; diff --git a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php index 9b588be..d75d708 100644 --- a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php +++ b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php @@ -2,6 +2,7 @@ namespace App\Services\Business\KuaiTuanTuan; +use App\Listeners\BindBusinessGoods; use App\Models\BusinessGoodsSku; use App\Models\GoodsSku; use App\Services\Business\BusinessClient; From 0cc4ef4451329aded2a6ff595cbd30be9fb622ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Mon, 8 Aug 2022 13:27:13 +0800 Subject: [PATCH 36/68] =?UTF-8?q?feat:=20#20220808=20=E5=BF=AB=E5=9B=A2?= =?UTF-8?q?=E5=9B=A2=E6=9C=8D=E5=8A=A1=E5=95=86=E8=B4=A6=E5=8F=B7=E5=B8=AE?= =?UTF-8?q?=E5=BF=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php index d75d708..8803dab 100644 --- a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php +++ b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php @@ -14,9 +14,9 @@ class KuaiTuanTuan extends BusinessClient // 如果请求的content-type是 application/x-www-form-urlencoded,所有参数值也做urlencode编码; // 如果是multipart/form-data格式,每个表单字段的参数值无需编码,但每个表单字段的charset需要指定为utf-8 // 如果指定接口返回数据格式为JSON,请指明header头content-type: application/json - protected $clientId = ''; + protected $clientId = '8d7ca13bc27247b6a04e08404b51dfd8'; - protected $clientSecret = ''; + protected $clientSecret = '4478bc82dc1e1f68fe06c9f2bc683f1dcb3e6d83'; protected $publicParams = [ 'type' => '', From 0e4fe053362a83f2788a0893dff5126fec5786cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Mon, 8 Aug 2022 13:30:59 +0800 Subject: [PATCH 37/68] =?UTF-8?q?feat:=20#10000=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E8=BF=81=E7=A7=BB=E8=84=9A=E6=9C=AC=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2022_08_05_030834_create_business_goods_skus_table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/2022_08_05_030834_create_business_goods_skus_table.php b/database/migrations/2022_08_05_030834_create_business_goods_skus_table.php index 8dce10b..18c9b5b 100644 --- a/database/migrations/2022_08_05_030834_create_business_goods_skus_table.php +++ b/database/migrations/2022_08_05_030834_create_business_goods_skus_table.php @@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateBusinessGoodsTable extends Migration +class CreateBusinessGoodsSkusTable extends Migration { /** * Run the migrations. From 92e9f33663e531ef91d3bcce4f1aa0314811209c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Mon, 8 Aug 2022 13:32:42 +0800 Subject: [PATCH 38/68] =?UTF-8?q?feat:=20#10000=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E8=BF=81=E7=A7=BB=E8=84=9A=E6=9C=AC=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2022_08_05_093629_create_business_orders_table.php | 1 - 1 file changed, 1 deletion(-) diff --git a/database/migrations/2022_08_05_093629_create_business_orders_table.php b/database/migrations/2022_08_05_093629_create_business_orders_table.php index b5b0311..7561823 100644 --- a/database/migrations/2022_08_05_093629_create_business_orders_table.php +++ b/database/migrations/2022_08_05_093629_create_business_orders_table.php @@ -53,7 +53,6 @@ class CreateBusinessOrdersTable extends Migration $table->integer('supply_participate_no')->nullable(); $table->mediumInteger('theoretical_refund_amount')->nullable(); $table->string('transaction_id')->nullable(); - $table->mediumInteger('updated_at')->nullable(); $table->integer('verification_status')->nullable(); $table->timestamps(); }); From 6831dbb2e40f93e8380fb1d29ddf16ede8db4a93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Mon, 8 Aug 2022 13:45:54 +0800 Subject: [PATCH 39/68] feat: --- app/Http/Controllers/Shop/ShopsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Shop/ShopsController.php b/app/Http/Controllers/Shop/ShopsController.php index d32528c..37be306 100644 --- a/app/Http/Controllers/Shop/ShopsController.php +++ b/app/Http/Controllers/Shop/ShopsController.php @@ -60,7 +60,7 @@ class ShopsController extends Controller $platList = $shop->getPlatList(); $shop = $shop->find($shopId); if ($platList[$platId] === $shop->plat_id) { - BusinessFactory::init()->make($shop->plat_id)->authCallback($request->get('code'), $shop->id); + BusinessFactory::init()->make($shop->plat_id)->authCallback($request->get('code'), $shop); } else { $this->res = [ 'httpCode' => 403, From a1e93f54e4027d7a0a447842d3a214453f0553b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Mon, 8 Aug 2022 13:59:44 +0800 Subject: [PATCH 40/68] =?UTF-8?q?feat:=20#10000=20=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/Business/BusinessClient.php | 4 +- .../Business/KuaiTuanTuan/KuaiTuanTuan.php | 2 +- composer.json | 1 + composer.lock | 1657 ++++++++++++++++- 4 files changed, 1607 insertions(+), 57 deletions(-) diff --git a/app/Services/Business/BusinessClient.php b/app/Services/Business/BusinessClient.php index cc36aeb..cbc6eac 100644 --- a/app/Services/Business/BusinessClient.php +++ b/app/Services/Business/BusinessClient.php @@ -3,7 +3,7 @@ namespace App\Services\Business; use App\Models\Log; use App\Models\Shop; -use Facade\FlareClient\Http\Client; +use GuzzleHttp\Client; abstract class BusinessClient { @@ -69,7 +69,7 @@ abstract class BusinessClient 'headers' => ['Content-type' => 'multipart/form-data;charset=UTF-8'], 'form_params' => $params ]; - $res = (new Client())->makeCurlRequest('POST', $url, $headers); + $res = (new Client())->request('POST', $url, $headers); $res = json_decode($res->getBody()->getContents(), true); if (isset($res['error_response'])) { $log = new Log(); diff --git a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php index 8803dab..27fd06d 100644 --- a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php +++ b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php @@ -99,7 +99,7 @@ class KuaiTuanTuan extends BusinessClient protected function getSign($params) { - $params = ksort($params); + ksort($params); $str = ''; foreach ($params as $key => $val) { $str .= $key . $val; diff --git a/composer.json b/composer.json index e442ecc..d12ec93 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,7 @@ "require": { "php": "^7.2.5|^8.0", "aliyuncs/oss-sdk-php": "^2.5", + "beyondcode/laravel-websockets": "^1.13", "fideloper/proxy": "^4.4", "intervention/image": "^2.7", "laravel/framework": "^6.20.26", diff --git a/composer.lock b/composer.lock index b66292d..9b5df2a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "87b78d5c6e1dfc1285abb501c7eb8372", + "content-hash": "0d3d2fbbec4c9922fb38612b6fa05ac0", "packages": [ { "name": "aliyuncs/oss-sdk-php", @@ -51,6 +51,151 @@ }, "time": "2022-05-13T07:41:28+00:00" }, + { + "name": "beyondcode/laravel-websockets", + "version": "1.13.1", + "source": { + "type": "git", + "url": "https://github.com/beyondcode/laravel-websockets.git", + "reference": "f0649b65fb5562d20eff66f61716ef98717e228a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/beyondcode/laravel-websockets/zipball/f0649b65fb5562d20eff66f61716ef98717e228a", + "reference": "f0649b65fb5562d20eff66f61716ef98717e228a", + "shasum": "" + }, + "require": { + "cboden/ratchet": "^0.4.1", + "ext-json": "*", + "facade/ignition-contracts": "^1.0", + "guzzlehttp/psr7": "^1.7|^2.0", + "illuminate/broadcasting": "^6.0|^7.0|^8.0|^9.0", + "illuminate/console": "^6.0|^7.0|^8.0|^9.0", + "illuminate/http": "^6.0|^7.0|^8.0|^9.0", + "illuminate/routing": "^6.0|^7.0|^8.0|^9.0", + "illuminate/support": "^6.0|^7.0|^8.0|^9.0", + "php": "^7.2|^8.0", + "pusher/pusher-php-server": "^3.0|^4.0|^5.0|^6.0|^7.0", + "react/dns": "^1.1", + "react/http": "^1.1", + "symfony/http-kernel": "^4.0|^5.0|^6.0", + "symfony/psr-http-message-bridge": "^1.1|^2.0" + }, + "require-dev": { + "mockery/mockery": "^1.3.3", + "orchestra/testbench": "^4.0|^5.0|^6.0", + "phpunit/phpunit": "^8.0|^9.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "BeyondCode\\LaravelWebSockets\\WebSocketsServiceProvider" + ], + "aliases": { + "WebSocketRouter": "BeyondCode\\LaravelWebSockets\\Facades\\WebSocketRouter" + } + } + }, + "autoload": { + "psr-4": { + "BeyondCode\\LaravelWebSockets\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marcel Pociot", + "email": "marcel@beyondco.de", + "homepage": "https://beyondcode.de", + "role": "Developer" + }, + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "An easy to use WebSocket server", + "homepage": "https://github.com/beyondcode/laravel-websockets", + "keywords": [ + "beyondcode", + "laravel-websockets" + ], + "support": { + "issues": "https://github.com/beyondcode/laravel-websockets/issues", + "source": "https://github.com/beyondcode/laravel-websockets/tree/1.13.1" + }, + "time": "2022-03-03T08:41:47+00:00" + }, + { + "name": "cboden/ratchet", + "version": "v0.4.4", + "source": { + "type": "git", + "url": "https://github.com/ratchetphp/Ratchet.git", + "reference": "5012dc954541b40c5599d286fd40653f5716a38f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ratchetphp/Ratchet/zipball/5012dc954541b40c5599d286fd40653f5716a38f", + "reference": "5012dc954541b40c5599d286fd40653f5716a38f", + "shasum": "" + }, + "require": { + "guzzlehttp/psr7": "^1.7|^2.0", + "php": ">=5.4.2", + "ratchet/rfc6455": "^0.3.1", + "react/event-loop": ">=0.4", + "react/socket": "^1.0 || ^0.8 || ^0.7 || ^0.6 || ^0.5", + "symfony/http-foundation": "^2.6|^3.0|^4.0|^5.0|^6.0", + "symfony/routing": "^2.6|^3.0|^4.0|^5.0|^6.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Ratchet\\": "src/Ratchet" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "role": "Developer" + }, + { + "name": "Matt Bonneau", + "role": "Developer" + } + ], + "description": "PHP WebSocket library", + "homepage": "http://socketo.me", + "keywords": [ + "Ratchet", + "WebSockets", + "server", + "sockets", + "websocket" + ], + "support": { + "chat": "https://gitter.im/reactphp/reactphp", + "issues": "https://github.com/ratchetphp/Ratchet/issues", + "source": "https://github.com/ratchetphp/Ratchet/tree/v0.4.4" + }, + "time": "2021-12-14T00:20:41+00:00" + }, { "name": "doctrine/inflector", "version": "2.0.4", @@ -350,6 +495,53 @@ ], "time": "2020-12-29T14:50:06+00:00" }, + { + "name": "evenement/evenement", + "version": "v3.0.1", + "source": { + "type": "git", + "url": "https://github.com/igorw/evenement.git", + "reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/igorw/evenement/zipball/531bfb9d15f8aa57454f5f0285b18bec903b8fb7", + "reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7", + "shasum": "" + }, + "require": { + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Evenement": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + } + ], + "description": "Événement is a very simple event dispatching library for PHP", + "keywords": [ + "event-dispatcher", + "event-emitter" + ], + "support": { + "issues": "https://github.com/igorw/evenement/issues", + "source": "https://github.com/igorw/evenement/tree/master" + }, + "time": "2017-07-23T21:35:13+00:00" + }, { "name": "ezyang/htmlpurifier", "version": "v4.14.0", @@ -401,6 +593,59 @@ }, "time": "2021-12-25T01:21:49+00:00" }, + { + "name": "facade/ignition-contracts", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/facade/ignition-contracts.git", + "reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/facade/ignition-contracts/zipball/3c921a1cdba35b68a7f0ccffc6dffc1995b18267", + "reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267", + "shasum": "" + }, + "require": { + "php": "^7.3|^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^v2.15.8", + "phpunit/phpunit": "^9.3.11", + "vimeo/psalm": "^3.17.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Facade\\IgnitionContracts\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://flareapp.io", + "role": "Developer" + } + ], + "description": "Solution contracts for Ignition", + "homepage": "https://github.com/facade/ignition-contracts", + "keywords": [ + "contracts", + "flare", + "ignition" + ], + "support": { + "issues": "https://github.com/facade/ignition-contracts/issues", + "source": "https://github.com/facade/ignition-contracts/tree/1.0.2" + }, + "time": "2020-10-16T08:27:54+00:00" + }, { "name": "fideloper/proxy", "version": "4.4.2", @@ -459,6 +704,270 @@ }, "time": "2022-02-09T13:33:34+00:00" }, + { + "name": "fig/http-message-util", + "version": "1.1.5", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message-util.git", + "reference": "9d94dc0154230ac39e5bf89398b324a86f63f765" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message-util/zipball/9d94dc0154230ac39e5bf89398b324a86f63f765", + "reference": "9d94dc0154230ac39e5bf89398b324a86f63f765", + "shasum": "" + }, + "require": { + "php": "^5.3 || ^7.0 || ^8.0" + }, + "suggest": { + "psr/http-message": "The package containing the PSR-7 interfaces" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Fig\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Utility classes and constants for use with PSR-7 (psr/http-message)", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "issues": "https://github.com/php-fig/http-message-util/issues", + "source": "https://github.com/php-fig/http-message-util/tree/1.1.5" + }, + "time": "2020-11-24T22:02:12+00:00" + }, + { + "name": "guzzlehttp/guzzle", + "version": "7.4.5", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "1dd98b0564cb3f6bd16ce683cb755f94c10fbd82" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/1dd98b0564cb3f6bd16ce683cb755f94c10fbd82", + "reference": "1dd98b0564cb3f6bd16ce683cb755f94c10fbd82", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/promises": "^1.5", + "guzzlehttp/psr7": "^1.9 || ^2.4", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "ext-curl": "*", + "php-http/client-integration-tests": "^3.0", + "phpunit/phpunit": "^8.5.5 || ^9.3.5", + "psr/log": "^1.1 || ^2.0 || ^3.0" + }, + "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "7.4-dev" + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "psr-18", + "psr-7", + "rest", + "web service" + ], + "support": { + "issues": "https://github.com/guzzle/guzzle/issues", + "source": "https://github.com/guzzle/guzzle/tree/7.4.5" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" + } + ], + "time": "2022-06-20T22:16:13+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/fe752aedc9fd8fcca3fe7ad05d419d32998a06da", + "reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "symfony/phpunit-bridge": "^4.4 || ^5.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.5-dev" + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/1.5.1" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "time": "2021-10-22T20:56:57+00:00" + }, { "name": "guzzlehttp/psr7", "version": "2.4.0", @@ -1815,6 +2324,92 @@ }, "time": "2020-10-15T08:29:30+00:00" }, + { + "name": "paragonie/sodium_compat", + "version": "v1.17.1", + "source": { + "type": "git", + "url": "https://github.com/paragonie/sodium_compat.git", + "reference": "ac994053faac18d386328c91c7900f930acadf1e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/sodium_compat/zipball/ac994053faac18d386328c91c7900f930acadf1e", + "reference": "ac994053faac18d386328c91c7900f930acadf1e", + "shasum": "" + }, + "require": { + "paragonie/random_compat": ">=1", + "php": "^5.2.4|^5.3|^5.4|^5.5|^5.6|^7|^8" + }, + "require-dev": { + "phpunit/phpunit": "^3|^4|^5|^6|^7|^8|^9" + }, + "suggest": { + "ext-libsodium": "PHP < 7.0: Better performance, password hashing (Argon2i), secure memory management (memzero), and better security.", + "ext-sodium": "PHP >= 7.0: Better performance, password hashing (Argon2i), secure memory management (memzero), and better security." + }, + "type": "library", + "autoload": { + "files": [ + "autoload.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "ISC" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com" + }, + { + "name": "Frank Denis", + "email": "jedisct1@pureftpd.org" + } + ], + "description": "Pure PHP implementation of libsodium; uses the PHP extension if it exists", + "keywords": [ + "Authentication", + "BLAKE2b", + "ChaCha20", + "ChaCha20-Poly1305", + "Chapoly", + "Curve25519", + "Ed25519", + "EdDSA", + "Edwards-curve Digital Signature Algorithm", + "Elliptic Curve Diffie-Hellman", + "Poly1305", + "Pure-PHP cryptography", + "RFC 7748", + "RFC 8032", + "Salpoly", + "Salsa20", + "X25519", + "XChaCha20-Poly1305", + "XSalsa20-Poly1305", + "Xchacha20", + "Xsalsa20", + "aead", + "cryptography", + "ecdh", + "elliptic curve", + "elliptic curve cryptography", + "encryption", + "libsodium", + "php", + "public-key cryptography", + "secret-key cryptography", + "side-channel resistant" + ], + "support": { + "issues": "https://github.com/paragonie/sodium_compat/issues", + "source": "https://github.com/paragonie/sodium_compat/tree/v1.17.1" + }, + "time": "2022-03-23T19:32:04+00:00" + }, { "name": "phpoffice/phpspreadsheet", "version": "1.24.1", @@ -2375,6 +2970,67 @@ }, "time": "2022-07-07T13:49:11+00:00" }, + { + "name": "pusher/pusher-php-server", + "version": "7.0.2", + "source": { + "type": "git", + "url": "https://github.com/pusher/pusher-http-php.git", + "reference": "af3eeaefc0c7959f5b3852f0a4dd5547245d33df" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pusher/pusher-http-php/zipball/af3eeaefc0c7959f5b3852f0a4dd5547245d33df", + "reference": "af3eeaefc0c7959f5b3852f0a4dd5547245d33df", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "guzzlehttp/guzzle": "^7.2", + "paragonie/sodium_compat": "^1.6", + "php": "^7.3|^8.0", + "psr/log": "^1.0|^2.0|^3.0" + }, + "require-dev": { + "overtrue/phplint": "^2.3", + "phpunit/phpunit": "^8.5|^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "Pusher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Library for interacting with the Pusher REST API", + "keywords": [ + "events", + "messaging", + "php-pusher-server", + "publish", + "push", + "pusher", + "real time", + "real-time", + "realtime", + "rest", + "trigger" + ], + "support": { + "issues": "https://github.com/pusher/pusher-http-php/issues", + "source": "https://github.com/pusher/pusher-http-php/tree/7.0.2" + }, + "time": "2021-12-07T13:09:00+00:00" + }, { "name": "ralouphie/getallheaders", "version": "3.0.3", @@ -2524,6 +3180,864 @@ ], "time": "2021-09-25T23:07:42+00:00" }, + { + "name": "ratchet/rfc6455", + "version": "v0.3.1", + "source": { + "type": "git", + "url": "https://github.com/ratchetphp/RFC6455.git", + "reference": "7c964514e93456a52a99a20fcfa0de242a43ccdb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ratchetphp/RFC6455/zipball/7c964514e93456a52a99a20fcfa0de242a43ccdb", + "reference": "7c964514e93456a52a99a20fcfa0de242a43ccdb", + "shasum": "" + }, + "require": { + "guzzlehttp/psr7": "^2 || ^1.7", + "php": ">=5.4.2" + }, + "require-dev": { + "phpunit/phpunit": "^5.7", + "react/socket": "^1.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Ratchet\\RFC6455\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "role": "Developer" + }, + { + "name": "Matt Bonneau", + "role": "Developer" + } + ], + "description": "RFC6455 WebSocket protocol handler", + "homepage": "http://socketo.me", + "keywords": [ + "WebSockets", + "rfc6455", + "websocket" + ], + "support": { + "chat": "https://gitter.im/reactphp/reactphp", + "issues": "https://github.com/ratchetphp/RFC6455/issues", + "source": "https://github.com/ratchetphp/RFC6455/tree/v0.3.1" + }, + "time": "2021-12-09T23:20:49+00:00" + }, + { + "name": "react/cache", + "version": "v1.1.1", + "source": { + "type": "git", + "url": "https://github.com/reactphp/cache.git", + "reference": "4bf736a2cccec7298bdf745db77585966fc2ca7e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/cache/zipball/4bf736a2cccec7298bdf745db77585966fc2ca7e", + "reference": "4bf736a2cccec7298bdf745db77585966fc2ca7e", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "react/promise": "^3.0 || ^2.0 || ^1.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async, Promise-based cache interface for ReactPHP", + "keywords": [ + "cache", + "caching", + "promise", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/cache/issues", + "source": "https://github.com/reactphp/cache/tree/v1.1.1" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2021-02-02T06:47:52+00:00" + }, + { + "name": "react/dns", + "version": "v1.9.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/dns.git", + "reference": "6d38296756fa644e6cb1bfe95eff0f9a4ed6edcb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/dns/zipball/6d38296756fa644e6cb1bfe95eff0f9a4ed6edcb", + "reference": "6d38296756fa644e6cb1bfe95eff0f9a4ed6edcb", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "react/cache": "^1.0 || ^0.6 || ^0.5", + "react/event-loop": "^1.2", + "react/promise": "^3.0 || ^2.7 || ^1.2.1", + "react/promise-timer": "^1.8" + }, + "require-dev": { + "clue/block-react": "^1.2", + "phpunit/phpunit": "^9.3 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Dns\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async DNS resolver for ReactPHP", + "keywords": [ + "async", + "dns", + "dns-resolver", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/dns/issues", + "source": "https://github.com/reactphp/dns/tree/v1.9.0" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2021-12-20T08:46:54+00:00" + }, + { + "name": "react/event-loop", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/event-loop.git", + "reference": "187fb56f46d424afb6ec4ad089269c72eec2e137" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/event-loop/zipball/187fb56f46d424afb6ec4ad089269c72eec2e137", + "reference": "187fb56f46d424afb6ec4ad089269c72eec2e137", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35" + }, + "suggest": { + "ext-event": "~1.0 for ExtEventLoop", + "ext-pcntl": "For signal handling support when using the StreamSelectLoop", + "ext-uv": "* for ExtUvLoop" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\EventLoop\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "ReactPHP's core reactor event loop that libraries can use for evented I/O.", + "keywords": [ + "asynchronous", + "event-loop" + ], + "support": { + "issues": "https://github.com/reactphp/event-loop/issues", + "source": "https://github.com/reactphp/event-loop/tree/v1.3.0" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2022-03-17T11:10:22+00:00" + }, + { + "name": "react/http", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/http.git", + "reference": "59961cc4a5b14481728f07c591546be18fa3a5c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/http/zipball/59961cc4a5b14481728f07c591546be18fa3a5c7", + "reference": "59961cc4a5b14481728f07c591546be18fa3a5c7", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "fig/http-message-util": "^1.1", + "php": ">=5.3.0", + "psr/http-message": "^1.0", + "react/event-loop": "^1.2", + "react/promise": "^2.3 || ^1.2.1", + "react/promise-stream": "^1.1", + "react/socket": "^1.9", + "react/stream": "^1.2", + "ringcentral/psr7": "^1.2" + }, + "require-dev": { + "clue/block-react": "^1.5", + "clue/http-proxy-react": "^1.7", + "clue/reactphp-ssh-proxy": "^1.3", + "clue/socks-react": "^1.3", + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Http\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Event-driven, streaming HTTP client and server implementation for ReactPHP", + "keywords": [ + "async", + "client", + "event-driven", + "http", + "http client", + "http server", + "https", + "psr-7", + "reactphp", + "server", + "streaming" + ], + "support": { + "issues": "https://github.com/reactphp/http/issues", + "source": "https://github.com/reactphp/http/tree/v1.6.0" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2022-02-03T13:17:37+00:00" + }, + { + "name": "react/promise", + "version": "v2.9.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/promise.git", + "reference": "234f8fd1023c9158e2314fa9d7d0e6a83db42910" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/promise/zipball/234f8fd1023c9158e2314fa9d7d0e6a83db42910", + "reference": "234f8fd1023c9158e2314fa9d7d0e6a83db42910", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.36" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "React\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "A lightweight implementation of CommonJS Promises/A for PHP", + "keywords": [ + "promise", + "promises" + ], + "support": { + "issues": "https://github.com/reactphp/promise/issues", + "source": "https://github.com/reactphp/promise/tree/v2.9.0" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2022-02-11T10:27:51+00:00" + }, + { + "name": "react/promise-stream", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/promise-stream.git", + "reference": "ef05517b99e4363beaa7993d4e2d6c50f1b22a09" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/promise-stream/zipball/ef05517b99e4363beaa7993d4e2d6c50f1b22a09", + "reference": "ef05517b99e4363beaa7993d4e2d6c50f1b22a09", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "react/promise": "^3 || ^2.1 || ^1.2", + "react/stream": "^1.0 || ^0.7 || ^0.6 || ^0.5 || ^0.4.6" + }, + "require-dev": { + "clue/block-react": "^1.0", + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35", + "react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3", + "react/promise-timer": "^1.0" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "React\\Promise\\Stream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "The missing link between Promise-land and Stream-land for ReactPHP", + "homepage": "https://github.com/reactphp/promise-stream", + "keywords": [ + "Buffer", + "async", + "promise", + "reactphp", + "stream", + "unwrap" + ], + "support": { + "issues": "https://github.com/reactphp/promise-stream/issues", + "source": "https://github.com/reactphp/promise-stream/tree/v1.4.0" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2022-06-20T10:36:51+00:00" + }, + { + "name": "react/promise-timer", + "version": "v1.9.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/promise-timer.git", + "reference": "aa7a73c74b8d8c0f622f5982ff7b0351bc29e495" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/promise-timer/zipball/aa7a73c74b8d8c0f622f5982ff7b0351bc29e495", + "reference": "aa7a73c74b8d8c0f622f5982ff7b0351bc29e495", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "react/event-loop": "^1.2", + "react/promise": "^3.0 || ^2.7.0 || ^1.2.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "React\\Promise\\Timer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "A trivial implementation of timeouts for Promises, built on top of ReactPHP.", + "homepage": "https://github.com/reactphp/promise-timer", + "keywords": [ + "async", + "event-loop", + "promise", + "reactphp", + "timeout", + "timer" + ], + "support": { + "issues": "https://github.com/reactphp/promise-timer/issues", + "source": "https://github.com/reactphp/promise-timer/tree/v1.9.0" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2022-06-13T13:41:03+00:00" + }, + { + "name": "react/socket", + "version": "v1.11.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/socket.git", + "reference": "f474156aaab4f09041144fa8b57c7d70aed32a1c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/socket/zipball/f474156aaab4f09041144fa8b57c7d70aed32a1c", + "reference": "f474156aaab4f09041144fa8b57c7d70aed32a1c", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.0", + "react/dns": "^1.8", + "react/event-loop": "^1.2", + "react/promise": "^2.6.0 || ^1.2.1", + "react/promise-timer": "^1.8", + "react/stream": "^1.2" + }, + "require-dev": { + "clue/block-react": "^1.5", + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35", + "react/promise-stream": "^1.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Socket\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP", + "keywords": [ + "Connection", + "Socket", + "async", + "reactphp", + "stream" + ], + "support": { + "issues": "https://github.com/reactphp/socket/issues", + "source": "https://github.com/reactphp/socket/tree/v1.11.0" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2022-01-14T10:14:32+00:00" + }, + { + "name": "react/stream", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/stream.git", + "reference": "7a423506ee1903e89f1e08ec5f0ed430ff784ae9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/stream/zipball/7a423506ee1903e89f1e08ec5f0ed430ff784ae9", + "reference": "7a423506ee1903e89f1e08ec5f0ed430ff784ae9", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.8", + "react/event-loop": "^1.2" + }, + "require-dev": { + "clue/stream-filter": "~1.2", + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Stream\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Event-driven readable and writable streams for non-blocking I/O in ReactPHP", + "keywords": [ + "event-driven", + "io", + "non-blocking", + "pipe", + "reactphp", + "readable", + "stream", + "writable" + ], + "support": { + "issues": "https://github.com/reactphp/stream/issues", + "source": "https://github.com/reactphp/stream/tree/v1.2.0" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2021-07-11T12:37:55+00:00" + }, + { + "name": "ringcentral/psr7", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/ringcentral/psr7.git", + "reference": "360faaec4b563958b673fb52bbe94e37f14bc686" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ringcentral/psr7/zipball/360faaec4b563958b673fb52bbe94e37f14bc686", + "reference": "360faaec4b563958b673fb52bbe94e37f14bc686", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "psr/http-message": "~1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "RingCentral\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "PSR-7 message implementation", + "keywords": [ + "http", + "message", + "stream", + "uri" + ], + "support": { + "source": "https://github.com/ringcentral/psr7/tree/master" + }, + "time": "2018-05-29T20:21:04+00:00" + }, { "name": "spatie/laravel-permission", "version": "5.3.2", @@ -4319,6 +5833,94 @@ ], "time": "2022-04-04T10:19:07+00:00" }, + { + "name": "symfony/psr-http-message-bridge", + "version": "v2.1.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/psr-http-message-bridge.git", + "reference": "22b37c8a3f6b5d94e9cdbd88e1270d96e2f97b34" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/22b37c8a3f6b5d94e9cdbd88e1270d96e2f97b34", + "reference": "22b37c8a3f6b5d94e9cdbd88e1270d96e2f97b34", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "psr/http-message": "^1.0", + "symfony/http-foundation": "^4.4 || ^5.0 || ^6.0" + }, + "require-dev": { + "nyholm/psr7": "^1.1", + "psr/log": "^1.1 || ^2 || ^3", + "symfony/browser-kit": "^4.4 || ^5.0 || ^6.0", + "symfony/config": "^4.4 || ^5.0 || ^6.0", + "symfony/event-dispatcher": "^4.4 || ^5.0 || ^6.0", + "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0", + "symfony/http-kernel": "^4.4 || ^5.0 || ^6.0", + "symfony/phpunit-bridge": "^5.4@dev || ^6.0" + }, + "suggest": { + "nyholm/psr7": "For a super lightweight PSR-7/17 implementation" + }, + "type": "symfony-bridge", + "extra": { + "branch-alias": { + "dev-main": "2.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Bridge\\PsrHttpMessage\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "PSR HTTP message bridge", + "homepage": "http://symfony.com", + "keywords": [ + "http", + "http-message", + "psr-17", + "psr-7" + ], + "support": { + "issues": "https://github.com/symfony/psr-http-message-bridge/issues", + "source": "https://github.com/symfony/psr-http-message-bridge/tree/v2.1.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-11-05T13:13:39+00:00" + }, { "name": "symfony/routing", "version": "v4.4.41", @@ -5090,59 +6692,6 @@ }, "time": "2022-02-23T20:20:52+00:00" }, - { - "name": "facade/ignition-contracts", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/facade/ignition-contracts.git", - "reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/facade/ignition-contracts/zipball/3c921a1cdba35b68a7f0ccffc6dffc1995b18267", - "reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267", - "shasum": "" - }, - "require": { - "php": "^7.3|^8.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^v2.15.8", - "phpunit/phpunit": "^9.3.11", - "vimeo/psalm": "^3.17.1" - }, - "type": "library", - "autoload": { - "psr-4": { - "Facade\\IgnitionContracts\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Freek Van der Herten", - "email": "freek@spatie.be", - "homepage": "https://flareapp.io", - "role": "Developer" - } - ], - "description": "Solution contracts for Ignition", - "homepage": "https://github.com/facade/ignition-contracts", - "keywords": [ - "contracts", - "flare", - "ignition" - ], - "support": { - "issues": "https://github.com/facade/ignition-contracts/issues", - "source": "https://github.com/facade/ignition-contracts/tree/1.0.2" - }, - "time": "2020-10-16T08:27:54+00:00" - }, { "name": "fakerphp/faker", "version": "v1.20.0", From 7bd32293a64f28d0b0d6ee3da7ffdfbefa1cff6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Mon, 8 Aug 2022 14:20:54 +0800 Subject: [PATCH 41/68] =?UTF-8?q?feat:=20#10000=20=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E5=9F=9F=E5=90=8D=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php index 27fd06d..979be48 100644 --- a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php +++ b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php @@ -109,7 +109,7 @@ class KuaiTuanTuan extends BusinessClient return strtoupper(md5($str)); } - public function doRequest($type, $appendParams = [], $url = 'http://gw-api.pinduoduo.com/api/router') + public function doRequest($type, $appendParams = [], $url = 'https://gw-api.pinduoduo.com/api/router') { $publicParams = [ 'type' => $type, From d8373b8fc78eec36fd71d416ca5792de14d820e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Mon, 8 Aug 2022 15:05:17 +0800 Subject: [PATCH 42/68] =?UTF-8?q?feat:=20#10000=20=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=AF=B7=E4=BC=98=E5=8C=96=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/Business/BusinessClient.php | 41 +++++++++++-------- .../Business/KuaiTuanTuan/KuaiTuanTuan.php | 16 ++------ app/Services/Business/MiaoXuan/Goods.php | 13 +++--- app/Services/Business/MiaoXuan/MiaoXuan.php | 11 +---- composer.json | 1 + composer.lock | 5 ++- 6 files changed, 41 insertions(+), 46 deletions(-) diff --git a/app/Services/Business/BusinessClient.php b/app/Services/Business/BusinessClient.php index cbc6eac..af1c81d 100644 --- a/app/Services/Business/BusinessClient.php +++ b/app/Services/Business/BusinessClient.php @@ -10,6 +10,7 @@ abstract class BusinessClient protected $redirectUri = 'http://erp.chutang66.com/callback'; protected $code; protected $shop; + protected $skuId = 0; abstract public function auth(); @@ -51,39 +52,47 @@ abstract class BusinessClient return $this->shop; } - protected function setCode($code) + public function setCode($code) { $this->code = $code; return $this; } - protected function getCode() + public function getCode() { return $this->code; } + public function setSkuId($skuId) + { + $this->skuId = $skuId; + + return $this; + } + + public function getSkuId() + { + return $this->skuId; + } + public function formDataPostRequest($url, $params) { $headers = [ - 'headers' => ['Content-type' => 'multipart/form-data;charset=UTF-8'], + 'headers' => ['Content-type' => 'application/x-www-form-urlencoded;charset=UTF-8'], 'form_params' => $params ]; $res = (new Client())->request('POST', $url, $headers); $res = json_decode($res->getBody()->getContents(), true); - if (isset($res['error_response'])) { - $log = new Log(); - $log->module = 'plat'; - $log->action = 'POST'; - $log->target_type = 'kuaituantuan'; - $log->target_id = 0; - $log->target_field = '更新库存'; - $log->user_id = 1; - $log->message = json_encode($res, 256); - $log->save(); - - throw new \Exception($res['error_response']['error_msg'], $res['error_response']['error_code']); - } + $log = new Log(); + $log->module = 'plat'; + $log->action = 'POST'; + $log->target_type = $this->shop->plat_id; + $log->target_id = $this->skuId; + $log->target_field = $params['type']; + $log->user_id = 1; + $log->message = json_encode($res, 256); + $log->save(); return $res; } diff --git a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php index 979be48..e63da0c 100644 --- a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php +++ b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php @@ -2,7 +2,6 @@ namespace App\Services\Business\KuaiTuanTuan; -use App\Listeners\BindBusinessGoods; use App\Models\BusinessGoodsSku; use App\Models\GoodsSku; use App\Services\Business\BusinessClient; @@ -40,7 +39,7 @@ class KuaiTuanTuan extends BusinessClient public function downloadGoods($page = 1) { [$type, $appendParams] = Goods::downloadGoods($this->shop->owner_name, $page); - $res = $this->formDataPostRequest($type, $appendParams); + $res = $this->doRequest($type, $appendParams); $goods = $res['ktt_goods_query_list_response']['goods_list']; $this->bindGoods($goods); $pageNum = ceil($res['total'] / $appendParams['size']); @@ -59,16 +58,7 @@ class KuaiTuanTuan extends BusinessClient $goodsSku = GoodsSku::query()->find($skuId); $business = BusinessGoodsSku::query()->where('shop_id', $this->shop->id)->where('self_sku_id', $skuId)->first(['goods_id', 'sku_id']); [$type, $appendParams] = Goods::incrQuantity($business->goodsId, $goodsSku->stock, $business->sku_id); - $this->formDataPostRequest($type, $appendParams); - $log = new Log(); - $log->module = 'plat'; - $log->action = 'POST'; - $log->target_type = 'kuaituantuan'; - $log->target_id = 0; - $log->target_field = $type; - $log->user_id = 1; - $log->message = 'success'; - $log->save(); + $this->doRequest($type, $appendParams); } public function downloadOrders($beginTime, $endTime, $activityNo, $downloadType = 'default') @@ -78,7 +68,7 @@ class KuaiTuanTuan extends BusinessClient } else { [$type, $appendParams] = Order::downloadOrders($beginTime, $endTime, $activityNo); } - $res = $this->formDataPostRequest($type, $appendParams); + $res = $this->doRequest($type, $appendParams); return $res['ktt_order_list_response']['order_list']; diff --git a/app/Services/Business/MiaoXuan/Goods.php b/app/Services/Business/MiaoXuan/Goods.php index 06ceddf..8276fa6 100644 --- a/app/Services/Business/MiaoXuan/Goods.php +++ b/app/Services/Business/MiaoXuan/Goods.php @@ -19,11 +19,14 @@ class Goods public static function incrQuantity($shopId, $quantity, $businessGoods) { return [ - 'stock' => $quantity, - 'business_sku_id' => $businessGoods['sku_id'], - 'business_goods_id' => $businessGoods['goods_id'], - 'erp_shop_id' => $shopId, - 'erp_sku_id' => $businessGoods['external_sku_id'] + 'data' => [ + 'stock' => $quantity, + 'business_sku_id' => $businessGoods['sku_id'], + 'business_goods_id' => $businessGoods['goods_id'], + 'erp_shop_id' => $shopId, + 'erp_sku_id' => $businessGoods['external_sku_id'], + ], + 'type' => '更新库存', ]; } } diff --git a/app/Services/Business/MiaoXuan/MiaoXuan.php b/app/Services/Business/MiaoXuan/MiaoXuan.php index 3415a33..300b967 100644 --- a/app/Services/Business/MiaoXuan/MiaoXuan.php +++ b/app/Services/Business/MiaoXuan/MiaoXuan.php @@ -29,17 +29,8 @@ class MiaoXuan extends BusinessClient $goodsSku = GoodsSku::query()->find($skuId); $business = BusinessGoodsSku::query()->where('shop_id', $this->shop->id)->where('self_sku_id', $skuId)->first(['goods_id', 'sku_id', 'external_sku_id'])->toArray(); $appendParams = Goods::incrQuantity($this->shop->id, $goodsSku->stock, $business); - $url = ''; // http://shop.chutang66.com/miaoxuan/stock + $url = 'http://shop.chutang66.com/miaoxuan/stock'; $this->formDataPostRequest($url, $appendParams); - $log = new Log(); - $log->module = 'plat'; - $log->action = 'POST'; - $log->target_type = 'miaoxuan'; - $log->target_id = 0; - $log->target_field = '更新库存'; - $log->user_id = 1; - $log->message = 'success'; - $log->save(); } public function downloadOrders($beginTime, $endTime, $activityNo, $downloadType = 'default') diff --git a/composer.json b/composer.json index d12ec93..979cd8b 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,7 @@ "license": "MIT", "require": { "php": "^7.2.5|^8.0", + "ext-json": "^1.7", "aliyuncs/oss-sdk-php": "^2.5", "beyondcode/laravel-websockets": "^1.13", "fideloper/proxy": "^4.4", diff --git a/composer.lock b/composer.lock index 9b5df2a..1e34c06 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0d3d2fbbec4c9922fb38612b6fa05ac0", + "content-hash": "5a01163bdf570af5226c567ad02f45d7", "packages": [ { "name": "aliyuncs/oss-sdk-php", @@ -9109,7 +9109,8 @@ "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": "^7.2.5|^8.0" + "php": "^7.2.5|^8.0", + "ext-json": "^1.7" }, "platform-dev": [], "plugin-api-version": "2.3.0" From a4d9d6cc9a3f155ee907fe9523e615d45e1e34c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Mon, 8 Aug 2022 15:11:16 +0800 Subject: [PATCH 43/68] =?UTF-8?q?feat:=20#10000=20json=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 979cd8b..4bbc05d 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "license": "MIT", "require": { "php": "^7.2.5|^8.0", - "ext-json": "^1.7", + "ext-json": "*", "aliyuncs/oss-sdk-php": "^2.5", "beyondcode/laravel-websockets": "^1.13", "fideloper/proxy": "^4.4", From d86418ea8cf3fd5cc6b3ef667da47af329de8e78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Mon, 8 Aug 2022 16:00:47 +0800 Subject: [PATCH 44/68] =?UTF-8?q?feat:=20#10000=20=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/Test.php | 48 +++++++++++++++++++ .../Controllers/Goods/GoodsSkusController.php | 3 +- app/Http/Requests/GoodsSkuRequest.php | 10 ++-- app/Models/Shop.php | 4 +- app/Services/Business/BusinessClient.php | 3 ++ .../Business/KuaiTuanTuan/KuaiTuanTuan.php | 4 +- .../2022_08_02_022448_create_shops_table.php | 4 +- ...30834_create_business_goods_skus_table.php | 20 ++++---- ...05_093629_create_business_orders_table.php | 16 +++---- ...3658_create_business_order_items_table.php | 16 +++---- 10 files changed, 92 insertions(+), 36 deletions(-) create mode 100644 app/Console/Commands/Test.php diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php new file mode 100644 index 0000000..cda01ab --- /dev/null +++ b/app/Console/Commands/Test.php @@ -0,0 +1,48 @@ +find(2); + $business = BusinessFactory::init()->make($shop->plat_id); + $business->setShop($shop); + $res = $business->downloadGoods(); + var_dump($res); + } +} diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index 71a6e25..3cf21f9 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -119,7 +119,8 @@ class GoodsSkusController extends Controller Rule::exists('goods_skus', 'id'), ], ]; - $validator = $this->validateUpdate($request->all(), $appendRules); + $skuRules = (new GoodsSkuRequest())->arrayRules('skus.*.'); + $validator = Validator::make($request->all(), array_merge($appendRules, $skuRules)); if ($validator->fails()) { $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); diff --git a/app/Http/Requests/GoodsSkuRequest.php b/app/Http/Requests/GoodsSkuRequest.php index c403df0..c12ba05 100644 --- a/app/Http/Requests/GoodsSkuRequest.php +++ b/app/Http/Requests/GoodsSkuRequest.php @@ -27,11 +27,11 @@ class GoodsSkuRequest extends FormRequest return [ 'id' => ['sometimes', 'required', 'integer', 'exists:goods_skus,id'], 'goods_id' => ['sometimes', 'required', 'integer', 'exists:goods,id'], - 'title' => ['required', 'string', 'max:255'], - 'sku_code' => ['required', 'distinct', 'alpha_dash', 'max:32'], - 'status' => ['required', 'integer', Rule::in([0, 1, 2])], - 'num' => ['required', 'integer'], - 'cost' => ['required', 'numeric'], + 'title' => ['sometimes', 'required', 'string', 'max:255'], + 'sku_code' => ['sometimes', 'required', 'distinct', 'alpha_dash', 'max:32'], + 'status' => ['sometimes', 'required', 'integer', Rule::in([0, 1, 2])], + 'num' => ['sometimes', 'required', 'integer'], + 'cost' => ['sometimes', 'required', 'numeric'], 'reference_price' => [ 'sometimes', 'numeric', diff --git a/app/Models/Shop.php b/app/Models/Shop.php index cee46e5..f45960b 100644 --- a/app/Models/Shop.php +++ b/app/Models/Shop.php @@ -16,7 +16,9 @@ class Shop extends Model 'pop_auth_token_create_response', ]; - protected $guarded = []; + protected $fillable = [ + 'access_token', 'expires_at', 'expires_in', 'owner_id', 'owner_name', 'refresh_token', 'refresh_token_expires_at', 'refresh_token_expires_in', 'scope', 'pop_auth_token_create_response', 'status' + ]; public function getStatusAttribute($value) { diff --git a/app/Services/Business/BusinessClient.php b/app/Services/Business/BusinessClient.php index af1c81d..4ef76d3 100644 --- a/app/Services/Business/BusinessClient.php +++ b/app/Services/Business/BusinessClient.php @@ -93,6 +93,9 @@ abstract class BusinessClient $log->user_id = 1; $log->message = json_encode($res, 256); $log->save(); + if (isset($res['error_response'])) { + throw new \Exception($res['error_response']['error_msg'], $res['error_response']['error_code']); + } return $res; } diff --git a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php index e63da0c..143f07d 100644 --- a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php +++ b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php @@ -30,7 +30,9 @@ class KuaiTuanTuan extends BusinessClient public function auth() { $accessToken = $this->getAccessTokenWithCode(); + $accessToken['scope'] = json_encode($accessToken['scope'], 256); $accessToken['pop_auth_token_create_response'] = json_encode($accessToken, 256); + $accessToken['status'] = 1; $this->shop->update($accessToken); return $this->shop; @@ -107,7 +109,7 @@ class KuaiTuanTuan extends BusinessClient 'timestamp' => time() ]; if ('pdd.pop.auth.token.create' !== $type) { - $publicParams['access_token'] = $this->getAccessToken(); + $publicParams['access_token'] = $this->getShop()->access_token; } $publicParams = array_merge($publicParams, $appendParams); $publicParams['sign'] = $this->getSign($publicParams); diff --git a/database/migrations/2022_08_02_022448_create_shops_table.php b/database/migrations/2022_08_02_022448_create_shops_table.php index 7fddb77..2cdeb16 100644 --- a/database/migrations/2022_08_02_022448_create_shops_table.php +++ b/database/migrations/2022_08_02_022448_create_shops_table.php @@ -18,12 +18,12 @@ class CreateShopsTable extends Migration $table->string('name')->unique(); $table->unsignedTinyInteger('plat_id')->comment('平台id'); $table->string('access_token')->nullable(); - $table->unsignedMediumInteger('expires_at')->nullable()->comment('access_token过期时间点'); + $table->unsignedBigInteger('expires_at')->nullable()->comment('access_token过期时间点'); $table->unsignedInteger('expires_in')->nullable()->comment('access_token过期时间段,10(表示10秒后过期)'); $table->string('owner_id')->nullable()->comment('商家店铺id'); $table->string('owner_name')->nullable()->comment('商家账号名称'); $table->string('refresh_token')->nullable()->comment('refresh token,可用来刷新access_token'); - $table->unsignedMediumInteger('refresh_token_expires_at')->nullable()->comment('Refresh token过期时间点'); + $table->unsignedBigInteger('refresh_token_expires_at')->nullable()->comment('Refresh token过期时间点'); $table->unsignedInteger('refresh_token_expires_in')->nullable()->comment('refresh_token过期时间段,10表示10秒后过期'); $table->text('scope')->nullable()->comment('接口列表'); $table->text('pop_auth_token_create_response')->nullable()->comment('授权认证信息'); diff --git a/database/migrations/2022_08_05_030834_create_business_goods_skus_table.php b/database/migrations/2022_08_05_030834_create_business_goods_skus_table.php index 18c9b5b..7a84e15 100644 --- a/database/migrations/2022_08_05_030834_create_business_goods_skus_table.php +++ b/database/migrations/2022_08_05_030834_create_business_goods_skus_table.php @@ -19,27 +19,27 @@ class CreateBusinessGoodsSkusTable extends Migration $table->bigInteger('self_sku_id')->nullable(); $table->string('activity_no')->nullable(); $table->string('category_name')->nullable(); - $table->mediumInteger('create_time')->nullable(); + $table->bigInteger('create_time')->nullable(); $table->text('goods_desc')->nullable(); $table->string('goods_id')->nullable(); $table->text('goods_image_list')->nullable(); $table->string('goods_name')->nullable(); $table->integer('is_activity_delete')->nullable(); $table->integer('limit_buy')->nullable(); - $table->mediumInteger('market_price')->nullable(); - $table->mediumInteger('update_time')->nullable(); + $table->bigInteger('market_price')->nullable(); + $table->bigInteger('update_time')->nullable(); $table->string('external_sku_id')->nullable(); - $table->mediumInteger('goods_purchase_price')->nullable(); - $table->mediumInteger('price_in_fen')->nullable(); - $table->mediumInteger('quantity')->nullable(); + $table->bigInteger('goods_purchase_price')->nullable(); + $table->bigInteger('price_in_fen')->nullable(); + $table->bigInteger('quantity')->nullable(); $table->integer('quantity_type')->nullable(); - $table->mediumInteger('reserve_quantity')->nullable(); - $table->mediumInteger('sku_id')->nullable(); - $table->mediumInteger('sold_quantity')->nullable(); + $table->bigInteger('reserve_quantity')->nullable(); + $table->bigInteger('sku_id')->nullable(); + $table->bigInteger('sold_quantity')->nullable(); $table->text('spec_list')->nullable(); $table->string('spec_name')->nullable(); $table->string('thumb_url')->nullable(); - $table->mediumInteger('total_quantity')->nullable(); + $table->bigInteger('total_quantity')->nullable(); $table->timestamps(); }); } diff --git a/database/migrations/2022_08_05_093629_create_business_orders_table.php b/database/migrations/2022_08_05_093629_create_business_orders_table.php index 7561823..69baab2 100644 --- a/database/migrations/2022_08_05_093629_create_business_orders_table.php +++ b/database/migrations/2022_08_05_093629_create_business_orders_table.php @@ -18,22 +18,22 @@ class CreateBusinessOrdersTable extends Migration $table->integer('shop_id'); $table->bigInteger('activity_no')->nullable(); $table->string('activity_title')->nullable(); - $table->mediumInteger('after_sales_status')->nullable(); + $table->bigInteger('after_sales_status')->nullable(); $table->string('business_note')->nullable(); $table->string('buyer_memo')->nullable(); $table->integer('cancel_status')->nullable(); - $table->mediumInteger('confirm_at')->nullable(); - $table->mediumInteger('discount_amount')->nullable(); + $table->bigInteger('confirm_at')->nullable(); + $table->bigInteger('discount_amount')->nullable(); $table->string('help_sell_nickname')->nullable(); $table->string('inner_transaction_id')->nullable(); $table->boolean('is_supplier')->nullable(); $table->integer('logistics_type')->nullable(); $table->integer('mall_activity_type')->nullable(); $table->string('nick_name')->nullable(); - $table->mediumInteger('order_amount')->nullable(); + $table->bigInteger('order_amount')->nullable(); $table->string('order_sn')->nullable(); $table->integer('participate_no')->nullable(); - $table->mediumInteger('platform_discount_amount')->nullable(); + $table->bigInteger('platform_discount_amount')->nullable(); $table->string('receiver_address_city')->nullable(); $table->string('receiver_address_detail')->nullable(); $table->string('receiver_address_district')->nullable(); @@ -46,12 +46,12 @@ class CreateBusinessOrdersTable extends Migration $table->string('self_pick_up_contact_mobile')->nullable(); $table->string('self_pick_up_contact_name')->nullable(); $table->string('self_pick_up_site_name')->nullable(); - $table->mediumInteger('service_amount')->nullable(); - $table->mediumInteger('shipping_amount')->nullable(); + $table->bigInteger('service_amount')->nullable(); + $table->bigInteger('shipping_amount')->nullable(); $table->integer('shipping_status')->nullable(); $table->string('supply_activity_no')->nullable(); $table->integer('supply_participate_no')->nullable(); - $table->mediumInteger('theoretical_refund_amount')->nullable(); + $table->bigInteger('theoretical_refund_amount')->nullable(); $table->string('transaction_id')->nullable(); $table->integer('verification_status')->nullable(); $table->timestamps(); diff --git a/database/migrations/2022_08_05_093658_create_business_order_items_table.php b/database/migrations/2022_08_05_093658_create_business_order_items_table.php index 325103c..0495831 100644 --- a/database/migrations/2022_08_05_093658_create_business_order_items_table.php +++ b/database/migrations/2022_08_05_093658_create_business_order_items_table.php @@ -21,21 +21,21 @@ class CreateBusinessOrderItemsTable extends Migration $table->integer('cancel_status')->nullable(); $table->string('category_name')->nullable(); $table->string('external_sku_id')->nullable(); - $table->mediumInteger('goods_amount')->nullable(); - $table->mediumInteger('goods_cost_price')->nullable(); - $table->mediumInteger('goods_id')->nullable(); + $table->bigInteger('goods_amount')->nullable(); + $table->bigInteger('goods_cost_price')->nullable(); + $table->bigInteger('goods_id')->nullable(); $table->string('goods_name')->nullable(); $table->integer('goods_number')->nullable(); - $table->mediumInteger('goods_price')->nullable(); - $table->mediumInteger('goods_purchase_price')->nullable(); + $table->bigInteger('goods_price')->nullable(); + $table->bigInteger('goods_purchase_price')->nullable(); $table->string('goods_specification')->nullable(); - $table->mediumInteger('help_sell_amount')->nullable(); + $table->bigInteger('help_sell_amount')->nullable(); $table->boolean('is_supplier')->nullable(); $table->integer('need_verification_number')->nullable(); $table->integer('shipping_status')->nullable(); - $table->mediumInteger('sku_id')->nullable(); + $table->bigInteger('sku_id')->nullable(); $table->string('sub_order_sn')->nullable(); - $table->mediumInteger('theoretically_refund_amount')->nullable(); + $table->bigInteger('theoretically_refund_amount')->nullable(); $table->string('thumb_url')->nullable(); $table->integer('verification_number')->nullable(); $table->timestamps(); From 73cebca1e5080995101749d8806373c98cb296e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Mon, 8 Aug 2022 17:20:49 +0800 Subject: [PATCH 45/68] =?UTF-8?q?feat:=20#10000=20=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E8=BF=94=E5=9B=9E=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Goods/GoodsSkusController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index 3cf21f9..ffbcffe 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -56,7 +56,7 @@ class GoodsSkusController extends Controller $query->with(['type:id,name', 'brand:id,name']); }]) ->with(['daily' => function ($query) use ($day) { - return $query->where('day', $day)->first(['id', 'sku_id', 'day', 'arrived_today_num', 'loss_num', 'inventory']); + $query->where('day', $day)->first(['arrived_today_num', 'loss_num', 'inventory']); }]) ->paginate(); From 8c3d717561d9890d008c94629b8711345b0ef23c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Mon, 8 Aug 2022 17:25:12 +0800 Subject: [PATCH 46/68] =?UTF-8?q?feat:=20#10000=20=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E8=BF=94=E5=9B=9E=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Goods/GoodsSkusController.php | 2 +- app/Models/DailyStockRecord.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index ffbcffe..dc16c7d 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -56,7 +56,7 @@ class GoodsSkusController extends Controller $query->with(['type:id,name', 'brand:id,name']); }]) ->with(['daily' => function ($query) use ($day) { - $query->where('day', $day)->first(['arrived_today_num', 'loss_num', 'inventory']); + $query->where('day', $day); }]) ->paginate(); diff --git a/app/Models/DailyStockRecord.php b/app/Models/DailyStockRecord.php index 7f609c6..84c1c61 100644 --- a/app/Models/DailyStockRecord.php +++ b/app/Models/DailyStockRecord.php @@ -4,5 +4,5 @@ namespace App\Models; class DailyStockRecord extends Model { - + protected $hidden = ['created_at', 'updated_at']; } From 942d46f7a9de094389f9eb21aaa8d706c6165388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Mon, 8 Aug 2022 18:53:38 +0800 Subject: [PATCH 47/68] =?UTF-8?q?feat:=20#10000=20=E5=AF=B9=E6=8E=A5?= =?UTF-8?q?=E5=BF=AB=E5=9B=A2=E5=9B=A2=E6=B5=8B=E8=AF=95=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/Test.php | 10 ++++-- app/Services/Business/BusinessClient.php | 31 +++++++++++++------ app/Services/Business/KuaiTuanTuan/Goods.php | 11 +++++-- .../Business/KuaiTuanTuan/KuaiTuanTuan.php | 28 +++++++++++++---- app/Services/Business/MiaoXuan/MiaoXuan.php | 7 ++++- ...03559_create_daily_stock_records_table.php | 2 +- 6 files changed, 66 insertions(+), 23 deletions(-) diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index cda01ab..b8ce985 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -2,6 +2,7 @@ namespace App\Console\Commands; +use App\Models\GoodsSku; use App\Models\Shop; use App\Services\Business\BusinessFactory; use Illuminate\Console\Command; @@ -42,7 +43,12 @@ class Test extends Command $shop = Shop::query()->find(2); $business = BusinessFactory::init()->make($shop->plat_id); $business->setShop($shop); - $res = $business->downloadGoods(); - var_dump($res); + // 下载商品 + $business->downloadGoods(1); + + // 库存修改 +// $business->incrQuantity(1); + + $this->info('执行测试成功'); } } diff --git a/app/Services/Business/BusinessClient.php b/app/Services/Business/BusinessClient.php index 4ef76d3..dd7b1c5 100644 --- a/app/Services/Business/BusinessClient.php +++ b/app/Services/Business/BusinessClient.php @@ -1,6 +1,7 @@ request('POST', $url, $headers); $res = json_decode($res->getBody()->getContents(), true); - $log = new Log(); - $log->module = 'plat'; - $log->action = 'POST'; - $log->target_type = $this->shop->plat_id; - $log->target_id = $this->skuId; - $log->target_field = $params['type']; - $log->user_id = 1; - $log->message = json_encode($res, 256); - $log->save(); + $disableLogType = [ + 'pdd.ktt.goods.query.list', + 'pdd.ktt.order.list', + 'pdd.ktt.increment.order.query' + ]; + if (!in_array($params['type'], $disableLogType, true)) { + $log = new Log(); + $log->module = 'plat'; + $log->action = 'POST'; + $log->target_type = $this->shop->plat_id; + $log->target_id = $this->skuId; + $log->target_field = $params['type']; + $log->user_id = 1; + $log->message = json_encode($res, 256); + $log->save(); + } + if (isset($res['error_response'])) { throw new \Exception($res['error_response']['error_msg'], $res['error_response']['error_code']); } diff --git a/app/Services/Business/KuaiTuanTuan/Goods.php b/app/Services/Business/KuaiTuanTuan/Goods.php index 7f4e540..90cc3cd 100644 --- a/app/Services/Business/KuaiTuanTuan/Goods.php +++ b/app/Services/Business/KuaiTuanTuan/Goods.php @@ -10,7 +10,7 @@ class Goods { $type = 'pdd.ktt.goods.query.list'; $appendParams = [ - 'activity_no' => $activityNo, // 非必填,团号(团号和创建时间只能传一个) +// 'activity_no' => $activityNo, // 非必填,团号(团号和创建时间只能传一个) 'page' => $page, 'size' => $size, // 'update_time_end' => '', // 非必填,结束最后更新时间(毫秒级时间戳) @@ -27,6 +27,7 @@ class Goods foreach ($goodsList as $businessGood) { $skuList = $businessGood['sku_list']; unset($businessGood['sku_list']); + $businessGood['goods_image_list'] = json_encode($businessGood['goods_image_list'], 256); foreach ($skuList as $sku) { $sku['spec_list'] = json_encode($sku['spec_list'], 256); $data = array_merge($businessGood, $sku); @@ -38,12 +39,16 @@ class Goods } } - public function downloadSingle($goodsId) + public static function downloadSingle($goodsId) { $type = 'pdd.ktt.goods.query.single'; $appendParams = [ - 'goods_id' => $goodsId + 'goods_id' => $goodsId, + 'page' => 1, + 'size' => 100, ]; + + return [$type, $appendParams]; } public static function incrQuantity($goodsId, $quantity, $skuId, $modifyType = 2) diff --git a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php index 143f07d..08611d9 100644 --- a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php +++ b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php @@ -38,13 +38,13 @@ class KuaiTuanTuan extends BusinessClient return $this->shop; } - public function downloadGoods($page = 1) + public function downloadGoodsList($page = 1) { - [$type, $appendParams] = Goods::downloadGoods($this->shop->owner_name, $page); + [$type, $appendParams] = Goods::downloadGoods($this->shop->owner_id, $page); $res = $this->doRequest($type, $appendParams); $goods = $res['ktt_goods_query_list_response']['goods_list']; $this->bindGoods($goods); - $pageNum = ceil($res['total'] / $appendParams['size']); + $pageNum = ceil($res['ktt_goods_query_list_response']['total'] / $appendParams['size']); if ($pageNum > $page && 10 >= $page) { $this->downloadGoods($page + 1); } @@ -57,9 +57,12 @@ class KuaiTuanTuan extends BusinessClient public function incrQuantity($skuId) { - $goodsSku = GoodsSku::query()->find($skuId); - $business = BusinessGoodsSku::query()->where('shop_id', $this->shop->id)->where('self_sku_id', $skuId)->first(['goods_id', 'sku_id']); - [$type, $appendParams] = Goods::incrQuantity($business->goodsId, $goodsSku->stock, $business->sku_id); + $goodsSku = GoodsSku::query() + ->with(['goods:id,goods_code']) + ->find($skuId); + $code = $goodsSku->goods->goods_code . '_' . $goodsSku->sku_code; + $business = BusinessGoodsSku::query()->where('shop_id', $this->shop->id)->where('external_sku_id', $code)->first(['goods_id', 'sku_id']); + [$type, $appendParams] = Goods::incrQuantity($business->goods_id, $goodsSku->stock, $business->sku_id); $this->doRequest($type, $appendParams); } @@ -124,4 +127,17 @@ class KuaiTuanTuan extends BusinessClient return "https://oauth.pinduoduo.com/authorize/ktt?client_id={$this->clientId}&redirect_uri={$this->redirectUri}&state={$state}"; } + + public function downloadGoods($skuId) + { + $goodsSku = GoodsSku::query() + ->with(['goods:id,goods_code']) + ->find($skuId); + $code = $goodsSku->goods->goods_code . '_' . $goodsSku->sku_code; + $business = BusinessGoodsSku::query()->where('shop_id', $this->shop->id)->where('external_sku_id', $code)->first(['goods_id', 'sku_id']); + [$type, $appendParams] = Goods::downloadSingle($business->goods_id); + $res = $this->doRequest($type, $appendParams); + $goods = $res['response']['result']; + $this->bindGoods([$goods]); + } } diff --git a/app/Services/Business/MiaoXuan/MiaoXuan.php b/app/Services/Business/MiaoXuan/MiaoXuan.php index 300b967..afd6faf 100644 --- a/app/Services/Business/MiaoXuan/MiaoXuan.php +++ b/app/Services/Business/MiaoXuan/MiaoXuan.php @@ -15,7 +15,7 @@ class MiaoXuan extends BusinessClient // TODO: Implement auth() method. } - public function downloadGoods() + public function downloadGoodsList() { } @@ -41,4 +41,9 @@ class MiaoXuan extends BusinessClient { Order::saveOrders($orders, $this->shop->id); } + + public function downloadGoods($skuId) + { + // TODO: Implement downloadGoods() method. + } } diff --git a/database/migrations/2022_07_26_103559_create_daily_stock_records_table.php b/database/migrations/2022_07_26_103559_create_daily_stock_records_table.php index 7d97f34..894332f 100644 --- a/database/migrations/2022_07_26_103559_create_daily_stock_records_table.php +++ b/database/migrations/2022_07_26_103559_create_daily_stock_records_table.php @@ -20,7 +20,7 @@ class CreateDailyStockRecordsTable extends Migration $table->unsignedInteger('arrived_today_num')->default(0)->comment('今日到货'); $table->unsignedInteger('loss_num')->default(0)->comment('损耗'); $table->unsignedInteger('inventory')->default(0)->comment('库存盘点'); - $table->unique('sku_id', 'day'); + $table->unique(['sku_id', 'day']); $table->timestamps(); }); } From a379270d7c83d17ccd25ecdca2e35d8d9931161f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Mon, 8 Aug 2022 20:02:08 +0800 Subject: [PATCH 48/68] =?UTF-8?q?feat:=20#10000=20=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Goods/GoodsSkusController.php | 5 +++-- app/Http/Requests/GoodsSkuRequest.php | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index dc16c7d..eb69941 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -216,12 +216,13 @@ class GoodsSkusController extends Controller return response($this->res, $this->res['httpCode']); } - private function stock($skus) + private function stock($request) { + $skus = $request->skus; $update = reset($skus); DB::beginTransaction(); try { - $sku = GoodsSku::query()->where('id', $update['id'])->get(['id', 'two_days_ago_num', 'yesterday_num', 'num', 'stock']); + $sku = GoodsSku::query()->where('id', $update['id'])->first(['id', 'two_days_ago_num', 'yesterday_num', 'num', 'stock']); $record = DailyStockRecord::query() ->where('sku_id', $sku->id) ->where('day', FormatUtils::date()) diff --git a/app/Http/Requests/GoodsSkuRequest.php b/app/Http/Requests/GoodsSkuRequest.php index c12ba05..e29cbb6 100644 --- a/app/Http/Requests/GoodsSkuRequest.php +++ b/app/Http/Requests/GoodsSkuRequest.php @@ -45,6 +45,18 @@ class GoodsSkuRequest extends FormRequest 'sometimes', 'integer', ], + 'arrived_today_num' => [ + 'sometimes', + 'integer', + ], + 'yesterday_num' => [ + 'sometimes', + 'integer', + ], + 'two_days_ago_num' => [ + 'sometimes', + 'integer', + ], 'inventory' => [ 'sometimes', 'integer', From 12b734e9160063606e3325346731b9b9fee4ae3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Tue, 9 Aug 2022 10:34:36 +0800 Subject: [PATCH 49/68] =?UTF-8?q?feat:=20#20220809=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/Test.php | 14 ++++++-- .../Controllers/Goods/GoodsController.php | 11 ++++-- .../Controllers/Goods/GoodsSkusController.php | 12 +++---- app/Http/Controllers/Menu/MenusController.php | 2 -- app/Services/Business/BusinessClient.php | 18 +++++----- .../Business/KuaiTuanTuan/KuaiTuanTuan.php | 11 +++++- app/Services/Business/KuaiTuanTuan/Order.php | 4 +-- app/Services/Business/MiaoXuan/MiaoXuan.php | 2 +- app/Utils/DateTimeUtils.php | 34 ++++++++++++++++++ app/Utils/FormatUtils.php | 14 -------- resources/templates/goods_skus_import.xlsx | Bin 11 files changed, 81 insertions(+), 41 deletions(-) create mode 100644 app/Utils/DateTimeUtils.php mode change 100644 => 100755 resources/templates/goods_skus_import.xlsx diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index b8ce985..85976af 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -2,9 +2,9 @@ namespace App\Console\Commands; -use App\Models\GoodsSku; use App\Models\Shop; use App\Services\Business\BusinessFactory; +use App\Utils\DateTimeUtils; use Illuminate\Console\Command; class Test extends Command @@ -43,12 +43,20 @@ class Test extends Command $shop = Shop::query()->find(2); $business = BusinessFactory::init()->make($shop->plat_id); $business->setShop($shop); - // 下载商品 - $business->downloadGoods(1); + // 下载商品列表 +// $business->downloadGoodsList(); + + // 下载单个商品 +// $business->downloadGoods(1); // 库存修改 // $business->incrQuantity(1); + // 订单下载 + $beginTime = DateTimeUtils::getMicroTime('2022-08-08'); + $endTime = DateTimeUtils::getMicroTime('2022-08-09'); + $business->downloadOrders($beginTime, $endTime); + $this->info('执行测试成功'); } } diff --git a/app/Http/Controllers/Goods/GoodsController.php b/app/Http/Controllers/Goods/GoodsController.php index 1d25ed8..0dedbb7 100644 --- a/app/Http/Controllers/Goods/GoodsController.php +++ b/app/Http/Controllers/Goods/GoodsController.php @@ -6,7 +6,7 @@ use App\Http\Controllers\Controller; use App\Http\Requests\GoodsSkuRequest; use App\Http\Resources\GoodsResource; use App\Models\Log as LogModel; -use App\Utils\FormatUtils; +use App\Utils\DateTimeUtils; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Validator; @@ -69,7 +69,7 @@ class GoodsController extends Controller foreach ($collection as $sku) { $newRecords[] = [ 'sku_id' => $sku['id'], - 'day' => FormatUtils::date(), + 'day' => DateTimeUtils::getToday(), ]; } $record = new DailyStockRecord(); @@ -89,6 +89,11 @@ class GoodsController extends Controller public function download() { - return Storage::download(resource_path('templates/goods_skus_import.xlsx')); + $file = resource_path('templates/goods_skus_import.xlsx'); + $headers = [ + 'Content-Type: application/xlsx', + ]; + + return response()->download($file, 'goods_skus_import.xlsx', $headers); } } diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index eb69941..664e99b 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -9,7 +9,7 @@ use App\Http\Requests\GoodsSkuRequest; use App\Models\Goods; use App\Models\Log; use App\Models\Log as LogModel; -use App\Utils\FormatUtils; +use App\Utils\DateTimeUtils; use Illuminate\Http\Request; use App\Models\GoodsSku; use App\Http\Resources\GoodsSkuResource; @@ -45,7 +45,7 @@ class GoodsSkusController extends Controller ->pluck('sku_id') ->toArray(); } - $day = FormatUtils::date(); + $day = DateTimeUtils::getToday(); $goodsSkus = GoodsSku::query() ->whereIn('goods_id', $goodsIds) ->when($ids, function ($query, $ids) { @@ -156,7 +156,7 @@ class GoodsSkusController extends Controller $costLog['after_update'] = $goodsSku->cost; $logs[] = $costLog; // 今日到货 - $record = DailyStockRecord::query()->where('sku_id', $sku['id'])->where('day', FormatUtils::date())->first(['id', 'arrived_today_num']); + $record = DailyStockRecord::query()->where('sku_id', $sku['id'])->where('day', DateTimeUtils::getToday())->first(['id', 'arrived_today_num']); $arrivedLog['target_field'] = 'arrived_today_num'; $arrivedLog['before_update'] = $record->arrived_today_num; $record->arrived_today_num += $sku['arrived_today_num']; @@ -193,7 +193,7 @@ class GoodsSkusController extends Controller 'user_id' => $request->user()->id ]; // 今日到货 - $record = DailyStockRecord::query()->where('sku_id', $sku['id'])->where('day', FormatUtils::date())->first(['id', 'inventory']); + $record = DailyStockRecord::query()->where('sku_id', $sku['id'])->where('day', DateTimeUtils::getToday())->first(['id', 'inventory']); $inventoryLog['target_field'] = 'inventory'; $inventoryLog['before_update'] = $record->inventory; $record->inventory = $sku['inventory']; @@ -225,7 +225,7 @@ class GoodsSkusController extends Controller $sku = GoodsSku::query()->where('id', $update['id'])->first(['id', 'two_days_ago_num', 'yesterday_num', 'num', 'stock']); $record = DailyStockRecord::query() ->where('sku_id', $sku->id) - ->where('day', FormatUtils::date()) + ->where('day', DateTimeUtils::getToday()) ->first(); $this->setBeforeUpdate([ 'two_days_ago_num' => $sku->two_days_ago_num, @@ -299,7 +299,7 @@ class GoodsSkusController extends Controller if ('loss_num' === $updateField) { $model = DailyStockRecord::query() ->where('sku_id', $id) - ->where('day', FormatUtils::date()) + ->where('day', DateTimeUtils::getToday()) ->first(['id', 'loss_num']); $this->log->message = $request->get('reason'); $this->setBeforeUpdate($model->loss_num); diff --git a/app/Http/Controllers/Menu/MenusController.php b/app/Http/Controllers/Menu/MenusController.php index dd50b68..4ee8538 100644 --- a/app/Http/Controllers/Menu/MenusController.php +++ b/app/Http/Controllers/Menu/MenusController.php @@ -6,8 +6,6 @@ use App\Http\Controllers\Controller; use App\Models\Log as LogModel; use App\Models\Menu; use App\Http\Resources\MenusResource; -use App\Models\User; -use App\Utils\ArrayUtils; use Illuminate\Http\Request; use Illuminate\Support\Facades\Validator; use Illuminate\Validation\Rule; diff --git a/app/Services/Business/BusinessClient.php b/app/Services/Business/BusinessClient.php index dd7b1c5..024a208 100644 --- a/app/Services/Business/BusinessClient.php +++ b/app/Services/Business/BusinessClient.php @@ -23,7 +23,7 @@ abstract class BusinessClient abstract public function incrQuantity($skuId); - abstract public function downloadOrders($beginTime, $endTime, $activityNo, $downloadType = 'default'); + abstract public function downloadOrders($beginTime, $endTime, $activityNo = '', $downloadType = 'default'); abstract public function saveOrders($orders); @@ -92,17 +92,17 @@ abstract class BusinessClient 'pdd.ktt.order.list', 'pdd.ktt.increment.order.query' ]; + $log = new Log(); + $log->module = 'plat'; + $log->action = 'POST'; + $log->target_type = $this->shop->plat_id; + $log->target_id = $this->skuId; + $log->target_field = $params['type']; + $log->user_id = 1; if (!in_array($params['type'], $disableLogType, true)) { - $log = new Log(); - $log->module = 'plat'; - $log->action = 'POST'; - $log->target_type = $this->shop->plat_id; - $log->target_id = $this->skuId; - $log->target_field = $params['type']; - $log->user_id = 1; $log->message = json_encode($res, 256); - $log->save(); } + $log->save(); if (isset($res['error_response'])) { throw new \Exception($res['error_response']['error_msg'], $res['error_response']['error_code']); diff --git a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php index 08611d9..9eaf85c 100644 --- a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php +++ b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php @@ -66,7 +66,16 @@ class KuaiTuanTuan extends BusinessClient $this->doRequest($type, $appendParams); } - public function downloadOrders($beginTime, $endTime, $activityNo, $downloadType = 'default') + /** + * 没有发起售后,未取消的订单 + * + * @param $beginTime + * @param $endTime + * @param $activityNo + * @param $downloadType + * @return mixed + */ + public function downloadOrders($beginTime, $endTime, $activityNo = '', $downloadType = 'default') { if ('increment' === $downloadType) { [$type, $appendParams] = Order::downloadIncrementOrders($beginTime, $endTime, $activityNo); diff --git a/app/Services/Business/KuaiTuanTuan/Order.php b/app/Services/Business/KuaiTuanTuan/Order.php index fed5f51..9c50b44 100644 --- a/app/Services/Business/KuaiTuanTuan/Order.php +++ b/app/Services/Business/KuaiTuanTuan/Order.php @@ -18,7 +18,7 @@ class Order 'page_number' => 1, // 页码, 必填 'page_size' => 100, // 数量, 必填, 1~100 // 非必填 - 'activity_no' => $activityNo, // 团号 +// 'activity_no' => $activityNo, // 团号 'after_sales_status' => 0, // 售后状态, 可选 0-未发起售后 1-退款中 2-退款成功 3-待处理 4-拒绝退款 6-待(顾客)退货 7-待(团长)确认退货 8-(顾客)撤销 9-(系统)关闭 'cancel_status' => 0, // 取消状态, 可选 0-未取消 1-已取消 // 'shipping_status' => '', // 发货状态 0-未发货 1-已发货 2-部分发货 3-已收货 @@ -40,7 +40,7 @@ class Order 'page_number' => 1, // 页码 'page_size' => 100, // 数量 // 非必填 - 'activity_no' => $activityNo, // 团号 +// 'activity_no' => $activityNo, // 团号 'after_sales_status' => 0, // 售后状态, 可选 0-未发起售后 1-退款中 2-退款成功 3-待处理 4-拒绝退款 6-待(顾客)退货 7-待(团长)确认退货 8-(顾客)撤销 9-(系统)关闭 'cancel_status' => 0, // 取消状态, 可选 0-未取消 1-已取消 // 'shipping_status' => '', // 发货状态 0-未发货 1-已发货 2-部分发货 3-已收货 diff --git a/app/Services/Business/MiaoXuan/MiaoXuan.php b/app/Services/Business/MiaoXuan/MiaoXuan.php index afd6faf..0b3fb35 100644 --- a/app/Services/Business/MiaoXuan/MiaoXuan.php +++ b/app/Services/Business/MiaoXuan/MiaoXuan.php @@ -33,7 +33,7 @@ class MiaoXuan extends BusinessClient $this->formDataPostRequest($url, $appendParams); } - public function downloadOrders($beginTime, $endTime, $activityNo, $downloadType = 'default') + public function downloadOrders($beginTime, $endTime, $activityNo = '', $downloadType = 'default') { } diff --git a/app/Utils/DateTimeUtils.php b/app/Utils/DateTimeUtils.php new file mode 100644 index 0000000..69d0886 --- /dev/null +++ b/app/Utils/DateTimeUtils.php @@ -0,0 +1,34 @@ + Date: Tue, 9 Aug 2022 10:57:03 +0800 Subject: [PATCH 50/68] =?UTF-8?q?feat:=20#10000=20=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Goods/GoodsSkusController.php | 6 ++++-- app/Imports/GoodsSkusImport.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index 664e99b..9e6e175 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -333,8 +333,10 @@ class GoodsSkusController extends Controller ]; } try { - $collection = Excel::import(new GoodsSkusImport(), $request->file('goodsSkus')); - $this->setAfterUpdate($collection->toArray()); + $import = new GoodsSkusImport(); + $path = $request->file('goodsSkus'); + Excel::import($import, $path); + $this->setAfterUpdate(''); $this->addLog(0, 'import'); } catch (ValidationException $exception) { $this->setValidatorFailResponse($exception->validator->getMessageBag()->getMessages()); diff --git a/app/Imports/GoodsSkusImport.php b/app/Imports/GoodsSkusImport.php index 6ca3402..639aa51 100644 --- a/app/Imports/GoodsSkusImport.php +++ b/app/Imports/GoodsSkusImport.php @@ -33,7 +33,7 @@ class GoodsSkusImport implements ToCollection, SkipsEmptyRows '*.0' => ['required', 'string', 'max:255'], '*.1' => ['required', 'string', 'max:255', 'exists:goods_types,name'], '*.2' => ['string', 'max:255', 'exists:goods_brands,name'], - '*.3' => ['required', 'alpha_dash', 'max:32', 'unique:goods,goods_code'], + '*.3' => ['required', 'alpha_dash', 'max:32'], '*.4' => ['required', 'string', 'max:255'], '*.5' => ['required', 'distinct', 'alpha_dash', 'max:32'], '*.6' => ['required', 'string', Rule::in(['下架', '在售', '预警'])], From 3d40201c179ab4c5be9b8c8ae85bebfb0d4aa50c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Tue, 9 Aug 2022 16:56:52 +0800 Subject: [PATCH 51/68] =?UTF-8?q?feat:=20#20220802=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- app/Console/Commands/Test.php | 4 +- .../Controllers/Auth/RegisterController.php | 4 +- .../Goods/GoodsBrandsController.php | 4 +- .../Controllers/Goods/GoodsSkusController.php | 1 - .../Goods/GoodsTypesController.php | 4 +- .../Permission/PermissionsController.php | 4 +- app/Http/Controllers/Role/RolesController.php | 4 +- app/Http/Controllers/Shop/ShopsController.php | 2 +- app/Http/Controllers/User/UsersController.php | 4 +- app/Http/Requests/GoodsRequest.php | 4 +- app/Http/Requests/GoodsSkuRequest.php | 2 +- app/Imports/GoodsSkusImport.php | 46 +++++++++++++------ app/Models/BusinessGoodsSku.php | 26 ++++++++++- app/Models/BusinessOrder.php | 37 ++++++++++++++- app/Services/Business/BusinessClient.php | 12 ++--- .../Business/KuaiTuanTuan/KuaiTuanTuan.php | 24 ++++++---- app/Services/Business/KuaiTuanTuan/Order.php | 14 +++--- app/Services/Business/MiaoXuan/MiaoXuan.php | 4 +- config/app.php | 2 +- config/database.php | 8 ++-- .../2014_10_12_000000_create_users_table.php | 3 ++ ..._07_26_061712_create_goods_types_table.php | 1 + ...07_26_085847_create_goods_brands_table.php | 1 + .../2022_07_26_090143_create_goods_table.php | 1 + ...2_07_26_090150_create_goods_skus_table.php | 2 + .../2022_07_28_095523_create_menus_table.php | 1 + .../2022_08_02_022448_create_shops_table.php | 1 + ...05_093629_create_business_orders_table.php | 2 +- 29 files changed, 157 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index 2267884..f93375a 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ 1. `composer install` 2. `cp .env.example .env` 3. 修改 .env 配置项为本地配置 -4. 创建数据库 `CREATE DATABASE IF NOT EXISTS `erp` DEFAULT CHARACTER SET utf8;` +4. 创建数据库 `CREATE DATABASE IF NOT EXISTS `erp` DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;` 5. `php artisan migrate` 如果数据填充没有执行成功,则需要再次执行 `php artisan migrate:fresh --seed` 6. `php artisan key:generate` 7. `php artisan update:super_admin_permissions` 更新超级管理员角色权限 diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index 85976af..dde17fa 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -40,7 +40,7 @@ class Test extends Command */ public function handle() { - $shop = Shop::query()->find(2); + $shop = Shop::query()->find(1); $business = BusinessFactory::init()->make($shop->plat_id); $business->setShop($shop); // 下载商品列表 @@ -55,7 +55,7 @@ class Test extends Command // 订单下载 $beginTime = DateTimeUtils::getMicroTime('2022-08-08'); $endTime = DateTimeUtils::getMicroTime('2022-08-09'); - $business->downloadOrders($beginTime, $endTime); + $business->downloadOrdersAndSave($beginTime, $endTime); $this->info('执行测试成功'); } diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index e48e455..dc42522 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -52,8 +52,8 @@ class RegisterController extends Controller protected function validator(array $data) { return Validator::make($data, [ - 'name' => ['required', 'string', 'unique:users', 'max:255'], - 'email' => ['string', 'email', 'max:255', 'unique:users'], + 'name' => ['required', 'string', 'unique:users', 'max:191'], + 'email' => ['string', 'email', 'max:191', 'unique:users'], 'password' => ['required', 'string', 'min:8', 'confirmed'], 'role_id' => ['required', 'numeric', 'exists:roles,id'], ]); diff --git a/app/Http/Controllers/Goods/GoodsBrandsController.php b/app/Http/Controllers/Goods/GoodsBrandsController.php index 6e54c9e..bfe167b 100644 --- a/app/Http/Controllers/Goods/GoodsBrandsController.php +++ b/app/Http/Controllers/Goods/GoodsBrandsController.php @@ -32,7 +32,7 @@ class GoodsBrandsController extends Controller { $validator = Validator::make($request->all(), [ 'names' => 'required|array', - 'names.*' => 'required|string|max:255|unique:goods_brands,name', + 'names.*' => 'required|string|max:191|unique:goods_brands,name', ]); if ($validator->fails()) { $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); @@ -68,7 +68,7 @@ class GoodsBrandsController extends Controller 'name' => [ 'required', 'string', - 'max:255', + 'max:191', Rule::unique('goods_brands')->ignore($id), ] ]); diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index 9e6e175..ab40a9b 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -336,7 +336,6 @@ class GoodsSkusController extends Controller $import = new GoodsSkusImport(); $path = $request->file('goodsSkus'); Excel::import($import, $path); - $this->setAfterUpdate(''); $this->addLog(0, 'import'); } catch (ValidationException $exception) { $this->setValidatorFailResponse($exception->validator->getMessageBag()->getMessages()); diff --git a/app/Http/Controllers/Goods/GoodsTypesController.php b/app/Http/Controllers/Goods/GoodsTypesController.php index 9a7611c..cb7afa7 100644 --- a/app/Http/Controllers/Goods/GoodsTypesController.php +++ b/app/Http/Controllers/Goods/GoodsTypesController.php @@ -32,7 +32,7 @@ class GoodsTypesController extends Controller { $validator = Validator::make($request->all(), [ 'names' => 'required|array', - 'names.*' => 'required|string|max:255|unique:goods_types,name', + 'names.*' => 'required|string|max:191|unique:goods_types,name', ]); if ($validator->fails()) { $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); @@ -68,7 +68,7 @@ class GoodsTypesController extends Controller 'name' => [ 'required', 'string', - 'max:255', + 'max:191', Rule::unique('goods_types')->ignore($id), ] ]); diff --git a/app/Http/Controllers/Permission/PermissionsController.php b/app/Http/Controllers/Permission/PermissionsController.php index 112f82b..43e4d01 100644 --- a/app/Http/Controllers/Permission/PermissionsController.php +++ b/app/Http/Controllers/Permission/PermissionsController.php @@ -39,7 +39,7 @@ class PermissionsController extends Controller public function store(Request $request) { $validator = Validator::make($request->all(), [ - 'name' => 'required|string|max:255|unique:permissions,name', + 'name' => 'required|string|max:191|unique:permissions,name', ]); if ($validator->fails()) { $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); @@ -63,7 +63,7 @@ class PermissionsController extends Controller public function update($id, Request $request) { $validator = Validator::make($request->all(), [ - 'name' => ['required', 'string', 'max:255', Rule::unique('permissions')->ignore($id),] + 'name' => ['required', 'string', 'max:191', Rule::unique('permissions')->ignore($id),] ]); if ($validator->fails()) { $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); diff --git a/app/Http/Controllers/Role/RolesController.php b/app/Http/Controllers/Role/RolesController.php index 2f861c2..1e592c7 100644 --- a/app/Http/Controllers/Role/RolesController.php +++ b/app/Http/Controllers/Role/RolesController.php @@ -40,7 +40,7 @@ class RolesController extends Controller public function store(Request $request) { $validator = Validator::make($request->all(), [ - 'name' => 'required|string|max:255|unique:roles,name', + 'name' => 'required|string|max:191|unique:roles,name', ]); if ($validator->fails()) { $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); @@ -75,7 +75,7 @@ class RolesController extends Controller public function update($id, Request $request) { $validator = Validator::make($request->all(), [ - 'name' => ['required', 'string', 'max:255', Rule::unique('roles')->ignore($id),] + 'name' => ['required', 'string', 'max:191', Rule::unique('roles')->ignore($id),] ]); if ($validator->fails()) { $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); diff --git a/app/Http/Controllers/Shop/ShopsController.php b/app/Http/Controllers/Shop/ShopsController.php index 37be306..e6fc501 100644 --- a/app/Http/Controllers/Shop/ShopsController.php +++ b/app/Http/Controllers/Shop/ShopsController.php @@ -37,7 +37,7 @@ class ShopsController extends Controller public function store(Request $request) { $validator = Validator::make($request->all(), [ - 'name' => 'required|string|max:255|unique:shops,name', + 'name' => 'required|string|max:191|unique:shops,name', 'plat_id' => 'required|integer', ]); if ($validator->fails()) { diff --git a/app/Http/Controllers/User/UsersController.php b/app/Http/Controllers/User/UsersController.php index e341bae..5a378d7 100644 --- a/app/Http/Controllers/User/UsersController.php +++ b/app/Http/Controllers/User/UsersController.php @@ -33,7 +33,7 @@ class UsersController extends Controller public function store(Request $request, Faker $faker) { $validator = Validator::make($request->all(), [ - 'name' => 'required|string|max:255|unique:users,name', + 'name' => 'required|string|max:191|unique:users,name', 'password' => 'required|string|min:8|confirmed', 'email' => 'email', 'role_name' => 'required|string|exists:roles,name' @@ -67,7 +67,7 @@ class UsersController extends Controller 'name' => [ 'required', 'string', - 'max:255', + 'max:191', Rule::unique('users')->ignore($id), ], // 'old_password' => 'sometimes|required|string|min:8', diff --git a/app/Http/Requests/GoodsRequest.php b/app/Http/Requests/GoodsRequest.php index e0ecc5f..b807bef 100644 --- a/app/Http/Requests/GoodsRequest.php +++ b/app/Http/Requests/GoodsRequest.php @@ -26,8 +26,8 @@ class GoodsRequest extends FormRequest { return [ 'id' => ['sometimes', 'required', 'integer', 'exists:goods,id'], - 'title' => ['required', 'string', 'max:255'], - 'img_url' => ['required', 'string', 'max:255'], + 'title' => ['required', 'string', 'max:191'], + 'img_url' => ['required', 'string', 'max:191'], 'type_id' => ['required', 'integer', 'exists:goods_types,id'], 'brand_id' => ['integer', 'exists:goods_brands,id'], 'goods_code' => ['required', 'alpha_dash', 'max:32', Rule::unique('goods')->ignore(request('goods_id'))], diff --git a/app/Http/Requests/GoodsSkuRequest.php b/app/Http/Requests/GoodsSkuRequest.php index e29cbb6..2af032a 100644 --- a/app/Http/Requests/GoodsSkuRequest.php +++ b/app/Http/Requests/GoodsSkuRequest.php @@ -27,7 +27,7 @@ class GoodsSkuRequest extends FormRequest return [ 'id' => ['sometimes', 'required', 'integer', 'exists:goods_skus,id'], 'goods_id' => ['sometimes', 'required', 'integer', 'exists:goods,id'], - 'title' => ['sometimes', 'required', 'string', 'max:255'], + 'title' => ['sometimes', 'required', 'string', 'max:191'], 'sku_code' => ['sometimes', 'required', 'distinct', 'alpha_dash', 'max:32'], 'status' => ['sometimes', 'required', 'integer', Rule::in([0, 1, 2])], 'num' => ['sometimes', 'required', 'integer'], diff --git a/app/Imports/GoodsSkusImport.php b/app/Imports/GoodsSkusImport.php index 639aa51..61bc4c4 100644 --- a/app/Imports/GoodsSkusImport.php +++ b/app/Imports/GoodsSkusImport.php @@ -2,11 +2,14 @@ namespace App\Imports; +use App\Models\DailyStockRecord; use App\Models\Goods; use App\Models\GoodsBrand; use App\Models\GoodsSku; use App\Models\GoodsType; +use App\Utils\DateTimeUtils; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\DB; use Illuminate\Validation\Rule; use Illuminate\Validation\ValidationException; use Maatwebsite\Excel\Concerns\SkipsEmptyRows; @@ -30,11 +33,11 @@ class GoodsSkusImport implements ToCollection, SkipsEmptyRows unset($collection[0], $collection[1]); $arr = $collection->toArray(); $validator = Validator::make($arr, [ - '*.0' => ['required', 'string', 'max:255'], - '*.1' => ['required', 'string', 'max:255', 'exists:goods_types,name'], - '*.2' => ['string', 'max:255', 'exists:goods_brands,name'], + '*.0' => ['required', 'string', 'max:191'], + '*.1' => ['required', 'string', 'max:191', 'exists:goods_types,name'], + '*.2' => ['string', 'max:191', 'exists:goods_brands,name'], '*.3' => ['required', 'alpha_dash', 'max:32'], - '*.4' => ['required', 'string', 'max:255'], + '*.4' => ['required', 'string', 'max:191'], '*.5' => ['required', 'distinct', 'alpha_dash', 'max:32'], '*.6' => ['required', 'string', Rule::in(['下架', '在售', '预警'])], '*.7' => ['required', 'max:10'], @@ -76,16 +79,33 @@ class GoodsSkusImport implements ToCollection, SkipsEmptyRows } $skus[] = $sku; } - if ($newGoods) { - $goods = new Goods(); - $goods->batchInsert(array_values($newGoods)); - $hasGoods = Goods::query()->whereIn('goods_code', array_column($newGoods, 'goods_code'))->get(['id', 'goods_code'])->toArray(); - $hasGoods = ArrayUtils::index($hasGoods, 'goods_code'); - foreach ($skus as &$sku) { - $sku['goods_id'] = isset($hasGoods[$sku['goods_id']]) ? $hasGoods[$sku['goods_id']]['id'] : $sku['goods_id']; + DB::beginTransaction(); + try { + if ($newGoods) { + $goods = new Goods(); + $goods->batchInsert(array_values($newGoods)); + $hasGoods = Goods::query()->whereIn('goods_code', array_column($newGoods, 'goods_code'))->get(['id', 'goods_code'])->toArray(); + $hasGoods = ArrayUtils::index($hasGoods, 'goods_code'); + foreach ($skus as &$newGoodsSku) { + $newGoodsSku['goods_id'] = isset($hasGoods[$newGoodsSku['goods_id']]) ? $hasGoods[$newGoodsSku['goods_id']]['id'] : $newGoodsSku['goods_id']; + } + unset($newGoodsSku); } + $goodsSku = new GoodsSku(); + $goodsSku->batchInsert(array_values($skus)); + $collection = GoodsSku::query()->whereIn('sku_code', array_column($skus, 'sku_code'))->get(['id', 'sku_code'])->toArray(); + $newRecords = []; + foreach ($collection as $sku) { + $newRecords[] = [ + 'sku_id' => $sku['id'], + 'day' => DateTimeUtils::getToday(), + ]; + } + $record = new DailyStockRecord(); + $record->batchInsert($newRecords); + DB::commit(); + } catch (\Exception $exception) { + DB::rollBack(); } - $goodsSku = new GoodsSku(); - $goodsSku->batchInsert(array_values($skus)); } } diff --git a/app/Models/BusinessGoodsSku.php b/app/Models/BusinessGoodsSku.php index 468332d..6d95bb9 100644 --- a/app/Models/BusinessGoodsSku.php +++ b/app/Models/BusinessGoodsSku.php @@ -9,5 +9,29 @@ class BusinessGoodsSku extends Model * * @var array */ - protected $guarded = []; + protected $fillable = [ + 'shop_id', + 'business_order_id', + 'already_cancel_number', + 'cancel_status', + 'category_name', + 'external_sku_id', + 'goods_amount', + 'goods_cost_price', + 'goods_id', + 'goods_name', + 'goods_number', + 'goods_price', + 'goods_purchase_price', + 'goods_specification', + 'help_sell_amount', + 'is_supplier', + 'need_verification_number', + 'shipping_status', + 'sku_id', + 'sub_order_sn', + 'theoretically_refund_amount', + 'thumb_url', + 'verification_number', + ]; } diff --git a/app/Models/BusinessOrder.php b/app/Models/BusinessOrder.php index bc4ef26..42d4f73 100644 --- a/app/Models/BusinessOrder.php +++ b/app/Models/BusinessOrder.php @@ -9,5 +9,40 @@ class BusinessOrder extends Model * * @var array */ - protected $guarded = []; + protected $fillable = [ + 'shop_id', + 'receiver_address_detail', + 'receiver_address_province', + 'self_pick_site_no', + 'discount_amount', + 'theoretical_refund_amount', + 'receiver_address_district', + 'verification_status', + 'inner_transaction_id', + 'is_supplier', + 'service_amount', + 'supply_participate_no', + 'updated_at', + 'order_amount', + 'receiver_address_city', + 'receiver_name', + 'business_note', + 'buyer_memo', + 'logistics_type', + 'help_sell_nickname', + 'activity_title', + 'after_sales_status', + 'mall_activity_type', + 'transaction_id', + 'activity_no', + 'confirm_at', + 'platform_discount_amount', + 'participate_no', + 'receiver_mobile', + 'shipping_status', + 'shipping_amount', + 'cancel_status', + 'nick_name', + 'order_sn', + ]; } diff --git a/app/Services/Business/BusinessClient.php b/app/Services/Business/BusinessClient.php index 024a208..fa9af39 100644 --- a/app/Services/Business/BusinessClient.php +++ b/app/Services/Business/BusinessClient.php @@ -15,7 +15,7 @@ abstract class BusinessClient abstract public function auth(); - abstract public function downloadGoodsList(); + abstract public function downloadGoodsListAndBind(); abstract public function downloadGoods($skuId); @@ -23,7 +23,7 @@ abstract class BusinessClient abstract public function incrQuantity($skuId); - abstract public function downloadOrders($beginTime, $endTime, $activityNo = '', $downloadType = 'default'); + abstract public function downloadOrdersAndSave($beginTime, $endTime, $page = 1, $activityNo = '', $downloadType = 'default'); abstract public function saveOrders($orders); @@ -86,12 +86,8 @@ abstract class BusinessClient 'form_params' => $params ]; $res = (new Client())->request('POST', $url, $headers); + $size = $res->getBody()->getSize(); $res = json_decode($res->getBody()->getContents(), true); - $disableLogType = [ - 'pdd.ktt.goods.query.list', - 'pdd.ktt.order.list', - 'pdd.ktt.increment.order.query' - ]; $log = new Log(); $log->module = 'plat'; $log->action = 'POST'; @@ -99,7 +95,7 @@ abstract class BusinessClient $log->target_id = $this->skuId; $log->target_field = $params['type']; $log->user_id = 1; - if (!in_array($params['type'], $disableLogType, true)) { + if ($size < 64000) { $log->message = json_encode($res, 256); } $log->save(); diff --git a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php index 9eaf85c..c8aae35 100644 --- a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php +++ b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php @@ -38,7 +38,7 @@ class KuaiTuanTuan extends BusinessClient return $this->shop; } - public function downloadGoodsList($page = 1) + public function downloadGoodsListAndBind($page = 1) { [$type, $appendParams] = Goods::downloadGoods($this->shop->owner_id, $page); $res = $this->doRequest($type, $appendParams); @@ -67,25 +67,29 @@ class KuaiTuanTuan extends BusinessClient } /** - * 没有发起售后,未取消的订单 + * 下载没有发起售后,未取消的订单 * * @param $beginTime * @param $endTime - * @param $activityNo - * @param $downloadType + * @param int $page + * @param string $activityNo + * @param string $downloadType * @return mixed */ - public function downloadOrders($beginTime, $endTime, $activityNo = '', $downloadType = 'default') + public function downloadOrdersAndSave($beginTime, $endTime, $page = 1, $activityNo = '', $downloadType = 'default') { if ('increment' === $downloadType) { - [$type, $appendParams] = Order::downloadIncrementOrders($beginTime, $endTime, $activityNo); + [$type, $appendParams] = Order::downloadIncrementOrders($beginTime, $endTime, $page); } else { - [$type, $appendParams] = Order::downloadOrders($beginTime, $endTime, $activityNo); + [$type, $appendParams] = Order::downloadOrders($beginTime, $endTime, $page); } $res = $this->doRequest($type, $appendParams); - - - return $res['ktt_order_list_response']['order_list']; + $this->saveOrders($res['ktt_order_list_response']['order_list']); + exit(); + $pageNum = ceil($res['ktt_order_list_response']['total_count'] / $appendParams['size']); + if ($pageNum > $page && 10 >= $page) { + $this->downloadOrdersAndSave($beginTime, $endTime, $page + 1); + } } public function saveOrders($orders) diff --git a/app/Services/Business/KuaiTuanTuan/Order.php b/app/Services/Business/KuaiTuanTuan/Order.php index 9c50b44..06ddf58 100644 --- a/app/Services/Business/KuaiTuanTuan/Order.php +++ b/app/Services/Business/KuaiTuanTuan/Order.php @@ -3,20 +3,21 @@ namespace App\Services\Business\KuaiTuanTuan; use App\Models\BusinessOrder; +use App\Models\BusinessOrderItem; class Order { /** * 根据成交时间拉取订单列表 */ - public static function downloadOrders($beginTime, $endTime, $activityNo) + public static function downloadOrders($beginTime, $endTime, $page = 1) { $type = 'pdd.ktt.order.list'; $appendParams = [ 'confirm_at_begin' => $beginTime, // 成交启始时间, 必填,毫秒时间戳 'confirm_at_end' => $endTime, // 成交结束时间,必填, 毫秒时间戳,成交结束时间 - 成交启始时间 <= 24h - 'page_number' => 1, // 页码, 必填 - 'page_size' => 100, // 数量, 必填, 1~100 + 'page_number' => $page, // 页码, 必填 + 'page_size' => 1, // 数量, 必填, 1~100 // 非必填 // 'activity_no' => $activityNo, // 团号 'after_sales_status' => 0, // 售后状态, 可选 0-未发起售后 1-退款中 2-退款成功 3-待处理 4-拒绝退款 6-待(顾客)退货 7-待(团长)确认退货 8-(顾客)撤销 9-(系统)关闭 @@ -31,13 +32,13 @@ class Order /** * 快团团增量查订单 */ - public static function downloadIncrementOrders($beginTime, $endTime, $activityNo) + public static function downloadIncrementOrders($beginTime, $endTime, $page = 1) { $type = 'pdd.ktt.increment.order.query'; $appendParams = [ 'start_updated_at' => $beginTime, // 更新起始时间 'end_updated_at' => $endTime, // 更新结束时间 - 'page_number' => 1, // 页码 + 'page_number' => $page, // 页码 'page_size' => 100, // 数量 // 非必填 // 'activity_no' => $activityNo, // 团号 @@ -54,12 +55,13 @@ class Order public static function saveOrders(array $orders, $shopId) { foreach ($orders as $order) { + unset($order['custom_item_list'], $order['logistics_list'], $order['gift_order_list']); $orderRecord = BusinessOrder::updateOrCreate( ['shop_id' => $shopId, 'order_sn' => $order['order_sn']], $order ); foreach ($order['sub_order_list'] as $item) { - $orderRecord = BusinessOrder::updateOrCreate( + BusinessOrderItem::updateOrCreate( ['shop_id' => $shopId, 'business_order_id' => $orderRecord->id, 'goods_id' => $item['goods_id'], 'sku_id' => $item['sku_id']], $item ); diff --git a/app/Services/Business/MiaoXuan/MiaoXuan.php b/app/Services/Business/MiaoXuan/MiaoXuan.php index 0b3fb35..7abbdff 100644 --- a/app/Services/Business/MiaoXuan/MiaoXuan.php +++ b/app/Services/Business/MiaoXuan/MiaoXuan.php @@ -15,7 +15,7 @@ class MiaoXuan extends BusinessClient // TODO: Implement auth() method. } - public function downloadGoodsList() + public function downloadGoodsListAndBind() { } @@ -33,7 +33,7 @@ class MiaoXuan extends BusinessClient $this->formDataPostRequest($url, $appendParams); } - public function downloadOrders($beginTime, $endTime, $activityNo = '', $downloadType = 'default') + public function downloadOrdersAndSave($beginTime, $endTime, $page = 1, $activityNo = '', $downloadType = 'default') { } diff --git a/config/app.php b/config/app.php index e370e27..7916e42 100644 --- a/config/app.php +++ b/config/app.php @@ -67,7 +67,7 @@ return [ | */ - 'timezone' => 'UTC', + 'timezone' => 'PRC', /* |-------------------------------------------------------------------------- diff --git a/config/database.php b/config/database.php index b7ba080..b186558 100644 --- a/config/database.php +++ b/config/database.php @@ -52,8 +52,8 @@ return [ 'username' => env('DB_USERNAME', ''), 'password' => env('DB_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), - 'charset' => 'utf8', - 'collation' => 'utf8_general_ci', + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'prefix_indexes' => true, 'strict' => true, @@ -71,7 +71,7 @@ return [ 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', + 'charset' => 'utf8mb4', 'prefix' => '', 'prefix_indexes' => true, 'schema' => 'public', @@ -86,7 +86,7 @@ return [ 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', + 'charset' => 'utf8mb4', 'prefix' => '', 'prefix_indexes' => true, ], diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 03b4dc9..4e3b45a 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -13,6 +13,7 @@ class CreateUsersTable extends Migration */ public function up() { + Schema::defaultStringLength(191); Schema::create('users', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name'); @@ -23,6 +24,8 @@ class CreateUsersTable extends Migration $table->softDeletes(); $table->rememberToken(); $table->timestamps(); + // 索引 + $table->unique('name'); }); } diff --git a/database/migrations/2022_07_26_061712_create_goods_types_table.php b/database/migrations/2022_07_26_061712_create_goods_types_table.php index f4bb7d6..0ef0220 100644 --- a/database/migrations/2022_07_26_061712_create_goods_types_table.php +++ b/database/migrations/2022_07_26_061712_create_goods_types_table.php @@ -13,6 +13,7 @@ class CreateGoodsTypesTable extends Migration */ public function up() { + Schema::defaultStringLength(191); Schema::create('goods_types', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name')->nullable(false); diff --git a/database/migrations/2022_07_26_085847_create_goods_brands_table.php b/database/migrations/2022_07_26_085847_create_goods_brands_table.php index b785b7f..6e44c7c 100644 --- a/database/migrations/2022_07_26_085847_create_goods_brands_table.php +++ b/database/migrations/2022_07_26_085847_create_goods_brands_table.php @@ -13,6 +13,7 @@ class CreateGoodsBrandsTable extends Migration */ public function up() { + Schema::defaultStringLength(191); Schema::create('goods_brands', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name')->nullable(false); diff --git a/database/migrations/2022_07_26_090143_create_goods_table.php b/database/migrations/2022_07_26_090143_create_goods_table.php index 749651e..1fdf2da 100644 --- a/database/migrations/2022_07_26_090143_create_goods_table.php +++ b/database/migrations/2022_07_26_090143_create_goods_table.php @@ -13,6 +13,7 @@ class CreateGoodsTable extends Migration */ public function up() { + Schema::defaultStringLength(191); Schema::create('goods', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('title')->nullable(false); diff --git a/database/migrations/2022_07_26_090150_create_goods_skus_table.php b/database/migrations/2022_07_26_090150_create_goods_skus_table.php index 522319b..468e37b 100644 --- a/database/migrations/2022_07_26_090150_create_goods_skus_table.php +++ b/database/migrations/2022_07_26_090150_create_goods_skus_table.php @@ -13,6 +13,7 @@ class CreateGoodsSkusTable extends Migration */ public function up() { + Schema::defaultStringLength(191); Schema::create('goods_skus', function (Blueprint $table) { $table->bigIncrements('id'); $table->unsignedBigInteger('goods_id')->nullable(false)->comment('商品id'); @@ -28,6 +29,7 @@ class CreateGoodsSkusTable extends Migration $table->unsignedInteger('reserve')->default(0)->comment('预留量'); $table->timestamps(); // 索引 + $table->unique(['goods_id', 'sku_code']); }); } diff --git a/database/migrations/2022_07_28_095523_create_menus_table.php b/database/migrations/2022_07_28_095523_create_menus_table.php index 333dcfe..18bdaea 100644 --- a/database/migrations/2022_07_28_095523_create_menus_table.php +++ b/database/migrations/2022_07_28_095523_create_menus_table.php @@ -13,6 +13,7 @@ class CreateMenusTable extends Migration */ public function up() { + Schema::defaultStringLength(191); Schema::create('menus', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('code', 32)->nullable(false)->comment('菜单编码'); diff --git a/database/migrations/2022_08_02_022448_create_shops_table.php b/database/migrations/2022_08_02_022448_create_shops_table.php index 2cdeb16..5d63e2f 100644 --- a/database/migrations/2022_08_02_022448_create_shops_table.php +++ b/database/migrations/2022_08_02_022448_create_shops_table.php @@ -13,6 +13,7 @@ class CreateShopsTable extends Migration */ public function up() { + Schema::defaultStringLength(191); Schema::create('shops', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name')->unique(); diff --git a/database/migrations/2022_08_05_093629_create_business_orders_table.php b/database/migrations/2022_08_05_093629_create_business_orders_table.php index 69baab2..d82f287 100644 --- a/database/migrations/2022_08_05_093629_create_business_orders_table.php +++ b/database/migrations/2022_08_05_093629_create_business_orders_table.php @@ -16,7 +16,7 @@ class CreateBusinessOrdersTable extends Migration Schema::create('business_orders', function (Blueprint $table) { $table->bigIncrements('id'); $table->integer('shop_id'); - $table->bigInteger('activity_no')->nullable(); + $table->string('activity_no')->nullable(); $table->string('activity_title')->nullable(); $table->bigInteger('after_sales_status')->nullable(); $table->string('business_note')->nullable(); From b20abf00d663f93c4bad2f0995422ceaa2871866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Tue, 9 Aug 2022 20:05:19 +0800 Subject: [PATCH 52/68] =?UTF-8?q?feat:=20#10000=20=E8=A7=84=E6=A0=BC?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Goods.php | 8 +++++++- app/Models/GoodsSku.php | 14 +++++++++++++- resources/lang/zh-CN/permission.php | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/Models/Goods.php b/app/Models/Goods.php index f9f9ff2..7919336 100644 --- a/app/Models/Goods.php +++ b/app/Models/Goods.php @@ -15,7 +15,13 @@ class Goods extends Model 'brand_id', ]; - protected $guarded = []; + protected $fillable = [ + 'title', + 'img_url', + 'type_id', + 'brand_id', + 'goods_code', + ]; /** * 多规格 diff --git a/app/Models/GoodsSku.php b/app/Models/GoodsSku.php index 19c1770..0004a6d 100644 --- a/app/Models/GoodsSku.php +++ b/app/Models/GoodsSku.php @@ -19,7 +19,19 @@ class GoodsSku extends Model * * @var array */ - protected $guarded = []; + protected $fillable = [ + 'goods_id', + 'title', + 'sku_code', + 'status', + 'num', + 'stock', + 'cost', + 'two_days_ago_num', + 'yesterday_num', + 'reference_price', + 'reserve', + ]; protected $hidden = ['created_at']; diff --git a/resources/lang/zh-CN/permission.php b/resources/lang/zh-CN/permission.php index 7ac3875..3a59603 100644 --- a/resources/lang/zh-CN/permission.php +++ b/resources/lang/zh-CN/permission.php @@ -37,7 +37,7 @@ return [ 'name' => '规格查看', 'parent_id' => 2, ], - 'goods_skus.udpate' => [ + 'goods_skus.update' => [ 'id' => 25, 'name' => '规格更新', 'parent_id' => 2, From 5475a468af987c5d021209ea891ae5d3b59c8c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Tue, 9 Aug 2022 20:40:39 +0800 Subject: [PATCH 53/68] =?UTF-8?q?feat:=20#10000=20=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Goods/GoodsSkusController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index ab40a9b..701fab0 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -92,10 +92,15 @@ class GoodsSkusController extends Controller $this->addLog($id, 'update'); // 商品更新 $goods = Goods::query()->find($sku->goods_id); + $this->log = new LogModel([ + 'module' => 'goods', + 'action' => $request->getMethod(), + 'target_type' => 'goods', + ]); $this->setBeforeUpdate($goods->toArray()); $goods->update($request->goods); $this->setAfterUpdate($goods->toArray()); - $this->addLog($sku->goods_id, 'update', 'goods'); + $this->addLog($sku->goods_id, 'update'); DB::commit(); } catch (\Exception $exception) { DB::rollBack(); From 5ebe7b685cdaad9154e21fd188113a3cc7334473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Wed, 10 Aug 2022 16:39:25 +0800 Subject: [PATCH 54/68] =?UTF-8?q?feat:=20#10000=20=E5=A2=9E=E9=87=8F?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/Swoole.php | 56 +++++++++++++++++++ ...ns.php => UpdateSuperAdminPermissions.php} | 2 +- app/Console/Kernel.php | 6 +- app/Http/Controllers/Shop/ShopsController.php | 2 - app/Jobs/ProcessPodcast.php | 34 +++++++++++ app/Listeners/UpdateBusinessGoodsStock.php | 16 ++++-- app/Services/Business/BusinessClient.php | 11 ++-- .../Business/KuaiTuanTuan/KuaiTuanTuan.php | 7 ++- app/Services/Business/KuaiTuanTuan/Order.php | 6 +- app/Services/Business/MiaoXuan/Order.php | 4 ++ composer.lock | 4 +- ...03559_create_daily_stock_records_table.php | 3 +- .../2022_08_10_150657_create_jobs_table.php | 36 ++++++++++++ 13 files changed, 165 insertions(+), 22 deletions(-) create mode 100644 app/Console/Commands/Swoole.php rename app/Console/Commands/{UpdateSuperPermissions.php => UpdateSuperAdminPermissions.php} (95%) create mode 100644 app/Jobs/ProcessPodcast.php create mode 100644 database/migrations/2022_08_10_150657_create_jobs_table.php diff --git a/app/Console/Commands/Swoole.php b/app/Console/Commands/Swoole.php new file mode 100644 index 0000000..9e97435 --- /dev/null +++ b/app/Console/Commands/Swoole.php @@ -0,0 +1,56 @@ +where('plat_id', 1)->where('status', 1)->get(); + $endTime = DateTimeUtils::getMicroTime(); + $beginTime = $endTime - 1000; + foreach ($shops as $shop) { + BusinessFactory::init()->make($shop->plat_id)->setShop($shop)->downloadOrdersAndSave($beginTime, $endTime, 1, '', 'increment'); + } + }); + Event::wait(); + } +} diff --git a/app/Console/Commands/UpdateSuperPermissions.php b/app/Console/Commands/UpdateSuperAdminPermissions.php similarity index 95% rename from app/Console/Commands/UpdateSuperPermissions.php rename to app/Console/Commands/UpdateSuperAdminPermissions.php index c662b0b..5f8b1b0 100644 --- a/app/Console/Commands/UpdateSuperPermissions.php +++ b/app/Console/Commands/UpdateSuperAdminPermissions.php @@ -7,7 +7,7 @@ use Illuminate\Console\Command; use Spatie\Permission\Models\Permission; use Spatie\Permission\Models\Role; -class UpdateSuperPermissions extends Command +class UpdateSuperAdminPermissions extends Command { /** * The name and signature of the console command. diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index a8c5158..35c09a0 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -2,6 +2,7 @@ namespace App\Console; +use App\Console\Commands\Inventory; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; @@ -24,8 +25,9 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { - // $schedule->command('inspire') - // ->hourly(); + // 服务器添加cron入口 + // * * * * * cd /home/wwwroot/erp.staging.chutang66.com && php artisan schedule:run >> /dev/null 2>&1 + $schedule->command(Inventory::class)->dailyAt('07:00'); } /** diff --git a/app/Http/Controllers/Shop/ShopsController.php b/app/Http/Controllers/Shop/ShopsController.php index e6fc501..a4aee5c 100644 --- a/app/Http/Controllers/Shop/ShopsController.php +++ b/app/Http/Controllers/Shop/ShopsController.php @@ -89,11 +89,9 @@ class ShopsController extends Controller $business->setShop($shop); if ('goods' === $request->get('type')) { $business->bindGoods($request->get('data')); - event(new BindBusinessGoods($shop)); } if ('orders' === $request->get('type')) { $business->saveOrders(); - event(new UpdateBusinessGoodsStock($shop)); } } } diff --git a/app/Jobs/ProcessPodcast.php b/app/Jobs/ProcessPodcast.php new file mode 100644 index 0000000..6d4df9c --- /dev/null +++ b/app/Jobs/ProcessPodcast.php @@ -0,0 +1,34 @@ +shop = $shop; + $this->shopId = $shopId; + $this->updateOrders = $updateOrders; } /** * Handle the event. * - * @param Registered $event + * @param Registered $event * @return void */ public function handle(Registered $event) { - // + if (empty($this->updateOrders)) { + return; + } } } diff --git a/app/Services/Business/BusinessClient.php b/app/Services/Business/BusinessClient.php index fa9af39..12dc06c 100644 --- a/app/Services/Business/BusinessClient.php +++ b/app/Services/Business/BusinessClient.php @@ -88,18 +88,21 @@ abstract class BusinessClient $res = (new Client())->request('POST', $url, $headers); $size = $res->getBody()->getSize(); $res = json_decode($res->getBody()->getContents(), true); - $log = new Log(); + if ('pdd.ktt.increment.order.query' === $params['type']) { + $log = Log::query()->where('user_id', $this->shop->id)->where('target_field', $params['type'])->first(); + } else { + $log = new Log(); + } $log->module = 'plat'; $log->action = 'POST'; $log->target_type = $this->shop->plat_id; - $log->target_id = $this->skuId; + $log->target_id = $this->getSkuId(); $log->target_field = $params['type']; - $log->user_id = 1; + $log->user_id = $this->shop->id; if ($size < 64000) { $log->message = json_encode($res, 256); } $log->save(); - if (isset($res['error_response'])) { throw new \Exception($res['error_response']['error_msg'], $res['error_response']['error_code']); } diff --git a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php index c8aae35..b299df8 100644 --- a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php +++ b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php @@ -80,13 +80,14 @@ class KuaiTuanTuan extends BusinessClient { if ('increment' === $downloadType) { [$type, $appendParams] = Order::downloadIncrementOrders($beginTime, $endTime, $page); + $responseName = 'ktt_increment_order_query_response'; } else { [$type, $appendParams] = Order::downloadOrders($beginTime, $endTime, $page); + $responseName = 'ktt_order_list_response'; } $res = $this->doRequest($type, $appendParams); - $this->saveOrders($res['ktt_order_list_response']['order_list']); - exit(); - $pageNum = ceil($res['ktt_order_list_response']['total_count'] / $appendParams['size']); + $this->saveOrders($res[$responseName]['order_list']); + $pageNum = ceil($res[$responseName]['total_count'] / $appendParams['page_size']); if ($pageNum > $page && 10 >= $page) { $this->downloadOrdersAndSave($beginTime, $endTime, $page + 1); } diff --git a/app/Services/Business/KuaiTuanTuan/Order.php b/app/Services/Business/KuaiTuanTuan/Order.php index 06ddf58..d9d74f9 100644 --- a/app/Services/Business/KuaiTuanTuan/Order.php +++ b/app/Services/Business/KuaiTuanTuan/Order.php @@ -2,6 +2,7 @@ namespace App\Services\Business\KuaiTuanTuan; +use App\Listeners\UpdateBusinessGoodsStock; use App\Models\BusinessOrder; use App\Models\BusinessOrderItem; @@ -17,7 +18,7 @@ class Order 'confirm_at_begin' => $beginTime, // 成交启始时间, 必填,毫秒时间戳 'confirm_at_end' => $endTime, // 成交结束时间,必填, 毫秒时间戳,成交结束时间 - 成交启始时间 <= 24h 'page_number' => $page, // 页码, 必填 - 'page_size' => 1, // 数量, 必填, 1~100 + 'page_size' => 100, // 数量, 必填, 1~100 // 非必填 // 'activity_no' => $activityNo, // 团号 'after_sales_status' => 0, // 售后状态, 可选 0-未发起售后 1-退款中 2-退款成功 3-待处理 4-拒绝退款 6-待(顾客)退货 7-待(团长)确认退货 8-(顾客)撤销 9-(系统)关闭 @@ -54,12 +55,14 @@ class Order // 下载订单事件之后去统计 然后更新库存 public static function saveOrders(array $orders, $shopId) { + $updateOrders = []; foreach ($orders as $order) { unset($order['custom_item_list'], $order['logistics_list'], $order['gift_order_list']); $orderRecord = BusinessOrder::updateOrCreate( ['shop_id' => $shopId, 'order_sn' => $order['order_sn']], $order ); + $updateOrders[] = $order['order_sn']; foreach ($order['sub_order_list'] as $item) { BusinessOrderItem::updateOrCreate( ['shop_id' => $shopId, 'business_order_id' => $orderRecord->id, 'goods_id' => $item['goods_id'], 'sku_id' => $item['sku_id']], @@ -67,6 +70,7 @@ class Order ); } } + event(new UpdateBusinessGoodsStock($shopId, $updateOrders)); } } diff --git a/app/Services/Business/MiaoXuan/Order.php b/app/Services/Business/MiaoXuan/Order.php index 07278fa..89c6e73 100644 --- a/app/Services/Business/MiaoXuan/Order.php +++ b/app/Services/Business/MiaoXuan/Order.php @@ -2,6 +2,7 @@ namespace App\Services\Business\MiaoXuan; +use App\Listeners\UpdateBusinessGoodsStock; use App\Models\BusinessOrder; class Order @@ -9,11 +10,13 @@ class Order // 下载订单事件之后去统计 然后更新库存 public static function saveOrders(array $orders, $shopId) { + $updateOrders = []; foreach ($orders as $order) { $orderRecord = BusinessOrder::updateOrCreate( ['shop_id' => $shopId, 'order_sn' => $order['order_sn']], $order ); + $updateOrders[] = $order['order_sn']; foreach ($order['sub_order_list'] as $item) { $orderRecord = BusinessOrder::updateOrCreate( ['shop_id' => $shopId, 'business_order_id' => $orderRecord->id, 'goods_id' => $item['goods_id'], 'sku_id' => $item['sku_id']], @@ -21,6 +24,7 @@ class Order ); } } + event(new UpdateBusinessGoodsStock($shopId, $updateOrders)); } } diff --git a/composer.lock b/composer.lock index 1e34c06..4c69252 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5a01163bdf570af5226c567ad02f45d7", + "content-hash": "037b06c1b26399725a1d9c0687402942", "packages": [ { "name": "aliyuncs/oss-sdk-php", @@ -9110,7 +9110,7 @@ "prefer-lowest": false, "platform": { "php": "^7.2.5|^8.0", - "ext-json": "^1.7" + "ext-json": "*" }, "platform-dev": [], "plugin-api-version": "2.3.0" diff --git a/database/migrations/2022_07_26_103559_create_daily_stock_records_table.php b/database/migrations/2022_07_26_103559_create_daily_stock_records_table.php index 894332f..3b1c792 100644 --- a/database/migrations/2022_07_26_103559_create_daily_stock_records_table.php +++ b/database/migrations/2022_07_26_103559_create_daily_stock_records_table.php @@ -20,8 +20,9 @@ class CreateDailyStockRecordsTable extends Migration $table->unsignedInteger('arrived_today_num')->default(0)->comment('今日到货'); $table->unsignedInteger('loss_num')->default(0)->comment('损耗'); $table->unsignedInteger('inventory')->default(0)->comment('库存盘点'); - $table->unique(['sku_id', 'day']); $table->timestamps(); + // 索引 + $table->unique(['sku_id', 'day']); }); } diff --git a/database/migrations/2022_08_10_150657_create_jobs_table.php b/database/migrations/2022_08_10_150657_create_jobs_table.php new file mode 100644 index 0000000..1be9e8a --- /dev/null +++ b/database/migrations/2022_08_10_150657_create_jobs_table.php @@ -0,0 +1,36 @@ +bigIncrements('id'); + $table->string('queue')->index(); + $table->longText('payload'); + $table->unsignedTinyInteger('attempts'); + $table->unsignedInteger('reserved_at')->nullable(); + $table->unsignedInteger('available_at'); + $table->unsignedInteger('created_at'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('jobs'); + } +} From a47fbb2622302026cacaca03bee2edf66bf55ac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Wed, 10 Aug 2022 23:45:03 +0800 Subject: [PATCH 55/68] =?UTF-8?q?feat:=20#10000=20=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Log/LogsController.php | 1 + app/Http/Controllers/Role/RolesController.php | 2 +- app/Http/Controllers/Shop/ShopsController.php | 3 +++ app/Models/BusinessOrder.php | 5 ++++ app/Models/BusinessOrderItem.php | 26 ++++++++++++++++++- .../2022_08_02_022448_create_shops_table.php | 2 +- database/seeds/MenusTableSeeder.php | 2 +- resources/lang/zh-CN/permission.php | 20 +++++++------- 8 files changed, 47 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/Log/LogsController.php b/app/Http/Controllers/Log/LogsController.php index f0441f6..cd74e76 100644 --- a/app/Http/Controllers/Log/LogsController.php +++ b/app/Http/Controllers/Log/LogsController.php @@ -12,6 +12,7 @@ class LogsController extends Controller public function index(Request $request) { $res = Log::query() + ->orderBy('id', 'desc') ->with(['user:id,name']) ->filter() ->paginate(); diff --git a/app/Http/Controllers/Role/RolesController.php b/app/Http/Controllers/Role/RolesController.php index 1e592c7..6338fd8 100644 --- a/app/Http/Controllers/Role/RolesController.php +++ b/app/Http/Controllers/Role/RolesController.php @@ -24,7 +24,7 @@ class RolesController extends Controller public function index() { - $roles = Role::query()->with('permissions')->get()->toArray(); + $roles = Role::query()->with('permissions')->where('id', '<>', 1)->get()->toArray(); $routes = include(resource_path('lang/zh-CN/permission.php')); foreach ($roles as &$role) { $permissions = []; diff --git a/app/Http/Controllers/Shop/ShopsController.php b/app/Http/Controllers/Shop/ShopsController.php index a4aee5c..ee8c0bf 100644 --- a/app/Http/Controllers/Shop/ShopsController.php +++ b/app/Http/Controllers/Shop/ShopsController.php @@ -48,6 +48,9 @@ class ShopsController extends Controller $shop = new Shop(); $shop->name = $request->name; $shop->plat_id = $request->plat_id; + if (0 === $request->plat_id) { + $shop->status = 2; + } $shop->save(); return response($this->res, $this->res['httpCode']); diff --git a/app/Models/BusinessOrder.php b/app/Models/BusinessOrder.php index 42d4f73..913a45a 100644 --- a/app/Models/BusinessOrder.php +++ b/app/Models/BusinessOrder.php @@ -45,4 +45,9 @@ class BusinessOrder extends Model 'nick_name', 'order_sn', ]; + + public function items() + { + return $this->hasMany(BusinessOrderItem::class, 'business_order_id'); + } } diff --git a/app/Models/BusinessOrderItem.php b/app/Models/BusinessOrderItem.php index daa3675..19015e3 100644 --- a/app/Models/BusinessOrderItem.php +++ b/app/Models/BusinessOrderItem.php @@ -9,7 +9,31 @@ class BusinessOrderItem extends Model * * @var array */ - protected $guarded = []; + protected $fillable = [ + 'shop_id', + 'business_order_id', + 'already_cancel_number', + 'cancel_status', + 'category_name', + 'external_sku_id', + 'goods_amount', + 'goods_cost_price', + 'goods_id', + 'goods_name', + 'goods_number', + 'goods_price', + 'goods_purchase_price', + 'goods_specification', + 'help_sell_amount', + 'is_supplier', + 'need_verification_number', + 'shipping_status', + 'sku_id', + 'sub_order_sn', + 'theoretically_refund_amount', + 'thumb_url', + 'verification_number', + ]; public function order() { diff --git a/database/migrations/2022_08_02_022448_create_shops_table.php b/database/migrations/2022_08_02_022448_create_shops_table.php index 5d63e2f..8364f24 100644 --- a/database/migrations/2022_08_02_022448_create_shops_table.php +++ b/database/migrations/2022_08_02_022448_create_shops_table.php @@ -28,7 +28,7 @@ class CreateShopsTable extends Migration $table->unsignedInteger('refresh_token_expires_in')->nullable()->comment('refresh_token过期时间段,10表示10秒后过期'); $table->text('scope')->nullable()->comment('接口列表'); $table->text('pop_auth_token_create_response')->nullable()->comment('授权认证信息'); - $table->string('status')->default(0)->comment('状态'); + $table->unsignedTinyInteger('status')->default(0)->comment('状态'); $table->softDeletes(); $table->timestamps(); }); diff --git a/database/seeds/MenusTableSeeder.php b/database/seeds/MenusTableSeeder.php index d968742..c260c8e 100644 --- a/database/seeds/MenusTableSeeder.php +++ b/database/seeds/MenusTableSeeder.php @@ -27,7 +27,7 @@ class MenusTableSeeder extends Seeder $id = DB::table('menus')->insertGetId(['parent_id' => 0,'code' => 'SYSTEM_MANAGE', 'name' => '系统管理', 'seq' => 3]); DB::table('menus')->insert([ ['parent_id' => $id,'code' => 'ROLE_MANAGE', 'name' => '角色管理', 'seq' => 0], - ['parent_id' => $id,'code' => 'PERMISSION_MANAGE', 'name' => '权限管理', 'seq' => 1], +// ['parent_id' => $id,'code' => 'PERMISSION_MANAGE', 'name' => '权限管理', 'seq' => 1], ]); // 系统日志 DB::table('menus')->insertGetId(['parent_id' => 0,'code' => 'SYSTEM_LOG', 'name' => '系统日志', 'seq' => 4]); diff --git a/resources/lang/zh-CN/permission.php b/resources/lang/zh-CN/permission.php index 3a59603..6d487bb 100644 --- a/resources/lang/zh-CN/permission.php +++ b/resources/lang/zh-CN/permission.php @@ -210,16 +210,16 @@ return [ 'name' => '设置权限', 'parent_id' => 8, ], - 'PERMISSION_MANAGE' => [ - 'id' => 9, - 'name' => '权限管理', - 'parent_id' => 7, - ], - 'permissions.index' => [ - 'id' => 90, - 'name' => '列表', - 'parent_id' => 9, - ], +// 'PERMISSION_MANAGE' => [ +// 'id' => 9, +// 'name' => '权限管理', +// 'parent_id' => 7, +// ], +// 'permissions.index' => [ +// 'id' => 90, +// 'name' => '列表', +// 'parent_id' => 9, +// ], // 系统日志 'SYSTEM_LOG' => [ 'id' => 10, From 4819f823e4fe93174091f1c535cbb12d669aca5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Thu, 11 Aug 2022 02:13:19 +0800 Subject: [PATCH 56/68] =?UTF-8?q?feat:=20#10000=20=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E5=90=8C=E6=AD=A5=E5=BA=93=E5=AD=98=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/Swoole.php | 2 +- app/Console/Commands/Test.php | 6 +- app/Http/Controllers/Shop/ShopsController.php | 2 +- app/Listeners/UpdateBusinessGoodsStock.php | 39 ++++++++-- app/Services/Business/BusinessClient.php | 73 ++++++++++++++++--- .../Business/KuaiTuanTuan/KuaiTuanTuan.php | 34 +++------ app/Services/Business/KuaiTuanTuan/Order.php | 33 +-------- app/Services/Business/MiaoXuan/MiaoXuan.php | 13 +--- app/Services/Business/MiaoXuan/Order.php | 22 ------ 9 files changed, 117 insertions(+), 107 deletions(-) diff --git a/app/Console/Commands/Swoole.php b/app/Console/Commands/Swoole.php index 9e97435..ecc9494 100644 --- a/app/Console/Commands/Swoole.php +++ b/app/Console/Commands/Swoole.php @@ -48,7 +48,7 @@ class Swoole extends Command $endTime = DateTimeUtils::getMicroTime(); $beginTime = $endTime - 1000; foreach ($shops as $shop) { - BusinessFactory::init()->make($shop->plat_id)->setShop($shop)->downloadOrdersAndSave($beginTime, $endTime, 1, '', 'increment'); + BusinessFactory::init()->make($shop->plat_id)->setShop($shop)->downloadOrdersAndSave($beginTime, $endTime, 'increment', 1); } }); Event::wait(); diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index dde17fa..619eb6b 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -53,9 +53,9 @@ class Test extends Command // $business->incrQuantity(1); // 订单下载 - $beginTime = DateTimeUtils::getMicroTime('2022-08-08'); - $endTime = DateTimeUtils::getMicroTime('2022-08-09'); - $business->downloadOrdersAndSave($beginTime, $endTime); +// $beginTime = DateTimeUtils::getMicroTime('2022-08-08'); +// $endTime = DateTimeUtils::getMicroTime('2022-08-09'); +// $business->downloadOrdersAndSave($beginTime, $endTime); $this->info('执行测试成功'); } diff --git a/app/Http/Controllers/Shop/ShopsController.php b/app/Http/Controllers/Shop/ShopsController.php index ee8c0bf..872a4d9 100644 --- a/app/Http/Controllers/Shop/ShopsController.php +++ b/app/Http/Controllers/Shop/ShopsController.php @@ -94,7 +94,7 @@ class ShopsController extends Controller $business->bindGoods($request->get('data')); } if ('orders' === $request->get('type')) { - $business->saveOrders(); + $business->saveOrders($request->get('data')); } } } diff --git a/app/Listeners/UpdateBusinessGoodsStock.php b/app/Listeners/UpdateBusinessGoodsStock.php index 2d6bfaa..8f99cbf 100644 --- a/app/Listeners/UpdateBusinessGoodsStock.php +++ b/app/Listeners/UpdateBusinessGoodsStock.php @@ -2,25 +2,29 @@ namespace App\Listeners; +use App\Models\GoodsSku; +use App\Models\Log; use App\Models\Shop; +use App\Services\Business\BusinessFactory; use Illuminate\Auth\Events\Registered; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Queue\InteractsWithQueue; +use App\Models\BusinessOrderItem; class UpdateBusinessGoodsStock implements ShouldQueue { - protected $shopId; - protected $updateOrders; + protected $num; + protected $businessOrderItem; /** * Create the event listener. * * @return void */ - public function __construct($shopId, $updateOrders) + public function __construct(BusinessOrderItem $item, $num) { - $this->shopId = $shopId; - $this->updateOrders = $updateOrders; + $this->businessOrderItem = $item; + $this->num = $num; } /** @@ -31,8 +35,29 @@ class UpdateBusinessGoodsStock implements ShouldQueue */ public function handle(Registered $event) { - if (empty($this->updateOrders)) { - return; + $shops = Shop::query()->where('id', '<>', $this->businessOrderItem->shop_id)->where('status', 1)->get(['id', 'plat_id']); + [$goodsCode, $skuCode] = explode('_', $this->businessOrderItem->external_sku_id); + $goodsSku = GoodsSku::query()->where('sku_code', $skuCode) + ->with(['goods' => function ($query) use ($goodsCode) { + $query->where('goods_code', $goodsCode); + }]) + ->first(); + if ($goodsSku) { + $goodsSku->stock += $this->num; + $goodsSku->save(); + foreach ($shops as $shop) { + BusinessFactory::init()->make($shop['plat_id'])->setShopId($shop['id'])->incrQuantity($this->businessOrderItem, $this->num, true, $goodsSku); + } + } else { + $log = new Log(); + $log->module = 'goods'; + $log->action = 'PATCH'; + $log->target_type = 'goods_sku'; + $log->target_id = $goodsSku->id; + $log->target_field = 'stock'; + $log->user_id = $this->businessOrderItem->shop_id; + $log->message = ($this->businessOrderItem->external_sku_id ?: '商品') . '未找到'; + $log->save(); } } } diff --git a/app/Services/Business/BusinessClient.php b/app/Services/Business/BusinessClient.php index 12dc06c..be66a2a 100644 --- a/app/Services/Business/BusinessClient.php +++ b/app/Services/Business/BusinessClient.php @@ -2,6 +2,10 @@ namespace App\Services\Business; +use App\Listeners\UpdateBusinessGoodsStock; +use App\Models\BusinessGoodsSku; +use App\Models\BusinessOrder; +use App\Models\GoodsSku; use App\Models\Log; use App\Models\Shop; use GuzzleHttp\Client; @@ -21,11 +25,60 @@ abstract class BusinessClient abstract public function bindGoods($goods); - abstract public function incrQuantity($skuId); + abstract public function incrQuantity(BusinessGoodsSku $businessGoodsSku, $num, $incremental, GoodsSku $goodsSku); - abstract public function downloadOrdersAndSave($beginTime, $endTime, $page = 1, $activityNo = '', $downloadType = 'default'); + abstract public function downloadOrdersAndSave($beginTime, $endTime, $downloadType = 'default', $page = 1); - abstract public function saveOrders($orders); + public function saveOrders($orders) + { + $shopId = $this->getShop()->id; + foreach ($orders as $order) { + unset($order['custom_item_list'], $order['logistics_list'], $order['gift_order_list']); + $order['shop_id'] = $shopId; + $orderRecord = BusinessOrder::query()->where('shop_id', $shopId)->where('order_sn', $order['order_sn'])->first(); + if (empty($orderRecord)) { + $orderRecord->create($order); + } else { + $orderRecord->update($order); + } + foreach ($order['sub_order_list'] as $item) { + $item['shop_id'] = $shopId; + $orderItem = BusinessOrder::query()->where('shop_id', $shopId) + ->where('business_order_id', $orderRecord->id) + ->where('goods_id', $item['goods_id']) + ->where('sku_id', $item['sku_id']) + ->first(); + $num = 0; + if (empty($orderItem)) { + if ($item['cancel_status']) { + if ($num = $item['goods_number'] - $item['already_cancel_number']) { + // 扣库存 $reduceNum + $num = 0 - $num; + } + } else { + // 扣库存 + $num = 0 - $item['goods_number']; + } + $orderItem->create($item); + } else { + if ($item['cancel_status'] !== $orderItem->cancel_status) { + if ($item['cancel_status']) { + // 加库存 + $num = $item['already_cancel_number']; + } else { + // 扣库存 + $num = 0 - $item['goods_number']; + } + } + $orderItem->update($item); + } + // 增量更新库存 + if ($num) { + event(new UpdateBusinessGoodsStock($orderItem, $num)); + } + } + } + } public function authCallback($code, $shopId) { @@ -81,31 +134,29 @@ abstract class BusinessClient public function formDataPostRequest($url, $params) { + $method = 'POST'; $headers = [ 'headers' => ['Content-type' => 'application/x-www-form-urlencoded;charset=UTF-8'], 'form_params' => $params ]; - $res = (new Client())->request('POST', $url, $headers); + $res = (new Client())->request($method, $url, $headers); $size = $res->getBody()->getSize(); $res = json_decode($res->getBody()->getContents(), true); if ('pdd.ktt.increment.order.query' === $params['type']) { - $log = Log::query()->where('user_id', $this->shop->id)->where('target_field', $params['type'])->first(); + $log = Log::query()->where('user_id', $this->getShop()->id)->where('target_field', $params['type'])->first(); } else { $log = new Log(); } $log->module = 'plat'; - $log->action = 'POST'; - $log->target_type = $this->shop->plat_id; + $log->action = $method; + $log->target_type = $this->getShop()->plat_id; $log->target_id = $this->getSkuId(); $log->target_field = $params['type']; - $log->user_id = $this->shop->id; + $log->user_id = $this->getShop()->id; if ($size < 64000) { $log->message = json_encode($res, 256); } $log->save(); - if (isset($res['error_response'])) { - throw new \Exception($res['error_response']['error_msg'], $res['error_response']['error_code']); - } return $res; } diff --git a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php index b299df8..7f2bcf1 100644 --- a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php +++ b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php @@ -55,14 +55,9 @@ class KuaiTuanTuan extends BusinessClient Goods::bindGoods($goods, $this->shop->id); } - public function incrQuantity($skuId) + public function incrQuantity($businessGoodsSku, $num, $incremental, GoodsSku $goodsSku) { - $goodsSku = GoodsSku::query() - ->with(['goods:id,goods_code']) - ->find($skuId); - $code = $goodsSku->goods->goods_code . '_' . $goodsSku->sku_code; - $business = BusinessGoodsSku::query()->where('shop_id', $this->shop->id)->where('external_sku_id', $code)->first(['goods_id', 'sku_id']); - [$type, $appendParams] = Goods::incrQuantity($business->goods_id, $goodsSku->stock, $business->sku_id); + [$type, $appendParams] = Goods::incrQuantity($businessGoodsSku->goods_id, $num, $businessGoodsSku->sku_id, $incremental ? 1 : 2); $this->doRequest($type, $appendParams); } @@ -72,11 +67,10 @@ class KuaiTuanTuan extends BusinessClient * @param $beginTime * @param $endTime * @param int $page - * @param string $activityNo * @param string $downloadType - * @return mixed + * @return void */ - public function downloadOrdersAndSave($beginTime, $endTime, $page = 1, $activityNo = '', $downloadType = 'default') + public function downloadOrdersAndSave($beginTime, $endTime, $downloadType = 'default', $page = 1) { if ('increment' === $downloadType) { [$type, $appendParams] = Order::downloadIncrementOrders($beginTime, $endTime, $page); @@ -93,11 +87,6 @@ class KuaiTuanTuan extends BusinessClient } } - public function saveOrders($orders) - { - Order::saveOrders($orders, $this->shop->id); - } - protected function getAccessTokenWithCode() { $type = 'pdd.pop.auth.token.create'; @@ -134,14 +123,6 @@ class KuaiTuanTuan extends BusinessClient return $this->formDataPostRequest($url, $publicParams); } - - public function getAuthUrl($shopId, $platId) - { - $state = $shopId . '_' . $platId; - - return "https://oauth.pinduoduo.com/authorize/ktt?client_id={$this->clientId}&redirect_uri={$this->redirectUri}&state={$state}"; - } - public function downloadGoods($skuId) { $goodsSku = GoodsSku::query() @@ -154,4 +135,11 @@ class KuaiTuanTuan extends BusinessClient $goods = $res['response']['result']; $this->bindGoods([$goods]); } + + public function getAuthUrl($shopId, $platId) + { + $state = $shopId . '_' . $platId; + + return "https://oauth.pinduoduo.com/authorize/ktt?client_id={$this->clientId}&redirect_uri={$this->redirectUri}&state={$state}"; + } } diff --git a/app/Services/Business/KuaiTuanTuan/Order.php b/app/Services/Business/KuaiTuanTuan/Order.php index d9d74f9..6fcdbc5 100644 --- a/app/Services/Business/KuaiTuanTuan/Order.php +++ b/app/Services/Business/KuaiTuanTuan/Order.php @@ -2,10 +2,6 @@ namespace App\Services\Business\KuaiTuanTuan; -use App\Listeners\UpdateBusinessGoodsStock; -use App\Models\BusinessOrder; -use App\Models\BusinessOrderItem; - class Order { /** @@ -21,8 +17,8 @@ class Order 'page_size' => 100, // 数量, 必填, 1~100 // 非必填 // 'activity_no' => $activityNo, // 团号 - 'after_sales_status' => 0, // 售后状态, 可选 0-未发起售后 1-退款中 2-退款成功 3-待处理 4-拒绝退款 6-待(顾客)退货 7-待(团长)确认退货 8-(顾客)撤销 9-(系统)关闭 - 'cancel_status' => 0, // 取消状态, 可选 0-未取消 1-已取消 +// 'after_sales_status' => 0, // 售后状态, 可选 0-未发起售后 1-退款中 2-退款成功 3-待处理 4-拒绝退款 6-待(顾客)退货 7-待(团长)确认退货 8-(顾客)撤销 9-(系统)关闭 +// 'cancel_status' => 0, // 取消状态, 可选 0-未取消 1-已取消 // 'shipping_status' => '', // 发货状态 0-未发货 1-已发货 2-部分发货 3-已收货 // 'verification_status' => '', // 核销状态, 可选 0-未核销 1-已核销 2-部分核销 ]; @@ -43,34 +39,13 @@ class Order 'page_size' => 100, // 数量 // 非必填 // 'activity_no' => $activityNo, // 团号 - 'after_sales_status' => 0, // 售后状态, 可选 0-未发起售后 1-退款中 2-退款成功 3-待处理 4-拒绝退款 6-待(顾客)退货 7-待(团长)确认退货 8-(顾客)撤销 9-(系统)关闭 - 'cancel_status' => 0, // 取消状态, 可选 0-未取消 1-已取消 +// 'after_sales_status' => 0, // 售后状态, 可选 0-未发起售后 1-退款中 2-退款成功 3-待处理 4-拒绝退款 6-待(顾客)退货 7-待(团长)确认退货 8-(顾客)撤销 9-(系统)关闭 +// 'cancel_status' => 0, // 取消状态, 可选 0-未取消 1-已取消 // 'shipping_status' => '', // 发货状态 0-未发货 1-已发货 2-部分发货 3-已收货 // 'verification_status' => '', // 核销状态, 可选 0-未核销 1-已核销 2-部分核销 ]; return [$type, $appendParams]; } - - // 下载订单事件之后去统计 然后更新库存 - public static function saveOrders(array $orders, $shopId) - { - $updateOrders = []; - foreach ($orders as $order) { - unset($order['custom_item_list'], $order['logistics_list'], $order['gift_order_list']); - $orderRecord = BusinessOrder::updateOrCreate( - ['shop_id' => $shopId, 'order_sn' => $order['order_sn']], - $order - ); - $updateOrders[] = $order['order_sn']; - foreach ($order['sub_order_list'] as $item) { - BusinessOrderItem::updateOrCreate( - ['shop_id' => $shopId, 'business_order_id' => $orderRecord->id, 'goods_id' => $item['goods_id'], 'sku_id' => $item['sku_id']], - $item - ); - } - } - event(new UpdateBusinessGoodsStock($shopId, $updateOrders)); - } } diff --git a/app/Services/Business/MiaoXuan/MiaoXuan.php b/app/Services/Business/MiaoXuan/MiaoXuan.php index 7abbdff..7840e27 100644 --- a/app/Services/Business/MiaoXuan/MiaoXuan.php +++ b/app/Services/Business/MiaoXuan/MiaoXuan.php @@ -24,24 +24,17 @@ class MiaoXuan extends BusinessClient Goods::bindGoods($goods, $this->shop->id); } - public function incrQuantity($skuId) + public function incrQuantity($businessGoodsSku, $num, $incremental, GoodsSku $goodsSku) { - $goodsSku = GoodsSku::query()->find($skuId); - $business = BusinessGoodsSku::query()->where('shop_id', $this->shop->id)->where('self_sku_id', $skuId)->first(['goods_id', 'sku_id', 'external_sku_id'])->toArray(); - $appendParams = Goods::incrQuantity($this->shop->id, $goodsSku->stock, $business); + $appendParams = Goods::incrQuantity($this->shop->id, $goodsSku->stock, $businessGoodsSku); $url = 'http://shop.chutang66.com/miaoxuan/stock'; $this->formDataPostRequest($url, $appendParams); } - public function downloadOrdersAndSave($beginTime, $endTime, $page = 1, $activityNo = '', $downloadType = 'default') + public function downloadOrdersAndSave($beginTime, $endTime, $downloadType = 'default', $page = 1) { } - public function saveOrders($orders) - { - Order::saveOrders($orders, $this->shop->id); - } - public function downloadGoods($skuId) { // TODO: Implement downloadGoods() method. diff --git a/app/Services/Business/MiaoXuan/Order.php b/app/Services/Business/MiaoXuan/Order.php index 89c6e73..43c0e9e 100644 --- a/app/Services/Business/MiaoXuan/Order.php +++ b/app/Services/Business/MiaoXuan/Order.php @@ -2,29 +2,7 @@ namespace App\Services\Business\MiaoXuan; -use App\Listeners\UpdateBusinessGoodsStock; -use App\Models\BusinessOrder; - class Order { - // 下载订单事件之后去统计 然后更新库存 - public static function saveOrders(array $orders, $shopId) - { - $updateOrders = []; - foreach ($orders as $order) { - $orderRecord = BusinessOrder::updateOrCreate( - ['shop_id' => $shopId, 'order_sn' => $order['order_sn']], - $order - ); - $updateOrders[] = $order['order_sn']; - foreach ($order['sub_order_list'] as $item) { - $orderRecord = BusinessOrder::updateOrCreate( - ['shop_id' => $shopId, 'business_order_id' => $orderRecord->id, 'goods_id' => $item['goods_id'], 'sku_id' => $item['sku_id']], - $item - ); - } - } - event(new UpdateBusinessGoodsStock($shopId, $updateOrders)); - } } From a7842b850df81288b84fd4fd4033e7a6f3df7e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Thu, 11 Aug 2022 04:06:38 +0800 Subject: [PATCH 57/68] =?UTF-8?q?feat:=20#1000=20=E5=A6=99=E9=80=89?= =?UTF-8?q?=E5=95=86=E5=93=81=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Shop/ShopsController.php | 4 +++- app/Services/Business/BusinessFactory.php | 2 ++ app/Services/Business/MiaoXuan/MiaoXuan.php | 2 -- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Shop/ShopsController.php b/app/Http/Controllers/Shop/ShopsController.php index 872a4d9..674ec89 100644 --- a/app/Http/Controllers/Shop/ShopsController.php +++ b/app/Http/Controllers/Shop/ShopsController.php @@ -48,7 +48,7 @@ class ShopsController extends Controller $shop = new Shop(); $shop->name = $request->name; $shop->plat_id = $request->plat_id; - if (0 === $request->plat_id) { + if (0 == $request->plat_id) { $shop->status = 2; } $shop->save(); @@ -96,5 +96,7 @@ class ShopsController extends Controller if ('orders' === $request->get('type')) { $business->saveOrders($request->get('data')); } + + return response(['Code' => 10000, 'Message' => 'SUCCESS']); } } diff --git a/app/Services/Business/BusinessFactory.php b/app/Services/Business/BusinessFactory.php index b34277c..c160d3a 100644 --- a/app/Services/Business/BusinessFactory.php +++ b/app/Services/Business/BusinessFactory.php @@ -3,6 +3,7 @@ namespace App\Services\Business; use App\Services\Business\KuaiTuanTuan\KuaiTuanTuan; +use App\Services\Business\MiaoXuan\MiaoXuan; class BusinessFactory { @@ -11,6 +12,7 @@ class BusinessFactory public function __construct() { $this->platList['快团团'] = KuaiTuanTuan::class; + $this->platList['妙选'] = MiaoXuan::class; } public function make($platName) diff --git a/app/Services/Business/MiaoXuan/MiaoXuan.php b/app/Services/Business/MiaoXuan/MiaoXuan.php index 7840e27..f2e64ae 100644 --- a/app/Services/Business/MiaoXuan/MiaoXuan.php +++ b/app/Services/Business/MiaoXuan/MiaoXuan.php @@ -2,9 +2,7 @@ namespace App\Services\Business\MiaoXuan; -use App\Models\BusinessGoodsSku; use App\Models\GoodsSku; -use App\Models\Log; use App\Services\Business\BusinessClient; class MiaoXuan extends BusinessClient From 804162083bef07b73684412ee15a9d9c6a354fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Thu, 11 Aug 2022 05:11:14 +0800 Subject: [PATCH 58/68] =?UTF-8?q?feat:=20#10000=20=E5=A6=99=E9=80=89?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=8E=A8=E9=80=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Listeners/UpdateBusinessGoodsStock.php | 3 +++ app/Services/Business/BusinessClient.php | 17 +++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/Listeners/UpdateBusinessGoodsStock.php b/app/Listeners/UpdateBusinessGoodsStock.php index 8f99cbf..9c54e2b 100644 --- a/app/Listeners/UpdateBusinessGoodsStock.php +++ b/app/Listeners/UpdateBusinessGoodsStock.php @@ -36,6 +36,9 @@ class UpdateBusinessGoodsStock implements ShouldQueue public function handle(Registered $event) { $shops = Shop::query()->where('id', '<>', $this->businessOrderItem->shop_id)->where('status', 1)->get(['id', 'plat_id']); + if (empty($shops)) { + return; + } [$goodsCode, $skuCode] = explode('_', $this->businessOrderItem->external_sku_id); $goodsSku = GoodsSku::query()->where('sku_code', $skuCode) ->with(['goods' => function ($query) use ($goodsCode) { diff --git a/app/Services/Business/BusinessClient.php b/app/Services/Business/BusinessClient.php index be66a2a..d1392ed 100644 --- a/app/Services/Business/BusinessClient.php +++ b/app/Services/Business/BusinessClient.php @@ -5,6 +5,7 @@ namespace App\Services\Business; use App\Listeners\UpdateBusinessGoodsStock; use App\Models\BusinessGoodsSku; use App\Models\BusinessOrder; +use App\Models\BusinessOrderItem; use App\Models\GoodsSku; use App\Models\Log; use App\Models\Shop; @@ -35,21 +36,17 @@ abstract class BusinessClient foreach ($orders as $order) { unset($order['custom_item_list'], $order['logistics_list'], $order['gift_order_list']); $order['shop_id'] = $shopId; - $orderRecord = BusinessOrder::query()->where('shop_id', $shopId)->where('order_sn', $order['order_sn'])->first(); - if (empty($orderRecord)) { - $orderRecord->create($order); + $orderRecord = BusinessOrder::firstOrNew(['shop_id' => $shopId, 'order_sn' => $order['order_sn']], $order); + if (empty($orderRecord->id)) { + $orderRecord->save(); } else { $orderRecord->update($order); } foreach ($order['sub_order_list'] as $item) { $item['shop_id'] = $shopId; - $orderItem = BusinessOrder::query()->where('shop_id', $shopId) - ->where('business_order_id', $orderRecord->id) - ->where('goods_id', $item['goods_id']) - ->where('sku_id', $item['sku_id']) - ->first(); + $orderItem = BusinessOrderItem::firstOrNew(['shop_id' => $shopId, 'business_order_id' => $orderRecord->id, 'goods_id' => $item['goods_id'], 'sku_id' => $item['sku_id']], $item); $num = 0; - if (empty($orderItem)) { + if (empty($orderItem->id)) { if ($item['cancel_status']) { if ($num = $item['goods_number'] - $item['already_cancel_number']) { // 扣库存 $reduceNum @@ -59,7 +56,7 @@ abstract class BusinessClient // 扣库存 $num = 0 - $item['goods_number']; } - $orderItem->create($item); + $orderItem->save(); } else { if ($item['cancel_status'] !== $orderItem->cancel_status) { if ($item['cancel_status']) { From 1a22edfd0590755756028b265e366a9491768d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Thu, 11 Aug 2022 11:18:21 +0800 Subject: [PATCH 59/68] =?UTF-8?q?feat:=20#10000=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E5=A2=9E=E5=8A=A0=E4=BA=8B=E4=BB=B6=E7=9B=91?= =?UTF-8?q?=E5=90=AC=E5=92=8C=E4=BB=BB=E5=8A=A1=E9=98=9F=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Events/BusinessOrdersUpdate.php | 58 + app/Http/Controllers/Shop/ShopsController.php | 2 - app/Jobs/BusinessGoodsSkuIncrQuantity.php | 45 + app/Jobs/ProcessPodcast.php | 34 - app/Listeners/SendDatabaseNotification.php | 14 +- app/Listeners/UpdateBusinessGoodsStock.php | 50 +- app/Providers/EventServiceProvider.php | 11 +- app/Services/Business/BusinessClient.php | 4 +- composer.lock | 1106 +++++++---------- 9 files changed, 557 insertions(+), 767 deletions(-) create mode 100644 app/Events/BusinessOrdersUpdate.php create mode 100644 app/Jobs/BusinessGoodsSkuIncrQuantity.php delete mode 100644 app/Jobs/ProcessPodcast.php diff --git a/app/Events/BusinessOrdersUpdate.php b/app/Events/BusinessOrdersUpdate.php new file mode 100644 index 0000000..480653b --- /dev/null +++ b/app/Events/BusinessOrdersUpdate.php @@ -0,0 +1,58 @@ +businessOrderItem = $item; + $this->num = $num; + $this->updateStock(); + } + + private function updateStock() + { + [$goodsCode, $skuCode] = explode('_', $this->businessOrderItem->external_sku_id); + $this->goodsSku = GoodsSku::query()->where('sku_code', $skuCode) + ->with(['goods' => function ($query) use ($goodsCode) { + $query->where('goods_code', $goodsCode); + }]) + ->first(); + if ($this->goodsSku) { + $this->goodsSku->stock += $this->num; + $this->goodsSku->save(); + } + } + + /** + * Get the channels the event should broadcast on. + * + * @return \Illuminate\Broadcasting\Channel|array + */ + public function broadcastOn() + { + return new PrivateChannel('channel-name'); + } +} diff --git a/app/Http/Controllers/Shop/ShopsController.php b/app/Http/Controllers/Shop/ShopsController.php index 674ec89..3f79c8e 100644 --- a/app/Http/Controllers/Shop/ShopsController.php +++ b/app/Http/Controllers/Shop/ShopsController.php @@ -3,8 +3,6 @@ namespace App\Http\Controllers\Shop; use App\Http\Controllers\Controller; -use App\Listeners\BindBusinessGoods; -use App\Listeners\UpdateBusinessGoodsStock; use App\Models\Shop; use App\Http\Resources\ShopsResource; use Illuminate\Http\Request; diff --git a/app/Jobs/BusinessGoodsSkuIncrQuantity.php b/app/Jobs/BusinessGoodsSkuIncrQuantity.php new file mode 100644 index 0000000..ca1da28 --- /dev/null +++ b/app/Jobs/BusinessGoodsSkuIncrQuantity.php @@ -0,0 +1,45 @@ +shop = $shop; + $this->businessOrderItem = $businessOrderItem; + $this->num = $num; + $this->goodsSku = $goodsSku; + } + + /** + * Execute the job. + * + * @return void + */ + public function handle() + { + BusinessFactory::init()->make($this->shop['plat_id'])->setShopId($this->shop['id'])->incrQuantity($this->businessOrderItem, $this->num, true, $this->goodsSku); + } +} diff --git a/app/Jobs/ProcessPodcast.php b/app/Jobs/ProcessPodcast.php deleted file mode 100644 index 6d4df9c..0000000 --- a/app/Jobs/ProcessPodcast.php +++ /dev/null @@ -1,34 +0,0 @@ -= $event->goodsSku->stock) { + // 发送通知给管理员 + } } } diff --git a/app/Listeners/UpdateBusinessGoodsStock.php b/app/Listeners/UpdateBusinessGoodsStock.php index 9c54e2b..92c370f 100644 --- a/app/Listeners/UpdateBusinessGoodsStock.php +++ b/app/Listeners/UpdateBusinessGoodsStock.php @@ -2,65 +2,55 @@ namespace App\Listeners; -use App\Models\GoodsSku; use App\Models\Log; use App\Models\Shop; use App\Services\Business\BusinessFactory; -use Illuminate\Auth\Events\Registered; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Queue\InteractsWithQueue; -use App\Models\BusinessOrderItem; +use App\Events\BusinessOrdersUpdate; +use App\Jobs\BusinessGoodsSkuIncrQuantity; class UpdateBusinessGoodsStock implements ShouldQueue { - protected $num; - protected $businessOrderItem; + use InteractsWithQueue; /** * Create the event listener. * * @return void */ - public function __construct(BusinessOrderItem $item, $num) + public function __construct() { - $this->businessOrderItem = $item; - $this->num = $num; + // } /** * Handle the event. * - * @param Registered $event + * @param BusinessOrdersUpdate $event * @return void */ - public function handle(Registered $event) + public function handle(BusinessOrdersUpdate $event) { - $shops = Shop::query()->where('id', '<>', $this->businessOrderItem->shop_id)->where('status', 1)->get(['id', 'plat_id']); - if (empty($shops)) { - return; - } - [$goodsCode, $skuCode] = explode('_', $this->businessOrderItem->external_sku_id); - $goodsSku = GoodsSku::query()->where('sku_code', $skuCode) - ->with(['goods' => function ($query) use ($goodsCode) { - $query->where('goods_code', $goodsCode); - }]) - ->first(); - if ($goodsSku) { - $goodsSku->stock += $this->num; - $goodsSku->save(); - foreach ($shops as $shop) { - BusinessFactory::init()->make($shop['plat_id'])->setShopId($shop['id'])->incrQuantity($this->businessOrderItem, $this->num, true, $goodsSku); - } - } else { + if (empty($event->goodsSku)) { $log = new Log(); $log->module = 'goods'; $log->action = 'PATCH'; $log->target_type = 'goods_sku'; - $log->target_id = $goodsSku->id; + $log->target_id = $event->goodsSku->id; $log->target_field = 'stock'; - $log->user_id = $this->businessOrderItem->shop_id; - $log->message = ($this->businessOrderItem->external_sku_id ?: '商品') . '未找到'; + $log->user_id = $event->businessOrderItem->shop_id; + $log->message = ($event->businessOrderItem->external_sku_id ?: '商品') . '未找到'; $log->save(); + return; + } + $shops = Shop::query()->where('id', '<>', $event->businessOrderItem->shop_id)->where('status', 1)->get(['id', 'plat_id']); + if (empty($shops)) { + return; + } + + foreach ($shops as $shop) { + BusinessGoodsSkuIncrQuantity::dispatch($shop, $event->businessOrderItem, $event->num, $event->goodsSku); } } } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index b975ef6..5b96a8e 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -2,12 +2,9 @@ namespace App\Providers; -use Illuminate\Auth\Events\Registered; -use Illuminate\Auth\Listeners\SendEmailVerificationNotification; +use App\Listeners\SendDatabaseNotification; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; use Illuminate\Support\Facades\Event; -use App\Listeners\SendDatabaseNotification; -use App\Listeners\BindBusinessGoods; use App\Listeners\UpdateBusinessGoodsStock; class EventServiceProvider extends ServiceProvider @@ -18,11 +15,9 @@ class EventServiceProvider extends ServiceProvider * @var array */ protected $listen = [ - Registered::class => [ - SendEmailVerificationNotification::class, - SendDatabaseNotification::class, - BindBusinessGoods::class, + 'App\Events\BusinessOrdersUpdate' => [ UpdateBusinessGoodsStock::class, + SendDatabaseNotification::class, ], ]; diff --git a/app/Services/Business/BusinessClient.php b/app/Services/Business/BusinessClient.php index d1392ed..47c9ea2 100644 --- a/app/Services/Business/BusinessClient.php +++ b/app/Services/Business/BusinessClient.php @@ -2,7 +2,7 @@ namespace App\Services\Business; -use App\Listeners\UpdateBusinessGoodsStock; +use App\Events\BusinessOrdersUpdate; use App\Models\BusinessGoodsSku; use App\Models\BusinessOrder; use App\Models\BusinessOrderItem; @@ -71,7 +71,7 @@ abstract class BusinessClient } // 增量更新库存 if ($num) { - event(new UpdateBusinessGoodsStock($orderItem, $num)); + event(new BusinessOrdersUpdate($orderItem, $num)); } } } diff --git a/composer.lock b/composer.lock index 4c69252..7144aa9 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "aliyuncs/oss-sdk-php", - "version": "v2.5.0", + "version": "v2.6.0", "source": { "type": "git", "url": "https://github.com/aliyun/aliyun-oss-php-sdk.git", - "reference": "f0413667d765855eb0aaa728b596801464ffdb06" + "reference": "572d0f8e099e8630ae7139ed3fdedb926c7a760f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/f0413667d765855eb0aaa728b596801464ffdb06", - "reference": "f0413667d765855eb0aaa728b596801464ffdb06", + "url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/572d0f8e099e8630ae7139ed3fdedb926c7a760f", + "reference": "572d0f8e099e8630ae7139ed3fdedb926c7a760f", "shasum": "" }, "require": { @@ -47,9 +47,9 @@ "homepage": "http://www.aliyun.com/product/oss/", "support": { "issues": "https://github.com/aliyun/aliyun-oss-php-sdk/issues", - "source": "https://github.com/aliyun/aliyun-oss-php-sdk/tree/v2.5.0" + "source": "https://github.com/aliyun/aliyun-oss-php-sdk/tree/v2.6.0" }, - "time": "2022-05-13T07:41:28+00:00" + "time": "2022-08-03T08:06:01+00:00" }, { "name": "beyondcode/laravel-websockets", @@ -595,25 +595,25 @@ }, { "name": "facade/ignition-contracts", - "version": "1.0.2", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/facade/ignition-contracts.git", - "reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267" + "reference": "aeab1ce8b68b188a43e81758e750151ad7da796b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/facade/ignition-contracts/zipball/3c921a1cdba35b68a7f0ccffc6dffc1995b18267", - "reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267", + "url": "https://api.github.com/repos/facade/ignition-contracts/zipball/aeab1ce8b68b188a43e81758e750151ad7da796b", + "reference": "aeab1ce8b68b188a43e81758e750151ad7da796b", "shasum": "" }, "require": { - "php": "^7.3|^8.0" + "php": "^7.1" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^v2.15.8", - "phpunit/phpunit": "^9.3.11", - "vimeo/psalm": "^3.17.1" + "friendsofphp/php-cs-fixer": "^2.14", + "phpunit/phpunit": "^7.5|^8.0", + "vimeo/psalm": "^3.12" }, "type": "library", "autoload": { @@ -642,9 +642,9 @@ ], "support": { "issues": "https://github.com/facade/ignition-contracts/issues", - "source": "https://github.com/facade/ignition-contracts/tree/1.0.2" + "source": "https://github.com/facade/ignition-contracts/tree/1.0.1" }, - "time": "2020-10-16T08:27:54+00:00" + "time": "2020-07-14T10:10:28+00:00" }, { "name": "fideloper/proxy", @@ -1889,16 +1889,16 @@ }, { "name": "monolog/monolog", - "version": "2.7.0", + "version": "2.8.0", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "5579edf28aee1190a798bfa5be8bc16c563bd524" + "reference": "720488632c590286b88b80e62aa3d3d551ad4a50" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/5579edf28aee1190a798bfa5be8bc16c563bd524", - "reference": "5579edf28aee1190a798bfa5be8bc16c563bd524", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/720488632c590286b88b80e62aa3d3d551ad4a50", + "reference": "720488632c590286b88b80e62aa3d3d551ad4a50", "shasum": "" }, "require": { @@ -1918,11 +1918,10 @@ "guzzlehttp/psr7": "^2.2", "mongodb/mongodb": "^1.8", "php-amqplib/php-amqplib": "~2.4 || ^3", - "php-console/php-console": "^3.1.3", "phpspec/prophecy": "^1.15", "phpstan/phpstan": "^0.12.91", "phpunit/phpunit": "^8.5.14", - "predis/predis": "^1.1", + "predis/predis": "^1.1 || ^2.0", "rollbar/rollbar": "^1.3 || ^2 || ^3", "ruflin/elastica": "^7", "swiftmailer/swiftmailer": "^5.3|^6.0", @@ -1942,7 +1941,6 @@ "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", "mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)", "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", - "php-console/php-console": "Allow sending log messages to Google Chrome", "rollbar/rollbar": "Allow sending log messages to Rollbar", "ruflin/elastica": "Allow sending log messages to an Elastic Search server" }, @@ -1977,7 +1975,7 @@ ], "support": { "issues": "https://github.com/Seldaek/monolog/issues", - "source": "https://github.com/Seldaek/monolog/tree/2.7.0" + "source": "https://github.com/Seldaek/monolog/tree/2.8.0" }, "funding": [ { @@ -1989,30 +1987,30 @@ "type": "tidelift" } ], - "time": "2022-06-09T08:59:12+00:00" + "time": "2022-07-24T11:55:47+00:00" }, { "name": "myclabs/php-enum", - "version": "1.8.3", + "version": "1.7.7", "source": { "type": "git", "url": "https://github.com/myclabs/php-enum.git", - "reference": "b942d263c641ddb5190929ff840c68f78713e937" + "reference": "d178027d1e679832db9f38248fcc7200647dc2b7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/php-enum/zipball/b942d263c641ddb5190929ff840c68f78713e937", - "reference": "b942d263c641ddb5190929ff840c68f78713e937", + "url": "https://api.github.com/repos/myclabs/php-enum/zipball/d178027d1e679832db9f38248fcc7200647dc2b7", + "reference": "d178027d1e679832db9f38248fcc7200647dc2b7", "shasum": "" }, "require": { "ext-json": "*", - "php": "^7.3 || ^8.0" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "^9.5", + "phpunit/phpunit": "^7", "squizlabs/php_codesniffer": "1.*", - "vimeo/psalm": "^4.6.2" + "vimeo/psalm": "^3.8" }, "type": "library", "autoload": { @@ -2037,7 +2035,7 @@ ], "support": { "issues": "https://github.com/myclabs/php-enum/issues", - "source": "https://github.com/myclabs/php-enum/tree/1.8.3" + "source": "https://github.com/myclabs/php-enum/tree/1.7.7" }, "funding": [ { @@ -2049,20 +2047,20 @@ "type": "tidelift" } ], - "time": "2021-07-05T08:18:36+00:00" + "time": "2020-11-14T18:14:52+00:00" }, { "name": "nesbot/carbon", - "version": "2.59.1", + "version": "2.61.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "a9000603ea337c8df16cc41f8b6be95a65f4d0f5" + "reference": "bdf4f4fe3a3eac4de84dbec0738082a862c68ba6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/a9000603ea337c8df16cc41f8b6be95a65f4d0f5", - "reference": "a9000603ea337c8df16cc41f8b6be95a65f4d0f5", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/bdf4f4fe3a3eac4de84dbec0738082a862c68ba6", + "reference": "bdf4f4fe3a3eac4de84dbec0738082a862c68ba6", "shasum": "" }, "require": { @@ -2151,7 +2149,7 @@ "type": "tidelift" } ], - "time": "2022-06-29T21:43:55+00:00" + "time": "2022-08-06T12:41:24+00:00" }, { "name": "nikic/php-parser", @@ -2412,16 +2410,16 @@ }, { "name": "phpoffice/phpspreadsheet", - "version": "1.24.1", + "version": "1.19.0", "source": { "type": "git", "url": "https://github.com/PHPOffice/PhpSpreadsheet.git", - "reference": "69991111e05fca3ff7398e1e7fca9ebed33efec6" + "reference": "a9ab55bfae02eecffb3df669a2e19ba0e2f04bbf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/69991111e05fca3ff7398e1e7fca9ebed33efec6", - "reference": "69991111e05fca3ff7398e1e7fca9ebed33efec6", + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/a9ab55bfae02eecffb3df669a2e19ba0e2f04bbf", + "reference": "a9ab55bfae02eecffb3df669a2e19ba0e2f04bbf", "shasum": "" }, "require": { @@ -2442,23 +2440,23 @@ "maennchen/zipstream-php": "^2.1", "markbaker/complex": "^3.0", "markbaker/matrix": "^3.0", - "php": "^7.3 || ^8.0", + "php": "^7.2 || ^8.0", "psr/http-client": "^1.0", "psr/http-factory": "^1.0", - "psr/simple-cache": "^1.0 || ^2.0" + "psr/simple-cache": "^1.0" }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "dev-master", - "dompdf/dompdf": "^1.0 || ^2.0", - "friendsofphp/php-cs-fixer": "^3.2", + "dompdf/dompdf": "^1.0", + "friendsofphp/php-cs-fixer": "^2.18", "jpgraph/jpgraph": "^4.0", - "mpdf/mpdf": "8.1.1", + "mpdf/mpdf": "^8.0", "phpcompatibility/php-compatibility": "^9.3", - "phpstan/phpstan": "^1.1", - "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^8.5 || ^9.0", - "squizlabs/php_codesniffer": "^3.7", - "tecnickcom/tcpdf": "^6.4" + "phpstan/phpstan": "^0.12.82", + "phpstan/phpstan-phpunit": "^0.12.18", + "phpunit/phpunit": "^8.5", + "squizlabs/php_codesniffer": "^3.5", + "tecnickcom/tcpdf": "^6.3" }, "suggest": { "dompdf/dompdf": "Option for rendering PDF with PDF Writer (doesn't yet support PHP8)", @@ -2510,35 +2508,39 @@ ], "support": { "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues", - "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.24.1" + "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.19.0" }, - "time": "2022-07-18T19:50:48+00:00" + "time": "2021-10-31T15:09:20+00:00" }, { "name": "phpoption/phpoption", - "version": "1.8.1", + "version": "1.9.0", "source": { "type": "git", "url": "https://github.com/schmittjoh/php-option.git", - "reference": "eab7a0df01fe2344d172bff4cd6dbd3f8b84ad15" + "reference": "dc5ff11e274a90cc1c743f66c9ad700ce50db9ab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/eab7a0df01fe2344d172bff4cd6dbd3f8b84ad15", - "reference": "eab7a0df01fe2344d172bff4cd6dbd3f8b84ad15", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/dc5ff11e274a90cc1c743f66c9ad700ce50db9ab", + "reference": "dc5ff11e274a90cc1c743f66c9ad700ce50db9ab", "shasum": "" }, "require": { - "php": "^7.0 || ^8.0" + "php": "^7.2.5 || ^8.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.4.1", - "phpunit/phpunit": "^6.5.14 || ^7.5.20 || ^8.5.19 || ^9.5.8" + "bamarni/composer-bin-plugin": "^1.8", + "phpunit/phpunit": "^8.5.28 || ^9.5.21" }, "type": "library", "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": true + }, "branch-alias": { - "dev-master": "1.8-dev" + "dev-master": "1.9-dev" } }, "autoload": { @@ -2571,7 +2573,7 @@ ], "support": { "issues": "https://github.com/schmittjoh/php-option/issues", - "source": "https://github.com/schmittjoh/php-option/tree/1.8.1" + "source": "https://github.com/schmittjoh/php-option/tree/1.9.0" }, "funding": [ { @@ -2583,7 +2585,7 @@ "type": "tidelift" } ], - "time": "2021-12-04T23:24:31+00:00" + "time": "2022-07-30T15:51:26+00:00" }, { "name": "psr/container", @@ -2896,16 +2898,16 @@ }, { "name": "psy/psysh", - "version": "v0.11.7", + "version": "v0.11.8", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "77fc7270031fbc28f9a7bea31385da5c4855cb7a" + "reference": "f455acf3645262ae389b10e9beba0c358aa6994e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/77fc7270031fbc28f9a7bea31385da5c4855cb7a", - "reference": "77fc7270031fbc28f9a7bea31385da5c4855cb7a", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/f455acf3645262ae389b10e9beba0c358aa6994e", + "reference": "f455acf3645262ae389b10e9beba0c358aa6994e", "shasum": "" }, "require": { @@ -2966,35 +2968,34 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.11.7" + "source": "https://github.com/bobthecow/psysh/tree/v0.11.8" }, - "time": "2022-07-07T13:49:11+00:00" + "time": "2022-07-28T14:25:11+00:00" }, { "name": "pusher/pusher-php-server", - "version": "7.0.2", + "version": "6.1.0", "source": { "type": "git", "url": "https://github.com/pusher/pusher-http-php.git", - "reference": "af3eeaefc0c7959f5b3852f0a4dd5547245d33df" + "reference": "8673f60458ceedb9531fad7a5747eb49de619a8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pusher/pusher-http-php/zipball/af3eeaefc0c7959f5b3852f0a4dd5547245d33df", - "reference": "af3eeaefc0c7959f5b3852f0a4dd5547245d33df", + "url": "https://api.github.com/repos/pusher/pusher-http-php/zipball/8673f60458ceedb9531fad7a5747eb49de619a8a", + "reference": "8673f60458ceedb9531fad7a5747eb49de619a8a", "shasum": "" }, "require": { "ext-curl": "*", - "ext-json": "*", "guzzlehttp/guzzle": "^7.2", "paragonie/sodium_compat": "^1.6", - "php": "^7.3|^8.0", - "psr/log": "^1.0|^2.0|^3.0" + "php": "^7.2.5|^8.0", + "psr/log": "^1.0" }, "require-dev": { "overtrue/phplint": "^2.3", - "phpunit/phpunit": "^8.5|^9.3" + "phpunit/phpunit": "^7.2|^8.5|^9.3" }, "type": "library", "extra": { @@ -3027,9 +3028,9 @@ ], "support": { "issues": "https://github.com/pusher/pusher-http-php/issues", - "source": "https://github.com/pusher/pusher-http-php/tree/7.0.2" + "source": "https://github.com/pusher/pusher-http-php/tree/6.1.0" }, - "time": "2021-12-07T13:09:00+00:00" + "time": "2021-03-24T08:23:36+00:00" }, { "name": "ralouphie/getallheaders", @@ -4198,16 +4199,16 @@ }, { "name": "symfony/console", - "version": "v4.4.43", + "version": "v4.4.44", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "8a2628d2d5639f35113dc1b833ecd91e1ed1cf46" + "reference": "c35fafd7f12ebd6f9e29c95a370df7f1fb171a40" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/8a2628d2d5639f35113dc1b833ecd91e1ed1cf46", - "reference": "8a2628d2d5639f35113dc1b833ecd91e1ed1cf46", + "url": "https://api.github.com/repos/symfony/console/zipball/c35fafd7f12ebd6f9e29c95a370df7f1fb171a40", + "reference": "c35fafd7f12ebd6f9e29c95a370df7f1fb171a40", "shasum": "" }, "require": { @@ -4268,7 +4269,7 @@ "description": "Eases the creation of beautiful and testable command line interfaces", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/console/tree/v4.4.43" + "source": "https://github.com/symfony/console/tree/v4.4.44" }, "funding": [ { @@ -4284,20 +4285,20 @@ "type": "tidelift" } ], - "time": "2022-06-23T12:22:25+00:00" + "time": "2022-07-20T09:59:04+00:00" }, { "name": "symfony/css-selector", - "version": "v5.4.3", + "version": "v5.4.11", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "b0a190285cd95cb019237851205b8140ef6e368e" + "reference": "c1681789f059ab756001052164726ae88512ae3d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/b0a190285cd95cb019237851205b8140ef6e368e", - "reference": "b0a190285cd95cb019237851205b8140ef6e368e", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/c1681789f059ab756001052164726ae88512ae3d", + "reference": "c1681789f059ab756001052164726ae88512ae3d", "shasum": "" }, "require": { @@ -4334,7 +4335,7 @@ "description": "Converts CSS selectors to XPath expressions", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/css-selector/tree/v5.4.3" + "source": "https://github.com/symfony/css-selector/tree/v5.4.11" }, "funding": [ { @@ -4350,20 +4351,20 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:53:40+00:00" + "time": "2022-06-27T16:58:25+00:00" }, { "name": "symfony/debug", - "version": "v4.4.41", + "version": "v4.4.44", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "6637e62480b60817b9a6984154a533e8e64c6bd5" + "reference": "1a692492190773c5310bc7877cb590c04c2f05be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/6637e62480b60817b9a6984154a533e8e64c6bd5", - "reference": "6637e62480b60817b9a6984154a533e8e64c6bd5", + "url": "https://api.github.com/repos/symfony/debug/zipball/1a692492190773c5310bc7877cb590c04c2f05be", + "reference": "1a692492190773c5310bc7877cb590c04c2f05be", "shasum": "" }, "require": { @@ -4402,7 +4403,7 @@ "description": "Provides tools to ease debugging PHP code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/debug/tree/v4.4.41" + "source": "https://github.com/symfony/debug/tree/v4.4.44" }, "funding": [ { @@ -4419,7 +4420,7 @@ } ], "abandoned": "symfony/error-handler", - "time": "2022-04-12T15:19:55+00:00" + "time": "2022-07-28T16:29:46+00:00" }, { "name": "symfony/deprecation-contracts", @@ -4490,16 +4491,16 @@ }, { "name": "symfony/error-handler", - "version": "v4.4.41", + "version": "v4.4.44", "source": { "type": "git", "url": "https://github.com/symfony/error-handler.git", - "reference": "529feb0e03133dbd5fd3707200147cc4903206da" + "reference": "be731658121ef2d8be88f3a1ec938148a9237291" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/error-handler/zipball/529feb0e03133dbd5fd3707200147cc4903206da", - "reference": "529feb0e03133dbd5fd3707200147cc4903206da", + "url": "https://api.github.com/repos/symfony/error-handler/zipball/be731658121ef2d8be88f3a1ec938148a9237291", + "reference": "be731658121ef2d8be88f3a1ec938148a9237291", "shasum": "" }, "require": { @@ -4538,7 +4539,7 @@ "description": "Provides tools to manage errors and ease debugging PHP code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/error-handler/tree/v4.4.41" + "source": "https://github.com/symfony/error-handler/tree/v4.4.44" }, "funding": [ { @@ -4554,20 +4555,20 @@ "type": "tidelift" } ], - "time": "2022-04-12T15:19:55+00:00" + "time": "2022-07-28T16:29:46+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.4.42", + "version": "v4.4.44", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "708e761740c16b02c86e3f0c932018a06b895d40" + "reference": "1e866e9e5c1b22168e0ce5f0b467f19bba61266a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/708e761740c16b02c86e3f0c932018a06b895d40", - "reference": "708e761740c16b02c86e3f0c932018a06b895d40", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/1e866e9e5c1b22168e0ce5f0b467f19bba61266a", + "reference": "1e866e9e5c1b22168e0ce5f0b467f19bba61266a", "shasum": "" }, "require": { @@ -4622,7 +4623,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v4.4.42" + "source": "https://github.com/symfony/event-dispatcher/tree/v4.4.44" }, "funding": [ { @@ -4638,7 +4639,7 @@ "type": "tidelift" } ], - "time": "2022-05-05T15:33:49+00:00" + "time": "2022-07-20T09:59:04+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -4721,16 +4722,16 @@ }, { "name": "symfony/finder", - "version": "v4.4.41", + "version": "v4.4.44", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "40790bdf293b462798882ef6da72bb49a4a6633a" + "reference": "66bd787edb5e42ff59d3523f623895af05043e4f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/40790bdf293b462798882ef6da72bb49a4a6633a", - "reference": "40790bdf293b462798882ef6da72bb49a4a6633a", + "url": "https://api.github.com/repos/symfony/finder/zipball/66bd787edb5e42ff59d3523f623895af05043e4f", + "reference": "66bd787edb5e42ff59d3523f623895af05043e4f", "shasum": "" }, "require": { @@ -4763,7 +4764,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v4.4.41" + "source": "https://github.com/symfony/finder/tree/v4.4.44" }, "funding": [ { @@ -4779,7 +4780,7 @@ "type": "tidelift" } ], - "time": "2022-04-14T15:36:10+00:00" + "time": "2022-07-29T07:35:46+00:00" }, { "name": "symfony/http-client-contracts", @@ -4861,16 +4862,16 @@ }, { "name": "symfony/http-foundation", - "version": "v4.4.43", + "version": "v4.4.44", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "4441dada27f9208e03f449d73cb9253c639e53c5" + "reference": "9bc83c2f78949fc64503134a3139a7b055890d06" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/4441dada27f9208e03f449d73cb9253c639e53c5", - "reference": "4441dada27f9208e03f449d73cb9253c639e53c5", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/9bc83c2f78949fc64503134a3139a7b055890d06", + "reference": "9bc83c2f78949fc64503134a3139a7b055890d06", "shasum": "" }, "require": { @@ -4909,7 +4910,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v4.4.43" + "source": "https://github.com/symfony/http-foundation/tree/v4.4.44" }, "funding": [ { @@ -4925,20 +4926,20 @@ "type": "tidelift" } ], - "time": "2022-06-19T13:07:44+00:00" + "time": "2022-07-20T09:59:04+00:00" }, { "name": "symfony/http-kernel", - "version": "v4.4.43", + "version": "v4.4.44", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "c4c33fb9203e6f166ac0f318ce34e00686702522" + "reference": "9e444442334fae9637ef3209bc2abddfef49e714" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/c4c33fb9203e6f166ac0f318ce34e00686702522", - "reference": "c4c33fb9203e6f166ac0f318ce34e00686702522", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/9e444442334fae9637ef3209bc2abddfef49e714", + "reference": "9e444442334fae9637ef3209bc2abddfef49e714", "shasum": "" }, "require": { @@ -5013,7 +5014,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v4.4.43" + "source": "https://github.com/symfony/http-kernel/tree/v4.4.44" }, "funding": [ { @@ -5029,20 +5030,20 @@ "type": "tidelift" } ], - "time": "2022-06-26T16:51:30+00:00" + "time": "2022-07-29T12:23:38+00:00" }, { "name": "symfony/mime", - "version": "v5.4.10", + "version": "v5.4.11", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "02265e1e5111c3cd7480387af25e82378b7ab9cc" + "reference": "3cd175cdcdb6db2e589e837dd46aff41027d9830" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/02265e1e5111c3cd7480387af25e82378b7ab9cc", - "reference": "02265e1e5111c3cd7480387af25e82378b7ab9cc", + "url": "https://api.github.com/repos/symfony/mime/zipball/3cd175cdcdb6db2e589e837dd46aff41027d9830", + "reference": "3cd175cdcdb6db2e589e837dd46aff41027d9830", "shasum": "" }, "require": { @@ -5096,7 +5097,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v5.4.10" + "source": "https://github.com/symfony/mime/tree/v5.4.11" }, "funding": [ { @@ -5112,7 +5113,7 @@ "type": "tidelift" } ], - "time": "2022-06-09T12:22:40+00:00" + "time": "2022-07-20T11:34:24+00:00" }, { "name": "symfony/polyfill-ctype", @@ -5773,16 +5774,16 @@ }, { "name": "symfony/process", - "version": "v4.4.41", + "version": "v4.4.44", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "9eedd60225506d56e42210a70c21bb80ca8456ce" + "reference": "5cee9cdc4f7805e2699d9fd66991a0e6df8252a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/9eedd60225506d56e42210a70c21bb80ca8456ce", - "reference": "9eedd60225506d56e42210a70c21bb80ca8456ce", + "url": "https://api.github.com/repos/symfony/process/zipball/5cee9cdc4f7805e2699d9fd66991a0e6df8252a2", + "reference": "5cee9cdc4f7805e2699d9fd66991a0e6df8252a2", "shasum": "" }, "require": { @@ -5815,7 +5816,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v4.4.41" + "source": "https://github.com/symfony/process/tree/v4.4.44" }, "funding": [ { @@ -5831,7 +5832,7 @@ "type": "tidelift" } ], - "time": "2022-04-04T10:19:07+00:00" + "time": "2022-06-27T13:16:42+00:00" }, { "name": "symfony/psr-http-message-bridge", @@ -5923,16 +5924,16 @@ }, { "name": "symfony/routing", - "version": "v4.4.41", + "version": "v4.4.44", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "c25e38d403c00d5ddcfc514f016f1b534abdf052" + "reference": "f7751fd8b60a07f3f349947a309b5bdfce22d6ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/c25e38d403c00d5ddcfc514f016f1b534abdf052", - "reference": "c25e38d403c00d5ddcfc514f016f1b534abdf052", + "url": "https://api.github.com/repos/symfony/routing/zipball/f7751fd8b60a07f3f349947a309b5bdfce22d6ae", + "reference": "f7751fd8b60a07f3f349947a309b5bdfce22d6ae", "shasum": "" }, "require": { @@ -5992,7 +5993,7 @@ "url" ], "support": { - "source": "https://github.com/symfony/routing/tree/v4.4.41" + "source": "https://github.com/symfony/routing/tree/v4.4.44" }, "funding": [ { @@ -6008,7 +6009,7 @@ "type": "tidelift" } ], - "time": "2022-04-12T15:19:55+00:00" + "time": "2022-07-20T09:59:04+00:00" }, { "name": "symfony/service-contracts", @@ -6095,16 +6096,16 @@ }, { "name": "symfony/translation", - "version": "v4.4.41", + "version": "v4.4.44", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "dcb67eae126e74507e0b4f0b9ac6ef35b37c3331" + "reference": "af947fefc306cec6ea5a1f6160c7e305a71f2493" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/dcb67eae126e74507e0b4f0b9ac6ef35b37c3331", - "reference": "dcb67eae126e74507e0b4f0b9ac6ef35b37c3331", + "url": "https://api.github.com/repos/symfony/translation/zipball/af947fefc306cec6ea5a1f6160c7e305a71f2493", + "reference": "af947fefc306cec6ea5a1f6160c7e305a71f2493", "shasum": "" }, "require": { @@ -6164,7 +6165,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v4.4.41" + "source": "https://github.com/symfony/translation/tree/v4.4.44" }, "funding": [ { @@ -6180,7 +6181,7 @@ "type": "tidelift" } ], - "time": "2022-04-21T07:22:34+00:00" + "time": "2022-07-20T09:59:04+00:00" }, { "name": "symfony/translation-contracts", @@ -6262,16 +6263,16 @@ }, { "name": "symfony/var-dumper", - "version": "v4.4.42", + "version": "v4.4.44", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "742aab50ad097bcb62d91fccb613f66b8047d2ca" + "reference": "f19951007dae942cc79b979c1fe26bfdfbeb54ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/742aab50ad097bcb62d91fccb613f66b8047d2ca", - "reference": "742aab50ad097bcb62d91fccb613f66b8047d2ca", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/f19951007dae942cc79b979c1fe26bfdfbeb54ed", + "reference": "f19951007dae942cc79b979c1fe26bfdfbeb54ed", "shasum": "" }, "require": { @@ -6331,7 +6332,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v4.4.42" + "source": "https://github.com/symfony/var-dumper/tree/v4.4.44" }, "funding": [ { @@ -6347,7 +6348,7 @@ "type": "tidelift" } ], - "time": "2022-05-21T10:00:54+00:00" + "time": "2022-07-20T09:59:04+00:00" }, { "name": "tijsverkoyen/css-to-inline-styles", @@ -6553,16 +6554,16 @@ }, { "name": "facade/flare-client-php", - "version": "1.9.1", + "version": "1.10.0", "source": { "type": "git", "url": "https://github.com/facade/flare-client-php.git", - "reference": "b2adf1512755637d0cef4f7d1b54301325ac78ed" + "reference": "213fa2c69e120bca4c51ba3e82ed1834ef3f41b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/facade/flare-client-php/zipball/b2adf1512755637d0cef4f7d1b54301325ac78ed", - "reference": "b2adf1512755637d0cef4f7d1b54301325ac78ed", + "url": "https://api.github.com/repos/facade/flare-client-php/zipball/213fa2c69e120bca4c51ba3e82ed1834ef3f41b8", + "reference": "213fa2c69e120bca4c51ba3e82ed1834ef3f41b8", "shasum": "" }, "require": { @@ -6575,7 +6576,7 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.14", - "phpunit/phpunit": "^7.5.16", + "phpunit/phpunit": "^7.5", "spatie/phpunit-snapshot-assertions": "^2.0" }, "type": "library", @@ -6606,7 +6607,7 @@ ], "support": { "issues": "https://github.com/facade/flare-client-php/issues", - "source": "https://github.com/facade/flare-client-php/tree/1.9.1" + "source": "https://github.com/facade/flare-client-php/tree/1.10.0" }, "funding": [ { @@ -6614,7 +6615,7 @@ "type": "github" } ], - "time": "2021-09-13T12:16:46+00:00" + "time": "2022-08-09T11:23:57+00:00" }, { "name": "facade/ignition", @@ -6883,33 +6884,30 @@ }, { "name": "mockery/mockery", - "version": "1.5.0", + "version": "1.3.5", "source": { "type": "git", "url": "https://github.com/mockery/mockery.git", - "reference": "c10a5f6e06fc2470ab1822fa13fa2a7380f8fbac" + "reference": "472fa8ca4e55483d55ee1e73c963718c4393791d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mockery/mockery/zipball/c10a5f6e06fc2470ab1822fa13fa2a7380f8fbac", - "reference": "c10a5f6e06fc2470ab1822fa13fa2a7380f8fbac", + "url": "https://api.github.com/repos/mockery/mockery/zipball/472fa8ca4e55483d55ee1e73c963718c4393791d", + "reference": "472fa8ca4e55483d55ee1e73c963718c4393791d", "shasum": "" }, "require": { "hamcrest/hamcrest-php": "^2.0.1", "lib-pcre": ">=7.0", - "php": "^7.3 || ^8.0" - }, - "conflict": { - "phpunit/phpunit": "<8.0" + "php": ">=5.6.0" }, "require-dev": { - "phpunit/phpunit": "^8.5 || ^9.3" + "phpunit/phpunit": "^5.7.10|^6.5|^7.5|^8.5|^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4.x-dev" + "dev-master": "1.3.x-dev" } }, "autoload": { @@ -6949,9 +6947,9 @@ ], "support": { "issues": "https://github.com/mockery/mockery/issues", - "source": "https://github.com/mockery/mockery/tree/1.5.0" + "source": "https://github.com/mockery/mockery/tree/1.3.5" }, - "time": "2022-01-20T13:18:17+00:00" + "time": "2021-09-13T15:33:03+00:00" }, { "name": "myclabs/deep-copy", @@ -7534,44 +7532,40 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.15", + "version": "7.0.15", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f" + "reference": "819f92bba8b001d4363065928088de22f25a3a48" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2e9da11878c4202f97915c1cb4bb1ca318a63f5f", - "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/819f92bba8b001d4363065928088de22f25a3a48", + "reference": "819f92bba8b001d4363065928088de22f25a3a48", "shasum": "" }, "require": { "ext-dom": "*", - "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.13.0", - "php": ">=7.3", - "phpunit/php-file-iterator": "^3.0.3", - "phpunit/php-text-template": "^2.0.2", - "sebastian/code-unit-reverse-lookup": "^2.0.2", - "sebastian/complexity": "^2.0", - "sebastian/environment": "^5.1.2", - "sebastian/lines-of-code": "^1.0.3", - "sebastian/version": "^3.0.1", - "theseer/tokenizer": "^1.2.0" + "php": ">=7.2", + "phpunit/php-file-iterator": "^2.0.2", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-token-stream": "^3.1.3 || ^4.0", + "sebastian/code-unit-reverse-lookup": "^1.0.1", + "sebastian/environment": "^4.2.2", + "sebastian/version": "^2.0.1", + "theseer/tokenizer": "^1.1.3" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^8.2.2" }, "suggest": { - "ext-pcov": "*", - "ext-xdebug": "*" + "ext-xdebug": "^2.7.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "9.2-dev" + "dev-master": "7.0-dev" } }, "autoload": { @@ -7599,7 +7593,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.15" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/7.0.15" }, "funding": [ { @@ -7607,32 +7601,32 @@ "type": "github" } ], - "time": "2022-03-07T09:28:20+00:00" + "time": "2021-07-26T12:20:09+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "3.0.6", + "version": "2.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" + "reference": "42c5ba5220e6904cbfe8b1a1bda7c0cfdc8c12f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", - "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/42c5ba5220e6904cbfe8b1a1bda7c0cfdc8c12f5", + "reference": "42c5ba5220e6904cbfe8b1a1bda7c0cfdc8c12f5", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^8.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -7659,7 +7653,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/2.0.5" }, "funding": [ { @@ -7667,97 +7661,26 @@ "type": "github" } ], - "time": "2021-12-02T12:48:52+00:00" - }, - { - "name": "phpunit/php-invoker", - "version": "3.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-invoker.git", - "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", - "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "ext-pcntl": "*", - "phpunit/phpunit": "^9.3" - }, - "suggest": { - "ext-pcntl": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Invoke callables with a timeout", - "homepage": "https://github.com/sebastianbergmann/php-invoker/", - "keywords": [ - "process" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-invoker/issues", - "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-09-28T05:58:55+00:00" + "time": "2021-12-02T12:42:26+00:00" }, { "name": "phpunit/php-text-template", - "version": "2.0.4", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", - "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", "shasum": "" }, "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" + "php": ">=5.3.3" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, "autoload": { "classmap": [ "src/" @@ -7781,40 +7704,34 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-text-template/issues", - "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + "source": "https://github.com/sebastianbergmann/php-text-template/tree/1.2.1" }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-10-26T05:33:50+00:00" + "time": "2015-06-21T13:50:34+00:00" }, { "name": "phpunit/php-timer", - "version": "5.0.3", + "version": "2.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" + "reference": "2454ae1765516d20c4ffe103d85a58a9a3bd5662" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", - "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/2454ae1765516d20c4ffe103d85a58a9a3bd5662", + "reference": "2454ae1765516d20c4ffe103d85a58a9a3bd5662", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^8.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-master": "2.1-dev" } }, "autoload": { @@ -7840,7 +7757,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-timer/issues", - "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + "source": "https://github.com/sebastianbergmann/php-timer/tree/2.1.3" }, "funding": [ { @@ -7848,20 +7765,80 @@ "type": "github" } ], - "time": "2020-10-26T13:16:10+00:00" + "time": "2020-11-30T08:20:02+00:00" }, { - "name": "phpunit/phpunit", - "version": "9.5.21", + "name": "phpunit/php-token-stream", + "version": "3.1.3", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "0e32b76be457de00e83213528f6bb37e2a38fcb1" + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "9c1da83261628cb24b6a6df371b6e312b3954768" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0e32b76be457de00e83213528f6bb37e2a38fcb1", - "reference": "0e32b76be457de00e83213528f6bb37e2a38fcb1", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/9c1da83261628cb24b6a6df371b6e312b3954768", + "reference": "9c1da83261628cb24b6a6df371b6e312b3954768", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-token-stream/issues", + "source": "https://github.com/sebastianbergmann/php-token-stream/tree/3.1.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "abandoned": true, + "time": "2021-07-26T12:15:06+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "8.5.28", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "8f2d1c9c7b30382459c871467853da1a6e44fbd4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/8f2d1c9c7b30382459c871467853da1a6e44fbd4", + "reference": "8f2d1c9c7b30382459c871467853da1a6e44fbd4", "shasum": "" }, "require": { @@ -7872,34 +7849,29 @@ "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.10.1", + "myclabs/deep-copy": "^1.10.0", "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", - "php": ">=7.3", - "phpspec/prophecy": "^1.12.1", - "phpunit/php-code-coverage": "^9.2.13", - "phpunit/php-file-iterator": "^3.0.5", - "phpunit/php-invoker": "^3.1.1", - "phpunit/php-text-template": "^2.0.3", - "phpunit/php-timer": "^5.0.2", - "sebastian/cli-parser": "^1.0.1", - "sebastian/code-unit": "^1.0.6", - "sebastian/comparator": "^4.0.5", - "sebastian/diff": "^4.0.3", - "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.3", - "sebastian/global-state": "^5.0.1", - "sebastian/object-enumerator": "^4.0.3", - "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.0", - "sebastian/version": "^3.0.2" - }, - "require-dev": { - "phpspec/prophecy-phpunit": "^2.0.1" + "php": ">=7.2", + "phpspec/prophecy": "^1.10.3", + "phpunit/php-code-coverage": "^7.0.12", + "phpunit/php-file-iterator": "^2.0.4", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-timer": "^2.1.2", + "sebastian/comparator": "^3.0.2", + "sebastian/diff": "^3.0.2", + "sebastian/environment": "^4.2.3", + "sebastian/exporter": "^3.1.2", + "sebastian/global-state": "^3.0.0", + "sebastian/object-enumerator": "^3.0.3", + "sebastian/resource-operations": "^2.0.1", + "sebastian/type": "^1.1.3", + "sebastian/version": "^2.0.1" }, "suggest": { "ext-soap": "*", - "ext-xdebug": "*" + "ext-xdebug": "*", + "phpunit/php-invoker": "^2.0.0" }, "bin": [ "phpunit" @@ -7907,13 +7879,10 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.5-dev" + "dev-master": "8.5-dev" } }, "autoload": { - "files": [ - "src/Framework/Assert/Functions.php" - ], "classmap": [ "src/" ] @@ -7938,7 +7907,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.21" + "source": "https://github.com/sebastianbergmann/phpunit/tree/8.5.28" }, "funding": [ { @@ -7950,7 +7919,7 @@ "type": "github" } ], - "time": "2022-06-19T12:14:25+00:00" + "time": "2022-07-29T09:20:50+00:00" }, { "name": "scrivo/highlight.php", @@ -8030,142 +7999,30 @@ ], "time": "2021-12-03T06:45:28+00:00" }, - { - "name": "sebastian/cli-parser", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library for parsing CLI options", - "homepage": "https://github.com/sebastianbergmann/cli-parser", - "support": { - "issues": "https://github.com/sebastianbergmann/cli-parser/issues", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-09-28T06:08:49+00:00" - }, - { - "name": "sebastian/code-unit", - "version": "1.0.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit.git", - "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", - "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Collection of value objects that represent the PHP code units", - "homepage": "https://github.com/sebastianbergmann/code-unit", - "support": { - "issues": "https://github.com/sebastianbergmann/code-unit/issues", - "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-10-26T13:08:54+00:00" - }, { "name": "sebastian/code-unit-reverse-lookup", - "version": "2.0.3", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" + "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", - "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/1de8cd5c010cb153fcd68b8d0f64606f523f7619", + "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=5.6" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^8.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { @@ -8187,7 +8044,7 @@ "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", "support": { "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", - "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/1.0.2" }, "funding": [ { @@ -8195,34 +8052,34 @@ "type": "github" } ], - "time": "2020-09-28T05:30:19+00:00" + "time": "2020-11-30T08:15:22+00:00" }, { "name": "sebastian/comparator", - "version": "4.0.6", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382" + "reference": "1071dfcef776a57013124ff35e1fc41ccd294758" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1071dfcef776a57013124ff35e1fc41ccd294758", + "reference": "1071dfcef776a57013124ff35e1fc41ccd294758", "shasum": "" }, "require": { - "php": ">=7.3", - "sebastian/diff": "^4.0", - "sebastian/exporter": "^4.0" + "php": ">=7.1", + "sebastian/diff": "^3.0", + "sebastian/exporter": "^3.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^8.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -8261,7 +8118,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6" + "source": "https://github.com/sebastianbergmann/comparator/tree/3.0.3" }, "funding": [ { @@ -8269,90 +8126,33 @@ "type": "github" } ], - "time": "2020-10-26T15:49:45+00:00" - }, - { - "name": "sebastian/complexity", - "version": "2.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", - "shasum": "" - }, - "require": { - "nikic/php-parser": "^4.7", - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library for calculating the complexity of PHP code units", - "homepage": "https://github.com/sebastianbergmann/complexity", - "support": { - "issues": "https://github.com/sebastianbergmann/complexity/issues", - "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-10-26T15:52:27+00:00" + "time": "2020-11-30T08:04:30+00:00" }, { "name": "sebastian/diff", - "version": "4.0.4", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" + "reference": "14f72dd46eaf2f2293cbe79c93cc0bc43161a211" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/14f72dd46eaf2f2293cbe79c93cc0bc43161a211", + "reference": "14f72dd46eaf2f2293cbe79c93cc0bc43161a211", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "^9.3", - "symfony/process": "^4.2 || ^5" + "phpunit/phpunit": "^7.5 || ^8.0", + "symfony/process": "^2 || ^3.3 || ^4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -8384,7 +8184,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/diff/tree/3.0.3" }, "funding": [ { @@ -8392,27 +8192,27 @@ "type": "github" } ], - "time": "2020-10-26T13:10:38+00:00" + "time": "2020-11-30T07:59:04+00:00" }, { "name": "sebastian/environment", - "version": "5.1.4", + "version": "4.2.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7" + "reference": "d47bbbad83711771f167c72d4e3f25f7fcc1f8b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7", - "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/d47bbbad83711771f167c72d4e3f25f7fcc1f8b0", + "reference": "d47bbbad83711771f167c72d4e3f25f7fcc1f8b0", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^7.5" }, "suggest": { "ext-posix": "*" @@ -8420,7 +8220,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.1-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -8447,7 +8247,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1.4" + "source": "https://github.com/sebastianbergmann/environment/tree/4.2.4" }, "funding": [ { @@ -8455,34 +8255,34 @@ "type": "github" } ], - "time": "2022-04-03T09:37:03+00:00" + "time": "2020-11-30T07:53:42+00:00" }, { "name": "sebastian/exporter", - "version": "4.0.4", + "version": "3.1.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9" + "reference": "0c32ea2e40dbf59de29f3b49bf375176ce7dd8db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/65e8b7db476c5dd267e65eea9cab77584d3cfff9", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/0c32ea2e40dbf59de29f3b49bf375176ce7dd8db", + "reference": "0c32ea2e40dbf59de29f3b49bf375176ce7dd8db", "shasum": "" }, "require": { - "php": ">=7.3", - "sebastian/recursion-context": "^4.0" + "php": ">=7.0", + "sebastian/recursion-context": "^3.0" }, "require-dev": { "ext-mbstring": "*", - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^8.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "3.1.x-dev" } }, "autoload": { @@ -8517,14 +8317,14 @@ } ], "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "https://www.github.com/sebastianbergmann/exporter", + "homepage": "http://www.github.com/sebastianbergmann/exporter", "keywords": [ "export", "exporter" ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/exporter/tree/3.1.4" }, "funding": [ { @@ -8532,30 +8332,30 @@ "type": "github" } ], - "time": "2021-11-11T14:18:36+00:00" + "time": "2021-11-11T13:51:24+00:00" }, { "name": "sebastian/global-state", - "version": "5.0.5", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2" + "reference": "de036ec91d55d2a9e0db2ba975b512cdb1c23921" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/de036ec91d55d2a9e0db2ba975b512cdb1c23921", + "reference": "de036ec91d55d2a9e0db2ba975b512cdb1c23921", "shasum": "" }, "require": { - "php": ">=7.3", - "sebastian/object-reflector": "^2.0", - "sebastian/recursion-context": "^4.0" + "php": ">=7.2", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" }, "require-dev": { "ext-dom": "*", - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^8.0" }, "suggest": { "ext-uopz": "*" @@ -8563,7 +8363,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -8588,7 +8388,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" + "source": "https://github.com/sebastianbergmann/global-state/tree/3.0.2" }, "funding": [ { @@ -8596,91 +8396,34 @@ "type": "github" } ], - "time": "2022-02-14T08:28:10+00:00" - }, - { - "name": "sebastian/lines-of-code", - "version": "1.0.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", - "shasum": "" - }, - "require": { - "nikic/php-parser": "^4.6", - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library for counting the lines of code in PHP source code", - "homepage": "https://github.com/sebastianbergmann/lines-of-code", - "support": { - "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-11-28T06:42:11+00:00" + "time": "2022-02-10T06:55:38+00:00" }, { "name": "sebastian/object-enumerator", - "version": "4.0.4", + "version": "3.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" + "reference": "e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", - "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2", + "reference": "e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2", "shasum": "" }, "require": { - "php": ">=7.3", - "sebastian/object-reflector": "^2.0", - "sebastian/recursion-context": "^4.0" + "php": ">=7.0", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -8702,7 +8445,7 @@ "homepage": "https://github.com/sebastianbergmann/object-enumerator/", "support": { "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", - "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/3.0.4" }, "funding": [ { @@ -8710,32 +8453,32 @@ "type": "github" } ], - "time": "2020-10-26T13:12:34+00:00" + "time": "2020-11-30T07:40:27+00:00" }, { "name": "sebastian/object-reflector", - "version": "2.0.4", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" + "reference": "9b8772b9cbd456ab45d4a598d2dd1a1bced6363d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", - "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/9b8772b9cbd456ab45d4a598d2dd1a1bced6363d", + "reference": "9b8772b9cbd456ab45d4a598d2dd1a1bced6363d", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=7.0" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "1.1-dev" } }, "autoload": { @@ -8757,7 +8500,7 @@ "homepage": "https://github.com/sebastianbergmann/object-reflector/", "support": { "issues": "https://github.com/sebastianbergmann/object-reflector/issues", - "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + "source": "https://github.com/sebastianbergmann/object-reflector/tree/1.1.2" }, "funding": [ { @@ -8765,32 +8508,32 @@ "type": "github" } ], - "time": "2020-10-26T13:14:26+00:00" + "time": "2020-11-30T07:37:18+00:00" }, { "name": "sebastian/recursion-context", - "version": "4.0.4", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" + "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", - "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/367dcba38d6e1977be014dc4b22f47a484dac7fb", + "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=7.0" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -8820,7 +8563,7 @@ "homepage": "http://www.github.com/sebastianbergmann/recursion-context", "support": { "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/recursion-context/tree/3.0.1" }, "funding": [ { @@ -8828,32 +8571,29 @@ "type": "github" } ], - "time": "2020-10-26T13:17:30+00:00" + "time": "2020-11-30T07:34:24+00:00" }, { "name": "sebastian/resource-operations", - "version": "3.0.3", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" + "reference": "31d35ca87926450c44eae7e2611d45a7a65ea8b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/31d35ca87926450c44eae7e2611d45a7a65ea8b3", + "reference": "31d35ca87926450c44eae7e2611d45a7a65ea8b3", "shasum": "" }, "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.0" + "php": ">=7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -8875,7 +8615,7 @@ "homepage": "https://www.github.com/sebastianbergmann/resource-operations", "support": { "issues": "https://github.com/sebastianbergmann/resource-operations/issues", - "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" + "source": "https://github.com/sebastianbergmann/resource-operations/tree/2.0.2" }, "funding": [ { @@ -8883,32 +8623,32 @@ "type": "github" } ], - "time": "2020-09-28T06:45:17+00:00" + "time": "2020-11-30T07:30:19+00:00" }, { "name": "sebastian/type", - "version": "3.0.0", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad" + "reference": "0150cfbc4495ed2df3872fb31b26781e4e077eb4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", - "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/0150cfbc4495ed2df3872fb31b26781e4e077eb4", + "reference": "0150cfbc4495ed2df3872fb31b26781e4e077eb4", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=7.2" }, "require-dev": { - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^8.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "1.1-dev" } }, "autoload": { @@ -8931,7 +8671,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.0.0" + "source": "https://github.com/sebastianbergmann/type/tree/1.1.4" }, "funding": [ { @@ -8939,29 +8679,29 @@ "type": "github" } ], - "time": "2022-03-15T09:54:48+00:00" + "time": "2020-11-30T07:25:11+00:00" }, { "name": "sebastian/version", - "version": "3.0.2", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "c6c1022351a901512170118436c764e473f6de8c" + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", - "reference": "c6c1022351a901512170118436c764e473f6de8c", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=5.6" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -8984,15 +8724,9 @@ "homepage": "https://github.com/sebastianbergmann/version", "support": { "issues": "https://github.com/sebastianbergmann/version/issues", - "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" + "source": "https://github.com/sebastianbergmann/version/tree/master" }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-09-28T06:39:44+00:00" + "time": "2016-10-03T07:35:21+00:00" }, { "name": "theseer/tokenizer", From a47657619d652958ada440fee6213f0ecb03bac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Thu, 11 Aug 2022 15:01:35 +0800 Subject: [PATCH 60/68] =?UTF-8?q?feat:=20#10000=20=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=9B=AE=E6=A0=87=E7=B1=BB=E5=9E=8B=E5=A2=9E=E5=8A=A0goods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Log.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Models/Log.php b/app/Models/Log.php index 06bc265..3ad09b9 100644 --- a/app/Models/Log.php +++ b/app/Models/Log.php @@ -70,6 +70,7 @@ class Log extends Model 'upload' => '上传', 'kuaituantuan' => '快团团', 'miaoxuan' => '妙选', + 'goods' => '商品', ]; return $map[$value]; From ee6e1fa09fef999571dab27c24da6d48110326e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Thu, 11 Aug 2022 15:22:50 +0800 Subject: [PATCH 61/68] =?UTF-8?q?feat:=20#10000=20=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=9B=AE=E6=A0=87=E7=B1=BB=E5=9E=8B=E5=A2=9E=E5=8A=A0goods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Log.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Models/Log.php b/app/Models/Log.php index 3ad09b9..43cd08b 100644 --- a/app/Models/Log.php +++ b/app/Models/Log.php @@ -42,7 +42,7 @@ class Log extends Model 'file' => '文件', ]; - return $map[$value]; + return $map[$value] ?? $value; } public function getActionAttribute($value) @@ -54,7 +54,7 @@ class Log extends Model 'DELETE' => '删除', ]; - return $map[$value]; + return $map[$value] ?? $value; } public function getTargetTypeAttribute($value) @@ -73,7 +73,7 @@ class Log extends Model 'goods' => '商品', ]; - return $map[$value]; + return $map[$value] ?? $value; } public function getTargetFieldAttribute($value) @@ -91,7 +91,7 @@ class Log extends Model 'inventory' => '库存盘点', ]; - return $map[$value]; + return $map[$value] ?? $value; } public function setUserIdAttribute($value) From 360cf5cf179c319196930b9353b74940b646a562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Thu, 11 Aug 2022 18:09:15 +0800 Subject: [PATCH 62/68] =?UTF-8?q?feat:=20#10000=20=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/Swoole.php | 2 +- app/Models/Log.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/Swoole.php b/app/Console/Commands/Swoole.php index ecc9494..1967e06 100644 --- a/app/Console/Commands/Swoole.php +++ b/app/Console/Commands/Swoole.php @@ -46,7 +46,7 @@ class Swoole extends Command Timer::tick(1000, function () { $shops = Shop::query()->where('plat_id', 1)->where('status', 1)->get(); $endTime = DateTimeUtils::getMicroTime(); - $beginTime = $endTime - 1000; + $beginTime = $endTime - 10000; foreach ($shops as $shop) { BusinessFactory::init()->make($shop->plat_id)->setShop($shop)->downloadOrdersAndSave($beginTime, $endTime, 'increment', 1); } diff --git a/app/Models/Log.php b/app/Models/Log.php index 43cd08b..be323d7 100644 --- a/app/Models/Log.php +++ b/app/Models/Log.php @@ -17,7 +17,8 @@ class Log extends Model 'target_id', 'target_field', 'user_id', - 'created_at', + 'start_time', + 'end_time', ]; public $fillable = [ From cf910fa6ae54917704a51a269e7954123aa5bc1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Thu, 11 Aug 2022 18:34:16 +0800 Subject: [PATCH 63/68] =?UTF-8?q?feat:=20#10000=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E9=98=9F=E5=88=97=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Jobs/BusinessGoodsSkuIncrQuantity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Jobs/BusinessGoodsSkuIncrQuantity.php b/app/Jobs/BusinessGoodsSkuIncrQuantity.php index ca1da28..6dcc2d3 100644 --- a/app/Jobs/BusinessGoodsSkuIncrQuantity.php +++ b/app/Jobs/BusinessGoodsSkuIncrQuantity.php @@ -40,6 +40,6 @@ class BusinessGoodsSkuIncrQuantity implements ShouldQueue */ public function handle() { - BusinessFactory::init()->make($this->shop['plat_id'])->setShopId($this->shop['id'])->incrQuantity($this->businessOrderItem, $this->num, true, $this->goodsSku); + BusinessFactory::init()->make($this->shop['plat_id'])->setShopWithId($this->shop['id'])->incrQuantity($this->businessOrderItem, $this->num, true, $this->goodsSku); } } From a2eb9e27ddee582b420fe4a13dadf1283b21db55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Thu, 11 Aug 2022 18:47:35 +0800 Subject: [PATCH 64/68] =?UTF-8?q?feat:=20#10000=20=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E6=8E=88=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Shop.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Models/Shop.php b/app/Models/Shop.php index f45960b..5140a13 100644 --- a/app/Models/Shop.php +++ b/app/Models/Shop.php @@ -8,7 +8,6 @@ class Shop extends Model { protected $hidden = [ 'access_token', - 'expires_at', 'expires_in', 'refresh_token', 'refresh_token_expires_at', @@ -28,6 +27,9 @@ class Shop extends Model 2 => '无需授权', 3 => '停用', ]; + if (1 === (int)$value && ($this->attributes['expires_at'] - time()) / 3600 <= 72) { + return '重新授权'; + } return $map[$value]; } From 46c59fe993f221ab59885fa5d9cd477f81140961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Fri, 12 Aug 2022 13:30:32 +0800 Subject: [PATCH 65/68] =?UTF-8?q?feat:=20#10000=20=E6=9D=83=E9=99=90?= =?UTF-8?q?=E4=BF=AE=E6=94=B9,=E5=A2=9E=E5=8A=A0=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Shop/ShopsController.php | 13 +++++++++++++ app/Models/BusinessOrderItem.php | 5 +++++ resources/lang/zh-CN/permission.php | 10 +++++----- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Shop/ShopsController.php b/app/Http/Controllers/Shop/ShopsController.php index 3f79c8e..63df107 100644 --- a/app/Http/Controllers/Shop/ShopsController.php +++ b/app/Http/Controllers/Shop/ShopsController.php @@ -9,6 +9,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Validator; use App\Services\Business\BusinessFactory; use Illuminate\Validation\Rule; +use App\Models\BusinessOrderItem; class ShopsController extends Controller { @@ -97,4 +98,16 @@ class ShopsController extends Controller return response(['Code' => 10000, 'Message' => 'SUCCESS']); } + + public function countOrdersNumWithSkuCode(Request $request) + { + Validator::make($request->all(), [ + 'sku_code' => ['required', 'array'], + ])->validate(); + return BusinessOrderItem::query() + ->whereIn('external_sku_id', $request->get('sku_code')) + ->groupBy(['shop_id']) + ->with(['shop:id,name']) + ->count('shop_id'); + } } diff --git a/app/Models/BusinessOrderItem.php b/app/Models/BusinessOrderItem.php index 19015e3..a656040 100644 --- a/app/Models/BusinessOrderItem.php +++ b/app/Models/BusinessOrderItem.php @@ -39,4 +39,9 @@ class BusinessOrderItem extends Model { return $this->hasOne(BusinessOrder::class, 'id', 'business_order_id'); } + + public function shop() + { + return $this->hasOne(Shop::class, 'id', 'shop_id'); + } } diff --git a/resources/lang/zh-CN/permission.php b/resources/lang/zh-CN/permission.php index 6d487bb..d000062 100644 --- a/resources/lang/zh-CN/permission.php +++ b/resources/lang/zh-CN/permission.php @@ -215,11 +215,11 @@ return [ // 'name' => '权限管理', // 'parent_id' => 7, // ], -// 'permissions.index' => [ -// 'id' => 90, -// 'name' => '列表', -// 'parent_id' => 9, -// ], + 'permissions.index' => [ + 'id' => 90, + 'name' => '列表', + 'parent_id' => 9, + ], // 系统日志 'SYSTEM_LOG' => [ 'id' => 10, From f497b36199a213e46ffc282f6b999cd61975fd6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Fri, 12 Aug 2022 16:20:40 +0800 Subject: [PATCH 66/68] =?UTF-8?q?feat:=20#10000=20=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E6=80=BB=E9=87=8F=E9=80=BB=E8=BE=91=E5=90=8C?= =?UTF-8?q?=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加订单占用接口 --- app/Console/Commands/Test.php | 2 +- .../Controllers/Goods/GoodsController.php | 1 + .../Controllers/Goods/GoodsSkusController.php | 44 ++++++++++--------- app/Http/Controllers/Shop/ShopsController.php | 31 ++++++++++--- app/Http/Requests/GoodsSkuRequest.php | 2 +- resources/lang/zh-CN/permission.php | 5 +++ routes/api.php | 1 + 7 files changed, 59 insertions(+), 27 deletions(-) diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index 619eb6b..d8d0c01 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -44,7 +44,7 @@ class Test extends Command $business = BusinessFactory::init()->make($shop->plat_id); $business->setShop($shop); // 下载商品列表 -// $business->downloadGoodsList(); +// $business->downloadGoodsListAndBind(); // 下载单个商品 // $business->downloadGoods(1); diff --git a/app/Http/Controllers/Goods/GoodsController.php b/app/Http/Controllers/Goods/GoodsController.php index 0dedbb7..fbb7fef 100644 --- a/app/Http/Controllers/Goods/GoodsController.php +++ b/app/Http/Controllers/Goods/GoodsController.php @@ -59,6 +59,7 @@ class GoodsController extends Controller $goodsSkus = []; foreach ($request->skus as $item) { $item['goods_id'] = $goods->id; + $item['stock'] = $item['num']; $item['reference_price'] = $item['cost'] * 1.5; $goodsSkus[] = $item; } diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index 701fab0..b70843d 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -58,6 +58,7 @@ class GoodsSkusController extends Controller ->with(['daily' => function ($query) use ($day) { $query->where('day', $day); }]) + ->orderBy('updated_at', 'desc') ->paginate(); return GoodsSkuResource::collection($goodsSkus); @@ -197,7 +198,6 @@ class GoodsSkusController extends Controller 'target_id' => $sku['id'], 'user_id' => $request->user()->id ]; - // 今日到货 $record = DailyStockRecord::query()->where('sku_id', $sku['id'])->where('day', DateTimeUtils::getToday())->first(['id', 'inventory']); $inventoryLog['target_field'] = 'inventory'; $inventoryLog['before_update'] = $record->inventory; @@ -227,7 +227,7 @@ class GoodsSkusController extends Controller $update = reset($skus); DB::beginTransaction(); try { - $sku = GoodsSku::query()->where('id', $update['id'])->first(['id', 'two_days_ago_num', 'yesterday_num', 'num', 'stock']); + $sku = GoodsSku::query()->where('id', $update['id'])->first(['id', 'two_days_ago_num', 'yesterday_num', 'num', 'stock', 'reserve']); $record = DailyStockRecord::query() ->where('sku_id', $sku->id) ->where('day', DateTimeUtils::getToday()) @@ -235,12 +235,15 @@ class GoodsSkusController extends Controller $this->setBeforeUpdate([ 'two_days_ago_num' => $sku->two_days_ago_num, 'yesterday_num' => $sku->yesterday_num, - 'num' => $sku->num, 'arrived_today_num' => $record->arrived_today_num, + 'num' => $sku->num, + 'stock' => $sku->stock, ]); $sku->two_days_ago_num = $update['two_days_ago_num']; $sku->yesterday_num = $update['yesterday_num']; - $sku->num = $update['two_days_ago_num'] + $update['yesterday_num'] + $sku->stock; + $stock = $update['two_days_ago_num'] + $update['yesterday_num'] + $update['arrived_today_num'] - $sku->reserve - $record->loss_num; + $sku->stock = $stock; + $sku->num = $stock + $sku->reserve + $record->loss_num; $sku->save(); $record->arrived_today_num = $update['arrived_today_num']; $record->save(); @@ -248,6 +251,8 @@ class GoodsSkusController extends Controller 'two_days_ago_num' => $sku->two_days_ago_num, 'yesterday_num' => $sku->yesterday_num, 'arrived_today_num' => $record->arrived_today_num, + 'num' => $sku->num, + 'stock' => $sku->stock, ]); $this->addLog($sku->id, 'stock'); DB::commit(); @@ -301,28 +306,27 @@ class GoodsSkusController extends Controller return response($this->res, $this->res['httpCode']); } $updateField = \request('updateField'); + $sku = GoodsSku::query()->find($id); if ('loss_num' === $updateField) { - $model = DailyStockRecord::query() + $record = DailyStockRecord::query() ->where('sku_id', $id) ->where('day', DateTimeUtils::getToday()) ->first(['id', 'loss_num']); $this->log->message = $request->get('reason'); - $this->setBeforeUpdate($model->loss_num); - $model->loss_num += $request->loss_num; - } else { - $model = GoodsSku::query()->find($id); - $this->setBeforeUpdate($model->$updateField); - if ('reserve' === $updateField) { - $changeNum = $model->reserve - $request->reserve; - $model->stock += $changeNum; - $model->reserve = $request->reserve; - $model->num += $changeNum; - } else { - $model->$updateField = $request->$updateField; - } + $this->setBeforeUpdate($record->loss_num); + $record->loss_num += $request->loss_num; + $record->save(); + $this->setAfterUpdate($record->loss_num); + $sku->stock -= $request->loss_num; } - $model->save(); - $this->setAfterUpdate($model->$updateField); + $this->setBeforeUpdate($sku->$updateField); + if ('reserve' === $updateField) { + $changeNum = $sku->reserve - $request->reserve; + $sku->stock += $changeNum; + } + $sku->$updateField = $request->$updateField; + $sku->save(); + $this->setAfterUpdate($sku->$updateField); $this->addLog($id, $updateField); return response($this->res, $this->res['httpCode']); diff --git a/app/Http/Controllers/Shop/ShopsController.php b/app/Http/Controllers/Shop/ShopsController.php index 63df107..e6f3245 100644 --- a/app/Http/Controllers/Shop/ShopsController.php +++ b/app/Http/Controllers/Shop/ShopsController.php @@ -6,6 +6,7 @@ use App\Http\Controllers\Controller; use App\Models\Shop; use App\Http\Resources\ShopsResource; use Illuminate\Http\Request; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Validator; use App\Services\Business\BusinessFactory; use Illuminate\Validation\Rule; @@ -101,13 +102,33 @@ class ShopsController extends Controller public function countOrdersNumWithSkuCode(Request $request) { - Validator::make($request->all(), [ + $validator = Validator::make($request->all(), [ 'sku_code' => ['required', 'array'], - ])->validate(); - return BusinessOrderItem::query() + ]); + if ($validator->fails()) { + $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); + + return response($this->res, $this->res['httpCode']); + } + $fields = implode(',', [ + 'shop_id', + 'external_sku_id', + 'count(id) as count', + ]); + $res = BusinessOrderItem::query() + ->select(DB::raw($fields)) ->whereIn('external_sku_id', $request->get('sku_code')) - ->groupBy(['shop_id']) + ->groupBy(['shop_id', 'external_sku_id']) ->with(['shop:id,name']) - ->count('shop_id'); + ->get(); + $data = []; + foreach ($res as $item) { + $data[$item->external_sku_id][] = [ + 'shop_name' => $item->shop->name, + 'count' => $item->count, + ]; + } + + return $data; } } diff --git a/app/Http/Requests/GoodsSkuRequest.php b/app/Http/Requests/GoodsSkuRequest.php index 2af032a..a9b2592 100644 --- a/app/Http/Requests/GoodsSkuRequest.php +++ b/app/Http/Requests/GoodsSkuRequest.php @@ -31,7 +31,7 @@ class GoodsSkuRequest extends FormRequest 'sku_code' => ['sometimes', 'required', 'distinct', 'alpha_dash', 'max:32'], 'status' => ['sometimes', 'required', 'integer', Rule::in([0, 1, 2])], 'num' => ['sometimes', 'required', 'integer'], - 'cost' => ['sometimes', 'required', 'numeric'], + 'cost' => ['sometimes', 'required', 'numeric', 'gt:0'], 'reference_price' => [ 'sometimes', 'numeric', diff --git a/resources/lang/zh-CN/permission.php b/resources/lang/zh-CN/permission.php index d000062..44c75aa 100644 --- a/resources/lang/zh-CN/permission.php +++ b/resources/lang/zh-CN/permission.php @@ -52,6 +52,11 @@ return [ 'name' => '字段更新', 'parent_id' => 2, ], + 'goods_sku.orders_num' => [ + 'id' => 28, + 'name' => '店铺订单', + 'parent_id' => 2, + ], 'GOODS_TYPE' => [ 'id' => 3, 'name' => '商品种类', diff --git a/routes/api.php b/routes/api.php index b322c4f..19fbfe3 100644 --- a/routes/api.php +++ b/routes/api.php @@ -33,6 +33,7 @@ Route::middleware(['auth:api', 'check.permissions'])->group(function () { Route::patch('single/goods_skus/{id}', [GoodsSkusController::class, 'updateField'])->name('goods_sku.single_update'); // 店铺 Route::resource('shops', 'Shop\ShopsController', ['only' => ['index', 'store', 'show', 'update', 'destroy']]); + Route::get('count/orders/num', [ShopsController::class, 'countOrdersNumWithSkuCode'])->name('goods_sku.orders_num'); // 角色 Route::resource('roles', 'Role\RolesController', ['only' => ['index', 'store', 'show', 'update']]); Route::post('roles/{id}/permissions', [RolesController::class, 'addPermissions'])->name('roles.permission'); From 0d7a59217cf7c139ae1e078d45e78e07c206ec12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Fri, 12 Aug 2022 17:45:33 +0800 Subject: [PATCH 67/68] =?UTF-8?q?feat:=20#10000=20=E9=A2=84=E7=95=99?= =?UTF-8?q?=E9=87=8F=E4=BF=AE=E6=94=B9=E5=A2=9E=E5=8A=A0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Goods/GoodsSkusController.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index b70843d..30fb032 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -302,8 +302,7 @@ class GoodsSkusController extends Controller $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); - - return response($this->res, $this->res['httpCode']); + goto end; } $updateField = \request('updateField'); $sku = GoodsSku::query()->find($id); @@ -322,12 +321,17 @@ class GoodsSkusController extends Controller $this->setBeforeUpdate($sku->$updateField); if ('reserve' === $updateField) { $changeNum = $sku->reserve - $request->reserve; + if (0 > $changeNum + $sku->stock) { + $this->setValidatorFailResponse('预留量超过库存数量'); + goto end; + } $sku->stock += $changeNum; } $sku->$updateField = $request->$updateField; $sku->save(); $this->setAfterUpdate($sku->$updateField); $this->addLog($id, $updateField); + end: return response($this->res, $this->res['httpCode']); } From c3bb6f0054a5a94a50e244357eded593af622334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Fri, 12 Aug 2022 17:52:28 +0800 Subject: [PATCH 68/68] =?UTF-8?q?feat:=20#10000=20=E6=8D=9F=E8=80=97?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Goods/GoodsSkusController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index 30fb032..b165a28 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -317,6 +317,8 @@ class GoodsSkusController extends Controller $record->save(); $this->setAfterUpdate($record->loss_num); $sku->stock -= $request->loss_num; + } else { + $sku->$updateField = $request->$updateField; } $this->setBeforeUpdate($sku->$updateField); if ('reserve' === $updateField) { @@ -327,7 +329,6 @@ class GoodsSkusController extends Controller } $sku->stock += $changeNum; } - $sku->$updateField = $request->$updateField; $sku->save(); $this->setAfterUpdate($sku->$updateField); $this->addLog($id, $updateField);