mirror of
http://124.126.16.154:8888/singularity/hdk-pay.git
synced 2026-01-15 02:15:07 +08:00
feat(Invoice): 添加价格和货币信息到发票信息
- 在 InvoiceInfo 类中添加 price 和 currencySymbol 属性,并提供相关获取方法 - 修改 InvoiceRepo 以适配新的 InvoiceInfo 结构
This commit is contained in:
@@ -7,11 +7,13 @@
|
||||
* Powered by PhpStorm
|
||||
* Created on 2025/9/5
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Money\Money;
|
||||
use Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice\ValueObject\PointBalance;
|
||||
|
||||
final readonly class InvoiceInfo
|
||||
@@ -27,8 +29,25 @@ final readonly class InvoiceInfo
|
||||
private Carbon $invoiceAt,
|
||||
private Carbon $designedAt,
|
||||
private string $patientName,
|
||||
private Money $price,
|
||||
private 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;
|
||||
@@ -78,4 +97,4 @@ final readonly class InvoiceInfo
|
||||
{
|
||||
return $this->patientName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,16 +136,7 @@ final class InvoiceRepo extends AbstractRepo implements InvoiceRepoInterface
|
||||
name: $result['product']['name'],
|
||||
sku: $result['product']['sku'],
|
||||
description: $result['product']['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['product']['prices'] ?? [],
|
||||
),
|
||||
prices: [],
|
||||
),
|
||||
balance: new PointBalance(
|
||||
total: $result['balance']['total'],
|
||||
@@ -156,6 +147,11 @@ final class InvoiceRepo extends AbstractRepo implements InvoiceRepoInterface
|
||||
invoiceAt: new Carbon($result['invoice_at']),
|
||||
designedAt: new Carbon($result['designed_at']),
|
||||
patientName: $result['patient_name'],
|
||||
price: new Money(
|
||||
bcmul((string)$result['price']['amount'], '100', 2),
|
||||
new Currency($result['price']['currency_code']),
|
||||
),
|
||||
currencySymbol: $result['price']['currency_symbol'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user