VerifyApi.php 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  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 getDeptList($params, $where = []) {
  147. $order = $params["order"] ?: "desc";
  148. $offset = $params["offset"] ?: 0;
  149. $limit = $params["limit"] ?: 10;
  150. $companyId = session("user")["companyId"];
  151. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  152. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  153. $count = Talent::alias("ti")
  154. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  155. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  156. ->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")
  157. //->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)")
  158. ->where($where)
  159. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])->count();
  160. $list = Talent::alias("ti")
  161. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  162. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  163. ->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")
  164. //->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)")
  165. ->where($where)
  166. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
  167. ->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")
  168. ->limit($offset, $limit)->order("ti.createTime " . $order)
  169. ->select()->toArray();
  170. foreach ($list as &$item) {
  171. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  172. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  173. $lastCheckLog = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
  174. $item["deptCheckState"] = $lastCheckLog["new_state"];
  175. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  176. }unset($item);
  177. return ["total" => $count, "rows" => $list];
  178. }
  179. public static function getPublicList($params) {
  180. $order = $params["order"];
  181. $offset = $params["offset"];
  182. $limit = $params["limit"];
  183. $where = [];
  184. $where[] = ["e.type", "=", session("user")["type"]];
  185. if ($params["name"]) {
  186. $where[] = ["ti.name", "like", "%" . $params["name"] . "%"];
  187. }
  188. if ($params["sex"]) {
  189. $where[] = ["ti.sex", "=", $params["sex"]];
  190. }
  191. if ($params["checkState"]) {
  192. $where[] = ["ti.checkState", "=", $params["checkState"]];
  193. }
  194. $type = $params["type"];
  195. switch ($type) {
  196. case 1:
  197. case 2:
  198. $where[] = ["ti.checkState", "=", TalentState::REVERIFY_PASS];
  199. break;
  200. case 3: //公示
  201. case 7: //公示预览
  202. $where[] = ["ti.checkState", "=", TalentState::ZX_PASS];
  203. break;
  204. case 4: //公示通过
  205. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED];
  206. break;
  207. case 5:
  208. case 8: //公布预览
  209. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED_REVERIFY_PASS];
  210. break;
  211. case 6:
  212. $where[] = ["ti.checkState", "=", TalentState::PUBLISH_PASS];
  213. break;
  214. }
  215. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  216. $count = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->count();
  217. $list = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  218. ->where($where)
  219. ->limit($offset, $limit)
  220. ->order("ti.createTime " . $order)->field("ti.*,e.name as enterpriseName,e.type as enterprise_type,enterpriseTag")->select()->toArray();
  221. foreach ($list as &$item) {
  222. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  223. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  224. }unset($item);
  225. return ["total" => $count, "rows" => $list];
  226. }
  227. public static function getListByIds($ids) {
  228. $where[] = ["id", "in", $ids];
  229. return Talent::where($where)->select()->toArray();
  230. }
  231. public static function getList($params) {
  232. $where = [];
  233. $order = $params["order"] ?: "desc";
  234. $offset = $params["offset"] ?: 0;
  235. $limit = $params["limit"] ?: 10;
  236. $where[] = ["e.type", "=", session("user")["type"]];
  237. if ($params["name"]) {
  238. $where[] = ["ti.name", "like", "%{$params["name"]}%"];
  239. }
  240. if ($params["card_number"]) {
  241. $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
  242. }
  243. if ($params["sex"]) {
  244. $where[] = ["ti.sex", "=", $params["sex"]];
  245. }
  246. if ($params["nation"]) {
  247. $where[] = ["ti.nation", "=", $params["nation"]];
  248. }
  249. if ($params["apply_year"]) {
  250. $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
  251. }
  252. if ($params["phone"]) {
  253. $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
  254. }
  255. if ($params["email"]) {
  256. $where[] = ["ti.email", "like", "%{$params["email"]}%"];
  257. }
  258. if ($params["nationality"]) {
  259. $where[] = ["ti.nationality", "=", $params["nationality"]];
  260. }
  261. if ($params["province"]) {
  262. $where[] = ["ti.province", "=", $params["province"]];
  263. }
  264. if ($params["politics"]) {
  265. $where[] = ["ti.politics", "=", $params["politics"]];
  266. }
  267. if ($params["enterprise_id"]) {
  268. $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
  269. }
  270. if ($params["street"]) {
  271. $where[] = ["e.street", "=", $params["street"]];
  272. }
  273. if ($params["industry_field"]) {
  274. $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
  275. }
  276. if ($params["industry_field_old"]) {
  277. $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
  278. }
  279. if ($params["enterprise_tag"]) {
  280. $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
  281. }
  282. if ($params["talent_type"]) {
  283. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  284. }
  285. if ($params["import_way"]) {
  286. $where[] = ["ti.import_way", "=", $params["import_way"]];
  287. }
  288. if ($params["highest_degree"]) {
  289. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  290. }
  291. if ($params["study_abroad"]) {
  292. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  293. }
  294. if ($params["source"]) {
  295. $where[] = ["ti.source", "=", $params["source"]];
  296. }
  297. if ($params["talent_arrange"]) {
  298. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  299. }
  300. if ($params["talent_condition"]) {
  301. $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
  302. }
  303. if ($params["isMatchZhiren"]) {
  304. $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
  305. }
  306. $process = $params["process"];
  307. if ($process == 4) {
  308. switch ($params["checkState"]) {
  309. case 5:
  310. $_where = [];
  311. $_where[] = ["type", "=", 1];
  312. $_where[] = ["active", "=", 1];
  313. $_where[] = ["step", "=", 3];
  314. $_where[] = ["companyId", "=", session("user")["companyId"]];
  315. $mainIds = \app\common\model\TalentChecklog::where($_where)->group("mainId")->order("createTime desc")->column("mainId");
  316. if ($mainIds) {
  317. $where[] = ["ti.id", "in", $mainIds];
  318. } else {
  319. $where[] = ["ti.checkState", "=", TalentState::FST_VERIFY_PASS];
  320. $where[] = ["ti.pass_dept_check", "=", 0];
  321. }
  322. break;
  323. default:
  324. $where[] = ["ti.checkState", "=", TalentState::FST_VERIFY_PASS];
  325. $where[] = ["ti.pass_dept_check", "=", 0];
  326. break;
  327. }
  328. return self::getDeptList($params, $where);
  329. }
  330. if ($process == 5) {
  331. $whereRaw = sprintf("(ti.checkState in (14,15,16)) or (ti.checkState=12 and ti.pass_dept_check=0) or (ti.checkState=10 and ti.pass_dept_check=1) or (ti.checkState=10 and (tc.companyIds is null or tc.companyIds = ''))");
  332. switch ($params["checkState"]) {
  333. case 1:
  334. $where[] = ["ti.checkState", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  335. break;
  336. case -1:
  337. $where[] = ["ti.checkState", "=", TalentState::REVERIFY_FAIL];
  338. break;
  339. }
  340. $count = Talent::alias("ti")
  341. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  342. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  343. ->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")
  344. //->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)")
  345. ->whereRaw($whereRaw)->where($where)->count();
  346. $list = Talent::alias("ti")
  347. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  348. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  349. ->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")
  350. //->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)")
  351. ->whereRaw($whereRaw)
  352. ->where($where)
  353. ->limit($offset, $limit)
  354. ->order("ti.createTime " . $order)
  355. ->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag")
  356. ->select()->toArray();
  357. } else {
  358. switch ($process) {
  359. case 1:
  360. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  361. break;
  362. case 2:
  363. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  364. break;
  365. case 3:
  366. switch ($params["checkState"]) {
  367. case -1://保存未提交
  368. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  369. $where[] = ["tl.state", "<>", TalentState::FST_VERIFY_REJECT];
  370. //$where[] = ["ti.first_submit_time", "exp", Db::raw("is null")];
  371. $where[] = ["ti.delete", "=", 0];
  372. break;
  373. case 1://待审核
  374. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  375. //$where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
  376. $where[] = ["tl.last_state", "<>", TalentState::FST_VERIFY_REJECT];
  377. break;
  378. case 2://驳回
  379. //$where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  380. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  381. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_REJECT];
  382. break;
  383. case 3://通过
  384. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_PASS]];
  385. break;
  386. case 4://失败
  387. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_FAIL]];
  388. break;
  389. case 5://重新提交
  390. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  391. $where[] = ["tl.last_state", "=", TalentState::FST_VERIFY_REJECT];
  392. break;
  393. default:
  394. //$where[] = ["ti.checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_FAIL]];
  395. //$where[] = ["tl.new_state", "in", [TalentState::SCND_SAVE, TalentState::SCND_SUBMIT]];
  396. $where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_REJECT]];
  397. }
  398. break;
  399. case 6:
  400. $where[] = ["ti.checkState", ">=", TalentState::REVERIFY_PASS];
  401. if ($params["checkState"]) {
  402. $where[] = ["ti.checkState", "=", $params["checkState"]];
  403. }
  404. break;
  405. case 7:
  406. $where[] = ["ti.checkState", "=", TalentState::CERTIFICATED];
  407. break;
  408. }
  409. $count = Talent::alias("ti")
  410. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  411. ->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")
  412. //->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")
  413. ->where($where)->count();
  414. $list = Talent::alias("ti")
  415. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  416. ->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")
  417. //->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")
  418. ->where($where)->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();
  419. }
  420. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  421. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  422. foreach ($list as &$item) {
  423. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  424. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  425. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  426. $item["talentConditionName"] = TalentCondition::findOrEmpty($item["talent_condition"])["name"];
  427. //$last_log = TalentLogApi::getLastLog($item["id"], 1, 0, ["step", "=", null]);
  428. //$item["lastState"] = $last_log["last_state"];
  429. //$item["realState"] = $last_log["state"];
  430. }unset($item);
  431. return ["total" => $count, "rows" => $list];
  432. }
  433. public static function getExportDatas($process, $params) {
  434. $where[] = [];
  435. //特殊字段处理
  436. $exportFields = $params["export"];
  437. $fields = [];
  438. foreach ($exportFields as $field) {
  439. if (!in_array($field, ["industryFieldNew", "enterpriseName", "enterpriseTag", "street", "talent_arrange_category", "checkMsg"])) {
  440. $fields[] = "ti." . $field;
  441. }
  442. }
  443. $fields[] = "e.name as enterpriseName";
  444. $fields[] = "e.industryFieldNew";
  445. $fields[] = "e.enterpriseTag";
  446. $fields[] = "e.street";
  447. $fields[] = "tc.talentLevelCat";
  448. $fields[] = "tl.description as checkMsg";
  449. $fields[] = "tc.name as talentConditionName";
  450. $fields[] = "tl.description as checkMsg";
  451. if (in_array("card_type", $exportFields)) {
  452. $cardTypes = DictApi::selectByParentCode("card_type");
  453. }
  454. if (in_array("industryFieldNew", $exportFields)) {
  455. $industry_fields = DictApi::selectByParentCode("industry_field");
  456. }
  457. if (in_array("enterpriseTag", $exportFields)) {
  458. $enterpriseTags = DictApi::selectByParentCode("enterprise_tag");
  459. }
  460. if (in_array("street", $exportFields)) {
  461. $streets = DictApi::selectByParentCode("street");
  462. }
  463. if (in_array("nation", $exportFields)) {
  464. $nations = DictApi::selectByParentCode("nation");
  465. }
  466. if (in_array("nationality", $exportFields)) {
  467. $nationalitys = DictApi::selectByParentCode("nationality");
  468. }
  469. if (in_array("politics", $exportFields)) {
  470. $politics = DictApi::selectByParentCode("politics");
  471. }
  472. if (in_array("talent_type", $exportFields)) {
  473. $talentTypes = DictApi::selectByParentCode("talent_type");
  474. }
  475. if (in_array("talent_arrange_category", $exportFields)) {
  476. $talentArrangeCategories = DictApi::selectByParentCode("talent_condition_cats");
  477. }
  478. if (in_array("highest_degree", $exportFields)) {
  479. $highest_degree = DictApi::selectByParentCode("highest_degree");
  480. }
  481. if (in_array("import_way", $exportFields)) {
  482. $import_way = DictApi::selectByParentCode("import_way");
  483. }
  484. if (in_array("source", $exportFields)) {
  485. $source = DictApi::selectByParentCode("source");
  486. }
  487. if (in_array("source_city", $exportFields)) {
  488. $source_city = DictApi::selectByParentCode("source_city");
  489. }
  490. if (in_array("source_county", $exportFields)) {
  491. $source_county = DictApi::selectByParentCode("source_county");
  492. }
  493. if (in_array("talent_arrange", $exportFields)) {
  494. $talent_arrange = DictApi::selectByParentCode("talent_arrange");
  495. }
  496. $sex = [1 => "男", 2 => "女"];
  497. $pre_import_type = [1 => "意向合同", 2 => "创业企业名称预核准"];
  498. $study_abroad = [1 => "是", 2 => "否"];
  499. $salary_pay_way = [1 => "本单位", 2 => "本单位所属集团公司及权属公司"];
  500. $return = [1 => "是", 2 => "否"];
  501. $isMatchZhiren = [0 => "否", 1 => "是"];
  502. $where = [];
  503. $where[] = ["e.type", "=", session("user")["type"]];
  504. if ($params["all"] != 1) {
  505. if ($params["name"]) {
  506. $where[] = ["ti.name", "like", "%{$params["name"]}%"];
  507. }
  508. if ($params["card_number"]) {
  509. $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
  510. }
  511. if ($params["sex"]) {
  512. $where[] = ["ti.sex", "=", $params["sex"]];
  513. }
  514. if ($params["nation"]) {
  515. $where[] = ["ti.nation", "=", $params["nation"]];
  516. }
  517. if ($params["apply_year"]) {
  518. $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
  519. }
  520. if ($params["phone"]) {
  521. $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
  522. }
  523. if ($params["email"]) {
  524. $where[] = ["ti.email", "like", "%{$params["email"]}%"];
  525. }
  526. if ($params["nationality"]) {
  527. $where[] = ["ti.nationality", "=", $params["nationality"]];
  528. }
  529. if ($params["province"]) {
  530. $where[] = ["ti.province", "=", $params["province"]];
  531. }
  532. if ($params["politics"]) {
  533. $where[] = ["ti.politics", "=", $params["politics"]];
  534. }
  535. if ($params["enterprise_id"]) {
  536. $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
  537. }
  538. if ($params["street"]) {
  539. $where[] = ["e.street", "=", $params["street"]];
  540. }
  541. if ($params["industry_field"]) {
  542. $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
  543. }
  544. if ($params["industry_field_old"]) {
  545. $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
  546. }
  547. if ($params["enterprise_tag"]) {
  548. $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
  549. }
  550. if ($params["talent_type"]) {
  551. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  552. }
  553. if ($params["import_way"]) {
  554. $where[] = ["ti.import_way", "=", $params["import_way"]];
  555. }
  556. if ($params["highest_degree"]) {
  557. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  558. }
  559. if ($params["study_abroad"]) {
  560. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  561. }
  562. if ($params["source"]) {
  563. $where[] = ["ti.source", "=", $params["source"]];
  564. }
  565. if ($params["talent_arrange"]) {
  566. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  567. }
  568. if ($params["talent_condition"]) {
  569. $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
  570. }
  571. if ($params["isMatchZhiren"]) {
  572. $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
  573. }
  574. switch ($process) {
  575. case 1:
  576. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  577. break;
  578. case 2:
  579. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  580. break;
  581. case 3:
  582. switch ($params["checkState"]) {
  583. case -1://保存未提交
  584. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  585. $where[] = ["tl.state", "<>", TalentState::FST_VERIFY_REJECT];
  586. //$where[] = ["ti.first_submit_time", "exp", Db::raw("is null")];
  587. $where[] = ["ti.delete", "=", 0];
  588. break;
  589. case 1://待审核
  590. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  591. //$where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
  592. $where[] = ["tl.last_state", "<>", TalentState::FST_VERIFY_REJECT];
  593. break;
  594. case 2://驳回
  595. //$where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  596. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  597. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_REJECT];
  598. break;
  599. case 3://通过
  600. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_PASS]];
  601. break;
  602. case 4://失败
  603. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_FAIL]];
  604. break;
  605. case 5://重新提交
  606. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  607. $where[] = ["tl.last_state", "=", TalentState::FST_VERIFY_REJECT];
  608. break;
  609. default:
  610. //$where[] = ["ti.checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_FAIL]];
  611. //$where[] = ["tl.new_state", "in", [TalentState::SCND_SAVE, TalentState::SCND_SUBMIT]];
  612. $where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_REJECT]];
  613. }
  614. break;
  615. case 4:
  616. switch ($params["checkState"]) {
  617. case 5:
  618. $_where = [];
  619. $_where[] = ["type", "=", 1];
  620. $_where[] = ["active", "=", 1];
  621. $_where[] = ["step", "=", 3];
  622. $_where[] = ["companyId", "=", session("user")["companyId"]];
  623. $mainIds = \app\common\model\TalentChecklog::where($_where)->group("mainId")->order("createTime desc")->column("mainId");
  624. if ($mainIds) {
  625. $where[] = ["ti.id", "in", $mainIds];
  626. } else {
  627. $where[] = ["ti.checkState", "=", TalentState::FST_VERIFY_PASS];
  628. $where[] = ["ti.pass_dept_check", "=", 0];
  629. }
  630. break;
  631. default:
  632. $where[] = ["ti.checkState", "=", TalentState::FST_VERIFY_PASS];
  633. $where[] = ["ti.pass_dept_check", "=", 0];
  634. break;
  635. }
  636. break;
  637. case 5:
  638. $whereRaw = sprintf("(ti.checkState in (14,15,16)) or (ti.checkState=12 and ti.pass_dept_check=0) or (ti.checkState=10 and ti.pass_dept_check=1) or (ti.checkState=10 and (tc.companyIds is null or tc.companyIds = ''))");
  639. switch ($params["checkState"]) {
  640. case 1:
  641. $where[] = ["ti.checkState", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  642. break;
  643. case -1:
  644. $where[] = ["ti.checkState", "=", TalentState::REVERIFY_FAIL];
  645. break;
  646. }
  647. break;
  648. case 6:
  649. $where[] = ["ti.checkState", ">=", TalentState::REVERIFY_PASS];
  650. if ($params["checkState"]) {
  651. $where[] = ["ti.checkState", "=", $params["checkState"]];
  652. }
  653. break;
  654. case 7:
  655. $where[] = ["ti.checkState", "=", TalentState::CERTIFICATED];
  656. break;
  657. }
  658. } else {
  659. $where[] = ["ti.delete", "=", 0];
  660. }
  661. $fields[] = "ti.pass_dept_check";
  662. $fields[] = "tl.state";
  663. $fields[] = "tl.new_state";
  664. $fields[] = "tl.last_state";
  665. $fields[] = "tc.companyIds";
  666. if ($process == 4) {
  667. $companyId = session("user")["companyId"];
  668. $list = Talent::alias("ti")
  669. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  670. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  671. ->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")
  672. //->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)")
  673. ->where($where)
  674. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
  675. ->field($fields)
  676. ->select()->toArray();
  677. } else if ($process == 5) {
  678. $list = Talent::alias("ti")
  679. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  680. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  681. ->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")
  682. //->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)")
  683. ->whereRaw($whereRaw)
  684. ->where($where)
  685. ->field($fields)
  686. ->select()->toArray();
  687. } else {
  688. $list = Talent::alias("ti")
  689. ->field($fields)
  690. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  691. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  692. ->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")
  693. //->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)")
  694. ->where($where)
  695. ->select()->toArray();
  696. }
  697. $un_common_location = Db::table("un_common_location")->column('name','code');
  698. foreach ($list as &$item) {
  699. $item["card_type"] = $cardTypes[$item["card_type"]];
  700. $item["industryFieldNew"] = $industry_fields[$item["industryFieldNew"]];
  701. $item["enterpriseTag"] = $enterpriseTags[$item["enterpriseTag"]];
  702. $item["street"] = $streets[$item["street"]];
  703. $item["nation"] = $nations[$item["nation"]];
  704. $item["nationality"] = $nationalitys[$item["nationality"]];
  705. $item["politics"] = $politics[$item["politics"]];
  706. $item["talent_type"] = $talentTypes[$item["talent_type"]];
  707. $item["talent_arrange_category"] = $talentArrangeCategories[$item["talentLevelCat"]];
  708. $item["sex"] = $sex[$item["sex"]];
  709. $item["highest_degree"] = $highest_degree[$item["highest_degree"]];
  710. $item["import_way"] = $import_way[$item["import_way"]];
  711. $item["salary_pay_way"] = $salary_pay_way[$item["salary_pay_way"]];
  712. $item["pre_import_type"] = $pre_import_type[$item["pre_import_type"]];
  713. $item["return"] = $return[$item["return"]];
  714. $item["isMatchZhiren"] = $isMatchZhiren[$item["isMatchZhiren"]];
  715. $item["study_abroad"] = $study_abroad[$item["study_abroad"]];
  716. $item["source"] = $source[$item["source"]];
  717. $item["talent_arrange"] = $talent_arrange[$item["talent_arrange"]];
  718. $item["talent_condition"] = $item["talentConditionName"];
  719. if (in_array("source_city", $exportFields)) {
  720. $item["source_city"] = $un_common_location[$item["source_city"]];
  721. }
  722. if (in_array("source_county", $exportFields)) {
  723. $item["source_county"] = $un_common_location[$item["source_county"]];
  724. }
  725. if (in_array("province", $exportFields)) {
  726. $item["province"] = $un_common_location[$item["province"]];
  727. }
  728. if (in_array("city", $exportFields)) {
  729. $item["city"] = $un_common_location[$item["city"]];
  730. }
  731. if (in_array("county", $exportFields)) {
  732. $item["county"] = $un_common_location[$item["county"]];
  733. }
  734. if ($item["state"] == TalentState::SCND_SUBMIT) {
  735. if ($item["last_state"] == TalentState::FST_VERIFY_REJECT) {
  736. $item["checkState"] = "待审核(重新提交)";
  737. } else {
  738. $item["checkState"] = "待初审";
  739. }
  740. } else if ($item["state"] == TalentState::FST_VERIFY_PASS) {
  741. if (!$item["companyIds"] || $item["pass_dept_check"] == 1) {
  742. $item["checkState"] = "初审通过,待复审";
  743. }
  744. if ($item["pass_dept_check"] == 0) {
  745. $item["checkState"] = "初审通过,待部门审核";
  746. }
  747. } else {
  748. $item["checkState"] = TalentState::getStateName($item["state"]);
  749. }
  750. }unset($item);
  751. return $list;
  752. }
  753. public static function getListByProcess($process) {
  754. switch ($process) {
  755. case 1:
  756. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  757. break;
  758. case 2:
  759. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  760. break;
  761. case 3:
  762. $where[] = ["ti.checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_FAIL]];
  763. break;
  764. default:
  765. return null;
  766. }
  767. return Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->field("ti.*,e.agentName,e.agentPhone")->select()->toArray();
  768. }
  769. public static function setPublic($mainId, $state, $msg, $batch = null, $type = 1) {
  770. $data["id"] = $mainId;
  771. $data["checkState"] = $state;
  772. switch ($state) {
  773. case TalentState::ZX_PASS:
  774. case TalentState::ZX_FAIL:
  775. $data["isPublic"] = 2;
  776. break;
  777. case TalentState::ANNOUNCED:
  778. $data["isPublic"] = 3;
  779. $data["publicBatch"] = $batch;
  780. break;
  781. case TalentState::ANNOUNCED_REVERIFY_PASS:
  782. case TalentState::ANNOUNCED_REVERIFY_FAIL:
  783. $data["isPublic"] = 3;
  784. break;
  785. case TalentState::PUBLISH_PASS:
  786. $data["isPublic"] = 4;
  787. $data["identifyMonth"] = $batch;
  788. $data["certificateGetTime"] = $batch; //时间待定
  789. $data["certificateExpireTime"] = date("Y-m-d", strtotime(sprintf("%s +6 years -1 days", $batch))); //时间待定
  790. break;
  791. case TalentState::PUBLISH_FAIL:
  792. $data["isPublic"] = 4;
  793. break;
  794. }
  795. if (Talent::update($data)) {
  796. TalentLogApi::write($type, $mainId, $state, $msg, 1);
  797. return true;
  798. }
  799. return false;
  800. }
  801. }