Talent.php 88 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846
  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. switch ($this->user["type"]) {
  32. case CommonConst::ENTERPRISE_WJ:
  33. $tpl = "/talent/hospital/index";
  34. break;
  35. }
  36. return view($tpl, ['type' => $this->user["type"]]);
  37. }
  38. public function list() {
  39. $step = 2;
  40. $res = TalentApi::getList($this->request, $step);
  41. return json($res);
  42. }
  43. public function zrIndex() {
  44. return view();
  45. }
  46. /**
  47. * 新人才申报企业端统一申报入口,混合基础信息及人才信息
  48. */
  49. public function apply(\think\Request $request) {
  50. $type = $this->user["type"];
  51. $tpl = "";
  52. switch ($type) {
  53. case CommonConst::ENTERPRISE_NORMAL:
  54. $tpl = "apply"; //晋江人才
  55. break;
  56. case CommonConst::ENTERPRISE_JC:
  57. $tpl = "ic_apply"; //集成电路
  58. break;
  59. case CommonConst::ENTERPRISE_WJ:
  60. $tpl = "/talent/hospital/apply"; //卫健医院
  61. break;
  62. case CommonConst::ENTERPRISE_GJ:
  63. $tpl = "/talent/school/apply"; //高教学校
  64. break;
  65. }
  66. $param = $request->param();
  67. $id = isset($param["id"]) ? $param["id"] : 0;
  68. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  69. if ($info["isImport"]) {
  70. //$tpl = "no_file_apply"; //晋江人才
  71. }
  72. $ep = EnterpriseApi::getOne($this->user["uid"]);
  73. if (!chkEnterpriseFull($ep))
  74. return;
  75. $tagList = DictApi::selectByParentCode('enterprise_tag');
  76. $streetList = DictApi::selectByParentCode('street');
  77. $industryFieldNew = DictApi::selectByParentCode('industry_field');
  78. $ep->enterpristTagName = $tagList[$ep->enterpriseTag];
  79. $ep->streetName = $streetList[$ep->street];
  80. $ep->industryFieldNewName = $industryFieldNew[$ep->industryFieldNew];
  81. if ($info) {
  82. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  83. }
  84. if ($info && in_array($info["checkState"], [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::REVERIFY_PASS, TalentState::REVERIFY_FAIL])) {
  85. return $this->view($request);
  86. exit();
  87. }
  88. if ($request->isPost()) {
  89. $checkState = $info["checkState"] ?: 0;
  90. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::FST_SAVE || $checkState == 0) {
  91. switch ($type) {
  92. case CommonConst::ENTERPRISE_NORMAL:
  93. $this->mixSave($info, $request, TalentState::SCND_SAVE);
  94. exit();
  95. break;
  96. case CommonConst::ENTERPRISE_JC:
  97. $this->icSave($info, $request, TalentState::SCND_SAVE);
  98. exit();
  99. break;
  100. case CommonConst::ENTERPRISE_WJ:
  101. if ($ep->isGeneral == 1 || ($ep->isGeneral == 2 && !\app\common\api\Nhc::hasGeneralHospital($ep->medicalCommunityId))) {
  102. $this->wjSave($info, $request, TalentState::SCND_SAVE);
  103. } else {
  104. $this->wjSave($info, $request, TalentState::FST_SAVE);
  105. }
  106. exit();
  107. break;
  108. case CommonConst::ENTERPRISE_GJ:
  109. $this->gjSave($info, $request, TalentState::SCND_SAVE);
  110. exit();
  111. break;
  112. }
  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. $checkState = $info["checkState"] ?: 0;
  123. $batch = $info["apply_year"] ?: BatchApi::getValidBatch(ProjectState::TALENT, $this->user["type"])["batch"];
  124. $info["enterprise"] = $ep;
  125. $info["talent_type_list"] = DictApi::findChildDictByCode("talent_type");
  126. if ($info["talent_condition"]) {
  127. $info["isSalary"] = \app\common\api\TalentConditionApi::getOne($info["talent_condition"])["isSalary"] ?: 0;
  128. }
  129. return view($tpl, ["year" => $batch, "checkState" => $checkState, "row" => $info]);
  130. }
  131. /**
  132. * 旧第二步
  133. * @param \think\Request $request
  134. * @return type
  135. */
  136. public function second(\think\Request $request) {
  137. if ($this->user["type"] != 1)
  138. return "此入口仅供晋江市人才申报,晋江集成电路人才请使用新统一申报入口";
  139. $params = $request->param();
  140. $id = $params["id"];
  141. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  142. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  143. if ($request->isPost()) {
  144. if (!$info || $info["enterprise_id"] != $this->user["uid"]) {
  145. $res = ["msg" => "没有对应的人才认定申报信息"];
  146. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  147. exit;
  148. }
  149. $checkState = $info["checkState"];
  150. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::BASE_REVERIFY_PASS) {
  151. $this->save($info, $request, TalentState::SCND_SAVE);
  152. exit();
  153. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
  154. $res = ["msg" => "审核不通过,不能再保存"];
  155. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  156. exit;
  157. }
  158. $res = ["msg" => "已提交审核,请耐心等待"];
  159. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  160. exit;
  161. }
  162. $enterprise_info = \app\common\model\Enterprise::find($this->user["uid"]);
  163. $info["enterprise"] = $enterprise_info;
  164. $batch = $info["apply_year"] ?: BatchApi::getValidBatch(ProjectState::TALENT, $enterprise_info["type"])["batch"];
  165. return view("second", ["year" => $batch, "row" => $info]);
  166. }
  167. public function view(\think\Request $request) {
  168. switch ($this->user["type"]) {
  169. case CommonConst::ENTERPRISE_NORMAL:
  170. $tpl = "view"; //晋江人才
  171. break;
  172. case CommonConst::ENTERPRISE_JC:
  173. $tpl = "ic_view"; //集成电路
  174. break;
  175. case CommonConst::ENTERPRISE_WJ:
  176. $tpl = "/talent/hospital/view"; //卫健医院
  177. break;
  178. case CommonConst::ENTERPRISE_GJ:
  179. $tpl = "/talent/school/view"; //高教学校
  180. break;
  181. }
  182. $id = $request->param("id");
  183. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  184. if ($info["isImport"]) {
  185. //$tpl = "no_file_view";
  186. }
  187. return view($tpl, ["row" => $info]);
  188. }
  189. /**
  190. * 提交表单(旧第二步)
  191. */
  192. public function submit() {
  193. $params = $this->request->param();
  194. $id = $params["id"];
  195. if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
  196. $res = ["msg" => "没有对应的人才认定申报信息"];
  197. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  198. exit;
  199. }
  200. if ($info) {
  201. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  202. }
  203. $checkState = $info["checkState"];
  204. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::BASE_REVERIFY_PASS) {
  205. $field_dict = \app\common\api\DictApi::getTalentFields(2);
  206. $no_empty = ["talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "bank", "bank_number", "bank_branch_name",
  207. "bank_account", "study_abroad", "phone", "email", "import_way", "cur_entry_time", "cur_entry_time", "position", "source"];
  208. $where = [];
  209. $where[] = ["rel", "=", "study_abroad"];
  210. $where[] = ["step", "=", 2];
  211. $where[] = ["project", "=", 1];
  212. $where[] = ["active", "=", 1];
  213. $where[] = ["delete", "=", 0];
  214. $where[] = ["type", "=", $this->user["type"]];
  215. $where[] = ["isConditionFile", "<>", 1];
  216. $abroad_files = Db::table("new_common_filetype")->where($where)->select()->toArray(); //留学的附件
  217. $abroad_file_ids = null;
  218. if ($abroad_files)
  219. $abroad_file_ids = array_column($abroad_files, "id");
  220. if ($params["study_abroad"] == 1) {
  221. $no_empty[] = "abroad_school";
  222. $no_empty[] = "abroad_major";
  223. }
  224. if (in_array($params["source"], [1, 3])) {
  225. $no_empty[] = "source_batch";
  226. $no_empty[] = "fujian_highcert_pubtime";
  227. $no_empty[] = "fujian_highcert_exptime";
  228. if ($params["source"] == 3) {
  229. $no_empty[] = "source_city";
  230. }
  231. }
  232. if (in_array($params["source"], [2, 4])) {
  233. $no_empty[] = "source_batch";
  234. $no_empty[] = "quanzhou_highcert_pubtime";
  235. $no_empty[] = "quanzhou_highcert_exptime";
  236. if ($params["source"] == 4) {
  237. $no_empty[] = "source_county";
  238. }
  239. }
  240. $condition_info = Db::table("new_talent_condition")->findOrEmpty($params["talent_condition"]);
  241. if ($condition_info["isSalary"] == 1) {
  242. $no_empty[] = "annual_salary";
  243. }
  244. $no_empty = array_filter($no_empty);
  245. $return = [];
  246. foreach ($no_empty as $key) {
  247. if (!$params[$key]) {
  248. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  249. }
  250. }
  251. if (count($return) > 0) {
  252. $res = ["msg" => implode("<br>", $return)];
  253. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  254. exit;
  255. }
  256. if ($condition_info["bindFileTypes"] && in_array($info["source"], [3, 4, 5])) {
  257. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  258. $whr[] = ["must", "=", 1];
  259. }
  260. $where = [];
  261. $where[] = ["step", "=", 2];
  262. $where[] = ["project", "=", 1];
  263. $where[] = ["type", "=", $this->user["type"]];
  264. $where[] = ["must", "=", 1];
  265. $where[] = ["active", "=", 1];
  266. $where[] = ["delete", "=", 0];
  267. $where[] = ["isConditionFile", "<>", 1];
  268. if ($whr) {
  269. $filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
  270. } else {
  271. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  272. }
  273. $ft_ids = array_column($filetypes, "id");
  274. if ($params["study_abroad"] == 1) {
  275. //选中留学,如果存在留学附件变成必传
  276. $ft_ids = array_unique(array_merge($ft_ids, (array) $abroad_file_ids));
  277. } else {
  278. //没选中,留学附件就算设成必传也不用验证
  279. $ft_ids = array_diff($ft_ids, (array) $abroad_file_ids);
  280. }
  281. $whr = [];
  282. $whr[] = ["typeId", "in", $ft_ids];
  283. $whr[] = ["mainId", "=", $id];
  284. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
  285. $upload_type_counts = count($distinct_filetypes);
  286. if ($upload_type_counts != count($ft_ids)) {
  287. $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
  288. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  289. exit;
  290. }
  291. $this->save($info, $this->request, TalentState::SCND_SUBMIT);
  292. } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
  293. $res = ["msg" => "审核不通过,不能再提交审核"];
  294. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  295. exit;
  296. }
  297. $res = ["msg" => "已提交审核,请耐心等待"];
  298. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  299. exit;
  300. }
  301. public function submitToCheck() {
  302. switch ($this->user["type"]) {
  303. case CommonConst::ENTERPRISE_NORMAL:
  304. return $this->submitToCheck_JJRC();
  305. case CommonConst::ENTERPRISE_JC:
  306. return $this->submitToCheck_IC();
  307. case CommonConst::ENTERPRISE_WJ:
  308. return $this->submitToCheck_WJ();
  309. case CommonConst::ENTERPRISE_GJ:
  310. return $this->submitToCheck_GJ();
  311. }
  312. }
  313. /**
  314. * 提交表单(新:混合基础信息人才申报信息)晋江人才
  315. */
  316. private function submitToCheck_JJRC() {
  317. $params = $this->request->param();
  318. $id = $params["id"];
  319. $info = TalentApi::chkIsOwner($id, $this->user["uid"]);
  320. if ($info) {
  321. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  322. }
  323. $checkState = $info["checkState"];
  324. if ($checkState == TalentState::SCND_SAVE || !$id) {
  325. $field_dict = \app\common\api\DictApi::getTalentFields(4, $info["isImport"]);
  326. $no_empty = ["name", "nation", "card_type", "card_number", "sex", "birthday", "politics", "nationality", "province", "city", "talent_type", "experience", "education",
  327. "talent_arrange", "talent_condition", "identifyGetTime", "bank", "bank_number", "bank_branch_name",
  328. "bank_account", "study_abroad", "phone", "email", "import_way", "cur_entry_time", "cur_entry_time", "position", "source"]; //"highest_degree", "graduate_school", "major",
  329. $where = [];
  330. $where[] = ["rel", "=", "study_abroad"];
  331. $where[] = ["project", "=", 1];
  332. $where[] = ["active", "=", 1];
  333. $where[] = ["delete", "=", 0];
  334. $where[] = ["type", "=", $this->user["type"]];
  335. $where[] = ["isConditionFile", "<>", 1];
  336. $abroad_files = Db::table("new_common_filetype")->where($where)->select()->toArray(); //留学的附件
  337. $abroad_file_ids = null;
  338. if ($abroad_files)
  339. $abroad_file_ids = array_column($abroad_files, "id");
  340. if (in_array($params["talent_type"], [1, 2])) {
  341. $no_empty[] = "tax_insurance_month";
  342. $no_empty[] = "labor_contract_rangetime";
  343. }
  344. if ($params["talent_type"] == 3) {
  345. $no_empty[] = "pre_import_type";
  346. }
  347. if ($params["study_abroad"] == 1) {
  348. $no_empty[] = "abroad_school";
  349. $no_empty[] = "abroad_major";
  350. }
  351. if (in_array($params["source"], [1, 3])) {
  352. //$no_empty[] = "source_batch";
  353. //$no_empty[] = "fujian_highcert_pubtime";
  354. //$no_empty[] = "fujian_highcert_exptime";
  355. if ($params["source"] == 3) {
  356. $no_empty[] = "source_city";
  357. }
  358. }
  359. if (in_array($params["source"], [2, 4])) {
  360. //$no_empty[] = "source_batch";
  361. //$no_empty[] = "quanzhou_highcert_pubtime";
  362. //$no_empty[] = "quanzhou_highcert_exptime";
  363. if ($params["source"] == 4) {
  364. $no_empty[] = "source_county";
  365. }
  366. }
  367. $condition_info = Db::table("new_talent_condition")->findOrEmpty($params["talent_condition"]);
  368. if ($condition_info["isSalary"] == 1) {
  369. $no_empty[] = "annual_salary";
  370. }
  371. $no_empty = array_filter($no_empty);
  372. $return = [];
  373. foreach ($no_empty as $key) {
  374. if (!$params[$key]) {
  375. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  376. }
  377. }
  378. if (count($return) > 0) {
  379. $res = ["msg" => implode("<br>", $return)];
  380. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  381. exit;
  382. }
  383. $isMatchZhiren = $info["isImport"] && $params["isMatchZhiren"] == 1 ? true : false;
  384. if ($condition_info["bindFileTypes"] && in_array($info["source"], [3, 4, 5]) && !$isMatchZhiren) {
  385. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  386. $whr[] = ["must", "=", 1];
  387. }
  388. $where = [];
  389. $where[] = ["project", "=", 1];
  390. $where[] = ["type", "=", $this->user["type"]];
  391. $where[] = ["must", "=", 1];
  392. $where[] = ["active", "=", 1];
  393. $where[] = ["delete", "=", 0];
  394. $where[] = ["isConditionFile", "<>", 1];
  395. if ($whr) {
  396. $filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
  397. } else {
  398. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  399. }
  400. $age = 0;
  401. if ($params["birthday"]) {
  402. $birthtime = strtotime($params["birthday"]);
  403. $currentYear = date("Y");
  404. $currentMonth = date("n");
  405. $birthdayYear = date("Y", $birthtime);
  406. $birthdayMonth = date("n", $birthtime);
  407. $age = ($currentYear * 12 + $currentMonth - $birthdayYear * 12 - $birthdayMonth) / 12;
  408. }
  409. $ft_ids = [];
  410. $deletes = [];
  411. foreach ($filetypes as $ft) {
  412. if ($ft["option"]) {
  413. if ($ft["rel"] == "birthday") {
  414. if ($age < $ft["option"]) {
  415. $deletes[] = $ft["id"];
  416. continue;
  417. }
  418. } else {
  419. $selectVal = $params[$ft["rel"]];
  420. $conditions = array_filter(explode(",", $ft["option"]));
  421. if (!in_array($selectVal, $conditions)) {
  422. $deletes[] = $ft["id"];
  423. continue;
  424. }
  425. }
  426. }
  427. $ft_ids[] = $ft["id"];
  428. }
  429. if ($params["study_abroad"] == 1) {
  430. //选中留学,如果存在留学附件变成必传
  431. $ft_ids = array_unique(array_merge($ft_ids, (array) $abroad_file_ids));
  432. } else {
  433. //没选中,留学附件就算设成必传也不用验证
  434. $ft_ids = array_diff($ft_ids, (array) $abroad_file_ids);
  435. }
  436. $whr = [];
  437. if ($id) {
  438. $whr[] = ["mainId", "=", $id];
  439. } else {
  440. if ($params["uploadFiles"])
  441. $whr[] = ["id", "in", $params["uploadFiles"]];
  442. }
  443. $whr[] = ["typeId", "in", $ft_ids];
  444. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
  445. $upload_type_counts = count($distinct_filetypes);
  446. if ($upload_type_counts != count($ft_ids)) {
  447. $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
  448. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  449. exit;
  450. }
  451. return $this->mixSave($info, $this->request, TalentState::SCND_SUBMIT);
  452. } 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])) {
  453. $res = ["msg" => "审核不通过,不能再提交审核"];
  454. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  455. exit;
  456. }
  457. $res = ["msg" => "已提交审核,请耐心等待"];
  458. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  459. exit;
  460. }
  461. /**
  462. * 提交表单(新:混合基础信息人才申报信息)晋江电路
  463. */
  464. private function submitToCheck_IC() {
  465. $params = $this->request->param();
  466. $id = $params["id"];
  467. if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
  468. return json(["msg" => "没有对应的人才认定申报信息"]);
  469. }
  470. if ($info) {
  471. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  472. }
  473. $checkState = $info["checkState"];
  474. if ($checkState == TalentState::SCND_SAVE) {
  475. $field_dict = \app\common\api\DictApi::getTalentFields_IC();
  476. $no_empty = ["name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "nation", "politics", "break_faith",
  477. "phone", "email", "highest_degree", "graduate_school", "major", "study_abroad", "position", "cur_entry_time", "labor_contract_rangetime",
  478. "talent_arrange", "talent_condition", "identifyConditionName", "identifyGetTime",
  479. "bank", "bank_branch_name", "bank_account", "experience", "education"];
  480. $no_empty = array_filter($no_empty);
  481. $return = [];
  482. foreach ($no_empty as $key) {
  483. if (!$info[$key]) {
  484. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  485. }
  486. }
  487. if (count($return) > 0) {
  488. return json(["msg" => implode("<br>", $return)]);
  489. }
  490. $where = [];
  491. $where[] = ["project", "=", 1];
  492. $where[] = ["type", "=", $this->user["type"]];
  493. $where[] = ["must", "=", 1];
  494. $where[] = ["active", "=", 1];
  495. $where[] = ["delete", "=", 0];
  496. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  497. $ft_ids = array_column($filetypes, "id");
  498. $whr = [];
  499. $whr[] = ["typeId", "in", $ft_ids];
  500. $whr[] = ["mainId", "=", $id];
  501. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select()->toArray();
  502. $upload_type_counts = count($distinct_filetypes);
  503. if ($upload_type_counts != count($ft_ids)) {
  504. return json(["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"]);
  505. }
  506. return $this->icSave($info, $this->request, TalentState::SCND_SUBMIT);
  507. } 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])) {
  508. return json(["msg" => "审核不通过,不能再提交审核", "code" => 500]);
  509. }
  510. return json(["msg" => "已提交审核,请耐心等待", "code" => 500]);
  511. }
  512. /**
  513. * 提交表单:卫健
  514. */
  515. private function submitToCheck_WJ() {
  516. $params = $this->request->param();
  517. $id = $params["id"];
  518. if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
  519. $res = ["msg" => "没有对应的人才认定申报信息"];
  520. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  521. exit;
  522. }
  523. if ($info) {
  524. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  525. }
  526. $checkState = $info["checkState"];
  527. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::FST_SAVE) {
  528. $field_dict = \app\common\api\DictApi::getTalentFields_WJ();
  529. $no_empty = ["name", "sex", "nation", "politics", "card_type", "card_number", "birthday", "talent_type",
  530. "highest_degree", "graduate_school", "major", "position", "cur_entry_time", "labor_contract_rangetime",
  531. "talent_arrange", "talent_condition",
  532. "bank", "bank_account", "bank_number", "bank_branch_name"];
  533. $no_empty = array_filter($no_empty);
  534. $return = [];
  535. foreach ($no_empty as $key) {
  536. if (!$params[$key]) {
  537. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  538. }
  539. }
  540. if (count($return) > 0) {
  541. $res = ["msg" => implode("<br>", $return)];
  542. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  543. exit;
  544. }
  545. $condition_info = Db::table("new_talent_condition")->findOrEmpty($params["talent_condition"]);
  546. if ($condition_info["bindFileTypes"]) {
  547. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  548. $whr[] = ["must", "=", 1];
  549. }
  550. $where = [];
  551. $where[] = ["project", "=", ProjectState::TALENT];
  552. $where[] = ["type", "=", $this->user["type"]];
  553. $where[] = ["must", "=", 1];
  554. $where[] = ["active", "=", 1];
  555. $where[] = ["delete", "=", 0];
  556. $where[] = ["isConditionFile", "<>", 1];
  557. if ($whr) {
  558. $filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
  559. } else {
  560. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  561. }
  562. $ft_ids = array_column($filetypes, "id");
  563. $whr = [];
  564. $whr[] = ["typeId", "in", $ft_ids];
  565. $whr[] = ["mainId", "=", $id];
  566. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select()->toArray();
  567. $upload_type_counts = count($distinct_filetypes);
  568. if ($upload_type_counts != count($ft_ids)) {
  569. $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
  570. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  571. exit;
  572. }
  573. if ($checkState == TalentState::FST_SAVE) {
  574. return $this->wjSave($info, $this->request, TalentState::FST_SUBMIT);
  575. } else {
  576. return $this->wjSave($info, $this->request, TalentState::SCND_SUBMIT);
  577. }
  578. } 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])) {
  579. $res = ["msg" => "审核不通过,不能再提交审核", "code" => 500];
  580. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  581. exit;
  582. }
  583. $res = ["msg" => "已提交审核,请耐心等待", "code" => 500];
  584. echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
  585. exit;
  586. }
  587. /**
  588. * 提交表单:高教
  589. */
  590. private function submitToCheck_GJ() {
  591. $params = $this->request->param();
  592. $id = $params["id"];
  593. if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
  594. return json(["msg" => "没有对应的人才认定申报信息"]);
  595. }
  596. if ($info) {
  597. $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
  598. }
  599. $checkState = $info["checkState"];
  600. if ($checkState == TalentState::SCND_SAVE) {
  601. $field_dict = \app\common\api\DictApi::getTalentFields_GJ();
  602. $no_empty = ["name", "nation", "card_type", "card_number", "sex", "birthday", "politics", "nationality", "province", "city", "talent_type",
  603. "position", "cur_entry_time", "labor_contract_rangetime", "highest_degree", "graduate_school", "major", "study_abroad", "phone",
  604. "talent_arrange", "talent_condition",
  605. "bank", "bank_account", "bank_number", "bank_branch_name", "experience", "education"];
  606. if ($info["study_abroad"] == 1) {
  607. $no_empty[] = "abroad_school";
  608. $no_empty[] = "abroad_major";
  609. }
  610. $no_empty = array_filter($no_empty);
  611. $return = [];
  612. foreach ($no_empty as $key) {
  613. if (!$info[$key]) {
  614. $return[] = sprintf("请填写“%s”", $field_dict[$key]);
  615. }
  616. }
  617. if (count($return) > 0) {
  618. return json(["msg" => implode("<br>", $return)]);
  619. }
  620. $condition_info = Db::table("new_talent_condition")->findOrEmpty($info["talent_condition"]);
  621. if ($condition_info["bindFileTypes"]) {
  622. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  623. $whr[] = ["must", "=", 1];
  624. }
  625. $where = [];
  626. $where[] = ["project", "=", ProjectState::TALENT];
  627. $where[] = ["type", "=", $this->user["type"]];
  628. $where[] = ["must", "=", 1];
  629. $where[] = ["active", "=", 1];
  630. $where[] = ["delete", "=", 0];
  631. $where[] = ["isConditionFile", "<>", 1];
  632. if ($whr) {
  633. $filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
  634. } else {
  635. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  636. }
  637. $ft_ids = array_column($filetypes, "id");
  638. $whr = [];
  639. $whr[] = ["typeId", "in", $ft_ids];
  640. $whr[] = ["mainId", "=", $id];
  641. $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select()->toArray();
  642. $upload_type_counts = count($distinct_filetypes);
  643. if ($upload_type_counts != count($ft_ids)) {
  644. return json(["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"]);
  645. }
  646. return $this->gjSave($info, $this->request, TalentState::SCND_SUBMIT);
  647. } 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])) {
  648. return json(["msg" => "审核不通过,不能再提交审核", "code" => 500]);
  649. }
  650. return json(["msg" => "已提交审核,请耐心等待", "code" => 500]);
  651. }
  652. /**
  653. * 保存表单(旧第二步)
  654. * @param type $info talent_info
  655. * @param type $param request->param();
  656. */
  657. private function save($info, \think\Request $request, $checkState) {
  658. try {
  659. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  660. if ($batch["code"] != 200) {
  661. throw new ValidateException($batch["msg"]);
  662. }
  663. $param = $request->param();
  664. validate(TalentInfo::class)->check($param);
  665. $data["apply_year"] = $batch["batch"];
  666. $all_valid_keys = ["applay_year", "import_way", "cur_entry_time", "position",
  667. "source", "source_batch", "fujian_highcert_pubtime", "fujian_highcert_exptime", "quanzhou_highcert_pubtime", "quanzhou_highcert_exptime", "source_city", "source_county",
  668. "talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "professional", "bank", "bank_number", "bank_branch_name", "bank_account",
  669. "study_abroad", "abroad_school", "abroad_major", "phone", "email", "annual_salary", "pro_qua"];
  670. foreach ($all_valid_keys as $key) {
  671. $data[$key] = trim($param[$key]);
  672. }
  673. if ($data["study_abroad"] == 1) {
  674. $data["abroad_school"] = $param["abroad_school"];
  675. $data["abroad_major"] = $param["abroad_major"];
  676. } else {
  677. $data["abroad_school"] = null;
  678. $data["abroad_major"] = null;
  679. }
  680. switch ($data["source"]) {
  681. case 1:
  682. $data["source_batch"] = $param["source_batch"];
  683. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  684. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  685. $data["source_city"] = null;
  686. break;
  687. case 2:
  688. $data["source_batch"] = $param["source_batch"];
  689. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  690. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  691. $data["source_county"] = null;
  692. break;
  693. case 3:
  694. $data["source_batch"] = $param["source_batch"];
  695. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  696. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  697. $data["source_city"] = $param["source_city"];
  698. break;
  699. case 4:
  700. $data["source_batch"] = $param["source_batch"];
  701. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  702. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  703. $data["source_county"] = $param["source_county"];
  704. break;
  705. }
  706. $condition_info = Db::table("new_talent_condition")->findOrEmpty($param["talent_condition"]);
  707. if ($condition_info["isSalary"] == 1) {
  708. $data["annual_salary"] = $param["annual_salary"];
  709. } else {
  710. $data["annual_salary"] = null;
  711. }
  712. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  713. //真实状态8是驳回,需要判断什么字段可以提交
  714. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  715. $tmp_data = $data;
  716. $data = [];
  717. foreach ($modify_fields as $field) {
  718. $data[$field] = $tmp_data[$field];
  719. }
  720. }
  721. $data["checkState"] = $checkState;
  722. $data["id"] = $info["id"];
  723. $success_msg = "提交成功";
  724. $error_msg = "提交失败";
  725. if ($checkState == TalentState::SCND_SAVE) {
  726. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  727. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  728. TalentLogApi::write(1, $data["id"], $checkState, "保存认定材料未提交", 1);
  729. }
  730. TalentModel::update($data);
  731. } else if ($checkState == TalentState::SCND_SUBMIT) {
  732. $success_msg = "提交成功";
  733. $error_msg = "提交失败";
  734. $data["new_submit_time"] = date("Y-m-d H:i:s");
  735. TalentModel::update($data);
  736. TalentLogApi::write(1, $info["id"], $checkState, "确认提交审核", 1);
  737. } else {
  738. throw new ValidateException($error_msg);
  739. }
  740. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $info["id"], "checkState" => $checkState]];
  741. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  742. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  743. exit();
  744. } catch (ValidateException $e) {
  745. $res = ["msg" => $e->getMessage()];
  746. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  747. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  748. exit();
  749. }
  750. }
  751. /**
  752. * 保存表单(新:混合基础信息人才申报信息)
  753. * @param type $info talent_info
  754. * @param type $param request->param();
  755. */
  756. private function mixSave($info, \think\Request $request, $checkState) {
  757. try {
  758. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  759. if ($batch["code"] != 200) {
  760. throw new ValidateException($batch["msg"]);
  761. }
  762. $param = $request->param();
  763. validate(TalentInfo::class)->check($param);
  764. $id = $param["id"];
  765. if ($id) {
  766. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  767. throw new ValidateException("没有对应的人才认定申报信息");
  768. }
  769. }
  770. $files = $param["uploadFiles"];
  771. $data["headimgurl"] = $info["headimgurl"];
  772. if ($request->file()) {
  773. $headimg = $request->file("photo");
  774. $upload = new \app\common\api\UploadApi();
  775. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  776. if ($result->code != 200) {
  777. throw new ValidateException($result->msg);
  778. }
  779. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  780. $width = imagesx($file);
  781. $height = imagesy($file);
  782. //免冠二寸照长宽413:579
  783. if ($width * 579 != $height * 413) {
  784. @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  785. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  786. }
  787. if ($info && $info["headimgurl"]) {
  788. //如果新照片符合像素要求,则删除旧照片
  789. $old_head_url = "storage/" . $info["headimgurl"];
  790. if (file_exists($old_head_url))
  791. @unlink($old_head_url);
  792. }
  793. $data["headimgurl"] = $result->filepath;
  794. }
  795. if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
  796. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  797. $where = [];
  798. $where[] = ["project", "=", 1];
  799. $where[] = ["type", "=", $this->user["type"]];
  800. $where[] = ["must", "=", 1];
  801. $where[] = ["active", "=", 1];
  802. $where[] = ["delete", "=", 0];
  803. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  804. $age = 0;
  805. if ($param["birthday"]) {
  806. $birthday = $param["birthday"];
  807. $birthdayYear = substr($birthday, 0, 4);
  808. $currentYear = date("Y");
  809. $age = $currentYear - $birthdayYear;
  810. }
  811. $ft_ids = [];
  812. $deletes = [];
  813. foreach ($filetypes as $ft) {
  814. if ($ft["option"]) {
  815. if ($ft["rel"] == "birthday") {
  816. if ($age < $ft["option"]) {
  817. $deletes[] = $ft["id"];
  818. continue;
  819. }
  820. } else {
  821. $selectVal = $param[$ft["rel"]];
  822. $conditions = array_filter(explode(",", $ft["option"]));
  823. if (!in_array($selectVal, $conditions)) {
  824. $deletes[] = $ft["id"];
  825. continue;
  826. }
  827. }
  828. }
  829. $ft_ids[] = $ft["id"];
  830. }
  831. $data["apply_year"] = $batch["batch"];
  832. $data["isMatchZhiren"] = $param["isMatchZhiren"] ?: 0;
  833. $all_valid_keys = ["talent_type", "name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "county", "nation", "politics", "experience", "education",
  834. "import_way", "cur_entry_time", "position",
  835. "source", "source_batch", "fujian_highcert_pubtime", "fujian_highcert_exptime", "quanzhou_highcert_pubtime", "quanzhou_highcert_exptime", "source_city", "source_county",
  836. "talent_arrange", "talent_condition", "identifyGetTime", "highest_degree", "graduate_school", "major", "professional", "bank", "bank_number", "bank_branch_name", "bank_account",
  837. "study_abroad", "abroad_school", "abroad_major", "phone", "email", "annual_salary", "pro_qua"];
  838. foreach ($all_valid_keys as $key) {
  839. $data[$key] = trim($param[$key]);
  840. }
  841. $data["return"] = 0; //流出晋江满3年后又返回晋江的,只有talent_type=2时可以填写且非必填
  842. if (in_array($data["talent_type"], [1, 2])) {
  843. $data["tax_insurance_month"] = $param["tax_insurance_month"];
  844. $data["labor_contract_rangetime"] = $param["labor_contract_rangetime"];
  845. $data["salary_pay_way"] = $param["salary_pay_way"];
  846. $data["salary_pay_month"] = $param["salary_pay_month"];
  847. $data["fst_work_time"] = $param["fst_work_time"];
  848. $data['pre_import_type'] = null;
  849. if ($data["talent_type"] == 2) {
  850. $data["return"] = $param["return"];
  851. }
  852. } else {
  853. $data["tax_insurance_month"] = null;
  854. $data["labor_contract_rangetime"] = null;
  855. $data["salary_pay_way"] = null;
  856. $data["salary_pay_month"] = null;
  857. $data["fst_work_time"] = null;
  858. $data['pre_import_type'] = $param["pre_import_type"];
  859. }
  860. if ($data["study_abroad"] == 1) {
  861. $data["abroad_school"] = $param["abroad_school"];
  862. $data["abroad_major"] = $param["abroad_major"];
  863. } else {
  864. $data["abroad_school"] = null;
  865. $data["abroad_major"] = null;
  866. }
  867. switch ($data["source"]) {
  868. case 1:
  869. $data["source_batch"] = $param["source_batch"];
  870. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  871. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  872. $data["source_city"] = null;
  873. break;
  874. case 2:
  875. $data["source_batch"] = $param["source_batch"];
  876. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  877. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  878. $data["source_county"] = null;
  879. break;
  880. case 3:
  881. $data["source_batch"] = $param["source_batch"];
  882. $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
  883. $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
  884. $data["source_city"] = $param["source_city"];
  885. break;
  886. case 4:
  887. $data["source_batch"] = $param["source_batch"];
  888. $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
  889. $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
  890. $data["source_county"] = $param["source_county"];
  891. break;
  892. }
  893. $condition_info = Db::table("new_talent_condition")->findOrEmpty($param["talent_condition"]);
  894. if ($condition_info["isSalary"] == 1) {
  895. $data["annual_salary"] = $param["annual_salary"];
  896. } else {
  897. $data["annual_salary"] = null;
  898. }
  899. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  900. //真实状态11是驳回,需要判断什么字段可以提交
  901. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  902. $tmp_data = $data;
  903. $data = [];
  904. foreach ($modify_fields as $field) {
  905. $data[$field] = $tmp_data[$field];
  906. }
  907. }
  908. $data["check_companys"] = $condition_info["companyIds"];
  909. $data["checkState"] = $checkState;
  910. $data["id"] = $id;
  911. $success_msg = "提交成功";
  912. $error_msg = "提交失败";
  913. if ($checkState == TalentState::SCND_SAVE) {
  914. $success_msg = "保存成功";
  915. if ($data["id"]) {
  916. //编辑
  917. $data["updateTime"] = date("Y-m-d H:i:s");
  918. TalentModel::update($data);
  919. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  920. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  921. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  922. } else {
  923. if (!$last_log["companyId"]) {
  924. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  925. }
  926. }
  927. } else {
  928. //新增
  929. $data["enterprise_id"] = $this->user["uid"];
  930. $data["createTime"] = date("Y-m-d H:i:s");
  931. $id = TalentModel::insertGetId($data);
  932. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  933. $whr = [];
  934. $whr[] = ["fileId", "in", $files];
  935. $upd_checklog["mainId"] = $id;
  936. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  937. }
  938. } else if ($checkState == TalentState::SCND_SUBMIT) {
  939. if (!$info["first_submit_time"]) {
  940. $data["first_submit_time"] = date("Y-m-d H:i:s");
  941. } else {
  942. $data["new_submit_time"] = date("Y-m-d H:i:s");
  943. }
  944. if ($data["id"]) {
  945. $data["updateTime"] = date("Y-m-d H:i:s");
  946. TalentModel::update($data);
  947. } else {
  948. //新增
  949. $data["enterprise_id"] = $this->user["uid"];
  950. $data["createTime"] = date("Y-m-d H:i:s");
  951. $id = TalentModel::insertGetId($data);
  952. $whr = [];
  953. $whr[] = ["fileId", "in", $files];
  954. $upd_checklog["mainId"] = $id;
  955. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  956. }
  957. TalentLogApi::write(1, $id, $checkState, "确认提交审核", 1);
  958. } else {
  959. throw new ValidateException($error_msg);
  960. }
  961. if ($id) {
  962. if ($deletes) {
  963. //删除多余的附件,一般是选择人才类型留下来的
  964. $whr = [];
  965. $whr[] = ["typeId", "in", $deletes];
  966. $whr[] = ["id", "in", $files];
  967. $_wait_del_files = Db::table("new_talent_file")->where($whr)->select()->toArray();
  968. $_logfileIds[] = [];
  969. foreach ($_wait_del_files as $_del_file) {
  970. $_logfileIds[] = $_del_file["id"];
  971. @unlink("storage/" . $_del_file["url"]);
  972. }
  973. Db::table("new_talent_file")->where($whr)->delete();
  974. if ($_logfileIds) {
  975. $whr = [];
  976. $whr[] = ["fileId", "in", $_logfileIds];
  977. $_upd_checklog["description"] = "删除附件";
  978. $_upd_checklog["updateUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"] ?: $this->user["rolename"]);
  979. $_upd_checklog["updateTime"] = date("Y-m-d H:i:s");
  980. Db::table("new_talent_checklog")->where($whr)->save($_upd_checklog);
  981. }
  982. }
  983. $whr = [];
  984. $whr[] = ["id", "in", $files];
  985. Db::table("new_talent_file")->where($whr)->save(["mainId" => $id]);
  986. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  987. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  988. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  989. exit();
  990. } else {
  991. throw new ValidateException($error_msg);
  992. }
  993. } catch (ValidateException $e) {
  994. $res = ["msg" => $e->getMessage()];
  995. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  996. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  997. exit();
  998. } catch (\think\Exception $e) {
  999. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  1000. $logInfo = [
  1001. "enterprise_id" => $this->user["uid"],
  1002. "data" => $data,
  1003. "controller" => $this->request->controller(),
  1004. "action" => $this->request->action(),
  1005. "errCode" => $e->getCode(),
  1006. "errMsg" => $e->getMessage()
  1007. ];
  1008. Log::write($logInfo, "error");
  1009. $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  1010. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1011. exit();
  1012. }
  1013. }
  1014. private function icSave($info, \think\Request $request, $checkState) {
  1015. try {
  1016. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  1017. if ($batch["code"] != 200) {
  1018. throw new ValidateException($batch["msg"]);
  1019. }
  1020. $param = $request->param();
  1021. validate(TalentInfo::class)->check($param);
  1022. $id = $param["id"];
  1023. if ($id) {
  1024. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  1025. throw new ValidateException("没有对应的人才认定申报信息");
  1026. }
  1027. }
  1028. $files = $param["uploadFiles"];
  1029. $data["headimgurl"] = $info["headimgurl"];
  1030. if ($request->file()) {
  1031. $headimg = $request->file("photo");
  1032. $upload = new \app\common\api\UploadApi();
  1033. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  1034. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  1035. $width = imagesx($file);
  1036. $height = imagesy($file);
  1037. //免冠二寸照长宽413:579
  1038. if ($width * 579 != $height * 413) {
  1039. @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  1040. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1041. }
  1042. if ($info && $info["headimgurl"]) {
  1043. //如果新照片符合像素要求,则删除旧照片
  1044. $old_head_url = "storage/" . $info["headimgurl"];
  1045. if (file_exists($old_head_url))
  1046. @unlink($old_head_url);
  1047. }
  1048. $data["headimgurl"] = $result->filepath;
  1049. }
  1050. if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
  1051. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1052. $data["apply_year"] = $batch["batch"];
  1053. $all_valid_keys = ["name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "county", "nation", "politics", "experience", "education", "break_faith",
  1054. "phone", "email", "highest_degree", "graduate_school", "major", "study_abroad",
  1055. "position", "cur_entry_time", "labor_contract_rangetime",
  1056. "talent_arrange", "talent_condition", "identifyConditionName", "identifyGetTime", "title", "pro_qua",
  1057. "bank", "bank_branch_name", "bank_account", "description"];
  1058. foreach ($all_valid_keys as $key) {
  1059. $value = trim($param[$key]);
  1060. if ($value) {
  1061. $data[$key] = $value;
  1062. }
  1063. }
  1064. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  1065. //真实状态11是驳回,需要判断什么字段可以提交
  1066. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  1067. $tmp_data = $data;
  1068. $data = [];
  1069. foreach ($modify_fields as $field) {
  1070. $data[$field] = $tmp_data[$field];
  1071. }
  1072. }
  1073. $success_msg = "提交成功";
  1074. $error_msg = "提交失败";
  1075. if ($checkState == TalentState::SCND_SAVE) {
  1076. $data["checkState"] = $checkState;
  1077. $data["id"] = $id;
  1078. $success_msg = "保存成功";
  1079. if ($data["id"]) {
  1080. //编辑
  1081. $data["updateTime"] = date("Y-m-d H:i:s");
  1082. TalentModel::update($data);
  1083. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  1084. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  1085. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  1086. } else {
  1087. if (!$last_log["companyId"]) {
  1088. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  1089. }
  1090. }
  1091. } else {
  1092. //新增
  1093. $data["enterprise_id"] = $this->user["uid"];
  1094. $data["createTime"] = date("Y-m-d H:i:s");
  1095. $id = TalentModel::insertGetId($data);
  1096. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  1097. $whr = [];
  1098. $whr[] = ["fileId", "in", $files];
  1099. $upd_checklog["mainId"] = $id;
  1100. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  1101. }
  1102. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1103. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1104. exit();
  1105. } else if ($checkState == TalentState::SCND_SUBMIT) {
  1106. unset($data);
  1107. $data["checkState"] = $checkState;
  1108. $data["id"] = $id;
  1109. if (!$info["first_submit_time"]) {
  1110. $data["first_submit_time"] = date("Y-m-d H:i:s");
  1111. } else {
  1112. $data["new_submit_time"] = date("Y-m-d H:i:s");
  1113. }
  1114. $data["updateTime"] = date("Y-m-d H:i:s");
  1115. TalentModel::update($data);
  1116. TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
  1117. return json(["msg" => $success_msg, "code" => 200]);
  1118. } else {
  1119. throw new ValidateException($error_msg);
  1120. }
  1121. } catch (ValidateException $e) {
  1122. if ($checkState == TalentState::SCND_SAVE) {
  1123. $res = ["msg" => $e->getMessage()];
  1124. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1125. exit();
  1126. } else {
  1127. return json(["msg" => $e->getMessage()]);
  1128. }
  1129. } catch (\think\Exception $e) {
  1130. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  1131. $logInfo = [
  1132. "enterprise_id" => $this->user["uid"],
  1133. "data" => $data,
  1134. "controller" => $this->request->controller(),
  1135. "action" => $this->request->action(),
  1136. "errCode" => $e->getCode(),
  1137. "errMsg" => $e->getMessage()
  1138. ];
  1139. Log::write($logInfo, "error");
  1140. if ($checkState == TalentState::SCND_SAVE) {
  1141. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1142. exit();
  1143. } else {
  1144. return json($res);
  1145. }
  1146. }
  1147. }
  1148. /**
  1149. * 卫健保存
  1150. * @param type $info
  1151. * @param \think\Request $request
  1152. * @param type $checkState
  1153. * @return type
  1154. * @throws ValidateException
  1155. */
  1156. private function wjSave($info, \think\Request $request, $checkState) {
  1157. $callback = "infoCallback";
  1158. if (in_array($checkState, [TalentState::FST_SUBMIT, TalentState::SCND_SUBMIT])) {
  1159. $callback = "submitCallback";
  1160. }
  1161. try {
  1162. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  1163. if ($batch["code"] != 200) {
  1164. throw new ValidateException($batch["msg"]);
  1165. }
  1166. $param = $request->param();
  1167. $i = validate(TalentInfo::class)->check($param);
  1168. $id = $param["id"];
  1169. if ($id) {
  1170. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  1171. throw new ValidateException("没有对应的人才认定申报信息");
  1172. }
  1173. }
  1174. $files = $param["uploadFiles"];
  1175. $data["headimgurl"] = $info["headimgurl"];
  1176. if ($request->file()) {
  1177. $headimg = $request->file("photo");
  1178. $upload = new \app\common\api\UploadApi();
  1179. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  1180. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  1181. $width = imagesx($file);
  1182. $height = imagesy($file);
  1183. //免冠二寸照长宽413:579
  1184. if ($width * 579 != $height * 413) {
  1185. @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  1186. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1187. }
  1188. if ($info && $info["headimgurl"]) {
  1189. //如果新照片符合像素要求,则删除旧照片
  1190. $old_head_url = "storage/" . $info["headimgurl"];
  1191. if (file_exists($old_head_url))
  1192. @unlink($old_head_url);
  1193. }
  1194. $data["headimgurl"] = $result->filepath;
  1195. }
  1196. if (!$data["headimgurl"] && ($checkState == TalentState::SCND_SUBMIT || $checkState == TalentState::FST_SUBMIT))
  1197. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1198. $data["apply_year"] = $batch["batch"];
  1199. $all_valid_keys = ["name", "sex", "nation", "politics", "card_type", "card_number", "birthday", "talent_type",
  1200. "highest_degree", "graduate_school", "major", "study_abroad", "abroad_school", "abroad_major",
  1201. "position", "cur_entry_time", "labor_contract_rangetime", "title",
  1202. "talent_arrange", "talent_condition",
  1203. "phone", "email", "bank", "bank_account", "bank_number", "bank_branch_name", "experience", "education"];
  1204. foreach ($all_valid_keys as $key) {
  1205. $value = trim($param[$key]);
  1206. if ($value) {
  1207. $data[$key] = $value;
  1208. }
  1209. }
  1210. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT || $info["real_state"] == TalentState::BASE_REJECT) {
  1211. //真实状态11是驳回,需要判断什么字段可以提交
  1212. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  1213. $tmp_data = $data;
  1214. $data = [];
  1215. foreach ($modify_fields as $field) {
  1216. $data[$field] = $tmp_data[$field];
  1217. }
  1218. }
  1219. $data["checkState"] = $checkState;
  1220. $data["id"] = $id;
  1221. $success_msg = "提交成功";
  1222. $error_msg = "提交失败";
  1223. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::FST_SAVE) {
  1224. $success_msg = "保存成功";
  1225. if ($data["id"]) {
  1226. //编辑
  1227. $data["updateTime"] = date("Y-m-d H:i:s");
  1228. TalentModel::update($data);
  1229. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  1230. if ($last_log["new_state"] != TalentState::SCND_SAVE && $last_log["new_state"] != TalentState::FST_SAVE) {
  1231. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  1232. } else {
  1233. if (!$last_log["companyId"]) {
  1234. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  1235. }
  1236. }
  1237. } else {
  1238. //新增
  1239. $data["enterprise_id"] = $this->user["uid"];
  1240. $data["createTime"] = date("Y-m-d H:i:s");
  1241. $id = TalentModel::insertGetId($data);
  1242. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  1243. $whr = [];
  1244. $whr[] = ["fileId", "in", $files];
  1245. $upd_checklog["mainId"] = $id;
  1246. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  1247. }
  1248. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1249. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1250. exit();
  1251. } else if ($checkState == TalentState::SCND_SUBMIT || $checkState == TalentState::FST_SUBMIT) {
  1252. if (!$info["first_submit_time"]) {
  1253. $data["first_submit_time"] = date("Y-m-d H:i:s");
  1254. } else {
  1255. $data["new_submit_time"] = date("Y-m-d H:i:s");
  1256. }
  1257. $data["updateTime"] = date("Y-m-d H:i:s");
  1258. TalentModel::update($data);
  1259. TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
  1260. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1261. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1262. exit();
  1263. } else {
  1264. throw new ValidateException($error_msg);
  1265. }
  1266. } catch (ValidateException $e) {
  1267. $res = ["msg" => $e->getMessage()];
  1268. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1269. exit();
  1270. } catch (\think\Exception $e) {
  1271. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  1272. $logInfo = [
  1273. "enterprise_id" => $this->user["uid"],
  1274. "data" => $data,
  1275. "controller" => $this->request->controller(),
  1276. "action" => $this->request->action(),
  1277. "errCode" => $e->getCode(),
  1278. "errMsg" => $e->getMessage()
  1279. ];
  1280. Log::write($logInfo, "error");
  1281. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1282. exit();
  1283. }
  1284. }
  1285. private function gjSave($info, \think\Request $request, $checkState) {
  1286. try {
  1287. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  1288. if ($batch["code"] != 200) {
  1289. throw new ValidateException($batch["msg"]);
  1290. }
  1291. $param = $request->param();
  1292. validate(TalentInfo::class)->check($param);
  1293. $id = $param["id"];
  1294. if ($id) {
  1295. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  1296. throw new ValidateException("没有对应的人才认定申报信息");
  1297. }
  1298. }
  1299. $files = $param["uploadFiles"];
  1300. $data["headimgurl"] = $info["headimgurl"];
  1301. if ($request->file()) {
  1302. $headimg = $request->file("photo");
  1303. $upload = new \app\common\api\UploadApi();
  1304. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  1305. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  1306. $width = imagesx($file);
  1307. $height = imagesy($file);
  1308. //免冠二寸照长宽413:579
  1309. if ($width * 579 != $height * 413) {
  1310. @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  1311. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1312. }
  1313. if ($info && $info["headimgurl"]) {
  1314. //如果新照片符合像素要求,则删除旧照片
  1315. $old_head_url = "storage/" . $info["headimgurl"];
  1316. if (file_exists($old_head_url))
  1317. @unlink($old_head_url);
  1318. }
  1319. $data["headimgurl"] = $result->filepath;
  1320. }
  1321. if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
  1322. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1323. $data["apply_year"] = $batch["batch"];
  1324. $all_valid_keys = ["name", "nation", "card_type", "card_number", "sex", "birthday", "politics", "nationality", "province", "city", "county", "talent_type",
  1325. "position", "cur_entry_time", "labor_contract_rangetime",
  1326. "highest_degree", "graduate_school", "major", "study_abroad", "title", "pro_qua", "phone", "email",
  1327. "talent_arrange", "talent_condition",
  1328. "bank", "bank_account", "bank_number", "bank_branch_name", "experience", "education"];
  1329. foreach ($all_valid_keys as $key) {
  1330. $value = trim($param[$key]);
  1331. if ($value) {
  1332. $data[$key] = $value;
  1333. }
  1334. }
  1335. if ($data["study_abroad"] == 1) {
  1336. $data["abroad_school"] = $param["abroad_school"];
  1337. $data["abroad_major"] = $param["abroad_major"];
  1338. }
  1339. if ($data["study_abroad"] == 2) {
  1340. $data["abroad_school"] = null;
  1341. $data["abroad_major"] = null;
  1342. }
  1343. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  1344. //真实状态11是驳回,需要判断什么字段可以提交
  1345. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  1346. $tmp_data = $data;
  1347. $data = [];
  1348. foreach ($modify_fields as $field) {
  1349. $data[$field] = $tmp_data[$field];
  1350. }
  1351. }
  1352. $success_msg = "提交成功";
  1353. $error_msg = "提交失败";
  1354. if ($checkState == TalentState::SCND_SAVE) {
  1355. $data["checkState"] = $checkState;
  1356. $data["id"] = $id;
  1357. $success_msg = "保存成功";
  1358. if ($data["id"]) {
  1359. //编辑
  1360. $data["updateTime"] = date("Y-m-d H:i:s");
  1361. TalentModel::update($data);
  1362. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  1363. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  1364. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  1365. } else {
  1366. if (!$last_log["companyId"]) {
  1367. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  1368. }
  1369. }
  1370. } else {
  1371. //新增
  1372. $data["enterprise_id"] = $this->user["uid"];
  1373. $data["createTime"] = date("Y-m-d H:i:s");
  1374. $id = TalentModel::insertGetId($data);
  1375. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  1376. $whr = [];
  1377. $whr[] = ["fileId", "in", $files];
  1378. $upd_checklog["mainId"] = $id;
  1379. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  1380. }
  1381. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1382. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1383. exit();
  1384. } else if ($checkState == TalentState::SCND_SUBMIT) {
  1385. unset($data);
  1386. $data["checkState"] = $checkState;
  1387. $data["id"] = $id;
  1388. if (!$info["first_submit_time"]) {
  1389. $data["first_submit_time"] = date("Y-m-d H:i:s");
  1390. } else {
  1391. $data["new_submit_time"] = date("Y-m-d H:i:s");
  1392. }
  1393. $data["updateTime"] = date("Y-m-d H:i:s");
  1394. TalentModel::update($data);
  1395. TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
  1396. return json(["msg" => $success_msg, "code" => 200]);
  1397. } else {
  1398. throw new ValidateException($error_msg);
  1399. }
  1400. } catch (ValidateException $e) {
  1401. if ($checkState == TalentState::SCND_SAVE) {
  1402. $res = ["msg" => $e->getMessage()];
  1403. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1404. exit();
  1405. } else {
  1406. return json(["msg" => $e->getMessage()]);
  1407. }
  1408. } catch (\think\Exception $e) {
  1409. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  1410. $logInfo = [
  1411. "enterprise_id" => $this->user["uid"],
  1412. "data" => $data,
  1413. "controller" => $this->request->controller(),
  1414. "action" => $this->request->action(),
  1415. "errCode" => $e->getCode(),
  1416. "errMsg" => $e->getMessage()
  1417. ];
  1418. Log::write($logInfo, "error");
  1419. if ($checkState == TalentState::SCND_SAVE) {
  1420. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1421. exit();
  1422. } else {
  1423. return json($res);
  1424. }
  1425. }
  1426. }
  1427. public function delete() {
  1428. $id = $this->request->param("talentInfoId");
  1429. $info = Talent::chkIsOwner($id, $this->user["uid"]);
  1430. if (!$info) {
  1431. return json(["msg" => "操作失败"]);
  1432. }
  1433. $checkState = $info["checkState"];
  1434. if (in_array($checkState, [0, 1])) {
  1435. $log = TalentLogApi::getLastLog($id, 1);
  1436. if ($log["state"] > 1) {
  1437. //有提交审核记录
  1438. return json(["msg" => "该申报已提交审核,无法删除"]);
  1439. }
  1440. }
  1441. $data["id"] = $id;
  1442. $data["updateTime"] = date("Y-m-d H:i:s");
  1443. $data["delete"] = 1;
  1444. TalentModel::update($data);
  1445. return json(["msg" => "删除成功"]);
  1446. }
  1447. public function detail() {
  1448. $id = $this->request->param("id");
  1449. $info = $this->getInfoById($id);
  1450. return json($info);
  1451. }
  1452. public function getInfoById($id) {
  1453. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  1454. if ($info["enterprise_id"] != $this->user["uid"]) {
  1455. return [];
  1456. }
  1457. return $info;
  1458. }
  1459. public function findTalentInfoInLibrary() {
  1460. $where = [];
  1461. $sList = [];
  1462. $type = $this->request->param('type');
  1463. if ($type == ProjectState::QUIT) {
  1464. $_where = [];
  1465. $_where[] = ["checkState", "not in", [3]];
  1466. $idCards = Db::table("un_talent_quit")->where($_where)->column("idCard");
  1467. $sList = array_merge($sList, (array) $idCards);
  1468. $where[] = ["active", "=", 1];
  1469. }
  1470. if ($type == ProjectState::BANKCHANGE) {
  1471. $_where = [];
  1472. $_where[] = ["checkState", "not in", [3]];
  1473. $idCards = Db::table("un_talent_bank_change")->where($_where)->column("idCard");
  1474. $sList = array_merge($sList, (array) $idCards);
  1475. }
  1476. if ($type == ProjectState::LEVELCHANGE) {
  1477. $_where = [];
  1478. $_where[] = ["checkState", "not in", [35, -1]];
  1479. $_where[] = ["isPublic", "<", 5];
  1480. $idCards = Db::table("un_talent_type_change")->where($_where)->column("idCard");
  1481. $sList = array_merge($sList, (array) $idCards);
  1482. }
  1483. $where[] = ["enterprise_id", "=", $this->user["uid"]];
  1484. $where[] = ["checkState", "=", TalentState::CERTIFICATED];
  1485. $where[] = ["isEffect", "<>", 4];
  1486. if ($sList) {
  1487. $where[] = ["card_number", "not in", $sList];
  1488. }
  1489. $result = TalentModel::where($where)->field("id,name")->select()->toArray();
  1490. return json($result);
  1491. }
  1492. public function findTalentInfoByChangeId() {
  1493. $where = [];
  1494. $id = $this->request->param('id');
  1495. $type = $this->request->param('type');
  1496. if ($type == ProjectState::QUIT) {
  1497. $info = Db::table("un_talent_quit")->where("id", $id)->find();
  1498. }
  1499. if ($type == ProjectState::LEVELCHANGE) {
  1500. $info = Db::table("un_talent_type_change")->where("id", $id)->find();
  1501. }
  1502. if ($type == ProjectState::BANKCHANGE) {
  1503. $info = Db::table("un_talent_bank_change")->where("id", $id)->find();
  1504. }
  1505. if (strlen($info["talentId"]) == 19) {
  1506. $where[] = ["enterprise_id", "=", $this->user["uid"]];
  1507. $where[] = ["card_number", "=", $info["idCard"]];
  1508. $where[] = ["delete", "=", 0];
  1509. $where[] = ["checkState", "=", TalentState::CERTIFICATED];
  1510. } else {
  1511. $where[] = ["id", "=", $info["talentId"]];
  1512. }
  1513. $result = TalentModel::where($where)->field("id,name")->select()->toArray();
  1514. return json($result);
  1515. }
  1516. public function getTalentBasicById() {
  1517. $id = $this->request["id"];
  1518. $ti = \app\common\api\VerifyApi::getTalentInfoById($id);
  1519. /* if(FengStringUtil.isNotEmpAndNull(year)){
  1520. StringBuilder sb = new StringBuilder();
  1521. List<TalentAllowancecontractDetail> contractDetailList = new ArrayList<>(); //保存上一年度的工作单位
  1522. TalentAllowanceInfo info = new TalentAllowanceInfo();
  1523. info.setType(ti.getType());
  1524. info.setYear(year);
  1525. info.setFirstInJJTime(ti.getFirstInJJTime());
  1526. ApiTalentAllowanceController.getConcatList(ti,info,year,sb,contractDetailList);
  1527. int active = AllowanceSelectUtil.validMyqy(contractDetailList,ti,info);
  1528. ti.setActive(active);
  1529. } */
  1530. return $ti;
  1531. }
  1532. /**
  1533. *
  1534. */
  1535. public function getTalentInfoFromOldLibrary() {
  1536. $responseObj = new \stdClass();
  1537. $responseObj->code = 500;
  1538. $ep = EnterpriseApi::getOne($this->user["uid"]);
  1539. $pIdCard = \StrUtil::getRequestDecodeParam($this->request, "idCard");
  1540. $eIdCard = $ep->idCard;
  1541. $where = [];
  1542. $where[] = ["e.idCard", "=", $eIdCard];
  1543. $where[] = ["ti.idCard", "=", $pIdCard];
  1544. $old = Db::table("un_talent_info")->alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterpriseId")->field("ti.*")->where($where)->order("ti.createTime desc")->find();
  1545. if ($old) {
  1546. $responseObj->code = 200;
  1547. $responseObj->info = $old;
  1548. return $responseObj;
  1549. }
  1550. return $responseObj;
  1551. }
  1552. /**
  1553. * 审核列表页
  1554. */
  1555. public function examineCenter() {
  1556. $tpl = "";
  1557. switch ($this->user["type"]) {
  1558. case CommonConst::ENTERPRISE_WJ:
  1559. $tpl = "/talent/hospital/examine_center"; //卫健医院
  1560. break;
  1561. }
  1562. return view($tpl);
  1563. }
  1564. /**
  1565. * 审核列表页
  1566. */
  1567. public function examineList() {
  1568. $res = TalentApi::getHospitalExamineList($this->request);
  1569. return json($res);
  1570. }
  1571. public function examinePage() {
  1572. $id = $this->request->param("id");
  1573. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  1574. return view("/talent/hospital/view", ["row" => $info]);
  1575. }
  1576. /**
  1577. * 医院人才申报审核保存
  1578. * @return type
  1579. */
  1580. public function check() {
  1581. $request = $this->request;
  1582. $params = $request->param();
  1583. $check = $params["checkState"];
  1584. $check_msg = trim($params["checkMsg"]);
  1585. $files = $params["files"];
  1586. $fields = $params["fields"];
  1587. $id = $params["id"];
  1588. $talent_info = \app\common\api\VerifyApi::getOne($id);
  1589. if (!$talent_info) {
  1590. return json(["msg" => "数据错误"]);
  1591. }
  1592. $enterprise = EnterpriseApi::getOne($talent_info["enterprise_id"]);
  1593. $checkState = $talent_info["checkState"];
  1594. if ($this->user["isGeneral"] != 1) {
  1595. return json(["msg" => "非总院账号,无法审核"]);
  1596. }
  1597. if ($this->user["medicalCommunityId"] != $enterprise["medicalCommunityId"]) {
  1598. return json(["msg" => "不能审核其它非本医共体医院"]);
  1599. }
  1600. if (!$check) {
  1601. return json(["msg" => "请选择审核状态"]);
  1602. }
  1603. if (!$check_msg) {
  1604. return json(["msg" => "请填写审核说明"]);
  1605. }
  1606. if ($checkState == TalentState::FST_SUBMIT) {
  1607. if ($params["checkState"] == 3) {
  1608. //审核成功
  1609. $log_checkState = $checkState = TalentState::SCND_SUBMIT; //待初审
  1610. } else {
  1611. //审核驳回并记录需要修改的字段和上传文件
  1612. $checkState = TalentState::FST_SAVE; //退回材料编辑状态
  1613. $log_checkState = TalentState::BASE_REJECT; //日志记录拒绝状态
  1614. }
  1615. $log = TalentLogApi::getLastLog($id, 1);
  1616. if (!$log && !$talent_info["oldId"])
  1617. return json(["msg" => "日志数据异常,保存失败"]);
  1618. if ($log["active"] === 0) {
  1619. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  1620. } else {
  1621. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  1622. }
  1623. $data["id"] = $talent_info["id"];
  1624. $data["modify_files"] = $params["files"];
  1625. $data["modify_fields"] = $params["fields"];
  1626. TalentModel::update($data);
  1627. return json(["code" => 200, "msg" => "保存成功"]);
  1628. } else {
  1629. return json(["msg" => "不在审核范围内,保存失败"]);
  1630. }
  1631. }
  1632. /**
  1633. * 医院人才申报审核
  1634. * @return type
  1635. */
  1636. public function submitCheck() {
  1637. $id = $this->request->param("id");
  1638. $talent_info = \app\common\api\VerifyApi::getOne($id);
  1639. if (!$talent_info) {
  1640. return json(["msg" => "数据错误"]);
  1641. }
  1642. $enterprise = EnterpriseApi::getOne($talent_info["enterprise_id"]);
  1643. $checkState = $talent_info["checkState"];
  1644. if ($this->user["isGeneral"] != 1) {
  1645. return json(["msg" => "非总院账号,无法审核"]);
  1646. }
  1647. if ($this->user["medicalCommunityId"] != $enterprise["medicalCommunityId"]) {
  1648. return json(["msg" => "不能审核其它非本医共体医院"]);
  1649. }
  1650. if ($checkState == TalentState::FST_SUBMIT) {
  1651. $nowProcess = 1;
  1652. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  1653. if (!$log || $log["active"] == 1)
  1654. return json(["msg" => "请先保存审核状态,再提交审核"]);
  1655. if (in_array($log["new_state"], [TalentState::SCND_SUBMIT])) {
  1656. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  1657. }
  1658. $data["id"] = $talent_info["id"];
  1659. $data["checkState"] = $log["new_state"];
  1660. TalentModel::update($data);
  1661. TalentLogApi::setActive($log["id"], 1);
  1662. if ($log["state"] == TalentState::BASE_REJECT) {
  1663. $this->sendMsg($enterprise["id"], $log["description"]);
  1664. }
  1665. return json(["code" => 200, "msg" => "审核成功"]);
  1666. } else {
  1667. return json(["msg" => "不在审核范围内,审核失败"]);
  1668. }
  1669. }
  1670. private function sendMsg($enterprise_id, $description = "") {
  1671. $ep = EnterpriseApi::getOne($enterprise_id);
  1672. if ($ep->agentPhone) {
  1673. $smsapi = new \app\common\api\ChuanglanSmsApi();
  1674. $result = $smsapi->sendSMS($phone, $template);
  1675. $result = json_decode($result, true);
  1676. $id = getStringId();
  1677. $record_data = [
  1678. 'id' => $id,
  1679. 'userId' => $ep->id,
  1680. 'bizId' => $result["msgId"],
  1681. 'type' => 2,
  1682. 'smsType' => 2,
  1683. 'name' => $ep->name,
  1684. 'phone' => $ep->agentPhone,
  1685. 'params' => "总院审核",
  1686. 'templateCode' => "【晋江市人才服务平台】尊敬的用户,您提交的人才认定申报审核驳回,原因是:{$description},请及时登录申报系统修改并重新提交。",
  1687. 'state' => $result['code'] == 0 ? 2 : 3,
  1688. 'sendingDate' => date("Y-m-d H:i:s", time()),
  1689. 'createTime' => date("Y-m-d H:i:s", time()),
  1690. 'msg' => $result['errorMsg']
  1691. ];
  1692. \app\admin\model\MessageRecord::create($record_data);
  1693. }
  1694. }
  1695. public function validateIsCheck() {
  1696. $params = $this->request->param();
  1697. $id = $params["id"];
  1698. $talent_info = \app\common\api\VerifyApi::getTalentInfoById($id);
  1699. $enterprise = EnterpriseApi::getOne($talent_info["enterprise_id"]);
  1700. if ($talent_info) {
  1701. $checkState = $talent_info["checkState"];
  1702. if ($this->user["isGeneral"] != 1) {
  1703. return json(["msg" => "非总院账号,无法审核"]);
  1704. }
  1705. if ($this->user["medicalCommunityId"] != $enterprise["medicalCommunityId"]) {
  1706. return json(["msg" => "不能审核其它非本医共体医院"]);
  1707. }
  1708. if ($checkState != TalentState::FST_SUBMIT) {
  1709. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  1710. }
  1711. $fields = DictApi::getTalentFields_WJ();
  1712. $field_tmp = [];
  1713. if ($fields) {
  1714. foreach ($fields as $key => $field) {
  1715. $field_tmp[] = ["key" => $key, "value" => $field];
  1716. }
  1717. }
  1718. $condition = \app\common\api\TalentConditionApi::getOne($talent_info["talent_condition"]);
  1719. $where = [];
  1720. $whr = [];
  1721. $where[] = ["project", "=", 1];
  1722. $where[] = ["active", "=", 1];
  1723. $where[] = ["type", "=", $enterprise["type"]];
  1724. $where[] = ["isConditionFile", "<>", 1];
  1725. $where[] = ["delete", "=", 0];
  1726. if ($condition && $condition["bindFileTypes"]) {
  1727. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  1728. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->order("sn asc")->select();
  1729. } else {
  1730. $files = \think\facade\Db::table("new_common_filetype")->where($where)->order("sn asc")->select();
  1731. }
  1732. $talent_info["files"] = array_filter(explode(",", $talent_info["modify_files"]));
  1733. $talent_info["fields"] = array_filter(explode(",", $talent_info["modify_fields"]));
  1734. /* 保存的审核内容start */
  1735. $last_log = TalentLogApi::getLastLog($id, ProjectState::TALENT, 0, ["active", "=", 0]);
  1736. $check = ["msg" => $last_log["description"]];
  1737. if ($last_log["state"] == TalentState::BASE_VERIFY_PASS) {
  1738. $check["checkState"] = 3;
  1739. }
  1740. if ($last_log["new_state"] == TalentState::FST_SAVE && $last_log["state"] == TalentState::BASE_REJECT) {
  1741. $check["checkState"] = 2;
  1742. }
  1743. /* 保存的审核内容end */
  1744. return json(["code" => 200, "obj" => ["talentInfo" => $talent_info, "check" => $check, "fieldList" => $field_tmp, "fileList" => $files]]);
  1745. }
  1746. }
  1747. // public function mixDelete() {
  1748. // $id = $this->request->param("talentInfoId");
  1749. // $info = TalentApi::chkIsOwner($id, $this->user["uid"]);
  1750. // if (!$info) {
  1751. // return json(["msg" => "操作失败"]);
  1752. // }
  1753. // $checkState = $info["checkState"];
  1754. // if (in_array($checkState, [0, TalentState::SCND_SAVE])) {
  1755. // $data["id"] = $id;
  1756. // $data["delete"] = 1;
  1757. // TalentModel::update($data);
  1758. // return json(["msg" => "删除成功"]);
  1759. // }
  1760. // return json(["msg" => "该申报已提交审核,无法删除"]);
  1761. // }
  1762. }