Talent.php 53 KB

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