Talent.php 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336
  1. <?php
  2. namespace app\enterprise\controller;
  3. use app\common\api\EducationApi;
  4. use app\enterprise\common\EnterpriseController;
  5. use app\enterprise\api\TalentApi;
  6. use app\enterprise\model\Talent as TalentModel;
  7. use think\facade\Db;
  8. use think\facade\Log;
  9. use app\common\api\EnterpriseApi;
  10. use app\common\api\DictApi;
  11. use app\common\api\TalentLogApi;
  12. use app\common\api\TalentState;
  13. use think\exception\ValidateException;
  14. use app\enterprise\validate\TalentInfo;
  15. use app\common\state\ProjectState;
  16. use app\common\api\BatchApi;
  17. use app\common\state\CommonConst;
  18. // 0正在填写 1保存未提交 2已提交未审核 3已审核 4驳回 5保存补充材料未提交 6提交补充材料进入初审 7初审通过 8初审驳回 9部门审核通过 10部门审核驳回 11复核通过 12复核驳回 13复核失败
  19. /**
  20. * Description of Talent
  21. *
  22. * @author sgq
  23. */
  24. class Talent extends EnterpriseController {
  25. public function index() {
  26. $isMix = $this->request->param("isMix");
  27. $tpl = "";
  28. if ($isMix == 1) {
  29. $tpl = "newIndex";
  30. }
  31. return view($tpl, ['type' => session("user")['type']]);
  32. }
  33. public function list() {
  34. $step = 2;
  35. $res = TalentApi::getList($this->request, $step);
  36. return json($res);
  37. }
  38. public function zrIndex() {
  39. return view();
  40. }
  41. /**
  42. * 新人才申报企业端统一申报入口,混合基础信息及人才信息
  43. */
  44. public function apply(\think\Request $request) {
  45. $type = $this->user["type"];
  46. $tpl = "";
  47. switch ($type) {
  48. case CommonConst::ENTERPRISE_NORMAL:
  49. $tpl = "apply"; //晋江人才
  50. break;
  51. case CommonConst::ENTERPRISE_JC:
  52. $tpl = "ic_apply"; //集成电路
  53. break;
  54. case CommonConst::ENTERPRISE_WJ:
  55. $tpl = "/talent/hospital/apply"; //卫健医院
  56. break;
  57. case CommonConst::ENTERPRISE_GJ:
  58. $tpl = "/talent/school/apply"; //高教学校
  59. break;
  60. }
  61. $param = $request->param();
  62. $id = isset($param["id"]) ? $param["id"] : 0;
  63. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  64. if ($info["isImport"]) {
  65. //$tpl = "no_file_apply"; //晋江人才
  66. }
  67. $ep = EnterpriseApi::getOne($this->user["uid"]);
  68. if (!chkEnterpriseFull($ep))
  69. return;
  70. $tagList = DictApi::selectByParentCode('enterprise_tag');
  71. $streetList = DictApi::selectByParentCode('street');
  72. $industryFieldNew = DictApi::selectByParentCode('industry_field');
  73. $ep->enterpristTagName = $tagList[$ep->enterpriseTag];
  74. $ep->streetName = $streetList[$ep->street];
  75. $ep->industryFieldNewName = $industryFieldNew[$ep->industryFieldNew];
  76. if ($info) {
  77. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  78. }
  79. if ($info && in_array($info["checkState"], [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::REVERIFY_PASS, TalentState::REVERIFY_FAIL])) {
  80. return $this->view($request);
  81. exit();
  82. }
  83. if ($request->isPost()) {
  84. $checkState = $info["checkState"] ?: 0;
  85. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::FST_SAVE || $checkState == 0) {
  86. switch ($type) {
  87. case CommonConst::ENTERPRISE_NORMAL:
  88. $this->mixSave($info, $request, TalentState::SCND_SAVE);
  89. exit();
  90. break;
  91. case CommonConst::ENTERPRISE_JC:
  92. $this->icSave($info, $request, TalentState::SCND_SAVE);
  93. exit();
  94. break;
  95. case CommonConst::ENTERPRISE_WJ:
  96. if ($ep->isGeneral == 1) {
  97. $this->wjSave($info, $request, TalentState::SCND_SAVE);
  98. } else {
  99. $this->wjSave($info, $request, TalentState::FST_SAVE);
  100. }
  101. break;
  102. case CommonConst::ENTERPRISE_GJ:
  103. $this->gjSave($info, $request, TalentState::SCND_SAVE);
  104. break;
  105. }
  106. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
  107. $res = ["msg" => "审核不通过,不能再保存"];
  108. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  109. exit;
  110. }
  111. $res = ["msg" => "已提交审核,请耐心等待"];
  112. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  113. exit;
  114. }
  115. $checkState = $info["checkState"] ?: 0;
  116. $batch = $info["apply_year"] ?: BatchApi::getValidBatch(ProjectState::TALENT, $this->user["type"])["batch"];
  117. $info["enterprise"] = $ep;
  118. $info["talent_type_list"] = DictApi::findChildDictByCode("talent_type");
  119. if ($info["talent_condition"]) {
  120. $info["isSalary"] = \app\common\api\TalentConditionApi::getOne($info["talent_condition"])["isSalary"] ?: 0;
  121. }
  122. return view($tpl, ["year" => $batch, "checkState" => $checkState, "row" => $info]);
  123. }
  124. /**
  125. * 旧第二步
  126. * @param \think\Request $request
  127. * @return type
  128. */
  129. public function second(\think\Request $request) {
  130. if ($this->user["type"] != 1)
  131. return "此入口仅供晋江市人才申报,晋江集成电路人才请使用新统一申报入口";
  132. $params = $request->param();
  133. $id = $params["id"];
  134. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  135. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  136. if ($request->isPost()) {
  137. if (!$info || $info["enterprise_id"] != $this->user["uid"]) {
  138. $res = ["msg" => "没有对应的人才认定申报信息"];
  139. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  140. exit;
  141. }
  142. $checkState = $info["checkState"];
  143. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::BASE_REVERIFY_PASS) {
  144. $this->save($info, $request, TalentState::SCND_SAVE);
  145. exit();
  146. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
  147. $res = ["msg" => "审核不通过,不能再保存"];
  148. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  149. exit;
  150. }
  151. $res = ["msg" => "已提交审核,请耐心等待"];
  152. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  153. exit;
  154. }
  155. $enterprise_info = \app\common\model\Enterprise::find($this->user["uid"]);
  156. $info["enterprise"] = $enterprise_info;
  157. $batch = $info["apply_year"] ?: BatchApi::getValidBatch(ProjectState::TALENT, $enterprise_info["type"])["batch"];
  158. return view("second", ["year" => $batch, "row" => $info]);
  159. }
  160. public function view(\think\Request $request) {
  161. switch ($this->user["type"]) {
  162. case CommonConst::ENTERPRISE_NORMAL:
  163. $tpl = "view"; //晋江人才
  164. break;
  165. case CommonConst::ENTERPRISE_JC:
  166. $tpl = "ic_view"; //集成电路
  167. break;
  168. case CommonConst::ENTERPRISE_WJ:
  169. $tpl = "/talent/hospital/view"; //卫健医院
  170. break;
  171. case CommonConst::ENTERPRISE_GJ:
  172. $tpl = "/talent/school/view"; //高教学校
  173. break;
  174. }
  175. $id = $request->param("id");
  176. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  177. if ($info["isImport"]) {
  178. //$tpl = "no_file_view";
  179. }
  180. return view($tpl, ["row" => $info]);
  181. }
  182. /**
  183. * 提交表单(旧第二步)
  184. */
  185. public function submit() {
  186. $params = $this->request->param();
  187. $id = $params["id"];
  188. if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
  189. $res = ["msg" => "没有对应的人才认定申报信息"];
  190. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  191. exit;
  192. }
  193. if ($info) {
  194. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  195. }
  196. $checkState = $info["checkState"];
  197. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::BASE_REVERIFY_PASS) {
  198. $field_dict = \app\common\api\DictApi::getTalentFields(2);
  199. $no_empty = ["talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "bank", "bank_number", "bank_branch_name",
  200. "bank_account", "study_abroad", "phone", "email", "import_way", "cur_entry_time", "cur_entry_time", "position", "source"];
  201. $where = [];
  202. $where[] = ["rel", "=", "study_abroad"];
  203. $where[] = ["step", "=", 2];
  204. $where[] = ["project", "=", 1];
  205. $where[] = ["active", "=", 1];
  206. $where[] = ["delete", "=", 0];
  207. $where[] = ["type", "=", $this->user["type"]];
  208. $where[] = ["isConditionFile", "<>", 1];
  209. $abroad_files = Db::table("new_common_filetype")->where($where)->select()->toArray(); //留学的附件
  210. $abroad_file_ids = null;
  211. if ($abroad_files)
  212. $abroad_file_ids = array_column($abroad_files, "id");
  213. if ($params["study_abroad"] == 1) {
  214. $no_empty[] = "abroad_school";
  215. $no_empty[] = "abroad_major";
  216. }
  217. if (in_array($params["source"], [1, 3])) {
  218. $no_empty[] = "source_batch";
  219. $no_empty[] = "fujian_highcert_pubtime";
  220. $no_empty[] = "fujian_highcert_exptime";
  221. if ($params["source"] == 3) {
  222. $no_empty[] = "source_city";
  223. }
  224. }
  225. if (in_array($params["source"], [2, 4])) {
  226. $no_empty[] = "source_batch";
  227. $no_empty[] = "quanzhou_highcert_pubtime";
  228. $no_empty[] = "quanzhou_highcert_exptime";
  229. if ($params["source"] == 4) {
  230. $no_empty[] = "source_county";
  231. }
  232. }
  233. $condition_info = Db::table("new_talent_condition")->findOrEmpty($params["talent_condition"]);
  234. if ($condition_info["isSalary"] == 1) {
  235. $no_empty[] = "annual_salary";
  236. }
  237. $no_empty = array_filter($no_empty);
  238. $return = [];
  239. foreach ($no_empty as $key) {
  240. if (!$params[$key]) {
  241. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  242. }
  243. }
  244. if (count($return) > 0) {
  245. $res = ["msg" => implode("<br>", $return)];
  246. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  247. exit;
  248. }
  249. if ($condition_info["bindFileTypes"] && in_array($info["source"], [3, 4, 5])) {
  250. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  251. $whr[] = ["must", "=", 1];
  252. }
  253. $where = [];
  254. $where[] = ["step", "=", 2];
  255. $where[] = ["project", "=", 1];
  256. $where[] = ["type", "=", $this->user["type"]];
  257. $where[] = ["must", "=", 1];
  258. $where[] = ["active", "=", 1];
  259. $where[] = ["delete", "=", 0];
  260. $where[] = ["isConditionFile", "<>", 1];
  261. if ($whr) {
  262. $filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
  263. } else {
  264. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  265. }
  266. $ft_ids = array_column($filetypes, "id");
  267. if ($params["study_abroad"] == 1) {
  268. //选中留学,如果存在留学附件变成必传
  269. $ft_ids = array_unique(array_merge($ft_ids, (array) $abroad_file_ids));
  270. } else {
  271. //没选中,留学附件就算设成必传也不用验证
  272. $ft_ids = array_diff($ft_ids, (array) $abroad_file_ids);
  273. }
  274. $whr = [];
  275. $whr[] = ["typeId", "in", $ft_ids];
  276. $whr[] = ["mainId", "=", $id];
  277. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
  278. $upload_type_counts = count($distinct_filetypes);
  279. if ($upload_type_counts != count($ft_ids)) {
  280. $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
  281. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  282. exit;
  283. }
  284. $this->save($info, $this->request, TalentState::SCND_SUBMIT);
  285. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
  286. $res = ["msg" => "审核不通过,不能再提交审核"];
  287. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  288. exit;
  289. }
  290. $res = ["msg" => "已提交审核,请耐心等待"];
  291. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  292. exit;
  293. }
  294. public function submitToCheck() {
  295. switch ($this->user["type"]) {
  296. case CommonConst::ENTERPRISE_NORMAL:
  297. return $this->submitToCheck_JJRC();
  298. case CommonConst::ENTERPRISE_JC:
  299. return $this->submitToCheck_IC();
  300. case CommonConst::ENTERPRISE_WJ:
  301. return $this->submitToCheck_WJ();
  302. case CommonConst::ENTERPRISE_GJ:
  303. return $this->submitToCheck_GJ();
  304. }
  305. }
  306. /**
  307. * 提交表单(新:混合基础信息人才申报信息)晋江人才
  308. */
  309. private function submitToCheck_JJRC() {
  310. $params = $this->request->param();
  311. $id = $params["id"];
  312. $info = TalentApi::chkIsOwner($id, $this->user["uid"]);
  313. if ($info) {
  314. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  315. }
  316. $checkState = $info["checkState"];
  317. if ($checkState == TalentState::SCND_SAVE || !$id) {
  318. $field_dict = \app\common\api\DictApi::getTalentFields(4, $info["isImport"]);
  319. $no_empty = ["name", "nation", "card_type", "card_number", "sex", "birthday", "politics", "nationality", "province", "city", "talent_type", "experience", "education",
  320. "talent_arrange", "talent_condition", "identifyGetTime", "bank", "bank_number", "bank_branch_name",
  321. "bank_account", "study_abroad", "phone", "email", "import_way", "cur_entry_time", "cur_entry_time", "position", "source"]; //"highest_degree", "graduate_school", "major",
  322. $where = [];
  323. $where[] = ["rel", "=", "study_abroad"];
  324. $where[] = ["project", "=", 1];
  325. $where[] = ["active", "=", 1];
  326. $where[] = ["delete", "=", 0];
  327. $where[] = ["type", "=", $this->user["type"]];
  328. $where[] = ["isConditionFile", "<>", 1];
  329. $abroad_files = Db::table("new_common_filetype")->where($where)->select()->toArray(); //留学的附件
  330. $abroad_file_ids = null;
  331. if ($abroad_files)
  332. $abroad_file_ids = array_column($abroad_files, "id");
  333. if (in_array($params["talent_type"], [1, 2])) {
  334. $no_empty[] = "tax_insurance_month";
  335. $no_empty[] = "labor_contract_rangetime";
  336. }
  337. if ($params["talent_type"] == 3) {
  338. $no_empty[] = "pre_import_type";
  339. }
  340. if ($params["study_abroad"] == 1) {
  341. $no_empty[] = "abroad_school";
  342. $no_empty[] = "abroad_major";
  343. }
  344. if (in_array($params["source"], [1, 3])) {
  345. //$no_empty[] = "source_batch";
  346. //$no_empty[] = "fujian_highcert_pubtime";
  347. //$no_empty[] = "fujian_highcert_exptime";
  348. if ($params["source"] == 3) {
  349. $no_empty[] = "source_city";
  350. }
  351. }
  352. if (in_array($params["source"], [2, 4])) {
  353. //$no_empty[] = "source_batch";
  354. //$no_empty[] = "quanzhou_highcert_pubtime";
  355. //$no_empty[] = "quanzhou_highcert_exptime";
  356. if ($params["source"] == 4) {
  357. $no_empty[] = "source_county";
  358. }
  359. }
  360. $condition_info = Db::table("new_talent_condition")->findOrEmpty($params["talent_condition"]);
  361. if ($condition_info["isSalary"] == 1) {
  362. $no_empty[] = "annual_salary";
  363. }
  364. $no_empty = array_filter($no_empty);
  365. $return = [];
  366. foreach ($no_empty as $key) {
  367. if (!$params[$key]) {
  368. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  369. }
  370. }
  371. if (count($return) > 0) {
  372. $res = ["msg" => implode("<br>", $return)];
  373. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  374. exit;
  375. }
  376. $isMatchZhiren = $info["isImport"] && $params["isMatchZhiren"] == 1 ? true : false;
  377. if ($condition_info["bindFileTypes"] && in_array($info["source"], [3, 4, 5]) && !$isMatchZhiren) {
  378. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  379. $whr[] = ["must", "=", 1];
  380. }
  381. $where = [];
  382. $where[] = ["project", "=", 1];
  383. $where[] = ["type", "=", $this->user["type"]];
  384. $where[] = ["must", "=", 1];
  385. $where[] = ["active", "=", 1];
  386. $where[] = ["delete", "=", 0];
  387. $where[] = ["isConditionFile", "<>", 1];
  388. if ($whr) {
  389. $filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
  390. } else {
  391. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  392. }
  393. $age = 0;
  394. if ($params["birthday"]) {
  395. $birthtime = strtotime($params["birthday"]);
  396. $currentYear = date("Y");
  397. $currentMonth = date("n");
  398. $birthdayYear = date("Y", $birthtime);
  399. $birthdayMonth = date("n", $birthtime);
  400. $age = ($currentYear * 12 + $currentMonth - $birthdayYear * 12 - $birthdayMonth) / 12;
  401. }
  402. $ft_ids = [];
  403. $deletes = [];
  404. foreach ($filetypes as $ft) {
  405. if ($ft["option"]) {
  406. if ($ft["rel"] == "birthday") {
  407. if ($age < $ft["option"]) {
  408. $deletes[] = $ft["id"];
  409. continue;
  410. }
  411. } else {
  412. $selectVal = $params[$ft["rel"]];
  413. $conditions = array_filter(explode(",", $ft["option"]));
  414. if (!in_array($selectVal, $conditions)) {
  415. $deletes[] = $ft["id"];
  416. continue;
  417. }
  418. }
  419. }
  420. $ft_ids[] = $ft["id"];
  421. }
  422. if ($params["study_abroad"] == 1) {
  423. //选中留学,如果存在留学附件变成必传
  424. $ft_ids = array_unique(array_merge($ft_ids, (array) $abroad_file_ids));
  425. } else {
  426. //没选中,留学附件就算设成必传也不用验证
  427. $ft_ids = array_diff($ft_ids, (array) $abroad_file_ids);
  428. }
  429. $whr = [];
  430. if ($id) {
  431. $whr[] = ["mainId", "=", $id];
  432. } else {
  433. if ($params["uploadFiles"])
  434. $whr[] = ["id", "in", $params["uploadFiles"]];
  435. }
  436. $whr[] = ["typeId", "in", $ft_ids];
  437. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
  438. $upload_type_counts = count($distinct_filetypes);
  439. if ($upload_type_counts != count($ft_ids)) {
  440. $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
  441. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  442. exit;
  443. }
  444. return $this->mixSave($info, $this->request, TalentState::SCND_SUBMIT);
  445. } 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])) {
  446. $res = ["msg" => "审核不通过,不能再提交审核"];
  447. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  448. exit;
  449. }
  450. $res = ["msg" => "已提交审核,请耐心等待"];
  451. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  452. exit;
  453. }
  454. /**
  455. * 提交表单(新:混合基础信息人才申报信息)晋江电路
  456. */
  457. private function submitToCheck_IC() {
  458. $params = $this->request->param();
  459. $id = $params["id"];
  460. if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
  461. return json(["msg" => "没有对应的人才认定申报信息"]);
  462. }
  463. if ($info) {
  464. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  465. }
  466. $checkState = $info["checkState"];
  467. if ($checkState == TalentState::SCND_SAVE) {
  468. $field_dict = \app\common\api\DictApi::getTalentFields_IC();
  469. $no_empty = ["name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "nation", "politics", "break_faith",
  470. "phone", "email", "highest_degree", "graduate_school", "major", "study_abroad", "position", "cur_entry_time", "labor_contract_rangetime",
  471. "talent_arrange", "talent_condition", "identifyConditionName", "identifyGetTime",
  472. "bank", "bank_branch_name", "bank_account", "experience", "education"];
  473. $no_empty = array_filter($no_empty);
  474. $return = [];
  475. foreach ($no_empty as $key) {
  476. if (!$info[$key]) {
  477. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  478. }
  479. }
  480. if (count($return) > 0) {
  481. return json(["msg" => implode("<br>", $return)]);
  482. }
  483. $where = [];
  484. $where[] = ["project", "=", 1];
  485. $where[] = ["type", "=", $this->user["type"]];
  486. $where[] = ["must", "=", 1];
  487. $where[] = ["active", "=", 1];
  488. $where[] = ["delete", "=", 0];
  489. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  490. $ft_ids = array_column($filetypes, "id");
  491. $whr = [];
  492. $whr[] = ["typeId", "in", $ft_ids];
  493. $whr[] = ["mainId", "=", $id];
  494. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select()->toArray();
  495. $upload_type_counts = count($distinct_filetypes);
  496. if ($upload_type_counts != count($ft_ids)) {
  497. return json(["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"]);
  498. }
  499. return $this->icSave($info, $this->request, TalentState::SCND_SUBMIT);
  500. } 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])) {
  501. return json(["msg" => "审核不通过,不能再提交审核", "code" => 500]);
  502. }
  503. return json(["msg" => "已提交审核,请耐心等待", "code" => 500]);
  504. }
  505. /**
  506. * 提交表单:卫健
  507. */
  508. private function submitToCheck_WJ() {
  509. $params = $this->request->param();
  510. $id = $params["id"];
  511. if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
  512. return json(["msg" => "没有对应的人才认定申报信息"]);
  513. }
  514. if ($info) {
  515. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  516. }
  517. $checkState = $info["checkState"];
  518. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::FST_SAVE) {
  519. $field_dict = \app\common\api\DictApi::getTalentFields_WJ();
  520. $no_empty = ["name", "sex", "nation", "politics", "card_type", "card_number", "birthday", "talent_type",
  521. "highest_degree", "graduate_school", "major", "position", "cur_entry_time", "labor_contract_rangetime",
  522. "talent_arrange", "talent_condition",
  523. "bank", "bank_account", "bank_number", "bank_branch_name"];
  524. $no_empty = array_filter($no_empty);
  525. $return = [];
  526. foreach ($no_empty as $key) {
  527. if (!$info[$key]) {
  528. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  529. }
  530. }
  531. if (count($return) > 0) {
  532. return json(["msg" => implode("<br>", $return)]);
  533. }
  534. $condition_info = Db::table("new_talent_condition")->findOrEmpty($params["talent_condition"]);
  535. if ($condition_info["bindFileTypes"]) {
  536. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  537. $whr[] = ["must", "=", 1];
  538. }
  539. $where = [];
  540. $where[] = ["project", "=", ProjectState::TALENT];
  541. $where[] = ["type", "=", $this->user["type"]];
  542. $where[] = ["must", "=", 1];
  543. $where[] = ["active", "=", 1];
  544. $where[] = ["delete", "=", 0];
  545. $where[] = ["isConditionFile", "<>", 1];
  546. if ($whr) {
  547. $filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
  548. } else {
  549. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  550. }
  551. $ft_ids = array_column($filetypes, "id");
  552. $whr = [];
  553. $whr[] = ["typeId", "in", $ft_ids];
  554. $whr[] = ["mainId", "=", $id];
  555. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select()->toArray();
  556. $upload_type_counts = count($distinct_filetypes);
  557. if ($upload_type_counts != count($ft_ids)) {
  558. return json(["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"]);
  559. }
  560. if ($checkState == TalentState::FST_SAVE) {
  561. return $this->wjSave($info, $this->request, TalentState::FST_SUBMIT);
  562. } else {
  563. return $this->wjSave($info, $this->request, TalentState::SCND_SUBMIT);
  564. }
  565. } 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])) {
  566. return json(["msg" => "审核不通过,不能再提交审核", "code" => 500]);
  567. }
  568. return json(["msg" => "已提交审核,请耐心等待", "code" => 500]);
  569. }
  570. /**
  571. * 保存表单(旧第二步)
  572. * @param type $info talent_info
  573. * @param type $param request->param();
  574. */
  575. private function save($info, \think\Request $request, $checkState) {
  576. try {
  577. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  578. if ($batch["code"] != 200) {
  579. throw new ValidateException($batch["msg"]);
  580. }
  581. $param = $request->param();
  582. validate(TalentInfo::class)->check($param);
  583. $data["apply_year"] = $batch["batch"];
  584. $all_valid_keys = ["applay_year", "import_way", "cur_entry_time", "position",
  585. "source", "source_batch", "fujian_highcert_pubtime", "fujian_highcert_exptime", "quanzhou_highcert_pubtime", "quanzhou_highcert_exptime", "source_city", "source_county",
  586. "talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "professional", "bank", "bank_number", "bank_branch_name", "bank_account",
  587. "study_abroad", "abroad_school", "abroad_major", "phone", "email", "annual_salary", "pro_qua"];
  588. foreach ($all_valid_keys as $key) {
  589. $data[$key] = trim($param[$key]);
  590. }
  591. if ($data["study_abroad"] == 1) {
  592. $data["abroad_school"] = $param["abroad_school"];
  593. $data["abroad_major"] = $param["abroad_major"];
  594. } else {
  595. $data["abroad_school"] = null;
  596. $data["abroad_major"] = null;
  597. }
  598. switch ($data["source"]) {
  599. case 1:
  600. $data["source_batch"] = $param["source_batch"];
  601. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  602. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  603. $data["source_city"] = null;
  604. break;
  605. case 2:
  606. $data["source_batch"] = $param["source_batch"];
  607. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  608. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  609. $data["source_county"] = null;
  610. break;
  611. case 3:
  612. $data["source_batch"] = $param["source_batch"];
  613. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  614. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  615. $data["source_city"] = $param["source_city"];
  616. break;
  617. case 4:
  618. $data["source_batch"] = $param["source_batch"];
  619. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  620. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  621. $data["source_county"] = $param["source_county"];
  622. break;
  623. }
  624. $condition_info = Db::table("new_talent_condition")->findOrEmpty($param["talent_condition"]);
  625. if ($condition_info["isSalary"] == 1) {
  626. $data["annual_salary"] = $param["annual_salary"];
  627. } else {
  628. $data["annual_salary"] = null;
  629. }
  630. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  631. //真实状态8是驳回,需要判断什么字段可以提交
  632. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  633. $tmp_data = $data;
  634. $data = [];
  635. foreach ($modify_fields as $field) {
  636. $data[$field] = $tmp_data[$field];
  637. }
  638. }
  639. $data["checkState"] = $checkState;
  640. $data["id"] = $info["id"];
  641. $success_msg = "提交成功";
  642. $error_msg = "提交失败";
  643. if ($checkState == TalentState::SCND_SAVE) {
  644. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  645. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  646. TalentLogApi::write(1, $data["id"], $checkState, "保存认定材料未提交", 1);
  647. }
  648. TalentModel::update($data);
  649. } else if ($checkState == TalentState::SCND_SUBMIT) {
  650. $success_msg = "提交成功";
  651. $error_msg = "提交失败";
  652. $data["new_submit_time"] = date("Y-m-d H:i:s");
  653. TalentModel::update($data);
  654. TalentLogApi::write(1, $info["id"], $checkState, "确认提交审核", 1);
  655. } else {
  656. throw new ValidateException($error_msg);
  657. }
  658. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $info["id"], "checkState" => $checkState]];
  659. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  660. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  661. exit();
  662. } catch (ValidateException $e) {
  663. $res = ["msg" => $e->getMessage()];
  664. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  665. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  666. exit();
  667. }
  668. }
  669. /**
  670. * 保存表单(新:混合基础信息人才申报信息)
  671. * @param type $info talent_info
  672. * @param type $param request->param();
  673. */
  674. private function mixSave($info, \think\Request $request, $checkState) {
  675. try {
  676. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  677. if ($batch["code"] != 200) {
  678. throw new ValidateException($batch["msg"]);
  679. }
  680. $param = $request->param();
  681. validate(TalentInfo::class)->check($param);
  682. $id = $param["id"];
  683. if ($id) {
  684. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  685. throw new ValidateException("没有对应的人才认定申报信息");
  686. }
  687. }
  688. $files = $param["uploadFiles"];
  689. $data["headimgurl"] = $info["headimgurl"];
  690. if ($request->file()) {
  691. $headimg = $request->file("photo");
  692. $upload = new \app\common\api\UploadApi();
  693. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  694. if ($result->code != 200) {
  695. throw new ValidateException($result->msg);
  696. }
  697. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  698. $width = imagesx($file);
  699. $height = imagesy($file);
  700. //免冠二寸照长宽413:579
  701. if ($width * 579 != $height * 413) {
  702. @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  703. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  704. }
  705. if ($info && $info["headimgurl"]) {
  706. //如果新照片符合像素要求,则删除旧照片
  707. $old_head_url = "storage/" . $info["headimgurl"];
  708. if (file_exists($old_head_url))
  709. @unlink($old_head_url);
  710. }
  711. $data["headimgurl"] = $result->filepath;
  712. }
  713. if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
  714. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  715. $where = [];
  716. $where[] = ["project", "=", 1];
  717. $where[] = ["type", "=", $this->user["type"]];
  718. $where[] = ["must", "=", 1];
  719. $where[] = ["active", "=", 1];
  720. $where[] = ["delete", "=", 0];
  721. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  722. $age = 0;
  723. if ($param["birthday"]) {
  724. $birthday = $param["birthday"];
  725. $birthdayYear = substr($birthday, 0, 4);
  726. $currentYear = date("Y");
  727. $age = $currentYear - $birthdayYear;
  728. }
  729. $ft_ids = [];
  730. $deletes = [];
  731. foreach ($filetypes as $ft) {
  732. if ($ft["option"]) {
  733. if ($ft["rel"] == "birthday") {
  734. if ($age < $ft["option"]) {
  735. $deletes[] = $ft["id"];
  736. continue;
  737. }
  738. } else {
  739. $selectVal = $param[$ft["rel"]];
  740. $conditions = array_filter(explode(",", $ft["option"]));
  741. if (!in_array($selectVal, $conditions)) {
  742. $deletes[] = $ft["id"];
  743. continue;
  744. }
  745. }
  746. }
  747. $ft_ids[] = $ft["id"];
  748. }
  749. $data["apply_year"] = $batch["batch"];
  750. $data["isMatchZhiren"] = $param["isMatchZhiren"] ?: 0;
  751. $all_valid_keys = ["talent_type", "name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "county", "nation", "politics", "experience", "education",
  752. "import_way", "cur_entry_time", "position",
  753. "source", "source_batch", "fujian_highcert_pubtime", "fujian_highcert_exptime", "quanzhou_highcert_pubtime", "quanzhou_highcert_exptime", "source_city", "source_county",
  754. "talent_arrange", "talent_condition", "identifyGetTime", "highest_degree", "graduate_school", "major", "professional", "bank", "bank_number", "bank_branch_name", "bank_account",
  755. "study_abroad", "abroad_school", "abroad_major", "phone", "email", "annual_salary", "pro_qua"];
  756. foreach ($all_valid_keys as $key) {
  757. $data[$key] = trim($param[$key]);
  758. }
  759. $data["return"] = 0; //流出晋江满3年后又返回晋江的,只有talent_type=2时可以填写且非必填
  760. if (in_array($data["talent_type"], [1, 2])) {
  761. $data["tax_insurance_month"] = $param["tax_insurance_month"];
  762. $data["labor_contract_rangetime"] = $param["labor_contract_rangetime"];
  763. $data["salary_pay_way"] = $param["salary_pay_way"];
  764. $data["salary_pay_month"] = $param["salary_pay_month"];
  765. $data["fst_work_time"] = $param["fst_work_time"];
  766. $data['pre_import_type'] = null;
  767. if ($data["talent_type"] == 2) {
  768. $data["return"] = $param["return"];
  769. }
  770. } else {
  771. $data["tax_insurance_month"] = null;
  772. $data["labor_contract_rangetime"] = null;
  773. $data["salary_pay_way"] = null;
  774. $data["salary_pay_month"] = null;
  775. $data["fst_work_time"] = null;
  776. $data['pre_import_type'] = $param["pre_import_type"];
  777. }
  778. if ($data["study_abroad"] == 1) {
  779. $data["abroad_school"] = $param["abroad_school"];
  780. $data["abroad_major"] = $param["abroad_major"];
  781. } else {
  782. $data["abroad_school"] = null;
  783. $data["abroad_major"] = null;
  784. }
  785. switch ($data["source"]) {
  786. case 1:
  787. $data["source_batch"] = $param["source_batch"];
  788. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  789. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  790. $data["source_city"] = null;
  791. break;
  792. case 2:
  793. $data["source_batch"] = $param["source_batch"];
  794. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  795. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  796. $data["source_county"] = null;
  797. break;
  798. case 3:
  799. $data["source_batch"] = $param["source_batch"];
  800. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  801. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  802. $data["source_city"] = $param["source_city"];
  803. break;
  804. case 4:
  805. $data["source_batch"] = $param["source_batch"];
  806. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  807. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  808. $data["source_county"] = $param["source_county"];
  809. break;
  810. }
  811. $condition_info = Db::table("new_talent_condition")->findOrEmpty($param["talent_condition"]);
  812. if ($condition_info["isSalary"] == 1) {
  813. $data["annual_salary"] = $param["annual_salary"];
  814. } else {
  815. $data["annual_salary"] = null;
  816. }
  817. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  818. //真实状态11是驳回,需要判断什么字段可以提交
  819. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  820. $tmp_data = $data;
  821. $data = [];
  822. foreach ($modify_fields as $field) {
  823. $data[$field] = $tmp_data[$field];
  824. }
  825. }
  826. $data["check_companys"] = $condition_info["companyIds"];
  827. $data["checkState"] = $checkState;
  828. $data["id"] = $id;
  829. $success_msg = "提交成功";
  830. $error_msg = "提交失败";
  831. if ($checkState == TalentState::SCND_SAVE) {
  832. $success_msg = "保存成功";
  833. if ($data["id"]) {
  834. //编辑
  835. $data["updateTime"] = date("Y-m-d H:i:s");
  836. TalentModel::update($data);
  837. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  838. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  839. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  840. } else {
  841. if (!$last_log["companyId"]) {
  842. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  843. }
  844. }
  845. } else {
  846. //新增
  847. $data["enterprise_id"] = $this->user["uid"];
  848. $data["createTime"] = date("Y-m-d H:i:s");
  849. $id = TalentModel::insertGetId($data);
  850. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  851. $whr = [];
  852. $whr[] = ["fileId", "in", $files];
  853. $upd_checklog["mainId"] = $id;
  854. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  855. }
  856. } else if ($checkState == TalentState::SCND_SUBMIT) {
  857. if (!$info["first_submit_time"]) {
  858. $data["first_submit_time"] = date("Y-m-d H:i:s");
  859. } else {
  860. $data["new_submit_time"] = date("Y-m-d H:i:s");
  861. }
  862. if ($data["id"]) {
  863. $data["updateTime"] = date("Y-m-d H:i:s");
  864. TalentModel::update($data);
  865. } else {
  866. //新增
  867. $data["enterprise_id"] = $this->user["uid"];
  868. $data["createTime"] = date("Y-m-d H:i:s");
  869. $id = TalentModel::insertGetId($data);
  870. $whr = [];
  871. $whr[] = ["fileId", "in", $files];
  872. $upd_checklog["mainId"] = $id;
  873. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  874. }
  875. TalentLogApi::write(1, $id, $checkState, "确认提交审核", 1);
  876. } else {
  877. throw new ValidateException($error_msg);
  878. }
  879. if ($id) {
  880. if ($deletes) {
  881. //删除多余的附件,一般是选择人才类型留下来的
  882. $whr = [];
  883. $whr[] = ["typeId", "in", $deletes];
  884. $whr[] = ["id", "in", $files];
  885. $_wait_del_files = Db::table("new_talent_file")->where($whr)->select()->toArray();
  886. $_logfileIds[] = [];
  887. foreach ($_wait_del_files as $_del_file) {
  888. $_logfileIds[] = $_del_file["id"];
  889. @unlink("storage/" . $_del_file["url"]);
  890. }
  891. Db::table("new_talent_file")->where($whr)->delete();
  892. if ($_logfileIds) {
  893. $whr = [];
  894. $whr[] = ["fileId", "in", $_logfileIds];
  895. $_upd_checklog["description"] = "删除附件";
  896. $_upd_checklog["updateUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"] ?: $this->user["rolename"]);
  897. $_upd_checklog["updateTime"] = date("Y-m-d H:i:s");
  898. Db::table("new_talent_checklog")->where($whr)->save($_upd_checklog);
  899. }
  900. }
  901. $whr = [];
  902. $whr[] = ["id", "in", $files];
  903. Db::table("new_talent_file")->where($whr)->save(["mainId" => $id]);
  904. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  905. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  906. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  907. exit();
  908. } else {
  909. throw new ValidateException($error_msg);
  910. }
  911. } catch (ValidateException $e) {
  912. $res = ["msg" => $e->getMessage()];
  913. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  914. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  915. exit();
  916. } catch (\think\Exception $e) {
  917. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  918. $logInfo = [
  919. "enterprise_id" => $this->user["uid"],
  920. "data" => $data,
  921. "controller" => $this->request->controller(),
  922. "action" => $this->request->action(),
  923. "errCode" => $e->getCode(),
  924. "errMsg" => $e->getMessage()
  925. ];
  926. Log::write($logInfo, "error");
  927. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  928. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  929. exit();
  930. }
  931. }
  932. private function icSave($info, \think\Request $request, $checkState) {
  933. try {
  934. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  935. if ($batch["code"] != 200) {
  936. throw new ValidateException($batch["msg"]);
  937. }
  938. $param = $request->param();
  939. validate(TalentInfo::class)->check($param);
  940. $id = $param["id"];
  941. if ($id) {
  942. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  943. throw new ValidateException("没有对应的人才认定申报信息");
  944. }
  945. }
  946. $files = $param["uploadFiles"];
  947. $data["headimgurl"] = $info["headimgurl"];
  948. if ($request->file()) {
  949. $headimg = $request->file("photo");
  950. $upload = new \app\common\api\UploadApi();
  951. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  952. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  953. $width = imagesx($file);
  954. $height = imagesy($file);
  955. //免冠二寸照长宽413:579
  956. if ($width * 579 != $height * 413) {
  957. @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  958. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  959. }
  960. if ($info && $info["headimgurl"]) {
  961. //如果新照片符合像素要求,则删除旧照片
  962. $old_head_url = "storage/" . $info["headimgurl"];
  963. if (file_exists($old_head_url))
  964. @unlink($old_head_url);
  965. }
  966. $data["headimgurl"] = $result->filepath;
  967. }
  968. if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
  969. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  970. $data["apply_year"] = $batch["batch"];
  971. $all_valid_keys = ["name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "county", "nation", "politics", "experience", "education", "break_faith",
  972. "phone", "email", "highest_degree", "graduate_school", "major", "study_abroad",
  973. "position", "cur_entry_time", "labor_contract_rangetime",
  974. "talent_arrange", "talent_condition", "identifyConditionName", "identifyGetTime", "title", "pro_qua",
  975. "bank", "bank_branch_name", "bank_account", "description"];
  976. foreach ($all_valid_keys as $key) {
  977. $value = trim($param[$key]);
  978. if ($value) {
  979. $data[$key] = $value;
  980. }
  981. }
  982. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  983. //真实状态11是驳回,需要判断什么字段可以提交
  984. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  985. $tmp_data = $data;
  986. $data = [];
  987. foreach ($modify_fields as $field) {
  988. $data[$field] = $tmp_data[$field];
  989. }
  990. }
  991. $data["checkState"] = $checkState;
  992. $data["id"] = $id;
  993. $success_msg = "提交成功";
  994. $error_msg = "提交失败";
  995. if ($checkState == TalentState::SCND_SAVE) {
  996. $success_msg = "保存成功";
  997. if ($data["id"]) {
  998. //编辑
  999. $data["updateTime"] = date("Y-m-d H:i:s");
  1000. TalentModel::update($data);
  1001. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  1002. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  1003. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  1004. } else {
  1005. if (!$last_log["companyId"]) {
  1006. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  1007. }
  1008. }
  1009. } else {
  1010. //新增
  1011. $data["enterprise_id"] = $this->user["uid"];
  1012. $data["createTime"] = date("Y-m-d H:i:s");
  1013. $id = TalentModel::insertGetId($data);
  1014. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  1015. $whr = [];
  1016. $whr[] = ["fileId", "in", $files];
  1017. $upd_checklog["mainId"] = $id;
  1018. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  1019. }
  1020. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1021. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1022. exit();
  1023. } else if ($checkState == TalentState::SCND_SUBMIT) {
  1024. $data["new_submit_time"] = date("Y-m-d H:i:s");
  1025. $data["updateTime"] = date("Y-m-d H:i:s");
  1026. TalentModel::update($data);
  1027. TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
  1028. return json(["msg" => $success_msg, "code" => 200]);
  1029. } else {
  1030. throw new ValidateException($error_msg);
  1031. }
  1032. } catch (ValidateException $e) {
  1033. if ($checkState == TalentState::SCND_SAVE) {
  1034. $res = ["msg" => $e->getMessage()];
  1035. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1036. exit();
  1037. } else {
  1038. return json(["msg" => $e->getMessage()]);
  1039. }
  1040. } catch (\think\Exception $e) {
  1041. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  1042. $logInfo = [
  1043. "enterprise_id" => $this->user["uid"],
  1044. "data" => $data,
  1045. "controller" => $this->request->controller(),
  1046. "action" => $this->request->action(),
  1047. "errCode" => $e->getCode(),
  1048. "errMsg" => $e->getMessage()
  1049. ];
  1050. Log::write($logInfo, "error");
  1051. if ($checkState == TalentState::SCND_SAVE) {
  1052. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1053. exit();
  1054. } else {
  1055. return json($res);
  1056. }
  1057. }
  1058. }
  1059. /**
  1060. * 卫健保存
  1061. * @param type $info
  1062. * @param \think\Request $request
  1063. * @param type $checkState
  1064. * @return type
  1065. * @throws ValidateException
  1066. */
  1067. private function wjSave($info, \think\Request $request, $checkState) {
  1068. try {
  1069. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  1070. if ($batch["code"] != 200) {
  1071. throw new ValidateException($batch["msg"]);
  1072. }
  1073. $param = $request->param();
  1074. validate(TalentInfo::class)->check($param);
  1075. $id = $param["id"];
  1076. if ($id) {
  1077. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  1078. throw new ValidateException("没有对应的人才认定申报信息");
  1079. }
  1080. }
  1081. $files = $param["uploadFiles"];
  1082. $data["headimgurl"] = $info["headimgurl"];
  1083. if ($request->file()) {
  1084. $headimg = $request->file("photo");
  1085. $upload = new \app\common\api\UploadApi();
  1086. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  1087. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  1088. $width = imagesx($file);
  1089. $height = imagesy($file);
  1090. //免冠二寸照长宽413:579
  1091. if ($width * 579 != $height * 413) {
  1092. @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  1093. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1094. }
  1095. if ($info && $info["headimgurl"]) {
  1096. //如果新照片符合像素要求,则删除旧照片
  1097. $old_head_url = "storage/" . $info["headimgurl"];
  1098. if (file_exists($old_head_url))
  1099. @unlink($old_head_url);
  1100. }
  1101. $data["headimgurl"] = $result->filepath;
  1102. }
  1103. if (!$data["headimgurl"] && ($checkState == TalentState::SCND_SUBMIT || $checkState == TalentState::FST_SUBMIT))
  1104. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1105. $data["apply_year"] = $batch["batch"];
  1106. $all_valid_keys = ["name", "sex", "nation", "politics", "card_type", "card_number", "birthday", "talent_type",
  1107. "highest_degree", "graduate_school", "major", "study_abroad", "abroad_school", "abroad_major",
  1108. "position", "cur_entry_time", "labor_contract_rangetime", "title",
  1109. "talent_arrange", "talent_condition",
  1110. "phone", "email", "bank", "bank_account", "bank_number", "bank_branch_name", "experience", "education"];
  1111. foreach ($all_valid_keys as $key) {
  1112. $value = trim($param[$key]);
  1113. if ($value) {
  1114. $data[$key] = $value;
  1115. }
  1116. }
  1117. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT || $info["real_state"] == TalentState::BASE_REJECT) {
  1118. //真实状态11是驳回,需要判断什么字段可以提交
  1119. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  1120. $tmp_data = $data;
  1121. $data = [];
  1122. foreach ($modify_fields as $field) {
  1123. $data[$field] = $tmp_data[$field];
  1124. }
  1125. }
  1126. $data["checkState"] = $checkState;
  1127. $data["id"] = $id;
  1128. $success_msg = "提交成功";
  1129. $error_msg = "提交失败";
  1130. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::FST_SAVE) {
  1131. $success_msg = "保存成功";
  1132. if ($data["id"]) {
  1133. //编辑
  1134. $data["updateTime"] = date("Y-m-d H:i:s");
  1135. TalentModel::update($data);
  1136. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  1137. if ($last_log["new_state"] != TalentState::SCND_SAVE || $last_log["new_state"] != TalentState::FST_SAVE) {
  1138. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  1139. } else {
  1140. if (!$last_log["companyId"]) {
  1141. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  1142. }
  1143. }
  1144. } else {
  1145. //新增
  1146. $data["enterprise_id"] = $this->user["uid"];
  1147. $data["createTime"] = date("Y-m-d H:i:s");
  1148. $id = TalentModel::insertGetId($data);
  1149. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  1150. $whr = [];
  1151. $whr[] = ["fileId", "in", $files];
  1152. $upd_checklog["mainId"] = $id;
  1153. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  1154. }
  1155. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1156. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1157. exit();
  1158. } else if ($checkState == TalentState::SCND_SUBMIT || $checkState == TalentState::FST_SUBMIT) {
  1159. $data["new_submit_time"] = date("Y-m-d H:i:s");
  1160. $data["updateTime"] = date("Y-m-d H:i:s");
  1161. TalentModel::update($data);
  1162. TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
  1163. return json(["msg" => $success_msg, "code" => 200]);
  1164. } else {
  1165. throw new ValidateException($error_msg);
  1166. }
  1167. } catch (ValidateException $e) {
  1168. if ($checkState == TalentState::SCND_SAVE) {
  1169. $res = ["msg" => $e->getMessage()];
  1170. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1171. exit();
  1172. } else {
  1173. return json(["msg" => $e->getMessage()]);
  1174. }
  1175. } catch (\think\Exception $e) {
  1176. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  1177. $logInfo = [
  1178. "enterprise_id" => $this->user["uid"],
  1179. "data" => $data,
  1180. "controller" => $this->request->controller(),
  1181. "action" => $this->request->action(),
  1182. "errCode" => $e->getCode(),
  1183. "errMsg" => $e->getMessage()
  1184. ];
  1185. Log::write($logInfo, "error");
  1186. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::FST_SAVE) {
  1187. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1188. exit();
  1189. } else {
  1190. return json($res);
  1191. }
  1192. }
  1193. }
  1194. public function delete() {
  1195. $id = $this->request->param("talentInfoId");
  1196. $info = Talent::chkIsOwner($id, $this->user["uid"]);
  1197. if (!$info) {
  1198. return json(["msg" => "操作失败"]);
  1199. }
  1200. $checkState = $info["checkState"];
  1201. if (in_array($checkState, [0, 1])) {
  1202. $log = TalentLogApi::getLastLog($id, 1);
  1203. if ($log["state"] > 1) {
  1204. //有提交审核记录
  1205. return json(["msg" => "该申报已提交审核,无法删除"]);
  1206. }
  1207. }
  1208. $data["id"] = $id;
  1209. $data["updateTime"] = date("Y-m-d H:i:s");
  1210. $data["delete"] = 1;
  1211. TalentModel::update($data);
  1212. return json(["msg" => "删除成功"]);
  1213. }
  1214. public function detail() {
  1215. $id = $this->request->param("id");
  1216. $info = $this->getInfoById($id);
  1217. return json($info);
  1218. }
  1219. public function getInfoById($id) {
  1220. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  1221. if ($info["enterprise_id"] != $this->user["uid"]) {
  1222. return [];
  1223. }
  1224. return $info;
  1225. }
  1226. public function findTalentInfoInLibrary() {
  1227. $where = [];
  1228. $sList = [];
  1229. $type = $this->request->param('type');
  1230. if ($type == ProjectState::QUIT) {
  1231. $_where = [];
  1232. $_where[] = ["checkState", "not in", [3]];
  1233. $talentIds = Db::table("un_talent_quit")->where($_where)->column("talentId");
  1234. $sList[] = array_merge($sList, (array) $talentIds);
  1235. $where[] = ["active", "=", 1];
  1236. }
  1237. if ($type == ProjectState::BANKCHANGE) {
  1238. $_where = [];
  1239. $_where[] = ["checkState", "not in", [3]];
  1240. $talentIds = Db::table("un_talent_bank_change")->where($_where)->column("talentId");
  1241. $sList[] = array_merge($sList, (array) $talentIds);
  1242. }
  1243. if ($type == ProjectState::LEVELCHANGE) {
  1244. $_where = [];
  1245. $_where[] = ["checkState", "not in", [35, -1]];
  1246. $_where[] = ["isPublic", "<", 5];
  1247. $talentIds = Db::table("un_talent_type_change")->where($_where)->column("talentId");
  1248. $sList[] = array_merge($sList, (array) $talentIds);
  1249. }
  1250. $where[] = ["enterprise_id", "=", $this->user["uid"]];
  1251. $where[] = ["checkState", "=", TalentState::CERTIFICATED];
  1252. $where[] = ["isEffect", "<>", 4];
  1253. if ($sList) {
  1254. $where[] = ["id", "not in", $sList];
  1255. }
  1256. return TalentModel::where($where)->field("id,name")->select()->toArray();
  1257. }
  1258. // public function mixDelete() {
  1259. // $id = $this->request->param("talentInfoId");
  1260. // $info = TalentApi::chkIsOwner($id, $this->user["uid"]);
  1261. // if (!$info) {
  1262. // return json(["msg" => "操作失败"]);
  1263. // }
  1264. // $checkState = $info["checkState"];
  1265. // if (in_array($checkState, [0, TalentState::SCND_SAVE])) {
  1266. // $data["id"] = $id;
  1267. // $data["delete"] = 1;
  1268. // TalentModel::update($data);
  1269. // return json(["msg" => "删除成功"]);
  1270. // }
  1271. // return json(["msg" => "该申报已提交审核,无法删除"]);
  1272. // }
  1273. }