| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace App\Module\Point\Enums;
- use UCore\Enum\EnumCore;
- use UCore\Enum\EnumToInt;
- /**
- * 积分分类枚举
- *
- * 定义积分的分类类型,用于区分不同状态的积分
- */
- enum POINT_CATE: int
- {
- use EnumToInt, EnumCore;
- /**
- * 可用积分
- */
- case AVAILABLE = 1;
- /**
- * 冻结积分
- */
- case FROZEN = 2;
- /**
- * 获取分类名称
- *
- * @return string 分类名称
- */
- public function getCategoryName(): string
- {
- return match($this) {
- self::AVAILABLE => '可用积分',
- self::FROZEN => '冻结积分',
- };
- }
- /**
- * 获取分类描述
- *
- * @return string 分类描述
- */
- public function getDescription(): string
- {
- return match($this) {
- self::AVAILABLE => '用户可以正常使用的积分',
- self::FROZEN => '被系统冻结暂时无法使用的积分',
- };
- }
- /**
- * 获取所有分类
- *
- * @return array 所有分类数组
- */
- public static function getAllCategories(): array
- {
- return [
- self::AVAILABLE->value => self::AVAILABLE->getCategoryName(),
- self::FROZEN->value => self::FROZEN->getCategoryName(),
- ];
- }
- }
|