VerifyApi.php 67 KB

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