WorkerAccountLogEnum.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. namespace app\common\enum\worker;
  3. /**
  4. * 工程师账户流水变动表枚举
  5. * Class AccountLogEnum
  6. * @package app\common\enum
  7. */
  8. class WorkerAccountLogEnum
  9. {
  10. /**
  11. * 变动类型命名规则:对象_动作_简洁描述
  12. * 动作 DEC-减少 INC-增加
  13. * 对象 UM-工程师余额
  14. */
  15. /**
  16. * 变动对象
  17. * UM 工程师余额(user_money)
  18. */
  19. const UM = 1;
  20. /**
  21. * 动作
  22. * INC 增加
  23. * DEC 减少
  24. */
  25. const INC = 1;
  26. const DEC = 2;
  27. /**
  28. * 工程师余额减少类型
  29. */
  30. const UM_DEC_ADMIN = 100;
  31. /**
  32. * 工程师余额增加类型
  33. */
  34. const UM_INC_ADMIN = 200;
  35. /**
  36. * 工程师提现类型
  37. */
  38. const UM_CASH_OUT = 300;
  39. /**
  40. * 工程师余额(减少类型汇总)
  41. */
  42. const UM_DEC = [
  43. self::UM_DEC_ADMIN,
  44. ];
  45. /**
  46. * 工程师余额(增加类型汇总)
  47. */
  48. const UM_INC = [
  49. self::UM_INC_ADMIN,
  50. ];
  51. /**
  52. * @notes 动作描述
  53. * @param $action
  54. * @param false $flag
  55. * @return string|string[]
  56. */
  57. public static function getActionDesc($action, $flag = false)
  58. {
  59. $desc = [
  60. self::DEC => '减少',
  61. self::INC => '增加',
  62. ];
  63. if ($flag) {
  64. return $desc;
  65. }
  66. return $desc[$action] ?? '';
  67. }
  68. /**
  69. * @notes 变动类型描述
  70. * @param $changeType
  71. * @param false $flag
  72. * @return string|string[]
  73. */
  74. public static function getChangeTypeDesc($changeType, $flag = false)
  75. {
  76. $desc = [
  77. self::UM_DEC_ADMIN => '平台减少余额',
  78. self::UM_INC_ADMIN => '平台增加余额',
  79. self::UM_CASH_OUT => '工程师提现余额',
  80. ];
  81. if ($flag) {
  82. return $desc;
  83. }
  84. return $desc[$changeType] ?? '';
  85. }
  86. /**
  87. * @notes 获取工程师余额类型描述
  88. * @return string|string[]
  89. */
  90. public static function getUserMoneyChangeTypeDesc()
  91. {
  92. $UMChangeType = self::getUserMoneyChangeType();
  93. $changeTypeDesc = self::getChangeTypeDesc('', true);
  94. return array_filter($changeTypeDesc, function ($key) use ($UMChangeType) {
  95. return in_array($key, $UMChangeType);
  96. }, ARRAY_FILTER_USE_KEY);
  97. }
  98. /**
  99. * @notes 获取工程师余额变动类型
  100. * @return int[]
  101. */
  102. public static function getUserMoneyChangeType() : array
  103. {
  104. return array_merge(self::UM_DEC, self::UM_INC);
  105. }
  106. /**
  107. * @notes 获取变动对象
  108. * @param $changeType
  109. * @return false
  110. */
  111. public static function getChangeObject($changeType)
  112. {
  113. // 工程师余额
  114. $um = self::getUserMoneyChangeType();
  115. if (in_array($changeType, $um)) {
  116. return self::UM;
  117. }
  118. // 其他...
  119. return false;
  120. }
  121. }