Talent.php 46 KB

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