feat: 初步实现了获取单个商品的方法

This commit is contained in:
李东云
2023-07-25 14:50:12 +08:00
parent 68d898d177
commit 196ea4d8bf
7 changed files with 502 additions and 201 deletions

View File

@@ -16,25 +16,37 @@
"require": {
"php": ">=8.0",
"composer/composer": ">=2.5.8",
"singularity/hdk-core": "^0.2.20",
"hyperf/guzzle": "~3.0.0",
"moneyphp/money": "^4.1"
"moneyphp/money": "^4.1",
"singularity/hdk-core": "^1.0.0",
"hyperf/contract": "~3.0.0",
"hyperf/config": "~3.0.0",
"hyperf/di": "~3.0.0"
},
"require-dev": {
"cooper/hyperf-pest": "^1.1",
"firebase/php-jwt": "^6.8.0",
"phpunit/phpunit": "^9.6.9"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"optimize-autoloader": true,
"sort-packages": true,
"secure-http": false
"secure-http": false,
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"test": "vendor/bin/phpunit --prepend test/bootstrap.php -c phpunit.xml --colors=always",
"test": [
"rm -rf runtime",
"Composer\\Config::disableProcessTimeout",
"co-pest --prepend tests/bootstrap.php -c phpunit.xml --colors=always"
],
"cs-fix": "php-cs-fixer fix $1",
"analyse": "phpstan analyse --memory-limit 300M -l 0 -c phpstan.neon ./app ./config"
},

520
composer.lock generated
View File

