Talent.php 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. <?php
  2. namespace app\enterprise\controller;
  3. use app\enterprise\common\EnterpriseController;
  4. use app\enterprise\api\TalentApi;
  5. use app\enterprise\model\Talent as TalentModel;
  6. use think\facade\Db;
  7. use think\facade\Log;
  8. use app\common\api\EnterpriseApi;
  9. use app\common\api\DictApi;
  10. use app\common\api\TalentLogApi;
  11. use app\common\api\TalentState;
  12. use think\exception\ValidateException;
  13. use app\enterprise\validate\TalentInfo;
  14. use app\common\state\ProjectState;
  15. use app\common\api\BatchApi;
  16. // 0正在填写 1保存未提交 2已提交未审核 3已审核 4驳回 5保存补充材料未提交 6提交补充材料进入初审 7初审通过 8初审驳回 9部门审核通过 10部门审核驳回 11复核通过 12复核驳回 13复核失败
  17. /**
  18. * Description of Talent
  19. *
  20. * @author sgq
  21. */
  22. class Talent extends EnterpriseController {
  23. public function index() {
  24. $isMix = $this->request->param("isMix");
  25. $tpl = "";
  26. if ($isMix == 1) {
  27. $tpl = "newIndex";
  28. }
  29. return view($tpl, ['type' => session("user")['type']]);
  30. }
  31. public function list() {
  32. $step = 2;
  33. $res = TalentApi::getList($this->request, $step);
  34. return json($res);
  35. }
  36. public function zrIndex() {
  37. return view();
  38. }
  39. /**
  40. * 新人才申报企业端统一申报入口,混合基础信息及人才信息
  41. */
  42. public function apply(\think\Request $request) {
  43. $type = $this->user["type"];
  44. $tpl = "";
  45. switch ($type) {
  46. case 1:
  47. $tpl = "apply"; //晋江人才
  48. break;
  49. case 2:
  50. $tpl = "ic_apply"; //集成电路
  51. break;
  52. }
  53. $param = $request->param();
  54. $id = isset($param["id"]) ? $param["id"] : 0;
  55. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  56. if ($info["isImport"]) {
  57. //$tpl = "no_file_apply"; //晋江人才
  58. }
  59. $ep = EnterpriseApi::getOne($this->user["uid"]);
  60. if (!chkEnterpriseFull($ep))
  61. return;
  62. $tagList = DictApi::selectByParentCode('enterprise_tag');
  63. $streetList = DictApi::selectByParentCode('street');
  64. $industryFieldNew = DictApi::selectByParentCode('industry_field');
  65. $ep->enterpristTagName = $tagList[$ep->enterpriseTag];
  66. $ep->streetName = $streetList[$ep->street];
  67. $ep->industryFieldNewName = $industryFieldNew[$ep->industryFieldNew];
  68. if ($info) {
  69. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  70. }
  71. if ($info && in_array($info["checkState"], [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::REVERIFY_PASS, TalentState::REVERIFY_FAIL])) {
  72. return $this->view($request);
  73. exit();
  74. }
  75. if ($request->isPost()) {
  76. $checkState = $info["checkState"] ?: 0;
  77. if ($checkState == TalentState::SCND_SAVE || $checkState == 0) {
  78. switch ($type) {
  79. case 1:
  80. $this->mixSave($info, $request, TalentState::SCND_SAVE);
  81. exit();
  82. break;
  83. case 2:
  84. $this->icSave($info, $request, TalentState::SCND_SAVE);
  85. exit();
  86. break;
  87. }
  88. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
  89. $res = ["msg" => "审核不通过,不能再保存"];
  90. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  91. exit;
  92. }
  93. $res = ["msg" => "已提交审核,请耐心等待"];
  94. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  95. exit;
  96. }
  97. $checkState = $info["checkState"] ?: 0;
  98. $batch = $info["apply_year"] ?: BatchApi::getValidBatch(ProjectState::TALENT, $this->user["type"])["batch"];
  99. $info["enterprise"] = $ep;
  100. $info["talent_type_list"] = DictApi::findChildDictByCode("talent_type");
  101. if ($info["talent_condition"]) {
  102. $info["isSalary"] = \app\common\api\TalentConditionApi::getOne($info["talent_condition"])["isSalary"] ?: 0;
  103. }
  104. return view($tpl, ["year" => $batch, "checkState" => $checkState, "row" => $info]);
  105. }
  106. /**
  107. * 旧第二步
  108. * @param \think\Request $request
  109. * @return type
  110. */
  111. public function second(\think\Request $request) {
  112. if ($this->user["type"] != 1)
  113. return "此入口仅供晋江市人才申报,晋江集成电路人才请使用新统一申报入口";
  114. $params = $request->param();
  115. $id = $params["id"];
  116. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  117. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  118. if ($request->isPost()) {
  119. if (!$info || $info["enterprise_id"] != $this->user["uid"]) {
  120. $res = ["msg" => "没有对应的人才认定申报信息"];
  121. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  122. exit;
  123. }
  124. $checkState = $info["checkState"];
  125. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::BASE_REVERIFY_PASS) {
  126. $this->save($info, $request, TalentState::SCND_SAVE);
  127. exit();
  128. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
  129. $res = ["msg" => "审核不通过,不能再保存"];
  130. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  131. exit;
  132. }
  133. $res = ["msg" => "已提交审核,请耐心等待"];
  134. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  135. exit;
  136. }
  137. $enterprise_info = \app\common\model\Enterprise::find($this->user["uid"]);
  138. $info["enterprise"] = $enterprise_info;
  139. $batch = $info["apply_year"] ?: BatchApi::getValidBatch(ProjectState::TALENT, $enterprise_info["type"])["batch"];
  140. return view("second", ["year" => $batch, "row" => $info]);
  141. }
  142. public function view(\think\Request $request) {
  143. switch ($this->user["type"]) {
  144. case 1:
  145. $tpl = "view"; //晋江人才
  146. break;
  147. case 2:
  148. $tpl = "ic_view"; //集成电路
  149. break;
  150. }
  151. $id = $request->param("id");
  152. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  153. if ($info["isImport"]) {
  154. //$tpl = "no_file_view";
  155. }
  156. return view($tpl, ["row" => $info]);
  157. }
  158. /**
  159. * 提交表单(旧第二步)
  160. */
  161. public function submit() {
  162. $params = $this->request->param();
  163. $id = $params["id"];
  164. if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
  165. $res = ["msg" => "没有对应的人才认定申报信息"];
  166. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  167. exit;
  168. }
  169. if ($info) {
  170. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  171. }
  172. $checkState = $info["checkState"];
  173. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::BASE_REVERIFY_PASS) {
  174. $field_dict = \app\common\api\DictApi::getTalentFields(2);
  175. $no_empty = ["talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "bank", "bank_number", "bank_branch_name",
  176. "bank_account", "study_abroad", "phone", "email", "import_way", "cur_entry_time", "cur_entry_time", "position", "source"];
  177. $where = [];
  178. $where[] = ["rel", "=", "study_abroad"];
  179. $where[] = ["step", "=", 2];
  180. $where[] = ["project", "=", 1];
  181. $where[] = ["active", "=", 1];
  182. $where[] = ["delete", "=", 0];
  183. $where[] = ["type", "=", $this->user["type"]];
  184. $where[] = ["isConditionFile", "<>", 1];
  185. $abroad_files = Db::table("new_common_filetype")->where($where)->select()->toArray(); //留学的附件
  186. $abroad_file_ids = null;
  187. if ($abroad_files)
  188. $abroad_file_ids = array_column($abroad_files, "id");
  189. if ($params["study_abroad"] == 1) {
  190. $no_empty[] = "abroad_school";
  191. $no_empty[] = "abroad_major";
  192. }
  193. if (in_array($params["source"], [1, 3])) {
  194. $no_empty[] = "source_batch";
  195. $no_empty[] = "fujian_highcert_pubtime";
  196. $no_empty[] = "fujian_highcert_exptime";
  197. if ($params["source"] == 3) {
  198. $no_empty[] = "source_city";
  199. }
  200. }
  201. if (in_array($params["source"], [2, 4])) {
  202. $no_empty[] = "source_batch";
  203. $no_empty[] = "quanzhou_highcert_pubtime";
  204. $no_empty[] = "quanzhou_highcert_exptime";
  205. if ($params["source"] == 4) {
  206. $no_empty[] = "source_county";
  207. }
  208. }
  209. $condition_info = Db::table("new_talent_condition")->findOrEmpty($params["talent_condition"]);
  210. if ($condition_info["isSalary"] == 1) {
  211. $no_empty[] = "annual_salary";
  212. }
  213. $no_empty = array_filter($no_empty);
  214. $return = [];
  215. foreach ($no_empty as $key) {
  216. if (!$params[$key]) {
  217. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  218. }
  219. }
  220. if (count($return) > 0) {
  221. $res = ["msg" => implode("<br>", $return)];
  222. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  223. exit;
  224. }
  225. if ($condition_info["bindFileTypes"] && in_array($info["source"], [3, 4, 5])) {
  226. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  227. $whr[] = ["must", "=", 1];
  228. }
  229. $where = [];
  230. $where[] = ["step", "=", 2];
  231. $where[] = ["project", "=", 1];
  232. $where[] = ["type", "=", $this->user["type"]];
  233. $where[] = ["must", "=", 1];
  234. $where[] = ["active", "=", 1];
  235. $where[] = ["delete", "=", 0];
  236. $where[] = ["isConditionFile", "<>", 1];
  237. if ($whr) {
  238. $filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
  239. } else {
  240. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  241. }
  242. $ft_ids = array_column($filetypes, "id");
  243. if ($params["study_abroad"] == 1) {
  244. //选中留学,如果存在留学附件变成必传
  245. $ft_ids = array_unique(array_merge($ft_ids, (array) $abroad_file_ids));
  246. } else {
  247. //没选中,留学附件就算设成必传也不用验证
  248. $ft_ids = array_diff($ft_ids, (array) $abroad_file_ids);
  249. }
  250. $whr = [];
  251. $whr[] = ["typeId", "in", $ft_ids];
  252. $whr[] = ["mainId", "=", $id];
  253. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
  254. $upload_type_counts = count($distinct_filetypes);
  255. if ($upload_type_counts != count($ft_ids)) {
  256. $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
  257. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  258. exit;
  259. }
  260. $this->save($info, $this->request, TalentState::SCND_SUBMIT);
  261. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
  262. $res = ["msg" => "审核不通过,不能再提交审核"];
  263. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  264. exit;
  265. }
  266. $res = ["msg" => "已提交审核,请耐心等待"];
  267. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  268. exit;
  269. }
  270. public function submitToCheck() {
  271. switch ($this->user["type"]) {
  272. case 1:
  273. return $this->submitToCheck_JJRC();
  274. case 2:
  275. return $this->submitToCheck_IC();
  276. }
  277. }
  278. /**
  279. * 提交表单(新:混合基础信息人才申报信息)晋江人才
  280. */
  281. private function submitToCheck_JJRC() {
  282. $params = $this->request->param();
  283. $id = $params["id"];
  284. $info = TalentApi::chkIsOwner($id, $this->user["uid"]);
  285. if ($info) {
  286. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  287. }
  288. $checkState = $info["checkState"];
  289. if ($checkState == TalentState::SCND_SAVE || !$id) {
  290. $field_dict = \app\common\api\DictApi::getTalentFields(4, $info["isImport"]);
  291. $no_empty = ["name", "nation", "card_type", "card_number", "sex", "birthday", "politics", "nationality", "province", "city", "talent_type", "experience", "education",
  292. "talent_arrange", "talent_condition", "identifyGetTime", "bank", "bank_number", "bank_branch_name",
  293. "bank_account", "study_abroad", "phone", "email", "import_way", "cur_entry_time", "cur_entry_time", "position", "source"]; //"highest_degree", "graduate_school", "major",
  294. $where = [];
  295. $where[] = ["rel", "=", "study_abroad"];
  296. $where[] = ["project", "=", 1];
  297. $where[] = ["active", "=", 1];
  298. $where[] = ["delete", "=", 0];
  299. $where[] = ["type", "=", $this->user["type"]];
  300. $where[] = ["isConditionFile", "<>", 1];
  301. $abroad_files = Db::table("new_common_filetype")->where($where)->select()->toArray(); //留学的附件
  302. $abroad_file_ids = null;
  303. if ($abroad_files)
  304. $abroad_file_ids = array_column($abroad_files, "id");
  305. if (in_array($params["talent_type"], [1, 2])) {
  306. $no_empty[] = "tax_insurance_month";
  307. $no_empty[] = "labor_contract_rangetime";
  308. }
  309. if ($params["talent_type"] == 3) {
  310. $no_empty[] = "pre_import_type";
  311. }
  312. if ($params["study_abroad"] == 1) {
  313. $no_empty[] = "abroad_school";
  314. $no_empty[] = "abroad_major";
  315. }
  316. if (in_array($params["source"], [1, 3])) {
  317. //$no_empty[] = "source_batch";
  318. //$no_empty[] = "fujian_highcert_pubtime";
  319. //$no_empty[] = "fujian_highcert_exptime";
  320. if ($params["source"] == 3) {
  321. $no_empty[] = "source_city";
  322. }
  323. }
  324. if (in_array($params["source"], [2, 4])) {
  325. //$no_empty[] = "source_batch";
  326. //$no_empty[] = "quanzhou_highcert_pubtime";
  327. //$no_empty[] = "quanzhou_highcert_exptime";
  328. if ($params["source"] == 4) {
  329. $no_empty[] = "source_county";
  330. }
  331. }
  332. $condition_info = Db::table("new_talent_condition")->findOrEmpty($params["talent_condition"]);
  333. if ($condition_info["isSalary"] == 1) {
  334. $no_empty[] = "annual_salary";
  335. }
  336. $no_empty = array_filter($no_empty);
  337. $return = [];
  338. foreach ($no_empty as $key) {
  339. if (!$params[$key]) {
  340. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  341. }
  342. }
  343. if (count($return) > 0) {
  344. $res = ["msg" => implode("<br>", $return)];
  345. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  346. exit;
  347. }
  348. $isMatchZhiren = $info["isImport"] && $params["isMatchZhiren"] == 1 ? true : false;
  349. if ($condition_info["bindFileTypes"] && in_array($info["source"], [3, 4, 5]) && !$isMatchZhiren) {
  350. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  351. $whr[] = ["must", "=", 1];
  352. }
  353. $where = [];
  354. $where[] = ["project", "=", 1];
  355. $where[] = ["type", "=", $this->user["type"]];
  356. $where[] = ["must", "=", 1];
  357. $where[] = ["active", "=", 1];
  358. $where[] = ["delete", "=", 0];
  359. $where[] = ["isConditionFile", "<>", 1];
  360. if ($whr) {
  361. $filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
  362. } else {
  363. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  364. }
  365. $age = 0;
  366. if ($params["birthday"]) {
  367. $birthtime = strtotime($params["birthday"]);
  368. $currentYear = date("Y");
  369. $currentMonth = date("n");
  370. $birthdayYear = date("Y", $birthtime);
  371. $birthdayMonth = date("n", $birthtime);
  372. $age = ($currentYear * 12 + $currentMonth - $birthdayYear * 12 - $birthdayMonth) / 12;
  373. }
  374. $ft_ids = [];
  375. $deletes = [];
  376. foreach ($filetypes as $ft) {
  377. if ($ft["option"]) {
  378. if ($ft["rel"] == "birthday") {
  379. if ($age < $ft["option"]) {
  380. $deletes[] = $ft["id"];
  381. continue;
  382. }
  383. } else {
  384. $selectVal = $params[$ft["rel"]];
  385. $conditions = array_filter(explode(",", $ft["option"]));
  386. if (!in_array($selectVal, $conditions)) {
  387. $deletes[] = $ft["id"];
  388. continue;
  389. }
  390. }
  391. }
  392. $ft_ids[] = $ft["id"];
  393. }
  394. if ($params["study_abroad"] == 1) {
  395. //选中留学,如果存在留学附件变成必传
  396. $ft_ids = array_unique(array_merge($ft_ids, (array) $abroad_file_ids));
  397. } else {
  398. //没选中,留学附件就算设成必传也不用验证
  399. $ft_ids = array_diff($ft_ids, (array) $abroad_file_ids);
  400. }
  401. $whr = [];
  402. if ($id) {
  403. $whr[] = ["mainId", "=", $id];
  404. } else {
  405. if ($params["uploadFiles"])
  406. $whr[] = ["id", "in", $params["uploadFiles"]];
  407. }
  408. $whr[] = ["typeId", "in", $ft_ids];
  409. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
  410. $upload_type_counts = count($distinct_filetypes);
  411. if ($upload_type_counts != count($ft_ids)) {
  412. $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
  413. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  414. exit;
  415. }
  416. return $this->mixSave($info, $this->request, TalentState::SCND_SUBMIT);
  417. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL])) {
  418. $res = ["msg" => "审核不通过,不能再提交审核"];
  419. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  420. exit;
  421. }
  422. $res = ["msg" => "已提交审核,请耐心等待"];
  423. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  424. exit;
  425. }
  426. /**
  427. * 提交表单(新:混合基础信息人才申报信息)晋江电路
  428. */
  429. private function submitToCheck_IC() {
  430. $params = $this->request->param();
  431. $id = $params["id"];
  432. if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
  433. return json(["msg" => "没有对应的人才认定申报信息"]);
  434. }
  435. if ($info) {
  436. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  437. }
  438. $checkState = $info["checkState"];
  439. if ($checkState == TalentState::SCND_SAVE) {
  440. $field_dict = \app\common\api\DictApi::getTalentFields_IC();
  441. $no_empty = ["name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "nation", "politics", "break_faith",
  442. "phone", "email", "highest_degree", "graduate_school", "major", "study_abroad", "position", "cur_entry_time", "labor_contract_rangetime",
  443. "talent_arrange", "talent_condition", "identifyConditionName", "identifyGetTime",
  444. "bank", "bank_branch_name", "bank_account", "experience", "education"];
  445. $no_empty = array_filter($no_empty);
  446. $return = [];
  447. foreach ($no_empty as $key) {
  448. if (!$info[$key]) {
  449. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  450. }
  451. }
  452. if (count($return) > 0) {
  453. return json(["msg" => implode("<br>", $return)]);
  454. }
  455. $where = [];
  456. $where[] = ["project", "=", 1];
  457. $where[] = ["type", "=", $this->user["type"]];
  458. $where[] = ["must", "=", 1];
  459. $where[] = ["active", "=", 1];
  460. $where[] = ["delete", "=", 0];
  461. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  462. $ft_ids = array_column($filetypes, "id");
  463. $whr = [];
  464. $whr[] = ["typeId", "in", $ft_ids];
  465. $whr[] = ["mainId", "=", $id];
  466. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
  467. $upload_type_counts = count($distinct_filetypes);
  468. if ($upload_type_counts != count($ft_ids)) {
  469. return json(["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"]);
  470. }
  471. return $this->icSave($info, $this->request, TalentState::SCND_SUBMIT);
  472. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL])) {
  473. return json(["msg" => "审核不通过,不能再提交审核", "code" => 500]);
  474. }
  475. return json(["msg" => "已提交审核,请耐心等待", "code" => 500]);
  476. }
  477. /**
  478. * 保存表单(旧第二步)
  479. * @param type $info talent_info
  480. * @param type $param request->param();
  481. */
  482. private function save($info, \think\Request $request, $checkState) {
  483. try {
  484. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  485. if ($batch["code"] != 200) {
  486. throw new ValidateException($batch["msg"]);
  487. }
  488. $param = $request->param();
  489. validate(TalentInfo::class)->check($param);
  490. $data["apply_year"] = $batch["batch"];
  491. $all_valid_keys = ["applay_year", "import_way", "cur_entry_time", "position",
  492. "source", "source_batch", "fujian_highcert_pubtime", "fujian_highcert_exptime", "quanzhou_highcert_pubtime", "quanzhou_highcert_exptime", "source_city", "source_county",
  493. "talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "professional", "bank", "bank_number", "bank_branch_name", "bank_account",
  494. "study_abroad", "abroad_school", "abroad_major", "phone", "email", "annual_salary", "pro_qua"];
  495. foreach ($all_valid_keys as $key) {
  496. $data[$key] = trim($param[$key]);
  497. }
  498. if ($data["study_abroad"] == 1) {
  499. $data["abroad_school"] = $param["abroad_school"];
  500. $data["abroad_major"] = $param["abroad_major"];
  501. } else {
  502. $data["abroad_school"] = null;
  503. $data["abroad_major"] = null;
  504. }
  505. switch ($data["source"]) {
  506. case 1:
  507. $data["source_batch"] = $param["source_batch"];
  508. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  509. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  510. $data["source_city"] = null;
  511. break;
  512. case 2:
  513. $data["source_batch"] = $param["source_batch"];
  514. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  515. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  516. $data["source_county"] = null;
  517. break;
  518. case 3:
  519. $data["source_batch"] = $param["source_batch"];
  520. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  521. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  522. $data["source_city"] = $param["source_city"];
  523. break;
  524. case 4:
  525. $data["source_batch"] = $param["source_batch"];
  526. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  527. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  528. $data["source_county"] = $param["source_county"];
  529. break;
  530. }
  531. $condition_info = Db::table("new_talent_condition")->findOrEmpty($param["talent_condition"]);
  532. if ($condition_info["isSalary"] == 1) {
  533. $data["annual_salary"] = $param["annual_salary"];
  534. } else {
  535. $data["annual_salary"] = null;
  536. }
  537. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  538. //真实状态8是驳回,需要判断什么字段可以提交
  539. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  540. $tmp_data = $data;
  541. $data = [];
  542. foreach ($modify_fields as $field) {
  543. $data[$field] = $tmp_data[$field];
  544. }
  545. }
  546. $data["checkState"] = $checkState;
  547. $data["id"] = $info["id"];
  548. $success_msg = "提交成功";
  549. $error_msg = "提交失败";
  550. if ($checkState == TalentState::SCND_SAVE) {
  551. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  552. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  553. TalentLogApi::write(1, $data["id"], $checkState, "保存认定材料未提交", 1);
  554. }
  555. TalentModel::update($data);
  556. } else if ($checkState == TalentState::SCND_SUBMIT) {
  557. $success_msg = "提交成功";
  558. $error_msg = "提交失败";
  559. $data["new_submit_time"] = date("Y-m-d H:i:s");
  560. TalentModel::update($data);
  561. TalentLogApi::write(1, $info["id"], $checkState, "确认提交审核", 1);
  562. } else {
  563. throw new ValidateException($error_msg);
  564. }
  565. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $info["id"], "checkState" => $checkState]];
  566. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  567. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  568. exit();
  569. } catch (ValidateException $e) {
  570. $res = ["msg" => $e->getMessage()];
  571. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  572. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  573. exit();
  574. }
  575. }
  576. /**
  577. * 保存表单(新:混合基础信息人才申报信息)
  578. * @param type $info talent_info
  579. * @param type $param request->param();
  580. */
  581. private function mixSave($info, \think\Request $request, $checkState) {
  582. try {
  583. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  584. if ($batch["code"] != 200) {
  585. throw new ValidateException($batch["msg"]);
  586. }
  587. $param = $request->param();
  588. validate(TalentInfo::class)->check($param);
  589. $id = $param["id"];
  590. if ($id) {
  591. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  592. throw new ValidateException("没有对应的人才认定申报信息");
  593. }
  594. }
  595. $files = $param["uploadFiles"];
  596. $data["headimgurl"] = $info["headimgurl"];
  597. if ($request->file()) {
  598. $headimg = $request->file("photo");
  599. $upload = new \app\common\api\UploadApi();
  600. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  601. if ($result->code != 200) {
  602. throw new ValidateException($result->msg);
  603. }
  604. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  605. $width = imagesx($file);
  606. $height = imagesy($file);
  607. //免冠二寸照长宽413:579
  608. if ($width * 579 != $height * 413) {
  609. @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  610. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  611. }
  612. if ($info && $info["headimgurl"]) {
  613. //如果新照片符合像素要求,则删除旧照片
  614. $old_head_url = "storage/" . $info["headimgurl"];
  615. if (file_exists($old_head_url))
  616. @unlink($old_head_url);
  617. }
  618. $data["headimgurl"] = $result->filepath;
  619. }
  620. if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
  621. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  622. $where = [];
  623. $where[] = ["project", "=", 1];
  624. $where[] = ["type", "=", $this->user["type"]];
  625. $where[] = ["must", "=", 1];
  626. $where[] = ["active", "=", 1];
  627. $where[] = ["delete", "=", 0];
  628. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  629. $age = 0;
  630. if ($param["birthday"]) {
  631. $birthday = $param["birthday"];
  632. $birthdayYear = substr($birthday, 0, 4);
  633. $currentYear = date("Y");
  634. $age = $currentYear - $birthdayYear;
  635. }
  636. $ft_ids = [];
  637. $deletes = [];
  638. foreach ($filetypes as $ft) {
  639. if ($ft["option"]) {
  640. if ($ft["rel"] == "birthday") {
  641. if ($age < $ft["option"]) {
  642. $deletes[] = $ft["id"];
  643. continue;
  644. }
  645. } else {
  646. $selectVal = $param[$ft["rel"]];
  647. $conditions = array_filter(explode(",", $ft["option"]));
  648. if (!in_array($selectVal, $conditions)) {
  649. $deletes[] = $ft["id"];
  650. continue;
  651. }
  652. }
  653. }
  654. $ft_ids[] = $ft["id"];
  655. }
  656. $data["apply_year"] = $batch["batch"];
  657. $data["isMatchZhiren"] = $param["isMatchZhiren"] ?: 0;
  658. $all_valid_keys = ["talent_type", "name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "county", "nation", "politics", "experience", "education",
  659. "import_way", "cur_entry_time", "position",
  660. "source", "source_batch", "fujian_highcert_pubtime", "fujian_highcert_exptime", "quanzhou_highcert_pubtime", "quanzhou_highcert_exptime", "source_city", "source_county",
  661. "talent_arrange", "talent_condition", "identifyGetTime", "highest_degree", "graduate_school", "major", "professional", "bank", "bank_number", "bank_branch_name", "bank_account",
  662. "study_abroad", "abroad_school", "abroad_major", "phone", "email", "annual_salary", "pro_qua"];
  663. foreach ($all_valid_keys as $key) {
  664. $data[$key] = trim($param[$key]);
  665. }
  666. $data["return"] = 0; //流出晋江满3年后又返回晋江的,只有talent_type=2时可以填写且非必填
  667. if (in_array($data["talent_type"], [1, 2])) {
  668. $data["tax_insurance_month"] = $param["tax_insurance_month"];
  669. $data["labor_contract_rangetime"] = $param["labor_contract_rangetime"];
  670. $data["salary_pay_way"] = $param["salary_pay_way"];
  671. $data["salary_pay_month"] = $param["salary_pay_month"];
  672. $data["fst_work_time"] = $param["fst_work_time"];
  673. $data['pre_import_type'] = null;
  674. if ($data["talent_type"] == 2) {
  675. $data["return"] = $param["return"];
  676. }
  677. } else {
  678. $data["tax_insurance_month"] = null;
  679. $data["labor_contract_rangetime"] = null;
  680. $data["salary_pay_way"] = null;
  681. $data["salary_pay_month"] = null;
  682. $data["fst_work_time"] = null;
  683. $data['pre_import_type'] = $param["pre_import_type"];
  684. }
  685. if ($data["study_abroad"] == 1) {
  686. $data["abroad_school"] = $param["abroad_school"];
  687. $data["abroad_major"] = $param["abroad_major"];
  688. } else {
  689. $data["abroad_school"] = null;
  690. $data["abroad_major"] = null;
  691. }
  692. switch ($data["source"]) {
  693. case 1:
  694. $data["source_batch"] = $param["source_batch"];
  695. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  696. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  697. $data["source_city"] = null;
  698. break;
  699. case 2:
  700. $data["source_batch"] = $param["source_batch"];
  701. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  702. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  703. $data["source_county"] = null;
  704. break;
  705. case 3:
  706. $data["source_batch"] = $param["source_batch"];
  707. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  708. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  709. $data["source_city"] = $param["source_city"];
  710. break;
  711. case 4:
  712. $data["source_batch"] = $param["source_batch"];
  713. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  714. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  715. $data["source_county"] = $param["source_county"];
  716. break;
  717. }
  718. $condition_info = Db::table("new_talent_condition")->findOrEmpty($param["talent_condition"]);
  719. if ($condition_info["isSalary"] == 1) {
  720. $data["annual_salary"] = $param["annual_salary"];
  721. } else {
  722. $data["annual_salary"] = null;
  723. }
  724. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  725. //真实状态11是驳回,需要判断什么字段可以提交
  726. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  727. $tmp_data = $data;
  728. $data = [];
  729. foreach ($modify_fields as $field) {
  730. $data[$field] = $tmp_data[$field];
  731. }
  732. }
  733. $data["check_companys"] = $condition_info["companyIds"];
  734. $data["checkState"] = $checkState;
  735. $data["id"] = $id;
  736. $success_msg = "提交成功";
  737. $error_msg = "提交失败";
  738. if ($checkState == TalentState::SCND_SAVE) {
  739. $success_msg = "保存成功";
  740. if ($data["id"]) {
  741. //编辑
  742. TalentModel::update($data);
  743. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  744. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  745. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  746. } else {
  747. if (!$last_log["companyId"]) {
  748. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  749. }
  750. }
  751. } else {
  752. //新增
  753. $data["enterprise_id"] = $this->user["uid"];
  754. $id = TalentModel::insertGetId($data);
  755. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  756. $whr = [];
  757. $whr[] = ["fileId", "in", $files];
  758. $upd_checklog["mainId"] = $id;
  759. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  760. }
  761. } else if ($checkState == TalentState::SCND_SUBMIT) {
  762. if (!$info["first_submit_time"]) {
  763. $data["first_submit_time"] = date("Y-m-d H:i:s");
  764. } else {
  765. $data["new_submit_time"] = date("Y-m-d H:i:s");
  766. }
  767. if ($data["id"]) {
  768. TalentModel::update($data);
  769. } else {
  770. //新增
  771. $data["enterprise_id"] = $this->user["uid"];
  772. $id = TalentModel::insertGetId($data);
  773. $whr = [];
  774. $whr[] = ["fileId", "in", $files];
  775. $upd_checklog["mainId"] = $id;
  776. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  777. }
  778. TalentLogApi::write(1, $id, $checkState, "确认提交审核", 1);
  779. } else {
  780. throw new ValidateException($error_msg);
  781. }
  782. if ($id) {
  783. if ($deletes) {
  784. //删除多余的附件,一般是选择人才类型留下来的
  785. $whr = [];
  786. $whr[] = ["typeId", "in", $deletes];
  787. $whr[] = ["id", "in", $files];
  788. $_wait_del_files = Db::table("new_talent_file")->where($whr)->select()->toArray();
  789. $_logfileIds[] = [];
  790. foreach ($_wait_del_files as $_del_file) {
  791. $_logfileIds[] = $_del_file["id"];
  792. @unlink("storage/" . $_del_file["url"]);
  793. }
  794. Db::table("new_talent_file")->where($whr)->delete();
  795. if ($_logfileIds) {
  796. $whr = [];
  797. $whr[] = ["fileId", "in", $_logfileIds];
  798. $_upd_checklog["description"] = "删除附件";
  799. $_upd_checklog["updateUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"] ?: $this->user["rolename"]);
  800. $_upd_checklog["updateTime"] = date("Y-m-d H:i:s");
  801. Db::table("new_talent_checklog")->where($whr)->save($_upd_checklog);
  802. }
  803. }
  804. $whr = [];
  805. $whr[] = ["id", "in", $files];
  806. Db::table("new_talent_file")->where($whr)->save(["mainId" => $id]);
  807. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  808. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  809. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  810. exit();
  811. } else {
  812. throw new ValidateException($error_msg);
  813. }
  814. } catch (ValidateException $e) {
  815. $res = ["msg" => $e->getMessage()];
  816. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  817. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  818. exit();
  819. } catch (\think\Exception $e) {
  820. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  821. $logInfo = [
  822. "enterprise_id" => $this->user["uid"],
  823. "data" => $data,
  824. "controller" => $this->request->controller(),
  825. "action" => $this->request->action(),
  826. "errCode" => $e->getCode(),
  827. "errMsg" => $e->getMessage()
  828. ];
  829. Log::write($logInfo, "error");
  830. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  831. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  832. exit();
  833. }
  834. }
  835. private function icSave($info, \think\Request $request, $checkState) {
  836. try {
  837. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  838. if ($batch["code"] != 200) {
  839. throw new ValidateException($batch["msg"]);
  840. }
  841. $param = $request->param();
  842. validate(TalentInfo::class)->check($param);
  843. $id = $param["id"];
  844. if ($id) {
  845. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  846. throw new ValidateException("没有对应的人才认定申报信息");
  847. }
  848. }
  849. $files = $param["uploadFiles"];
  850. $data["headimgurl"] = $info["headimgurl"];
  851. if ($request->file()) {
  852. $headimg = $request->file("photo");
  853. $upload = new \app\common\api\UploadApi();
  854. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  855. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  856. $width = imagesx($file);
  857. $height = imagesy($file);
  858. //免冠二寸照长宽413:579
  859. if ($width * 579 != $height * 413) {
  860. @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  861. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  862. }
  863. if ($info && $info["headimgurl"]) {
  864. //如果新照片符合像素要求,则删除旧照片
  865. $old_head_url = "storage/" . $info["headimgurl"];
  866. if (file_exists($old_head_url))
  867. @unlink($old_head_url);
  868. }
  869. $data["headimgurl"] = $result->filepath;
  870. }
  871. if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
  872. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  873. $data["apply_year"] = $batch["batch"];
  874. $all_valid_keys = ["name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "county", "nation", "politics", "experience", "education", "break_faith",
  875. "phone", "email", "highest_degree", "graduate_school", "major", "study_abroad",
  876. "position", "cur_entry_time", "labor_contract_rangetime",
  877. "talent_arrange", "talent_condition", "identifyConditionName", "identifyGetTime", "title", "pro_qua",
  878. "bank", "bank_branch_name", "bank_account", "description"];
  879. foreach ($all_valid_keys as $key) {
  880. $value = trim($param[$key]);
  881. if ($value) {
  882. $data[$key] = $value;
  883. }
  884. }
  885. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  886. //真实状态11是驳回,需要判断什么字段可以提交
  887. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  888. $tmp_data = $data;
  889. $data = [];
  890. foreach ($modify_fields as $field) {
  891. $data[$field] = $tmp_data[$field];
  892. }
  893. }
  894. $data["checkState"] = $checkState;
  895. $data["id"] = $id;
  896. $success_msg = "提交成功";
  897. $error_msg = "提交失败";
  898. if ($checkState == TalentState::SCND_SAVE) {
  899. $success_msg = "保存成功";
  900. if ($data["id"]) {
  901. //编辑
  902. TalentModel::update($data);
  903. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  904. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  905. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  906. } else {
  907. if (!$last_log["companyId"]) {
  908. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  909. }
  910. }
  911. } else {
  912. //新增
  913. $data["enterprise_id"] = $this->user["uid"];
  914. $id = TalentModel::insertGetId($data);
  915. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  916. $whr = [];
  917. $whr[] = ["fileId", "in", $files];
  918. $upd_checklog["mainId"] = $id;
  919. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  920. }
  921. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  922. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  923. exit();
  924. } else if ($checkState == TalentState::SCND_SUBMIT) {
  925. $data["new_submit_time"] = date("Y-m-d H:i:s");
  926. TalentModel::update($data);
  927. TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
  928. return json(["msg" => $success_msg, "code" => 200]);
  929. } else {
  930. throw new ValidateException($error_msg);
  931. }
  932. } catch (ValidateException $e) {
  933. if ($checkState == TalentState::SCND_SAVE) {
  934. $res = ["msg" => $e->getMessage()];
  935. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  936. exit();
  937. } else {
  938. return json(["msg" => $e->getMessage()]);
  939. }
  940. } catch (\think\Exception $e) {
  941. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  942. $logInfo = [
  943. "enterprise_id" => $this->user["uid"],
  944. "data" => $data,
  945. "controller" => $this->request->controller(),
  946. "action" => $this->request->action(),
  947. "errCode" => $e->getCode(),
  948. "errMsg" => $e->getMessage()
  949. ];
  950. Log::write($logInfo, "error");
  951. if ($checkState == TalentState::SCND_SAVE) {
  952. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  953. exit();
  954. } else {
  955. return json($res);
  956. }
  957. }
  958. }
  959. public function delete() {
  960. $id = $this->request->param("talentInfoId");
  961. $info = Talent::chkIsOwner($id, $this->user["uid"]);
  962. if (!$info) {
  963. return json(["msg" => "操作失败"]);
  964. }
  965. $checkState = $info["checkState"];
  966. if (in_array($checkState, [0, 1])) {
  967. $log = TalentLogApi::getLastLog($id, 1);
  968. if ($log["state"] > 1) {
  969. //有提交审核记录
  970. return json(["msg" => "该申报已提交审核,无法删除"]);
  971. }
  972. }
  973. $data["id"] = $id;
  974. $data["delete"] = 1;
  975. TalentModel::update($data);
  976. return json(["msg" => "删除成功"]);
  977. }
  978. public function getInfoById($id) {
  979. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  980. if ($info["enterprise_id"] != $this->user["uid"]) {
  981. return [];
  982. }
  983. return $info;
  984. }
  985. public function findTalentInfoInLibrary($type) {
  986. $where = [];
  987. $sList = [];
  988. if ($type == ProjectState::QUIT) {
  989. $_where = [];
  990. $_where[] = ["checkState", "not in", [3]];
  991. $talentIds = Db::table("un_talent_quit")->where($_where)->column("talentId");
  992. $sList[] = array_merge($sList, (array) $talentIds);
  993. $where[] = ["active", "=", 1];
  994. }
  995. if ($type == ProjectState::BANKCHANGE) {
  996. $_where = [];
  997. $_where[] = ["checkState", "not in", [3]];
  998. $talentIds = Db::table("un_talent_bank_change")->where($_where)->column("talentId");
  999. $sList[] = array_merge($sList, (array) $talentIds);
  1000. }
  1001. if ($type == ProjectState::LEVELCHANGE) {
  1002. $_where = [];
  1003. $_where[] = ["checkState", "not in", [35, -1]];
  1004. $_where[] = ["isPublic", "<", 5];
  1005. $talentIds = Db::table("un_talent_type_change")->where($_where)->column("talentId");
  1006. $sList[] = array_merge($sList, (array) $talentIds);
  1007. }
  1008. $where[] = ["enterprise_id", "=", $this->user["uid"]];
  1009. $where[] = ["checkState", "=", TalentState::CERTIFICATED];
  1010. $where[] = ["isEffect", "<>", 4];
  1011. if ($sList) {
  1012. $where[] = ["id", "not in", $sList];
  1013. }
  1014. return TalentModel::where($where)->field("id,name")->select()->toArray();
  1015. }
  1016. // public function mixDelete() {
  1017. // $id = $this->request->param("talentInfoId");
  1018. // $info = TalentApi::chkIsOwner($id, $this->user["uid"]);
  1019. // if (!$info) {
  1020. // return json(["msg" => "操作失败"]);
  1021. // }
  1022. // $checkState = $info["checkState"];
  1023. // if (in_array($checkState, [0, TalentState::SCND_SAVE])) {
  1024. // $data["id"] = $id;
  1025. // $data["delete"] = 1;
  1026. // TalentModel::update($data);
  1027. // return json(["msg" => "删除成功"]);
  1028. // }
  1029. // return json(["msg" => "该申报已提交审核,无法删除"]);
  1030. // }
  1031. }