WorkerAccountLogEnum.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. * FROZEN 冻结
  25. * RELEASE 解冻
  26. */
  27. const INC = 1;
  28. const DEC = 2;
  29. const FROZEN = 3;
  30. const RELEASE = 4;
  31. /**
  32. * 工程师余额减少类型
  33. */
  34. const UM_DEC_ADMIN = 100;
  35. /**
  36. * 工程师余额增加类型
  37. */
  38. const UM_INC_ADMIN = 200;
  39. /**
  40. * 工程师提现类型
  41. */
  42. const UM_CASH_OUT = 300;
  43. /**
  44. * 工程师余额(减少类型汇总)
  45. */
  46. const UM_DEC = [
  47. self::UM_DEC_ADMIN,
  48. ];
  49. /**
  50. * 工程师余额(增加类型汇总)
  51. */
  52. const UM_INC = [
  53. self::UM_INC_ADMIN,
  54. ];
  55. /**
  56. * @notes 动作描述
  57. * @param $action
  58. * @param false $flag
  59. * @return string|string[]
  60. */
  61. public static function getActionDesc($action, $flag = false)
  62. {
  63. $desc = [
  64. self::DEC => '减少',
  65. self::INC => '增加',
  66. ];
  67. if ($flag) {
  68. return $desc;
  69. }
  70. return $desc[$action] ?? '';
  71. }
  72. /**
  73. * @notes 变动类型描述
  74. * @param $changeType
  75. * @param false $flag
  76. * @return string|string[]
  77. */
  78. public static function getChangeTypeDesc($changeType, $flag = false)
  79. {
  80. $desc = [
  81. self::UM_DEC_ADMIN => '平台减少余额',
  82. self::UM_INC_ADMIN => '平台增加余额',
  83. self::UM_CASH_OUT => '工程师提现余额',
  84. ];
  85. if ($flag) {
  86. return $desc;
  87. }
  88. return $desc[$changeType] ?? '';
  89. }
  90. /**
  91. * @notes 获取工程师余额类型描述
  92. * @return string|string[]
  93. */
  94. public static function getUserMoneyChangeTypeDesc()
  95. {
  96. $UMChangeType = self::getUserMoneyChangeType();
  97. $changeTypeDesc = self::getChangeTypeDesc('', true);
  98. return array_filter($changeTypeDesc, function ($key) use ($UMChangeType) {
  99. return in_array($key, $UMChangeType);
  100. }, ARRAY_FILTER_USE_KEY);
  101. }
  102. /**
  103. * @notes 获取工程师余额变动类型
  104. * @return int[]
  105. */
  106. public static function getUserMoneyChangeType() : array
  107. {
  108. return array_merge(self::UM_DEC, self::UM_INC);
  109. }
  110. /**
  111. * @notes 获取变动对象
  112. * @param $changeType
  113. * @return false
  114. */
  115. public static function getChangeObject($changeType)
  116. {
  117. // 工程师余额
  118. $um = self::getUserMoneyChangeType();
  119. if (in_array($changeType, $um)) {
  120. return self::UM;
  121. }
  122. // 其他...
  123. return false;
  124. }
  125. }