Talent.php 49 KB

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