Talent.php 52 KB

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