VerifyApi.php 62 KB

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