TalentApi.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. use app\enterprise\model\TalentTypeChange;
  9. /**
  10. * Description of TalentApi
  11. *
  12. * @author sgq
  13. */
  14. class TalentApi {
  15. /**
  16. * 判断是否可以编辑
  17. * @param type $id
  18. * @return boolean
  19. */
  20. public static function checkIsEditable($id) {
  21. $info = Talent::findOrEmpty($id)->toArray();
  22. if ($info["delete"] == 1 || !in_array($info["checkState"], [0, TalentState::FST_SAVE, TalentState::BASE_REVERIFY_PASS, TalentState::SCND_SAVE]))
  23. return false;
  24. return true;
  25. }
  26. static public function chkIsOwner($id, $uid) {
  27. $info = self::getOne($id);
  28. if ($info["enterprise_id"] != $uid)
  29. return null;
  30. return $info;
  31. }
  32. public static function getOne($id) {
  33. $one = Talent::findOrEmpty($id);
  34. return $one;
  35. }
  36. public static function getList($request, $step = 0) {
  37. $order = trim($request->param("order")) ?: "desc";
  38. $offset = trim($request->param("offset")) ?: 0;
  39. $limit = trim($request->param("limit")) ?: 10;
  40. $name = trim($request->param("name"));
  41. $idCard = trim($request->param("card_number"));
  42. $sex = trim($request->param("sex"));
  43. $nation = trim($request->param("nation"));
  44. $nationality = trim($request->param("nationality"));
  45. $talentArrange = trim($request->param("talent_arrange"));
  46. $checkState = trim($request->param("checkState"));
  47. $type = session("user")["type"];
  48. $where = [];
  49. $where[] = ["delete", "=", 0];
  50. if (session("user")["usertype"] == 2) {
  51. $where[] = ["enterprise_id", "=", session("user")["uid"]];
  52. }
  53. //$where[] = ["isImport", "=", $request->param("import") ?: 0];
  54. if ($step) {
  55. switch ($step) {
  56. case 1:
  57. $where[] = ["checkState", "in", [TalentState::FST_SAVE, TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_REJECT, TalentState::BASE_REVERIFY_FAIL, TalentState::BASE_REJECT, TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  58. switch ($checkState) {
  59. case -1:
  60. $where[] = ["checkState", "in", [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL]];
  61. break;
  62. case 1:
  63. $where[] = ["checkState", "=", TalentState::FST_SAVE];
  64. break;
  65. case 2:
  66. $where[] = ["checkState", "in", [TalentState::BASE_REJECT, TalentState::BASE_REVERIFY_REJECT]];
  67. break;
  68. case 3:
  69. $where[] = ["checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_PASS]];
  70. break;
  71. }
  72. break;
  73. case 2:
  74. $where[] = ["checkState", "not in", [TalentState::FST_SAVE, TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_REJECT, TalentState::BASE_REVERIFY_FAIL, TalentState::BASE_REJECT, TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  75. switch ($checkState) {
  76. case -1:
  77. $where[] = ["checkState", "in", [TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL]];
  78. break;
  79. case 1:
  80. $where[] = ["checkState", "=", TalentState::SCND_SAVE];
  81. break;
  82. case 2:
  83. $where[] = ["checkState", "in", [TalentState::FST_VERIFY_REJECT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
  84. break;
  85. case 3:
  86. $where[] = ["checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::REVERIFY_PASS, TalentState::ZX_PASS,
  87. TalentState::ANNOUNCED_REVERIFY_PASS, TalentState::PUBLISH_PASS]];
  88. break;
  89. case 4:
  90. $where[] = ["checkState", "=", TalentState::CERTIFICATED];
  91. break;
  92. }
  93. break;
  94. case 3:
  95. $where[] = ["checkState", "=", TalentState::CERTIFICATED];
  96. break;
  97. }
  98. if ($name) {
  99. $where[] = ["name", "like", "%" . $name . "%"];
  100. }
  101. if ($idCard) {
  102. $where[] = ["card_number", "like", "%" . $idCard . "%"];
  103. }
  104. if ($sex) {
  105. $where[] = ["sex", "=", $sex];
  106. }
  107. if ($nation) {
  108. $where[] = ["nation", "=", $nation];
  109. }
  110. if ($nationality) {
  111. $where[] = ["nationality", "=", $nationality];
  112. }
  113. if ($talentArrange) {
  114. $where[] = ["talent_arrange", "=", $talentArrange];
  115. }
  116. $count = Talent::where($where)->count();
  117. $list = Talent::where($where)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();
  118. $talentTagList = DictApi::selectByParentCode("enterprise_tag"); //单位标签
  119. $talentArangeList = DictApi::selectByParentCode("talent_arrange"); //人才层次
  120. $industries = DictApi::selectByParentCode("industry_field"); //产业
  121. $enterprise = \app\common\model\Enterprise::find(session("user")["uid"]);
  122. foreach ($list as $key => $item) {
  123. $condition = TalentConditionApi::getOne($item["talent_condition"]);
  124. $list[$key]["talentArrangeName"] = isset($talentArangeList[$item["talent_arrange"]]) ? $talentArangeList[$item["talent_arrange"]] : "";
  125. $list[$key]["identifyConditionText"] = $condition["name"];
  126. if (!$item["isMatchZhiren"]) {
  127. $list[$key]["companyIds"] = $condition["companyIds"];
  128. }
  129. $list[$key]["type"] = $enterprise["type"];
  130. $list[$key]["enterpriseName"] = $enterprise["name"];
  131. $list[$key]["industryName"] = $industries[$enterprise["industryFieldNew"]];
  132. $list[$key]["enterpriseTagName"] = $talentTagList[$enterprise["enterpriseTag"]];
  133. $last_log = TalentLogApi::getLastLog($item["id"], 1, 0, ["active", "=", 1]);
  134. $list[$key]["real_state"] = $last_log["state"];
  135. $list[$key]["last_state"] = $last_log["last_state"];
  136. }
  137. return ["total" => $count, "rows" => $list];
  138. }
  139. }
  140. public static function getTypeChangeList($request) {
  141. $order = trim($request->param("order")) ?: "desc";
  142. $offset = trim($request->param("offset")) ?: 0;
  143. $limit = trim($request->param("limit")) ?: 10;
  144. $talentName = trim($request->param("talentName"));
  145. $oldTalentArrange = trim($request->param("oldTalentArrange"));
  146. $newTalentArrange = trim($request->param("newTalentArrange"));
  147. $checkState = trim($request->param("checkState"));
  148. $oldIdentifyCondition = trim($request->param("oldIdentifyCondition"));
  149. $newIdentifyCondition = trim($request->param("newIdentifyCondition"));
  150. $where = [];
  151. $where[] = ["enterpriseId", "=", session("user")["uid"]];
  152. if ($talentName) {
  153. $where[] = ["talentName", "like", "%" . $talentName . "%"];
  154. }
  155. if ($oldTalentArrange) {
  156. $where[] = ["oldTalentArrange", "=", $oldTalentArrange];
  157. }
  158. if ($newTalentArrange) {
  159. $where[] = ["newTalentArrange", "=", $newTalentArrange];
  160. }
  161. if ($checkState) {
  162. $where[] = ["checkState", "=", $checkState];
  163. }
  164. if ($oldIdentifyCondition) {
  165. $where[] = ["oldIdentifyCondition", "=", $oldIdentifyCondition];
  166. }
  167. if ($newIdentifyCondition) {
  168. $where[] = ["newIdentifyCondition", "=", $newIdentifyCondition];
  169. }
  170. $count = TalentTypeChange::where($where)->count();
  171. $list = TalentTypeChange::where($where)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();
  172. $talentArangeList = DictApi::selectByParentCode("talent_arrange"); //人才层次
  173. foreach ($list as $k => $v){
  174. $list[$k]["oldTalentArrangeName"] = array_key_exists($v["oldTalentArrange"],$talentArangeList) ? $talentArangeList[$v["oldTalentArrange"]] : "";
  175. $list[$k]["newTalentArrangeName"] = array_key_exists($v["newTalentArrange"],$talentArangeList) ? $talentArangeList[$v["newTalentArrange"]] : "";
  176. }
  177. return ["total" => $count, "rows" => $list];
  178. }
  179. }