@@ -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": "6274b63fa7f0516d1252cdbf12547952",
"content-hash": "192445d2df00eb55cb874c9667c9ff3d",
"packages": [
{
"name": "composer/ca-bundle",
@@ -111,7 +111,7 @@
"version": "2.5.8",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/composer/composer/2.5.8/composer-composer-2.5.8.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/composer/composer/2.5.8/composer-composer-2.5.8.zip",
"reference": "4c516146167d1392c8b9b269bb7c24115d262164",
"shasum": ""
},
@@ -199,7 +199,7 @@
"version": "1.0.0",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/composer/metadata-minifier/1.0.0/composer-metadata-minifier-1.0.0.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/composer/metadata-minifier/1.0.0/composer-metadata-minifier-1.0.0.zip",
"reference": "c549d23829536f0d0e984aaabbf02af91f443207",
"shasum": ""
},
@@ -347,7 +347,7 @@
"version": "1.5.7",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/composer/spdx-licenses/1.5.7/composer-spdx-licenses-1.5.7.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/composer/spdx-licenses/1.5.7/composer-spdx-licenses-1.5.7.zip",
"reference": "c848241796da2abf65837d51dce1fae55a960149",
"shasum": ""
},
@@ -556,7 +556,7 @@
"version": "2.3.0",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/ergebnis/http-method/2.3.0/ergebnis-http-method-2.3.0.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/ergebnis/http-method/2.3.0/ergebnis-http-method-2.3.0.zip",
"reference": "e120f01ca55b0129d842a1832aca073431e35136",
"shasum": ""
},
@@ -606,7 +606,7 @@
"version": "1.1.5",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/fig/http-message-util/1.1.5/fig-http-message-util-1.1.5.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/fig/http-message-util/1.1.5/fig-http-message-util-1.1.5.zip",
"reference": "9d94dc0154230ac39e5bf89398b324a86f63f765",
"shasum": ""
},
@@ -947,7 +947,7 @@
"version": "v3.0.18",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/hyperf/code-parser/v3.0.18/hyperf-code-parser-v3.0.18.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/code-parser/v3.0.18/hyperf-code-parser-v3.0.18.zip",
"reference": "f1812421150d7ef95067eb6657c6f84514b6dfea",
"shasum": ""
},
@@ -987,11 +987,11 @@
},
{
"name": "hyperf/codec",
"version": "v3.0.1",
"version": "v3.0.30",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/hyperf/codec/v3.0.1/hyperf-codec-v3.0.1.zip",
"reference": "7d3cbfa06c50ef52809acadfcbcd59424366f591",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/codec/v3.0.30/hyperf-codec-v3.0.30.zip",
"reference": "30b170b59770c7f92ae845fca777b8ea8a953599",
"shasum": ""
},
"require": {
@@ -1000,6 +1000,9 @@
"hyperf/contract": "~3.0.0",
"php": ">=8.0"
},
"suggest": {
"ext-igbinary": "Required to use IgbinarySerializerPacker."
},
"type": "library",
"extra": {
"branch-alias": {
@@ -1022,14 +1025,14 @@
"php",
"swoole"
],
"time": "2023-04-24T09:49:41+00:00"
"time": "2023-07-18T12:10:42+00:00"
},
{
"name": "hyperf/collection",
"version": "v3.0.29",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/hyperf/collection/v3.0.29/hyperf-collection-v3.0.29.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/collection/v3.0.29/hyperf-collection-v3.0.29.zip",
"reference": "c2e3f919f8c445da69e0e0c10920c6fc0754b9ad",
"shasum": ""
},
@@ -1070,7 +1073,7 @@
"version": "v3.0.0",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/hyperf/conditionable/v3.0.0/hyperf-conditionable-v3.0.0.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/conditionable/v3.0.0/hyperf-conditionable-v3.0.0.zip",
"reference": "4222cdc512e9e48e4375a480161c6365276ff803",
"shasum": ""
},
@@ -1161,7 +1164,7 @@
"version": "v3.0.18",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/hyperf/constants/v3.0.18/hyperf-constants-v3.0.18.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/constants/v3.0.18/hyperf-constants-v3.0.18.zip",
"reference": "71eadfcf6495eb4945a2416569649e39a89a55e3",
"shasum": ""
},
@@ -1242,7 +1245,7 @@
"version": "v3.0.10",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/hyperf/contract/v3.0.10/hyperf-contract-v3.0.10.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/contract/v3.0.10/hyperf-contract-v3.0.10.zip",
"reference": "93488df36b1c4e2fc16c630fb77c110bafffb141",
"shasum": ""
},
@@ -1277,7 +1280,7 @@
"version": "v3.0.22",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/hyperf/coordinator/v3.0.22/hyperf-coordinator-v3.0.22.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/coordinator/v3.0.22/hyperf-coordinator-v3.0.22.zip",
"reference": "a49c2d22995b4115e8b21f1de58b992047c4d0fd",
"shasum": ""
},
@@ -1314,7 +1317,7 @@
"version": "v3.0.16",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/hyperf/coroutine/v3.0.16/hyperf-coroutine-v3.0.16.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/coroutine/v3.0.16/hyperf-coroutine-v3.0.16.zip",
"reference": "4944ce69d5f35407e5dbcf7e9991f1db3366f254",
"shasum": ""
},
@@ -1409,7 +1412,7 @@
"version": "v2.10.0",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/hyperf/engine/v2.10.0/hyperf-engine-v2.10.0.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/engine/v2.10.0/hyperf-engine-v2.10.0.zip",
"reference": "9b27b29041403b8ee397ffe1e5254816e18cb5b9",
"shasum": ""
},
@@ -1469,7 +1472,7 @@
"version": "v1.9.0",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/hyperf/engine-contract/v1.9.0/hyperf-engine-contract-v1.9.0.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/engine-contract/v1.9.0/hyperf-engine-contract-v1.9.0.zip",
"reference": "45c9c49766d8b0e539975fe4c5ed6807221c4b38",
"shasum": ""
},
@@ -1707,7 +1710,7 @@
"version": "v3.0.0",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/hyperf/macroable/v3.0.0/hyperf-macroable-v3.0.0.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/macroable/v3.0.0/hyperf-macroable-v3.0.0.zip",
"reference": "822de69ba0c75aa9767a9cea487b84bf31d5240a",
"shasum": ""
},
@@ -1743,7 +1746,7 @@
"version": "v3.0.18",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/hyperf/paginator/v3.0.18/hyperf-paginator-v3.0.18.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/paginator/v3.0.18/hyperf-paginator-v3.0.18.zip",
"reference": "5e732c60fb47be062970a2d436e3bee341f15302",
"shasum": ""
},
@@ -1789,7 +1792,7 @@
"version": "v3.0.16",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/hyperf/pipeline/v3.0.16/hyperf-pipeline-v3.0.16.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/pipeline/v3.0.16/hyperf-pipeline-v3.0.16.zip",
"reference": "a3f48561f5cfef5f697e7005446e16560024a443",
"shasum": ""
},
@@ -1919,7 +1922,7 @@
"version": "v3.0.18",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/hyperf/resource/v3.0.18/hyperf-resource-v3.0.18.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/resource/v3.0.18/hyperf-resource-v3.0.18.zip",
"reference": "2b65201ca475cf45fb2070cfca95a4b8a85f82f6",
"shasum": ""
},
@@ -1965,7 +1968,7 @@
"version": "v3.0.0",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/hyperf/serializer/v3.0.0/hyperf-serializer-v3.0.0.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/serializer/v3.0.0/hyperf-serializer-v3.0.0.zip",
"reference": "c4efedaa072c5ffe196e95e0c74a9d90fd1e4811",
"shasum": ""
},
@@ -2010,7 +2013,7 @@
"version": "v3.0.27",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/hyperf/stringable/v3.0.27/hyperf-stringable-v3.0.27.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/stringable/v3.0.27/hyperf-stringable-v3.0.27.zip",
"reference": "cd56584d5d7a2688e1c1a401c3c41c0a8143a920",
"shasum": ""
},
@@ -2058,7 +2061,7 @@
"version": "v3.0.24",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/hyperf/support/v3.0.24/hyperf-support-v3.0.24.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/support/v3.0.24/hyperf-support-v3.0.24.zip",
"reference": "576838e7185bf8eb749920a3285b399cb9c3a24b",
"shasum": ""
},
@@ -2106,7 +2109,7 @@
"version": "v3.0.0",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/hyperf/tappable/v3.0.0/hyperf-tappable-v3.0.0.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/tappable/v3.0.0/hyperf-tappable-v3.0.0.zip",
"reference": "4f90b9026a5bdce5b3e6be29a2ab7a86c54f372a",
"shasum": ""
},
@@ -2145,7 +2148,7 @@
"version": "v3.0.22",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/hyperf/translation/v3.0.22/hyperf-translation-v3.0.22.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/translation/v3.0.22/hyperf-translation-v3.0.22.zip",
"reference": "d8043633db04c81490b87c29007f3e53307b3aa1",
"shasum": ""
},
@@ -2423,7 +2426,7 @@
"version": "1.2.0",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/lmc/http-constants/1.2.0/lmc-http-constants-1.2.0.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/lmc/http-constants/1.2.0/lmc-http-constants-1.2.0.zip",
"reference": "8cb0fbffdafdf0c0c42e05935fb09cc588633d48",
"shasum": ""
},
@@ -3143,7 +3146,7 @@
"version": "1.6.0",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/roave/dont/1.6.0/roave-dont-1.6.0.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/roave/dont/1.6.0/roave-dont-1.6.0.zip",
"reference": "e40b8fbeb9c0b076eedd54dae2e1b27bfad74930",
"shasum": ""
},
@@ -3227,7 +3230,7 @@
"version": "1.2.1",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/seld/phar-utils/1.2.1/seld-phar-utils-1.2.1.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/seld/phar-utils/1.2.1/seld-phar-utils-1.2.1.zip",
"reference": "ea2f4014f163c1be4c601b9b7bd6af81ba8d701c",
"shasum": ""
},
@@ -3265,7 +3268,7 @@
"version": "2.0.1",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/seld/signal-handler/2.0.1/seld-signal-handler-2.0.1.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/seld/signal-handler/2.0.1/seld-signal-handler-2.0.1.zip",
"reference": "f69d119511dc0360440cdbdaa71829c149b7be75",
"shasum": ""
},
@@ -3313,11 +3316,11 @@
},
{
"name": "singularity/hdk-core",
"version": "0.2.23",
"version": "1.0.0-alpha.2",
"source": {
"type": "git",
"url": "http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore.git",
"reference": "3d86b05fffe6e87f065aaee4e867c0f0b3e49ada"
"reference": "3042ce00545ab5bc3b64b1bb10998bcd4739f8fa"
},
"require": {
"composer/composer": ">=2.0",
@@ -3418,7 +3421,7 @@
}
],
"description": "Common Hyperf Development Kit",
"time": "2023-07-07T02:13:01+00:00"
"time": "2023-07-21T08:22:48+00:00"
},
{
"name": "symfony/console",
@@ -4240,7 +4243,7 @@
"version": "v1.1.2",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/teapot/status-code/v1.1.2/teapot-status-code-v1.1.2.zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/teapot/status-code/v1.1.2/teapot-status-code-v1.1.2.zip",
"reference": "7aaba4364645ebb9d3a36267c9b3a32206d3042b",
"shasum": ""
},
@@ -4338,6 +4341,124 @@
}
],
"packages-dev": [
{
"name": "cooper/hyperf-pest",
"version": "v1.1.0",
"dist": {
"type": "zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/cooper/hyperf-pest/v1.1.0/cooper-hyperf-pest-v1.1.0.zip",
"reference": "977381d06b1db2b1401dba51e307290941378298",
"shasum": ""
},
"require": {
"hyperf/contract": "~3.0.0",
"hyperf/di": "~3.0.0",
"hyperf/utils": "~3.0.0",
"pestphp/pest": "~1.23.0",
"php": ">=8.0"
},
"require-dev": {
"composer/composer": "^2.0",
"friendsofphp/php-cs-fixer": "^3.0",
"hyperf/testing": "~3.0.0",
"mockery/mockery": "^1.0",
"phpstan/phpstan": "^1.0",
"phpunit/phpunit": "^9.6",
"swoole/ide-helper": "^5.0"
},
"suggest": {
"swow/swow": "Required to create swow components."
},
"bin": [
"bin/co-pest"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
},
"hyperf": {
"config": "Cooper\\HyperfPest\\ConfigProvider"
}
},
"autoload": {
"psr-4": {
"Cooper\\HyperfPest\\": "src/"
}
},
"license": [
"MIT"
],
"authors": [
{
"name": "cooper",
"email": "myxiaoao@gmail.com"
}
],
"description": "Pest Testing for hyperf",
"keywords": [
"hyperf",
"pest",
"php",
"testing"
],
"time": "2023-07-20T00:42:46+00:00"
},
{
"name": "filp/whoops",
"version": "2.15.3",
"dist": {
"type": "zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/filp/whoops/2.15.3/filp-whoops-2.15.3.zip",
"reference": "c83e88a30524f9360b11f585f71e6b17313b7187",
"shasum": ""
},
"require": {
"php": "^5.5.9 || ^7.0 || ^8.0",
"psr/log": "^1.0.1 || ^2.0 || ^3.0"
},
"require-dev": {
"mockery/mockery": "^0.9 || ^1.0",
"phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.3",
"symfony/var-dumper": "^2.6 || ^3.0 || ^4.0 || ^5.0"
},
"suggest": {
"symfony/var-dumper": "Pretty print complex values better with var-dumper available",
"whoops/soap": "Formats errors as SOAP responses"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.7-dev"
}
},
"autoload": {
"psr-4": {
"Whoops\\": "src/Whoops/"
}
},
"license": [
"MIT"
],
"authors": [
{
"name": "Filipe Dobreira",
"homepage": "https://github.com/filp",
"role": "Developer"
}
],
"description": "php error handling for cool kids",
"homepage": "https://filp.github.io/whoops/",
"keywords": [
"error",
"exception",
"handling",
"library",
"throwable",
"whoops"
],
"time": "2023-07-13T12:00:00+00:00"
},
{
"name": "firebase/php-jwt",
"version": "v6.8.1",
@@ -4391,51 +4512,6 @@
],
"time": "2023-07-14T18:33:00+00:00"
},
{
"name": "hyperf/session",
"version": "v3.0.18",
"dist": {
"type": "zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/hyperf/session/v3.0.18/hyperf-session-v3.0.18.zip",
"reference": "8c7d727c2c66f464e2b11d2a3ebee2d108b92c0b",
"shasum": ""
},
"require": {
"hyperf/collection": "~3.0.0",
"hyperf/support": "~3.0.0",
"hyperf/utils": "~3.0.0",
"php": ">=8.0",
"psr/http-server-middleware": "^1.0"
},
"suggest": {
"hyperf/config": "Required to load session config.",
"psr/container": "Required to use SessionFactory."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
},
"hyperf": {
"config": "Hyperf\\Session\\ConfigProvider"
}
},
"autoload": {
"psr-4": {
"Hyperf\\Session\\": "src/"
}
},
"license": [
"MIT"
],
"description": "A session library",
"homepage": "https://hyperf.io",
"keywords": [
"php",
"session"
],
"time": "2023-04-26T03:02:31+00:00"
},
{
"name": "myclabs/deep-copy",
"version": "1.11.1",
@@ -4479,6 +4555,192 @@
],
"time": "2023-03-08T13:26:56+00:00"
},
{
"name": "nunomaduro/collision",
"version": "v6.4.0",
"dist": {
"type": "zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/nunomaduro/collision/v6.4.0/nunomaduro-collision-v6.4.0.zip",
"reference": "f05978827b9343cba381ca05b8c7deee346b6015",
"shasum": ""
},
"require": {
"filp/whoops": "^2.14.5",
"php": "^8.0.0",
"symfony/console": "^6.0.2"
},
"require-dev": {
"brianium/paratest": "^6.4.1",
"laravel/framework": "^9.26.1",
"laravel/pint": "^1.1.1",
"nunomaduro/larastan": "^1.0.3",
"nunomaduro/mock-final-classes": "^1.1.0",
"orchestra/testbench": "^7.7",
"phpunit/phpunit": "^9.5.23",
"spatie/ignition": "^1.4.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-develop": "6.x-dev"
},
"laravel": {
"providers": [
"NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"NunoMaduro\\Collision\\": "src/"
}
},
"license": [
"MIT"
],
"authors": [
{
"name": "Nuno Maduro",
"email": "enunomaduro@gmail.com"
}
],
"description": "Cli error handling for console/command-line PHP applications.",
"keywords": [
"artisan",
"cli",
"command-line",
"console",
"error",
"handling",
"laravel",
"laravel-zero",
"php",
"symfony"
],
"time": "2023-01-03T12:54:54+00:00"
},
{
"name": "pestphp/pest",
"version": "v1.23.1",
"dist": {
"type": "zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/pestphp/pest/v1.23.1/pestphp-pest-v1.23.1.zip",
"reference": "5c56ad8772b89611c72a07e23f6e30aa29dc677a",
"shasum": ""
},
"require": {
"nunomaduro/collision": "^5.11.0|^6.4.0",
"pestphp/pest-plugin": "^1.1.0",
"php": "^7.3 || ^8.0",
"phpunit/phpunit": "^9.6.10"
},
"require-dev": {
"illuminate/console": "^8.83.27",
"illuminate/support": "^8.83.27",
"laravel/dusk": "^6.25.2",
"pestphp/pest-dev-tools": "^1.0.0",
"pestphp/pest-plugin-parallel": "^1.2.1"
},
"bin": [
"bin/pest"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-1.x": "1.x-dev"
},
"pest": {
"plugins": [
"Pest\\Plugins\\Coverage",
"Pest\\Plugins\\Init",
"Pest\\Plugins\\Version",
"Pest\\Plugins\\Environment"
]
},
"laravel": {
"providers": [
"Pest\\Laravel\\PestServiceProvider"
]
}
},
"autoload": {
"files": [
"src/Functions.php",
"src/Pest.php"
],
"psr-4": {
"Pest\\": "src/"
}
},
"license": [
"MIT"
],
"authors": [
{
"name": "Nuno Maduro",
"email": "enunomaduro@gmail.com"
}
],
"description": "An elegant PHP Testing Framework.",
"keywords": [
"framework",
"pest",
"php",
"test",
"testing",
"unit"
],
"time": "2023-07-12T19:42:47+00:00"
},
{
"name": "pestphp/pest-plugin",
"version": "v1.1.0",
"dist": {
"type": "zip",
"url": "https://mirrors.cloud.tencent.com/repository/composer/pestphp/pest-plugin/v1.1.0/pestphp-pest-plugin-v1.1.0.zip",
"reference": "606c5f79c6a339b49838ffbee0151ca519efe378",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.1.0 || ^2.0.0",
"php": "^7.3 || ^8.0"
},
"conflict": {
"pestphp/pest": "<1.0"
},
"require-dev": {
"composer/composer": "^2.4.2",
"pestphp/pest": "^1.22.1",
"pestphp/pest-dev-tools": "^1.0.0"
},
"type": "composer-plugin",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
},
"class": "Pest\\Plugin\\Manager"
},
"autoload": {
"psr-4": {
"Pest\\Plugin\\": "src/"
}
},
"license": [
"MIT"
],
"description": "The Pest plugin manager",
"keywords": [
"framework",
"manager",
"pest",
"php",
"plugin",
"test",
"testing",
"unit"
],
"time": "2022-09-18T13:18:17+00:00"
},
{
"name": "phar-io/manifest",
"version": "2.0.3",
@@ -4886,100 +5148,6 @@
],
"time": "2023-07-10T04:04:23+00:00"
},
{
"name": "psr/http-server-handler",
"version": "1.0.2",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/psr/http-server-handler/1.0.2/psr-http-server-handler-1.0.2.zip",
"reference": "84c4fb66179be4caaf8e97bd239203245302e7d4",
"shasum": ""
},
"require": {
"php": ">=7.0",
"psr/http-message": "^1.0 || ^2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Server\\": "src/"
}
},
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for HTTP server-side request handler",
"keywords": [
"handler",
"http",
"http-interop",
"psr",
"psr-15",
"psr-7",
"request",
"response",
"server"
],
"time": "2023-04-10T20:06:20+00:00"
},
{
"name": "psr/http-server-middleware",
"version": "1.0.2",
"dist": {
"type": "zip",
"url": "https://mirrors.tencent.com/repository/composer/psr/http-server-middleware/1.0.2/psr-http-server-middleware-1.0.2.zip",
"reference": "c1481f747daaa6a0782775cd6a8c26a1bf4a3829",
"shasum": ""
},
"require": {
"php": ">=7.0",
"psr/http-message": "^1.0 || ^2.0",
"psr/http-server-handler": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Server\\": "src/"
}
},
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for HTTP server-side middleware",
"keywords": [
"http",
"http-interop",
"middleware",
"psr",
"psr-15",
"psr-7",
"request",
"response"
],
"time": "2023-04-11T06:14:47+00:00"
},
{
"name": "sebastian/cli-parser",
"version": "1.0.1",
@@ -5724,7 +5892,7 @@
}
],
"aliases": [],
"minimum-stability": "stable",
"minimum-stability": "dev",
"stability-flags": [],
"prefer-stable": true,
"prefer-lowest": false,

