feat(product): 增加 EMA 产品查询功能

- 移除了未使用的 ProductItem 引用
- 修改了 findEmaProduct 方法的参数,从 currentVersion 改为 uid
- 更新了 findEmaProduct 方法的实现,使用 uid 参数进行查询
- 重构了 RechargeProduct 对象的构建方式,提高了代码可读性
- 更新了单元测试,增加了 EMA 产品查询的测试用例
This commit is contained in:
李东云
2025-08-18 16:57:14 +08:00
parent 06dc4a2e65
commit 1814adc30e
3 changed files with 74 additions and 39 deletions

View File

@@ -8,6 +8,7 @@
* Created on 2025/8/18
*/
use Pest\Expectation;
use Singularity\HDK\Pay\Domain\Product\Aggregate\Entities\ProductItem;
use Singularity\HDK\Pay\Domain\Product\Aggregate\RechargeProduct;
use Singularity\HDK\Pay\Infrastructure\Repository\ProductRepo;
@@ -18,9 +19,28 @@ it('should can query LuxPoint products', function () {
$repo = make(ProductRepo::class);
$products = $repo->findLuxPointProduct();
var_dump($products);
expect($products)
->toBeInstanceOf(RechargeProduct::class)
->and($products->getOneTime())->toBeInstanceOf(ProductItem::class)
->and($products->getPackages())->each->toBeInstanceOf(ProductItem::class);
});
it('should can query EMA products', function () {
$repo = make(ProductRepo::class);
$uid = 'cn3321';
$products = $repo->findEmaProduct($uid);
expect($products)
->toBeInstanceOf(RechargeProduct::class)
->when(
$products->getOneTime() !== null,
fn(Expectation $expectation) => $expectation
->and($products->getOneTime())->toBeInstanceOf(ProductItem::class),
)
->when(
$products->getRenew() !== null,
fn(Expectation $expectation) => $expectation
->and($products->getRenew())->toBeInstanceOf(ProductItem::class),
)
->and($products->getPlans())->each->toBeInstanceOf(ProductItem::class);
})->only();