LivingAllowance.php 49 KB

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