Talent.php 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037
  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. $data["return"] = 0; //流出晋江满3年后又返回晋江的,只有talent_type=2时可以填写且非必填
  660. if (in_array($data["talent_type"], [1, 2])) {
  661. $data["tax_insurance_month"] = $param["tax_insurance_month"];
  662. $data["labor_contract_rangetime"] = $param["labor_contract_rangetime"];
  663. $data["salary_pay_way"] = $param["salary_pay_way"];
  664. $data["salary_pay_month"] = $param["salary_pay_month"];
  665. $data["fst_work_time"] = $param["fst_work_time"];
  666. $data['pre_import_type'] = null;
  667. if ($data["talent_type"] == 2) {
  668. $data["return"] = $param["return"];
  669. }
  670. } else {
  671. $data["tax_insurance_month"] = null;
  672. $data["labor_contract_rangetime"] = null;
  673. $data["salary_pay_way"] = null;
  674. $data["salary_pay_month"] = null;
  675. $data["fst_work_time"] = null;
  676. $data['pre_import_type'] = $param["pre_import_type"];
  677. }
  678. if ($data["study_abroad"] == 1) {
  679. $data["abroad_school"] = $param["abroad_school"];
  680. $data["abroad_major"] = $param["abroad_major"];
  681. } else {
  682. $data["abroad_school"] = null;
  683. $data["abroad_major"] = null;
  684. }
  685. switch ($data["source"]) {
  686. case 1:
  687. $data["source_batch"] = $param["source_batch"];
  688. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  689. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  690. $data["source_city"] = null;
  691. break;
  692. case 2:
  693. $data["source_batch"] = $param["source_batch"];
  694. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  695. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  696. $data["source_county"] = null;
  697. break;
  698. case 3:
  699. $data["source_batch"] = $param["source_batch"];
  700. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  701. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  702. $data["source_city"] = $param["source_city"];
  703. break;
  704. case 4:
  705. $data["source_batch"] = $param["source_batch"];
  706. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  707. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  708. $data["source_county"] = $param["source_county"];
  709. break;
  710. }
  711. $condition_info = Db::table("new_talent_condition")->findOrEmpty($param["talent_condition"]);
  712. if ($condition_info["isSalary"] == 1) {
  713. $data["annual_salary"] = $param["annual_salary"];
  714. } else {
  715. $data["annual_salary"] = null;
  716. }
  717. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  718. //真实状态11是驳回,需要判断什么字段可以提交
  719. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  720. $tmp_data = $data;
  721. $data = [];
  722. foreach ($modify_fields as $field) {
  723. $data[$field] = $tmp_data[$field];
  724. }
  725. }
  726. $data["checkState"] = $checkState;
  727. $data["id"] = $id;
  728. $success_msg = "提交成功";
  729. $error_msg = "提交失败";
  730. if ($checkState == TalentState::SCND_SAVE) {
  731. $success_msg = "保存成功";
  732. if ($data["id"]) {
  733. //编辑
  734. TalentModel::update($data);
  735. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  736. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  737. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  738. } else {
  739. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  740. }
  741. } else {
  742. //新增
  743. $data["enterprise_id"] = $this->user["uid"];
  744. $id = TalentModel::insertGetId($data);
  745. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  746. $whr = [];
  747. $whr[] = ["fileId", "in", $files];
  748. $upd_checklog["mainId"] = $id;
  749. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  750. }
  751. } else if ($checkState == TalentState::SCND_SUBMIT) {
  752. if (!$info["first_submit_time"]) {
  753. $data["first_submit_time"] = date("Y-m-d H:i:s");
  754. } else {
  755. $data["new_submit_time"] = date("Y-m-d H:i:s");
  756. }
  757. if ($data["id"]) {
  758. TalentModel::update($data);
  759. } else {
  760. //新增
  761. $data["enterprise_id"] = $this->user["uid"];
  762. $id = TalentModel::insertGetId($data);
  763. $whr = [];
  764. $whr[] = ["fileId", "in", $files];
  765. $upd_checklog["mainId"] = $id;
  766. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  767. }
  768. TalentLogApi::write(1, $id, $checkState, "确认提交审核", 1);
  769. } else {
  770. throw new ValidateException($error_msg);
  771. }
  772. if ($id) {
  773. if ($deletes) {
  774. //删除多余的附件,一般是选择人才类型留下来的
  775. $whr = [];
  776. $whr[] = ["typeId", "in", $deletes];
  777. $whr[] = ["id", "in", $files];
  778. $_wait_del_files = Db::table("new_talent_file")->where($whr)->select()->toArray();
  779. $_logfileIds[] = [];
  780. foreach ($_wait_del_files as $_del_file) {
  781. $_logfileIds[] = $_del_file["id"];
  782. @unlink("storage/" . $_del_file["url"]);
  783. }
  784. Db::table("new_talent_file")->where($whr)->delete();
  785. if ($_logfileIds) {
  786. $whr = [];
  787. $whr[] = ["fileId", "in", $_logfileIds];
  788. $_upd_checklog["description"] = "删除附件";
  789. $_upd_checklog["updateUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"] ?: $this->user["rolename"]);
  790. $_upd_checklog["updateTime"] = date("Y-m-d H:i:s");
  791. Db::table("new_talent_checklog")->where($whr)->save($_upd_checklog);
  792. }
  793. }
  794. $whr = [];
  795. $whr[] = ["id", "in", $files];
  796. Db::table("new_talent_file")->where($whr)->save(["mainId" => $id]);
  797. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  798. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  799. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  800. exit();
  801. } else {
  802. throw new ValidateException($error_msg);
  803. }
  804. } catch (ValidateException $e) {
  805. $res = ["msg" => $e->getMessage()];
  806. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  807. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  808. exit();
  809. } catch (\think\Exception $e) {
  810. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  811. $logInfo = [
  812. "enterprise_id" => $this->user["uid"],
  813. "data" => $data,
  814. "controller" => $this->request->controller(),
  815. "action" => $this->request->action(),
  816. "errCode" => $e->getCode(),
  817. "errMsg" => $e->getMessage()
  818. ];
  819. Log::write($logInfo, "error");
  820. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  821. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  822. exit();
  823. }
  824. }
  825. private function icSave($info, \think\Request $request, $checkState) {
  826. try {
  827. $batch = \app\common\api\BatchApi::getValidBatch(1, $this->user["type"]);
  828. if (!$batch) {
  829. throw new ValidateException("不在人才认定申报申请时间内");
  830. }
  831. $param = $request->param();
  832. validate(TalentInfo::class)->check($param);
  833. $id = $param["id"];
  834. if ($id) {
  835. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  836. throw new ValidateException("没有对应的人才认定申报信息");
  837. }
  838. }
  839. $files = $param["uploadFiles"];
  840. $data["headimgurl"] = $info["headimgurl"];
  841. if ($request->file()) {
  842. $headimg = $request->file("photo");
  843. $upload = new \app\common\api\UploadApi();
  844. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  845. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  846. $width = imagesx($file);
  847. $height = imagesy($file);
  848. //免冠二寸照长宽413:579
  849. if ($width * 579 != $height * 413) {
  850. @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  851. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  852. }
  853. if ($info && $info["headimgurl"]) {
  854. //如果新照片符合像素要求,则删除旧照片
  855. $old_head_url = "storage/" . $info["headimgurl"];
  856. if (file_exists($old_head_url))
  857. @unlink($old_head_url);
  858. }
  859. $data["headimgurl"] = $result->filepath;
  860. }
  861. if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
  862. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  863. $data["apply_year"] = $batch["batch"];
  864. $all_valid_keys = ["name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "county", "nation", "politics", "experience", "education", "break_faith",
  865. "phone", "email", "highest_degree", "graduate_school", "major", "study_abroad",
  866. "position", "cur_entry_time", "labor_contract_rangetime",
  867. "talent_arrange", "talent_condition", "identifyConditionName", "identifyGetTime", "title", "pro_qua",
  868. "bank", "bank_branch_name", "bank_account", "description"];
  869. foreach ($all_valid_keys as $key) {
  870. $value = trim($param[$key]);
  871. if ($value) {
  872. $data[$key] = $value;
  873. }
  874. }
  875. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  876. //真实状态11是驳回,需要判断什么字段可以提交
  877. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  878. $tmp_data = $data;
  879. $data = [];
  880. foreach ($modify_fields as $field) {
  881. $data[$field] = $tmp_data[$field];
  882. }
  883. }
  884. $data["checkState"] = $checkState;
  885. $data["id"] = $id;
  886. $success_msg = "提交成功";
  887. $error_msg = "提交失败";
  888. if ($checkState == TalentState::SCND_SAVE) {
  889. $success_msg = "保存成功";
  890. if ($data["id"]) {
  891. //编辑
  892. TalentModel::update($data);
  893. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  894. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  895. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  896. } else {
  897. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  898. }
  899. } else {
  900. //新增
  901. $data["enterprise_id"] = $this->user["uid"];
  902. $id = TalentModel::insertGetId($data);
  903. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  904. $whr = [];
  905. $whr[] = ["fileId", "in", $files];
  906. $upd_checklog["mainId"] = $id;
  907. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  908. }
  909. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  910. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  911. exit();
  912. } else if ($checkState == TalentState::SCND_SUBMIT) {
  913. $data["new_submit_time"] = date("Y-m-d H:i:s");
  914. TalentModel::update($data);
  915. TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
  916. return json(["msg" => $success_msg, "code" => 200]);
  917. } else {
  918. throw new ValidateException($error_msg);
  919. }
  920. } catch (ValidateException $e) {
  921. if ($checkState == TalentState::SCND_SAVE) {
  922. $res = ["msg" => $e->getMessage()];
  923. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  924. exit();
  925. } else {
  926. return json(["msg" => $e->getMessage()]);
  927. }
  928. } catch (\think\Exception $e) {
  929. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  930. $logInfo = [
  931. "enterprise_id" => $this->user["uid"],
  932. "data" => $data,
  933. "controller" => $this->request->controller(),
  934. "action" => $this->request->action(),
  935. "errCode" => $e->getCode(),
  936. "errMsg" => $e->getMessage()
  937. ];
  938. Log::write($logInfo, "error");
  939. if ($checkState == TalentState::SCND_SAVE) {
  940. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  941. exit();
  942. } else {
  943. return json($res);
  944. }
  945. }
  946. }
  947. public function delete() {
  948. $id = $this->request->param("talentInfoId");
  949. $info = Talent::chkIsOwner($id, $this->user["uid"]);
  950. if (!$info) {
  951. return json(["msg" => "操作失败"]);
  952. }
  953. $checkState = $info["checkState"];
  954. if (in_array($checkState, [0, 1])) {
  955. $log = TalentLogApi::getLastLog($id, 1);
  956. if ($log["state"] > 1) {
  957. //有提交审核记录
  958. return json(["msg" => "该申报已提交审核,无法删除"]);
  959. }
  960. }
  961. $data["id"] = $id;
  962. $data["delete"] = 1;
  963. TalentModel::update($data);
  964. return json(["msg" => "删除成功"]);
  965. }
  966. public function mixDelete() {
  967. $id = $this->request->param("talentInfoId");
  968. $info = Talent::chkIsOwner($id, $this->user["uid"]);
  969. if (!$info) {
  970. return json(["msg" => "操作失败"]);
  971. }
  972. $checkState = $info["checkState"];
  973. if (in_array($checkState, [0, TalentState::SCND_SAVE])) {
  974. $log = TalentLogApi::getLastLog($id, 1);
  975. if ($log["state"] > 1) {
  976. //有提交审核记录
  977. return json(["msg" => "该申报已提交审核,无法删除"]);
  978. }
  979. }
  980. $data["id"] = $id;
  981. $data["delete"] = 1;
  982. TalentModel::update($data);
  983. return json(["msg" => "删除成功"]);
  984. }
  985. }