From e7e1c7f6c946fa171cdbf8049f1d90864a043685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=B8=9C=E4=BA=91?= Date: Fri, 19 Sep 2025 16:39:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor(domain):=20=E6=9B=B4=E6=96=B0=E6=B1=87?= =?UTF-8?q?=E7=8E=87=E6=8E=A5=E5=8F=A3=E5=B9=B6=E6=B7=BB=E5=8A=A0=20UID=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 ExchangeRepoInterface 中添加了 uid 参数 - 在 ProductRepo 中实现了 getRate 方法,增加了 uid 参数 - 更新了单元测试,添加了 uid 参数 --- src/Domain/Product/Repository/ExchangeRepoInterface.php | 3 ++- src/Infrastructure/Repository/ProductRepo.php | 3 ++- tests/Feature/Product/QueryPointRateTest.php | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Domain/Product/Repository/ExchangeRepoInterface.php b/src/Domain/Product/Repository/ExchangeRepoInterface.php index 316c0f9..6cc3c4a 100644 --- a/src/Domain/Product/Repository/ExchangeRepoInterface.php +++ b/src/Domain/Product/Repository/ExchangeRepoInterface.php @@ -16,7 +16,8 @@ interface ExchangeRepoInterface /** * @param PointType $source * @param PointType $target + * @param string $uid * @return float */ - public function getRate(PointType $source, PointType $target): float; + public function getRate(PointType $source, PointType $target, string $uid): float; } \ No newline at end of file diff --git a/src/Infrastructure/Repository/ProductRepo.php b/src/Infrastructure/Repository/ProductRepo.php index 80fa8ed..24a5dd9 100644 --- a/src/Infrastructure/Repository/ProductRepo.php +++ b/src/Infrastructure/Repository/ProductRepo.php @@ -206,10 +206,11 @@ final class ProductRepo extends AbstractRepo implements RechargeProductRepoInter * @return float * @throws GuzzleException */ - public function getRate(PointType $source, PointType $target): float + public function getRate(PointType $source, PointType $target, string $uid): float { $response = $this->requestService->requestGet( url: "/rpc/v2/products/$target->value/exchange-rate/$source->value", + params: ['uid' => $uid] ); $content = $response->getBody()->getContents(); diff --git a/tests/Feature/Product/QueryPointRateTest.php b/tests/Feature/Product/QueryPointRateTest.php index 791a17a..f0a3090 100644 --- a/tests/Feature/Product/QueryPointRateTest.php +++ b/tests/Feature/Product/QueryPointRateTest.php @@ -19,6 +19,8 @@ it('can query point rate', function () { $from = PointType::FtaiAligner; $to = PointType::LuxPoint; - $rate = $repo->getRate($from, $to); + $uid = 'cn3321'; + + $rate = $repo->getRate($from, $to, $uid); expect($rate)->toBeFloat(); });