TalentApi.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. static public function chkIsOwner($id, $uid) {
  26. $info = self::getOne($id);
  27. if ($info["enterprise_id"] != $uid)
  28. return null;
  29. return $info;
  30. }
  31. public static function getOne($id) {
  32. $one = Talent::findOrEmpty($id);
  33. if ($one["headimgurl"]) {
  34. $one["headimgurl"] = getStoragePath($one["headimgurl"]);
  35. }
  36. return $one;
  37. }
  38. public static function getList($request, $step = 0) {
  39. $order = trim($request->param("order")) ?: "desc";
  40. $offset = trim($request->param("offset")) ?: 0;
  41. $limit = trim($request->param("limit")) ?: 10;
  42. $name = trim($request->param("name"));
  43. $idCard = trim($request->param("card_number"));
  44. $sex = trim($request->param("sex"));
  45. $nation = trim($request->param("nation"));
  46. $nationality = trim($request->param("nationality"));
  47. $talentArrange = trim($request->param("talent_arrange"));
  48. $checkState = trim($request->param("checkState"));
  49. $type = session("user")["type"];
  50. $where = [];
  51. $where[] = ["delete", "=", 0];
  52. if (session("user")["usertype"] == 2) {
  53. $where[] = ["enterprise_id", "=", session("user")["uid"]];
  54. }
  55. if ($step) {
  56. switch ($step) {
  57. case 1:
  58. $where[] = ["checkState", "in", [TalentState::FST_SAVE, TalentState::BASE_REJECT, TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  59. switch ($checkState) {
  60. case -1:
  61. $where[] = ["checkState", "=", TalentState::BASE_VERIFY_FAIL];
  62. break;
  63. case 1:
  64. $where[] = ["checkState", "=", TalentState::FST_SAVE];
  65. break;
  66. case 2:
  67. $where[] = ["checkState", "=", TalentState::BASE_REJECT];
  68. break;
  69. case 3:
  70. $where[] = ["checkState", "=", TalentState::FST_SUBMIT];
  71. break;
  72. }
  73. break;
  74. case 2:
  75. $where[] = ["checkState", "not in", [TalentState::FST_SAVE, TalentState::BASE_REJECT, TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  76. switch ($checkState) {
  77. case -1:
  78. $where[] = ["checkState", "in", [TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL]];
  79. break;
  80. case 1:
  81. $where[] = ["checkState", "=", TalentState::SCND_SAVE];
  82. break;
  83. case 2:
  84. $where[] = ["checkState", "in", [TalentState::FST_VERIFY_REJECT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
  85. break;
  86. case 3:
  87. $where[] = ["checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::REVERIFY_PASS, TalentState::ZX_PASS,
  88. TalentState::ANNOUNCED_REVERIFY_PASS, TalentState::PUBLISH_PASS]];
  89. break;
  90. case 4:
  91. $where[] = ["checkState", "=", TalentState::CERTIFICATED];
  92. break;
  93. }
  94. }
  95. if ($name) {
  96. $where[] = ["name", "like", "%" . $name . "%"];
  97. }
  98. if ($idCard) {
  99. $where[] = ["card_number", "like", "%" . $idCard . "%"];
  100. }
  101. if ($sex) {
  102. $where[] = ["sex", "=", $sex];
  103. }
  104. if ($nation) {
  105. $where[] = ["nation", "=", $nation];
  106. }
  107. if ($nationality) {
  108. $where[] = ["nationality", "=", $nationality];
  109. }
  110. if ($talentArrange) {
  111. $where[] = ["talent_arrange", "=", $talentArrange];
  112. }
  113. $count = Talent::where($where)->count();
  114. $list = Talent::where($where)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();
  115. $talentTagList = DictApi::selectByParentCode("enterprise_tag"); //单位标签
  116. $talentArangeList = DictApi::selectByParentCode("talent_arrange"); //人才层次
  117. $industries = DictApi::selectByParentCode("industry_field"); //产业
  118. $enterprise = \app\common\model\Enterprise::find(session("user")["uid"]);
  119. foreach ($list as $key => $item) {
  120. $condition = TalentConditionApi::getOne($item["talent_condition"]);
  121. $list[$key]["talentArrangeName"] = isset($talentArangeList[$item["talent_arrange"]]) ? $talentArangeList[$item["talent_arrange"]] : "";
  122. $list[$key]["identifyConditionText"] = $condition["name"];
  123. $list[$key]["companyIds"] = $condition["companyIds"];
  124. $list[$key]["type"] = $enterprise["type"];
  125. $list[$key]["enterpriseName"] = $enterprise["name"];
  126. $list[$key]["industryName"] = $industries[$enterprise["industryFieldNew"]];
  127. $list[$key]["enterpriseTagName"] = $talentTagList[$enterprise["enterpriseTag"]];
  128. $last_log = TalentLogApi::getLastLog($item["id"], 1);
  129. $list[$key]["real_state"] = $last_log["state"];
  130. $list[$key]["last_state"] = $last_log["last_state"];
  131. }
  132. return ["total" => $count, "rows" => $list];
  133. }
  134. }
  135. }