Talent.php 45 KB

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