CommonConst.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /*
  3. * To change this license header, choose License Headers in Project Properties.
  4. * To change this template file, choose Tools | Templates
  5. * and open the template in the editor.
  6. */
  7. namespace app\common\state;
  8. /**
  9. * Description of CommonConst
  10. * 公共常量
  11. * @author sgq
  12. */
  13. class CommonConst {
  14. /**
  15. * 通过层次得到层次基础积分
  16. * @param type $level
  17. * @return int
  18. */
  19. public static function getLayerPointsByLayer($level) {
  20. $level = $level ?: 8;
  21. $levelAndPoints = [
  22. 1 => 6000,
  23. 2 => 4000,
  24. 3 => 2000,
  25. 4 => 1000,
  26. 5 => 500,
  27. 6 => 200,
  28. 7 => 100,
  29. 8 => 0
  30. ];
  31. return $levelAndPoints[$level];
  32. }
  33. /**
  34. * 通过层次得到层次名
  35. * @param type $level
  36. * @return string
  37. */
  38. public static function getLayerNameByLayer($level) {
  39. $level = $level ?: 8;
  40. $levelAndNames = [
  41. 1 => "第一层次",
  42. 2 => "第二层次",
  43. 3 => "第三层次",
  44. 4 => "第四层次",
  45. 5 => "第五层次",
  46. 6 => "第六层次",
  47. 7 => "第七层次",
  48. 8 => "非优秀人才"
  49. ];
  50. return $levelAndNames[$level];
  51. }
  52. /**
  53. * 通过积分得到层次
  54. * @param type $points
  55. * @return int
  56. */
  57. public static function getLayerByPoints($points) {
  58. $level = 1;
  59. while ($levelPoints = CommonConst::getLayerPointsByLayer($level)) {
  60. if ($points >= $levelPoints) {
  61. break;
  62. }
  63. $level++;
  64. }
  65. return $level;
  66. }
  67. }