View File

@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php"
colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd">
<coverage/>
<testsuites>
<testsuite name="Example">
<directory>./tests/Example/</directory>
<testsuite name="Pest">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>

50
src/Resource/Goods.php Normal file
View File

@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
/**
* Goods.php@Pay
*
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
* Powered by PhpStorm
* Created on 2023/7/20
*/
namespace Singularity\HDK\Pay\Resource;
use Hyperf\Resource\Json\JsonResource;
use Money\Money;
/**
* Singularity\HDK\Pay\Resource\Goods@Pay
*
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
* Powered by PhpStorm
* Created on 2023/7/20
*
* @property-read int $id
* @property-read string $goodsName
* @property-read array<string, mixed>|array{} $goodsSpec
* @property-read Money $amount
*/
final class Goods extends JsonResource
{
public ?string $wrap = null;
/**
* @return array{id: int, goodsName: string, goodsSpec: array<string, mixed>|array{}, amount: Money}
*/
public function toArray(): array
{
return [
'id' => $this->id,
'goodsName' => $this->goodsName,
'goodsSpec' => $this->goodsSpec,
'amount' => new Money($this->amount['price'], $this->amount['currency'])
];
}
public function __get($key)
{
return $this->resource->{$key} ?? $this->resource[$key];
}
}

