Talent.php 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987
  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 ($data["id"]) {
  736. $data["new_submit_time"] = date("Y-m-d H:i:s");
  737. TalentModel::update($data);
  738. } else {
  739. //新增
  740. $data["enterprise_id"] = $this->user["uid"];
  741. $id = TalentModel::insertGetId($data);
  742. $whr = [];
  743. $whr[] = ["fileId", "in", $files];
  744. $upd_checklog["mainId"] = $id;
  745. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  746. }
  747. TalentLogApi::write(1, $id, $checkState, "确认提交审核", 1);
  748. } else {
  749. throw new ValidateException($error_msg);
  750. }
  751. if ($id) {
  752. if ($deletes) {
  753. //删除多余的附件,一般是选择人才类型留下来的
  754. $whr = [];
  755. $whr[] = ["typeId", "in", $deletes];
  756. $whr[] = ["id", "in", $files];
  757. $_wait_del_files = Db::table("new_talent_file")->where($whr)->select()->toArray();
  758. $_logfileIds[] = [];
  759. foreach ($_wait_del_files as $_del_file) {
  760. $_logfileIds[] = $_del_file["id"];
  761. @unlink("storage/" . $_del_file["url"]);
  762. }
  763. Db::table("new_talent_file")->where($whr)->delete();
  764. if ($_logfileIds) {
  765. $whr = [];
  766. $whr[] = ["fileId", "in", $_logfileIds];
  767. $_upd_checklog["description"] = "删除附件";
  768. $_upd_checklog["updateUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"] ?: $this->user["rolename"]);
  769. $_upd_checklog["updateTime"] = date("Y-m-d H:i:s");
  770. Db::table("new_talent_checklog")->where($whr)->save($_upd_checklog);
  771. }
  772. }
  773. $whr = [];
  774. $whr[] = ["id", "in", $files];
  775. Db::table("new_talent_file")->where($whr)->save(["mainId" => $id]);
  776. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  777. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  778. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  779. exit();
  780. } else {
  781. throw new ValidateException($error_msg);
  782. }
  783. } catch (ValidateException $e) {
  784. $res = ["msg" => $e->getMessage()];
  785. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  786. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  787. exit();
  788. }
  789. }
  790. private function icSave($info, \think\Request $request, $checkState) {
  791. try {
  792. $batch = \app\common\api\BatchApi::getValidBatch(1, $this->user["type"]);
  793. if (!$batch) {
  794. throw new ValidateException("不在人才认定申报申请时间内");
  795. }
  796. $param = $request->param();
  797. validate(TalentInfo::class)->check($param);
  798. $id = $param["id"];
  799. if ($id) {
  800. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  801. throw new ValidateException("没有对应的人才认定申报信息");
  802. }
  803. }
  804. $files = $param["uploadFiles"];
  805. $data["headimgurl"] = $info["headimgurl"];
  806. if ($request->file()) {
  807. $headimg = $request->file("photo");
  808. $upload = new \app\common\api\UploadApi();
  809. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  810. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  811. $width = imagesx($file);
  812. $height = imagesy($file);
  813. //免冠二寸照长宽413:579
  814. if ($width * 579 != $height * 413) {
  815. @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  816. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  817. }
  818. if ($info && $info["headimgurl"]) {
  819. //如果新照片符合像素要求,则删除旧照片
  820. $old_head_url = "storage/" . $info["headimgurl"];
  821. if (file_exists($old_head_url))
  822. @unlink($old_head_url);
  823. }
  824. $data["headimgurl"] = $result->filepath;
  825. }
  826. if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
  827. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  828. $data["apply_year"] = $batch["batch"];
  829. $all_valid_keys = ["name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "county", "nation", "politics", "experience", "education", "break_faith",
  830. "phone", "email", "highest_degree", "graduate_school", "major", "study_abroad",
  831. "position", "cur_entry_time", "labor_contract_rangetime",
  832. "talent_arrange", "talent_condition", "identifyConditionName", "identifyGetTime", "title", "pro_qua",
  833. "bank", "bank_branch_name", "bank_account", "description"];
  834. foreach ($all_valid_keys as $key) {
  835. $value = trim($param[$key]);
  836. if ($value) {
  837. $data[$key] = $value;
  838. }
  839. }
  840. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  841. //真实状态11是驳回,需要判断什么字段可以提交
  842. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  843. $tmp_data = $data;
  844. $data = [];
  845. foreach ($modify_fields as $field) {
  846. $data[$field] = $tmp_data[$field];
  847. }
  848. }
  849. $data["checkState"] = $checkState;
  850. $data["id"] = $id;
  851. $success_msg = "提交成功";
  852. $error_msg = "提交失败";
  853. if ($checkState == TalentState::SCND_SAVE) {
  854. $success_msg = "保存成功";
  855. if ($data["id"]) {
  856. //编辑
  857. TalentModel::update($data);
  858. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  859. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  860. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  861. } else {
  862. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  863. }
  864. } else {
  865. //新增
  866. $data["enterprise_id"] = $this->user["uid"];
  867. $id = TalentModel::insertGetId($data);
  868. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  869. $whr = [];
  870. $whr[] = ["fileId", "in", $files];
  871. $upd_checklog["mainId"] = $id;
  872. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  873. }
  874. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $data["id"], "checkState" => $checkState]];
  875. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  876. exit();
  877. } else if ($checkState == TalentState::SCND_SUBMIT) {
  878. $data["new_submit_time"] = date("Y-m-d H:i:s");
  879. TalentModel::update($data);
  880. TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
  881. return json(["msg" => $success_msg, "code" => 200]);
  882. } else {
  883. throw new ValidateException($error_msg);
  884. }
  885. } catch (ValidateException $e) {
  886. if ($checkState == TalentState::SCND_SAVE) {
  887. $res = ["msg" => $e->getMessage()];
  888. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  889. exit();
  890. } else {
  891. return json(["msg" => $e->getMessage()], 500);
  892. }
  893. }
  894. }
  895. public function delete() {
  896. $id = $this->request->param("talentInfoId");
  897. $info = Talent::chkIsOwner($id, $this->user["uid"]);
  898. if (!$info) {
  899. return json(["msg" => "操作失败"]);
  900. }
  901. $checkState = $info["checkState"];
  902. if (in_array($checkState, [0, 1])) {
  903. $log = TalentLogApi::getLastLog($id, 1);
  904. if ($log["state"] > 1) {
  905. //有提交审核记录
  906. return json(["msg" => "该申报已提交审核,无法删除"]);
  907. }
  908. }
  909. $data["id"] = $id;
  910. $data["delete"] = 1;
  911. TalentModel::update($data);
  912. return json(["msg" => "删除成功"]);
  913. }
  914. public function mixDelete() {
  915. $id = $this->request->param("talentInfoId");
  916. $info = Talent::chkIsOwner($id, $this->user["uid"]);
  917. if (!$info) {
  918. return json(["msg" => "操作失败"]);
  919. }
  920. $checkState = $info["checkState"];
  921. if (in_array($checkState, [0, TalentState::SCND_SAVE])) {
  922. $log = TalentLogApi::getLastLog($id, 1);
  923. if ($log["state"] > 1) {
  924. //有提交审核记录
  925. return json(["msg" => "该申报已提交审核,无法删除"]);
  926. }
  927. }
  928. $data["id"] = $id;
  929. $data["delete"] = 1;
  930. TalentModel::update($data);
  931. return json(["msg" => "删除成功"]);
  932. }
  933. }