mirror of
http://124.126.16.154:8888/singularity/hdk-pay.git
synced 2026-01-15 07:15:06 +08:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d4f561ef0 | ||
|
|
aa8742923c | ||
|
|
738d225fd8 | ||
|
|
38ce644c73 | ||
|
|
f2a51fa1da | ||
|
|
59b5118b93 | ||
|
|
c468fdda0e | ||
|
|
24709acf09 | ||
|
|
f141989a8d | ||
|
|
fd6548e144 | ||
|
|
acc3121320 | ||
|
|
b521e7c9e0 | ||
|
|
2276885ac1 |
@@ -17,6 +17,8 @@ jobs:
|
||||
ls ${{ gitea.workspace }}
|
||||
- name: Zip files in the repository
|
||||
run: |
|
||||
sed -i 's|deb.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list
|
||||
sed -i 's|security.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list
|
||||
apt-get update
|
||||
apt-get install zip
|
||||
zip -r dist.zip *
|
||||
|
||||
47
CHANGELOG.md
47
CHANGELOG.md
@@ -1,4 +1,51 @@
|
||||
# 版本更新日志
|
||||
### [1.3.1](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.3.0...v1.3.1) (2025-08-27)
|
||||
|
||||
|
||||
### ♻️ Code Refactoring | 代码重构
|
||||
|
||||
* **account:** 优化点数日志仓库接口和实现类 ([aa87429](http://124.126.16.154:8888/singularity/hdk-pay/commit/aa8742923c38ae90386c83b8a280a47dacc3537b))
|
||||
|
||||
## [1.3.0](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.2.7...v1.3.0) (2025-08-27)
|
||||
|
||||
|
||||
### ♻️ Code Refactoring | 代码重构
|
||||
|
||||
* **Account:** 重构账户相关类的命名空间 ([f2a51fa](http://124.126.16.154:8888/singularity/hdk-pay/commit/f2a51fa1da67d5169761bc47cbe2b6da605051ae))
|
||||
|
||||
|
||||
### ✨ Features | 新功能
|
||||
|
||||
* **account:** 添加积分日志相关功能 ([38ce644](http://124.126.16.154:8888/singularity/hdk-pay/commit/38ce644c7351740641901a0497351f45c0119339))
|
||||
|
||||
### [1.2.7](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.2.6...v1.2.7) (2025-08-26)
|
||||
|
||||
|
||||
### 📦 Build System | 打包构建
|
||||
|
||||
* 更新发布流程以使用阿里云镜像源 ([c468fdd](http://124.126.16.154:8888/singularity/hdk-pay/commit/c468fdda0e4fd8bf5b2253527b368362ccb81954))
|
||||
|
||||
### [1.2.6](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.2.5...v1.2.6) (2025-08-26)
|
||||
|
||||
|
||||
### ♻️ Code Refactoring | 代码重构
|
||||
|
||||
* **Order:** 重构订单资源以支持经典订单解析 ([f141989](http://124.126.16.154:8888/singularity/hdk-pay/commit/f141989a8d7c6055d0d740619cc0660a1ea0ef7f))
|
||||
|
||||
### [1.2.5](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.2.4...v1.2.5) (2025-08-26)
|
||||
|
||||
|
||||
### 🐛 Bug Fixes | Bug 修复
|
||||
|
||||
* **Sdk:** 调整 WechatRpc 类中数组键名的命名风格 ([acc3121](http://124.126.16.154:8888/singularity/hdk-pay/commit/acc3121320d74e2ea3423e3502779afde9675ee8))
|
||||
|
||||
### [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)
|
||||
|
||||
|
||||
|
||||
@@ -70,5 +70,5 @@
|
||||
"url": "https://mirrors.aliyun.com/composer/"
|
||||
}
|
||||
},
|
||||
"version": "1.2.3"
|
||||
"version": "1.3.1"
|
||||
}
|
||||
|
||||
@@ -7,11 +7,13 @@ namespace Singularity\HDK\Pay;
|
||||
use Hyperf\Contract\StdoutLoggerInterface;
|
||||
use Hyperf\Framework\Logger\StdoutLogger;
|
||||
use Singularity\HDK\Pay\Domain\Account\Repository\AccountRepoInterface;
|
||||
use Singularity\HDK\Pay\Domain\Account\Repository\PointLogRepoInterface;
|
||||
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\PointLogRepo;
|
||||
use Singularity\HDK\Pay\Infrastructure\Repository\ProductRepo;
|
||||
|
||||
/**
|
||||
@@ -30,11 +32,12 @@ class ConfigProvider
|
||||
'dependencies' => [
|
||||
StdoutLoggerInterface::class => StdoutLogger::class,
|
||||
|
||||
// Command
|
||||
// Repo
|
||||
AccountRepoInterface::class => AccountBalanceRepo::class,
|
||||
ExchangeRepoInterface::class => ProductRepo::class,
|
||||
RechargeProductRepoInterface::class => ProductRepo::class,
|
||||
OrderRepoInterface::class => OrderRepo::class,
|
||||
PointLogRepoInterface::class => PointLogRepo::class,
|
||||
],
|
||||
// 合并到 config/autoload/annotations.php 文件
|
||||
'annotations' => [
|
||||
|
||||
@@ -9,9 +9,7 @@
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Account\Aggregate;
|
||||
|
||||
use Singularity\HDK\Pay\Domain\Account\Aggregate\ValueObject\PointsBalance;
|
||||
namespace Singularity\HDK\Pay\Domain\Account\Aggregate\Account;
|
||||
|
||||
/**
|
||||
* Singularity\HDK\Pay\Domain\Account\Aggregate\AccountBalance@Pay
|
||||
@@ -27,7 +25,7 @@ final readonly class AccountBalance
|
||||
{
|
||||
/**
|
||||
* @param string $uid
|
||||
* @param TPointsBalances $pointsBalances
|
||||
* @param PointsBalance $pointsBalances
|
||||
*/
|
||||
public function __construct(
|
||||
private string $uid,
|
||||
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Account\Aggregate\ValueObject;
|
||||
namespace Singularity\HDK\Pay\Domain\Account\Aggregate\Account;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Singularity\HDK\Pay\Domain\Account\Enum\PointType;
|
||||
70
src/Domain/Account/Aggregate/PointLog/PointLog.php
Normal file
70
src/Domain/Account/Aggregate/PointLog/PointLog.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PointLog.php@LuxPay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/21
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Account\Aggregate\PointLog;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Singularity\HDK\Pay\Domain\AggregateRoot;
|
||||
|
||||
final class PointLog extends AggregateRoot
|
||||
{
|
||||
public function __construct(
|
||||
private readonly int $id,
|
||||
private readonly string $caseId,
|
||||
private readonly string $uid,
|
||||
private readonly float $credits,
|
||||
private readonly string $source,
|
||||
private readonly string $operator,
|
||||
private readonly string $description,
|
||||
private readonly Carbon $date,
|
||||
) {}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function getSource(): string
|
||||
{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
public function getDate(): Carbon
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function getUid(): string
|
||||
{
|
||||
return $this->uid;
|
||||
}
|
||||
|
||||
|
||||
public function getCredits(): float
|
||||
{
|
||||
return $this->credits;
|
||||
}
|
||||
|
||||
public function getOperator(): string
|
||||
{
|
||||
return $this->operator;
|
||||
}
|
||||
|
||||
public function getCaseId(): ?string
|
||||
{
|
||||
return $this->caseId;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
35
src/Domain/Account/Enum/PointAction.php
Normal file
35
src/Domain/Account/Enum/PointAction.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* PointAction.php@LuxPay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/21
|
||||
*/
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Account\Enum;
|
||||
|
||||
enum PointAction
|
||||
{
|
||||
case Initial;
|
||||
|
||||
case Deduct;
|
||||
|
||||
case Refund;
|
||||
|
||||
case Increase;
|
||||
|
||||
case Clear;
|
||||
|
||||
public static function tryFrom(string $action): ?PointAction
|
||||
{
|
||||
return match (strtolower($action)) {
|
||||
'initial' => self::Initial,
|
||||
'deduct' => self::Deduct,
|
||||
'refund' => self::Refund,
|
||||
'increase' => self::Increase,
|
||||
'clear' => self::Clear,
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Account\Repository;
|
||||
|
||||
use Singularity\HDK\Pay\Domain\Account\Aggregate\AccountBalance;
|
||||
use Singularity\HDK\Pay\Domain\Account\Aggregate\ValueObject\PointsBalance;
|
||||
use Singularity\HDK\Pay\Domain\Account\Aggregate\Account\AccountBalance;
|
||||
use Singularity\HDK\Pay\Domain\Account\Aggregate\Account\PointsBalance;
|
||||
use Singularity\HDK\Pay\Domain\Account\Enum\PointType;
|
||||
|
||||
interface AccountRepoInterface
|
||||
|
||||
22
src/Domain/Account/Repository/PointLogRepoInterface.php
Normal file
22
src/Domain/Account/Repository/PointLogRepoInterface.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* PointLogRepoInterface.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/27
|
||||
*/
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Account\Repository;
|
||||
|
||||
use Singularity\HDK\Pay\Domain\Account\Aggregate\PointLog\PointLog;
|
||||
|
||||
interface PointLogRepoInterface
|
||||
{
|
||||
/**
|
||||
* @param string $uid
|
||||
* @return PointLog[]
|
||||
*/
|
||||
public function getList(string $uid): array;
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@ final class Item extends ArrayObject
|
||||
parent::__construct([
|
||||
'name' => $name,
|
||||
'quantity' => $quantity,
|
||||
'price' => $price,
|
||||
'unit_price' => $price,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ final class CallbackDomainSvc
|
||||
callback: fn(array $item) => new Item(
|
||||
name: $item['name'],
|
||||
quantity: $item['quantity'],
|
||||
price: $item['price'],
|
||||
price: $item['unit_price'],
|
||||
),
|
||||
array: $order['items'],
|
||||
),
|
||||
|
||||
@@ -12,8 +12,8 @@ declare(strict_types=1);
|
||||
namespace Singularity\HDK\Pay\Infrastructure\Repository;
|
||||
|
||||
use Hyperf\Codec\Json;
|
||||
use Singularity\HDK\Pay\Domain\Account\Aggregate\AccountBalance;
|
||||
use Singularity\HDK\Pay\Domain\Account\Aggregate\ValueObject\PointsBalance;
|
||||
use Singularity\HDK\Pay\Domain\Account\Aggregate\Account\AccountBalance;
|
||||
use Singularity\HDK\Pay\Domain\Account\Aggregate\Account\PointsBalance;
|
||||
use Singularity\HDK\Pay\Domain\Account\Enum\PointType;
|
||||
use Singularity\HDK\Pay\Domain\Account\Repository\AccountRepoInterface;
|
||||
|
||||
|
||||
41
src/Infrastructure/Repository/PointLogRepo.php
Normal file
41
src/Infrastructure/Repository/PointLogRepo.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PointLogRepo.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/27
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Infrastructure\Repository;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Codec\Json;
|
||||
use Singularity\HDK\Pay\Domain\Account\Aggregate\PointLog\PointLog;
|
||||
use Singularity\HDK\Pay\Domain\Account\Repository\PointLogRepoInterface;
|
||||
|
||||
final class PointLogRepo extends AbstractRepo implements PointLogRepoInterface
|
||||
{
|
||||
public function getList(string $uid): array
|
||||
{
|
||||
$response = $this->requestService->requestGet(url: "/rpc/v2/account/$uid/logs/points");
|
||||
|
||||
$content = $response->getBody()->getContents();
|
||||
$result = Json::decode($content);
|
||||
|
||||
return array_map(function ($item) {
|
||||
return new PointLog(
|
||||
id: $item['id'],
|
||||
caseId: $item['case_id'],
|
||||
uid: $item['uid'],
|
||||
credits: $item['credits'],
|
||||
source: $item['source'],
|
||||
operator: $item['operator'],
|
||||
description: $item['description'],
|
||||
date: new Carbon($item['date']),
|
||||
);
|
||||
}, $result);
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace Singularity\HDK\Pay\Resource\V2;
|
||||
|
||||
use App\Model\ServiceProvider;
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Resource\Json\JsonResource;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Singularity\HDK\Pay\Enum\OrderStatus;
|
||||
use stdClass;
|
||||
|
||||
@@ -48,6 +48,9 @@ class Order extends JsonResource
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
if (empty($this->resource['order_no'])) {
|
||||
return $this->parseClassicOrder();
|
||||
}
|
||||
return [
|
||||
'order_no' => $this->order_no,
|
||||
'state' => $this->state,
|
||||
@@ -65,6 +68,25 @@ class Order extends JsonResource
|
||||
];
|
||||
}
|
||||
|
||||
private function parseClassicOrder(): array
|
||||
{
|
||||
return [
|
||||
'order_no' => $this->orderNo,
|
||||
'state' => $this->state,
|
||||
'transaction_id' => $this->transactionId,
|
||||
'uid' => $this->uid,
|
||||
'method' => $this->payment,
|
||||
'description' => $this->goodsName,
|
||||
'total_amount' => new Money($this->amount['amount'], new Currency($this->amount['currency'])),
|
||||
'currency' => $this->amount['currency'],
|
||||
'items' => [],
|
||||
'external' => [],
|
||||
'remark' => $this->remark,
|
||||
'notification' => $this->notification ?? [],
|
||||
'more_details' => [],
|
||||
];
|
||||
}
|
||||
|
||||
public function __get($key)
|
||||
{
|
||||
return $this->resource->{$key} ?? $this->resource[$key];
|
||||
|
||||
@@ -76,8 +76,8 @@ final class WechatRpc
|
||||
'amount' => (int)$money->getAmount(),
|
||||
'fileType' => $type,
|
||||
'uid' => $uid,
|
||||
'goods_detail' => [
|
||||
'goods_name' => $goodsName,
|
||||
'goodsDetail' => [
|
||||
'goodsName' => $goodsName,
|
||||
],
|
||||
'number' => $number,
|
||||
],
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* Created on 2025/8/18
|
||||
*/
|
||||
|
||||
use Singularity\HDK\Pay\Domain\Account\Aggregate\AccountBalance;
|
||||
use Singularity\HDK\Pay\Domain\Account\Aggregate\Account\AccountBalance;
|
||||
use Singularity\HDK\Pay\Infrastructure\Repository\AccountBalanceRepo;
|
||||
|
||||
use function Hyperf\Support\make;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* Created on 2025/8/18
|
||||
*/
|
||||
|
||||
use Singularity\HDK\Pay\Domain\Account\Aggregate\ValueObject\PointsBalance;
|
||||
use Singularity\HDK\Pay\Domain\Account\Aggregate\Account\PointsBalance;
|
||||
use Singularity\HDK\Pay\Domain\Account\Enum\PointType;
|
||||
use Singularity\HDK\Pay\Infrastructure\Repository\AccountBalanceRepo;
|
||||
|
||||
|
||||
25
tests/Feature/Account/QueryPointLogListTest.php
Normal file
25
tests/Feature/Account/QueryPointLogListTest.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* QueryPointLogListTest.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/8/27
|
||||
*/
|
||||
|
||||
use Singularity\HDK\Pay\Domain\Account\Aggregate\PointLog\PointLog;
|
||||
use Singularity\HDK\Pay\Infrastructure\Repository\PointLogRepo;
|
||||
|
||||
use function Hyperf\Support\make;
|
||||
|
||||
it('should can query point log list', function () {
|
||||
$uid = '61a74db54f387';
|
||||
|
||||
$repo = make(PointLogRepo::class);
|
||||
$list = $repo->getList($uid);
|
||||
expect($list)
|
||||
->not->toBeEmpty()
|
||||
->each
|
||||
->toBeInstanceOf(PointLog::class);
|
||||
});
|
||||
Reference in New Issue
Block a user