Talent.php 75 KB

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