VerifyApi.php 78 KB

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