POINT_CATE.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace App\Module\Point\Enums;
  3. use UCore\Enum\EnumCore;
  4. use UCore\Enum\EnumToInt;
  5. /**
  6. * 积分分类枚举
  7. *
  8. * 定义积分的分类类型,用于区分不同状态的积分
  9. */
  10. enum POINT_CATE: int
  11. {
  12. use EnumToInt, EnumCore;
  13. /**
  14. * 可用积分
  15. */
  16. case AVAILABLE = 1;
  17. /**
  18. * 冻结积分
  19. */
  20. case FROZEN = 2;
  21. /**
  22. * 获取分类名称
  23. *
  24. * @return string 分类名称
  25. */
  26. public function getCategoryName(): string
  27. {
  28. return match($this) {
  29. self::AVAILABLE => '可用积分',
  30. self::FROZEN => '冻结积分',
  31. };
  32. }
  33. /**
  34. * 获取分类描述
  35. *
  36. * @return string 分类描述
  37. */
  38. public function getDescription(): string
  39. {
  40. return match($this) {
  41. self::AVAILABLE => '用户可以正常使用的积分',
  42. self::FROZEN => '被系统冻结暂时无法使用的积分',
  43. };
  44. }
  45. /**
  46. * 获取所有分类
  47. *
  48. * @return array 所有分类数组
  49. */
  50. public static function getAllCategories(): array
  51. {
  52. return [
  53. self::AVAILABLE->value => self::AVAILABLE->getCategoryName(),
  54. self::FROZEN->value => self::FROZEN->getCategoryName(),
  55. ];
  56. }
  57. }