From 657663c9d0583cca409c15bcf5c99bb176861d64 Mon Sep 17 00:00:00 2001 From: xing Date: Sat, 25 May 2024 22:06:58 +0800 Subject: [PATCH] add partly goods logic --- .env.example | 3 +- Dockerfile | 23 + app/Console/Commands/HandleNotice.php | 37 +- app/Jobs/notice.php | 49 +- app/Models/Base.php | 10 + app/Models/Good.php | 8 +- app/Models/GoodItem.php | 4 +- app/Models/Notice.php | 5 +- app/helpers/FormType.php | 11 + app/helpers/apiRequest.php | 81 +++ composer.json | 1 + composer.lock | 497 +++++++++++++++++- ...2024_05_24_033401_create_notices_table.php | 2 +- .../2024_05_24_034644_create_goods_table.php | 3 +- ..._05_24_034726_create_goods_items_table.php | 2 +- .../2024_05_25_120049_modify_table_notice.php | 28 + .../2024_05_25_135703_modify_goods_table.php | 28 + ...5_140215_modify_goods_table_add_itemid.php | 28 + 18 files changed, 787 insertions(+), 33 deletions(-) create mode 100644 Dockerfile create mode 100644 app/Models/Base.php create mode 100644 app/helpers/FormType.php create mode 100644 app/helpers/apiRequest.php create mode 100644 database/migrations/2024_05_25_120049_modify_table_notice.php create mode 100644 database/migrations/2024_05_25_135703_modify_goods_table.php create mode 100644 database/migrations/2024_05_25_140215_modify_goods_table_add_itemid.php diff --git a/.env.example b/.env.example index ea0665b..adc7656 100755 --- a/.env.example +++ b/.env.example @@ -3,7 +3,8 @@ APP_ENV=local APP_KEY= APP_DEBUG=true APP_URL=http://localhost - +NOTICE_URL= +GOODS_URL= LOG_CHANNEL=stack LOG_DEPRECATIONS_CHANNEL=null LOG_LEVEL=debug diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a567e8c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM php:8.3-cli + +RUN pecl install redis \ + && pecl install xdebug \ + && docker-php-ext-enable redis xdebug + + +RUN curl -sSLf \ + -o /usr/local/bin/install-php-extensions \ + https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ + chmod +x /usr/local/bin/install-php-extensions && \ + install-php-extensions mongodb igbinary imagick gd + +RUN install-php-extensions zip +RUN apt update && apt install git -y + + +RUN echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +RUN echo "xdebug.client_host=\"host.docker.internal\"" >> /usr/local/etc/php/conf +RUN echo "xdebug.start_with_request=default" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +RUN curl -o composer-setup.php https://getcomposer.org/installer +RUN php composer-setup.php --install-dir=/usr/local/bin/ --filename=composer +RUN install-php-extensions pdo_mysql diff --git a/app/Console/Commands/HandleNotice.php b/app/Console/Commands/HandleNotice.php index a992d3d..e22bffe 100644 --- a/app/Console/Commands/HandleNotice.php +++ b/app/Console/Commands/HandleNotice.php @@ -2,8 +2,9 @@ namespace App\Console\Commands; +use App\helpers\apiRequest; use App\Models\Notice; -use GuzzleHttp\Client; +use GuzzleHttp\Exception\GuzzleException; use Illuminate\Console\Command; use Illuminate\Contracts\Console\Isolatable; @@ -28,7 +29,7 @@ class HandleNotice extends Command implements Isolatable * * @return void */ - public function __construct(public Client $client) + public function __construct() { parent::__construct();; } @@ -37,44 +38,52 @@ public function __construct(public Client $client) * Execute the console command. * * @return int + * @throws GuzzleException */ - public function handle() + public function handle(): int { $this->line('开始消息队列'); $url = env('NOTICE_URL'); - $res = json_decode($this->client->post($url)->getBody()->getContents(), true); + $res = apiRequest::request($url); if (!$res['result'] || $res['errCode'] != '0000') { $this->error('request err: ' . $res['desc'] ?? ''); return 1; } $arr = $res['data']['notice_list'] ?? []; - while ($items = array_splice($arr, 0, 1)) { + while ($items = array_splice($arr, 0, 500)) { $ids = array_column($items, 'notice_id'); - $data = array_column($items, null, 'notice_id'); if (!$ids) { continue; } - $hadIds = Notice::query()->select('id')->whereIn('id', $ids)->get()->toArray(); + $data = array_column($items, null, 'notice_id'); - $hadIds = array_column($hadIds, 'id'); + $hadIds = Notice::query()->select('notice_id')->whereIn('notice_id', $ids)->get()->toArray(); + + $hadIds = array_column($hadIds, 'notice_id'); $newIds = array_diff($ids, $hadIds); + if (!$newIds) { + continue; + } $notices = []; $time = date('Y-m-d H:i:s'); + $queue = []; foreach ($newIds as $id) { $notices[] = [ 'notice_id' => $id, + 'notice_type'=>$data[$id]['type'], 'raw_content' => json_encode($data[$id]), 'created_at' => $time, ]; + $queue[$data[$id]['type']][] = $data[$id]; } - try{ + try { Notice::insert($notices); - }catch (\Exception $exception){ - $this->error('insert err:'. $exception->getMessage()); + } catch (\Exception $exception) { + $this->error('insert err:' . $exception->getMessage()); + continue; } - //todo 入队 - foreach ($newIds as $id){ - \App\Jobs\notice::dispatch($data[$id]); + foreach ($queue as $type => $item) { + \App\Jobs\notice::dispatch($type, $item); } diff --git a/app/Jobs/notice.php b/app/Jobs/notice.php index 7a14ff1..f7177a1 100644 --- a/app/Jobs/notice.php +++ b/app/Jobs/notice.php @@ -2,6 +2,11 @@ namespace App\Jobs; +use App\helpers\apiRequest; +use App\helpers\FormType; +use App\Models\Good; +use GuzzleHttp\Client; +use GuzzleHttp\Exception\GuzzleException; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -12,19 +17,57 @@ class notice implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + public Client $client; /** * Create a new job instance. */ - public function __construct() + public function __construct(public int $type,public mixed $data) { - // + $this->goodsUrl=env('GOODS_URL'); } + public string $goodsUrl ; + /** * Execute the job. + * @throws GuzzleException */ public function handle(): void { - // + switch ($this->type) { + case 1: + $this->addGoods(); + break; + case 2: + case 3: + case 4: + case 5: + } + } + + /** + * @throws GuzzleException + * @throws \Exception + */ + public function addGoods(): void + { + $goods = []; + $this->client = new Client(); + foreach ($this->data as $item) { + $product = apiRequest::requests($this->client,$this->goodsUrl,[ + 'itemId' =>$item['result']['itemId'], + ],FormType::json); + if($product['errCode']!='0000'){ + throw new \Exception('request item '. $item['item_id'].' err:' .$product['desc'] ?? ''); + } + $product = $product['data']['product']; + $product['itemid'] = $product['itemId']; + $good = new Good(); + $good->fill($product); + $goods[]=$good->toArray(); + } + Good::insert($goods); } } + + diff --git a/app/Models/Base.php b/app/Models/Base.php new file mode 100644 index 0000000..98b080c --- /dev/null +++ b/app/Models/Base.php @@ -0,0 +1,10 @@ +hasOne(GoodItem::class,'item_id'); } diff --git a/app/Models/GoodItem.php b/app/Models/GoodItem.php index a5418a8..d41fcbc 100644 --- a/app/Models/GoodItem.php +++ b/app/Models/GoodItem.php @@ -10,10 +10,8 @@ /** * @property Good $good */ -class GoodItem extends Model +class GoodItem extends Base { - use HasFactory; - public function Good () : BelongsTo{ return $this->belongsTo(Good::class,'item_id'); } diff --git a/app/Models/Notice.php b/app/Models/Notice.php index e3ff934..f22a939 100644 --- a/app/Models/Notice.php +++ b/app/Models/Notice.php @@ -5,9 +5,6 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; -class Notice extends Model +class Notice extends Base { - use HasFactory; - - public $timestamps = true; } diff --git a/app/helpers/FormType.php b/app/helpers/FormType.php new file mode 100644 index 0000000..5466680 --- /dev/null +++ b/app/helpers/FormType.php @@ -0,0 +1,11 @@ + $timeout + ]; + switch ($type) { + case FormType::urlencoded: + $params['form_params'] = $param; + $type = 'POST'; + break; + case FormType::json: + $params['json'] = $param; + $type = 'POST'; + break; + case FormType::formData: + $params['multipart'] = $param; + $type = 'POST'; + break; + default: + $params['query'] = $param; + $type = 'GET'; + break; + } + if ($extern) { + $params = array_merge($params, $extern); + } + $r = $client->request($type, $url, $params); + $res = $r->getBody()->getContents(); + if ($isJson) { + $data = json_decode($res, true); + if ($data === false) { + throw new Exception($res, 0); + } + } else { + $data = $res; + } + return $data; + } +} diff --git a/composer.json b/composer.json index 8a3d72d..f3d07f6 100755 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ "laravel/tinker": "^2.8" }, "require-dev": { + "barryvdh/laravel-ide-helper": "^3.0", "fakerphp/faker": "^1.9.1", "laravel/pint": "^1.0", "laravel/sail": "^1.18", diff --git a/composer.lock b/composer.lock index 5b3ec37..527acc9 100755 --- 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": "9c491b8531eec05ba41a11d9276a5749", + "content-hash": "6f4cd8c4286fcd65009ebc43750ac48f", "packages": [ { "name": "brick/math", @@ -5678,6 +5678,343 @@ } ], "packages-dev": [ + { + "name": "barryvdh/laravel-ide-helper", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-ide-helper.git", + "reference": "bc1d67f01ce8c77e3f97d48ba51fa1d81874f622" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-ide-helper/zipball/bc1d67f01ce8c77e3f97d48ba51fa1d81874f622", + "reference": "bc1d67f01ce8c77e3f97d48ba51fa1d81874f622", + "shasum": "" + }, + "require": { + "barryvdh/reflection-docblock": "^2.1.1", + "composer/class-map-generator": "^1.0", + "ext-json": "*", + "illuminate/console": "^10 || ^11", + "illuminate/database": "^10.38 || ^11", + "illuminate/filesystem": "^10 || ^11", + "illuminate/support": "^10 || ^11", + "nikic/php-parser": "^4.18 || ^5", + "php": "^8.1", + "phpdocumentor/type-resolver": "^1.1.0" + }, + "require-dev": { + "ext-pdo_sqlite": "*", + "friendsofphp/php-cs-fixer": "^3", + "illuminate/config": "^9 || ^10 || ^11", + "illuminate/view": "^9 || ^10 || ^11", + "mockery/mockery": "^1.4", + "orchestra/testbench": "^8 || ^9", + "phpunit/phpunit": "^10.5", + "spatie/phpunit-snapshot-assertions": "^4 || ^5", + "vimeo/psalm": "^5.4" + }, + "suggest": { + "illuminate/events": "Required for automatic helper generation (^6|^7|^8|^9|^10|^11)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + }, + "laravel": { + "providers": [ + "Barryvdh\\LaravelIdeHelper\\IdeHelperServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Barryvdh\\LaravelIdeHelper\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.", + "keywords": [ + "autocomplete", + "codeintel", + "helper", + "ide", + "laravel", + "netbeans", + "phpdoc", + "phpstorm", + "sublime" + ], + "support": { + "issues": "https://github.com/barryvdh/laravel-ide-helper/issues", + "source": "https://github.com/barryvdh/laravel-ide-helper/tree/v3.0.0" + }, + "funding": [ + { + "url": "https://fruitcake.nl", + "type": "custom" + }, + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], + "time": "2024-03-01T12:53:18+00:00" + }, + { + "name": "barryvdh/reflection-docblock", + "version": "v2.1.1", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/ReflectionDocBlock.git", + "reference": "e6811e927f0ecc37cc4deaa6627033150343e597" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/ReflectionDocBlock/zipball/e6811e927f0ecc37cc4deaa6627033150343e597", + "reference": "e6811e927f0ecc37cc4deaa6627033150343e597", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.14|^9" + }, + "suggest": { + "dflydev/markdown": "~1.0", + "erusev/parsedown": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Barryvdh": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "support": { + "source": "https://github.com/barryvdh/ReflectionDocBlock/tree/v2.1.1" + }, + "time": "2023-06-14T05:06:27+00:00" + }, + { + "name": "composer/class-map-generator", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/composer/class-map-generator.git", + "reference": "8286a62d243312ed99b3eee20d5005c961adb311" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/class-map-generator/zipball/8286a62d243312ed99b3eee20d5005c961adb311", + "reference": "8286a62d243312ed99b3eee20d5005c961adb311", + "shasum": "" + }, + "require": { + "composer/pcre": "^2.1 || ^3.1", + "php": "^7.2 || ^8.0", + "symfony/finder": "^4.4 || ^5.3 || ^6 || ^7" + }, + "require-dev": { + "phpstan/phpstan": "^1.6", + "phpstan/phpstan-deprecation-rules": "^1", + "phpstan/phpstan-phpunit": "^1", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/filesystem": "^5.4 || ^6", + "symfony/phpunit-bridge": "^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\ClassMapGenerator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "https://seld.be" + } + ], + "description": "Utilities to scan PHP code and generate class maps.", + "keywords": [ + "classmap" + ], + "support": { + "issues": "https://github.com/composer/class-map-generator/issues", + "source": "https://github.com/composer/class-map-generator/tree/1.1.1" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-03-15T12:53:41+00:00" + }, + { + "name": "composer/pcre", + "version": "3.1.3", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "5b16e25a5355f1f3afdfc2f954a0a80aec4826a8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/5b16e25a5355f1f3afdfc2f954a0a80aec4826a8", + "reference": "5b16e25a5355f1f3afdfc2f954a0a80aec4826a8", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.3", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/3.1.3" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-03-19T10:26:25+00:00" + }, + { + "name": "doctrine/deprecations", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/doctrine/deprecations.git", + "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", + "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^9", + "phpstan/phpstan": "1.4.10 || 1.10.15", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "psalm/plugin-phpunit": "0.18.4", + "psr/log": "^1 || ^2 || ^3", + "vimeo/psalm": "4.30.0 || 5.12.0" + }, + "suggest": { + "psr/log": "Allows logging deprecations via PSR-3 logger implementation" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", + "homepage": "https://www.doctrine-project.org/", + "support": { + "issues": "https://github.com/doctrine/deprecations/issues", + "source": "https://github.com/doctrine/deprecations/tree/1.1.3" + }, + "time": "2024-01-30T19:34:25+00:00" + }, { "name": "fakerphp/faker", "version": "v1.23.1", @@ -6348,6 +6685,164 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "phpdocumentor/reflection-common", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-2.x": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + }, + "time": "2020-06-27T09:03:43+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "1.8.2", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "153ae662783729388a584b4361f2545e4d841e3c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/153ae662783729388a584b4361f2545e4d841e3c", + "reference": "153ae662783729388a584b4361f2545e4d841e3c", + "shasum": "" + }, + "require": { + "doctrine/deprecations": "^1.0", + "php": "^7.3 || ^8.0", + "phpdocumentor/reflection-common": "^2.0", + "phpstan/phpdoc-parser": "^1.13" + }, + "require-dev": { + "ext-tokenizer": "*", + "phpbench/phpbench": "^1.2", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-phpunit": "^1.1", + "phpunit/phpunit": "^9.5", + "rector/rector": "^0.13.9", + "vimeo/psalm": "^4.25" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-1.x": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.8.2" + }, + "time": "2024-02-23T11:10:43+00:00" + }, + { + "name": "phpstan/phpdoc-parser", + "version": "1.29.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "536889f2b340489d328f5ffb7b02bb6b183ddedc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/536889f2b340489d328f5ffb7b02bb6b183ddedc", + "reference": "536889f2b340489d328f5ffb7b02bb6b183ddedc", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "doctrine/annotations": "^2.0", + "nikic/php-parser": "^4.15", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^1.5", + "phpstan/phpstan-phpunit": "^1.1", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^9.5", + "symfony/process": "^5.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "support": { + "issues": "https://github.com/phpstan/phpdoc-parser/issues", + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.29.0" + }, + "time": "2024-05-06T12:04:23+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "10.1.14", diff --git a/database/migrations/2024_05_24_033401_create_notices_table.php b/database/migrations/2024_05_24_033401_create_notices_table.php index ddd51be..6137e01 100644 --- a/database/migrations/2024_05_24_033401_create_notices_table.php +++ b/database/migrations/2024_05_24_033401_create_notices_table.php @@ -15,10 +15,10 @@ public function up() { Schema::create('notices', function (Blueprint $table) { $table->id(); - $table->timestamps(); $table->text('raw_content')->comment('原始消息内容'); $table->string('err_message')->default('')->comment('处理时错误信息'); $table->tinyInteger('state')->default(1)->comment('消息状态,1待消费,2消费进行中,3处理完成'); + $table->timestamps(); }); } diff --git a/database/migrations/2024_05_24_034644_create_goods_table.php b/database/migrations/2024_05_24_034644_create_goods_table.php index b635c9f..669c21a 100644 --- a/database/migrations/2024_05_24_034644_create_goods_table.php +++ b/database/migrations/2024_05_24_034644_create_goods_table.php @@ -15,7 +15,6 @@ public function up() { Schema::create('goods', function (Blueprint $table) { $table->id('itemid')->comment('商品id'); - $table->timestamps(); $table->integer('typeid')->comment(''); $table->string('product_name')->comment('商品名'); $table->string('product_code')->index()->comment('商品code'); @@ -25,7 +24,7 @@ public function up() $table->integer('category_id')->index()->comment('分类id'); $table->string('category_name')->comment('分类名'); $table->tinyInteger('state')->default(10)->comment('状态 1正常 2 下架'); - + $table->timestamps(); }); } diff --git a/database/migrations/2024_05_24_034726_create_goods_items_table.php b/database/migrations/2024_05_24_034726_create_goods_items_table.php index 0ef58f4..8d85f62 100644 --- a/database/migrations/2024_05_24_034726_create_goods_items_table.php +++ b/database/migrations/2024_05_24_034726_create_goods_items_table.php @@ -16,7 +16,6 @@ public function up() Schema::create('goods_items', function (Blueprint $table) { $table->id(); $table->integer('item_id')->index(); - $table->timestamps(); $table->string('brand')->default('')->comment('品牌'); $table->string('color_name')->default('')->comment('颜色'); $table->string('sell_point')->default('')->comment('卖点'); @@ -27,6 +26,7 @@ public function up() $table->string('product_infos')->default('')->comment('图文信息'); $table->string('app_introduce')->default('')->comment('app信息'); $table->string('applet_introduce')->default('详情图片地址'); + $table->timestamps(); }); } diff --git a/database/migrations/2024_05_25_120049_modify_table_notice.php b/database/migrations/2024_05_25_120049_modify_table_notice.php new file mode 100644 index 0000000..b978232 --- /dev/null +++ b/database/migrations/2024_05_25_120049_modify_table_notice.php @@ -0,0 +1,28 @@ +integer('notice_type')->comment('通知type')->after('notice_id'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('notices', function (Blueprint $table) { + $table->dropColumn('notice_type'); + }); + } +}; diff --git a/database/migrations/2024_05_25_135703_modify_goods_table.php b/database/migrations/2024_05_25_135703_modify_goods_table.php new file mode 100644 index 0000000..2f25bdd --- /dev/null +++ b/database/migrations/2024_05_25_135703_modify_goods_table.php @@ -0,0 +1,28 @@ +renameColumn('itemid','id'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('goods', function (Blueprint $table) { + $table->renameColumn('id','itemid'); + }); + } +}; diff --git a/database/migrations/2024_05_25_140215_modify_goods_table_add_itemid.php b/database/migrations/2024_05_25_140215_modify_goods_table_add_itemid.php new file mode 100644 index 0000000..7366137 --- /dev/null +++ b/database/migrations/2024_05_25_140215_modify_goods_table_add_itemid.php @@ -0,0 +1,28 @@ +integer('itemId')->after('id')->index()->comment('商品id'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('goods', function (Blueprint $table) { + $table->dropColumn('itemId'); + }); + } +};