TalentApi.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. /**
  8. * Description of TalentApi
  9. *
  10. * @author sgq
  11. */
  12. class TalentApi {
  13. /**
  14. * 判断是否可以编辑
  15. * @param type $id
  16. * @return boolean
  17. */
  18. public static function checkIsEditable($id) {
  19. $info = Talent::findOrEmpty($id);
  20. if (!$info || !in_array($info["checkState"], [0, 1, 3, 5]))
  21. return false;
  22. return true;
  23. }
  24. public static function getOne($id) {
  25. return Talent::findOrEmpty($id);
  26. }
  27. public static function getList($request) {
  28. $order = trim($request->param("order")) ?: "desc";
  29. $offset = trim($request->param("offset")) ?: 0;
  30. $limit = trim($request->param("limit")) ?: 10;
  31. $name = trim($request->param("name"));
  32. $idCard = trim($request->param("card_number"));
  33. $sex = trim($request->param("sex"));
  34. $nation = trim($request->param("nation"));
  35. $nationality = trim($request->param("nationality"));
  36. $talentArrange = trim($request->param("talent_arrange"));
  37. $checkState = trim($request->param("checkState"));
  38. $type = session("user")["type"];
  39. $where = [];
  40. $where[] = ["delete", "=", 0];
  41. if (session("user")["usertype"] == 2) {
  42. $where[] = ["enterprise_id", "=", session("user")["uid"]];
  43. }
  44. if ($name) {
  45. $where[] = ["name", "like", "%" . $name . "%"];
  46. }
  47. if ($idCard) {
  48. $where[] = ["card_number", "like", "%" . $idCard . "%"];
  49. }
  50. if ($sex) {
  51. $where[] = ["sex", $sex];
  52. }
  53. if ($nation) {
  54. $where[] = ["nation", $nation];
  55. }
  56. if ($nationality) {
  57. $where[] = ["nationality", $nationality];
  58. }
  59. if ($talentArrange) {
  60. $where[] = ["talent_arrange", $talentArrange];
  61. }
  62. if ($checkState) {
  63. switch ($checkState) {
  64. case -1:
  65. $where[] = [["checkState", $checkState], ["isPublic", ">=", 5]];
  66. break;
  67. case 1:
  68. $where[] = [["checkState", $checkState]];
  69. break;
  70. case 2:
  71. $where[] = [["checkState", "in", "5,10"]];
  72. break;
  73. case 3:
  74. $where[] = [["checkState", "not in", "1,5,10"], ["isPublic", "<", 5]];
  75. break;
  76. case 4:
  77. $where[] = [["checkState", 35], ["isPublic", ">=", 5]];
  78. break;
  79. }
  80. }
  81. if ($request->param("type") == 2) {
  82. $where[] = [["checkState", 35], ["isPublic", 6]];
  83. }
  84. $count = Talent::where($where)->count();
  85. $list = Talent::where($where)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();
  86. $talentTagList = DictApi::selectByParentCode("enterprise_tag"); //单位标签
  87. $talentArangeList = DictApi::selectByParentCode("talent_arrange"); //人才层次
  88. $enterprise = \app\common\model\Enterprise::find(session("user")["uid"]);
  89. //DictApi::selectByParentCode($code);
  90. foreach ($list as $key => $item) {
  91. $condition = TalentConditionApi::getOne($item["talent_condition"]);
  92. $list[$key]["talentArrangeName"] = isset($talentArangeList[$item["talent_arrange"]]) ? $talentArangeList[$item["talent_arrange"]] : "";
  93. $list[$key]["identifyConditionText"] = $condition["name"];
  94. $list[$key]["companyIds"] = $condition["companyIds"];
  95. $list[$key]["type"] = $enterprise["type"];
  96. $list[$key]["enterpriseTagName"] = $talentTagList[$enterprise["enterpriseTag"]];
  97. $last_log = TalentLogApi::getLastLog($item["id"], 1);
  98. $list[$key]["real_state"] = $last_log["state"];
  99. }
  100. return ["total" => $count, "rows" => $list];
  101. }
  102. }