Talent.php 50 KB

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