VerifyApi.php 70 KB

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