mirror of
http://124.126.16.154:8888/singularity/hdk-pay.git
synced 2026-01-15 05:55:08 +08:00
feat(invoice): 添加发票发送功能并进行测试
- 在 InvoiceRepo 中添加 send 方法,用于发送发票邮件 - 在 CreateInvoiceTest 中添加测试用例,验证发票发送功能
This commit is contained in:
@@ -11,7 +11,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Singularity\HDK\Pay\Infrastructure\Repository;
|
namespace Singularity\HDK\Pay\Infrastructure\Repository;
|
||||||
|
|
||||||
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
use Hyperf\Codec\Json;
|
use Hyperf\Codec\Json;
|
||||||
|
use Singularity\HDK\Core\Exceptions\ValidateException;
|
||||||
use Singularity\HDK\Pay\Application\Command\CreateInvoiceCmd;
|
use Singularity\HDK\Pay\Application\Command\CreateInvoiceCmd;
|
||||||
use Singularity\HDK\Pay\Domain\Invoice\Aggregate\Invoice\Address;
|
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\Invoice;
|
||||||
@@ -54,4 +56,17 @@ final class InvoiceRepo extends AbstractRepo implements InvoiceRepoInterface
|
|||||||
receiver: $result['receiver'],
|
receiver: $result['receiver'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $invoiceNo
|
||||||
|
* @return void
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -34,3 +34,14 @@ it('should can create invoice', function () {
|
|||||||
expect($invoice)
|
expect($invoice)
|
||||||
->toBeInstanceOf(Invoice::class);
|
->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);
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user