Talent.php 47 KB

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