mirror of
http://124.126.16.154:8888/singularity/hdk-pay.git
synced 2026-01-15 02:15:07 +08:00
refactor(domain): 更新汇率接口并添加 UID 参数
- 在 ExchangeRepoInterface 中添加了 uid 参数 - 在 ProductRepo 中实现了 getRate 方法,增加了 uid 参数 - 更新了单元测试,添加了 uid 参数
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user