mirror of
https://gitee.com/technical-laohu/mpay_v2_webman.git
synced 2026-04-23 18:44:26 +08:00
重构初始化
This commit is contained in:
39
app/common/constant/AuthConstant.php
Normal file
39
app/common/constant/AuthConstant.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\constant;
|
||||
|
||||
/**
|
||||
* 认证相关常量。
|
||||
*
|
||||
* 统一管理登录域、令牌状态、签名类型等枚举值。
|
||||
*/
|
||||
final class AuthConstant
|
||||
{
|
||||
public const GUARD_ADMIN = 1;
|
||||
public const GUARD_MERCHANT = 2;
|
||||
|
||||
public const JWT_ALG_HS256 = 'HS256';
|
||||
|
||||
public const TOKEN_STATUS_DISABLED = 0;
|
||||
public const TOKEN_STATUS_ENABLED = 1;
|
||||
|
||||
public const LOGIN_STATUS_DISABLED = 0;
|
||||
public const LOGIN_STATUS_ENABLED = 1;
|
||||
|
||||
public const API_SIGN_TYPE_MD5 = 0;
|
||||
|
||||
public static function signTypeMap(): array
|
||||
{
|
||||
return [
|
||||
self::API_SIGN_TYPE_MD5 => 'MD5',
|
||||
];
|
||||
}
|
||||
|
||||
public static function guardMap(): array
|
||||
{
|
||||
return [
|
||||
self::GUARD_ADMIN => 'admin',
|
||||
self::GUARD_MERCHANT => 'merchant',
|
||||
];
|
||||
}
|
||||
}
|
||||
31
app/common/constant/CommonConstant.php
Normal file
31
app/common/constant/CommonConstant.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\constant;
|
||||
|
||||
/**
|
||||
* 通用状态常量。
|
||||
*/
|
||||
final class CommonConstant
|
||||
{
|
||||
public const STATUS_DISABLED = 0;
|
||||
public const STATUS_ENABLED = 1;
|
||||
|
||||
public const NO = 0;
|
||||
public const YES = 1;
|
||||
|
||||
public static function statusMap(): array
|
||||
{
|
||||
return [
|
||||
self::STATUS_DISABLED => '禁用',
|
||||
self::STATUS_ENABLED => '启用',
|
||||
];
|
||||
}
|
||||
|
||||
public static function yesNoMap(): array
|
||||
{
|
||||
return [
|
||||
self::NO => '否',
|
||||
self::YES => '是',
|
||||
];
|
||||
}
|
||||
}
|
||||
135
app/common/constant/FileConstant.php
Normal file
135
app/common/constant/FileConstant.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\constant;
|
||||
|
||||
/**
|
||||
* 文件相关常量。
|
||||
*/
|
||||
final class FileConstant
|
||||
{
|
||||
public const SOURCE_UPLOAD = 1;
|
||||
public const SOURCE_REMOTE_URL = 2;
|
||||
|
||||
public const VISIBILITY_PUBLIC = 1;
|
||||
public const VISIBILITY_PRIVATE = 2;
|
||||
|
||||
public const SCENE_IMAGE = 1;
|
||||
public const SCENE_CERTIFICATE = 2;
|
||||
public const SCENE_TEXT = 3;
|
||||
public const SCENE_OTHER = 4;
|
||||
|
||||
public const STORAGE_LOCAL = 1;
|
||||
public const STORAGE_ALIYUN_OSS = 2;
|
||||
public const STORAGE_TENCENT_COS = 3;
|
||||
public const STORAGE_REMOTE_URL = 4;
|
||||
|
||||
public const CONFIG_DEFAULT_ENGINE = 'file_storage_default_engine';
|
||||
public const CONFIG_LOCAL_PUBLIC_BASE_URL = 'file_storage_local_public_base_url';
|
||||
public const CONFIG_LOCAL_PUBLIC_DIR = 'file_storage_local_public_dir';
|
||||
public const CONFIG_LOCAL_PRIVATE_DIR = 'file_storage_local_private_dir';
|
||||
public const CONFIG_UPLOAD_MAX_SIZE_MB = 'file_storage_upload_max_size_mb';
|
||||
public const CONFIG_REMOTE_DOWNLOAD_LIMIT_MB = 'file_storage_remote_download_limit_mb';
|
||||
public const CONFIG_ALLOWED_EXTENSIONS = 'file_storage_allowed_extensions';
|
||||
public const CONFIG_OSS_ENDPOINT = 'file_storage_aliyun_oss_endpoint';
|
||||
public const CONFIG_OSS_BUCKET = 'file_storage_aliyun_oss_bucket';
|
||||
public const CONFIG_OSS_ACCESS_KEY_ID = 'file_storage_aliyun_oss_access_key_id';
|
||||
public const CONFIG_OSS_ACCESS_KEY_SECRET = 'file_storage_aliyun_oss_access_key_secret';
|
||||
public const CONFIG_OSS_PUBLIC_DOMAIN = 'file_storage_aliyun_oss_public_domain';
|
||||
public const CONFIG_OSS_REGION = 'file_storage_aliyun_oss_region';
|
||||
public const CONFIG_COS_REGION = 'file_storage_tencent_cos_region';
|
||||
public const CONFIG_COS_BUCKET = 'file_storage_tencent_cos_bucket';
|
||||
public const CONFIG_COS_SECRET_ID = 'file_storage_tencent_cos_secret_id';
|
||||
public const CONFIG_COS_SECRET_KEY = 'file_storage_tencent_cos_secret_key';
|
||||
public const CONFIG_COS_PUBLIC_DOMAIN = 'file_storage_tencent_cos_public_domain';
|
||||
|
||||
public static function sourceTypeMap(): array
|
||||
{
|
||||
return [
|
||||
self::SOURCE_UPLOAD => '上传',
|
||||
self::SOURCE_REMOTE_URL => '远程导入',
|
||||
];
|
||||
}
|
||||
|
||||
public static function visibilityMap(): array
|
||||
{
|
||||
return [
|
||||
self::VISIBILITY_PUBLIC => '公开',
|
||||
self::VISIBILITY_PRIVATE => '私有',
|
||||
];
|
||||
}
|
||||
|
||||
public static function sceneMap(): array
|
||||
{
|
||||
return [
|
||||
self::SCENE_IMAGE => '图片',
|
||||
self::SCENE_CERTIFICATE => '证书',
|
||||
self::SCENE_TEXT => '文本',
|
||||
self::SCENE_OTHER => '其他',
|
||||
];
|
||||
}
|
||||
|
||||
public static function storageEngineMap(): array
|
||||
{
|
||||
return [
|
||||
self::STORAGE_LOCAL => '本地存储',
|
||||
self::STORAGE_ALIYUN_OSS => '阿里云 OSS',
|
||||
self::STORAGE_TENCENT_COS => '腾讯云 COS',
|
||||
self::STORAGE_REMOTE_URL => '远程引用',
|
||||
];
|
||||
}
|
||||
|
||||
public static function selectableStorageEngineMap(): array
|
||||
{
|
||||
return [
|
||||
self::STORAGE_LOCAL => '本地存储',
|
||||
self::STORAGE_ALIYUN_OSS => '阿里云 OSS',
|
||||
self::STORAGE_TENCENT_COS => '腾讯云 COS',
|
||||
];
|
||||
}
|
||||
|
||||
public static function imageExtensionMap(): array
|
||||
{
|
||||
return [
|
||||
'jpg' => true,
|
||||
'jpeg' => true,
|
||||
'png' => true,
|
||||
'gif' => true,
|
||||
'webp' => true,
|
||||
'bmp' => true,
|
||||
'svg' => true,
|
||||
];
|
||||
}
|
||||
|
||||
public static function certificateExtensionMap(): array
|
||||
{
|
||||
return [
|
||||
'pem' => true,
|
||||
'crt' => true,
|
||||
'cer' => true,
|
||||
'key' => true,
|
||||
'p12' => true,
|
||||
'pfx' => true,
|
||||
];
|
||||
}
|
||||
|
||||
public static function textExtensionMap(): array
|
||||
{
|
||||
return [
|
||||
'txt' => true,
|
||||
'log' => true,
|
||||
'csv' => true,
|
||||
'json' => true,
|
||||
'xml' => true,
|
||||
'md' => true,
|
||||
'ini' => true,
|
||||
'conf' => true,
|
||||
'yaml' => true,
|
||||
'yml' => true,
|
||||
];
|
||||
}
|
||||
|
||||
public static function defaultAllowedExtensions(): array
|
||||
{
|
||||
return array_keys(self::imageExtensionMap() + self::certificateExtensionMap() + self::textExtensionMap());
|
||||
}
|
||||
}
|
||||
54
app/common/constant/LedgerConstant.php
Normal file
54
app/common/constant/LedgerConstant.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\constant;
|
||||
|
||||
/**
|
||||
* 账户流水相关枚举。
|
||||
*/
|
||||
final class LedgerConstant
|
||||
{
|
||||
public const BIZ_TYPE_PAY_FREEZE = 0;
|
||||
public const BIZ_TYPE_PAY_DEDUCT = 1;
|
||||
public const BIZ_TYPE_PAY_RELEASE = 2;
|
||||
public const BIZ_TYPE_SETTLEMENT_CREDIT = 3;
|
||||
public const BIZ_TYPE_REFUND_REVERSE = 4;
|
||||
public const BIZ_TYPE_MANUAL_ADJUST = 5;
|
||||
|
||||
public const EVENT_TYPE_CREATE = 0;
|
||||
public const EVENT_TYPE_SUCCESS = 1;
|
||||
public const EVENT_TYPE_FAILED = 2;
|
||||
public const EVENT_TYPE_REVERSE = 3;
|
||||
|
||||
public const DIRECTION_IN = 0;
|
||||
public const DIRECTION_OUT = 1;
|
||||
|
||||
public static function bizTypeMap(): array
|
||||
{
|
||||
return [
|
||||
self::BIZ_TYPE_PAY_FREEZE => '支付冻结',
|
||||
self::BIZ_TYPE_PAY_DEDUCT => '支付扣费',
|
||||
self::BIZ_TYPE_PAY_RELEASE => '支付释放',
|
||||
self::BIZ_TYPE_SETTLEMENT_CREDIT => '清算入账',
|
||||
self::BIZ_TYPE_REFUND_REVERSE => '退款冲正',
|
||||
self::BIZ_TYPE_MANUAL_ADJUST => '人工调整',
|
||||
];
|
||||
}
|
||||
|
||||
public static function eventTypeMap(): array
|
||||
{
|
||||
return [
|
||||
self::EVENT_TYPE_CREATE => '创建',
|
||||
self::EVENT_TYPE_SUCCESS => '成功',
|
||||
self::EVENT_TYPE_FAILED => '失败',
|
||||
self::EVENT_TYPE_REVERSE => '冲正',
|
||||
];
|
||||
}
|
||||
|
||||
public static function directionMap(): array
|
||||
{
|
||||
return [
|
||||
self::DIRECTION_IN => '入账',
|
||||
self::DIRECTION_OUT => '出账',
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/common/constant/MerchantConstant.php
Normal file
35
app/common/constant/MerchantConstant.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\constant;
|
||||
|
||||
/**
|
||||
* 商户相关枚举。
|
||||
*/
|
||||
final class MerchantConstant
|
||||
{
|
||||
public const TYPE_PERSON = 0;
|
||||
public const TYPE_COMPANY = 1;
|
||||
public const TYPE_OTHER = 2;
|
||||
|
||||
public const RISK_LOW = 0;
|
||||
public const RISK_MEDIUM = 1;
|
||||
public const RISK_HIGH = 2;
|
||||
|
||||
public static function typeMap(): array
|
||||
{
|
||||
return [
|
||||
self::TYPE_PERSON => '个人',
|
||||
self::TYPE_COMPANY => '企业',
|
||||
self::TYPE_OTHER => '其他',
|
||||
];
|
||||
}
|
||||
|
||||
public static function riskLevelMap(): array
|
||||
{
|
||||
return [
|
||||
self::RISK_LOW => '低',
|
||||
self::RISK_MEDIUM => '中',
|
||||
self::RISK_HIGH => '高',
|
||||
];
|
||||
}
|
||||
}
|
||||
70
app/common/constant/NotifyConstant.php
Normal file
70
app/common/constant/NotifyConstant.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\constant;
|
||||
|
||||
/**
|
||||
* 通知与回调相关枚举。
|
||||
*/
|
||||
final class NotifyConstant
|
||||
{
|
||||
public const NOTIFY_TYPE_ASYNC = 0;
|
||||
public const NOTIFY_TYPE_QUERY = 1;
|
||||
|
||||
public const CALLBACK_TYPE_ASYNC = 0;
|
||||
public const CALLBACK_TYPE_SYNC = 1;
|
||||
|
||||
public const VERIFY_STATUS_UNKNOWN = 0;
|
||||
public const VERIFY_STATUS_SUCCESS = 1;
|
||||
public const VERIFY_STATUS_FAILED = 2;
|
||||
|
||||
public const PROCESS_STATUS_PENDING = 0;
|
||||
public const PROCESS_STATUS_SUCCESS = 1;
|
||||
public const PROCESS_STATUS_FAILED = 2;
|
||||
|
||||
public const TASK_STATUS_PENDING = 0;
|
||||
public const TASK_STATUS_SUCCESS = 1;
|
||||
public const TASK_STATUS_FAILED = 2;
|
||||
|
||||
public static function notifyTypeMap(): array
|
||||
{
|
||||
return [
|
||||
self::NOTIFY_TYPE_ASYNC => '异步通知',
|
||||
self::NOTIFY_TYPE_QUERY => '查单',
|
||||
];
|
||||
}
|
||||
|
||||
public static function callbackTypeMap(): array
|
||||
{
|
||||
return [
|
||||
self::CALLBACK_TYPE_ASYNC => '异步通知',
|
||||
self::CALLBACK_TYPE_SYNC => '同步返回',
|
||||
];
|
||||
}
|
||||
|
||||
public static function verifyStatusMap(): array
|
||||
{
|
||||
return [
|
||||
self::VERIFY_STATUS_UNKNOWN => '未知',
|
||||
self::VERIFY_STATUS_SUCCESS => '成功',
|
||||
self::VERIFY_STATUS_FAILED => '失败',
|
||||
];
|
||||
}
|
||||
|
||||
public static function processStatusMap(): array
|
||||
{
|
||||
return [
|
||||
self::PROCESS_STATUS_PENDING => '待处理',
|
||||
self::PROCESS_STATUS_SUCCESS => '成功',
|
||||
self::PROCESS_STATUS_FAILED => '失败',
|
||||
];
|
||||
}
|
||||
|
||||
public static function taskStatusMap(): array
|
||||
{
|
||||
return [
|
||||
self::TASK_STATUS_PENDING => '待通知',
|
||||
self::TASK_STATUS_SUCCESS => '成功',
|
||||
self::TASK_STATUS_FAILED => '失败',
|
||||
];
|
||||
}
|
||||
}
|
||||
55
app/common/constant/RouteConstant.php
Normal file
55
app/common/constant/RouteConstant.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\constant;
|
||||
|
||||
/**
|
||||
* 路由与通道编排相关枚举。
|
||||
*/
|
||||
final class RouteConstant
|
||||
{
|
||||
public const CHANNEL_TYPE_PLATFORM_COLLECT = 0;
|
||||
public const CHANNEL_TYPE_MERCHANT_SELF = 1;
|
||||
|
||||
public const CHANNEL_MODE_COLLECT = 0;
|
||||
public const CHANNEL_MODE_SELF = 1;
|
||||
|
||||
/**
|
||||
* 轮询组模式:按编排顺序依次轮询可用通道。
|
||||
*/
|
||||
public const ROUTE_MODE_ORDER = 0;
|
||||
|
||||
/**
|
||||
* 轮询组模式:按通道权重随机选择可用通道。
|
||||
*/
|
||||
public const ROUTE_MODE_WEIGHTED = 1;
|
||||
|
||||
/**
|
||||
* 轮询组模式:优先选择默认启用通道,默认不可用时回退到首个可用通道。
|
||||
*/
|
||||
public const ROUTE_MODE_FIRST_AVAILABLE = 2;
|
||||
|
||||
public static function channelTypeMap(): array
|
||||
{
|
||||
return [
|
||||
self::CHANNEL_TYPE_PLATFORM_COLLECT => '平台代收',
|
||||
self::CHANNEL_TYPE_MERCHANT_SELF => '商户自有',
|
||||
];
|
||||
}
|
||||
|
||||
public static function channelModeMap(): array
|
||||
{
|
||||
return [
|
||||
self::CHANNEL_MODE_COLLECT => '代收',
|
||||
self::CHANNEL_MODE_SELF => '自收',
|
||||
];
|
||||
}
|
||||
|
||||
public static function routeModeMap(): array
|
||||
{
|
||||
return [
|
||||
self::ROUTE_MODE_ORDER => '顺序依次轮询',
|
||||
self::ROUTE_MODE_WEIGHTED => '权重随机轮询',
|
||||
self::ROUTE_MODE_FIRST_AVAILABLE => '默认启用通道',
|
||||
];
|
||||
}
|
||||
}
|
||||
157
app/common/constant/TradeConstant.php
Normal file
157
app/common/constant/TradeConstant.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\constant;
|
||||
|
||||
/**
|
||||
* 交易、订单与结算相关枚举。
|
||||
*/
|
||||
final class TradeConstant
|
||||
{
|
||||
public const SETTLEMENT_CYCLE_D0 = 0;
|
||||
public const SETTLEMENT_CYCLE_D1 = 1;
|
||||
public const SETTLEMENT_CYCLE_D7 = 2;
|
||||
public const SETTLEMENT_CYCLE_T1 = 3;
|
||||
public const SETTLEMENT_CYCLE_OTHER = 4;
|
||||
|
||||
public const ORDER_STATUS_CREATED = 0;
|
||||
public const ORDER_STATUS_PAYING = 1;
|
||||
public const ORDER_STATUS_SUCCESS = 2;
|
||||
public const ORDER_STATUS_FAILED = 3;
|
||||
public const ORDER_STATUS_CLOSED = 4;
|
||||
public const ORDER_STATUS_TIMEOUT = 5;
|
||||
|
||||
public const FEE_STATUS_NONE = 0;
|
||||
public const FEE_STATUS_FROZEN = 1;
|
||||
public const FEE_STATUS_DEDUCTED = 2;
|
||||
public const FEE_STATUS_RELEASED = 3;
|
||||
|
||||
public const SETTLEMENT_STATUS_NONE = 0;
|
||||
public const SETTLEMENT_STATUS_PENDING = 1;
|
||||
public const SETTLEMENT_STATUS_SETTLED = 2;
|
||||
public const SETTLEMENT_STATUS_REVERSED = 3;
|
||||
|
||||
public const REFUND_STATUS_CREATED = 0;
|
||||
public const REFUND_STATUS_PROCESSING = 1;
|
||||
public const REFUND_STATUS_SUCCESS = 2;
|
||||
public const REFUND_STATUS_FAILED = 3;
|
||||
public const REFUND_STATUS_CLOSED = 4;
|
||||
|
||||
public static function settlementCycleMap(): array
|
||||
{
|
||||
return [
|
||||
self::SETTLEMENT_CYCLE_D0 => 'D0',
|
||||
self::SETTLEMENT_CYCLE_D1 => 'D1',
|
||||
self::SETTLEMENT_CYCLE_D7 => 'D7',
|
||||
self::SETTLEMENT_CYCLE_T1 => 'T1',
|
||||
self::SETTLEMENT_CYCLE_OTHER => 'OTHER',
|
||||
];
|
||||
}
|
||||
|
||||
public static function orderStatusMap(): array
|
||||
{
|
||||
return [
|
||||
self::ORDER_STATUS_CREATED => '待创建',
|
||||
self::ORDER_STATUS_PAYING => '支付中',
|
||||
self::ORDER_STATUS_SUCCESS => '成功',
|
||||
self::ORDER_STATUS_FAILED => '失败',
|
||||
self::ORDER_STATUS_CLOSED => '关闭',
|
||||
self::ORDER_STATUS_TIMEOUT => '超时',
|
||||
];
|
||||
}
|
||||
|
||||
public static function feeStatusMap(): array
|
||||
{
|
||||
return [
|
||||
self::FEE_STATUS_NONE => '无',
|
||||
self::FEE_STATUS_FROZEN => '冻结',
|
||||
self::FEE_STATUS_DEDUCTED => '已扣',
|
||||
self::FEE_STATUS_RELEASED => '已释放',
|
||||
];
|
||||
}
|
||||
|
||||
public static function settlementStatusMap(): array
|
||||
{
|
||||
return [
|
||||
self::SETTLEMENT_STATUS_NONE => '无',
|
||||
self::SETTLEMENT_STATUS_PENDING => '待清算',
|
||||
self::SETTLEMENT_STATUS_SETTLED => '已清算',
|
||||
self::SETTLEMENT_STATUS_REVERSED => '已冲正',
|
||||
];
|
||||
}
|
||||
|
||||
public static function refundStatusMap(): array
|
||||
{
|
||||
return [
|
||||
self::REFUND_STATUS_CREATED => '待创建',
|
||||
self::REFUND_STATUS_PROCESSING => '处理中',
|
||||
self::REFUND_STATUS_SUCCESS => '成功',
|
||||
self::REFUND_STATUS_FAILED => '失败',
|
||||
self::REFUND_STATUS_CLOSED => '关闭',
|
||||
];
|
||||
}
|
||||
|
||||
public static function orderMutableStatuses(): array
|
||||
{
|
||||
return [
|
||||
self::ORDER_STATUS_CREATED,
|
||||
self::ORDER_STATUS_PAYING,
|
||||
];
|
||||
}
|
||||
|
||||
public static function orderTerminalStatuses(): array
|
||||
{
|
||||
return [
|
||||
self::ORDER_STATUS_SUCCESS,
|
||||
self::ORDER_STATUS_FAILED,
|
||||
self::ORDER_STATUS_CLOSED,
|
||||
self::ORDER_STATUS_TIMEOUT,
|
||||
];
|
||||
}
|
||||
|
||||
public static function isOrderTerminalStatus(int $status): bool
|
||||
{
|
||||
return in_array($status, self::orderTerminalStatuses(), true);
|
||||
}
|
||||
|
||||
public static function refundMutableStatuses(): array
|
||||
{
|
||||
return [
|
||||
self::REFUND_STATUS_CREATED,
|
||||
self::REFUND_STATUS_PROCESSING,
|
||||
self::REFUND_STATUS_FAILED,
|
||||
];
|
||||
}
|
||||
|
||||
public static function refundTerminalStatuses(): array
|
||||
{
|
||||
return [
|
||||
self::REFUND_STATUS_SUCCESS,
|
||||
self::REFUND_STATUS_CLOSED,
|
||||
];
|
||||
}
|
||||
|
||||
public static function isRefundTerminalStatus(int $status): bool
|
||||
{
|
||||
return in_array($status, self::refundTerminalStatuses(), true);
|
||||
}
|
||||
|
||||
public static function settlementMutableStatuses(): array
|
||||
{
|
||||
return [
|
||||
self::SETTLEMENT_STATUS_PENDING,
|
||||
];
|
||||
}
|
||||
|
||||
public static function settlementTerminalStatuses(): array
|
||||
{
|
||||
return [
|
||||
self::SETTLEMENT_STATUS_SETTLED,
|
||||
self::SETTLEMENT_STATUS_REVERSED,
|
||||
];
|
||||
}
|
||||
|
||||
public static function isSettlementTerminalStatus(int $status): bool
|
||||
{
|
||||
return in_array($status, self::settlementTerminalStatuses(), true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user