Talent.php 49 KB

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