Talent.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  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 app\common\api\EnterpriseApi;
  8. use app\common\api\DictApi;
  9. use app\common\api\TalentLogApi;
  10. use app\common\api\TalentState;
  11. use think\exception\ValidateException;
  12. use app\enterprise\validate\TalentInfo;
  13. // 0正在填写 1保存未提交 2已提交未审核 3已审核 4驳回 5保存补充材料未提交 6提交补充材料进入初审 7初审通过 8初审驳回 9部门审核通过 10部门审核驳回 11复核通过 12复核驳回 13复核失败
  14. /**
  15. * Description of Talent
  16. *
  17. * @author sgq
  18. */
  19. class Talent extends EnterpriseController {
  20. public function index() {
  21. $isMix = $this->request->param("isMix");
  22. $tpl = "";
  23. if ($isMix == 1) {
  24. $tpl = "newIndex";
  25. }
  26. return view($tpl);
  27. }
  28. public function list() {
  29. $step = 2;
  30. $res = TalentApi::getList($this->request, $step);
  31. return json($res);
  32. }
  33. /**
  34. * 新人才申报企业端统一申报入口,混合基础信息及人才信息
  35. */
  36. public function apply(\think\Request $request) {
  37. $type = $this->user["type"];
  38. $tpl = "";
  39. switch ($type) {
  40. case 1:
  41. $tpl = "apply"; //晋江人才
  42. break;
  43. case 2:
  44. $tpl = "ic_apply"; //集成电路
  45. break;
  46. }
  47. $param = $request->param();
  48. $id = isset($param["id"]) ? $param["id"] : 0;
  49. $info = TalentApi::chkIsOwner($id, $this->user["uid"]);
  50. $ep = EnterpriseApi::getOne($this->user["uid"]);
  51. if (!chkEnterpriseFull($ep))
  52. return;
  53. $tagList = DictApi::selectByParentCode('enterprise_tag');
  54. $streetList = DictApi::selectByParentCode('street');
  55. $industryFieldNew = DictApi::selectByParentCode('industry_field');
  56. $ep->enterpristTagName = $tagList[$ep->enterpriseTag];
  57. $ep->streetName = $streetList[$ep->street];
  58. $ep->industryFieldNewName = $industryFieldNew[$ep->industryFieldNew];
  59. if ($info) {
  60. $info["real_state"] = TalentLogApi::getLastLog($id, $type)["state"];
  61. }
  62. if ($info && in_array($info["checkState"], [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::REVERIFY_PASS, TalentState::REVERIFY_FAIL])) {
  63. return $this->view($request);
  64. exit();
  65. }
  66. if ($request->isPost()) {
  67. $checkState = $info["checkState"] ?: 0;
  68. if ($checkState == TalentState::SCND_SAVE || $checkState == 0) {
  69. $this->mixSave($info, $request, TalentState::SCND_SAVE);
  70. exit();
  71. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
  72. $res = ["msg" => "审核失败,不能再保存"];
  73. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  74. exit;
  75. }
  76. $res = ["msg" => "已提交审核,请耐心等待"];
  77. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  78. exit;
  79. }
  80. $checkState = $info["checkState"] ?: 0;
  81. $info["enterprise"] = $ep;
  82. $info["talent_type_list"] = DictApi::findChildDictByCode("talent_type");
  83. return view($tpl, ["year" => date("Y"), "checkState" => $checkState, "row" => $info]);
  84. }
  85. /**
  86. * 旧第二步
  87. * @param \think\Request $request
  88. * @return type
  89. */
  90. public function second(\think\Request $request) {
  91. $params = $request->param();
  92. $id = $params["id"];
  93. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  94. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  95. if ($request->isPost()) {
  96. if (!$info || $info["enterprise_id"] != $this->user["uid"]) {
  97. $res = ["msg" => "没有对应的人才认定申报信息"];
  98. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  99. exit;
  100. }
  101. $checkState = $info["checkState"];
  102. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::BASE_REVERIFY_PASS) {
  103. $this->save($info, $request, TalentState::SCND_SAVE);
  104. exit();
  105. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
  106. $res = ["msg" => "审核失败,不能再保存"];
  107. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  108. exit;
  109. }
  110. $res = ["msg" => "已提交审核,请耐心等待"];
  111. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  112. exit;
  113. }
  114. $enterprise_info = \app\common\model\Enterprise::find($this->user["uid"]);
  115. $info["enterprise"] = $enterprise_info;
  116. $batch = \app\common\api\BatchApi::getValidBatch(1, $enterprise_info["type"]);
  117. return view("second", ["year" => $info["apply_year"] ?: $batch["batch"], "row" => $info]);
  118. }
  119. public function view(\think\Request $request) {
  120. switch ($this->user["type"]) {
  121. case 1:
  122. $tpl = "view"; //晋江人才
  123. break;
  124. case 2:
  125. $tpl = "ic_view"; //集成电路
  126. break;
  127. }
  128. $id = $request->param("id");
  129. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  130. return view($tpl, ["row" => $info]);
  131. }
  132. /**
  133. * 提交表单(旧第二步)
  134. */
  135. public function submit() {
  136. $params = $this->request->param();
  137. $id = $params["id"];
  138. if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
  139. $res = ["msg" => "没有对应的人才认定申报信息"];
  140. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  141. exit;
  142. }
  143. $checkState = $info["checkState"];
  144. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::BASE_REVERIFY_PASS) {
  145. $field_dict = \app\common\api\DictApi::getTalentFields(2);
  146. $no_empty = ["talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "bank", "bank_number", "bank_branch_name",
  147. "bank_account", "study_abroad", "phone", "email", "import_way", "cur_entry_time", "cur_entry_time", "position", "source"];
  148. $where = [];
  149. $where[] = ["rel", "=", "study_abroad"];
  150. $where[] = ["step", "=", 2];
  151. $where[] = ["project", "=", 1];
  152. $where[] = ["active", "=", 1];
  153. $where[] = ["delete", "=", 0];
  154. $where[] = ["type", "=", $this->user["type"]];
  155. $where[] = ["isConditionFile", "<>", 1];
  156. $abroad_files = Db::table("new_common_filetype")->where($where)->select()->toArray(); //留学的附件
  157. $abroad_file_ids = null;
  158. if ($abroad_files)
  159. $abroad_file_ids = array_column($abroad_files, "id");
  160. if ($params["study_abroad"] == 1) {
  161. $no_empty[] = "abroad_school";
  162. $no_empty[] = "abroad_major";
  163. }
  164. if (in_array($params["source"], [1, 3])) {
  165. $no_empty[] = "source_batch";
  166. $no_empty[] = "fujian_highcert_pubtime";
  167. $no_empty[] = "fujian_highcert_exptime";
  168. if ($params["source"] == 3) {
  169. $no_empty[] = "source_city";
  170. }
  171. }
  172. if (in_array($params["source"], [2, 4])) {
  173. $no_empty[] = "source_batch";
  174. $no_empty[] = "quanzhou_highcert_pubtime";
  175. $no_empty[] = "quanzhou_highcert_exptime";
  176. if ($params["source"] == 4) {
  177. $no_empty[] = "source_county";
  178. }
  179. }
  180. $condition_info = Db::table("new_talent_condition")->findOrEmpty($params["talent_condition"]);
  181. if ($condition_info["isSalary"] == 1) {
  182. $no_empty[] = "annual_salary";
  183. }
  184. $no_empty = array_filter($no_empty);
  185. $return = [];
  186. foreach ($no_empty as $key) {
  187. if (!$params[$key]) {
  188. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  189. }
  190. }
  191. if (count($return) > 0) {
  192. $res = ["msg" => implode("<br>", $return)];
  193. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  194. exit;
  195. }
  196. if ($condition_info["bindFileTypes"] && $info["source"] == 5) {
  197. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  198. $whr[] = ["must", "=", 1];
  199. }
  200. $where = [];
  201. $where[] = ["step", "=", 2];
  202. $where[] = ["project", "=", 1];
  203. $where[] = ["type", "=", $this->user["type"]];
  204. $where[] = ["must", "=", 1];
  205. $where[] = ["active", "=", 1];
  206. $where[] = ["delete", "=", 0];
  207. $where[] = ["isConditionFile", "<>", 1];
  208. if ($whr) {
  209. $filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
  210. } else {
  211. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  212. }
  213. $ft_ids = array_column($filetypes, "id");
  214. if ($params["study_abroad"] == 1) {
  215. //选中留学,如果存在留学附件变成必传
  216. $ft_ids = array_unique(array_merge($ft_ids, (array) $abroad_file_ids));
  217. } else {
  218. //没选中,留学附件就算设成必传也不用验证
  219. $ft_ids = array_diff($ft_ids, (array) $abroad_file_ids);
  220. }
  221. $whr = [];
  222. $whr[] = ["typeId", "in", $ft_ids];
  223. $whr[] = ["mainId", "=", $id];
  224. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
  225. $upload_type_counts = count($distinct_filetypes);
  226. if ($upload_type_counts != count($ft_ids)) {
  227. $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
  228. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  229. exit;
  230. }
  231. $this->save($info, $this->request, TalentState::SCND_SUBMIT);
  232. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
  233. $res = ["msg" => "审核失败,不能再提交审核"];
  234. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  235. exit;
  236. }
  237. $res = ["msg" => "已提交审核,请耐心等待"];
  238. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  239. exit;
  240. }
  241. /**
  242. * 提交表单(新:混合基础信息人才申报信息)
  243. */
  244. public function submitToCheck() {
  245. $params = $this->request->param();
  246. $id = $params["id"];
  247. if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
  248. $res = ["msg" => "没有对应的人才认定申报信息"];
  249. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  250. exit;
  251. }
  252. $checkState = $info["checkState"];
  253. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::BASE_REVERIFY_PASS) {
  254. $field_dict = \app\common\api\DictApi::getTalentFields(2);
  255. $no_empty = ["talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "bank", "bank_number", "bank_branch_name",
  256. "bank_account", "study_abroad", "phone", "email", "import_way", "cur_entry_time", "cur_entry_time", "position", "source"];
  257. $where = [];
  258. $where[] = ["rel", "=", "study_abroad"];
  259. $where[] = ["step", "=", 2];
  260. $where[] = ["project", "=", 1];
  261. $where[] = ["active", "=", 1];
  262. $where[] = ["delete", "=", 0];
  263. $where[] = ["type", "=", $this->user["type"]];
  264. $where[] = ["isConditionFile", "<>", 1];
  265. $abroad_files = Db::table("new_common_filetype")->where($where)->select()->toArray(); //留学的附件
  266. $abroad_file_ids = null;
  267. if ($abroad_files)
  268. $abroad_file_ids = array_column($abroad_files, "id");
  269. if ($params["study_abroad"] == 1) {
  270. $no_empty[] = "abroad_school";
  271. $no_empty[] = "abroad_major";
  272. }
  273. if (in_array($params["source"], [1, 3])) {
  274. $no_empty[] = "source_batch";
  275. $no_empty[] = "fujian_highcert_pubtime";
  276. $no_empty[] = "fujian_highcert_exptime";
  277. if ($params["source"] == 3) {
  278. $no_empty[] = "source_city";
  279. }
  280. }
  281. if (in_array($params["source"], [2, 4])) {
  282. $no_empty[] = "source_batch";
  283. $no_empty[] = "quanzhou_highcert_pubtime";
  284. $no_empty[] = "quanzhou_highcert_exptime";
  285. if ($params["source"] == 4) {
  286. $no_empty[] = "source_county";
  287. }
  288. }
  289. $condition_info = Db::table("new_talent_condition")->findOrEmpty($params["talent_condition"]);
  290. if ($condition_info["isSalary"] == 1) {
  291. $no_empty[] = "annual_salary";
  292. }
  293. $no_empty = array_filter($no_empty);
  294. $return = [];
  295. foreach ($no_empty as $key) {
  296. if (!$params[$key]) {
  297. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  298. }
  299. }
  300. if (count($return) > 0) {
  301. $res = ["msg" => implode("<br>", $return)];
  302. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  303. exit;
  304. }
  305. if ($condition_info["bindFileTypes"] && $info["source"] == 5) {
  306. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  307. $whr[] = ["must", "=", 1];
  308. }
  309. $where = [];
  310. $where[] = ["step", "=", 2];
  311. $where[] = ["project", "=", 1];
  312. $where[] = ["type", "=", $this->user["type"]];
  313. $where[] = ["must", "=", 1];
  314. $where[] = ["active", "=", 1];
  315. $where[] = ["delete", "=", 0];
  316. $where[] = ["isConditionFile", "<>", 1];
  317. if ($whr) {
  318. $filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
  319. } else {
  320. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  321. }
  322. $ft_ids = array_column($filetypes, "id");
  323. if ($params["study_abroad"] == 1) {
  324. //选中留学,如果存在留学附件变成必传
  325. $ft_ids = array_unique(array_merge($ft_ids, (array) $abroad_file_ids));
  326. } else {
  327. //没选中,留学附件就算设成必传也不用验证
  328. $ft_ids = array_diff($ft_ids, (array) $abroad_file_ids);
  329. }
  330. $whr = [];
  331. $whr[] = ["typeId", "in", $ft_ids];
  332. $whr[] = ["mainId", "=", $id];
  333. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
  334. $upload_type_counts = count($distinct_filetypes);
  335. if ($upload_type_counts != count($ft_ids)) {
  336. $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
  337. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  338. exit;
  339. }
  340. $this->save($info, $this->request, TalentState::SCND_SUBMIT);
  341. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
  342. $res = ["msg" => "审核失败,不能再提交审核"];
  343. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  344. exit;
  345. }
  346. $res = ["msg" => "已提交审核,请耐心等待"];
  347. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  348. exit;
  349. }
  350. /**
  351. * 保存表单(旧第二步)
  352. * @param type $info talent_info
  353. * @param type $param request->param();
  354. */
  355. private function save($info, \think\Request $request, $checkState) {
  356. try {
  357. $batch = \app\common\api\BatchApi::getValidBatch(1, $this->user["type"]);
  358. if (!$batch) {
  359. throw new ValidateException("不在人才认定申报申请时间内");
  360. }
  361. $param = $request->param();
  362. validate(TalentInfo::class)->check($param);
  363. $data["apply_year"] = $batch["batch"];
  364. $all_valid_keys = ["applay_year", "import_way", "cur_entry_time", "position",
  365. "source", "source_batch", "fujian_highcert_pubtime", "fujian_highcert_exptime", "quanzhou_highcert_pubtime", "quanzhou_highcert_exptime", "source_city", "source_county",
  366. "talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "professional", "bank", "bank_number", "bank_branch_name", "bank_account",
  367. "study_abroad", "abroad_school", "abroad_major", "phone", "email", "annual_salary", "pro_qua"];
  368. foreach ($all_valid_keys as $key) {
  369. $data[$key] = trim($param[$key]);
  370. }
  371. if ($data["study_abroad"] == 1) {
  372. $data["abroad_school"] = $param["abroad_school"];
  373. $data["abroad_major"] = $param["abroad_major"];
  374. } else {
  375. $data["abroad_school"] = null;
  376. $data["abroad_major"] = null;
  377. }
  378. switch ($data["source"]) {
  379. case 1:
  380. $data["source_batch"] = $param["source_batch"];
  381. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  382. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  383. $data["source_city"] = null;
  384. break;
  385. case 2:
  386. $data["source_batch"] = $param["source_batch"];
  387. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  388. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  389. $data["source_county"] = null;
  390. break;
  391. case 3:
  392. $data["source_batch"] = $param["source_batch"];
  393. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  394. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  395. $data["source_city"] = $param["source_city"];
  396. break;
  397. case 4:
  398. $data["source_batch"] = $param["source_batch"];
  399. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  400. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  401. $data["source_county"] = $param["source_county"];
  402. break;
  403. }
  404. $condition_info = Db::table("new_talent_condition")->findOrEmpty($param["talent_condition"]);
  405. if ($condition_info["isSalary"] == 1) {
  406. $data["annual_salary"] = $param["annual_salary"];
  407. } else {
  408. $data["annual_salary"] = null;
  409. }
  410. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  411. //真实状态8是驳回,需要判断什么字段可以提交
  412. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  413. $tmp_data = $data;
  414. $data = [];
  415. foreach ($modify_fields as $field) {
  416. $data[$field] = $tmp_data[$field];
  417. }
  418. }
  419. $data["checkState"] = $checkState;
  420. $data["id"] = $info["id"];
  421. $success_msg = "提交成功";
  422. $error_msg = "提交失败";
  423. if ($checkState == TalentState::SCND_SAVE) {
  424. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  425. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  426. TalentLogApi::write(1, $data["id"], $checkState, "保存认定材料未提交", 1);
  427. }
  428. TalentModel::update($data);
  429. } else if ($checkState == TalentState::SCND_SUBMIT) {
  430. $success_msg = "提交成功";
  431. $error_msg = "提交失败";
  432. $data["new_submit_time"] = date("Y-m-d H:i:s");
  433. TalentModel::update($data);
  434. TalentLogApi::write(1, $info["id"], $checkState, "确认提交审核", 1);
  435. } else {
  436. throw new ValidateException($error_msg);
  437. }
  438. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $info["id"], "checkState" => $checkState]];
  439. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  440. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  441. exit();
  442. } catch (ValidateException $e) {
  443. $res = ["msg" => $e->getMessage()];
  444. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  445. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  446. exit();
  447. }
  448. }
  449. /**
  450. * 保存表单(新:混合基础信息人才申报信息)
  451. * @param type $info talent_info
  452. * @param type $param request->param();
  453. */
  454. private function mixSave($info, \think\Request $request, $checkState) {
  455. try {
  456. $batch = \app\common\api\BatchApi::getValidBatch(1, $this->user["type"]);
  457. if (!$batch) {
  458. throw new ValidateException("不在人才认定申报申请时间内");
  459. }
  460. $param = $request->param();
  461. validate(TalentInfo::class)->check($param);
  462. $data["apply_year"] = $batch["batch"];
  463. $all_valid_keys = ["applay_year", "import_way", "cur_entry_time", "position",
  464. "source", "source_batch", "fujian_highcert_pubtime", "fujian_highcert_exptime", "quanzhou_highcert_pubtime", "quanzhou_highcert_exptime", "source_city", "source_county",
  465. "talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "professional", "bank", "bank_number", "bank_branch_name", "bank_account",
  466. "study_abroad", "abroad_school", "abroad_major", "phone", "email", "annual_salary", "pro_qua"];
  467. foreach ($all_valid_keys as $key) {
  468. $data[$key] = trim($param[$key]);
  469. }
  470. if ($data["study_abroad"] == 1) {
  471. $data["abroad_school"] = $param["abroad_school"];
  472. $data["abroad_major"] = $param["abroad_major"];
  473. } else {
  474. $data["abroad_school"] = null;
  475. $data["abroad_major"] = null;
  476. }
  477. switch ($data["source"]) {
  478. case 1:
  479. $data["source_batch"] = $param["source_batch"];
  480. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  481. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  482. $data["source_city"] = null;
  483. break;
  484. case 2:
  485. $data["source_batch"] = $param["source_batch"];
  486. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  487. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  488. $data["source_county"] = null;
  489. break;
  490. case 3:
  491. $data["source_batch"] = $param["source_batch"];
  492. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  493. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  494. $data["source_city"] = $param["source_city"];
  495. break;
  496. case 4:
  497. $data["source_batch"] = $param["source_batch"];
  498. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  499. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  500. $data["source_county"] = $param["source_county"];
  501. break;
  502. }
  503. $condition_info = Db::table("new_talent_condition")->findOrEmpty($param["talent_condition"]);
  504. if ($condition_info["isSalary"] == 1) {
  505. $data["annual_salary"] = $param["annual_salary"];
  506. } else {
  507. $data["annual_salary"] = null;
  508. }
  509. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  510. //真实状态8是驳回,需要判断什么字段可以提交
  511. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  512. $tmp_data = $data;
  513. $data = [];
  514. foreach ($modify_fields as $field) {
  515. $data[$field] = $tmp_data[$field];
  516. }
  517. }
  518. $data["checkState"] = $checkState;
  519. $data["id"] = $info["id"];
  520. $success_msg = "提交成功";
  521. $error_msg = "提交失败";
  522. if ($checkState == TalentState::SCND_SAVE) {
  523. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  524. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  525. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  526. }
  527. TalentModel::update($data);
  528. } else if ($checkState == TalentState::SCND_SUBMIT) {
  529. $success_msg = "提交成功";
  530. $error_msg = "提交失败";
  531. $data["new_submit_time"] = date("Y-m-d H:i:s");
  532. TalentModel::update($data);
  533. TalentLogApi::write(1, $info["id"], $checkState, "确认提交审核", 1);
  534. } else {
  535. throw new ValidateException($error_msg);
  536. }
  537. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $info["id"], "checkState" => $checkState]];
  538. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  539. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  540. exit();
  541. } catch (ValidateException $e) {
  542. $res = ["msg" => $e->getMessage()];
  543. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  544. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  545. exit();
  546. }
  547. }
  548. public function delete() {
  549. $id = $this->request->param("talentInfoId");
  550. $info = Talent::chkIsOwner($id, $this->user["uid"]);
  551. if (!$info) {
  552. return json(["msg" => "操作失败"]);
  553. }
  554. $checkState = $info["checkState"];
  555. if (in_array($checkState, [0, 1])) {
  556. $log = TalentLogApi::getLastLog($id, 1);
  557. if ($log["state"] > 1) {
  558. //有提交审核记录
  559. return json(["msg" => "操作失败"]);
  560. }
  561. }
  562. $data["id"] = $id;
  563. $data["delete"] = 1;
  564. TalentModel::update($data);
  565. return json(["msg" => "删除成功"]);
  566. }
  567. }