TalentApi.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. namespace app\enterprise\api;
  3. use app\enterprise\model\Talent;
  4. use app\common\api\DictApi;
  5. use app\common\api\TalentConditionApi;
  6. use app\common\api\TalentLogApi;
  7. use app\common\api\TalentState;
  8. /**
  9. * Description of TalentApi
  10. *
  11. * @author sgq
  12. */
  13. class TalentApi {
  14. /**
  15. * 判断是否可以编辑
  16. * @param type $id
  17. * @return boolean
  18. */
  19. public static function checkIsEditable($id) {
  20. $info = Talent::findOrEmpty($id);
  21. if (!$info || !in_array($info["checkState"], [0, 1, 3, 5]))
  22. return false;
  23. return true;
  24. }
  25. public static function getOne($id) {
  26. return Talent::findOrEmpty($id);
  27. }
  28. public static function getList($request, $step = 0) {
  29. $order = trim($request->param("order")) ?: "desc";
  30. $offset = trim($request->param("offset")) ?: 0;
  31. $limit = trim($request->param("limit")) ?: 10;
  32. $name = trim($request->param("name"));
  33. $idCard = trim($request->param("card_number"));
  34. $sex = trim($request->param("sex"));
  35. $nation = trim($request->param("nation"));
  36. $nationality = trim($request->param("nationality"));
  37. $talentArrange = trim($request->param("talent_arrange"));
  38. $checkState = trim($request->param("checkState"));
  39. $type = session("user")["type"];
  40. $where = [];
  41. $where[] = ["delete", "=", 0];
  42. if (session("user")["usertype"] == 2) {
  43. $where[] = ["enterprise_id", "=", session("user")["uid"]];
  44. }
  45. if ($step) {
  46. switch ($step) {
  47. case 1:
  48. $where[] = ["checkState", "in", [TalentState::FST_SAVE, TalentState::BASE_REJECT, TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  49. switch ($checkState) {
  50. case -1:
  51. $where[] = ["checkState", "=", TalentState::BASE_VERIFY_FAIL];
  52. break;
  53. case 1:
  54. $where[] = ["checkState", "=", TalentState::FST_SAVE];
  55. break;
  56. case 2:
  57. $where[] = ["checkState", "=", TalentState::BASE_REJECT];
  58. break;
  59. case 3:
  60. $where[] = ["checkState", "=", TalentState::FST_SUBMIT];
  61. break;
  62. }
  63. break;
  64. case 2:
  65. $where[] = ["checkState", "not in", [TalentState::FST_SAVE, TalentState::BASE_REJECT, TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  66. switch ($checkState) {
  67. case -1:
  68. $where[] = ["checkState", "in", [TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL]];
  69. break;
  70. case 1:
  71. $where[] = ["checkState", "=", TalentState::SCND_SAVE];
  72. break;
  73. case 2:
  74. $where[] = ["checkState", "in", [TalentState::FST_VERIFY_REJECT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
  75. break;
  76. case 3:
  77. $where[] = ["checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::REVERIFY_PASS, TalentState::ZX_PASS,
  78. TalentState::ANNOUNCED_REVERIFY_PASS, TalentState::PUBLISH_PASS]];
  79. break;
  80. case 4:
  81. $where[] = ["checkState", "=", TalentState::CERTIFICATED];
  82. break;
  83. }
  84. }
  85. if ($name) {
  86. $where[] = ["name", "like", "%" . $name . "%"];
  87. }
  88. if ($idCard) {
  89. $where[] = ["card_number", "like", "%" . $idCard . "%"];
  90. }
  91. if ($sex) {
  92. $where[] = ["sex", "=", $sex];
  93. }
  94. if ($nation) {
  95. $where[] = ["nation", "=", $nation];
  96. }
  97. if ($nationality) {
  98. $where[] = ["nationality", "=", $nationality];
  99. }
  100. if ($talentArrange) {
  101. $where[] = ["talent_arrange", "=", $talentArrange];
  102. }
  103. $count = Talent::where($where)->count();
  104. $list = Talent::where($where)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();
  105. $talentTagList = DictApi::selectByParentCode("enterprise_tag"); //单位标签
  106. $talentArangeList = DictApi::selectByParentCode("talent_arrange"); //人才层次
  107. $industries = DictApi::selectByParentCode("industry_field"); //产业
  108. $enterprise = \app\common\model\Enterprise::find(session("user")["uid"]);
  109. foreach ($list as $key => $item) {
  110. $condition = TalentConditionApi::getOne($item["talent_condition"]);
  111. $list[$key]["talentArrangeName"] = isset($talentArangeList[$item["talent_arrange"]]) ? $talentArangeList[$item["talent_arrange"]] : "";
  112. $list[$key]["identifyConditionText"] = $condition["name"];
  113. $list[$key]["companyIds"] = $condition["companyIds"];
  114. $list[$key]["type"] = $enterprise["type"];
  115. $list[$key]["enterpriseName"] = $enterprise["name"];
  116. $list[$key]["industryName"] = $industries[$enterprise["industryFieldNew"]];
  117. $list[$key]["enterpriseTagName"] = $talentTagList[$enterprise["enterpriseTag"]];
  118. $last_log = TalentLogApi::getLastLog($item["id"], 1);
  119. $list[$key]["real_state"] = $last_log["state"];
  120. $list[$key]["last_state"] = $last_log["last_state"];
  121. }
  122. return ["total" => $count, "rows" => $list];
  123. }
  124. }
  125. }