VerifyApi.php 45 KB

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