mirror of
http://124.126.16.154:8888/singularity/hdk-pay.git
synced 2026-01-15 07:15:06 +08:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b521e7c9e0 | ||
|
|
2276885ac1 | ||
|
|
8d2d3c8ba5 | ||
|
|
86939ea421 | ||
|
|
960e3f1877 | ||
|
|
2ea5227185 | ||
|
|
c7f94bb396 | ||
|
|
9d61106e2e | ||
|
|
c3a256cb3d | ||
|
|
245f13b26d | ||
|
|
fc5cf453ae | ||
|
|
8f71cbeb65 | ||
|
|
9517b5bd62 | ||
|
|
c8ee3bb23b | ||
|
|
80dc1a3706 |
53
CHANGELOG.md
53
CHANGELOG.md
@@ -1,4 +1,57 @@
|
||||
# 版本更新日志
|
||||
### [1.2.4](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.2.3...v1.2.4) (2025-08-21)
|
||||
|
||||
|
||||
### ♻️ Code Refactoring | 代码重构
|
||||
|
||||
* **transaction:** 修改交易项中的价格字段名称 ([2276885](http://124.126.16.154:8888/singularity/hdk-pay/commit/2276885ac1759a330eb6fb73e1158235edcac941))
|
||||
|
||||
### [1.2.3](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.2.2...v1.2.3) (2025-08-20)
|
||||
|
||||
|
||||
### ♻️ Code Refactoring | 代码重构
|
||||
|
||||
* **transaction:** 重构交易信息构建方式 ([86939ea](http://124.126.16.154:8888/singularity/hdk-pay/commit/86939ea421d2f14c621da4e3bb86e3ab8d8b7d33))
|
||||
|
||||
### [1.2.2](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.2.1...v1.2.2) (2025-08-20)
|
||||
|
||||
|
||||
### 🐛 Bug Fixes | Bug 修复
|
||||
|
||||
* **transaction:** 修复回调服务中的商品价格字段 ([2ea5227](http://124.126.16.154:8888/singularity/hdk-pay/commit/2ea52271852e4e009b044fb9baeb222b3a54c111))
|
||||
|
||||
### [1.2.1](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.2.0...v1.2.1) (2025-08-20)
|
||||
|
||||
|
||||
### 📦 Build System | 打包构建
|
||||
|
||||
* **deps:** 更新多个依赖至最新版本 ([c3a256c](http://124.126.16.154:8888/singularity/hdk-pay/commit/c3a256cb3d5e41a29a4969442b5a7f27c9000576))
|
||||
|
||||
|
||||
### ✨ Features | 新功能
|
||||
|
||||
* **TransactionRecord:** 添加 TransactionRecord 类的 getter 方法 ([9d61106](http://124.126.16.154:8888/singularity/hdk-pay/commit/9d61106e2e8b04559fb34b606fb489a2890c34d5))
|
||||
|
||||
## [1.2.0](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.1.0...v1.2.0) (2025-08-20)
|
||||
|
||||
|
||||
### ✨ Features | 新功能
|
||||
|
||||
* **transaction:** 添加交易相关实体和回调服务 ([8f71cbe](http://124.126.16.154:8888/singularity/hdk-pay/commit/8f71cbeb653d0722f231c300c2a1fabe79764580))
|
||||
|
||||
|
||||
### ✅ Tests | 测试
|
||||
|
||||
* 更新 LuxPay 回调测试用例 ([fc5cf45](http://124.126.16.154:8888/singularity/hdk-pay/commit/fc5cf453aed133552514e1b60699fe63d2178543))
|
||||
|
||||
## [1.1.0](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.0.0...v1.1.0) (2025-08-18)
|
||||
|
||||
|
||||
### ✨ Features | 新功能
|
||||
|
||||
* **pay:** 新增消费命令和通用订单 DTO ([c8ee3bb](http://124.126.16.154:8888/singularity/hdk-pay/commit/c8ee3bb23bf41f39a64ca08db4a005d2893c1554))
|
||||
* **pay:** 添加充值功能 ([80dc1a3](http://124.126.16.154:8888/singularity/hdk-pay/commit/80dc1a3706fa973f3360c70f1db34d403eb741df))
|
||||
|
||||
## [1.0.0](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.0.0-beta.5...v1.0.0) (2025-08-18)
|
||||
|
||||
|
||||
|
||||
@@ -70,5 +70,5 @@
|
||||
"url": "https://mirrors.aliyun.com/composer/"
|
||||
}
|
||||
},
|
||||
"version": "1.0.0"
|
||||
"version": "1.2.4"
|
||||
}
|
||||
|
||||
133
composer.lock
generated
133
composer.lock
generated
@@ -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": "1502e30908a8b64e02da6b75783f3598",
|
||||
"content-hash": "842b9afd4b54f12687b614b3d52a7b77",
|
||||
"packages": [
|
||||
{
|
||||
"name": "carbonphp/carbon-doctrine-types",
|
||||
@@ -942,16 +942,16 @@
|
||||
},
|
||||
{
|
||||
"name": "ergebnis/http-method",
|
||||
"version": "2.5.0",
|
||||
"version": "2.6.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ergebnis/http-method.git",
|
||||
"reference": "cb034b68d82e21b8a3cd4062426d3c28ced32d2c"
|
||||
"reference": "e8dd54f942095fdbc5678fac193c4940710a2fba"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ergebnis/http-method/zipball/cb034b68d82e21b8a3cd4062426d3c28ced32d2c",
|
||||
"reference": "cb034b68d82e21b8a3cd4062426d3c28ced32d2c",
|
||||
"url": "https://api.github.com/repos/ergebnis/http-method/zipball/e8dd54f942095fdbc5678fac193c4940710a2fba",
|
||||
"reference": "e8dd54f942095fdbc5678fac193c4940710a2fba",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@@ -961,20 +961,27 @@
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"php": "~8.1.0 || ~8.2.0 || ~8.3.0"
|
||||
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ergebnis/composer-normalize": "^2.39.0",
|
||||
"ergebnis/license": "^2.3.0",
|
||||
"ergebnis/php-cs-fixer-config": "^6.12.0",
|
||||
"ergebnis/phpunit-slow-test-detector": "^2.4.0",
|
||||
"phpunit/phpunit": "^10.4.2",
|
||||
"psalm/plugin-phpunit": "~0.18.4",
|
||||
"rector/rector": "~0.18.11",
|
||||
"vimeo/psalm": "^5.16.0"
|
||||
"ergebnis/composer-normalize": "^2.44.0",
|
||||
"ergebnis/license": "^2.6.0",
|
||||
"ergebnis/php-cs-fixer-config": "^6.37.0",
|
||||
"ergebnis/phpunit-slow-test-detector": "^2.16.1",
|
||||
"phpstan/extension-installer": "^1.4.3",
|
||||
"phpstan/phpstan": "^1.12.10",
|
||||
"phpstan/phpstan-deprecation-rules": "^1.2.1",
|
||||
"phpstan/phpstan-phpunit": "^1.4.0",
|
||||
"phpstan/phpstan-strict-rules": "^1.6.1",
|
||||
"phpunit/phpunit": "^10.5.26",
|
||||
"rector/rector": "^1.2.10",
|
||||
"roave/backward-compatibility-check": "^8.6.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "2.6-dev"
|
||||
},
|
||||
"composer-normalize": {
|
||||
"indent-size": 2,
|
||||
"indent-style": "space"
|
||||
@@ -1008,7 +1015,7 @@
|
||||
"security": "https://github.com/ergebnis/http-method/blob/main/.github/SECURITY.md",
|
||||
"source": "https://github.com/ergebnis/http-method"
|
||||
},
|
||||
"time": "2023-11-28T09:50:06+00:00"
|
||||
"time": "2024-11-17T21:27:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "fig/http-message-util",
|
||||
@@ -5710,16 +5717,16 @@
|
||||
},
|
||||
{
|
||||
"name": "react/promise",
|
||||
"version": "v2.11.0",
|
||||
"version": "v3.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/reactphp/promise.git",
|
||||
"reference": "1a8460931ea36dc5c76838fec5734d55c88c6831"
|
||||
"reference": "8a164643313c71354582dc850b42b33fa12a4b63"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/reactphp/promise/zipball/1a8460931ea36dc5c76838fec5734d55c88c6831",
|
||||
"reference": "1a8460931ea36dc5c76838fec5734d55c88c6831",
|
||||
"url": "https://api.github.com/repos/reactphp/promise/zipball/8a164643313c71354582dc850b42b33fa12a4b63",
|
||||
"reference": "8a164643313c71354582dc850b42b33fa12a4b63",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@@ -5729,10 +5736,11 @@
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4.0"
|
||||
"php": ">=7.1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36"
|
||||
"phpstan/phpstan": "1.10.39 || 1.4.10",
|
||||
"phpunit/phpunit": "^9.6 || ^7.5"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
@@ -5776,7 +5784,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/reactphp/promise/issues",
|
||||
"source": "https://github.com/reactphp/promise/tree/v2.11.0"
|
||||
"source": "https://github.com/reactphp/promise/tree/v3.2.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -5784,7 +5792,7 @@
|
||||
"type": "open_collective"
|
||||
}
|
||||
],
|
||||
"time": "2023-11-16T16:16:50+00:00"
|
||||
"time": "2024-05-24T10:39:05+00:00"
|
||||
},
|
||||
{
|
||||
"name": "rector/rector",
|
||||
@@ -6102,16 +6110,16 @@
|
||||
},
|
||||
{
|
||||
"name": "singularity/hdk-core",
|
||||
"version": "1.0.0-beta.14",
|
||||
"version": "1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://nest.doylee.cn/HDK/hdk-core",
|
||||
"reference": "1.0.0-beta.14"
|
||||
"reference": "1.0.1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://nest.doylee.cn/api/packages/HDK/composer/files/singularity%2Fhdk-core/1.0.0-beta.14/singularity-hdk-core.1.0.0-beta.14.zip",
|
||||
"shasum": "dc0a07b1c83088d3ba2b694de7d11dae9ca8b115"
|
||||
"url": "https://nest.doylee.cn/api/packages/HDK/composer/files/singularity%2Fhdk-core/1.0.1/singularity-hdk-core.1.0.1.zip",
|
||||
"shasum": "b61df9f495b193f441b0e92edf7f8cdeb8d1d038"
|
||||
},
|
||||
"require": {
|
||||
"composer/composer": ">=2.0",
|
||||
@@ -6204,7 +6212,7 @@
|
||||
}
|
||||
],
|
||||
"description": "Common Hyperf Development Kit",
|
||||
"time": "2025-08-12T15:05:30+08:00"
|
||||
"time": "2025-08-20T14:10:21+08:00"
|
||||
},
|
||||
{
|
||||
"name": "swow/psr7-plus",
|
||||
@@ -6662,7 +6670,7 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-ctype",
|
||||
"version": "v1.31.0",
|
||||
"version": "v1.32.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-ctype.git",
|
||||
@@ -6727,7 +6735,7 @@
|
||||
"portable"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0"
|
||||
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.32.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -6747,7 +6755,7 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-intl-grapheme",
|
||||
"version": "v1.31.0",
|
||||
"version": "v1.32.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-intl-grapheme.git",
|
||||
@@ -6811,7 +6819,7 @@
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.31.0"
|
||||
"source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.32.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -6831,7 +6839,7 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-intl-normalizer",
|
||||
"version": "v1.31.0",
|
||||
"version": "v1.32.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-intl-normalizer.git",
|
||||
@@ -6898,7 +6906,7 @@
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.31.0"
|
||||
"source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.32.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -6918,16 +6926,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-mbstring",
|
||||
"version": "v1.31.0",
|
||||
"version": "v1.32.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
||||
"reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341"
|
||||
"reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341",
|
||||
"reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493",
|
||||
"reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@@ -6937,6 +6945,7 @@
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"ext-iconv": "*",
|
||||
"php": ">=7.2"
|
||||
},
|
||||
"provide": {
|
||||
@@ -6948,8 +6957,8 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"thanks": {
|
||||
"name": "symfony/polyfill",
|
||||
"url": "https://github.com/symfony/polyfill"
|
||||
"url": "https://github.com/symfony/polyfill",
|
||||
"name": "symfony/polyfill"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -6984,7 +6993,7 @@
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0"
|
||||
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.32.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -7000,11 +7009,11 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-09-09T11:45:10+00:00"
|
||||
"time": "2024-12-23T08:48:59+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php73",
|
||||
"version": "v1.31.0",
|
||||
"version": "v1.32.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-php73.git",
|
||||
@@ -7066,7 +7075,7 @@
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-php73/tree/v1.31.0"
|
||||
"source": "https://github.com/symfony/polyfill-php73/tree/v1.32.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -7086,16 +7095,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php80",
|
||||
"version": "v1.31.0",
|
||||
"version": "v1.32.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-php80.git",
|
||||
"reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8"
|
||||
"reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
|
||||
"reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608",
|
||||
"reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@@ -7152,7 +7161,7 @@
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0"
|
||||
"source": "https://github.com/symfony/polyfill-php80/tree/v1.32.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -7168,11 +7177,11 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-09-09T11:45:10+00:00"
|
||||
"time": "2025-01-02T08:10:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php81",
|
||||
"version": "v1.31.0",
|
||||
"version": "v1.32.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-php81.git",
|
||||
@@ -7234,7 +7243,7 @@
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-php81/tree/v1.31.0"
|
||||
"source": "https://github.com/symfony/polyfill-php81/tree/v1.32.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -7254,7 +7263,7 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php82",
|
||||
"version": "v1.31.0",
|
||||
"version": "v1.32.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-php82.git",
|
||||
@@ -7316,7 +7325,7 @@
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-php82/tree/v1.31.0"
|
||||
"source": "https://github.com/symfony/polyfill-php82/tree/v1.32.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -7336,7 +7345,7 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php83",
|
||||
"version": "v1.31.0",
|
||||
"version": "v1.32.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-php83.git",
|
||||
@@ -7398,7 +7407,7 @@
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-php83/tree/v1.31.0"
|
||||
"source": "https://github.com/symfony/polyfill-php83/tree/v1.32.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -7418,16 +7427,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php84",
|
||||
"version": "v1.31.0",
|
||||
"version": "v1.32.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-php84.git",
|
||||
"reference": "e5493eb51311ab0b1cc2243416613f06ed8f18bd"
|
||||
"reference": "000df7860439609837bbe28670b0be15783b7fbf"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-php84/zipball/e5493eb51311ab0b1cc2243416613f06ed8f18bd",
|
||||
"reference": "e5493eb51311ab0b1cc2243416613f06ed8f18bd",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-php84/zipball/000df7860439609837bbe28670b0be15783b7fbf",
|
||||
"reference": "000df7860439609837bbe28670b0be15783b7fbf",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@@ -7480,7 +7489,7 @@
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-php84/tree/v1.31.0"
|
||||
"source": "https://github.com/symfony/polyfill-php84/tree/v1.32.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -7496,7 +7505,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-09-09T12:04:04+00:00"
|
||||
"time": "2025-02-20T12:04:08+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/process",
|
||||
|
||||
41
src/Application/Command/ConsumeCmd.php
Normal file
41
src/Application/Command/ConsumeCmd.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ConsumeCmd.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/18
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Application\Command;
|
||||
|
||||
use Singularity\HDK\Pay\Domain\Account\Enum\PointType;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\PayType;
|
||||
use Singularity\HDK\Pay\Enum\PaymentMethod;
|
||||
|
||||
final class ConsumeCmd
|
||||
{
|
||||
public array $items = [];
|
||||
|
||||
public function __construct(
|
||||
public string $uid,
|
||||
public PayType $type,
|
||||
public PaymentMethod|PointType $method,
|
||||
public array $external,
|
||||
public ?string $externalID = null,
|
||||
public ?string $remark = null,
|
||||
) {}
|
||||
|
||||
public function addItem(string $name, float $unitPrice, int $quantity = 1): ConsumeCmd
|
||||
{
|
||||
$this->items[] = [
|
||||
'name' => $name,
|
||||
'quantity' => $quantity,
|
||||
'unit_price' => $unitPrice,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
28
src/Application/Command/RechargeCmd.php
Normal file
28
src/Application/Command/RechargeCmd.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* RechargeCmd.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/18
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Application\Command;
|
||||
|
||||
final class RechargeCmd {
|
||||
public array $items = [];
|
||||
|
||||
public function __construct(public string $uid) {}
|
||||
|
||||
public function addItem(int $productId, int $quantity = 1): RechargeCmd
|
||||
{
|
||||
$this->items[] = [
|
||||
'product_id' => $productId,
|
||||
'quantity' => $quantity,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
46
src/Application/Dto/Transaction/OrderDto.php
Normal file
46
src/Application/Dto/Transaction/OrderDto.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* RechargeDto.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/18
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Application\Dto\Transaction;
|
||||
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\OrderAction;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\OrderStatus;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\PayType;
|
||||
|
||||
final readonly class OrderDto
|
||||
{
|
||||
public function __construct(
|
||||
private string $orderNo,
|
||||
private OrderAction $action,
|
||||
private PayType $payType,
|
||||
private OrderStatus $status,
|
||||
) {}
|
||||
|
||||
public function getOrderNo(): string
|
||||
{
|
||||
return $this->orderNo;
|
||||
}
|
||||
|
||||
public function getAction(): OrderAction
|
||||
{
|
||||
return $this->action;
|
||||
}
|
||||
|
||||
public function getPayType(): PayType
|
||||
{
|
||||
return $this->payType;
|
||||
}
|
||||
|
||||
public function getStatus(): OrderStatus
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,9 @@ use Hyperf\Framework\Logger\StdoutLogger;
|
||||
use Singularity\HDK\Pay\Domain\Account\Repository\AccountRepoInterface;
|
||||
use Singularity\HDK\Pay\Domain\Product\Repository\ExchangeRepoInterface;
|
||||
use Singularity\HDK\Pay\Domain\Product\Repository\RechargeProductRepoInterface;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Repository\OrderRepoInterface;
|
||||
use Singularity\HDK\Pay\Infrastructure\Repository\AccountBalanceRepo;
|
||||
use Singularity\HDK\Pay\Infrastructure\Repository\OrderRepo;
|
||||
use Singularity\HDK\Pay\Infrastructure\Repository\ProductRepo;
|
||||
|
||||
/**
|
||||
@@ -28,10 +30,11 @@ class ConfigProvider
|
||||
'dependencies' => [
|
||||
StdoutLoggerInterface::class => StdoutLogger::class,
|
||||
|
||||
// Repository
|
||||
// Command
|
||||
AccountRepoInterface::class => AccountBalanceRepo::class,
|
||||
ExchangeRepoInterface::class => ProductRepo::class,
|
||||
RechargeProductRepoInterface::class => ProductRepo::class,
|
||||
OrderRepoInterface::class => OrderRepo::class,
|
||||
],
|
||||
// 合并到 config/autoload/annotations.php 文件
|
||||
'annotations' => [
|
||||
|
||||
127
src/Domain/Transaction/Aggregate/TransactionRecord.php
Normal file
127
src/Domain/Transaction/Aggregate/TransactionRecord.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* TransactionRecord.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/20
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Transaction\Aggregate;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Singularity\HDK\Pay\Domain\AggregateRoot;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Aggregate\ValueObject\Item;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Aggregate\ValueObject\Transaction\CardTransaction;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Aggregate\ValueObject\Transaction\PointTransaction;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\OrderAction;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\OrderStatus;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\PayType;
|
||||
|
||||
final class TransactionRecord extends AggregateRoot
|
||||
{
|
||||
/**
|
||||
* @param string $orderNo
|
||||
* @param string $uid
|
||||
* @param PayType $payType
|
||||
* @param OrderAction $action
|
||||
* @param OrderStatus $status
|
||||
* @param string $source
|
||||
* @param Item[] $items
|
||||
* @param array<PointTransaction|CardTransaction> $transactions
|
||||
* @param array $refunds
|
||||
* @param array|null $external
|
||||
* @param string|null $externalId
|
||||
* @param Carbon|null $createdAt
|
||||
* @param Carbon|null $occurredAt
|
||||
* @param Carbon|null $lastRefundedAt
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly string $orderNo,
|
||||
private readonly string $uid,
|
||||
private readonly PayType $payType,
|
||||
private readonly OrderAction $action,
|
||||
private readonly OrderStatus $status,
|
||||
private readonly string $source,
|
||||
private readonly array $items,
|
||||
private readonly array $transactions,
|
||||
private readonly array $refunds,
|
||||
private readonly ?array $external,
|
||||
private readonly ?string $externalId,
|
||||
private readonly ?Carbon $createdAt,
|
||||
private readonly ?Carbon $occurredAt,
|
||||
private readonly ?Carbon $lastRefundedAt,
|
||||
) {}
|
||||
|
||||
public function getOrderNo(): string
|
||||
{
|
||||
return $this->orderNo;
|
||||
}
|
||||
|
||||
public function getUid(): string
|
||||
{
|
||||
return $this->uid;
|
||||
}
|
||||
|
||||
public function getPayType(): PayType
|
||||
{
|
||||
return $this->payType;
|
||||
}
|
||||
|
||||
public function getAction(): OrderAction
|
||||
{
|
||||
return $this->action;
|
||||
}
|
||||
|
||||
public function getStatus(): OrderStatus
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function getSource(): string
|
||||
{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
public function getItems(): array
|
||||
{
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
public function getTransactions(): array
|
||||
{
|
||||
return $this->transactions;
|
||||
}
|
||||
|
||||
public function getRefunds(): array
|
||||
{
|
||||
return $this->refunds;
|
||||
}
|
||||
|
||||
public function getExternal(): ?array
|
||||
{
|
||||
return $this->external;
|
||||
}
|
||||
|
||||
public function getExternalId(): ?string
|
||||
{
|
||||
return $this->externalId;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): ?Carbon
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function getOccurredAt(): ?Carbon
|
||||
{
|
||||
return $this->occurredAt;
|
||||
}
|
||||
|
||||
public function getLastRefundedAt(): ?Carbon
|
||||
{
|
||||
return $this->lastRefundedAt;
|
||||
}
|
||||
}
|
||||
44
src/Domain/Transaction/Aggregate/ValueObject/Item.php
Normal file
44
src/Domain/Transaction/Aggregate/ValueObject/Item.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Item.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/20
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Transaction\Aggregate\ValueObject;
|
||||
|
||||
use Swoole\ArrayObject;
|
||||
|
||||
final class Item extends ArrayObject
|
||||
{
|
||||
public function __construct(
|
||||
private readonly string $name,
|
||||
private readonly int $quantity,
|
||||
private readonly float $price,
|
||||
) {
|
||||
parent::__construct([
|
||||
'name' => $name,
|
||||
'quantity' => $quantity,
|
||||
'unit_price' => $price,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getQuantity(): int
|
||||
{
|
||||
return $this->quantity;
|
||||
}
|
||||
|
||||
public function getPrice(): float
|
||||
{
|
||||
return $this->price;
|
||||
}
|
||||
}
|
||||
44
src/Domain/Transaction/Aggregate/ValueObject/Transaction.php
Normal file
44
src/Domain/Transaction/Aggregate/ValueObject/Transaction.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Transaction.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/20
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Transaction\Aggregate\ValueObject;
|
||||
|
||||
use Singularity\HDK\Pay\Domain\Account\Enum\PointType;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\OrderStatus;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\PayType;
|
||||
use Singularity\HDK\Pay\Enum\PaymentMethod;
|
||||
use Swoole\ArrayObject;
|
||||
|
||||
/**
|
||||
* Singularity\HDK\Pay\Domain\Transaction\Aggregate\ValueObject\Transaction@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/20
|
||||
*/
|
||||
abstract class Transaction extends ArrayObject
|
||||
{
|
||||
public function __construct(
|
||||
private PayType $payType,
|
||||
private PaymentMethod|PointType $type,
|
||||
private float $amount,
|
||||
private OrderStatus $status,
|
||||
) {
|
||||
parent::__construct(
|
||||
[
|
||||
'pay_type' => $payType->value,
|
||||
'type' => $type->value,
|
||||
'amount' => $amount,
|
||||
'status' => $status->name,
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CardTransaction.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/20
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Transaction\Aggregate\ValueObject\Transaction;
|
||||
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Aggregate\ValueObject\Transaction;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\OrderStatus;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\PayType;
|
||||
use Singularity\HDK\Pay\Enum\PaymentMethod;
|
||||
|
||||
final class CardTransaction extends Transaction
|
||||
{
|
||||
public function __construct(
|
||||
PaymentMethod $method,
|
||||
float $amount,
|
||||
OrderStatus $status,
|
||||
) {
|
||||
parent::__construct(
|
||||
payType: PayType::Card,
|
||||
type: $method,
|
||||
amount: $amount,
|
||||
status: $status,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PointTransaction.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/20
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Transaction\Aggregate\ValueObject\Transaction;
|
||||
|
||||
use Singularity\HDK\Pay\Domain\Account\Enum\PointType;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Aggregate\ValueObject\Transaction;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\OrderStatus;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\PayType;
|
||||
|
||||
final class PointTransaction extends Transaction
|
||||
{
|
||||
public function __construct(PointType $type, float $amount, OrderStatus $status)
|
||||
{
|
||||
parent::__construct(
|
||||
payType: PayType::Point,
|
||||
type: $type,
|
||||
amount: $amount,
|
||||
status: $status,
|
||||
);
|
||||
}
|
||||
}
|
||||
18
src/Domain/Transaction/Enum/OrderAction.php
Normal file
18
src/Domain/Transaction/Enum/OrderAction.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* OrderAction.php@LuxDesign
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/7/30
|
||||
*/
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Transaction\Enum;
|
||||
|
||||
enum OrderAction: string {
|
||||
case Recharge = 'recharge';
|
||||
|
||||
case Consumption = 'consumption';
|
||||
|
||||
case Refund = 'refund';
|
||||
}
|
||||
58
src/Domain/Transaction/Enum/OrderStatus.php
Normal file
58
src/Domain/Transaction/Enum/OrderStatus.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* OrderStatus.php@LuxDesign
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2024/11/26
|
||||
*/
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Transaction\Enum;
|
||||
|
||||
enum OrderStatus
|
||||
{
|
||||
case created;
|
||||
|
||||
case paid;
|
||||
|
||||
case completed;
|
||||
|
||||
case refunded;
|
||||
|
||||
case cancelled;
|
||||
|
||||
case failed;
|
||||
|
||||
case closed;
|
||||
|
||||
public static function tryFrom(mixed $status): OrderStatus
|
||||
{
|
||||
$status = strtolower($status);
|
||||
return match ($status) {
|
||||
'paid' => self::paid,
|
||||
'refunded' => self::refunded,
|
||||
'cancelled' => self::cancelled,
|
||||
'completed' => self::completed,
|
||||
'failed' => self::failed,
|
||||
'closed' => self::closed,
|
||||
default => self::created,
|
||||
};
|
||||
}
|
||||
|
||||
public static function all(): array
|
||||
{
|
||||
return [
|
||||
self::created,
|
||||
self::paid,
|
||||
self::completed,
|
||||
self::refunded,
|
||||
self::cancelled,
|
||||
self::closed,
|
||||
];
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::all(), 'value');
|
||||
}
|
||||
}
|
||||
18
src/Domain/Transaction/Enum/PayType.php
Normal file
18
src/Domain/Transaction/Enum/PayType.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* PayType.php@LuxDesign
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/7/25
|
||||
*/
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Transaction\Enum;
|
||||
|
||||
Enum PayType: string {
|
||||
case Point = 'point';
|
||||
|
||||
case Card = 'card';
|
||||
|
||||
case Hybrid = 'hybrid';
|
||||
}
|
||||
21
src/Domain/Transaction/Repository/OrderRepoInterface.php
Normal file
21
src/Domain/Transaction/Repository/OrderRepoInterface.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* OrderRepoInterface.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/18
|
||||
*/
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Transaction\Repository;
|
||||
|
||||
use Singularity\HDK\Pay\Application\Command\ConsumeCmd;
|
||||
use Singularity\HDK\Pay\Application\Command\RechargeCmd;
|
||||
use Singularity\HDK\Pay\Application\Dto\Transaction\OrderDto;
|
||||
|
||||
interface OrderRepoInterface
|
||||
{
|
||||
public function recharge(RechargeCmd $cmd): OrderDto;
|
||||
|
||||
public function consume(ConsumeCmd $cmd): OrderDto;
|
||||
}
|
||||
80
src/Domain/Transaction/Service/CallbackDomainSvc.php
Normal file
80
src/Domain/Transaction/Service/CallbackDomainSvc.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CallbackDomainSvc.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/20
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Transaction\Service;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Singularity\HDK\Pay\Domain\Account\Enum\PointType;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Aggregate\TransactionRecord;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Aggregate\ValueObject\Item;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Aggregate\ValueObject\Transaction\CardTransaction;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Aggregate\ValueObject\Transaction\PointTransaction;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\OrderAction;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\OrderStatus;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\PayType;
|
||||
use Singularity\HDK\Pay\Enum\PaymentMethod;
|
||||
|
||||
/**
|
||||
* Singularity\HDK\Pay\Domain\Transaction\Service\CallbackDomainSvc@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/20
|
||||
*/
|
||||
final class CallbackDomainSvc
|
||||
{
|
||||
/**
|
||||
* @param array $order
|
||||
* @return TransactionRecord
|
||||
*/
|
||||
public function callback(array $order): TransactionRecord
|
||||
{
|
||||
$payType = PayType::tryFrom($order['pay_type']);
|
||||
|
||||
return new TransactionRecord(
|
||||
orderNo: $order['order_no'],
|
||||
uid: $order['uid'],
|
||||
payType: $payType,
|
||||
action: OrderAction::tryFrom($order['action']),
|
||||
status: OrderStatus::tryFrom($order['status']),
|
||||
source: $order['source'],
|
||||
items: array_map(
|
||||
callback: fn(array $item) => new Item(
|
||||
name: $item['name'],
|
||||
quantity: $item['quantity'],
|
||||
price: $item['unit_price'],
|
||||
),
|
||||
array: $order['items'],
|
||||
),
|
||||
transactions: array_map(
|
||||
callback: fn(array $transaction)
|
||||
=> $transaction['pay_type'] === PayType::Card->value
|
||||
? new CardTransaction(
|
||||
method: PaymentMethod::tryFrom($transaction['type']),
|
||||
amount: $transaction['amount'],
|
||||
status: OrderStatus::tryFrom($transaction['status']),
|
||||
)
|
||||
: new PointTransaction(
|
||||
type: PointType::tryFrom($transaction['type']),
|
||||
amount: $transaction['amount'],
|
||||
status: OrderStatus::tryFrom($transaction['status']),
|
||||
),
|
||||
array: $order['transactions'],
|
||||
),
|
||||
refunds: $order['refunds'],
|
||||
external: $order['external'],
|
||||
externalId: $order['external_id'],
|
||||
createdAt: isset($order['created_at']) ? new Carbon($order['created_at']) : null,
|
||||
occurredAt: isset($order['occurred_at']) ? new Carbon($order['occurred_at']) : null,
|
||||
lastRefundedAt: isset($order['last_refunded_at']) ? new Carbon($order['last_refunded_at']) : null,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ abstract class AbstractRepo
|
||||
$this->requestService = RequestServiceFactory::make([
|
||||
'base_uri' => $baseUrl ?? config('payment.base_uri'),
|
||||
RequestOptions::ALLOW_REDIRECTS => true,
|
||||
'headers' => $this->headerBuilder(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -26,9 +26,6 @@ final class AccountBalanceRepo extends AbstractRepo implements AccountRepoInterf
|
||||
params: [
|
||||
'type' => join(',', PointType::values()),
|
||||
],
|
||||
options: [
|
||||
'headers' => $this->headerBuilder(),
|
||||
],
|
||||
);
|
||||
|
||||
$content = $response->getBody()->getContents();
|
||||
@@ -55,9 +52,6 @@ final class AccountBalanceRepo extends AbstractRepo implements AccountRepoInterf
|
||||
{
|
||||
$response = $this->requestService->requestGet(
|
||||
url: "/rpc/v2/account/$uid/balance/$pointType->value",
|
||||
options: [
|
||||
'headers' => $this->headerBuilder(),
|
||||
],
|
||||
);
|
||||
|
||||
$content = $response->getBody()->getContents();
|
||||
|
||||
77
src/Infrastructure/Repository/OrderRepo.php
Normal file
77
src/Infrastructure/Repository/OrderRepo.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* OrderRepo.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/18
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Infrastructure\Repository;
|
||||
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Hyperf\Codec\Json;
|
||||
use Singularity\HDK\Pay\Application\Command\ConsumeCmd;
|
||||
use Singularity\HDK\Pay\Application\Command\RechargeCmd;
|
||||
use Singularity\HDK\Pay\Application\Dto\Transaction\OrderDto;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\OrderAction;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\OrderStatus;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\PayType;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Repository\OrderRepoInterface;
|
||||
|
||||
final class OrderRepo extends AbstractRepo implements OrderRepoInterface
|
||||
{
|
||||
/**
|
||||
* @param RechargeCmd $cmd
|
||||
* @return OrderDto
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function recharge(RechargeCmd $cmd): OrderDto
|
||||
{
|
||||
$response = $this->requestService->requestPost(
|
||||
url: '/rpc/v2/transaction/orders/recharge',
|
||||
data: [
|
||||
'uid' => $cmd->uid,
|
||||
'items' => $cmd->items,
|
||||
],
|
||||
);
|
||||
|
||||
$content = $response->getBody()->getContents();
|
||||
$result = Json::decode($content);
|
||||
|
||||
return new OrderDto(
|
||||
orderNo: $result['order_no'],
|
||||
action: OrderAction::tryFrom($result['action']),
|
||||
payType: PayType::tryFrom($result['pay_type']),
|
||||
status: OrderStatus::tryFrom($result['status']),
|
||||
);
|
||||
}
|
||||
|
||||
public function consume(ConsumeCmd $cmd): OrderDto
|
||||
{
|
||||
$response = $this->requestService->requestPost(
|
||||
url: '/rpc/v2/transaction/orders/consumption',
|
||||
data: [
|
||||
'uid' => $cmd->uid,
|
||||
'type' => $cmd->type->value,
|
||||
'method' => $cmd->method->value,
|
||||
'items' => $cmd->items,
|
||||
'external' => $cmd->external,
|
||||
'external_id' => $cmd->externalID ?? '',
|
||||
'remark' => $cmd->remark,
|
||||
],
|
||||
);
|
||||
|
||||
$content = $response->getBody()->getContents();
|
||||
$result = Json::decode($content);
|
||||
|
||||
return new OrderDto(
|
||||
orderNo: $result['order_no'],
|
||||
action: OrderAction::tryFrom($result['action']),
|
||||
payType: PayType::tryFrom($result['pay_type']),
|
||||
status: OrderStatus::tryFrom($result['status']),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -80,9 +80,6 @@ final class ProductRepo extends AbstractRepo implements RechargeProductRepoInter
|
||||
$response = $this->requestService->requestGet(
|
||||
url: '/rpc/v2/products/ema',
|
||||
params: ['uid' => $uid],
|
||||
options: [
|
||||
'headers' => $this->headerBuilder(),
|
||||
],
|
||||
);
|
||||
|
||||
$content = $response->getBody()->getContents();
|
||||
@@ -148,9 +145,6 @@ final class ProductRepo extends AbstractRepo implements RechargeProductRepoInter
|
||||
{
|
||||
$response = $this->requestService->requestGet(
|
||||
url: "/rpc/v2/products/$target->value/exchange-rate/$source->value",
|
||||
options: [
|
||||
'headers' => $this->headerBuilder(),
|
||||
],
|
||||
);
|
||||
|
||||
$content = $response->getBody()->getContents();
|
||||
|
||||
@@ -43,4 +43,4 @@ it('should can query EMA products', function () {
|
||||
->and($products->getRenew())->toBeInstanceOf(ProductItem::class),
|
||||
)
|
||||
->and($products->getPlans())->each->toBeInstanceOf(ProductItem::class);
|
||||
})->only();
|
||||
});
|
||||
|
||||
34
tests/Feature/Transaction/CreateConsumptionOrderTest.php
Normal file
34
tests/Feature/Transaction/CreateConsumptionOrderTest.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CreateConsumptionOrderTest.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/18
|
||||
*/
|
||||
|
||||
use Singularity\HDK\Pay\Application\Command\ConsumeCmd;
|
||||
use Singularity\HDK\Pay\Application\Dto\Transaction\OrderDto;
|
||||
use Singularity\HDK\Pay\Domain\Account\Enum\PointType;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Enum\PayType;
|
||||
use Singularity\HDK\Pay\Infrastructure\Repository\OrderRepo;
|
||||
|
||||
use function Hyperf\Support\make;
|
||||
|
||||
it('should can create consumption order', function () {
|
||||
$uid = 'cn3321';
|
||||
|
||||
$cmd = (new ConsumeCmd(
|
||||
uid: $uid,
|
||||
type: PayType::Point,
|
||||
method: PointType::FtaiAligner,
|
||||
external: [],
|
||||
externalID: null,
|
||||
remark: '',
|
||||
))->addItem('Design FTAI Aligner', 1, 5);
|
||||
|
||||
$repo = make(OrderRepo::class);
|
||||
$result = $repo->consume($cmd);
|
||||
expect($result)->toBeInstanceOf(OrderDto::class);
|
||||
});
|
||||
23
tests/Feature/Transaction/CreateRechargeOrderTest.php
Normal file
23
tests/Feature/Transaction/CreateRechargeOrderTest.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CreateRechargeOrderTest.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/18
|
||||
*/
|
||||
|
||||
use Singularity\HDK\Pay\Application\Command\RechargeCmd;
|
||||
use Singularity\HDK\Pay\Application\Dto\Transaction\OrderDto;
|
||||
use Singularity\HDK\Pay\Infrastructure\Repository\OrderRepo;
|
||||
|
||||
use function Hyperf\Support\make;
|
||||
|
||||
it('should can create recharge order', function () {
|
||||
$cmd = (new RechargeCmd('cn3321'))->addItem(1, 2);
|
||||
|
||||
$repo = make(OrderRepo::class);
|
||||
$result = $repo->recharge($cmd);
|
||||
expect($result)->toBeInstanceOf(OrderDto::class);
|
||||
});
|
||||
99
tests/Feature/Transaction/LuxPayCallbackTest.php
Normal file
99
tests/Feature/Transaction/LuxPayCallbackTest.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* LuxPayCallbackTest.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/20
|
||||
*/
|
||||
|
||||
use Hyperf\Codec\Json;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Aggregate\TransactionRecord;
|
||||
use Singularity\HDK\Pay\Domain\Transaction\Service\CallbackDomainSvc;
|
||||
|
||||
use function Hyperf\Support\make;
|
||||
|
||||
dataset('cases', [
|
||||
'recharge' => [
|
||||
<<<JSON
|
||||
{
|
||||
"order_no": "202508191929138659DTB",
|
||||
"uid": "cn3321",
|
||||
"pay_type": "card",
|
||||
"action": "recharge",
|
||||
"status": "created",
|
||||
"source": "LuxDesign",
|
||||
"items": [
|
||||
{
|
||||
"name": "Starter Pack",
|
||||
"unit_price": 399,
|
||||
"quantity": 1
|
||||
}
|
||||
],
|
||||
"transactions": [
|
||||
{
|
||||
"pay_type": "card",
|
||||
"type": "stripe.checkout",
|
||||
"amount": 399,
|
||||
"status": "created"
|
||||
}
|
||||
],
|
||||
"refunds": [],
|
||||
"external": [],
|
||||
"external_id": "",
|
||||
"created_at": "2025-08-20 10:44:46",
|
||||
"occurred_at": null,
|
||||
"last_refunded_at": null
|
||||
}
|
||||
JSON,
|
||||
],
|
||||
'consumption' => [
|
||||
<<<JSON
|
||||
{
|
||||
"order_no": "202508190441101116DTB",
|
||||
"uid": "cn3321",
|
||||
"pay_type": "hybrid",
|
||||
"action": "consumption",
|
||||
"status": "created",
|
||||
"source": "LuxDesign",
|
||||
"items": [
|
||||
{
|
||||
"name": "Design - retainer",
|
||||
"quantity": 1,
|
||||
"unit_price": 3
|
||||
}
|
||||
],
|
||||
"transactions": [
|
||||
{
|
||||
"pay_type": "card",
|
||||
"type": "stripe.checkout",
|
||||
"amount": 3,
|
||||
"status": "created"
|
||||
},
|
||||
{
|
||||
"pay_type": "point",
|
||||
"type": "lux-point",
|
||||
"amount": 3.05,
|
||||
"status": "created"
|
||||
}
|
||||
],
|
||||
"refunds": [],
|
||||
"external": [],
|
||||
"external_id": "",
|
||||
"created_at": "2025-08-20 10:44:46",
|
||||
"occurred_at": null,
|
||||
"last_refunded_at": null
|
||||
}
|
||||
JSON,
|
||||
]
|
||||
]);
|
||||
|
||||
it(
|
||||
'should parse request recharge body to TransactionRecord Entity',
|
||||
function ($data) {
|
||||
$data = Json::decode($data);
|
||||
$entity = make(CallbackDomainSvc::class)->callback($data);
|
||||
expect($entity)->toBeInstanceOf(TransactionRecord::class);
|
||||
},
|
||||
)->with('cases');
|
||||
@@ -34,6 +34,7 @@ $container = ApplicationContext::setContainer($container);
|
||||
/** @var Config $config */
|
||||
$config = make(Config::class, [
|
||||
[
|
||||
'app_name' => 'LuxDesign',
|
||||
'dependencies' => [],
|
||||
'payment' => [
|
||||
'base_uri' => env('LUX_PAY_BASE_URI', 'http://test-pay.luxcreo.com'),
|
||||
|
||||
Reference in New Issue
Block a user