Talent.php 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046
  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);
  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"] && $info["source"] == 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", "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"] && $info["source"] == 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. $birthday = $params["birthday"];
  368. $birthdayYear = substr($birthday, 0, 4);
  369. $currentYear = date("Y");
  370. $age = $currentYear - $birthdayYear;
  371. }
  372. $ft_ids = [];
  373. $deletes = [];
  374. foreach ($filetypes as $ft) {
  375. if ($ft["option"]) {
  376. if ($ft["rel"] == "birthday") {
  377. if ($age < $ft["option"]) {
  378. $deletes[] = $ft["id"];
  379. continue;
  380. }
  381. } else {
  382. $selectVal = $params[$ft["rel"]];
  383. $conditions = array_filter(explode(",", $ft["option"]));
  384. if (!in_array($selectVal, $conditions)) {
  385. $deletes[] = $ft["id"];
  386. continue;
  387. }
  388. }
  389. }
  390. $ft_ids[] = $ft["id"];
  391. }
  392. if ($params["study_abroad"] == 1) {
  393. //选中留学,如果存在留学附件变成必传
  394. $ft_ids = array_unique(array_merge($ft_ids, (array) $abroad_file_ids));
  395. } else {
  396. //没选中,留学附件就算设成必传也不用验证
  397. $ft_ids = array_diff($ft_ids, (array) $abroad_file_ids);
  398. }
  399. $whr = [];
  400. if ($id) {
  401. $whr[] = ["mainId", "=", $id];
  402. } else {
  403. if ($params["uploadFiles"])
  404. $whr[] = ["id", "in", $params["uploadFiles"]];
  405. }
  406. $whr[] = ["typeId", "in", $ft_ids];
  407. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
  408. $upload_type_counts = count($distinct_filetypes);
  409. if ($upload_type_counts != count($ft_ids)) {
  410. $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
  411. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  412. exit;
  413. }
  414. return $this->mixSave($info, $this->request, TalentState::SCND_SUBMIT);
  415. } 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])) {
  416. $res = ["msg" => "审核失败,不能再提交审核"];
  417. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  418. exit;
  419. }
  420. $res = ["msg" => "已提交审核,请耐心等待"];
  421. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  422. exit;
  423. }
  424. /**
  425. * 提交表单(新:混合基础信息人才申报信息)晋江电路
  426. */
  427. private function submitToCheck_IC() {
  428. $params = $this->request->param();
  429. $id = $params["id"];
  430. if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
  431. return json(["msg" => "没有对应的人才认定申报信息"]);
  432. }
  433. if ($info) {
  434. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  435. }
  436. $checkState = $info["checkState"];
  437. if ($checkState == TalentState::SCND_SAVE) {
  438. $field_dict = \app\common\api\DictApi::getTalentFields_IC();
  439. $no_empty = ["name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "nation", "politics", "break_faith",
  440. "phone", "email", "highest_degree", "graduate_school", "major", "study_abroad", "position", "cur_entry_time", "labor_contract_rangetime",
  441. "talent_arrange", "talent_condition", "identifyConditionName", "identifyGetTime",
  442. "bank", "bank_branch_name", "bank_account", "experience", "education"];
  443. $no_empty = array_filter($no_empty);
  444. $return = [];
  445. foreach ($no_empty as $key) {
  446. if (!$info[$key]) {
  447. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  448. }
  449. }
  450. if (count($return) > 0) {
  451. return json(["msg" => implode("<br>", $return)]);
  452. }
  453. $where = [];
  454. $where[] = ["project", "=", 1];
  455. $where[] = ["type", "=", $this->user["type"]];
  456. $where[] = ["must", "=", 1];
  457. $where[] = ["active", "=", 1];
  458. $where[] = ["delete", "=", 0];
  459. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  460. $ft_ids = array_column($filetypes, "id");
  461. $whr = [];
  462. $whr[] = ["typeId", "in", $ft_ids];
  463. $whr[] = ["mainId", "=", $id];
  464. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
  465. $upload_type_counts = count($distinct_filetypes);
  466. if ($upload_type_counts != count($ft_ids)) {
  467. return json(["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"]);
  468. }
  469. return $this->icSave($info, $this->request, TalentState::SCND_SUBMIT);
  470. } 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])) {
  471. return json(["msg" => "审核失败,不能再提交审核", "code" => 500]);
  472. }
  473. return json(["msg" => "已提交审核,请耐心等待", "code" => 500]);
  474. }
  475. /**
  476. * 保存表单(旧第二步)
  477. * @param type $info talent_info
  478. * @param type $param request->param();
  479. */
  480. private function save($info, \think\Request $request, $checkState) {
  481. try {
  482. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"]], $this->user["type"]);
  483. if ($batch["code"] != 200) {
  484. throw new ValidateException($batch["msg"]);
  485. }
  486. $param = $request->param();
  487. validate(TalentInfo::class)->check($param);
  488. $data["apply_year"] = $batch["batch"];
  489. $all_valid_keys = ["applay_year", "import_way", "cur_entry_time", "position",
  490. "source", "source_batch", "fujian_highcert_pubtime", "fujian_highcert_exptime", "quanzhou_highcert_pubtime", "quanzhou_highcert_exptime", "source_city", "source_county",
  491. "talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "professional", "bank", "bank_number", "bank_branch_name", "bank_account",
  492. "study_abroad", "abroad_school", "abroad_major", "phone", "email", "annual_salary", "pro_qua"];
  493. foreach ($all_valid_keys as $key) {
  494. $data[$key] = trim($param[$key]);
  495. }
  496. if ($data["study_abroad"] == 1) {
  497. $data["abroad_school"] = $param["abroad_school"];
  498. $data["abroad_major"] = $param["abroad_major"];
  499. } else {
  500. $data["abroad_school"] = null;
  501. $data["abroad_major"] = null;
  502. }
  503. switch ($data["source"]) {
  504. case 1:
  505. $data["source_batch"] = $param["source_batch"];
  506. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  507. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  508. $data["source_city"] = null;
  509. break;
  510. case 2:
  511. $data["source_batch"] = $param["source_batch"];
  512. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  513. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  514. $data["source_county"] = null;
  515. break;
  516. case 3:
  517. $data["source_batch"] = $param["source_batch"];
  518. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  519. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  520. $data["source_city"] = $param["source_city"];
  521. break;
  522. case 4:
  523. $data["source_batch"] = $param["source_batch"];
  524. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  525. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  526. $data["source_county"] = $param["source_county"];
  527. break;
  528. }
  529. $condition_info = Db::table("new_talent_condition")->findOrEmpty($param["talent_condition"]);
  530. if ($condition_info["isSalary"] == 1) {
  531. $data["annual_salary"] = $param["annual_salary"];
  532. } else {
  533. $data["annual_salary"] = null;
  534. }
  535. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  536. //真实状态8是驳回,需要判断什么字段可以提交
  537. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  538. $tmp_data = $data;
  539. $data = [];
  540. foreach ($modify_fields as $field) {
  541. $data[$field] = $tmp_data[$field];
  542. }
  543. }
  544. $data["checkState"] = $checkState;
  545. $data["id"] = $info["id"];
  546. $success_msg = "提交成功";
  547. $error_msg = "提交失败";
  548. if ($checkState == TalentState::SCND_SAVE) {
  549. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  550. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  551. TalentLogApi::write(1, $data["id"], $checkState, "保存认定材料未提交", 1);
  552. }
  553. TalentModel::update($data);
  554. } else if ($checkState == TalentState::SCND_SUBMIT) {
  555. $success_msg = "提交成功";
  556. $error_msg = "提交失败";
  557. $data["new_submit_time"] = date("Y-m-d H:i:s");
  558. TalentModel::update($data);
  559. TalentLogApi::write(1, $info["id"], $checkState, "确认提交审核", 1);
  560. } else {
  561. throw new ValidateException($error_msg);
  562. }
  563. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $info["id"], "checkState" => $checkState]];
  564. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  565. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  566. exit();
  567. } catch (ValidateException $e) {
  568. $res = ["msg" => $e->getMessage()];
  569. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  570. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  571. exit();
  572. }
  573. }
  574. /**
  575. * 保存表单(新:混合基础信息人才申报信息)
  576. * @param type $info talent_info
  577. * @param type $param request->param();
  578. */
  579. private function mixSave($info, \think\Request $request, $checkState) {
  580. try {
  581. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"]], $this->user["type"]);
  582. if ($batch["code"] != 200) {
  583. throw new ValidateException($batch["msg"]);
  584. }
  585. $param = $request->param();
  586. validate(TalentInfo::class)->check($param);
  587. $id = $param["id"];
  588. if ($id) {
  589. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  590. throw new ValidateException("没有对应的人才认定申报信息");
  591. }
  592. }
  593. $files = $param["uploadFiles"];
  594. $data["headimgurl"] = $info["headimgurl"];
  595. if ($request->file()) {
  596. $headimg = $request->file("photo");
  597. $upload = new \app\common\api\UploadApi();
  598. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  599. if($result->code != 200){
  600. throw new ValidateException($result->msg);
  601. }
  602. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  603. $width = imagesx($file);
  604. $height = imagesy($file);
  605. //免冠二寸照长宽413:579
  606. if ($width * 579 != $height * 413) {
  607. @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  608. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  609. }
  610. if ($info && $info["headimgurl"]) {
  611. //如果新照片符合像素要求,则删除旧照片
  612. $old_head_url = "storage/" . $info["headimgurl"];
  613. if (file_exists($old_head_url))
  614. @unlink($old_head_url);
  615. }
  616. $data["headimgurl"] = $result->filepath;
  617. }
  618. if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
  619. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  620. $where = [];
  621. $where[] = ["project", "=", 1];
  622. $where[] = ["type", "=", $this->user["type"]];
  623. $where[] = ["must", "=", 1];
  624. $where[] = ["active", "=", 1];
  625. $where[] = ["delete", "=", 0];
  626. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  627. $age = 0;
  628. if ($param["birthday"]) {
  629. $birthday = $param["birthday"];
  630. $birthdayYear = substr($birthday, 0, 4);
  631. $currentYear = date("Y");
  632. $age = $currentYear - $birthdayYear;
  633. }
  634. $ft_ids = [];
  635. $deletes = [];
  636. foreach ($filetypes as $ft) {
  637. if ($ft["option"]) {
  638. if ($ft["rel"] == "birthday") {
  639. if ($age < $ft["option"]) {
  640. $deletes[] = $ft["id"];
  641. continue;
  642. }
  643. } else {
  644. $selectVal = $param[$ft["rel"]];
  645. $conditions = array_filter(explode(",", $ft["option"]));
  646. if (!in_array($selectVal, $conditions)) {
  647. $deletes[] = $ft["id"];
  648. continue;
  649. }
  650. }
  651. }
  652. $ft_ids[] = $ft["id"];
  653. }
  654. $data["apply_year"] = $batch["batch"];
  655. $data["isMatchZhiren"] = $param["isMatchZhiren"] ?: 0;
  656. $all_valid_keys = ["talent_type", "name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "county", "nation", "politics", "experience", "education",
  657. "import_way", "cur_entry_time", "position",
  658. "source", "source_batch", "fujian_highcert_pubtime", "fujian_highcert_exptime", "quanzhou_highcert_pubtime", "quanzhou_highcert_exptime", "source_city", "source_county",
  659. "talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "professional", "bank", "bank_number", "bank_branch_name", "bank_account",
  660. "study_abroad", "abroad_school", "abroad_major", "phone", "email", "annual_salary", "pro_qua"];
  661. foreach ($all_valid_keys as $key) {
  662. $data[$key] = trim($param[$key]);
  663. }
  664. $data["return"] = 0; //流出晋江满3年后又返回晋江的,只有talent_type=2时可以填写且非必填
  665. if (in_array($data["talent_type"], [1, 2])) {
  666. $data["tax_insurance_month"] = $param["tax_insurance_month"];
  667. $data["labor_contract_rangetime"] = $param["labor_contract_rangetime"];
  668. $data["salary_pay_way"] = $param["salary_pay_way"];
  669. $data["salary_pay_month"] = $param["salary_pay_month"];
  670. $data["fst_work_time"] = $param["fst_work_time"];
  671. $data['pre_import_type'] = null;
  672. if ($data["talent_type"] == 2) {
  673. $data["return"] = $param["return"];
  674. }
  675. } else {
  676. $data["tax_insurance_month"] = null;
  677. $data["labor_contract_rangetime"] = null;
  678. $data["salary_pay_way"] = null;
  679. $data["salary_pay_month"] = null;
  680. $data["fst_work_time"] = null;
  681. $data['pre_import_type'] = $param["pre_import_type"];
  682. }
  683. if ($data["study_abroad"] == 1) {
  684. $data["abroad_school"] = $param["abroad_school"];
  685. $data["abroad_major"] = $param["abroad_major"];
  686. } else {
  687. $data["abroad_school"] = null;
  688. $data["abroad_major"] = null;
  689. }
  690. switch ($data["source"]) {
  691. case 1:
  692. $data["source_batch"] = $param["source_batch"];
  693. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  694. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  695. $data["source_city"] = null;
  696. break;
  697. case 2:
  698. $data["source_batch"] = $param["source_batch"];
  699. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  700. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  701. $data["source_county"] = null;
  702. break;
  703. case 3:
  704. $data["source_batch"] = $param["source_batch"];
  705. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  706. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  707. $data["source_city"] = $param["source_city"];
  708. break;
  709. case 4:
  710. $data["source_batch"] = $param["source_batch"];
  711. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  712. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  713. $data["source_county"] = $param["source_county"];
  714. break;
  715. }
  716. $condition_info = Db::table("new_talent_condition")->findOrEmpty($param["talent_condition"]);
  717. if ($condition_info["isSalary"] == 1) {
  718. $data["annual_salary"] = $param["annual_salary"];
  719. } else {
  720. $data["annual_salary"] = null;
  721. }
  722. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  723. //真实状态11是驳回,需要判断什么字段可以提交
  724. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  725. $tmp_data = $data;
  726. $data = [];
  727. foreach ($modify_fields as $field) {
  728. $data[$field] = $tmp_data[$field];
  729. }
  730. }
  731. $data["checkState"] = $checkState;
  732. $data["id"] = $id;
  733. $success_msg = "提交成功";
  734. $error_msg = "提交失败";
  735. if ($checkState == TalentState::SCND_SAVE) {
  736. $success_msg = "保存成功";
  737. if ($data["id"]) {
  738. //编辑
  739. TalentModel::update($data);
  740. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  741. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  742. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  743. } else {
  744. if (!$last_log["companyId"]) {
  745. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  746. }
  747. }
  748. } else {
  749. //新增
  750. $data["enterprise_id"] = $this->user["uid"];
  751. $id = TalentModel::insertGetId($data);
  752. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  753. $whr = [];
  754. $whr[] = ["fileId", "in", $files];
  755. $upd_checklog["mainId"] = $id;
  756. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  757. }
  758. } else if ($checkState == TalentState::SCND_SUBMIT) {
  759. if (!$info["first_submit_time"]) {
  760. $data["first_submit_time"] = date("Y-m-d H:i:s");
  761. } else {
  762. $data["new_submit_time"] = date("Y-m-d H:i:s");
  763. }
  764. if ($data["id"]) {
  765. TalentModel::update($data);
  766. } else {
  767. //新增
  768. $data["enterprise_id"] = $this->user["uid"];
  769. $id = TalentModel::insertGetId($data);
  770. $whr = [];
  771. $whr[] = ["fileId", "in", $files];
  772. $upd_checklog["mainId"] = $id;
  773. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  774. }
  775. TalentLogApi::write(1, $id, $checkState, "确认提交审核", 1);
  776. } else {
  777. throw new ValidateException($error_msg);
  778. }
  779. if ($id) {
  780. if ($deletes) {
  781. //删除多余的附件,一般是选择人才类型留下来的
  782. $whr = [];
  783. $whr[] = ["typeId", "in", $deletes];
  784. $whr[] = ["id", "in", $files];
  785. $_wait_del_files = Db::table("new_talent_file")->where($whr)->select()->toArray();
  786. $_logfileIds[] = [];
  787. foreach ($_wait_del_files as $_del_file) {
  788. $_logfileIds[] = $_del_file["id"];
  789. @unlink("storage/" . $_del_file["url"]);
  790. }
  791. Db::table("new_talent_file")->where($whr)->delete();
  792. if ($_logfileIds) {
  793. $whr = [];
  794. $whr[] = ["fileId", "in", $_logfileIds];
  795. $_upd_checklog["description"] = "删除附件";
  796. $_upd_checklog["updateUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"] ?: $this->user["rolename"]);
  797. $_upd_checklog["updateTime"] = date("Y-m-d H:i:s");
  798. Db::table("new_talent_checklog")->where($whr)->save($_upd_checklog);
  799. }
  800. }
  801. $whr = [];
  802. $whr[] = ["id", "in", $files];
  803. Db::table("new_talent_file")->where($whr)->save(["mainId" => $id]);
  804. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  805. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  806. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  807. exit();
  808. } else {
  809. throw new ValidateException($error_msg);
  810. }
  811. } catch (ValidateException $e) {
  812. $res = ["msg" => $e->getMessage()];
  813. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  814. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  815. exit();
  816. } catch (\think\Exception $e) {
  817. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  818. $logInfo = [
  819. "enterprise_id" => $this->user["uid"],
  820. "data" => $data,
  821. "controller" => $this->request->controller(),
  822. "action" => $this->request->action(),
  823. "errCode" => $e->getCode(),
  824. "errMsg" => $e->getMessage()
  825. ];
  826. Log::write($logInfo, "error");
  827. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  828. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  829. exit();
  830. }
  831. }
  832. private function icSave($info, \think\Request $request, $checkState) {
  833. try {
  834. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"]], $this->user["type"]);
  835. if ($batch["code"] != 200) {
  836. throw new ValidateException($batch["msg"]);
  837. }
  838. $param = $request->param();
  839. validate(TalentInfo::class)->check($param);
  840. $id = $param["id"];
  841. if ($id) {
  842. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  843. throw new ValidateException("没有对应的人才认定申报信息");
  844. }
  845. }
  846. $files = $param["uploadFiles"];
  847. $data["headimgurl"] = $info["headimgurl"];
  848. if ($request->file()) {
  849. $headimg = $request->file("photo");
  850. $upload = new \app\common\api\UploadApi();
  851. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  852. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  853. $width = imagesx($file);
  854. $height = imagesy($file);
  855. //免冠二寸照长宽413:579
  856. if ($width * 579 != $height * 413) {
  857. @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  858. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  859. }
  860. if ($info && $info["headimgurl"]) {
  861. //如果新照片符合像素要求,则删除旧照片
  862. $old_head_url = "storage/" . $info["headimgurl"];
  863. if (file_exists($old_head_url))
  864. @unlink($old_head_url);
  865. }
  866. $data["headimgurl"] = $result->filepath;
  867. }
  868. if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
  869. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  870. $data["apply_year"] = $batch["batch"];
  871. $all_valid_keys = ["name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "county", "nation", "politics", "experience", "education", "break_faith",
  872. "phone", "email", "highest_degree", "graduate_school", "major", "study_abroad",
  873. "position", "cur_entry_time", "labor_contract_rangetime",
  874. "talent_arrange", "talent_condition", "identifyConditionName", "identifyGetTime", "title", "pro_qua",
  875. "bank", "bank_branch_name", "bank_account", "description"];
  876. foreach ($all_valid_keys as $key) {
  877. $value = trim($param[$key]);
  878. if ($value) {
  879. $data[$key] = $value;
  880. }
  881. }
  882. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  883. //真实状态11是驳回,需要判断什么字段可以提交
  884. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  885. $tmp_data = $data;
  886. $data = [];
  887. foreach ($modify_fields as $field) {
  888. $data[$field] = $tmp_data[$field];
  889. }
  890. }
  891. $data["checkState"] = $checkState;
  892. $data["id"] = $id;
  893. $success_msg = "提交成功";
  894. $error_msg = "提交失败";
  895. if ($checkState == TalentState::SCND_SAVE) {
  896. $success_msg = "保存成功";
  897. if ($data["id"]) {
  898. //编辑
  899. TalentModel::update($data);
  900. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  901. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  902. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  903. } else {
  904. if (!$last_log["companyId"]) {
  905. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  906. }
  907. }
  908. } else {
  909. //新增
  910. $data["enterprise_id"] = $this->user["uid"];
  911. $id = TalentModel::insertGetId($data);
  912. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  913. $whr = [];
  914. $whr[] = ["fileId", "in", $files];
  915. $upd_checklog["mainId"] = $id;
  916. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  917. }
  918. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  919. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  920. exit();
  921. } else if ($checkState == TalentState::SCND_SUBMIT) {
  922. $data["new_submit_time"] = date("Y-m-d H:i:s");
  923. TalentModel::update($data);
  924. TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
  925. return json(["msg" => $success_msg, "code" => 200]);
  926. } else {
  927. throw new ValidateException($error_msg);
  928. }
  929. } catch (ValidateException $e) {
  930. if ($checkState == TalentState::SCND_SAVE) {
  931. $res = ["msg" => $e->getMessage()];
  932. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  933. exit();
  934. } else {
  935. return json(["msg" => $e->getMessage()]);
  936. }
  937. } catch (\think\Exception $e) {
  938. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  939. $logInfo = [
  940. "enterprise_id" => $this->user["uid"],
  941. "data" => $data,
  942. "controller" => $this->request->controller(),
  943. "action" => $this->request->action(),
  944. "errCode" => $e->getCode(),
  945. "errMsg" => $e->getMessage()
  946. ];
  947. Log::write($logInfo, "error");
  948. if ($checkState == TalentState::SCND_SAVE) {
  949. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  950. exit();
  951. } else {
  952. return json($res);
  953. }
  954. }
  955. }
  956. public function delete() {
  957. $id = $this->request->param("talentInfoId");
  958. $info = Talent::chkIsOwner($id, $this->user["uid"]);
  959. if (!$info) {
  960. return json(["msg" => "操作失败"]);
  961. }
  962. $checkState = $info["checkState"];
  963. if (in_array($checkState, [0, 1])) {
  964. $log = TalentLogApi::getLastLog($id, 1);
  965. if ($log["state"] > 1) {
  966. //有提交审核记录
  967. return json(["msg" => "该申报已提交审核,无法删除"]);
  968. }
  969. }
  970. $data["id"] = $id;
  971. $data["delete"] = 1;
  972. TalentModel::update($data);
  973. return json(["msg" => "删除成功"]);
  974. }
  975. public function mixDelete() {
  976. $id = $this->request->param("talentInfoId");
  977. $info = Talent::chkIsOwner($id, $this->user["uid"]);
  978. if (!$info) {
  979. return json(["msg" => "操作失败"]);
  980. }
  981. $checkState = $info["checkState"];
  982. if (in_array($checkState, [0, TalentState::SCND_SAVE])) {
  983. $log = TalentLogApi::getLastLog($id, 1);
  984. if ($log["state"] > 1) {
  985. //有提交审核记录
  986. return json(["msg" => "该申报已提交审核,无法删除"]);
  987. }
  988. }
  989. $data["id"] = $id;
  990. $data["delete"] = 1;
  991. TalentModel::update($data);
  992. return json(["msg" => "删除成功"]);
  993. }
  994. }