VerifyApi.php 76 KB

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