Talent.php 94 KB

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