6
0
Fork 0
jiqu-library-server/app/Enums/PayWay.php

96 lines
2.8 KiB
PHP

<?php
namespace App\Enums;
use Dcat\Admin\Admin;
enum PayWay: string {
case None = 'none';
case Offline = 'offline';
case Balance = 'balance';
case Wallet = 'wallet';
// 微信支付
case WxpayApp = 'wxpay_app';
case WxpayH5 = 'wxpay_h5';
case WxpayJsApi = 'wxpay_jsapi';
case WxpayMiniProgram = 'wxpay_mp';
case WxpayTransfer = 'wxpay_transfer';
case WxPayShare = 'wx_pay_share';
// 阿里支付
case AlipayApp = 'alipay_app';
public function dot()
{
$color = $this->color();
$color = Admin::color()->get($color, $color);
return '<i class="fa fa-circle" style="font-size: 13px;color: '.$color.'"></i>&nbsp;'.$this->text() ?? 'Unknown';
}
public function color()
{
return match ($this) {
static::Offline => '#5b69bc',
static::Balance => '#dda451',
static::Wallet => '#ff8acc',
static::WxpayApp, static::WxpayH5, static::WxpayJsApi, static::WxpayMiniProgram, static::WxpayTransfer, static::WxPayShare => '#21b978',
static::AlipayApp => '#3085d6',
default => '#ea5455',
};
}
public function label()
{
return match ($this) {
static::None => 'none',
static::Offline => 'offline',
static::Balance => 'balance',
static::Wallet => 'wallet',
static::WxpayApp, static::WxpayH5, static::WxpayJsApi, static::WxpayMiniProgram, static::WxPayShare => 'wxpay',
static::AlipayApp => 'alipay',
};
}
/**
* 支付方式文本
*
* @return string
*/
public function text(): string
{
return match ($this) {
static::None => '无',
static::Offline => '线下',
static::Balance => '余额',
static::Wallet => '钱包',
static::WxpayApp, static::WxpayH5, static::WxpayJsApi, static::WxpayMiniProgram => '微信支付',
static::AlipayApp => '支付宝',
static::WxpayTransfer => '微信企业付款',
static::WxPayShare => '微信分账',
};
}
/**
* 支付方式对应的颜色
*
* @return array
*/
public static function colors(): array
{
return [
static::Offline->value => '#5b69bc',
static::Balance->value => '#dda451',
static::Wallet->value => '#ff8acc',
// 微信支付
static::WxpayApp->value => '#21b978',
static::WxpayH5->value => '#21b978',
static::WxpayJsApi->value => '#21b978',
static::WxpayMiniProgram->value => '#21b978',
static::WxPayShare->value => '#21b978',
// 支付宝
static::AlipayApp->value => '#3085d6',
];
}
}