mirror of
http://124.126.16.154:8888/singularity/hdk-pay.git
synced 2026-01-15 06:15:09 +08:00
feat(enum): 增加订单相关的枚举类型
This commit is contained in:
23
src/Enum/CurrencyEnum.php
Normal file
23
src/Enum/CurrencyEnum.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Currencies.php@LuxPay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2023/5/17
|
||||
*/
|
||||
|
||||
namespace Singularity\HDK\Pay\Enum;
|
||||
|
||||
use Money\Currency;
|
||||
|
||||
enum CurrencyEnum
|
||||
{
|
||||
case CNY;
|
||||
case USD;
|
||||
|
||||
public function getInstance(): Currency
|
||||
{
|
||||
return new Currency($this->name);
|
||||
}
|
||||
}
|
||||
54
src/Enum/OrderStatus.php
Normal file
54
src/Enum/OrderStatus.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* OrderStatus.php@LuxPay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2023/5/19
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Pay\Enum;
|
||||
|
||||
/**
|
||||
* App\Enum\OrderStatus@LuxPay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2023/5/19
|
||||
*/
|
||||
enum OrderStatus: string
|
||||
{
|
||||
case Created = "Created";
|
||||
|
||||
case Paid = 'Paid';
|
||||
|
||||
case Cancelled = 'Cancelled';
|
||||
|
||||
case Closed = 'Closed';
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public static function all(): array
|
||||
{
|
||||
$list = [];
|
||||
foreach (self::cases() as $key) {
|
||||
$list[] = $key->name;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
// public static function from(string $value): ?OrderStatus
|
||||
// {
|
||||
// var_dump($value, __METHOD__);
|
||||
// return match ($value) {
|
||||
// 'Created' => OrderStatus::Created,
|
||||
// 'Paid' => OrderStatus::Paid,
|
||||
// 'Cancelled' => OrderStatus::Cancelled,
|
||||
// 'Closed' => OrderStatus::Closed,
|
||||
// default => null
|
||||
// };
|
||||
// }
|
||||
}
|
||||
53
src/Enum/PaymentMethod.php
Normal file
53
src/Enum/PaymentMethod.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* PaymentMethod.php@Pay
|
||||
*
|
||||
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2023/9/19
|
||||
*/
|
||||
|
||||
namespace Singularity\HDK\Pay\Enum;
|
||||
|
||||
enum PaymentMethod: string
|
||||
{
|
||||
case Stripe = 'stripe';
|
||||
|
||||
case WechatPay = 'wechat';
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function all(): array
|
||||
{
|
||||
$list = [];
|
||||
foreach (self::cases() as $key) {
|
||||
$list[$key->name] = $key->value;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function values(): array
|
||||
{
|
||||
$list = [];
|
||||
foreach (self::cases() as $key) {
|
||||
$list[] = $key->value;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function keys(): array
|
||||
{
|
||||
$list = [];
|
||||
foreach (self::cases() as $key) {
|
||||
$list[] = $key->name;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user