53
src/Sdk/GoodsRpc.php Normal file
View File

@@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
/**
* GoodsRpc.php@Pay
*
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
* Powered by PhpStorm
* Created on 2023/7/21
*/
namespace Singularity\HDK\Pay\Sdk;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\RequestOptions;
use Hyperf\Codec\Json;
use Hyperf\Di\Annotation\Inject;
use Singularity\HDK\Core\Service\HttpRequestService;
use Singularity\HDK\Pay\Resource\Goods;
use function Hyperf\Config\config;
final class GoodsRpc
{
public function __construct(private HttpRequestService $requestService, private ?string $baseUri = null)
{
$this->baseUri ??= config('payment.base_uri');
if (empty($this->baseUri)) {
throw new \InvalidArgumentException('payment.base_uri is required');
}
$this->requestService->setOptions(
[
'base_uri' => $this->baseUri,
RequestOptions::ALLOW_REDIRECTS => true,
]
);
}
/**
* 筛选某个商品
* @param int $goodsId
* @param array $specifies
* @return Goods
* @throws GuzzleException
*/
public function find(int $goodsId, array $specifies): Goods
{
$url = $this->baseUri . '/rpc/v1/wechat/qrcode';
$response = $this->requestService->requestGet("/rpc/v1/goods/$goodsId/search", $specifies);
$content = $response->getBody()->getContents();
return Goods::make(Json::decode($content, false));
}
}

