Talent.php 45 KB

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