VerifyApi.php 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043
  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. if ($params["company_id"]) {
  152. $where[] = ["tc.companyIds", "like", "%" . $params["company_id"] . "%"];
  153. }
  154. switch ($params["checkState"]) {
  155. case 1:
  156. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  157. $where[] = ["ti.pass_dept_check", "=", 0];
  158. break;
  159. case 2:
  160. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  161. break;
  162. case 3:
  163. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_PASS];
  164. break;
  165. default:
  166. $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);
  167. break;
  168. }
  169. $companyId = session("user")["companyId"];
  170. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  171. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  172. $count = Talent::alias("ti")
  173. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  174. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  175. ->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")
  176. ->where($where)
  177. ->where($whereRaw)->count();
  178. $list = Talent::alias("ti")
  179. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  180. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  181. ->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")
  182. ->where($where)
  183. ->where($whereRaw)
  184. ->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag,tc.name as talentConditionName,tc.companyIds")
  185. ->limit($offset, $limit)->order("ti.createTime " . $order)
  186. ->select()->toArray();
  187. foreach ($list as &$item) {
  188. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  189. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  190. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  191. $companys = array_filter(explode(",", $item["companyIds"]));
  192. $verifyDepts = [];
  193. foreach ($companys as $k => $companyId) {
  194. $company = getCacheById("Company", $companyId);
  195. $log = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
  196. $verifyDepts[$k]["id"] = $companyId;
  197. $verifyDepts[$k]["shortName"] = $company["shortName"];
  198. $verifyDepts[$k]["name"] = $company["name"];
  199. $verifyDepts[$k]["code"] = $company["code"];
  200. $verifyDepts[$k]["checkState"] = $log["new_state"];
  201. $verifyDepts[$k]["active"] = $log["active"];
  202. }
  203. $item["verifyDepts"] = $verifyDepts;
  204. }unset($item);
  205. return ["total" => $count, "rows" => $list];
  206. }
  207. public static function getDeptList($params, $where = []) {
  208. $order = $params["order"] ?: "desc";
  209. $offset = $params["offset"] ?: 0;
  210. $limit = $params["limit"] ?: 10;
  211. $companyId = session("user")["companyId"];
  212. switch ($params["checkState"]) {
  213. case 1:
  214. //待审核
  215. $where[] = ["tl.active", "=", 0];
  216. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  217. break;
  218. case 2:
  219. //已驳回
  220. $where[] = ["tl.active", "=", 1];
  221. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  222. break;
  223. case 3:
  224. //已通过
  225. $where[] = ["tl.active", "=", 1];
  226. $where[] = ["tl.new_state", "=", TalentState::DEPT_VERIFY_PASS];
  227. break;
  228. default:
  229. $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);
  230. break;
  231. }
  232. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  233. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  234. $count = Talent::alias("ti")
  235. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  236. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  237. ->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")
  238. ->where($where)
  239. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])->count();
  240. $list = Talent::alias("ti")
  241. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  242. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  243. ->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")
  244. ->where($where)
  245. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
  246. ->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")
  247. ->limit($offset, $limit)->order("ti.createTime " . $order)
  248. ->select()->toArray();
  249. foreach ($list as &$item) {
  250. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  251. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  252. $lastCheckLog = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
  253. $item["deptCheckState"] = $lastCheckLog["new_state"];
  254. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  255. }unset($item);
  256. return ["total" => $count, "rows" => $list];
  257. }
  258. public static function getPublicList($params) {
  259. $order = $params["order"];
  260. $offset = $params["offset"];
  261. $limit = $params["limit"];
  262. $where = [];
  263. $where[] = ["e.type", "=", session("user")["type"]];
  264. if ($params["name"]) {
  265. $where[] = ["ti.name", "like", "%" . $params["name"] . "%"];
  266. }
  267. if ($params["sex"]) {
  268. $where[] = ["ti.sex", "=", $params["sex"]];
  269. }
  270. if ($params["checkState"]) {
  271. $where[] = ["ti.checkState", "=", $params["checkState"]];
  272. }
  273. $type = $params["type"];
  274. switch ($type) {
  275. case 1:
  276. case 2:
  277. $where[] = ["ti.checkState", "=", TalentState::REVERIFY_PASS];
  278. break;
  279. case 3: //公示
  280. case 7: //公示预览
  281. $where[] = ["ti.checkState", "=", TalentState::ZX_PASS];
  282. break;
  283. case 4: //公示通过
  284. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED];
  285. break;
  286. case 5:
  287. case 8: //公布预览
  288. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED_REVERIFY_PASS];
  289. break;
  290. case 6:
  291. $where[] = ["ti.checkState", "=", TalentState::PUBLISH_PASS];
  292. break;
  293. }
  294. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  295. $count = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->count();
  296. $list = Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  297. ->where($where)
  298. ->limit($offset, $limit)
  299. ->order("ti.createTime " . $order)->field("ti.*,e.name as enterpriseName,e.type as enterprise_type,enterpriseTag")->select()->toArray();
  300. foreach ($list as &$item) {
  301. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  302. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  303. }unset($item);
  304. return ["total" => $count, "rows" => $list];
  305. }
  306. public static function getListByIds($ids) {
  307. $where[] = ["id", "in", $ids];
  308. return Talent::where($where)->select()->toArray();
  309. }
  310. public static function getList($params) {
  311. $where = [];
  312. $order = $params["order"] ?: "desc";
  313. $offset = $params["offset"] ?: 0;
  314. $limit = $params["limit"] ?: 10;
  315. $where[] = ["e.type", "=", session("user")["type"]];
  316. if ($params["name"]) {
  317. $where[] = ["ti.name", "like", "%{$params["name"]}%"];
  318. }
  319. if ($params["card_number"]) {
  320. $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
  321. }
  322. if ($params["sex"]) {
  323. $where[] = ["ti.sex", "=", $params["sex"]];
  324. }
  325. if ($params["nation"]) {
  326. $where[] = ["ti.nation", "=", $params["nation"]];
  327. }
  328. if ($params["apply_year"]) {
  329. $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
  330. }
  331. if ($params["phone"]) {
  332. $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
  333. }
  334. if ($params["email"]) {
  335. $where[] = ["ti.email", "like", "%{$params["email"]}%"];
  336. }
  337. if ($params["nationality"]) {
  338. $where[] = ["ti.nationality", "=", $params["nationality"]];
  339. }
  340. if ($params["province"]) {
  341. $where[] = ["ti.province", "=", $params["province"]];
  342. }
  343. if ($params["politics"]) {
  344. $where[] = ["ti.politics", "=", $params["politics"]];
  345. }
  346. if ($params["enterprise_id"]) {
  347. $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
  348. }
  349. if ($params["street"]) {
  350. $where[] = ["e.street", "=", $params["street"]];
  351. }
  352. if ($params["industry_field"]) {
  353. $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
  354. }
  355. if ($params["industry_field_old"]) {
  356. $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
  357. }
  358. if ($params["enterprise_tag"]) {
  359. $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
  360. }
  361. if ($params["talent_type"]) {
  362. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  363. }
  364. if ($params["import_way"]) {
  365. $where[] = ["ti.import_way", "=", $params["import_way"]];
  366. }
  367. if ($params["highest_degree"]) {
  368. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  369. }
  370. if ($params["study_abroad"]) {
  371. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  372. }
  373. if ($params["source"]) {
  374. $where[] = ["ti.source", "=", $params["source"]];
  375. }
  376. if ($params["talent_arrange"]) {
  377. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  378. }
  379. if ($params["talent_condition"]) {
  380. $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
  381. }
  382. if ($params["isMatchZhiren"]) {
  383. $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
  384. }
  385. $process = $params["process"];
  386. if ($process == 4) {
  387. $companyId = session('user')['companyId'];
  388. $company_info = CompanyApi::getOne($companyId);
  389. if ($company_info["code"] == "super" || $company_info["code"] == "rsj") {
  390. return self::getFullDeptList($params, $where);
  391. } else {
  392. return self::getDeptList($params, $where);
  393. }
  394. }
  395. if ($process == 5) {
  396. $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 = ''))");
  397. switch ($params["checkState"]) {
  398. case 1://待复审(首次提交)
  399. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  400. $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  401. break;
  402. case 2://待复审(重新提交)
  403. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  404. $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  405. break;
  406. case 3://复审通过
  407. $where[] = ["tl.state", "=", TalentState::REVERIFY_PASS];
  408. break;
  409. case 4://复审驳回
  410. $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
  411. break;
  412. case 5://复审不通过
  413. $where[] = ["tl.state", "=", TalentState::REVERIFY_FAIL];
  414. break;
  415. }
  416. $count = Talent::alias("ti")
  417. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  418. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  419. ->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")
  420. ->leftJoin("(select id as resubmit,mainId from new_talent_checklog where state=15 and `type`=1 and `active`=1 group by mainId) as tl2", "`tl2`.mainId=`ti`.id")
  421. ->whereRaw($whereRaw)->where($where)->count();
  422. $list = Talent::alias("ti")
  423. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  424. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  425. ->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")
  426. ->leftJoin("(select id as resubmit,mainId from new_talent_checklog where state=15 and `type`=1 and `active`=1 group by mainId) as tl2", "`tl2`.mainId=`ti`.id")
  427. ->whereRaw($whereRaw)
  428. ->where($where)
  429. ->limit($offset, $limit)
  430. ->order("ti.createTime " . $order)
  431. ->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterprise_name,e.type as enterprise_type,enterpriseTag,tl2.resubmit")
  432. ->select()->toArray();
  433. } else {
  434. switch ($process) {
  435. case 1:
  436. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  437. break;
  438. case 2:
  439. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  440. break;
  441. case 3:
  442. switch ($params["checkState"]) {
  443. case 1://保存未提交
  444. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  445. $where[] = ["tl.state", "=", TalentState::SCND_SAVE];
  446. $where[] = ["ti.delete", "=", 0];
  447. break;
  448. case 2://初审驳回
  449. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  450. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_REJECT];
  451. break;
  452. case 3://待初审(首次提交)
  453. $where[] = ["tl.last_state", "<>", TalentState::FST_VERIFY_REJECT];
  454. $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
  455. break;
  456. case 4://待初审(重新提交)
  457. $where[] = ["tl.last_state", "=", TalentState::FST_VERIFY_REJECT];
  458. $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
  459. break;
  460. case 5://待初审(部门并审驳回)
  461. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  462. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  463. break;
  464. case 6://待初审(复审驳回)
  465. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  466. $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
  467. break;
  468. case 7://初审通过(待部门并审)
  469. $where[] = ["ti.pass_dept_check", "=", 0];
  470. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  471. break;
  472. case 8://初审通过(待复审)
  473. $where[] = ["ti.pass_dept_check", "=", 1];
  474. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  475. break;
  476. case 9://初审不通过
  477. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_FAIL];
  478. break;
  479. default:
  480. //$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);
  481. $where[] = ["tl.state", "in", [TalentState::SCND_SAVE, TalentState::FST_VERIFY_REJECT, TalentState::SCND_SUBMIT,
  482. TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_FAIL]];
  483. $where[] = ["ti.delete", "=", 0];
  484. }
  485. break;
  486. case 6:
  487. $where[] = ["tl.state", ">=", TalentState::REVERIFY_PASS];
  488. $where[] = ["tl.state", "not in", [TalentState::REVERIFY_REJECT, TalentState::REVERIFY_FAIL]];
  489. if ($params["checkState"]) {
  490. $where[] = ["tl.state", "=", $params["checkState"]];
  491. }
  492. break;
  493. case 7:
  494. $where[] = ["tl.state", "=", TalentState::CERTIFICATED];
  495. break;
  496. }
  497. $count = Talent::alias("ti")
  498. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  499. ->leftJoin("(select mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  500. //->leftJoin("(select 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")
  501. ->where($where)->where($whereRaw)->count();
  502. $list = Talent::alias("ti")
  503. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  504. ->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")
  505. //->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")
  506. ->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();
  507. }
  508. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  509. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  510. foreach ($list as &$item) {
  511. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  512. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  513. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  514. $item["talentConditionName"] = TalentCondition::findOrEmpty($item["talent_condition"])["name"];
  515. //$last_log = TalentLogApi::getLastLog($item["id"], 1, 0, ["step", "=", null]);
  516. //$item["lastState"] = $last_log["last_state"];
  517. //$item["realState"] = $last_log["state"];
  518. }unset($item);
  519. return ["total" => $count, "rows" => $list];
  520. }
  521. public static function getExportDatas($process, $params) {
  522. $where[] = [];
  523. //特殊字段处理
  524. $exportFields = $params["export"];
  525. $fields = [];
  526. foreach ($exportFields as $field) {
  527. if (!in_array($field, ["industryFieldNew", "enterpriseName", "enterpriseTag", "street", "talent_arrange_category", "checkMsg"])) {
  528. $fields[] = "ti." . $field;
  529. }
  530. }
  531. $fields[] = "e.name as enterpriseName";
  532. $fields[] = "e.industryFieldNew";
  533. $fields[] = "e.enterpriseTag";
  534. $fields[] = "e.street";
  535. $fields[] = "tc.talentLevelCat";
  536. $fields[] = "tl.description as checkMsg";
  537. $fields[] = "tc.name as talentConditionName";
  538. $fields[] = "tl.description as checkMsg";
  539. if (in_array("card_type", $exportFields)) {
  540. $cardTypes = DictApi::selectByParentCode("card_type");
  541. }
  542. if (in_array("industryFieldNew", $exportFields)) {
  543. $industry_fields = DictApi::selectByParentCode("industry_field");
  544. }
  545. if (in_array("enterpriseTag", $exportFields)) {
  546. $enterpriseTags = DictApi::selectByParentCode("enterprise_tag");
  547. }
  548. if (in_array("street", $exportFields)) {
  549. $streets = DictApi::selectByParentCode("street");
  550. }
  551. if (in_array("nation", $exportFields)) {
  552. $nations = DictApi::selectByParentCode("nation");
  553. }
  554. if (in_array("nationality", $exportFields)) {
  555. $nationalitys = DictApi::selectByParentCode("nationality");
  556. }
  557. if (in_array("politics", $exportFields)) {
  558. $politics = DictApi::selectByParentCode("politics");
  559. }
  560. if (in_array("talent_type", $exportFields)) {
  561. $talentTypes = DictApi::selectByParentCode("talent_type");
  562. }
  563. if (in_array("talent_arrange_category", $exportFields)) {
  564. $talentArrangeCategories = DictApi::selectByParentCode("talent_condition_cats");
  565. }
  566. if (in_array("highest_degree", $exportFields)) {
  567. $highest_degree = DictApi::selectByParentCode("highest_degree");
  568. }
  569. if (in_array("import_way", $exportFields)) {
  570. $import_way = DictApi::selectByParentCode("import_way");
  571. }
  572. if (in_array("source", $exportFields)) {
  573. $source = DictApi::selectByParentCode("source");
  574. }
  575. if (in_array("source_city", $exportFields)) {
  576. $source_city = DictApi::selectByParentCode("source_city");
  577. }
  578. if (in_array("source_county", $exportFields)) {
  579. $source_county = DictApi::selectByParentCode("source_county");
  580. }
  581. if (in_array("talent_arrange", $exportFields)) {
  582. $talent_arrange = DictApi::selectByParentCode("talent_arrange");
  583. }
  584. $sex = [1 => "男", 2 => "女"];
  585. $pre_import_type = [1 => "意向合同", 2 => "创业企业名称预核准"];
  586. $study_abroad = [1 => "是", 2 => "否"];
  587. $salary_pay_way = [1 => "本单位", 2 => "本单位所属集团公司及权属公司"];
  588. $return = [1 => "是", 2 => "否"];
  589. $isMatchZhiren = [0 => "否", 1 => "是"];
  590. $where = [];
  591. $where[] = ["e.type", "=", session("user")["type"]];
  592. if ($params["all"] != 1) {
  593. if ($params["name"]) {
  594. $where[] = ["ti.name", "like", "%{$params["name"]}%"];
  595. }
  596. if ($params["card_number"]) {
  597. $where[] = ["ti.card_number", "like", "%" . $params["card_number"] . "%"];
  598. }
  599. if ($params["sex"]) {
  600. $where[] = ["ti.sex", "=", $params["sex"]];
  601. }
  602. if ($params["nation"]) {
  603. $where[] = ["ti.nation", "=", $params["nation"]];
  604. }
  605. if ($params["apply_year"]) {
  606. $where[] = ["ti.apply_year", "like", "{$params["apply_year"]}%"];
  607. }
  608. if ($params["phone"]) {
  609. $where[] = ["ti.phone", "like", "%{$params["phone"]}%"];
  610. }
  611. if ($params["email"]) {
  612. $where[] = ["ti.email", "like", "%{$params["email"]}%"];
  613. }
  614. if ($params["nationality"]) {
  615. $where[] = ["ti.nationality", "=", $params["nationality"]];
  616. }
  617. if ($params["province"]) {
  618. $where[] = ["ti.province", "=", $params["province"]];
  619. }
  620. if ($params["politics"]) {
  621. $where[] = ["ti.politics", "=", $params["politics"]];
  622. }
  623. if ($params["enterprise_id"]) {
  624. $where[] = ["ti.enterprise_id", "=", $params["enterprise_id"]];
  625. }
  626. if ($params["street"]) {
  627. $where[] = ["e.street", "=", $params["street"]];
  628. }
  629. if ($params["industry_field"]) {
  630. $where[] = ["e.industryFieldNew", "=", $params["industry_field"]];
  631. }
  632. if ($params["industry_field_old"]) {
  633. $where[] = ["e.industryFieldOld", "=", $params["industry_field_old"]];
  634. }
  635. if ($params["enterprise_tag"]) {
  636. $where[] = ["e.enterpriseTag", "=", $params["enterprise_tag"]];
  637. }
  638. if ($params["talent_type"]) {
  639. $where[] = ["ti.talent_type", "=", $params["talent_type"]];
  640. }
  641. if ($params["import_way"]) {
  642. $where[] = ["ti.import_way", "=", $params["import_way"]];
  643. }
  644. if ($params["highest_degree"]) {
  645. $where[] = ["ti.highest_degree", "=", $params["highest_degree"]];
  646. }
  647. if ($params["study_abroad"]) {
  648. $where[] = ["ti.study_abroad", "=", $params["study_abroad"]];
  649. }
  650. if ($params["source"]) {
  651. $where[] = ["ti.source", "=", $params["source"]];
  652. }
  653. if ($params["talent_arrange"]) {
  654. $where[] = ["ti.talent_arrange", "=", $params["talent_arrange"]];
  655. }
  656. if ($params["talent_condition"]) {
  657. $where[] = ["ti.talent_condition", "=", $params["talent_condition"]];
  658. }
  659. if ($params["isMatchZhiren"]) {
  660. $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
  661. }
  662. switch ($process) {
  663. case 1:
  664. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  665. break;
  666. case 2:
  667. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  668. break;
  669. case 3:
  670. switch ($params["checkState"]) {
  671. case 1://保存未提交
  672. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  673. $where[] = ["tl.state", "=", TalentState::SCND_SAVE];
  674. $where[] = ["ti.delete", "=", 0];
  675. break;
  676. case 2://初审驳回
  677. $where[] = ["tl.new_state", "=", TalentState::SCND_SAVE];
  678. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_REJECT];
  679. break;
  680. case 3://待初审(首次提交)
  681. $where[] = ["tl.last_state", "<>", TalentState::FST_VERIFY_REJECT];
  682. $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
  683. break;
  684. case 4://待初审(重新提交)
  685. $where[] = ["tl.last_state", "=", TalentState::FST_VERIFY_REJECT];
  686. $where[] = ["tl.state", "=", TalentState::SCND_SUBMIT];
  687. break;
  688. case 5://待初审(部门并审驳回)
  689. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  690. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  691. break;
  692. case 6://待初审(复审驳回)
  693. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  694. $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
  695. break;
  696. case 7://初审通过(待部门并审)
  697. $where[] = ["ti.pass_dept_check", "=", 0];
  698. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  699. break;
  700. case 8://初审通过(待复审)
  701. $where[] = ["ti.pass_dept_check", "=", 1];
  702. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  703. break;
  704. case 9://初审不通过
  705. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_FAIL];
  706. break;
  707. default:
  708. $where[] = ["tl.state", "in", [TalentState::SCND_SAVE, TalentState::FST_VERIFY_REJECT, TalentState::SCND_SUBMIT,
  709. TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT, TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_FAIL]];
  710. $where[] = ["ti.delete", "=", 0];
  711. }
  712. break;
  713. case 4:
  714. $companyId = session('user')['companyId'];
  715. $company_info = CompanyApi::getOne($companyId);
  716. if ($company_info["code"] == "super" || $company_info["code"] == "rsj") {
  717. switch ($params["checkState"]) {
  718. case 1:
  719. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  720. $where[] = ["ti.pass_dept_check", "=", 0];
  721. break;
  722. case 2:
  723. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_REJECT];
  724. break;
  725. case 3:
  726. $where[] = ["tl.state", "=", TalentState::DEPT_VERIFY_PASS];
  727. break;
  728. default:
  729. $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);
  730. break;
  731. }
  732. } else {
  733. switch ($params["checkState"]) {
  734. case 1:
  735. //待审核
  736. $where[] = ["tl.active", "=", 0];
  737. $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
  738. break;
  739. case 2:
  740. //已驳回
  741. $where[] = ["tl.active", "=", 1];
  742. $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
  743. break;
  744. case 3:
  745. //已通过
  746. $where[] = ["tl.active", "=", 1];
  747. $where[] = ["tl.new_state", "=", TalentState::DEPT_VERIFY_PASS];
  748. break;
  749. default:
  750. $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);
  751. break;
  752. }
  753. }
  754. break;
  755. case 5:
  756. $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 = ''))");
  757. switch ($params["checkState"]) {
  758. case 1://待复审(首次提交)
  759. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  760. $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
  761. break;
  762. case 2://待复审(重新提交)
  763. $where[] = ["tl.state", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  764. $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
  765. break;
  766. case 3://复审通过
  767. $where[] = ["tl.state", "=", TalentState::REVERIFY_PASS];
  768. break;
  769. case 4://复审驳回
  770. $where[] = ["tl.state", "=", TalentState::REVERIFY_REJECT];
  771. break;
  772. case 5://复审不通过
  773. $where[] = ["tl.state", "=", TalentState::REVERIFY_FAIL];
  774. break;
  775. }
  776. break;
  777. case 6:
  778. $where[] = ["tl.state", ">=", TalentState::REVERIFY_PASS];
  779. if ($params["checkState"]) {
  780. $where[] = ["tl.state", "=", $params["checkState"]];
  781. }
  782. break;
  783. case 7:
  784. $where[] = ["tl.state", "=", TalentState::CERTIFICATED];
  785. break;
  786. }
  787. } else {
  788. $whereRaw = "tl.state is not null";
  789. $where[] = ["ti.delete", "=", 0];
  790. }
  791. $fields[] = "ti.id";
  792. $fields[] = "ti.pass_dept_check";
  793. $fields[] = "tl.state";
  794. $fields[] = "tl.new_state";
  795. $fields[] = "tl.last_state";
  796. $fields[] = "tc.companyIds";
  797. if ($process == 4) {
  798. if ($company_info["code"] == "super" || $company_info["code"] == "rsj") {
  799. $list = Talent::alias("ti")
  800. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  801. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  802. ->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")
  803. ->where($where)
  804. ->where($whereRaw)
  805. ->field($fields)
  806. ->select()->toArray();
  807. } else {
  808. $fields[] = "tl.active";
  809. $fields[] = "tl.new_state as deptCheckState";
  810. $fields[] = "tl.createTime as first_dept_check_time";
  811. $list = Talent::alias("ti")
  812. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  813. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  814. ->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")
  815. ->where($where)
  816. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
  817. ->field($fields)
  818. ->select()->toArray();
  819. }
  820. } else if ($process == 5) {
  821. $fields[] = "tl2.resubmit";
  822. $list = Talent::alias("ti")
  823. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  824. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  825. ->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")
  826. ->leftJoin("(select id as resubmit,mainId from new_talent_checklog where state=15 and `type`=1 and `active`=1 group by mainId) as tl2", "`tl2`.mainId=`ti`.id")
  827. ->whereRaw($whereRaw)
  828. ->where($where)
  829. ->field($fields)
  830. ->select()->toArray();
  831. } else {
  832. $list = Talent::alias("ti")
  833. ->field($fields)
  834. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  835. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  836. ->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")
  837. //->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)")
  838. ->where($where)
  839. ->where($whereRaw)
  840. ->select()->toArray();
  841. }
  842. $un_common_location = Db::table("un_common_location")->column('name', 'code');
  843. foreach ($list as &$item) {
  844. $item["card_type"] = $cardTypes[$item["card_type"]];
  845. $item["industryFieldNew"] = $industry_fields[$item["industryFieldNew"]];
  846. $item["enterpriseTag"] = $enterpriseTags[$item["enterpriseTag"]];
  847. $item["street"] = $streets[$item["street"]];
  848. $item["nation"] = $nations[$item["nation"]];
  849. $item["nationality"] = $nationalitys[$item["nationality"]];
  850. $item["politics"] = $politics[$item["politics"]];
  851. $item["talent_type"] = $talentTypes[$item["talent_type"]];
  852. $item["talent_arrange_category"] = $talentArrangeCategories[$item["talentLevelCat"]];
  853. $item["sex"] = $sex[$item["sex"]];
  854. $item["highest_degree"] = $highest_degree[$item["highest_degree"]];
  855. $item["import_way"] = $import_way[$item["import_way"]];
  856. $item["salary_pay_way"] = $salary_pay_way[$item["salary_pay_way"]];
  857. $item["pre_import_type"] = $pre_import_type[$item["pre_import_type"]];
  858. $item["return"] = $return[$item["return"]];
  859. $item["isMatchZhiren"] = $isMatchZhiren[$item["isMatchZhiren"]];
  860. $item["study_abroad"] = $study_abroad[$item["study_abroad"]];
  861. $item["source"] = $source[$item["source"]];
  862. $item["talent_arrange"] = $talent_arrange[$item["talent_arrange"]];
  863. $item["talent_condition"] = $item["talentConditionName"];
  864. if (in_array("source_city", $exportFields)) {
  865. $item["source_city"] = $un_common_location[$item["source_city"]];
  866. }
  867. if (in_array("source_county", $exportFields)) {
  868. $item["source_county"] = $un_common_location[$item["source_county"]];
  869. }
  870. if (in_array("province", $exportFields)) {
  871. $item["province"] = $un_common_location[$item["province"]];
  872. }
  873. if (in_array("city", $exportFields)) {
  874. $item["city"] = $un_common_location[$item["city"]];
  875. }
  876. if (in_array("county", $exportFields)) {
  877. $item["county"] = $un_common_location[$item["county"]];
  878. }
  879. if ($item["state"] == TalentState::SCND_SUBMIT) {
  880. if ($item["last_state"] == TalentState::FST_VERIFY_REJECT) {
  881. $item["checkState"] = "待初审(重新提交)";
  882. } else {
  883. $item["checkState"] = "待初审(首次提交)";
  884. }
  885. } else if ($item["state"] == TalentState::FST_VERIFY_PASS) {
  886. if ($item["deptCheckState"]) {
  887. if ($item["acitve"] == 0 && $item["state"] == TalentState::FST_VERIFY_PASS) {
  888. $item["checkState"] = "待部门并审";
  889. }
  890. if ($item["active"] == 1 && $item["new_state"] == TalentState::DEPT_VERIFY_PASS) {
  891. $item["checkState"] = "部门并审通过";
  892. }
  893. if ($item["active"] == 1 && $item["new_state"] == TalentState::SCND_SUBMIT) {
  894. $item["checkState"] = "部门并审驳回";
  895. }
  896. } else {
  897. if (!$item["companyIds"] || $item["pass_dept_check"] == 1) {
  898. if ($process == 3) {
  899. $item["checkState"] = "初审通过(待复审)";
  900. } else {
  901. if ($item["resubmit"]) {
  902. $item["checkState"] = "待复审(重新提交)";
  903. } else {
  904. $item["checkState"] = "待复审(首次提交)";
  905. }
  906. }
  907. }
  908. if ($item["pass_dept_check"] == 0) {
  909. if ($process == 3) {
  910. $item["checkState"] = "初审通过(待部门并审)";
  911. } else {
  912. $item["checkState"] = "待部门并审";
  913. }
  914. }
  915. }
  916. } else if ($item["state"] == TalentState::DEPT_VERIFY_REJECT) {
  917. if ($process == 3) {
  918. $item["checkState"] = "待初审(部门并审驳回)";
  919. } else {
  920. $item["checkState"] = "部门并审驳回";
  921. }
  922. } else if ($item["state"] == TalentState::DEPT_VERIFY_PASS) {
  923. if ($process == 3) {
  924. $item["checkState"] = "待复审(部门并审通过)";
  925. } else if ($process == 4) {
  926. $item["checkState"] = "部门并审通过";
  927. } else {
  928. if ($item["resubmit"]) {
  929. $item["checkState"] = "待复审(重新提交)";
  930. } else {
  931. $item["checkState"] = "待复审(首次提交)";
  932. }
  933. }
  934. } else if ($item["state"] == TalentState::REVERIFY_REJECT) {
  935. if ($process == 3) {
  936. $item["checkState"] = "待初审(复审驳回)";
  937. } else {
  938. $item["checkState"] = "复审驳回";
  939. }
  940. } else {
  941. $item["checkState"] = TalentState::getStateName($item["state"]);
  942. }
  943. if ($process == 4 && in_array($company_info["code"], ["super", "rsj"])) {
  944. $companys = array_filter(explode(",", $item["companyIds"]));
  945. $verifyDepts = [];
  946. $item["deptReject"] = 0;
  947. $item["deptPass"] = 0;
  948. $item["deptWait"] = 0;
  949. $deptDescriptions = [];
  950. foreach ($companys as $k => $companyId) {
  951. $company = getCacheById("Company", $companyId);
  952. $log = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
  953. $item["first_dept_check_time"] = $log["createTime"];
  954. $verifyDepts[$k] = $company["name"];
  955. if ($log["active"] == 1) {
  956. if ($log["new_state"] == 9) {
  957. $verifyDepts[$k] .= "(审核驳回)";
  958. $item["deptReject"]++;
  959. }
  960. if ($log["new_state"] == 12) {
  961. $verifyDepts[$k] .= "(审核通过)";
  962. $item["deptPass"]++;
  963. }
  964. $deptDescriptions[] = sprintf("%s:%s", $company["name"], $log["description"]);
  965. } else {
  966. $verifyDepts[$k] .= "(待审核)";
  967. $item["deptWait"]++;
  968. }
  969. }
  970. $item["verifyDepts"] = implode(chr(10), $verifyDepts);
  971. $item["deptDescription"] = implode(chr(10), $deptDescriptions);
  972. }
  973. }unset($item);
  974. return $list;
  975. }
  976. public static function getListByProcess($process) {
  977. switch ($process) {
  978. case 1:
  979. $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
  980. break;
  981. case 2:
  982. $where[] = ["ti.checkState", "in", [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_FAIL]];
  983. break;
  984. case 3:
  985. $where[] = ["ti.checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_FAIL]];
  986. break;
  987. default:
  988. return null;
  989. }
  990. return Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->where($where)->field("ti.*,e.agentName,e.agentPhone")->select()->toArray();
  991. }
  992. public static function setPublic($mainId, $state, $msg, $batch = null, $type = 1) {
  993. $data["id"] = $mainId;
  994. $data["checkState"] = $state;
  995. switch ($state) {
  996. case TalentState::ZX_PASS:
  997. case TalentState::ZX_FAIL:
  998. $data["isPublic"] = 2;
  999. break;
  1000. case TalentState::ANNOUNCED:
  1001. $data["isPublic"] = 3;
  1002. $data["publicBatch"] = $batch;
  1003. break;
  1004. case TalentState::ANNOUNCED_REVERIFY_PASS:
  1005. case TalentState::ANNOUNCED_REVERIFY_FAIL:
  1006. $data["isPublic"] = 3;
  1007. break;
  1008. case TalentState::PUBLISH_PASS:
  1009. $data["isPublic"] = 4;
  1010. $data["identifyMonth"] = $batch;
  1011. $data["certificateGetTime"] = $batch; //时间待定
  1012. $data["certificateExpireTime"] = date("Y-m-d", strtotime(sprintf("%s +6 years -1 days", $batch))); //时间待定
  1013. break;
  1014. case TalentState::PUBLISH_FAIL:
  1015. $data["isPublic"] = 4;
  1016. break;
  1017. }
  1018. if (Talent::update($data)) {
  1019. TalentLogApi::write($type, $mainId, $state, $msg, 1);
  1020. return true;
  1021. }
  1022. return false;
  1023. }
  1024. }