Talent.php 89 KB

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