CommonConst.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. $levelAndPoints = [
  21. 1 => 6000,
  22. 2 => 4000,
  23. 3 => 2000,
  24. 4 => 1000,
  25. 5 => 500,
  26. 6 => 200,
  27. 7 => 100,
  28. 8 => 0
  29. ];
  30. return $levelAndPoints[$level];
  31. }
  32. /**
  33. * 通过层次得到层次名
  34. * @param type $level
  35. * @return string
  36. */
  37. public static function getLayerNameByLayer($level) {
  38. $levelAndNames = [
  39. 1 => "第一层次",
  40. 2 => "第二层次",
  41. 3 => "第三层次",
  42. 4 => "第四层次",
  43. 5 => "第五层次",
  44. 6 => "第六层次",
  45. 7 => "第七层次",
  46. 8 => "非优秀人才"
  47. ];
  48. return $levelAndNames[$level];
  49. }
  50. /**
  51. * 通过积分得到层次
  52. * @param type $points
  53. * @return int
  54. */
  55. public static function getLayerByPoints($points) {
  56. $level = 1;
  57. while ($levelPoints = CommonConst::getLayerPointsByLayer($level)) {
  58. if ($points >= $levelPoints) {
  59. break;
  60. }
  61. $level++;
  62. }
  63. return $level;
  64. }
  65. }