Talent.php 47 KB

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