Talent.php 47 KB

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