mirror of
http://124.126.16.154:8888/singularity/hdk-pay.git
synced 2026-01-15 07:15:06 +08:00
Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e92a6f46a4 | ||
|
|
e0748e444b | ||
|
|
244dd1220a | ||
|
|
8a9971bc59 | ||
|
|
4c5dde9020 | ||
|
|
1cb20a7c7e | ||
|
|
028721feb1 | ||
|
|
bd00102081 | ||
|
|
7763b088df | ||
|
|
cd56a6214b | ||
|
|
31559fdf5d | ||
|
|
41d768ba82 | ||
|
|
c552dd8ed0 | ||
|
|
e7e1c7f6c9 | ||
|
|
7e0d711e99 | ||
|
|
eb44b6e3b6 | ||
|
|
3af39e4254 | ||
|
|
8bbc8ed629 | ||
|
|
48e6fafe8e | ||
|
|
874a6f4fa9 | ||
|
|
8ac850fc62 | ||
|
|
8f8f7b08b0 | ||
|
|
203dd34353 | ||
|
|
87b09ef34c | ||
|
|
a59d979076 | ||
|
|
686d835a91 | ||
|
|
65b060e5d3 | ||
|
|
3b12216344 | ||
|
|
7354abb99a | ||
|
|
93f923181c | ||
|
|
fb3327b252 | ||
|
|
975a5ee301 | ||
|
|
580c2f6ca0 | ||
|
|
15c0ecb6fe | ||
|
|
fb54e19366 | ||
|
|
366f1d64ad | ||
|
|
72f7d37382 | ||
|
|
2a40b3b219 | ||
|
|
86f375b18a | ||
|
|
8a70e35de7 |
134
CHANGELOG.md
134
CHANGELOG.md
@@ -1,4 +1,138 @@
|
||||
# 版本更新日志
|
||||
### [1.11.1](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.11.0...v1.11.1) (2025-11-27)
|
||||
|
||||
## [1.11.0](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.10.0...v1.11.0) (2025-11-27)
|
||||
|
||||
|
||||
### ✨ Features | 新功能
|
||||
|
||||
* **invoice:** 添加发票金额和货币支持 ([244dd12](http://124.126.16.154:8888/singularity/hdk-pay/commit/244dd1220a2c19197ef08f41a82bcb273d0900e8))
|
||||
|
||||
## [1.10.0](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.9.7...v1.10.0) (2025-11-25)
|
||||
|
||||
|
||||
### 🚀 Chore | 构建/工程依赖/工具
|
||||
|
||||
* **deps:** 移除 Carbon 依赖包 ([028721f](http://124.126.16.154:8888/singularity/hdk-pay/commit/028721feb1079eaa4fe80f20066912d46634f3df))
|
||||
|
||||
|
||||
### ✅ Tests | 测试
|
||||
|
||||
* **product:** 移除测试中的 only 标记 ([1cb20a7](http://124.126.16.154:8888/singularity/hdk-pay/commit/1cb20a7c7e2c1a26c7b72669e6885d39f8d16005))
|
||||
|
||||
|
||||
### ✨ Features | 新功能
|
||||
|
||||
* **invoice:** 引入点数价格值对象并更新发票产品结构 ([4c5dde9](http://124.126.16.154:8888/singularity/hdk-pay/commit/4c5dde9020364573d0e9673138620d967149e9f0))
|
||||
|
||||
### [1.9.7](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.9.6...v1.9.7) (2025-10-30)
|
||||
|
||||
|
||||
### ✨ Features | 新功能
|
||||
|
||||
* **account:** 添加4D X无限奖励积分类型 ([7763b08](http://124.126.16.154:8888/singularity/hdk-pay/commit/7763b088dff711f2d95e65ec8437000322931f50))
|
||||
|
||||
### [1.9.6](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.9.5...v1.9.6) (2025-09-19)
|
||||
|
||||
|
||||
### ♻️ Code Refactoring | 代码重构
|
||||
|
||||
* **Domain:** 重构 ExchangeRepoInterface 接口 ([31559fd](http://124.126.16.154:8888/singularity/hdk-pay/commit/31559fdf5ddec048680f520563fa7de56eae3e90))
|
||||
|
||||
### [1.9.5](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.9.4...v1.9.5) (2025-09-19)
|
||||
|
||||
|
||||
### ♻️ Code Refactoring | 代码重构
|
||||
|
||||
* **domain:** 更新汇率接口并添加 UID 参数 ([e7e1c7f](http://124.126.16.154:8888/singularity/hdk-pay/commit/e7e1c7f6c946fa171cdbf8049f1d90864a043685))
|
||||
* **ProductRepo:** 优化 getRate 方法参数处理 ([c552dd8](http://124.126.16.154:8888/singularity/hdk-pay/commit/c552dd8ed0b00f58fefa47c02219ce4de972e85c))
|
||||
|
||||
### [1.9.4](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.9.3...v1.9.4) (2025-09-19)
|
||||
|
||||
|
||||
### 🐛 Bug Fixes | Bug 修复
|
||||
|
||||
* **product:** 修复产品列表中点数显示问题 ([eb44b6e](http://124.126.16.154:8888/singularity/hdk-pay/commit/eb44b6e3b6e9a2e3f757076d0d4438163e7d1f51))
|
||||
|
||||
### [1.9.3](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.9.2...v1.9.3) (2025-09-19)
|
||||
|
||||
|
||||
### ✨ Features | 新功能
|
||||
|
||||
* **PointType:** 添加 ScanToModel 作为点类型 ([8bbc8ed](http://124.126.16.154:8888/singularity/hdk-pay/commit/8bbc8ed629e5c15e42db0adf758505e531ff3dca))
|
||||
|
||||
### [1.9.2](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.9.1...v1.9.2) (2025-09-19)
|
||||
|
||||
|
||||
### ✨ Features | 新功能
|
||||
|
||||
* **Account:** 添加新的积分类型 ([874a6f4](http://124.126.16.154:8888/singularity/hdk-pay/commit/874a6f4fa96b09a4c6c652b6d285d4b6631a3c66))
|
||||
|
||||
### [1.9.1](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.9.0...v1.9.1) (2025-09-17)
|
||||
|
||||
|
||||
### 🐛 Bug Fixes | Bug 修复
|
||||
|
||||
* **account:** 修复初始账户命令和测试 ([8f8f7b0](http://124.126.16.154:8888/singularity/hdk-pay/commit/8f8f7b08b03d9b810bb09ce4b1f15a27cbd43e68))
|
||||
|
||||
## [1.9.0](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.8.2...v1.9.0) (2025-09-17)
|
||||
|
||||
|
||||
### ✨ Features | 新功能
|
||||
|
||||
* **account:** 添加初始化账户余额功能 ([87b09ef](http://124.126.16.154:8888/singularity/hdk-pay/commit/87b09ef34cd3427816ef2c357406a74975ada8a9))
|
||||
|
||||
### [1.8.2](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.8.1...v1.8.2) (2025-09-17)
|
||||
|
||||
|
||||
### 🐛 Bug Fixes | Bug 修复
|
||||
|
||||
* **ProductRepo:** 修复产品仓库中的数组为空的处理逻辑 ([686d835](http://124.126.16.154:8888/singularity/hdk-pay/commit/686d835a9130d60768eef37a3c9a67c6526cb418))
|
||||
|
||||
### [1.8.1](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.8.0...v1.8.1) (2025-09-05)
|
||||
|
||||
|
||||
### ✨ Features | 新功能
|
||||
|
||||
* **PointLog:** 添加获取病人姓名的方法并更新相关代码 ([3b12216](http://124.126.16.154:8888/singularity/hdk-pay/commit/3b1221634419f0ca39359e36c0363602b075b9b8))
|
||||
|
||||
## [1.8.0](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.7.0...v1.8.0) (2025-09-05)
|
||||
|
||||
|
||||
### ✨ Features | 新功能
|
||||
|
||||
* **invoice:** 添加发票详情查询功能 ([93f9231](http://124.126.16.154:8888/singularity/hdk-pay/commit/93f923181c41ce7e96077f304efe6e980231f1f6))
|
||||
|
||||
## [1.7.0](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.6.1...v1.7.0) (2025-09-04)
|
||||
|
||||
|
||||
### ✨ Features | 新功能
|
||||
|
||||
* **account:** 增加积分日志详情查询功能并支持发票信息 ([975a5ee](http://124.126.16.154:8888/singularity/hdk-pay/commit/975a5ee30110f27ceba0ef11fba751639189d57b))
|
||||
|
||||
### [1.6.1](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.6.0...v1.6.1) (2025-09-04)
|
||||
|
||||
|
||||
### ✨ Features | 新功能
|
||||
|
||||
* **invoice:** 添加发票下载和发送功能 ([15c0ecb](http://124.126.16.154:8888/singularity/hdk-pay/commit/15c0ecb6fe8f227b09c4d4618ffb2f5560e4b261))
|
||||
|
||||
## [1.6.0](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.5.3...v1.6.0) (2025-09-04)
|
||||
|
||||
|
||||
### ✨ Features | 新功能
|
||||
|
||||
* **invoice:** 添加发票下载功能并优化测试 ([366f1d6](http://124.126.16.154:8888/singularity/hdk-pay/commit/366f1d64add68d1bb8a9b3e5f17b23963a91d3bc))
|
||||
* **invoice:** 添加发票发送功能并进行测试 ([72f7d37](http://124.126.16.154:8888/singularity/hdk-pay/commit/72f7d37382752047ed4c15809f16c3f1d07e16e0))
|
||||
|
||||
### [1.5.3](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.5.2...v1.5.3) (2025-09-04)
|
||||
|
||||
|
||||
### ♻️ Code Refactoring | 代码重构
|
||||
|
||||
* **invoice:** 重构发票创建流程和积分日志接口 ([8a70e35](http://124.126.16.154:8888/singularity/hdk-pay/commit/8a70e35de72d269bbbd0b5e05c3fa4bccdf1878c))
|
||||
* **PointLogRepo:** 优化 getList 方法参数类型 ([86f375b](http://124.126.16.154:8888/singularity/hdk-pay/commit/86f375b18a0c3213e405b6fcaec20224979dd991))
|
||||
|
||||
### [1.5.2](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.5.1...v1.5.2) (2025-09-02)
|
||||
|
||||
|
||||
|
||||
@@ -36,8 +36,7 @@
|
||||
"firebase/php-jwt": "^6.8.0",
|
||||
"hyperf/testing": "^3.1",
|
||||
"friendsofhyperf/pest-plugin-hyperf": "3.1.*",
|
||||
"swoole/ide-helper": "^4.8.13",
|
||||
"nesbot/carbon": "^2.0"
|
||||
"swoole/ide-helper": "^4.8.13"
|
||||
},
|
||||
"minimum-stability": "beta",
|
||||
"prefer-stable": true,
|
||||
@@ -70,5 +69,5 @@
|
||||
"url": "https://mirrors.aliyun.com/composer/"
|
||||
}
|
||||
},
|
||||
"version": "1.5.2"
|
||||
"version": "1.11.1"
|
||||
}
|
||||
|
||||
987
composer.lock
generated
987
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -11,17 +11,21 @@ declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Application\Command;
|
||||
|
||||
final readonly class CreateInvoiceCmd {
|
||||
use Money\Money;
|
||||
|
||||
final readonly class CreateInvoiceCmd
|
||||
{
|
||||
public function __construct(
|
||||
public string $uid,
|
||||
public string $caseId,
|
||||
public bool $setFreqInvAddr,
|
||||
public string $receiver,
|
||||
public string $patientName,
|
||||
public string $address,
|
||||
public string $city,
|
||||
public string $state,
|
||||
public string $country,
|
||||
public string $zipCode,
|
||||
public string $caseId,
|
||||
public bool $setFreqInvAddr,
|
||||
public string $receiver,
|
||||
public string $patientName,
|
||||
public string $address,
|
||||
public string $city,
|
||||
public string $state,
|
||||
public string $country,
|
||||
public string $zipCode,
|
||||
public Money $price,
|
||||
public string $currencySymbol,
|
||||
) {}
|
||||
}
|
||||
40
src/Application/Command/InitialAccountCmd.php
Normal file
40
src/Application/Command/InitialAccountCmd.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* InitialAccountCmd.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/9/17
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Application\Command;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Singularity\HDK\Pay\Domain\Account\Enum\PointType;
|
||||
|
||||
final class InitialAccountCmd
|
||||
{
|
||||
public array $pointsBalances;
|
||||
|
||||
public function __construct(
|
||||
public readonly string $uid,
|
||||
) {}
|
||||
|
||||
public function addPointsBalance(
|
||||
PointType $type,
|
||||
float $basic = 0.0,
|
||||
float $bonus = 0.0,
|
||||
?Carbon $expiredAt = null,
|
||||
?string $version = null,
|
||||
): array {
|
||||
return $this->pointsBalances[] = [
|
||||
'type' => $type->value,
|
||||
'basic' => $basic,
|
||||
'bonus' => $bonus,
|
||||
'expired_at' => $expiredAt->toDateTimeString(),
|
||||
'version' => $version,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -54,17 +54,19 @@ final class RechargeProductsDto extends AbstractDto
|
||||
if (!$is_ftai) {
|
||||
$result += [
|
||||
'total_points' => $effect->getPointTotal(),
|
||||
'bonus_rate_pct' => (float)(bcmul(
|
||||
num1: $effect->getPointTotal() == 0
|
||||
? '0'
|
||||
: bcdiv(
|
||||
(string)$effect->pointBonus,
|
||||
(string)$effect->getPointTotal(),
|
||||
3,
|
||||
),
|
||||
num2: '100',
|
||||
scale: 0,
|
||||
)),
|
||||
'bonus_rate_pct' => round(
|
||||
(float)(bcmul(
|
||||
num1: $effect->getPointTotal() == 0
|
||||
? '0'
|
||||
: bcdiv(
|
||||
(string)$effect->pointBonus,
|
||||
(string)$effect->getPointTotal(),
|
||||
3,
|
||||
),
|
||||
num2: '100',
|
||||
scale: 3,
|
||||
)),
|
||||
),
|
||||
'point' => [
|
||||
'total' => $effect->getPointTotal(),
|
||||
'number' => $effect->pointBasic,
|
||||
|
||||
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Singularity\HDK\Pay\Domain\Account\Aggregate\PointLog;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Singularity\HDK\Pay\Domain\Account\Aggregate\PointLog\ValueObject\InvoiceRecord;
|
||||
use Singularity\HDK\Pay\Domain\AggregateRoot;
|
||||
|
||||
final class PointLog extends AggregateRoot
|
||||
@@ -24,9 +25,17 @@ final class PointLog extends AggregateRoot
|
||||
private readonly string $source,
|
||||
private readonly string $operator,
|
||||
private readonly string $description,
|
||||
private readonly string $patientName,
|
||||
private readonly Carbon $date,
|
||||
private readonly bool $invoiceable,
|
||||
private readonly ?InvoiceRecord $invoiceRecord,
|
||||
) {}
|
||||
|
||||
public function getPatientName(): string
|
||||
{
|
||||
return $this->patientName;
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
@@ -67,4 +76,19 @@ final class PointLog extends AggregateRoot
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getInvoiceNo(): ?string
|
||||
{
|
||||
return $this->invoiceRecord?->invoiceNo;
|
||||
}
|
||||
|
||||
public function getInvoiceReceiver(): ?string
|
||||
{
|
||||
return $this->invoiceRecord?->receiver;
|
||||
}
|
||||
|
||||
public function getInvoiceable(): bool
|
||||
{
|
||||
return $this->invoiceable;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* InvoiceRecord.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/9/4
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Account\Aggregate\PointLog\ValueObject;
|
||||
|
||||
final class InvoiceRecord
|
||||
{
|
||||
public function __construct(
|
||||
public string $invoiceNo,
|
||||
public string $receiver,
|
||||
) {}
|
||||
}
|
||||
@@ -21,6 +21,10 @@ enum PointType: string
|
||||
case Aligner4D = 'aligner-4d';
|
||||
case NightguardAi = 'nightguard-ai';
|
||||
|
||||
case ScanToModel = 'scan-to-model';
|
||||
|
||||
case FourDXUnlimitedBonusCredits = 'aligner-4d-u';
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return [
|
||||
@@ -30,6 +34,8 @@ enum PointType: string
|
||||
self::FtaiRetainer->value,
|
||||
self::Aligner4D->value,
|
||||
self::NightguardAi->value,
|
||||
self::ScanToModel->value,
|
||||
self::FourDXUnlimitedBonusCredits->value,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,29 @@ declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Account\Repository;
|
||||
|
||||
use Singularity\HDK\Pay\Application\Command\InitialAccountCmd;
|
||||
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
|
||||
{
|
||||
/**
|
||||
* @param string $uid
|
||||
* @return AccountBalance
|
||||
*/
|
||||
public function getAccount(string $uid): AccountBalance;
|
||||
|
||||
/**
|
||||
* @param string $uid
|
||||
* @param PointType $pointType
|
||||
* @return PointsBalance
|
||||
*/
|
||||
public function getPointBalance(string $uid, PointType $pointType): PointsBalance;
|
||||
|
||||
/**
|
||||
* @param InitialAccountCmd $cmd
|
||||
* @return void
|
||||
*/
|
||||
public function initial(InitialAccountCmd $cmd): void;
|
||||
}
|
||||
@@ -19,4 +19,9 @@ interface PointLogRepoInterface
|
||||
*/
|
||||
public function getList(string $uid): array;
|
||||
|
||||
/**
|
||||
* @param string $caseId
|
||||
* @return PointLog
|
||||
*/
|
||||
public function getDetail(string $caseId): PointLog;
|
||||
}
|
||||
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice;
|
||||
|
||||
use Money\Money;
|
||||
use Singularity\HDK\Pay\Domain\AggregateRoot;
|
||||
|
||||
final class Invoice extends AggregateRoot
|
||||
@@ -22,8 +23,25 @@ final class Invoice extends AggregateRoot
|
||||
private readonly Address $address,
|
||||
private readonly bool $setFreqInvAddr,
|
||||
private readonly string $receiver,
|
||||
private readonly Money $price,
|
||||
private readonly string $currencySymbol,
|
||||
) {}
|
||||
|
||||
public function getAmount(): float
|
||||
{
|
||||
return (float)bcdiv($this->price->getAmount(), '100', 2);
|
||||
}
|
||||
|
||||
public function getCurrencyCode(): string
|
||||
{
|
||||
return $this->price->getCurrency()->getCode();
|
||||
}
|
||||
|
||||
public function getCurrencySymbol(): string
|
||||
{
|
||||
return $this->currencySymbol;
|
||||
}
|
||||
|
||||
public function getInvoiceNo(): string
|
||||
{
|
||||
return $this->invoiceNo;
|
||||
|
||||
81
src/Domain/Invoice/Aggregate/Invoice/InvoiceInfo.php
Normal file
81
src/Domain/Invoice/Aggregate/Invoice/InvoiceInfo.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* InvoiceInfo.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/9/5
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice\ValueObject\PointBalance;
|
||||
|
||||
final readonly class InvoiceInfo
|
||||
{
|
||||
public function __construct(
|
||||
private string $invoiceNo,
|
||||
private string $uid,
|
||||
private string $caseId,
|
||||
private Address $address,
|
||||
private InvoiceProduct $product,
|
||||
private PointBalance $balance,
|
||||
private string $receiver,
|
||||
private Carbon $invoiceAt,
|
||||
private Carbon $designedAt,
|
||||
private string $patientName,
|
||||
) {}
|
||||
|
||||
public function getInvoiceNo(): string
|
||||
{
|
||||
return $this->invoiceNo;
|
||||
}
|
||||
|
||||
public function getUid(): string
|
||||
{
|
||||
return $this->uid;
|
||||
}
|
||||
|
||||
public function getCaseId(): string
|
||||
{
|
||||
return $this->caseId;
|
||||
}
|
||||
|
||||
public function getAddress(): Address
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
public function getProduct(): InvoiceProduct
|
||||
{
|
||||
return $this->product;
|
||||
}
|
||||
|
||||
public function getBalance(): PointBalance
|
||||
{
|
||||
return $this->balance;
|
||||
}
|
||||
|
||||
public function getReceiver(): string
|
||||
{
|
||||
return $this->receiver;
|
||||
}
|
||||
|
||||
public function getInvoiceAt(): Carbon
|
||||
{
|
||||
return $this->invoiceAt;
|
||||
}
|
||||
|
||||
public function getDesignedAt(): Carbon
|
||||
{
|
||||
return $this->designedAt;
|
||||
}
|
||||
|
||||
public function getPatientName(): string
|
||||
{
|
||||
return $this->patientName;
|
||||
}
|
||||
}
|
||||
@@ -11,12 +11,23 @@ declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice;
|
||||
|
||||
use Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice\ValueObject\PointPrice;
|
||||
|
||||
final readonly class InvoiceProduct {
|
||||
/**
|
||||
* @param string $caseId
|
||||
* @param string $uid
|
||||
* @param string $name
|
||||
* @param string $sku
|
||||
* @param string $description
|
||||
* @param PointPrice[] $prices
|
||||
*/
|
||||
public function __construct(
|
||||
public string $caseId,
|
||||
public string $uid,
|
||||
public string $name,
|
||||
public string $sku,
|
||||
public string $description,
|
||||
public array $prices,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PointBalance.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/9/5
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice\ValueObject;
|
||||
|
||||
final readonly class PointBalance {
|
||||
public function __construct(
|
||||
public float $total,
|
||||
public float $cost,
|
||||
public float $remain,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PointPrice.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/11/25
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice\ValueObject;
|
||||
|
||||
use Money\Money;
|
||||
use Singularity\HDK\Pay\Domain\Account\Enum\PointType;
|
||||
|
||||
final readonly class PointPrice
|
||||
{
|
||||
public function __construct(
|
||||
public Money $price,
|
||||
public string $currencySymbol,
|
||||
) {}
|
||||
}
|
||||
@@ -9,14 +9,38 @@
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Invoice\Repository;
|
||||
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Singularity\HDK\Pay\Application\Command\CreateInvoiceCmd;
|
||||
use Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice\Invoice;
|
||||
use Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice\InvoiceInfo;
|
||||
|
||||
interface InvoiceRepoInterface
|
||||
{
|
||||
/**
|
||||
* @param CreateInvoiceCmd $cmd
|
||||
* @return Invoice
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function create(CreateInvoiceCmd $cmd): Invoice;
|
||||
|
||||
/**
|
||||
* @param string $invoiceNo
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function download(string $invoiceNo): ResponseInterface;
|
||||
|
||||
/**
|
||||
* @param string $invoiceNo
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function send(string $invoiceNo): void;
|
||||
|
||||
/**
|
||||
* @param string $invoiceNo
|
||||
* @return InvoiceInfo
|
||||
*/
|
||||
public function findOne(string $invoiceNo): InvoiceInfo;
|
||||
}
|
||||
@@ -16,7 +16,8 @@ interface ExchangeRepoInterface
|
||||
/**
|
||||
* @param PointType $source
|
||||
* @param PointType $target
|
||||
* @param string|null $uid
|
||||
* @return float
|
||||
*/
|
||||
public function getRate(PointType $source, PointType $target): float;
|
||||
public function getRate(PointType $source, PointType $target, ?string $uid = null): float;
|
||||
}
|
||||
@@ -13,6 +13,7 @@ namespace Singularity\HDK\Pay\Infrastructure\Repository;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Codec\Json;
|
||||
use Singularity\HDK\Pay\Application\Command\InitialAccountCmd;
|
||||
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;
|
||||
@@ -67,4 +68,17 @@ final class AccountBalanceRepo extends AbstractRepo implements AccountRepoInterf
|
||||
expiredAt: isset($result['expired_at']) ? new Carbon($result['expired_at']): null,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function initial(InitialAccountCmd $cmd): void
|
||||
{
|
||||
$uid = $cmd->uid;
|
||||
|
||||
$this->requestService->requestPost(
|
||||
url: "/rpc/v2/account/$uid/balance",
|
||||
data: $cmd->pointsBalances
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,10 @@ declare(strict_types=1);
|
||||
namespace Singularity\HDK\Pay\Infrastructure\Repository;
|
||||
|
||||
use Hyperf\Codec\Json;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice\InvoiceProduct;
|
||||
use Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice\ValueObject\PointPrice;
|
||||
use Singularity\HDK\Pay\Domain\Invoice\Repository\InvoiceProductRepoInterface;
|
||||
|
||||
final class InvoiceProductRepo extends AbstractRepo implements InvoiceProductRepoInterface
|
||||
@@ -33,6 +36,16 @@ final class InvoiceProductRepo extends AbstractRepo implements InvoiceProductRep
|
||||
name: $result['name'],
|
||||
sku: $result['sku'],
|
||||
description: $result['description'],
|
||||
prices: array_map(
|
||||
callback: fn(array $price) => new PointPrice(
|
||||
price: new Money(
|
||||
amount: bcmul((string)$price['amount'], '100', 2),
|
||||
currency: new Currency($price['currency']),
|
||||
),
|
||||
currencySymbol: $price['symbol'],
|
||||
),
|
||||
array: $result['prices'],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -11,18 +11,30 @@ declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Infrastructure\Repository;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Codec\Json;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Singularity\HDK\Core\Exceptions\ValidateException;
|
||||
use Singularity\HDK\Pay\Application\Command\CreateInvoiceCmd;
|
||||
use Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice\Address;
|
||||
use Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice\Invoice;
|
||||
use Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice\InvoiceInfo;
|
||||
use Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice\InvoiceProduct;
|
||||
use Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice\ValueObject\PointBalance;
|
||||
use Singularity\HDK\Pay\Domain\Invoice\Repository\InvoiceRepoInterface;
|
||||
|
||||
final class InvoiceRepo extends AbstractRepo implements InvoiceRepoInterface
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function create(CreateInvoiceCmd $cmd): Invoice
|
||||
{
|
||||
$money = $cmd->price;
|
||||
$response = $this->requestService->requestPost(
|
||||
url: "/rpc/v2/account/$cmd->uid/logs/points/$cmd->caseId/invoices",
|
||||
url: "/rpc/v2/account/logs/points/$cmd->caseId/invoices",
|
||||
data: [
|
||||
'set_freq_addr' => $cmd->setFreqInvAddr,
|
||||
'receiver' => $cmd->receiver,
|
||||
@@ -32,12 +44,20 @@ final class InvoiceRepo extends AbstractRepo implements InvoiceRepoInterface
|
||||
'state' => $cmd->state,
|
||||
'country' => $cmd->country,
|
||||
'zip' => $cmd->zipCode,
|
||||
'price' => [
|
||||
'amount' => (float)bcmul($money->getAmount(), '100', 2),
|
||||
'currency' => [
|
||||
'code' => $money->getCurrency()->getCode(),
|
||||
'symbol' => $cmd->currencySymbol,
|
||||
],
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
$content = $response->getBody()->getContents();
|
||||
$result = Json::decode($content);
|
||||
|
||||
$price = $result['price'];
|
||||
return new Invoice(
|
||||
invoiceNo: $result['invoice_no'],
|
||||
uid: $result['uid'],
|
||||
@@ -52,6 +72,78 @@ final class InvoiceRepo extends AbstractRepo implements InvoiceRepoInterface
|
||||
),
|
||||
setFreqInvAddr: $result['set_freq_addr'],
|
||||
receiver: $result['receiver'],
|
||||
price: new Money(
|
||||
bcmul((string)$price['amount'], '100', 2),
|
||||
new Currency($price['code']),
|
||||
),
|
||||
currencySymbol: $price['symbol'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function send(string $invoiceNo): void
|
||||
{
|
||||
if (empty($invoiceNo)) {
|
||||
throw new ValidateException(message: 'invoice no is required.');
|
||||
}
|
||||
$this->requestService->requestGet(url: "/rpc/v2/invoice/invoices/$invoiceNo/email");
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function download(string $invoiceNo): ResponseInterface
|
||||
{
|
||||
if (empty($invoiceNo)) {
|
||||
throw new ValidateException(message: 'invoice no is required.');
|
||||
}
|
||||
|
||||
return $this->requestService->requestGet(url: "/rpc/v2/invoice/invoices/$invoiceNo/pdf");
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function findOne(string $invoiceNo): InvoiceInfo
|
||||
{
|
||||
if (empty($invoiceNo)) {
|
||||
throw new ValidateException(message: 'invoice no is required.');
|
||||
}
|
||||
|
||||
$response = $this->requestService->requestGet(url: "/rpc/v2/invoice/invoices/$invoiceNo");
|
||||
$content = $response->getBody()->getContents();
|
||||
$result = Json::decode($content);
|
||||
|
||||
return new InvoiceInfo(
|
||||
invoiceNo: $result['invoice_no'],
|
||||
uid: $result['uid'],
|
||||
caseId: $result['case_id'],
|
||||
address: new Address(
|
||||
patientName: $result['patient_name'],
|
||||
address: $result['address']['address'],
|
||||
city: $result['address']['city'],
|
||||
state: $result['address']['state'],
|
||||
country: $result['address']['country'],
|
||||
zipCode: $result['address']['zip_code'],
|
||||
),
|
||||
product: new InvoiceProduct(
|
||||
caseId: $result['case_id'],
|
||||
uid: $result['uid'],
|
||||
name: $result['product']['name'],
|
||||
sku: $result['product']['sku'],
|
||||
description: $result['product']['description'],
|
||||
),
|
||||
balance: new PointBalance(
|
||||
total: $result['balance']['total'],
|
||||
cost: $result['balance']['cost'],
|
||||
remain: $result['balance']['remain'],
|
||||
),
|
||||
receiver: $result['receiver'],
|
||||
invoiceAt: new Carbon($result['invoice_at']),
|
||||
designedAt: new Carbon($result['designed_at']),
|
||||
patientName: $result['patient_name'],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -12,15 +12,25 @@ declare(strict_types=1);
|
||||
namespace Singularity\HDK\Pay\Infrastructure\Repository;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Hyperf\Codec\Json;
|
||||
use Singularity\HDK\Pay\Domain\Account\Aggregate\PointLog\PointLog;
|
||||
use Singularity\HDK\Pay\Domain\Account\Aggregate\PointLog\ValueObject\InvoiceRecord;
|
||||
use Singularity\HDK\Pay\Domain\Account\Enum\PointType;
|
||||
use Singularity\HDK\Pay\Domain\Account\Repository\PointLogRepoInterface;
|
||||
|
||||
final class PointLogRepo extends AbstractRepo implements PointLogRepoInterface
|
||||
{
|
||||
public function getList(string $uid): array
|
||||
/**
|
||||
* @param string $uid
|
||||
* @param PointType|null $type
|
||||
* @return array{}|PointLog[]
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getList(string $uid, ?PointType $type = null): array
|
||||
{
|
||||
$response = $this->requestService->requestGet(url: "/rpc/v2/account/$uid/logs/points");
|
||||
$type = isset($type) ? $type->value : 'all';
|
||||
$response = $this->requestService->requestGet(url: "/rpc/v2/account/$uid/balance/$type/logs");
|
||||
|
||||
$content = $response->getBody()->getContents();
|
||||
$result = Json::decode($content);
|
||||
@@ -34,8 +44,46 @@ final class PointLogRepo extends AbstractRepo implements PointLogRepoInterface
|
||||
source: $item['source'],
|
||||
operator: $item['operator'],
|
||||
description: $item['description'],
|
||||
patientName: $item['patient_name'],
|
||||
date: new Carbon($item['date']),
|
||||
invoiceable: $item['invoiceable'],
|
||||
invoiceRecord: isset($item['invoice_record'])
|
||||
? new InvoiceRecord(
|
||||
invoiceNo: $item['invoice_record']['invoice_no'],
|
||||
receiver: $item['invoice_record']['receiver'],
|
||||
)
|
||||
: null,
|
||||
);
|
||||
}, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDetail(string $caseId): PointLog
|
||||
{
|
||||
$response = $this->requestService->requestGet(url: "/rpc/v2/account/logs/points/$caseId");
|
||||
|
||||
$content = $response->getBody()->getContents();
|
||||
$result = Json::decode($content);
|
||||
|
||||
return new PointLog(
|
||||
id: $result['id'],
|
||||
caseId: $result['case_id'],
|
||||
uid: $result['uid'],
|
||||
credits: $result['credits'],
|
||||
source: $result['source'],
|
||||
operator: $result['operator'],
|
||||
description: $result['description'],
|
||||
patientName: $result['patient_name'],
|
||||
date: new Carbon($result['date']),
|
||||
invoiceable: $result['invoiceable'],
|
||||
invoiceRecord: isset($result['invoice_record'])
|
||||
? new InvoiceRecord(
|
||||
$result['invoice_record']['invoice_no'],
|
||||
$result['invoice_record']['receiver'],
|
||||
)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ final class ProductRepo extends AbstractRepo implements RechargeProductRepoInter
|
||||
id: $result['one_time']['id'],
|
||||
description: $result['one_time']['name'],
|
||||
unitPrice: new Money(
|
||||
amount:bcmul((string)$result['one_time']['price'], '100'),
|
||||
amount: bcmul((string)$result['one_time']['price'], '100'),
|
||||
currency: new Currency($result['one_time']['currency']),
|
||||
),
|
||||
productType: ProductType::oneTime,
|
||||
@@ -55,20 +55,23 @@ final class ProductRepo extends AbstractRepo implements RechargeProductRepoInter
|
||||
pointBonus: $result['one_time']['point']['bonus'],
|
||||
),
|
||||
),
|
||||
packages: array_map(fn(array $item) => new ProductItem(
|
||||
id: $item['id'],
|
||||
description: $item['name'],
|
||||
unitPrice: new Money(
|
||||
amount: bcmul((string)$item['price'], '100'),
|
||||
currency: new Currency($item['currency']),
|
||||
packages: array_map(
|
||||
fn(array $item) => new ProductItem(
|
||||
id: $item['id'],
|
||||
description: $item['name'],
|
||||
unitPrice: new Money(
|
||||
amount: bcmul((string)$item['price'], '100'),
|
||||
currency: new Currency($item['currency']),
|
||||
),
|
||||
productType: ProductType::pack,
|
||||
effect: new RechargeEffect(
|
||||
pointType: PointType::LuxPoint,
|
||||
pointBasic: $item['point']['number'],
|
||||
pointBonus: $item['point']['bonus'],
|
||||
),
|
||||
),
|
||||
productType: ProductType::pack,
|
||||
effect: new RechargeEffect(
|
||||
pointType: PointType::LuxPoint,
|
||||
pointBasic: $item['point']['number'],
|
||||
pointBonus: $item['point']['bonus'],
|
||||
),
|
||||
), $result['package']),
|
||||
$result['package'] ?? [],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -99,29 +102,35 @@ final class ProductRepo extends AbstractRepo implements RechargeProductRepoInter
|
||||
),
|
||||
)
|
||||
: null,
|
||||
plans: array_map(fn(array $item) => new ProductItem(
|
||||
id: $item['id'],
|
||||
description: $item['name'],
|
||||
unitPrice: new Money(
|
||||
amount: bcmul((string)$item['price'], '100'),
|
||||
currency: new Currency($item['currency']),
|
||||
plans: array_map(
|
||||
fn(array $item) => new ProductItem(
|
||||
id: $item['id'],
|
||||
description: $item['name'],
|
||||
unitPrice: new Money(
|
||||
amount: bcmul((string)$item['price'], '100'),
|
||||
currency: new Currency($item['currency']),
|
||||
),
|
||||
productType: ProductType::plan,
|
||||
),
|
||||
productType: ProductType::plan,
|
||||
), $result['plan']),
|
||||
packages: array_map(fn(array $item) => new ProductItem(
|
||||
id: $item['id'],
|
||||
description: $item['name'],
|
||||
unitPrice: new Money(
|
||||
amount: bcmul((string)$item['price'], '100'),
|
||||
currency: new Currency($item['currency']),
|
||||
$result['plan'] ?? [],
|
||||
),
|
||||
packages: array_map(
|
||||
fn(array $item) => new ProductItem(
|
||||
id: $item['id'],
|
||||
description: $item['name'],
|
||||
unitPrice: new Money(
|
||||
amount: bcmul((string)$item['price'], '100'),
|
||||
currency: new Currency($item['currency']),
|
||||
),
|
||||
productType: ProductType::plan,
|
||||
effect: new RechargeEffect(
|
||||
pointType: $pointType,
|
||||
pointBasic: $item['point']['number'],
|
||||
pointBonus: $item['point']['bonus'],
|
||||
),
|
||||
),
|
||||
productType: ProductType::plan,
|
||||
effect: new RechargeEffect(
|
||||
pointType: $pointType,
|
||||
pointBasic: $item['point']['number'],
|
||||
pointBonus: $item['point']['bonus'],
|
||||
),
|
||||
), $result['package']),
|
||||
$result['package'] ?? [],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -144,7 +153,7 @@ final class ProductRepo extends AbstractRepo implements RechargeProductRepoInter
|
||||
id: $result['one_time']['id'],
|
||||
description: $result['one_time']['name'],
|
||||
unitPrice: new Money(
|
||||
amount:bcmul((string)$result['one_time']['price'], '100'),
|
||||
amount: bcmul((string)$result['one_time']['price'], '100'),
|
||||
currency: new Currency($result['one_time']['currency']),
|
||||
),
|
||||
productType: ProductType::oneTime,
|
||||
@@ -171,20 +180,23 @@ final class ProductRepo extends AbstractRepo implements RechargeProductRepoInter
|
||||
),
|
||||
)
|
||||
: null,
|
||||
plans: array_map(fn(array $item) => new ProductItem(
|
||||
id: $item['id'],
|
||||
description: $item['name'],
|
||||
unitPrice: new Money(
|
||||
amount: bcmul((string)$item['price'], '100'),
|
||||
currency: new Currency($item['currency']),
|
||||
plans: array_map(
|
||||
fn(array $item) => new ProductItem(
|
||||
id: $item['id'],
|
||||
description: $item['name'],
|
||||
unitPrice: new Money(
|
||||
amount: bcmul((string)$item['price'], '100'),
|
||||
currency: new Currency($item['currency']),
|
||||
),
|
||||
productType: ProductType::plan,
|
||||
effect: new RechargeEffect(
|
||||
pointType: PointType::EMA,
|
||||
pointBasic: $item['point']['number'],
|
||||
pointBonus: $item['point']['bonus'],
|
||||
),
|
||||
),
|
||||
productType: ProductType::plan,
|
||||
effect: new RechargeEffect(
|
||||
pointType: PointType::EMA,
|
||||
pointBasic: $item['point']['number'],
|
||||
pointBonus: $item['point']['bonus'],
|
||||
),
|
||||
), $result['plan']),
|
||||
$result['plan'] ?? [],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -194,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 = null): float
|
||||
{
|
||||
$response = $this->requestService->requestGet(
|
||||
url: "/rpc/v2/products/$target->value/exchange-rate/$source->value",
|
||||
params: array_filter(['uid' => $uid]),
|
||||
);
|
||||
|
||||
$content = $response->getBody()->getContents();
|
||||
|
||||
53
tests/Feature/Account/InitialAccountBalanceTest.php
Normal file
53
tests/Feature/Account/InitialAccountBalanceTest.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* InitialAccountBalanceTest.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/9/17
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Singularity\HDK\Pay\Application\Command\InitialAccountCmd;
|
||||
use Singularity\HDK\Pay\Domain\Account\Enum\PointType;
|
||||
|
||||
use Singularity\HDK\Pay\Infrastructure\Repository\AccountBalanceRepo;
|
||||
|
||||
use function Hyperf\Support\make;
|
||||
|
||||
it('should initial account balance', function () {
|
||||
$uid = uniqid('TDD');
|
||||
$data = [
|
||||
[
|
||||
'type' => 'aligner',
|
||||
'basic' => 0,
|
||||
'bonus' => 40,
|
||||
'expired_at' => Carbon::now()->addYear(),
|
||||
'version' => 'trial',
|
||||
],
|
||||
[
|
||||
'type' => 'ema',
|
||||
'basic' => 0,
|
||||
'bonus' => 1,
|
||||
'expired_at' => Carbon::now()->addYear(),
|
||||
'version' => 'Trial',
|
||||
],
|
||||
];
|
||||
|
||||
$cmd = new InitialAccountCmd($uid);
|
||||
foreach ($data as $point_balance) {
|
||||
$cmd->addPointsBalance(
|
||||
type: PointType::from($point_balance['type']),
|
||||
basic: $point_balance['basic'],
|
||||
bonus: $point_balance['bonus'],
|
||||
expiredAt:$point_balance['expired_at'],
|
||||
version: $point_balance['version'],
|
||||
);
|
||||
}
|
||||
|
||||
$repo = make(AccountBalanceRepo::class);
|
||||
$repo->initial($cmd);
|
||||
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* QueryPointLogListTest.php@Pay
|
||||
* QueryPointLogTest.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
@@ -23,3 +23,12 @@ it('should can query point log list', function () {
|
||||
->each
|
||||
->toBeInstanceOf(PointLog::class);
|
||||
});
|
||||
|
||||
it('should can query a point log', function () {
|
||||
$case_id = '68b6ac37a6440';
|
||||
|
||||
$repo = make(PointLogRepo::class);
|
||||
$log = $repo->getDetail($case_id);
|
||||
expect($log)
|
||||
->toBeInstanceOf(PointLog::class);
|
||||
});
|
||||
@@ -8,6 +8,8 @@
|
||||
* Created on 2025/8/29
|
||||
*/
|
||||
|
||||
use Money\Money;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Singularity\HDK\Pay\Application\Command\CreateInvoiceCmd;
|
||||
use Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice\Invoice;
|
||||
use Singularity\HDK\Pay\Infrastructure\Repository\InvoiceRepo;
|
||||
@@ -19,7 +21,6 @@ it('should can create invoice', function () {
|
||||
|
||||
$invoice = $repo->create(
|
||||
new CreateInvoiceCmd(
|
||||
uid: '61dbe752d4caa',
|
||||
caseId: '68affb136c01d',
|
||||
setFreqInvAddr: true,
|
||||
receiver: "dongyun.li@luxcreo.ai",
|
||||
@@ -29,9 +30,32 @@ it('should can create invoice', function () {
|
||||
state: "Illinois",
|
||||
country: "United States",
|
||||
zipCode: "67890-1234",
|
||||
price: Money::EUR('19900'),
|
||||
currencySymbol: '€'
|
||||
),
|
||||
);
|
||||
|
||||
expect($invoice)
|
||||
->toBeInstanceOf(Invoice::class);
|
||||
});
|
||||
|
||||
it('should can send invoice email to receiver', function () {
|
||||
$repo = make(InvoiceRepo::class);
|
||||
|
||||
expect(
|
||||
(function () use ($repo) {
|
||||
$invoice_no = '517268';
|
||||
$repo->send($invoice_no);
|
||||
|
||||
return true;
|
||||
})(),
|
||||
)->not->toThrow(Throwable::class);
|
||||
});
|
||||
|
||||
it('should can download invoice pdf', function () {
|
||||
$repo = make(InvoiceRepo::class);
|
||||
|
||||
$invoice_no = '517268';
|
||||
$response = $repo->download($invoice_no);
|
||||
expect($response)->toBeInstanceOf(ResponseInterface::class);
|
||||
});
|
||||
|
||||
@@ -10,16 +10,20 @@
|
||||
|
||||
|
||||
use Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice\InvoiceProduct;
|
||||
use Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice\ValueObject\PointPrice;
|
||||
use Singularity\HDK\Pay\Infrastructure\Repository\InvoiceProductRepo;
|
||||
|
||||
use function Hyperf\Support\make;
|
||||
|
||||
it('should can query case invoice product', function () {
|
||||
/** @var InvoiceProductRepo $invoiceProductRepo */
|
||||
$invoiceProductRepo = make(InvoiceProductRepo::class);
|
||||
|
||||
$caseId = '68affb136c01d';
|
||||
|
||||
$result = $invoiceProductRepo->getCaseProduct(caseId: $caseId);
|
||||
|
||||
expect($result)->toBeInstanceOf(InvoiceProduct::class);
|
||||
expect($result)->toBeInstanceOf(InvoiceProduct::class)
|
||||
->prices->toBeArray()
|
||||
->each->toBeInstanceOf(PointPrice::class);
|
||||
});
|
||||
|
||||
23
tests/Feature/Invoice/QueryInvoiceDetailTest.php
Normal file
23
tests/Feature/Invoice/QueryInvoiceDetailTest.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* QueryInvoiceDetailTest.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/9/5
|
||||
*/
|
||||
|
||||
use Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice\InvoiceInfo;
|
||||
use Singularity\HDK\Pay\Infrastructure\Repository\InvoiceRepo;
|
||||
|
||||
use function Hyperf\Support\make;
|
||||
|
||||
it('should can query invoice detail', function () {
|
||||
$repo = make(InvoiceRepo::class);
|
||||
|
||||
$invoiceNo = '517268';
|
||||
$result = $repo->findOne($invoiceNo);
|
||||
expect($result)
|
||||
->toBeInstanceOf(InvoiceInfo::class);
|
||||
});
|
||||
@@ -19,6 +19,20 @@ 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();
|
||||
});
|
||||
|
||||
it('can query point rate with uid', function () {
|
||||
$repo = make(ProductRepo::class);
|
||||
|
||||
$from = PointType::FtaiAligner;
|
||||
$to = PointType::LuxPoint;
|
||||
|
||||
$uid = 'cn3321';
|
||||
|
||||
$rate = $repo->getRate($from, $to, $uid);
|
||||
expect($rate)->toBeFloat();
|
||||
});
|
||||
|
||||
@@ -29,7 +29,7 @@ test('能够正常创建 Stripe 订单', function () {
|
||||
service: 1
|
||||
);
|
||||
expect($order)->toBeInstanceOf(Order::class);
|
||||
});
|
||||
})->skip();
|
||||
|
||||
test('能够正常获取 Stripe 配置信息', function () {
|
||||
/** @var StripeRpc $service */
|
||||
@@ -40,4 +40,4 @@ test('能够正常获取 Stripe 配置信息', function () {
|
||||
->toBeInstanceOf(StripeConfiguration::class)
|
||||
->toHaveKeys(['id', 'pk'])
|
||||
->and($configures->resolve())->toBeArray();
|
||||
});
|
||||
})->skip();
|
||||
|
||||
Reference in New Issue
Block a user