VerifyApi.php 78 KB

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