Talent.php 47 KB

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