VerifyApi.php 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918
  1. <?php
  2. namespace app\common\api;
  3. use app\admin\model\Notice as NoticeModel;
  4. use app\enterprise\model\Talent;
  5. use app\common\api\DictApi;
  6. use app\admin\model\Enterprise;
  7. use think\facade\Db;
  8. use app\common\model\TalentCondition;
  9. /**
  10. * Description of VerifyApi
  11. *
  12. * @author sgq
  13. */
  14. class VerifyApi {
  15. public static function getTalentInfoById($id, $isAdmin = false) {//添加admin只为区别导入数据管理端的显示差异
  16. $where = [];
  17. $where[] = ["id", "=", $id];
  18. $info = Talent::findOrEmpty($id)->toArray();
  19. if ($info) {
  20. if ($info["talent_type"]) {
  21. $info["talentTypeName"] = DictApi::selectByParentCode("talent_type")[$info["talent_type"]];
  22. }
  23. if ($info["nationality"]) {
  24. $info["nationalityName"] = DictApi::selectByParentCode("nationality")[$info["nationality"]];
  25. }
  26. if ($info["nation"]) {
  27. $info["nationName"] = DictApi::selectByParentCode("nation")[$info["nation"]];
  28. }
  29. if ($info["politics"]) {
  30. $info["politicsName"] = DictApi::selectByParentCode("politics")[$info["politics"]];
  31. }
  32. if ($info["province"]) {
  33. $info["provinceName"] = Db::table("un_common_location")->where("code", "=", $info["province"])->findOrEmpty()["name"];
  34. }
  35. if ($info["city"]) {
  36. $info["cityName"] = Db::table("un_common_location")->where("code", "=", $info["city"])->findOrEmpty()["name"];
  37. }
  38. if ($info["county"]) {
  39. $info["countyName"] = Db::table("un_common_location")->where("code", "=", $info["county"])->findOrEmpty()["name"];
  40. }
  41. $enterprise = Enterprise::findOrEmpty($info["enterprise_id"])->toArray();
  42. $info["enterpriseName"] = $enterprise["name"];
  43. $info["enterpriseId"] = $enterprise["id"];
  44. $info["enterpriseType"] = $enterprise["type"];
  45. $info["enterpriseEphone"] = $enterprise["ephone"];
  46. $info["enterpriseTag"] = $enterprise["enterpriseTag"];
  47. $info["enterpriseBankCard"] = $enterprise["bankCard"];
  48. $info["enterpriseBankNetwork"] = $enterprise["bankNetwork"];
  49. $info["enterpriseBank"] = $enterprise["bank"];
  50. if ($enterprise["street"]) {
  51. $info["street"] = $enterprise["street"];
  52. $info["streetName"] = DictApi::selectByParentCode("street")[$enterprise["street"]];
  53. }
  54. if ($enterprise["industryFieldNew"]) {
  55. $info["industryFieldName"] = DictApi::selectByParentCode("industry_field")[$enterprise["industryFieldNew"]];
  56. }
  57. if ($enterprise["enterpriseTag"]) {
  58. $info["enterpriseTagName"] = DictApi::selectByParentCode("enterprise_tag")[$enterprise["enterpriseTag"]];
  59. }
  60. if ($info["talent_arrange"]) {
  61. $info["talentArrangeName"] = DictApi::selectByParentCode("talent_arrange")[$info["talent_arrange"]];
  62. }
  63. if ($info["import_way"]) {
  64. $info["importWayName"] = DictApi::selectByParentCode("import_way")[$info["import_way"]];
  65. }
  66. if ($info["source"]) {
  67. $info["sourceName"] = DictApi::selectByParentCode("source")[$info["source"]];
  68. }
  69. if ($info["source_city"]) {
  70. $info["sourceCityName"] = Db::table("un_common_location")->where("code", "=", $info["source_city"])->findOrEmpty()["name"];
  71. }
  72. if ($info["source_county"]) {
  73. $info["sourceCountyName"] = Db::table("un_common_location")->where("code", "=", $info["source_county"])->findOrEmpty()["name"];
  74. }
  75. if ($info["highest_degree"]) {
  76. $info["highestDegreeName"] = DictApi::selectByParentCode("highest_degree")[$info["highest_degree"]];
  77. }
  78. if ($info["qz_talent_info"]) {
  79. $qz_talent_info = explode(";", $info["qz_talent_info"]);
  80. list($tmp1, $timeStart) = explode(":", $qz_talent_info[1]);
  81. list($tmp2, $timeEnd) = explode(":", $qz_talent_info[2]);
  82. if (strtotime($timeStart)) {
  83. $tmp_time = date("Y-m-d", strtotime($timeStart));
  84. $qz_talent_info[1] = implode(":", [$tmp1, $tmp_time]);
  85. if ($isAdmin) {
  86. $batch_info = NoticeModel::where('batch', $tmp_time)->find();
  87. if ($batch_info) {
  88. $qz_talent_info[1] = "<a target='_blank' href='/common/notice/view/id/" . $batch_info['id'] . "'>" . $qz_talent_info[1] . "</a>";
  89. }
  90. }
  91. }
  92. if (strtotime($timeEnd)) {
  93. $qz_talent_info[2] = implode(":", [$tmp2, date("Y-m-d", strtotime($timeEnd))]);
  94. }
  95. $info["qz_talent_info"] = implode(";", $qz_talent_info);
  96. }
  97. if ($info["fj_talent_info"]) {
  98. $fj_talent_info = explode(";", $info["fj_talent_info"]);
  99. list($tmp1, $timeStart) = explode(":", $fj_talent_info[0]);
  100. list($tmp2, $validYear) = explode(":", $fj_talent_info[2]);
  101. $timeStart = str_replace(["."], "-", $timeStart);
  102. if (strtotime($timeStart)) {
  103. $tmp_time = date("Y-m-d", strtotime($timeStart));
  104. $fj_talent_info[0] = implode(":", [$tmp1, $tmp_time]);
  105. if ($isAdmin) {
  106. $batch_info = NoticeModel::where('batch', $tmp_time)->find();
  107. if ($batch_info) {
  108. $fj_talent_info[0] = "<a target='_blank' href='/common/notice/view/id/" . $batch_info['id'] . "'>" . $fj_talent_info[0] . "</a>";
  109. }
  110. }
  111. if (strtotime($validYear)) {
  112. $fj_talent_info[2] = implode(":", [$tmp2, date("Y-m-d", strtotime($validYear))]);
  113. } else {
  114. $validval = intval($validYear);
  115. if ($validYear > 0) {
  116. $timestr = str_replace($validval, "", $validYear);
  117. switch ($timestr) {
  118. case "月":
  119. $timetype = "months";
  120. break;
  121. case "日":
  122. $timetype = "days";
  123. break;
  124. default:
  125. $timetype = "years";
  126. break;
  127. }
  128. $fj_talent_info[2] = implode(":", [$tmp2, date("Y-m-d", strtotime("+{$validval} {$timetype} -1 days", strtotime($timeStart)))]);
  129. }
  130. }
  131. }
  132. $info["fj_talent_info"] = implode(";", $fj_talent_info);
  133. }
  134. if ($info["talent_condition"]) {
  135. $talent_condition = \app\common\model\TalentCondition::findOrEmpty($info["talent_condition"]);
  136. $info["talentConditionName"] = $talent_condition["name"];
  137. $info["talent_arrange_category"] = $talent_condition["talentLevelCat"];
  138. $info["talentArrangeCatName"] = DictApi::selectByParentCode("talent_condition_cats")[$talent_condition["talentLevelCat"]];
  139. }
  140. }
  141. return $info;
  142. }
  143. public static function getOne($id) {
  144. return Talent::findOrEmpty($id);
  145. }
  146. public static function getFullDeptList($params, $where = []) {
  147. $order = $params["order"] ?: "desc";
  148. $offset = $params["offset"] ?: 0;
  149. $limit = $params["limit"] ?: 10;
  150. $whereRaw = "";
  151. switch ($params["checkState"]) {
  152. case 1:
  153. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  154. $where[] = ["ti.pass_dept_check", "=", 0];
  155. break;
  156. case 2:
  157. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  158. break;
  159. case 3:
  160. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_PASS];
  161. break;
  162. default:
  163. $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);
  164. break;
  165. }
  166. $companyId = session("user")["companyId"];
  167. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  168. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  169. $count = Talent::alias("ti")
  170. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  171. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  172. ->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")
  173. ->where($where)
  174. ->where($whereRaw)->count();
  175. $list = Talent::alias("ti")
  176. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  177. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  178. ->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")
  179. ->where($where)
  180. ->where($whereRaw)
  181. ->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")
  182. ->limit($offset, $limit)->order("ti.createTime " . $order)
  183. ->select()->toArray();
  184. foreach ($list as &$item) {
  185. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  186. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  187. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  188. }unset($item);
  189. return ["total" => $count, "rows" => $list];
  190. }
  191. public static function getDeptList($params, $where = []) {
  192. $order = $params["order"] ?: "desc";
  193. $offset = $params["offset"] ?: 0;
  194. $limit = $params["limit"] ?: 10;
  195. $companyId = session("user")["companyId"];
  196. switch ($params["checkState"]) {
  197. case 1:
  198. //待审核
  199. $where[] = ["tl.active", "=", 0];
  200. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  201. break;
  202. case 2:
  203. //已驳回
  204. $where[] = ["tl.active", "=", 1];
  205. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  206. break;
  207. case 3:
  208. //已通过
  209. $where[] = ["tl.active", "=", 1];
  210. $where[] = ["tl.new_state", "=", TalentState::DEPT_VERIFY_PASS];
  211. break;
  212. default:
  213. $where = sprintf("(tl.active=0 and tl.state=%d) or (tl.active=1 and (tl.new_state in (%d,%d)))", TalentState::FST_VERIFY_PASS, TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_PASS);
  214. break;
  215. }
  216. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  217. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  218. $count = 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,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")
  222. ->where($where)
  223. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])->count();
  224. $list = Talent::alias("ti")
  225. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  226. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  227. ->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")
  228. ->where($where)
  229. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
  230. ->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")
  231. ->limit($offset, $limit)->order("ti.createTime " . $order)
  232. ->select()->toArray();
  233. foreach ($list as &$item) {
  234. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  235. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  236. $lastCheckLog = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
  237. $item["deptCheckState"] = $lastCheckLog["new_state"];
  238. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  239. }unset($item);
  240. return ["total" => $count, "rows" => $list];
  241. }
  242. public static function getPublicList($params) {
  243. $order = $params["order"];
  244. $offset = $params["offset"];
  245. $limit = $params["limit"];
  246. $where = [];
  247. $where[] = ["e.type", "=", session("user")["type"]];
  248. if ($params["name"]) {
  249. $where[] = ["ti.name", "like", "%" . $params["name"] . "%"];
  250. }
  251. if ($params["sex"]) {
  252. $where[] = ["ti.sex", "=", $params["sex"]];
  253. }
  254. if ($params["checkState"]) {
  255. $where[] = ["ti.checkState", "=", $params["checkState"]];
  256. }
  257. $type = $params["type"];
  258. switch ($type) {
  259. case 1:
  260. case 2:
  261. $where[] = ["ti.checkState", "=", TalentState::REVERIFY_PASS];
  262. break;
  263. case 3: //公示
  264. case 7: //公示预览
  265. $where[] = ["ti.checkState", "=", TalentState::ZX_PASS];
  266. break;
  267. case 4: //公示通过
  268. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED];
  269. break;
  270. case 5:
  271. case 8: //公布预览
  272. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED_REVERIFY_PASS];
  273. break;
  274. case 6:
  275. $where[] = ["ti.checkState", "=", TalentState::PUBLISH_PASS];
  276. break;
  277. }
  278. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  279. $count = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->count();
  280. $list = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  281. ->where($where)
  282. ->limit($offset, $limit)
  283. ->order("ti.createTime " . $order)->field("ti.*,e.name as enterpriseName,e.type as enterprise_type,enterpriseTag")->select()->toArray();
  284. foreach ($list as &$item) {
  285. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  286. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  287. }unset($item);
  288. return ["total" => $count, "rows" => $list];
  289. }
  290. public static function getListByIds($ids) {
  291. $where[] = ["id", "in", $ids];
  292. return Talent::where($where)->select()->toArray();
  293. }
  294. public static function getList($params) {
  295. $where = [];
  296. $order = $params["order"] ?: "desc";
  297. $offset = $params["offset"] ?: 0;
  298. $limit = $params["limit"] ?: 10;
  299. $where[] = ["e.type", "=", session("user")["type"]];
  300. if ($params["name"]) {
  301. $where[] = ["ti.name", "like", "%{$params["name"]}%"];
  302. }
  303. if ($params["card_number"]) {
  304. $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
  305. }
  306. if ($params["sex"]) {
  307. $where[] = ["ti.sex", "=", $params["sex"]];
  308. }
  309. if ($params["nation"]) {
  310. $where[] = ["ti.nation", "=", $params["nation"]];
  311. }
  312. if ($params["apply_year"]) {
  313. $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
  314. }
  315. if ($params["phone"]) {
  316. $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
  317. }
  318. if ($params["email"]) {
  319. $where[] = ["ti.email", "like", "%{$params["email"]}%"];
  320. }
  321. if ($params["nationality"]) {
  322. $where[] = ["ti.nationality", "=", $params["nationality"]];
  323. }
  324. if ($params["province"]) {
  325. $where[] = ["ti.province", "=", $params["province"]];
  326. }
  327. if ($params["politics"]) {
  328. $where[] = ["ti.politics", "=", $params["politics"]];
  329. }
  330. if ($params["enterprise_id"]) {
  331. $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
  332. }
  333. if ($params["street"]) {
  334. $where[] = ["e.street", "=", $params["street"]];
  335. }
  336. if ($params["industry_field"]) {
  337. $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
  338. }
  339. if ($params["industry_field_old"]) {
  340. $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
  341. }
  342. if ($params["enterprise_tag"]) {
  343. $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
  344. }
  345. if ($params["talent_type"]) {
  346. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  347. }
  348. if ($params["import_way"]) {
  349. $where[] = ["ti.import_way", "=", $params["import_way"]];
  350. }
  351. if ($params["highest_degree"]) {
  352. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  353. }
  354. if ($params["study_abroad"]) {
  355. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  356. }
  357. if ($params["source"]) {
  358. $where[] = ["ti.source", "=", $params["source"]];
  359. }
  360. if ($params["talent_arrange"]) {
  361. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  362. }
  363. if ($params["talent_condition"]) {
  364. $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
  365. }
  366. if ($params["isMatchZhiren"]) {
  367. $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
  368. }
  369. $process = $params["process"];
  370. if ($process == 4) {
  371. $companyId = session('user')['companyId'];
  372. $company_info = CompanyApi::getOne($companyId);
  373. if ($company_info["code"] == "super" || $company_info["code"] == "rsj") {
  374. return self::getFullDeptList($params, $where);
  375. } else {
  376. return self::getDeptList($params, $where);
  377. }
  378. }
  379. if ($process == 5) {
  380. $whereRaw = sprintf("(tl.state in (14,15,16)) or (tl.state=12 and ti.pass_dept_check=0) or (tl.state=10 and ti.pass_dept_check=1) or (tl.state=10 and (tc.companyIds is null or tc.companyIds = ''))");
  381. switch ($params["checkState"]) {
  382. case 1:
  383. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  384. break;
  385. case -1:
  386. $where[] = ["tl.state", "=", TalentState::REVERIFY_FAIL];
  387. break;
  388. }
  389. $count = Talent::alias("ti")
  390. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  391. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  392. ->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")
  393. //->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)")
  394. ->whereRaw($whereRaw)->where($where)->count();
  395. $list = Talent::alias("ti")
  396. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  397. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  398. ->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")
  399. //->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)")
  400. ->whereRaw($whereRaw)
  401. ->where($where)
  402. ->limit($offset, $limit)
  403. ->order("ti.createTime " . $order)
  404. ->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag")
  405. ->select()->toArray();
  406. } else {
  407. switch ($process) {
  408. case 1:
  409. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  410. break;
  411. case 2:
  412. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  413. break;
  414. case 3:
  415. switch ($params["checkState"]) {
  416. case -1://保存未提交
  417. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  418. $where[] = ["tl.state", "<>", TalentState::FST_VERIFY_REJECT];
  419. //$where[] = ["ti.first_submit_time", "exp", Db::raw("is null")];
  420. $where[] = ["ti.delete", "=", 0];
  421. break;
  422. case 1://待审核
  423. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  424. //$where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
  425. $where[] = ["tl.last_state", "<>", TalentState::FST_VERIFY_REJECT];
  426. break;
  427. case 2://驳回
  428. //$where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  429. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  430. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_REJECT];
  431. break;
  432. case 3://通过
  433. //$where[] = ["tl.state", "in", [TalentState::FST_VERIFY_PASS]];
  434. $whereRaw = sprintf("tl.state=%d or tl.state>%d", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_REJECT);
  435. break;
  436. case 4://失败
  437. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_FAIL]];
  438. break;
  439. case 5://重新提交
  440. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  441. $where[] = ["tl.last_state", "=", TalentState::FST_VERIFY_REJECT];
  442. break;
  443. default:
  444. //$where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_REJECT]];
  445. $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);
  446. }
  447. break;
  448. case 6:
  449. $where[] = ["tl.state", ">=", TalentState::REVERIFY_PASS];
  450. if ($params["checkState"]) {
  451. $where[] = ["tl.state", "=", $params["checkState"]];
  452. }
  453. break;
  454. case 7:
  455. $where[] = ["tl.state", "=", TalentState::CERTIFICATED];
  456. break;
  457. }
  458. $count = Talent::alias("ti")
  459. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  460. ->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")
  461. //->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")
  462. ->where($where)->where($whereRaw)->count();
  463. $list = Talent::alias("ti")
  464. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  465. ->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")
  466. //->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")
  467. ->where($where)->where($whereRaw)->limit($offset, $limit)->order("ti.createTime " . $order)->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag")->select()->toArray();
  468. }
  469. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  470. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  471. foreach ($list as &$item) {
  472. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  473. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  474. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  475. $item["talentConditionName"] = TalentCondition::findOrEmpty($item["talent_condition"])["name"];
  476. //$last_log = TalentLogApi::getLastLog($item["id"], 1, 0, ["step", "=", null]);
  477. //$item["lastState"] = $last_log["last_state"];
  478. //$item["realState"] = $last_log["state"];
  479. }unset($item);
  480. return ["total" => $count, "rows" => $list];
  481. }
  482. public static function getExportDatas($process, $params) {
  483. $where[] = [];
  484. //特殊字段处理
  485. $exportFields = $params["export"];
  486. $fields = [];
  487. foreach ($exportFields as $field) {
  488. if (!in_array($field, ["industryFieldNew", "enterpriseName", "enterpriseTag", "street", "talent_arrange_category", "checkMsg"])) {
  489. $fields[] = "ti." . $field;
  490. }
  491. }
  492. $fields[] = "e.name as enterpriseName";
  493. $fields[] = "e.industryFieldNew";
  494. $fields[] = "e.enterpriseTag";
  495. $fields[] = "e.street";
  496. $fields[] = "tc.talentLevelCat";
  497. $fields[] = "tl.description as checkMsg";
  498. $fields[] = "tc.name as talentConditionName";
  499. $fields[] = "tl.description as checkMsg";
  500. if (in_array("card_type", $exportFields)) {
  501. $cardTypes = DictApi::selectByParentCode("card_type");
  502. }
  503. if (in_array("industryFieldNew", $exportFields)) {
  504. $industry_fields = DictApi::selectByParentCode("industry_field");
  505. }
  506. if (in_array("enterpriseTag", $exportFields)) {
  507. $enterpriseTags = DictApi::selectByParentCode("enterprise_tag");
  508. }
  509. if (in_array("street", $exportFields)) {
  510. $streets = DictApi::selectByParentCode("street");
  511. }
  512. if (in_array("nation", $exportFields)) {
  513. $nations = DictApi::selectByParentCode("nation");
  514. }
  515. if (in_array("nationality", $exportFields)) {
  516. $nationalitys = DictApi::selectByParentCode("nationality");
  517. }
  518. if (in_array("politics", $exportFields)) {
  519. $politics = DictApi::selectByParentCode("politics");
  520. }
  521. if (in_array("talent_type", $exportFields)) {
  522. $talentTypes = DictApi::selectByParentCode("talent_type");
  523. }
  524. if (in_array("talent_arrange_category", $exportFields)) {
  525. $talentArrangeCategories = DictApi::selectByParentCode("talent_condition_cats");
  526. }
  527. if (in_array("highest_degree", $exportFields)) {
  528. $highest_degree = DictApi::selectByParentCode("highest_degree");
  529. }
  530. if (in_array("import_way", $exportFields)) {
  531. $import_way = DictApi::selectByParentCode("import_way");
  532. }
  533. if (in_array("source", $exportFields)) {
  534. $source = DictApi::selectByParentCode("source");
  535. }
  536. if (in_array("source_city", $exportFields)) {
  537. $source_city = DictApi::selectByParentCode("source_city");
  538. }
  539. if (in_array("source_county", $exportFields)) {
  540. $source_county = DictApi::selectByParentCode("source_county");
  541. }
  542. if (in_array("talent_arrange", $exportFields)) {
  543. $talent_arrange = DictApi::selectByParentCode("talent_arrange");
  544. }
  545. $sex = [1 => "男", 2 => "女"];
  546. $pre_import_type = [1 => "意向合同", 2 => "创业企业名称预核准"];
  547. $study_abroad = [1 => "是", 2 => "否"];
  548. $salary_pay_way = [1 => "本单位", 2 => "本单位所属集团公司及权属公司"];
  549. $return = [1 => "是", 2 => "否"];
  550. $isMatchZhiren = [0 => "否", 1 => "是"];
  551. $where = [];
  552. $where[] = ["e.type", "=", session("user")["type"]];
  553. if ($params["all"] != 1) {
  554. if ($params["name"]) {
  555. $where[] = ["ti.name", "like", "%{$params["name"]}%"];
  556. }
  557. if ($params["card_number"]) {
  558. $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
  559. }
  560. if ($params["sex"]) {
  561. $where[] = ["ti.sex", "=", $params["sex"]];
  562. }
  563. if ($params["nation"]) {
  564. $where[] = ["ti.nation", "=", $params["nation"]];
  565. }
  566. if ($params["apply_year"]) {
  567. $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
  568. }
  569. if ($params["phone"]) {
  570. $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
  571. }
  572. if ($params["email"]) {
  573. $where[] = ["ti.email", "like", "%{$params["email"]}%"];
  574. }
  575. if ($params["nationality"]) {
  576. $where[] = ["ti.nationality", "=", $params["nationality"]];
  577. }
  578. if ($params["province"]) {
  579. $where[] = ["ti.province", "=", $params["province"]];
  580. }
  581. if ($params["politics"]) {
  582. $where[] = ["ti.politics", "=", $params["politics"]];
  583. }
  584. if ($params["enterprise_id"]) {
  585. $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
  586. }
  587. if ($params["street"]) {
  588. $where[] = ["e.street", "=", $params["street"]];
  589. }
  590. if ($params["industry_field"]) {
  591. $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
  592. }
  593. if ($params["industry_field_old"]) {
  594. $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
  595. }
  596. if ($params["enterprise_tag"]) {
  597. $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
  598. }
  599. if ($params["talent_type"]) {
  600. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  601. }
  602. if ($params["import_way"]) {
  603. $where[] = ["ti.import_way", "=", $params["import_way"]];
  604. }
  605. if ($params["highest_degree"]) {
  606. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  607. }
  608. if ($params["study_abroad"]) {
  609. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  610. }
  611. if ($params["source"]) {
  612. $where[] = ["ti.source", "=", $params["source"]];
  613. }
  614. if ($params["talent_arrange"]) {
  615. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  616. }
  617. if ($params["talent_condition"]) {
  618. $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
  619. }
  620. if ($params["isMatchZhiren"]) {
  621. $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
  622. }
  623. switch ($process) {
  624. case 1:
  625. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  626. break;
  627. case 2:
  628. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  629. break;
  630. case 3:
  631. switch ($params["checkState"]) {
  632. case -1://保存未提交
  633. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  634. $where[] = ["tl.state", "<>", TalentState::FST_VERIFY_REJECT];
  635. //$where[] = ["ti.first_submit_time", "exp", Db::raw("is null")];
  636. $where[] = ["ti.delete", "=", 0];
  637. break;
  638. case 1://待审核
  639. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  640. //$where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
  641. $where[] = ["tl.last_state", "<>", TalentState::FST_VERIFY_REJECT];
  642. break;
  643. case 2://驳回
  644. //$where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  645. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  646. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_REJECT];
  647. break;
  648. case 3://通过
  649. //$where[] = ["tl.state", "in", [TalentState::FST_VERIFY_PASS]];
  650. $whereRaw = sprintf("tl.state=%d or tl.state>%d", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_REJECT);
  651. break;
  652. case 4://失败
  653. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_FAIL]];
  654. break;
  655. case 5://重新提交
  656. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  657. $where[] = ["tl.last_state", "=", TalentState::FST_VERIFY_REJECT];
  658. break;
  659. default:
  660. //$where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_REJECT]];
  661. $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);
  662. }
  663. break;
  664. case 4:
  665. $companyId = session('user')['companyId'];
  666. $company_info = CompanyApi::getOne($companyId);
  667. if ($company_info["code"] == "super" || $company_info["code"] == "rsj") {
  668. switch ($params["checkState"]) {
  669. case 1:
  670. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  671. $where[] = ["ti.pass_dept_check", "=", 0];
  672. break;
  673. case 2:
  674. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  675. break;
  676. case 3:
  677. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_PASS];
  678. break;
  679. default:
  680. $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);
  681. break;
  682. }
  683. } else {
  684. switch ($params["checkState"]) {
  685. case 1:
  686. //待审核
  687. $where[] = ["tl.active", "=", 0];
  688. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  689. break;
  690. case 2:
  691. //已驳回
  692. $where[] = ["tl.active", "=", 1];
  693. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  694. break;
  695. case 3:
  696. //已通过
  697. $where[] = ["tl.active", "=", 1];
  698. $where[] = ["tl.new_state", "=", TalentState::DEPT_VERIFY_PASS];
  699. break;
  700. default:
  701. $where = sprintf("(tl.active=0 and tl.state=%d) or (tl.active=1 and (tl.new_state in (%d,%d)))", TalentState::FST_VERIFY_PASS, TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_PASS);
  702. break;
  703. }
  704. }
  705. break;
  706. case 5:
  707. $whereRaw = sprintf("(tl.state in (14,15,16)) or (tl.state=12 and ti.pass_dept_check=0) or (tl.state=10 and ti.pass_dept_check=1) or (tl.state=10 and (tc.companyIds is null or tc.companyIds = ''))");
  708. switch ($params["checkState"]) {
  709. case 1:
  710. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  711. break;
  712. case -1:
  713. $where[] = ["tl.state", "=", TalentState::REVERIFY_FAIL];
  714. break;
  715. }
  716. break;
  717. case 6:
  718. $where[] = ["tl.state", ">=", TalentState::REVERIFY_PASS];
  719. if ($params["checkState"]) {
  720. $where[] = ["tl.state", "=", $params["checkState"]];
  721. }
  722. break;
  723. case 7:
  724. $where[] = ["tl.state", "=", TalentState::CERTIFICATED];
  725. break;
  726. }
  727. } else {
  728. $whereRaw = "tl.state is not null";
  729. $where[] = ["ti.delete", "=", 0];
  730. }
  731. $fields[] = "ti.pass_dept_check";
  732. $fields[] = "tl.state";
  733. $fields[] = "tl.new_state";
  734. $fields[] = "tl.last_state";
  735. $fields[] = "tc.companyIds";
  736. if ($process == 4) {
  737. if ($company_info["code"] == "super" || $company_info["code"] == "rsj") {
  738. $list = Talent::alias("ti")
  739. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  740. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  741. ->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")
  742. ->where($where)
  743. ->where($whereRaw)
  744. ->field($fields)
  745. ->select()->toArray();
  746. } else {
  747. $fields[] = "tl.active";
  748. $fields[] = "tl.new_state as deptCheckState";
  749. $list = Talent::alias("ti")
  750. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  751. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  752. ->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")
  753. ->where($where)
  754. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
  755. ->field($fields)
  756. ->select()->toArray();
  757. }
  758. } else if ($process == 5) {
  759. $list = Talent::alias("ti")
  760. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  761. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  762. ->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")
  763. //->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)")
  764. ->whereRaw($whereRaw)
  765. ->where($where)
  766. ->field($fields)
  767. ->select()->toArray();
  768. } else {
  769. $list = Talent::alias("ti")
  770. ->field($fields)
  771. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  772. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  773. ->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")
  774. //->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)")
  775. ->where($where)
  776. ->where($whereRaw)
  777. ->select()->toArray();
  778. }
  779. $un_common_location = Db::table("un_common_location")->column('name', 'code');
  780. foreach ($list as &$item) {
  781. $item["card_type"] = $cardTypes[$item["card_type"]];
  782. $item["industryFieldNew"] = $industry_fields[$item["industryFieldNew"]];
  783. $item["enterpriseTag"] = $enterpriseTags[$item["enterpriseTag"]];
  784. $item["street"] = $streets[$item["street"]];
  785. $item["nation"] = $nations[$item["nation"]];
  786. $item["nationality"] = $nationalitys[$item["nationality"]];
  787. $item["politics"] = $politics[$item["politics"]];
  788. $item["talent_type"] = $talentTypes[$item["talent_type"]];
  789. $item["talent_arrange_category"] = $talentArrangeCategories[$item["talentLevelCat"]];
  790. $item["sex"] = $sex[$item["sex"]];
  791. $item["highest_degree"] = $highest_degree[$item["highest_degree"]];
  792. $item["import_way"] = $import_way[$item["import_way"]];
  793. $item["salary_pay_way"] = $salary_pay_way[$item["salary_pay_way"]];
  794. $item["pre_import_type"] = $pre_import_type[$item["pre_import_type"]];
  795. $item["return"] = $return[$item["return"]];
  796. $item["isMatchZhiren"] = $isMatchZhiren[$item["isMatchZhiren"]];
  797. $item["study_abroad"] = $study_abroad[$item["study_abroad"]];
  798. $item["source"] = $source[$item["source"]];
  799. $item["talent_arrange"] = $talent_arrange[$item["talent_arrange"]];
  800. $item["talent_condition"] = $item["talentConditionName"];
  801. if (in_array("source_city", $exportFields)) {
  802. $item["source_city"] = $un_common_location[$item["source_city"]];
  803. }
  804. if (in_array("source_county", $exportFields)) {
  805. $item["source_county"] = $un_common_location[$item["source_county"]];
  806. }
  807. if (in_array("province", $exportFields)) {
  808. $item["province"] = $un_common_location[$item["province"]];
  809. }
  810. if (in_array("city", $exportFields)) {
  811. $item["city"] = $un_common_location[$item["city"]];
  812. }
  813. if (in_array("county", $exportFields)) {
  814. $item["county"] = $un_common_location[$item["county"]];
  815. }
  816. if ($item["state"] == TalentState::SCND_SUBMIT) {
  817. if ($item["last_state"] == TalentState::FST_VERIFY_REJECT) {
  818. $item["checkState"] = "待初审(重新提交)";
  819. } else {
  820. $item["checkState"] = "待初审(首次提交)";
  821. }
  822. } else if ($item["state"] == TalentState::FST_VERIFY_PASS) {
  823. if ($item["deptCheckState"]) {
  824. if ($item["acitve"] == 0 && $item["state"] == TalentState::FST_VERIFY_PASS) {
  825. $item["checkState"] = "待部门审核";
  826. }
  827. if ($item["active"] == 1 && $item["new_state"] == TalentState::DEPT_VERIFY_PASS) {
  828. $item["checkState"] = "部门审核通过";
  829. }
  830. if ($item["active"] == 1 && $item["new_state"] == TalentState::SCND_SUBMIT) {
  831. $item["checkState"] = "部门审核驳回";
  832. }
  833. } else {
  834. if (!$item["companyIds"] || $item["pass_dept_check"] == 1) {
  835. $item["checkState"] = "待复核(初审通过)";
  836. }
  837. if ($item["pass_dept_check"] == 0) {
  838. $item["checkState"] = "待部门并审";
  839. }
  840. }
  841. } else if ($item["state"] == TalentState::DEPT_VERIFY_REJECT) {
  842. $item["checkState"] = "待初审(部门并审驳回)";
  843. } else if ($item["state"] == TalentState::DEPT_VERIFY_PASS) {
  844. $item["checkState"] = "待复核(部门并审通过)";
  845. } else {
  846. $item["checkState"] = TalentState::getStateName($item["state"]);
  847. }
  848. }unset($item);
  849. return $list;
  850. }
  851. public static function getListByProcess($process) {
  852. switch ($process) {
  853. case 1:
  854. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  855. break;
  856. case 2:
  857. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  858. break;
  859. case 3:
  860. $where[] = ["ti.checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_FAIL]];
  861. break;
  862. default:
  863. return null;
  864. }
  865. return Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->field("ti.*,e.agentName,e.agentPhone")->select()->toArray();
  866. }
  867. public static function setPublic($mainId, $state, $msg, $batch = null, $type = 1) {
  868. $data["id"] = $mainId;
  869. $data["checkState"] = $state;
  870. switch ($state) {
  871. case TalentState::ZX_PASS:
  872. case TalentState::ZX_FAIL:
  873. $data["isPublic"] = 2;
  874. break;
  875. case TalentState::ANNOUNCED:
  876. $data["isPublic"] = 3;
  877. $data["publicBatch"] = $batch;
  878. break;
  879. case TalentState::ANNOUNCED_REVERIFY_PASS:
  880. case TalentState::ANNOUNCED_REVERIFY_FAIL:
  881. $data["isPublic"] = 3;
  882. break;
  883. case TalentState::PUBLISH_PASS:
  884. $data["isPublic"] = 4;
  885. $data["identifyMonth"] = $batch;
  886. $data["certificateGetTime"] = $batch; //时间待定
  887. $data["certificateExpireTime"] = date("Y-m-d", strtotime(sprintf("%s +6 years -1 days", $batch))); //时间待定
  888. break;
  889. case TalentState::PUBLISH_FAIL:
  890. $data["isPublic"] = 4;
  891. break;
  892. }
  893. if (Talent::update($data)) {
  894. TalentLogApi::write($type, $mainId, $state, $msg, 1);
  895. return true;
  896. }
  897. return false;
  898. }
  899. }