View File

@@ -1,18 +0,0 @@
<?php
declare(strict_types=1);
namespace Tests\Example;
use PHPUnit\Framework\TestCase;
use Example\Greeting;
class GreetingTest extends TestCase
{
public function testItGreetsUser(): void
{
$greeting = new Greeting('Rasmus Lerdorf');
$this->assertSame('Hello Rasmus Lerdorf', $greeting->sayHello());
}
}

36
tests/Unit/GoodsTest.php Normal file
View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
/**
* GoodsTest.php@LuxPay
*
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
* Powered by PhpStorm
* Created on 2023/7/18
*/
use Singularity\HDK\Core\Service\HttpRequestService;
use Singularity\HDK\Pay\Resource\Goods;
use Singularity\HDK\Pay\Sdk\GoodsRpc;
/** @var GoodsRpc $service */
$service = \Hyperf\Support\make(
GoodsRpc::class,
[
'requestService' => \Hyperf\Support\make(HttpRequestService::class),
'baseUri' => 'http://localhost:9611'
]);
test('根据分类和商品名称获取到对应的 SKU', function () use ($service) {
$goods = $service->find(
1,
[
'lattice' => 'TYPE-0',
'precision' => 'high',
'mode' => 'gradient',
],
);
expect($goods)->toBeInstanceOf(Goods::class);
})->only();