VerifyApi.php 63 KB

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