refactor(domain): 更新汇率接口并添加 UID 参数

- 在 ExchangeRepoInterface 中添加了 uid 参数
- 在 ProductRepo 中实现了 getRate 方法,增加了 uid 参数
- 更新了单元测试,添加了 uid 参数
This commit is contained in:
李东云
2025-09-19 16:39:09 +08:00
parent 7e0d711e99
commit e7e1c7f6c9
3 changed files with 7 additions and 3 deletions

View File

@@ -16,7 +16,8 @@ interface ExchangeRepoInterface
/** /**
* @param PointType $source * @param PointType $source
* @param PointType $target * @param PointType $target
* @param string $uid
* @return float * @return float
*/ */
public function getRate(PointType $source, PointType $target): float; public function getRate(PointType $source, PointType $target, string $uid): float;
} }

View File

@@ -206,10 +206,11 @@ final class ProductRepo extends AbstractRepo implements RechargeProductRepoInter
* @return float * @return float
* @throws GuzzleException * @throws GuzzleException
*/ */
public function getRate(PointType $source, PointType $target): float public function getRate(PointType $source, PointType $target, string $uid): float
{ {
$response = $this->requestService->requestGet( $response = $this->requestService->requestGet(
url: "/rpc/v2/products/$target->value/exchange-rate/$source->value", url: "/rpc/v2/products/$target->value/exchange-rate/$source->value",
params: ['uid' => $uid]
); );
$content = $response->getBody()->getContents(); $content = $response->getBody()->getContents();

View File

@@ -19,6 +19,8 @@ it('can query point rate', function () {
$from = PointType::FtaiAligner; $from = PointType::FtaiAligner;
$to = PointType::LuxPoint; $to = PointType::LuxPoint;
$rate = $repo->getRate($from, $to); $uid = 'cn3321';
$rate = $repo->getRate($from, $to, $uid);
expect($rate)->toBeFloat(); expect($rate)->toBeFloat();
}); });