VerifyApi.php 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317
  1. <?php
  2. namespace app\common\api;
  3. use app\admin\model\Notice as NoticeModel;
  4. use app\enterprise\model\Talent;
  5. use app\common\api\DictApi;
  6. use app\admin\model\Enterprise;
  7. use think\facade\Db;
  8. use app\common\model\TalentCondition;
  9. /**
  10. * Description of VerifyApi
  11. *
  12. * @author sgq
  13. */
  14. class VerifyApi {
  15. public static function getTalentInfoById($id, $isAdmin = false) {//添加admin只为区别导入数据管理端的显示差异
  16. $info = self::getOne($id);
  17. if ($info) {
  18. if ($info["talent_type"]) {
  19. $info["talentTypeName"] = DictApi::selectByParentCode("talent_type")[$info["talent_type"]];
  20. }
  21. if ($info["nationality"]) {
  22. $info["nationalityName"] = DictApi::selectByParentCode("nationality")[$info["nationality"]];
  23. }
  24. if ($info["nation"]) {
  25. $info["nationName"] = DictApi::selectByParentCode("nation")[$info["nation"]];
  26. }
  27. if ($info["politics"]) {
  28. $info["politicsName"] = DictApi::selectByParentCode("politics")[$info["politics"]];
  29. }
  30. if ($info["province"]) {
  31. $info["provinceName"] = Db::table("un_common_location")->where("code", "=", $info["province"])->findOrEmpty()["name"];
  32. }
  33. if ($info["city"]) {
  34. $info["cityName"] = Db::table("un_common_location")->where("code", "=", $info["city"])->findOrEmpty()["name"];
  35. }
  36. if ($info["county"]) {
  37. $info["countyName"] = Db::table("un_common_location")->where("code", "=", $info["county"])->findOrEmpty()["name"];
  38. }
  39. $enterprise = Enterprise::findOrEmpty($info["enterprise_id"])->toArray();
  40. $info["enterpriseName"] = $enterprise["name"];
  41. $info["enterpriseAddress"] = $enterprise["address"];
  42. $info["enterpriseId"] = $enterprise["id"];
  43. $info["enterpriseType"] = $enterprise["type"];
  44. $info["enterpriseEphone"] = $enterprise["ephone"];
  45. $info["enterpriseTag"] = $enterprise["enterpriseTag"];
  46. $info["enterpriseBankCard"] = $enterprise["bankCard"];
  47. $info["enterpriseBankNetwork"] = $enterprise["bankNetwork"];
  48. $info["enterpriseBank"] = $enterprise["bank"];
  49. $info["isGeneral"] = $enterprise["isGeneral"];
  50. $info["medicalCommunityName"] = \app\common\api\Nhc::getMedicalCommunityMap()[$enterprise["medicalCommunityId"]];
  51. if ($enterprise["street"]) {
  52. $info["street"] = $enterprise["street"];
  53. $info["streetName"] = DictApi::selectByParentCode("street")[$enterprise["street"]];
  54. }
  55. if ($enterprise["industryFieldNew"]) {
  56. $info["industryFieldName"] = DictApi::selectByParentCode("industry_field")[$enterprise["industryFieldNew"]];
  57. }
  58. if ($enterprise["enterpriseTag"]) {
  59. $info["enterpriseTagName"] = DictApi::selectByParentCode("enterprise_tag")[$enterprise["enterpriseTag"]];
  60. }
  61. if ($info["talent_arrange"]) {
  62. $info["talentArrangeName"] = DictApi::selectByParentCode("talent_arrange")[$info["talent_arrange"]];
  63. }
  64. if ($info["import_way"]) {
  65. $info["importWayName"] = DictApi::selectByParentCode("import_way")[$info["import_way"]];
  66. }
  67. if ($info["source"]) {
  68. $info["sourceName"] = DictApi::selectByParentCode("source")[$info["source"]];
  69. }
  70. if ($info["source_city"]) {
  71. $info["sourceCityName"] = Db::table("un_common_location")->where("code", "=", $info["source_city"])->findOrEmpty()["name"];
  72. }
  73. if ($info["source_county"]) {
  74. $info["sourceCountyName"] = Db::table("un_common_location")->where("code", "=", $info["source_county"])->findOrEmpty()["name"];
  75. }
  76. if ($info["highest_degree"]) {
  77. $info["highestDegreeName"] = DictApi::selectByParentCode("highest_degree")[$info["highest_degree"]];
  78. }
  79. if ($info["labor_contract_rangetime"]) {
  80. list($startTime, $endTime) = explode(" - ", $info["labor_contract_rangetime"]);
  81. $info["startTime"] = $startTime;
  82. $info["endTime"] = $endTime;
  83. }
  84. if ($info["qz_talent_info"]) {
  85. $qz_talent_info = explode(";", $info["qz_talent_info"]);
  86. list($tmp1, $timeStart) = explode(":", $qz_talent_info[1]);
  87. list($tmp2, $timeEnd) = explode(":", $qz_talent_info[2]);
  88. if (strtotime($timeStart)) {
  89. $tmp_time = date("Y-m-d", strtotime($timeStart));
  90. $qz_talent_info[1] = implode(":", [$tmp1, $tmp_time]);
  91. if ($isAdmin) {
  92. $batch_info = NoticeModel::where('batch', $tmp_time)->find();
  93. if ($batch_info) {
  94. $qz_talent_info[1] = "<a target='_blank' href='/common/notice/view/id/" . $batch_info['id'] . "'>" . $qz_talent_info[1] . "</a>";
  95. }
  96. }
  97. }
  98. if (strtotime($timeEnd)) {
  99. $qz_talent_info[2] = implode(":", [$tmp2, date("Y-m-d", strtotime($timeEnd))]);
  100. }
  101. $info["qz_talent_info"] = implode(";", $qz_talent_info);
  102. }
  103. if ($info["fj_talent_info"]) {
  104. $fj_talent_info = explode(";", $info["fj_talent_info"]);
  105. list($tmp1, $timeStart) = explode(":", $fj_talent_info[0]);
  106. list($tmp2, $validYear) = explode(":", $fj_talent_info[2]);
  107. $timeStart = str_replace(["."], "-", $timeStart);
  108. if (strtotime($timeStart)) {
  109. $tmp_time = date("Y-m-d", strtotime($timeStart));
  110. $fj_talent_info[0] = implode(":", [$tmp1, $tmp_time]);
  111. if ($isAdmin) {
  112. $batch_info = NoticeModel::where('batch', $tmp_time)->find();
  113. if ($batch_info) {
  114. $fj_talent_info[0] = "<a target='_blank' href='/common/notice/view/id/" . $batch_info['id'] . "'>" . $fj_talent_info[0] . "</a>";
  115. }
  116. }
  117. if (strtotime($validYear)) {
  118. $fj_talent_info[2] = implode(":", [$tmp2, date("Y-m-d", strtotime($validYear))]);
  119. } else {
  120. $validval = intval($validYear);
  121. if ($validYear > 0) {
  122. $timestr = str_replace($validval, "", $validYear);
  123. switch ($timestr) {
  124. case "月":
  125. $timetype = "months";
  126. break;
  127. case "日":
  128. $timetype = "days";
  129. break;
  130. default:
  131. $timetype = "years";
  132. break;
  133. }
  134. $fj_talent_info[2] = implode(":", [$tmp2, date("Y-m-d", strtotime("+{$validval} {$timetype} -1 days", strtotime($timeStart)))]);
  135. }
  136. }
  137. }
  138. $info["fj_talent_info"] = implode(";", $fj_talent_info);
  139. }
  140. if ($info["talent_condition"]) {
  141. $talent_condition = \app\common\model\TalentCondition::findOrEmpty($info["talent_condition"]);
  142. $info["talentConditionName"] = $talent_condition["name"];
  143. $info["talent_arrange_category"] = $talent_condition["talentLevelCat"];
  144. $info["talentArrangeCatName"] = DictApi::selectByParentCode("talent_condition_cats")[$talent_condition["talentLevelCat"]];
  145. }
  146. }
  147. return $info;
  148. }
  149. public static function getOne($id) {
  150. return Talent::findOrEmpty($id)->toArray();
  151. }
  152. /**
  153. * 获得新的需要重审的部门集合(如果$oriReCheckCompanyIds为空,返回认定条件审核部门集合$talentConditionCompanyIds)
  154. * @param type $oriReCheckCompanyIds 原来的需要再审核的部门id集合
  155. * @param type $talentConditionCompanyIds 认定条件中的审核部门id集合
  156. * @param type $passedCompanyIds 已经通过审核的部门id集合
  157. * @return type
  158. */
  159. public static function getNewReCheckCompanyIds($oriReCheckCompanyIds, $talentConditionCompanyIds, $passedCompanyIds) {
  160. if ($oriReCheckCompanyIds) {
  161. //$removeReCheckCompanyIds:获得再审核部门中已经被移除的集合(修改认定条件审核部门后,已经不再在列表中的部门Id集合)
  162. $removeReCheckCompanyIds = array_diff($oriReCheckCompanyIds, $talentConditionCompanyIds);
  163. //$reCheckCompanyIds:获得再审核部门中仍需审核的部门集合
  164. $reCheckCompanyIds = array_diff($oriReCheckCompanyIds, $removeReCheckCompanyIds);
  165. //$notInReCheckCompanyIds:不在重审列表里面的审核部门集合(这里面存在新增的审核部门)
  166. $notInReCheckCompanyIds = array_diff($talentConditionCompanyIds, $reCheckCompanyIds);
  167. //$needReCheckCompanyIds:找出不在重审列表里面并且没有在已审核通过的列表中的部门Id集合
  168. $needReCheckCompanyIds = array_diff($notInReCheckCompanyIds, $passedCompanyIds);
  169. //合并新的需要重审的部门集合
  170. $newReCheckCompanyIds = array_unique(array_merge($reCheckCompanyIds, $needReCheckCompanyIds));
  171. return $newReCheckCompanyIds;
  172. }
  173. return $talentConditionCompanyIds;
  174. }
  175. public static function getFullDeptList($params, $where = []) {
  176. $order = $params["order"] ?: "desc";
  177. $offset = $params["offset"] ?: 0;
  178. $limit = $params["limit"] ?: 10;
  179. $whereRaw = "";
  180. if ($params["company_id"]) {
  181. $where[] = ["tc.companyIds", "like", "%" . $params["company_id"] . "%"];
  182. }
  183. switch ($params["checkState"]) {
  184. case 1://待部门并审(首次提交)
  185. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  186. $where[] = ["ti.pass_dept_check", "=", 0];
  187. $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  188. break;
  189. case 2://待部门并审(重新提交)
  190. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  191. $where[] = ["ti.pass_dept_check", "=", 0];
  192. $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  193. break;
  194. case 3://部门并审通过
  195. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_PASS];
  196. break;
  197. case 4://部门并审驳回
  198. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  199. break;
  200. default:
  201. $whereRaw = sprintf("(tl.state=%d and ti.pass_dept_check=0) or (tl.state=%d) or (tl.state=%d)", TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::DEPT_VERIFY_REJECT);
  202. break;
  203. }
  204. $companyId = session("user")["companyId"];
  205. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  206. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  207. $count = Talent::alias("ti")
  208. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  209. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  210. ->leftJoin("(select mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  211. ->leftJoin(sprintf("(select id as resubmit,mainId from new_talent_checklog where state in(%d,%d) and step is null and `type`=1 and `active`=1 group by mainId) as tl2", TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT), "`tl2`.mainId=`ti`.id")
  212. ->where($where)
  213. ->where($whereRaw)->count();
  214. $list = Talent::alias("ti")
  215. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  216. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  217. ->leftJoin("(select mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  218. ->leftJoin(sprintf("(select id as resubmit,mainId from new_talent_checklog where state in(%d,%d) and step is null and `type`=1 and `active`=1 group by mainId) as tl2", TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT), "`tl2`.mainId=`ti`.id")
  219. ->where($where)
  220. ->where($whereRaw)
  221. ->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag,tc.name as talentConditionName,tc.companyIds,tl2.resubmit")
  222. ->limit($offset, $limit)->order("ti.createTime " . $order)
  223. ->select()->toArray();
  224. foreach ($list as &$item) {
  225. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  226. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  227. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  228. $companys = array_filter(explode(",", $item["companyIds"]));
  229. $verifyDepts = [];
  230. foreach ($companys as $k => $companyId) {
  231. $company = getCacheById("Company", $companyId);
  232. $log = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
  233. if (!$log && in_array($item["realState"], [TalentState::DEPT_VERIFY_PASS, TalentState::DEPT_VERIFY_REJECT]))
  234. continue;
  235. $verifyDepts[$k]["id"] = $companyId;
  236. $verifyDepts[$k]["shortName"] = $company["shortName"];
  237. $verifyDepts[$k]["name"] = $company["name"];
  238. $verifyDepts[$k]["code"] = $company["code"];
  239. $verifyDepts[$k]["checkState"] = $log["new_state"];
  240. $verifyDepts[$k]["active"] = $log["active"];
  241. }
  242. $item["verifyDepts"] = $verifyDepts;
  243. }unset($item);
  244. return ["total" => $count, "rows" => $list];
  245. }
  246. public static function getDeptList($params, $where = []) {
  247. $order = $params["order"] ?: "desc";
  248. $offset = $params["offset"] ?: 0;
  249. $limit = $params["limit"] ?: 10;
  250. $companyId = session("user")["companyId"];
  251. $whereRaw = "";
  252. switch ($params["checkState"]) {
  253. case 1://待部门并审(首次提交)
  254. //$where[] = ["tl.active", "=", 0];
  255. //$where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  256. //$where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  257. $whereRaw = sprintf("((tl.active=0 and tl.state=%d) or (tl.active is null)) and tl2.resubmit is null and ti.pass_dept_check=0 and ti.checkState=%d", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS);
  258. break;
  259. case 2://待部门并审(重新提交)
  260. //$where[] = ["tl.active", "=", 0];
  261. //$where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  262. //$where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  263. $whereRaw = sprintf("((tl.active=0 and tl.state=%d) or (tl.active is null)) and tl2.resubmit is not null and ti.pass_dept_check=0 and ti.checkState=%d", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS);
  264. break;
  265. case 3://部门并审通过
  266. $where[] = ["tl.active", "=", 1];
  267. $where[] = ["tl.new_state", "=", TalentState::DEPT_VERIFY_PASS];
  268. break;
  269. case 4://部门并审驳回
  270. $where[] = ["tl.active", "=", 1];
  271. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  272. break;
  273. default:
  274. $whereRaw = sprintf("(((tl.active=0 and tl.state=%d) or (tl.active is null)) and ti.pass_dept_check=0 and ti.checkState=%d) or (tl.active=1 and (tl.new_state in (%d,%d)))", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_PASS);
  275. break;
  276. }
  277. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  278. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  279. $count = Talent::alias("ti")
  280. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  281. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  282. ->leftJoin("(select mainId,active,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,companyId,mainId,`type`)) in (select md5(concat(max(createTime),companyId,mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step`=3 and companyId='{$companyId}' and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  283. ->leftJoin(sprintf("(select id as resubmit,mainId from new_talent_checklog where state in(%d,%d) and step is null and `type`=1 and `active`=1 group by mainId) as tl2", TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT), "`tl2`.mainId=`ti`.id")
  284. ->where($where)
  285. ->where($whereRaw)
  286. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])->count();
  287. $list = Talent::alias("ti")
  288. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  289. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  290. ->leftJoin("(select mainId,active,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,companyId,mainId,`type`)) in (select md5(concat(max(createTime),companyId,mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step`=3 and companyId='{$companyId}' and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  291. ->leftJoin(sprintf("(select id as resubmit,mainId from new_talent_checklog where state in(%d,%d) and step is null and `type`=1 and `active`=1 group by mainId) as tl2", TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT), "`tl2`.mainId=`ti`.id")
  292. ->where($where)
  293. ->where($whereRaw)
  294. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
  295. ->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',tl.new_state as 'newState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag,e.isGeneral,e.medicalCommunityId,tc.name as talentConditionName,tl2.resubmit,tl.active as deptActive")
  296. ->limit($offset, $limit)->order("ti.createTime " . $order)
  297. ->select()->toArray();
  298. $medicalCommunity_kvs = Nhc::getMedicalCommunityMap();
  299. foreach ($list as &$item) {
  300. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  301. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  302. $lastCheckLog = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
  303. $item["deptCheckState"] = $lastCheckLog["new_state"] ?: TalentState::FST_VERIFY_PASS;
  304. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  305. $item["medicalCommunityName"] = $item["medicalCommunityId"] ? $medicalCommunity_kvs[$item["medicalCommunityId"]] : null;
  306. }unset($item);
  307. return ["total" => $count, "rows" => $list];
  308. }
  309. public static function getPublicList($params) {
  310. $order = $params["order"];
  311. $offset = $params["offset"];
  312. $limit = $params["limit"];
  313. $where = [];
  314. $where[] = ["e.type", "=", session("user")["type"]];
  315. if ($params["name"]) {
  316. $where[] = ["ti.name", "like", "%" . $params["name"] . "%"];
  317. }
  318. if ($params["sex"]) {
  319. $where[] = ["ti.sex", "=", $params["sex"]];
  320. }
  321. if ($params["checkState"]) {
  322. $where[] = ["ti.checkState", "=", $params["checkState"]];
  323. }
  324. $type = $params["type"];
  325. switch ($type) {
  326. case 1:
  327. case 2:
  328. $where[] = ["ti.checkState", "=", TalentState::REVERIFY_PASS];
  329. break;
  330. case 3: //公示
  331. case 7: //公示预览
  332. $where[] = ["ti.checkState", "=", TalentState::ZX_PASS];
  333. break;
  334. case 4: //公示通过
  335. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED];
  336. break;
  337. case 5:
  338. case 8: //公布预览
  339. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED_REVERIFY_PASS];
  340. break;
  341. case 6:
  342. $where[] = ["ti.checkState", "=", TalentState::PUBLISH_PASS];
  343. break;
  344. }
  345. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  346. //$count = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->count();
  347. $list = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  348. ->where($where)
  349. //->limit($offset, $limit)
  350. ->order("ti.createTime " . $order)
  351. ->field("ti.*,e.name as enterpriseName,e.type as enterprise_type,enterpriseTag")->select()->toArray();
  352. foreach ($list as &$item) {
  353. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  354. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  355. }unset($item);
  356. return $list;
  357. }
  358. public static function getListByIds($ids) {
  359. $where[] = ["id", "in", $ids];
  360. return Talent::where($where)->select()->toArray();
  361. }
  362. public static function getList($params) {
  363. $where = [];
  364. $order = $params["order"] ?: "desc";
  365. $offset = $params["offset"] ?: 0;
  366. $limit = $params["limit"] ?: 10;
  367. $type = session("user")["type"];
  368. $where[] = ["e.type", "=", $type];
  369. if ($params["name"]) {
  370. $where[] = ["ti.name", "like", "%{$params["name"]}%"];
  371. }
  372. if ($params["card_number"]) {
  373. $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
  374. }
  375. if ($params["sex"]) {
  376. $where[] = ["ti.sex", "=", $params["sex"]];
  377. }
  378. if ($params["nation"]) {
  379. $where[] = ["ti.nation", "=", $params["nation"]];
  380. }
  381. if ($params["apply_year"]) {
  382. $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
  383. }
  384. if ($params["phone"]) {
  385. $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
  386. }
  387. if ($params["email"]) {
  388. $where[] = ["ti.email", "like", "%{$params["email"]}%"];
  389. }
  390. if ($params["nationality"]) {
  391. $where[] = ["ti.nationality", "=", $params["nationality"]];
  392. }
  393. if ($params["province"]) {
  394. $where[] = ["ti.province", "=", $params["province"]];
  395. }
  396. if ($params["politics"]) {
  397. $where[] = ["ti.politics", "=", $params["politics"]];
  398. }
  399. if ($params["enterprise_id"]) {
  400. $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
  401. }
  402. if ($params["medicalCommunityId"]) {
  403. $where[] = ["e.medicalCommunityId", "=", $params["medicalCommunityId"]];
  404. }
  405. if ($params["isGeneral"]) {
  406. $where[] = ["e.isGeneral", "=", $params["isGeneral"]];
  407. }
  408. if ($params["street"]) {
  409. $where[] = ["e.street", "=", $params["street"]];
  410. }
  411. if ($params["industry_field"]) {
  412. $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
  413. }
  414. if ($params["industry_field_old"]) {
  415. $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
  416. }
  417. if ($params["enterprise_tag"]) {
  418. $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
  419. }
  420. if ($params["talent_type"]) {
  421. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  422. }
  423. if ($params["import_way"]) {
  424. $where[] = ["ti.import_way", "=", $params["import_way"]];
  425. }
  426. if ($params["highest_degree"]) {
  427. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  428. }
  429. if ($params["study_abroad"]) {
  430. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  431. }
  432. if ($params["source"]) {
  433. $where[] = ["ti.source", "=", $params["source"]];
  434. }
  435. if ($params["talent_arrange"]) {
  436. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  437. }
  438. if ($params["talent_condition"]) {
  439. $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
  440. }
  441. if ($params["isMatchZhiren"]) {
  442. $params["isMatchZhiren"] = $params["isMatchZhiren"] == 1 ?: 0;
  443. $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
  444. }
  445. if ($params["active"]) {
  446. $where[] = ["ti.active", "=", $params["active"]];
  447. }
  448. if ($params["breakFaith"]) {
  449. $where[] = ["ti.break_faith", "=", $params["breakFaith"]];
  450. }
  451. $process = $params["process"];
  452. if ($process == 4) {
  453. if (self::chkUserInSuperDeptUsers()) {
  454. return self::getFullDeptList($params, $where);
  455. } else {
  456. return self::getDeptList($params, $where);
  457. }
  458. }
  459. if ($process == 5) {
  460. $whereRaw = sprintf("(tl.state in (-14,14,15,16)) or (tl.state=12 and ti.pass_dept_check=0) or (tl.state=10 and ti.pass_dept_check=1) or (tl.state=10 and (tc.companyIds is null or tc.companyIds = ''))");
  461. switch ($params["checkState"]) {
  462. case 1://待复审(首次提交)
  463. $where[] = ["tl.state", "in", [TalentState::REVERIFY_CANCEL, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  464. $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  465. break;
  466. case 2://待复审(重新提交)
  467. $where[] = ["tl.state", "in", [TalentState::REVERIFY_CANCEL, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  468. $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  469. break;
  470. case 3://复审通过
  471. $where[] = ["tl.state", "=", TalentState::REVERIFY_PASS];
  472. break;
  473. case 4://复审驳回
  474. $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
  475. break;
  476. case 5://复审不通过
  477. $where[] = ["tl.state", "=", TalentState::REVERIFY_FAIL];
  478. break;
  479. default:
  480. if ($type == 2) {
  481. $where[] = ["tl.state", "in", [TalentState::REVERIFY_CANCEL, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  482. }
  483. break;
  484. }
  485. $count = Talent::alias("ti")
  486. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  487. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  488. ->leftJoin("(select mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  489. ->leftJoin("(select id as resubmit,mainId from new_talent_checklog where state=" . TalentState::REVERIFY_REJECT . " and `type`=1 and `active`=1 group by mainId) as tl2", "`tl2`.mainId=`ti`.id")
  490. ->whereRaw($whereRaw)->where($where)->count();
  491. $list = Talent::alias("ti")
  492. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  493. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  494. ->leftJoin("(select mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  495. ->leftJoin("(select id as resubmit,mainId from new_talent_checklog where state=" . TalentState::REVERIFY_REJECT . " and `type`=1 and `active`=1 group by mainId) as tl2", "`tl2`.mainId=`ti`.id")
  496. ->whereRaw($whereRaw)
  497. ->where($where)
  498. ->limit($offset, $limit)
  499. ->order("ti.createTime " . $order)
  500. ->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag,e.isGeneral,e.medicalCommunityId,tl2.resubmit")
  501. ->select()->toArray();
  502. } else {
  503. switch ($process) {
  504. case 1:
  505. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  506. break;
  507. case 2:
  508. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  509. break;
  510. case 3:
  511. switch ($params["checkState"]) {
  512. case 1://保存未提交
  513. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  514. $where[] = ["tl.state", "=", TalentState::SCND_SAVE];
  515. $where[] = ["ti.delete", "=", 0];
  516. break;
  517. case 2://初审驳回
  518. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  519. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_REJECT];
  520. $where[] = ["ti.delete", "=", 0];
  521. break;
  522. case 3://待初审(首次提交)
  523. $where[] = ["tl.last_state", "<>", TalentState::FST_VERIFY_REJECT];
  524. $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
  525. $where[] = ["ti.delete", "=", 0];
  526. break;
  527. case 4://待初审(重新提交)
  528. $where[] = ["tl.last_state", "=", TalentState::FST_VERIFY_REJECT];
  529. $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
  530. $where[] = ["ti.delete", "=", 0];
  531. break;
  532. case 5://待初审(部门并审驳回)
  533. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  534. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  535. $where[] = ["ti.delete", "=", 0];
  536. break;
  537. case 6://待初审(复审驳回)
  538. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  539. $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
  540. $where[] = ["ti.delete", "=", 0];
  541. break;
  542. case 7://初审通过(待部门并审)
  543. $where[] = ["ti.pass_dept_check", "=", 0];
  544. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  545. $where[] = ["ti.delete", "=", 0];
  546. break;
  547. case 8://初审通过(待复审)
  548. $where[] = ["ti.pass_dept_check", "=", 1];
  549. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  550. $where[] = ["ti.delete", "=", 0];
  551. break;
  552. case 9://初审不通过
  553. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_FAIL];
  554. $where[] = ["ti.delete", "=", 0];
  555. break;
  556. default:
  557. //$whereRaw = sprintf("((tl.new_state=%d and ti.`delete`=0) or tl.new_state=%d or tl.state in (%d,%d) or tl.state>%d)", TalentState::SCND_SAVE, TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_FAIL, TalentState::FST_VERIFY_REJECT);
  558. if ($type == 2) {
  559. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_REJECT, TalentState::SCND_SUBMIT,
  560. TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
  561. $where[] = ["ti.delete", "=", 0];
  562. } else {
  563. $where[] = ["tl.state", "in", [TalentState::SCND_SAVE, TalentState::FST_VERIFY_REJECT, TalentState::SCND_SUBMIT,
  564. TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_FAIL]];
  565. $where[] = ["ti.delete", "=", 0];
  566. }
  567. }
  568. break;
  569. case 6:
  570. $where[] = ["tl.state", ">=", TalentState::REVERIFY_PASS];
  571. $where[] = ["tl.state", "not in", [TalentState::REVERIFY_REJECT, TalentState::REVERIFY_FAIL]];
  572. if ($params["checkState"]) {
  573. $where[] = ["tl.state", "=", $params["checkState"]];
  574. }
  575. break;
  576. case 7:
  577. $where[] = ["tl.state", "=", TalentState::CERTIFICATED];
  578. break;
  579. }
  580. $count = Talent::alias("ti")
  581. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  582. ->leftJoin("(select mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  583. //->leftJoin("(select mainId,last_state,new_state,state,createTime,row_number() over (partition by mainId order by createTime desc) as rowIndex from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null) tl", "tl.mainId=ti.id and tl.rowIndex=1")
  584. ->where($where)->where($whereRaw)->count();
  585. $list = Talent::alias("ti")
  586. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  587. ->leftJoin("(select mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  588. //->leftJoin("(select mainId,last_state,new_state,state,createTime,row_number() over (partition by mainId order by createTime desc) as rowIndex from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null) tl", "tl.mainId=ti.id and tl.rowIndex=1")
  589. ->where($where)->where($whereRaw)->limit($offset, $limit)->order("ti.createTime " . $order)->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag,e.isGeneral,e.medicalCommunityId")->select()->toArray();
  590. }
  591. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  592. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  593. $medicalCommunity_kvs = Nhc::getMedicalCommunityMap();
  594. foreach ($list as &$item) {
  595. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  596. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  597. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  598. $item["talentConditionName"] = TalentCondition::findOrEmpty($item["talent_condition"])["name"];
  599. $item["medicalCommunityName"] = $item["medicalCommunityId"] ? $medicalCommunity_kvs[$item["medicalCommunityId"]] : null;
  600. //$last_log = TalentLogApi::getLastLog($item["id"], 1, 0, ["step", "=", null]);
  601. //$item["lastState"] = $last_log["last_state"];
  602. //$item["realState"] = $last_log["state"];
  603. }unset($item);
  604. return ["total" => $count, "rows" => $list];
  605. }
  606. public static function getExportDatas($process, $params) {
  607. $where[] = [];
  608. //特殊字段处理
  609. $exportFields = $params["export"];
  610. $fields = [];
  611. foreach ($exportFields as $field) {
  612. if (!in_array($field, ["industryFieldNew", "enterpriseName", "enterpriseTag", "street", "talent_arrange_category", "checkMsg", "breakFaithName", "activeName"])) {
  613. $fields[] = "ti." . $field;
  614. }
  615. }
  616. $fields[] = "e.name as enterpriseName";
  617. $fields[] = "e.industryFieldNew";
  618. $fields[] = "e.enterpriseTag";
  619. $fields[] = "e.street";
  620. $fields[] = "tc.talentLevelCat";
  621. $fields[] = "tl.description as checkMsg";
  622. $fields[] = "tc.name as talentConditionName";
  623. $fields[] = "tl.description as checkMsg";
  624. $fields[] = "if(ti.break_faith=1,'是','否') as breakFaithName";
  625. $fields[] = "if(ti.active=2,'离职','在职') as activeName";
  626. if (in_array("card_type", $exportFields)) {
  627. $cardTypes = DictApi::selectByParentCode("card_type");
  628. }
  629. if (in_array("industryFieldNew", $exportFields)) {
  630. $industry_fields = DictApi::selectByParentCode("industry_field");
  631. }
  632. if (in_array("enterpriseTag", $exportFields)) {
  633. $enterpriseTags = DictApi::selectByParentCode("enterprise_tag");
  634. }
  635. if (in_array("street", $exportFields)) {
  636. $streets = DictApi::selectByParentCode("street");
  637. }
  638. if (in_array("nation", $exportFields)) {
  639. $nations = DictApi::selectByParentCode("nation");
  640. }
  641. if (in_array("nationality", $exportFields)) {
  642. $nationalitys = DictApi::selectByParentCode("nationality");
  643. }
  644. if (in_array("politics", $exportFields)) {
  645. $politics = DictApi::selectByParentCode("politics");
  646. }
  647. if (in_array("talent_type", $exportFields)) {
  648. $talentTypes = DictApi::selectByParentCode("talent_type");
  649. }
  650. if (in_array("talent_arrange_category", $exportFields)) {
  651. $talentArrangeCategories = DictApi::selectByParentCode("talent_condition_cats");
  652. }
  653. if (in_array("highest_degree", $exportFields)) {
  654. $highest_degree = DictApi::selectByParentCode("highest_degree");
  655. }
  656. if (in_array("import_way", $exportFields)) {
  657. $import_way = DictApi::selectByParentCode("import_way");
  658. }
  659. if (in_array("source", $exportFields)) {
  660. $source = DictApi::selectByParentCode("source");
  661. }
  662. if (in_array("source_city", $exportFields)) {
  663. $source_city = DictApi::selectByParentCode("source_city");
  664. }
  665. if (in_array("source_county", $exportFields)) {
  666. $source_county = DictApi::selectByParentCode("source_county");
  667. }
  668. if (in_array("talent_arrange", $exportFields)) {
  669. $talent_arrange = DictApi::selectByParentCode("talent_arrange");
  670. }
  671. $sex = [1 => "男", 2 => "女"];
  672. $pre_import_type = [1 => "意向合同", 2 => "创业企业名称预核准"];
  673. $study_abroad = [1 => "是", 2 => "否"];
  674. $salary_pay_way = [1 => "本单位", 2 => "本单位所属集团公司及权属公司"];
  675. $return = [1 => "是", 2 => "否"];
  676. $isMatchZhiren = [0 => "否", 1 => "是"];
  677. $where = [];
  678. $whereRaw = "";
  679. $user = session("user");
  680. if ($user["usertype"] == 1) {
  681. $where[] = ["e.type", "=", $user["type"]];
  682. } else if ($user["usertype"] == 2) {
  683. $where[] = ["e.id", "=", $user["uid"]];
  684. } else {
  685. }
  686. if ($params["all"] != 1) {
  687. if ($params["name"]) {
  688. $where[] = ["ti.name", "like", "%{$params["name"]}%"];
  689. }
  690. if ($params["card_number"]) {
  691. $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
  692. }
  693. if ($params["sex"]) {
  694. $where[] = ["ti.sex", "=", $params["sex"]];
  695. }
  696. if ($params["nation"]) {
  697. $where[] = ["ti.nation", "=", $params["nation"]];
  698. }
  699. if ($params["apply_year"]) {
  700. $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
  701. }
  702. if ($params["phone"]) {
  703. $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
  704. }
  705. if ($params["email"]) {
  706. $where[] = ["ti.email", "like", "%{$params["email"]}%"];
  707. }
  708. if ($params["nationality"]) {
  709. $where[] = ["ti.nationality", "=", $params["nationality"]];
  710. }
  711. if ($params["province"]) {
  712. $where[] = ["ti.province", "=", $params["province"]];
  713. }
  714. if ($params["politics"]) {
  715. $where[] = ["ti.politics", "=", $params["politics"]];
  716. }
  717. if ($params["enterprise_id"]) {
  718. $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
  719. }
  720. if ($params["street"]) {
  721. $where[] = ["e.street", "=", $params["street"]];
  722. }
  723. if ($params["industry_field"]) {
  724. $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
  725. }
  726. if ($params["industry_field_old"]) {
  727. $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
  728. }
  729. if ($params["enterprise_tag"]) {
  730. $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
  731. }
  732. if ($params["talent_type"]) {
  733. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  734. }
  735. if ($params["import_way"]) {
  736. $where[] = ["ti.import_way", "=", $params["import_way"]];
  737. }
  738. if ($params["highest_degree"]) {
  739. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  740. }
  741. if ($params["study_abroad"]) {
  742. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  743. }
  744. if ($params["source"]) {
  745. $where[] = ["ti.source", "=", $params["source"]];
  746. }
  747. if ($params["talent_arrange"]) {
  748. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  749. }
  750. if ($params["talent_condition"]) {
  751. $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
  752. }
  753. if ($params["isMatchZhiren"]) {
  754. $params["isMatchZhiren"] = $params["isMatchZhiren"] == 1 ?: 0;
  755. $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
  756. }
  757. if ($params["active"]) {
  758. $where[] = ["ti.active", "=", $params["active"]];
  759. }
  760. if ($params["breakFaith"]) {
  761. $where[] = ["ti.break_faith", "=", $params["breakFaith"]];
  762. }
  763. if ($params["company_id"]) {
  764. $where[] = ["tc.companyIds", "like", "%" . $params["company_id"] . "%"];
  765. }
  766. switch ($process) {
  767. case 1:
  768. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  769. break;
  770. case 2:
  771. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  772. break;
  773. case 3:
  774. switch ($params["checkState"]) {
  775. case 1://保存未提交
  776. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  777. $where[] = ["tl.state", "=", TalentState::SCND_SAVE];
  778. $where[] = ["ti.delete", "=", 0];
  779. break;
  780. case 2://初审驳回
  781. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  782. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_REJECT];
  783. break;
  784. case 3://待初审(首次提交)
  785. $where[] = ["tl.last_state", "<>", TalentState::FST_VERIFY_REJECT];
  786. $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
  787. break;
  788. case 4://待初审(重新提交)
  789. $where[] = ["tl.last_state", "=", TalentState::FST_VERIFY_REJECT];
  790. $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
  791. break;
  792. case 5://待初审(部门并审驳回)
  793. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  794. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  795. break;
  796. case 6://待初审(复审驳回)
  797. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  798. $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
  799. break;
  800. case 7://初审通过(待部门并审)
  801. $where[] = ["ti.pass_dept_check", "=", 0];
  802. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  803. break;
  804. case 8://初审通过(待复审)
  805. $where[] = ["ti.pass_dept_check", "=", 1];
  806. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  807. break;
  808. case 9://初审不通过
  809. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_FAIL];
  810. break;
  811. default:
  812. $where[] = ["tl.state", "in", [TalentState::SCND_SAVE, TalentState::FST_VERIFY_REJECT, TalentState::SCND_SUBMIT,
  813. TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_FAIL]];
  814. $where[] = ["ti.delete", "=", 0];
  815. }
  816. break;
  817. case 4:
  818. $companyId = session('user')['companyId'];
  819. $company_info = CompanyApi::getOne($companyId);
  820. if (self::chkUserInSuperDeptUsers()) {
  821. switch ($params["checkState"]) {
  822. case 1:
  823. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  824. $where[] = ["ti.pass_dept_check", "=", 0];
  825. $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  826. break;
  827. case 2:
  828. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  829. $where[] = ["ti.pass_dept_check", "=", 0];
  830. $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  831. break;
  832. case 3:
  833. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_PASS];
  834. break;
  835. case 4:
  836. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  837. break;
  838. default:
  839. $whereRaw = sprintf("(tl.state=%d and ti.pass_dept_check=0) or (tl.state=%d) or (tl.state=%d)", TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::DEPT_VERIFY_REJECT);
  840. break;
  841. }
  842. } else {
  843. switch ($params["checkState"]) {
  844. case 1://待部门并审(首次提交)
  845. //$where[] = ["tl.active", "=", 0];
  846. //$where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  847. //$where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  848. $whereRaw = sprintf("((tl.active=0 and tl.state=%d) or (tl.active is null)) and tl2.resubmit is null and ti.pass_dept_check=0 and ti.checkState=%d", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS);
  849. break;
  850. case 2://待部门并审(重新提交)
  851. //$where[] = ["tl.active", "=", 0];
  852. //$where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  853. //$where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  854. $whereRaw = sprintf("((tl.active=0 and tl.state=%d) or (tl.active is null)) and tl2.resubmit is not null and ti.pass_dept_check=0 and ti.checkState=%d", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS);
  855. break;
  856. case 3://部门并审通过
  857. $where[] = ["tl.active", "=", 1];
  858. $where[] = ["tl.new_state", "=", TalentState::DEPT_VERIFY_PASS];
  859. break;
  860. case 4://部门并审驳回
  861. $where[] = ["tl.active", "=", 1];
  862. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  863. break;
  864. default:
  865. $whereRaw = sprintf("(((tl.active=0 and tl.state=%d) or (tl.active is null)) and ti.pass_dept_check=0 and ti.checkState=%d) or (tl.active=1 and (tl.new_state in (%d,%d)))", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_PASS);
  866. break;
  867. }
  868. }
  869. break;
  870. case 5:
  871. $whereRaw = sprintf("(tl.state in (-14,14,15,16)) or (tl.state=12 and ti.pass_dept_check=0) or (tl.state=10 and ti.pass_dept_check=1) or (tl.state=10 and (tc.companyIds is null or tc.companyIds = ''))");
  872. switch ($params["checkState"]) {
  873. case 1://待复审(首次提交)
  874. $where[] = ["tl.state", "in", [TalentState::REVERIFY_CANCEL, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  875. $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  876. break;
  877. case 2://待复审(重新提交)
  878. $where[] = ["tl.state", "in", [TalentState::REVERIFY_CANCEL, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  879. $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  880. break;
  881. case 3://复审通过
  882. $where[] = ["tl.state", "=", TalentState::REVERIFY_PASS];
  883. break;
  884. case 4://复审驳回
  885. $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
  886. break;
  887. case 5://复审不通过
  888. $where[] = ["tl.state", "=", TalentState::REVERIFY_FAIL];
  889. break;
  890. }
  891. break;
  892. case 6:
  893. $where[] = ["tl.state", ">=", TalentState::REVERIFY_PASS];
  894. if ($params["checkState"]) {
  895. $where[] = ["tl.state", "=", $params["checkState"]];
  896. }
  897. break;
  898. case 7:
  899. $where[] = ["tl.state", "=", TalentState::CERTIFICATED];
  900. break;
  901. }
  902. } else {
  903. $whereRaw = "tl.state is not null";
  904. $where[] = ["ti.delete", "=", 0];
  905. }
  906. $fields[] = "ti.id";
  907. $fields[] = "ti.pass_dept_check";
  908. $fields[] = "tl.state";
  909. $fields[] = "tl.new_state";
  910. $fields[] = "tl.last_state";
  911. $fields[] = "tc.companyIds";
  912. if ($process == 4) {
  913. $fields[] = "tl2.resubmit";
  914. if (self::chkUserInSuperDeptUsers()) {
  915. $fields[] = "tl3.deptVerifyJsonData";
  916. $list = Talent::alias("ti")
  917. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  918. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  919. ->leftJoin("(select mainId,description,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  920. ->leftJoin(sprintf("(select id as resubmit,mainId from new_talent_checklog where state in(%d,%d) and step is null and `type`=1 and `active`=1 group by mainId) as tl2", TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT), "`tl2`.mainId=`ti`.id")
  921. ->leftJoin("(select mainId,JSON_ARRAYAGG(JSON_OBJECT('companyId',companyId,'active',`active`,'description',`description`,'new_state',`new_state`,'createTime',unix_timestamp(`createTime`))) as deptVerifyJsonData from new_talent_checklog where `step`=3 and `type`=1 group by mainId) as tl3", "tl3.mainId=ti.`id`")
  922. ->where($where)
  923. ->where($whereRaw)
  924. ->field($fields)
  925. ->select()->toArray();
  926. } else {
  927. $fields[] = "tl.active";
  928. $fields[] = "if(tl.new_state,tl.new_state,10) as deptCheckState";
  929. $fields[] = "tl.createTime as first_dept_check_time";
  930. $list = Talent::alias("ti")
  931. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  932. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  933. ->leftJoin("(select mainId,active,description,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,companyId,mainId,`type`)) in (select md5(concat(max(createTime),companyId,mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step`=3 and companyId='{$companyId}' and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  934. ->leftJoin(sprintf("(select id as resubmit,mainId from new_talent_checklog where state in(%d,%d) and step is null and `type`=1 and `active`=1 group by mainId) as tl2", TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT), "`tl2`.mainId=`ti`.id")
  935. ->where($where)
  936. ->where($whereRaw)
  937. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
  938. ->field($fields)
  939. ->select()->toArray();
  940. }
  941. } else if ($process == 5) {
  942. $fields[] = "tl2.resubmit";
  943. $list = Talent::alias("ti")
  944. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  945. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  946. ->leftJoin("(select description,mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  947. ->leftJoin("(select id as resubmit,mainId from new_talent_checklog where state=" . TalentState::REVERIFY_REJECT . " and `type`=1 and `active`=1 group by mainId) as tl2", "`tl2`.mainId=`ti`.id")
  948. ->where($whereRaw)
  949. ->where($where)
  950. ->field($fields)
  951. ->select()->toArray();
  952. } else {
  953. $list = Talent::alias("ti")
  954. ->field($fields)
  955. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  956. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  957. ->leftJoin("(select description,mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  958. //->leftJoin("new_talent_checklog tl", "tl.mainId=ti.id and tl.id=(select id from new_talent_checklog where mainId=ti.id and `step` is null and active=1 and typeFileId is null order by createTime desc limit 1)")
  959. ->where($where)
  960. ->where($whereRaw)
  961. ->select()->toArray();
  962. }
  963. $un_common_location = Db::table("un_common_location")->column('name', 'code');
  964. foreach ($list as &$item) {
  965. $item["card_type"] = $cardTypes[$item["card_type"]];
  966. $item["industryFieldNew"] = $industry_fields[$item["industryFieldNew"]];
  967. $item["enterpriseTag"] = $enterpriseTags[$item["enterpriseTag"]];
  968. $item["street"] = $streets[$item["street"]];
  969. $item["nation"] = $nations[$item["nation"]];
  970. $item["nationality"] = $nationalitys[$item["nationality"]];
  971. $item["politics"] = $politics[$item["politics"]];
  972. $item["talent_type"] = $talentTypes[$item["talent_type"]];
  973. $item["talent_arrange_category"] = $talentArrangeCategories[$item["talentLevelCat"]];
  974. $item["sex"] = $sex[$item["sex"]];
  975. $item["highest_degree"] = $highest_degree[$item["highest_degree"]];
  976. $item["import_way"] = $import_way[$item["import_way"]];
  977. $item["salary_pay_way"] = $salary_pay_way[$item["salary_pay_way"]];
  978. $item["pre_import_type"] = $pre_import_type[$item["pre_import_type"]];
  979. $item["return"] = $return[$item["return"]];
  980. $item["isMatchZhiren"] = $isMatchZhiren[$item["isMatchZhiren"]];
  981. $item["study_abroad"] = $study_abroad[$item["study_abroad"]];
  982. $item["source"] = $source[$item["source"]];
  983. $item["talent_arrange"] = $talent_arrange[$item["talent_arrange"]];
  984. $item["talent_condition"] = $item["checkState"] == TalentState::CERTIFICATED && !$item["talent_condition"] ? "积分认定" : $item["talentConditionName"];
  985. if (in_array("source_city", $exportFields)) {
  986. $item["source_city"] = $un_common_location[$item["source_city"]];
  987. }
  988. if (in_array("source_county", $exportFields)) {
  989. $item["source_county"] = $un_common_location[$item["source_county"]];
  990. }
  991. if (in_array("province", $exportFields)) {
  992. $item["province"] = $un_common_location[$item["province"]];
  993. }
  994. if (in_array("city", $exportFields)) {
  995. $item["city"] = $un_common_location[$item["city"]];
  996. }
  997. if (in_array("county", $exportFields)) {
  998. $item["county"] = $un_common_location[$item["county"]];
  999. }
  1000. if ($item["state"] == TalentState::SCND_SUBMIT) {
  1001. if ($item["last_state"] == TalentState::FST_VERIFY_REJECT) {
  1002. $item["checkState"] = "待初审(重新提交)";
  1003. } else {
  1004. $item["checkState"] = "待初审(首次提交)";
  1005. }
  1006. } else if ($item["state"] == TalentState::FST_VERIFY_PASS || (!$item["state"] && $item["deptCheckState"])) {
  1007. if ($item["deptCheckState"]) {
  1008. if (($item["acitve"] == 0 && $item["state"] == TalentState::FST_VERIFY_PASS) || !$item["active"]) {
  1009. if ($item["resubmit"]) {
  1010. $item["checkState"] = "待部门并审(重新提交)";
  1011. } else {
  1012. $item["checkState"] = "待部门并审(首次提交)";
  1013. }
  1014. }
  1015. if ($item["active"] == 1 && $item["new_state"] == TalentState::DEPT_VERIFY_PASS) {
  1016. $item["checkState"] = "部门并审通过";
  1017. }
  1018. if ($item["active"] == 1 && $item["new_state"] == TalentState::SCND_SUBMIT) {
  1019. $item["checkState"] = "部门并审驳回";
  1020. }
  1021. } else {
  1022. if (!$item["companyIds"] || $item["pass_dept_check"] == 1) {
  1023. if ($process == 3) {
  1024. $item["checkState"] = "初审通过(待复审)";
  1025. } else {
  1026. if ($item["resubmit"]) {
  1027. $item["checkState"] = "待复审(重新提交)";
  1028. } else {
  1029. $item["checkState"] = "待复审(首次提交)";
  1030. }
  1031. }
  1032. }
  1033. if ($item["pass_dept_check"] == 0) {
  1034. if ($process == 3) {
  1035. $item["checkState"] = "初审通过(待部门并审)";
  1036. } else {
  1037. if ($item["resubmit"]) {
  1038. $item["checkState"] = "待部门并审(重新提交)";
  1039. } else {
  1040. $item["checkState"] = "待部门并审(首次提交)";
  1041. }
  1042. }
  1043. }
  1044. }
  1045. } else if ($item["state"] == TalentState::DEPT_VERIFY_REJECT) {
  1046. if ($process == 3) {
  1047. $item["checkState"] = "待初审(部门并审驳回)";
  1048. } else {
  1049. $item["checkState"] = "部门并审驳回";
  1050. }
  1051. } else if ($item["state"] == TalentState::DEPT_VERIFY_PASS) {
  1052. if ($process == 3) {
  1053. $item["checkState"] = "待复审(部门并审通过)";
  1054. } else if ($process == 4) {
  1055. $item["checkState"] = "部门并审通过";
  1056. } else {
  1057. if ($item["resubmit"]) {
  1058. $item["checkState"] = "待复审(重新提交)";
  1059. } else {
  1060. $item["checkState"] = "待复审(首次提交)";
  1061. }
  1062. }
  1063. } else if ($item["state"] == TalentState::REVERIFY_REJECT) {
  1064. if ($process == 3) {
  1065. $item["checkState"] = "待初审(复审驳回)";
  1066. } else {
  1067. $item["checkState"] = "复审驳回";
  1068. }
  1069. } else {
  1070. $item["checkState"] = TalentState::getStateName($item["state"]);
  1071. }
  1072. if ($process == 4) {
  1073. if (self::chkUserInSuperDeptUsers()) {
  1074. $companys = array_filter(explode(",", $item["companyIds"]));
  1075. $deptChecklogs = json_decode($item["deptVerifyJsonData"], true);
  1076. $deptChecklogs = bubbleSort($deptChecklogs, "createTime", "desc");
  1077. $verifyDepts = [];
  1078. $item["deptReject"] = 0;
  1079. $item["deptPass"] = 0;
  1080. $item["deptWait"] = 0;
  1081. $deptDescriptions = [];
  1082. foreach ($companys as $k => $companyId) {
  1083. $company = getCacheById("Company", $companyId);
  1084. //$log = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
  1085. $i = 0;
  1086. while ($log = $deptChecklogs[$i]) {
  1087. if ($log["companyId"] == $companyId) {
  1088. break;
  1089. } else {
  1090. $log = null;
  1091. }
  1092. $i++;
  1093. }
  1094. $item["first_dept_check_time"] = date("Y-m-d H:i:s", $log["createTime"]);
  1095. $verifyDepts[$k] = $company["name"];
  1096. if ($log["active"] == 1) {
  1097. if ($log["new_state"] == 9) {
  1098. $verifyDepts[$k] .= "(审核驳回)";
  1099. $item["deptReject"]++;
  1100. }
  1101. if ($log["new_state"] == 12) {
  1102. $verifyDepts[$k] .= "(审核通过)";
  1103. $item["deptPass"]++;
  1104. }
  1105. $deptDescriptions[] = sprintf("%s:%s", $company["name"], $log["description"]);
  1106. } else {
  1107. if (!$log && in_array($item["state"], [TalentState::DEPT_VERIFY_PASS, TalentState::DEPT_VERIFY_REJECT])) {
  1108. unset($verifyDepts[$k]);
  1109. continue;
  1110. }
  1111. $verifyDepts[$k] .= "(待审核)";
  1112. $item["deptWait"]++;
  1113. }
  1114. }
  1115. $item["verifyDepts"] = implode(chr(10), $verifyDepts);
  1116. $item["deptDescription"] = implode(chr(10), $deptDescriptions);
  1117. } else {
  1118. $item["checkMsg"] = $item["active"] == 1 ? $item["checkMsg"] : "等待部门审核";
  1119. }
  1120. }
  1121. }unset($item);
  1122. return $list;
  1123. }
  1124. public static function getListByProcess($params) {
  1125. $process = $params["process"];
  1126. $type = session("user")["type"];
  1127. $where[] = ["e.type", "=", $type];
  1128. if ($params["name"]) {
  1129. $where[] = ["ti.name", "like", "%{$params["name"]}%"];
  1130. }
  1131. if ($params["card_number"]) {
  1132. $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
  1133. }
  1134. if ($params["sex"]) {
  1135. $where[] = ["ti.sex", "=", $params["sex"]];
  1136. }
  1137. if ($params["nation"]) {
  1138. $where[] = ["ti.nation", "=", $params["nation"]];
  1139. }
  1140. if ($params["apply_year"]) {
  1141. $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
  1142. }
  1143. if ($params["phone"]) {
  1144. $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
  1145. }
  1146. if ($params["email"]) {
  1147. $where[] = ["ti.email", "like", "%{$params["email"]}%"];
  1148. }
  1149. if ($params["nationality"]) {
  1150. $where[] = ["ti.nationality", "=", $params["nationality"]];
  1151. }
  1152. if ($params["province"]) {
  1153. $where[] = ["ti.province", "=", $params["province"]];
  1154. }
  1155. if ($params["politics"]) {
  1156. $where[] = ["ti.politics", "=", $params["politics"]];
  1157. }
  1158. if ($params["enterprise_id"]) {
  1159. $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
  1160. }
  1161. if ($params["medicalCommunityId"]) {
  1162. $where[] = ["e.medicalCommunityId", "=", $params["medicalCommunityId"]];
  1163. }
  1164. if ($params["isGeneral"]) {
  1165. $where[] = ["e.isGeneral", "=", $params["isGeneral"]];
  1166. }
  1167. if ($params["street"]) {
  1168. $where[] = ["e.street", "=", $params["street"]];
  1169. }
  1170. if ($params["industry_field"]) {
  1171. $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
  1172. }
  1173. if ($params["industry_field_old"]) {
  1174. $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
  1175. }
  1176. if ($params["enterprise_tag"]) {
  1177. $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
  1178. }
  1179. if ($params["talent_type"]) {
  1180. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  1181. }
  1182. if ($params["import_way"]) {
  1183. $where[] = ["ti.import_way", "=", $params["import_way"]];
  1184. }
  1185. if ($params["highest_degree"]) {
  1186. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  1187. }
  1188. if ($params["study_abroad"]) {
  1189. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  1190. }
  1191. if ($params["source"]) {
  1192. $where[] = ["ti.source", "=", $params["source"]];
  1193. }
  1194. if ($params["talent_arrange"]) {
  1195. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  1196. }
  1197. if ($params["talent_condition"]) {
  1198. $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
  1199. }
  1200. if ($params["isMatchZhiren"]) {
  1201. $params["isMatchZhiren"] = $params["isMatchZhiren"] == 1 ?: 0;
  1202. $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
  1203. }
  1204. if ($params["active"]) {
  1205. $where[] = ["ti.active", "=", $params["active"]];
  1206. }
  1207. if ($params["breakFaith"]) {
  1208. $where[] = ["ti.break_faith", "=", $params["breakFaith"]];
  1209. }
  1210. switch ($process) {
  1211. case 1:
  1212. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  1213. break;
  1214. case 2:
  1215. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  1216. break;
  1217. case 3:
  1218. $where[] = ["ti.checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_FAIL]];
  1219. break;
  1220. default:
  1221. return null;
  1222. }
  1223. return Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->field("ti.*,e.agentName,e.agentPhone")->select()->toArray();
  1224. }
  1225. public static function setPublic($mainId, $state, $msg, $batch = null, $type = 1) {
  1226. $data["id"] = $mainId;
  1227. $data["checkState"] = $state;
  1228. switch ($state) {
  1229. case TalentState::ZX_PASS:
  1230. case TalentState::ZX_FAIL:
  1231. $data["isPublic"] = 2;
  1232. break;
  1233. case TalentState::ANNOUNCED:
  1234. $data["isPublic"] = 3;
  1235. $data["publicBatch"] = $batch;
  1236. break;
  1237. case TalentState::ANNOUNCED_REVERIFY_PASS:
  1238. case TalentState::ANNOUNCED_REVERIFY_FAIL:
  1239. $data["isPublic"] = 3;
  1240. break;
  1241. case TalentState::PUBLISH_PASS:
  1242. $data["isPublic"] = 4;
  1243. $data["identifyMonth"] = $batch;
  1244. $data["certificateGetTime"] = $batch; //时间待定
  1245. $data["certificateExpireTime"] = date("Y-m-d", strtotime(sprintf("%s +6 years -1 days", $batch))); //时间待定
  1246. break;
  1247. case TalentState::PUBLISH_FAIL:
  1248. $data["isPublic"] = 4;
  1249. break;
  1250. }
  1251. if (Talent::update($data)) {
  1252. TalentLogApi::write($type, $mainId, $state, $msg, 1);
  1253. return true;
  1254. }
  1255. return false;
  1256. }
  1257. public static function setEffect($mainId, $effect, $log) {
  1258. $data["id"] = $mainId;
  1259. $data["isEffect"] = $effect;
  1260. if (Talent::update($data)) {
  1261. $user = session("user");
  1262. $log["id"] = getStringId();
  1263. $log["type"] = \app\common\state\ProjectState::TALENT;
  1264. $log["mainId"] = $mainId;
  1265. if ($user) {
  1266. $log["companyId"] = $user["companyId"];
  1267. }
  1268. $log["active"] = $log["active"] ?: 0;
  1269. $log["createUser"] = $user ? sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]) : "系统";
  1270. $log["createTime"] = date("Y-m-d H:i:s");
  1271. if ($effect == 1) {
  1272. $log["step"] = 65;
  1273. } else {
  1274. $log["step"] = 60;
  1275. }
  1276. \app\common\model\TalentLog::create($log);
  1277. return true;
  1278. }
  1279. return false;
  1280. }
  1281. private static function getSuperPrivsForDeptVerify() {
  1282. $config = getJsonConfig("../sys_config.json", "super_privs_for_dept_verify");
  1283. return $config;
  1284. }
  1285. public static function chkUserInSuperDeptUsers() {
  1286. $config = self::getSuperPrivsForDeptVerify();
  1287. $companyId = session("user")["companyId"];
  1288. $company = getCacheById("Company", $companyId);
  1289. $account = session("user")["account"];
  1290. return in_array($company["code"], $config["companys"]) || in_array($account, $config["users"]);
  1291. }
  1292. }