Talent.php 47 KB

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