Talent.php 89 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862
  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. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  1039. $width = imagesx($file);
  1040. $height = imagesy($file);
  1041. //免冠二寸照长宽413:579
  1042. if ($width * 579 != $height * 413) {
  1043. @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  1044. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1045. }
  1046. if ($info && $info["headimgurl"]) {
  1047. //如果新照片符合像素要求,则删除旧照片
  1048. $old_head_url = "storage/" . $info["headimgurl"];
  1049. if (file_exists($old_head_url))
  1050. @unlink($old_head_url);
  1051. }
  1052. $data["headimgurl"] = $result->filepath;
  1053. }
  1054. if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
  1055. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1056. $data["apply_year"] = $batch["batch"];
  1057. $all_valid_keys = ["name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "county", "nation", "politics", "experience", "education", "break_faith",
  1058. "phone", "email", "highest_degree", "graduate_school", "major", "study_abroad",
  1059. "position", "cur_entry_time", "labor_contract_rangetime",
  1060. "talent_arrange", "talent_condition", "identifyConditionName", "identifyGetTime", "title", "pro_qua",
  1061. "bank", "bank_branch_name", "bank_account", "description"];
  1062. foreach ($all_valid_keys as $key) {
  1063. $value = trim($param[$key]);
  1064. if ($value) {
  1065. $data[$key] = $value;
  1066. }
  1067. }
  1068. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  1069. //真实状态11是驳回,需要判断什么字段可以提交
  1070. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  1071. $tmp_data = $data;
  1072. $data = [];
  1073. foreach ($modify_fields as $field) {
  1074. $data[$field] = $tmp_data[$field];
  1075. }
  1076. }
  1077. $success_msg = "提交成功";
  1078. $error_msg = "提交失败";
  1079. if ($checkState == TalentState::SCND_SAVE) {
  1080. $data["checkState"] = $checkState;
  1081. $data["id"] = $id;
  1082. $success_msg = "保存成功";
  1083. if ($data["id"]) {
  1084. //编辑
  1085. $data["updateTime"] = date("Y-m-d H:i:s");
  1086. TalentModel::update($data);
  1087. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  1088. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  1089. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  1090. } else {
  1091. if (!$last_log["companyId"]) {
  1092. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  1093. }
  1094. }
  1095. } else {
  1096. //新增
  1097. $data["enterprise_id"] = $this->user["uid"];
  1098. $data["createTime"] = date("Y-m-d H:i:s");
  1099. $id = TalentModel::insertGetId($data);
  1100. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  1101. $whr = [];
  1102. $whr[] = ["fileId", "in", $files];
  1103. $upd_checklog["mainId"] = $id;
  1104. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  1105. }
  1106. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1107. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1108. exit();
  1109. } else if ($checkState == TalentState::SCND_SUBMIT) {
  1110. unset($data);
  1111. $data["checkState"] = $checkState;
  1112. $data["id"] = $id;
  1113. if (!$info["first_submit_time"]) {
  1114. $data["first_submit_time"] = date("Y-m-d H:i:s");
  1115. } else {
  1116. $data["new_submit_time"] = date("Y-m-d H:i:s");
  1117. }
  1118. $data["updateTime"] = date("Y-m-d H:i:s");
  1119. TalentModel::update($data);
  1120. TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
  1121. return json(["msg" => $success_msg, "code" => 200]);
  1122. } else {
  1123. throw new ValidateException($error_msg);
  1124. }
  1125. } catch (ValidateException $e) {
  1126. if ($checkState == TalentState::SCND_SAVE) {
  1127. $res = ["msg" => $e->getMessage()];
  1128. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1129. exit();
  1130. } else {
  1131. return json(["msg" => $e->getMessage()]);
  1132. }
  1133. } catch (\think\Exception $e) {
  1134. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  1135. $logInfo = [
  1136. "enterprise_id" => $this->user["uid"],
  1137. "data" => $data,
  1138. "controller" => $this->request->controller(),
  1139. "action" => $this->request->action(),
  1140. "errCode" => $e->getCode(),
  1141. "errMsg" => $e->getMessage()
  1142. ];
  1143. Log::write($logInfo, "error");
  1144. if ($checkState == TalentState::SCND_SAVE) {
  1145. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1146. exit();
  1147. } else {
  1148. return json($res);
  1149. }
  1150. }
  1151. }
  1152. /**
  1153. * 卫健保存
  1154. * @param type $info
  1155. * @param \think\Request $request
  1156. * @param type $checkState
  1157. * @return type
  1158. * @throws ValidateException
  1159. */
  1160. private function wjSave($info, \think\Request $request, $checkState) {
  1161. $callback = "infoCallback";
  1162. if (in_array($checkState, [TalentState::FST_SUBMIT, TalentState::SCND_SUBMIT])) {
  1163. $callback = "submitCallback";
  1164. }
  1165. try {
  1166. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  1167. if ($batch["code"] != 200) {
  1168. throw new ValidateException($batch["msg"]);
  1169. }
  1170. $param = $request->param();
  1171. $i = validate(TalentInfo::class)->check($param);
  1172. $id = $param["id"];
  1173. if ($id) {
  1174. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  1175. throw new ValidateException("没有对应的人才认定申报信息");
  1176. }
  1177. }
  1178. $files = $param["uploadFiles"];
  1179. $data["headimgurl"] = $info["headimgurl"];
  1180. if ($request->file()) {
  1181. $headimg = $request->file("photo");
  1182. $upload = new \app\common\api\UploadApi();
  1183. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  1184. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  1185. $width = imagesx($file);
  1186. $height = imagesy($file);
  1187. //免冠二寸照长宽413:579
  1188. if ($width * 579 != $height * 413) {
  1189. @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  1190. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1191. }
  1192. if ($info && $info["headimgurl"]) {
  1193. //如果新照片符合像素要求,则删除旧照片
  1194. $old_head_url = "storage/" . $info["headimgurl"];
  1195. if (file_exists($old_head_url))
  1196. @unlink($old_head_url);
  1197. }
  1198. $data["headimgurl"] = $result->filepath;
  1199. }
  1200. if (!$data["headimgurl"] && ($checkState == TalentState::SCND_SUBMIT || $checkState == TalentState::FST_SUBMIT))
  1201. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1202. $data["apply_year"] = $batch["batch"];
  1203. $all_valid_keys = ["name", "sex", "nation", "politics", "card_type", "card_number", "birthday", "talent_type",
  1204. "highest_degree", "graduate_school", "major", "study_abroad", "abroad_school", "abroad_major",
  1205. "position", "cur_entry_time", "labor_contract_rangetime", "title", "fst_city_work_time",
  1206. "talent_arrange", "talent_condition",
  1207. "phone", "email", "bank", "bank_account", "bank_number", "bank_branch_name", "experience", "education"];
  1208. foreach ($all_valid_keys as $key) {
  1209. $value = trim($param[$key]);
  1210. if ($value) {
  1211. $data[$key] = $value;
  1212. }
  1213. }
  1214. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT || $info["real_state"] == TalentState::BASE_REJECT) {
  1215. //真实状态11是驳回,需要判断什么字段可以提交
  1216. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  1217. $tmp_data = $data;
  1218. $data = [];
  1219. foreach ($modify_fields as $field) {
  1220. $data[$field] = $tmp_data[$field];
  1221. }
  1222. }
  1223. $data["checkState"] = $checkState;
  1224. $data["id"] = $id;
  1225. $success_msg = "提交成功";
  1226. $error_msg = "提交失败";
  1227. if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::FST_SAVE) {
  1228. $success_msg = "保存成功";
  1229. if ($data["id"]) {
  1230. //编辑
  1231. $data["updateTime"] = date("Y-m-d H:i:s");
  1232. TalentModel::update($data);
  1233. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  1234. if ($last_log["new_state"] != TalentState::SCND_SAVE && $last_log["new_state"] != TalentState::FST_SAVE) {
  1235. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  1236. } else {
  1237. if (!$last_log["companyId"]) {
  1238. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  1239. }
  1240. }
  1241. } else {
  1242. //新增
  1243. $data["enterprise_id"] = $this->user["uid"];
  1244. $data["createTime"] = date("Y-m-d H:i:s");
  1245. $id = TalentModel::insertGetId($data);
  1246. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  1247. $whr = [];
  1248. $whr[] = ["fileId", "in", $files];
  1249. $upd_checklog["mainId"] = $id;
  1250. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  1251. }
  1252. //$res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1253. //echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1254. //exit();
  1255. } else if ($checkState == TalentState::SCND_SUBMIT || $checkState == TalentState::FST_SUBMIT) {
  1256. if (!$info["first_submit_time"]) {
  1257. $data["first_submit_time"] = date("Y-m-d H:i:s");
  1258. } else {
  1259. $data["new_submit_time"] = date("Y-m-d H:i:s");
  1260. }
  1261. $data["updateTime"] = date("Y-m-d H:i:s");
  1262. TalentModel::update($data);
  1263. TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
  1264. //$res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1265. //echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1266. //exit();
  1267. } else {
  1268. throw new ValidateException($error_msg);
  1269. }
  1270. if ($id) {
  1271. $whr = [];
  1272. $whr[] = ["id", "in", $files];
  1273. Db::table("new_talent_file")->where($whr)->save(["mainId" => $id]);
  1274. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1275. //$callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
  1276. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1277. exit();
  1278. } else {
  1279. throw new ValidateException($error_msg);
  1280. }
  1281. } catch (ValidateException $e) {
  1282. $res = ["msg" => $e->getMessage()];
  1283. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1284. exit();
  1285. } catch (\think\Exception $e) {
  1286. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  1287. $logInfo = [
  1288. "enterprise_id" => $this->user["uid"],
  1289. "data" => $data,
  1290. "controller" => $this->request->controller(),
  1291. "action" => $this->request->action(),
  1292. "errCode" => $e->getCode(),
  1293. "errMsg" => $e->getMessage()
  1294. ];
  1295. Log::write($logInfo, "error");
  1296. echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
  1297. exit();
  1298. }
  1299. }
  1300. private function gjSave($info, \think\Request $request, $checkState) {
  1301. try {
  1302. $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
  1303. if ($batch["code"] != 200) {
  1304. throw new ValidateException($batch["msg"]);
  1305. }
  1306. $param = $request->param();
  1307. validate(TalentInfo::class)->check($param);
  1308. $id = $param["id"];
  1309. if ($id) {
  1310. if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
  1311. throw new ValidateException("没有对应的人才认定申报信息");
  1312. }
  1313. }
  1314. $files = $param["uploadFiles"];
  1315. $data["headimgurl"] = $info["headimgurl"];
  1316. if ($request->file()) {
  1317. $headimg = $request->file("photo");
  1318. $upload = new \app\common\api\UploadApi();
  1319. $result = $upload->uploadOne($headimg, "image", "talent/photo");
  1320. $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
  1321. $width = imagesx($file);
  1322. $height = imagesy($file);
  1323. //免冠二寸照长宽413:579
  1324. if ($width * 579 != $height * 413) {
  1325. @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
  1326. throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1327. }
  1328. if ($info && $info["headimgurl"]) {
  1329. //如果新照片符合像素要求,则删除旧照片
  1330. $old_head_url = "storage/" . $info["headimgurl"];
  1331. if (file_exists($old_head_url))
  1332. @unlink($old_head_url);
  1333. }
  1334. $data["headimgurl"] = $result->filepath;
  1335. }
  1336. if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
  1337. throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
  1338. $data["apply_year"] = $batch["batch"];
  1339. $all_valid_keys = ["name", "nation", "card_type", "card_number", "sex", "birthday", "politics", "nationality", "province", "city", "county", "talent_type",
  1340. "position", "cur_entry_time", "labor_contract_rangetime",
  1341. "highest_degree", "graduate_school", "major", "study_abroad", "title", "pro_qua", "phone", "email",
  1342. "talent_arrange", "talent_condition",
  1343. "bank", "bank_account", "bank_number", "bank_branch_name", "experience", "education"];
  1344. foreach ($all_valid_keys as $key) {
  1345. $value = trim($param[$key]);
  1346. if ($value) {
  1347. $data[$key] = $value;
  1348. }
  1349. }
  1350. if ($data["study_abroad"] == 1) {
  1351. $data["abroad_school"] = $param["abroad_school"];
  1352. $data["abroad_major"] = $param["abroad_major"];
  1353. }
  1354. if ($data["study_abroad"] == 2) {
  1355. $data["abroad_school"] = null;
  1356. $data["abroad_major"] = null;
  1357. }
  1358. if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
  1359. //真实状态11是驳回,需要判断什么字段可以提交
  1360. $modify_fields = array_filter(explode(",", $info["modify_fields"]));
  1361. $tmp_data = $data;
  1362. $data = [];
  1363. foreach ($modify_fields as $field) {
  1364. $data[$field] = $tmp_data[$field];
  1365. }
  1366. }
  1367. $success_msg = "提交成功";
  1368. $error_msg = "提交失败";
  1369. if ($checkState == TalentState::SCND_SAVE) {
  1370. $data["checkState"] = $checkState;
  1371. $data["id"] = $id;
  1372. $success_msg = "保存成功";
  1373. if ($data["id"]) {
  1374. //编辑
  1375. $data["updateTime"] = date("Y-m-d H:i:s");
  1376. TalentModel::update($data);
  1377. $last_log = TalentLogApi::getLastLog($data["id"], 1);
  1378. if ($last_log["new_state"] != TalentState::SCND_SAVE) {
  1379. TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
  1380. } else {
  1381. if (!$last_log["companyId"]) {
  1382. TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
  1383. }
  1384. }
  1385. } else {
  1386. //新增
  1387. $data["enterprise_id"] = $this->user["uid"];
  1388. $data["createTime"] = date("Y-m-d H:i:s");
  1389. $id = TalentModel::insertGetId($data);
  1390. TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
  1391. $whr = [];
  1392. $whr[] = ["fileId", "in", $files];
  1393. $upd_checklog["mainId"] = $id;
  1394. Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
  1395. }
  1396. $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
  1397. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1398. exit();
  1399. } else if ($checkState == TalentState::SCND_SUBMIT) {
  1400. unset($data);
  1401. $data["checkState"] = $checkState;
  1402. $data["id"] = $id;
  1403. if (!$info["first_submit_time"]) {
  1404. $data["first_submit_time"] = date("Y-m-d H:i:s");
  1405. } else {
  1406. $data["new_submit_time"] = date("Y-m-d H:i:s");
  1407. }
  1408. $data["updateTime"] = date("Y-m-d H:i:s");
  1409. TalentModel::update($data);
  1410. TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
  1411. return json(["msg" => $success_msg, "code" => 200]);
  1412. } else {
  1413. throw new ValidateException($error_msg);
  1414. }
  1415. } catch (ValidateException $e) {
  1416. if ($checkState == TalentState::SCND_SAVE) {
  1417. $res = ["msg" => $e->getMessage()];
  1418. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1419. exit();
  1420. } else {
  1421. return json(["msg" => $e->getMessage()]);
  1422. }
  1423. } catch (\think\Exception $e) {
  1424. $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
  1425. $logInfo = [
  1426. "enterprise_id" => $this->user["uid"],
  1427. "data" => $data,
  1428. "controller" => $this->request->controller(),
  1429. "action" => $this->request->action(),
  1430. "errCode" => $e->getCode(),
  1431. "errMsg" => $e->getMessage()
  1432. ];
  1433. Log::write($logInfo, "error");
  1434. if ($checkState == TalentState::SCND_SAVE) {
  1435. echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
  1436. exit();
  1437. } else {
  1438. return json($res);
  1439. }
  1440. }
  1441. }
  1442. public function delete() {
  1443. $id = $this->request->param("talentInfoId");
  1444. $info = Talent::chkIsOwner($id, $this->user["uid"]);
  1445. if (!$info) {
  1446. return json(["msg" => "操作失败"]);
  1447. }
  1448. $checkState = $info["checkState"];
  1449. if (in_array($checkState, [0, 1])) {
  1450. $log = TalentLogApi::getLastLog($id, 1);
  1451. if ($log["state"] > 1) {
  1452. //有提交审核记录
  1453. return json(["msg" => "该申报已提交审核,无法删除"]);
  1454. }
  1455. }
  1456. $data["id"] = $id;
  1457. $data["updateTime"] = date("Y-m-d H:i:s");
  1458. $data["delete"] = 1;
  1459. TalentModel::update($data);
  1460. return json(["msg" => "删除成功"]);
  1461. }
  1462. public function detail() {
  1463. $id = $this->request->param("id");
  1464. $info = $this->getInfoById($id);
  1465. return json($info);
  1466. }
  1467. public function getInfoById($id) {
  1468. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  1469. if ($info["enterprise_id"] != $this->user["uid"]) {
  1470. return [];
  1471. }
  1472. return $info;
  1473. }
  1474. public function findTalentInfoInLibrary() {
  1475. $where = [];
  1476. $sList = [];
  1477. $type = $this->request->param('type');
  1478. if ($type == ProjectState::QUIT) {
  1479. $_where = [];
  1480. $_where[] = ["checkState", "not in", [3]];
  1481. $idCards = Db::table("un_talent_quit")->where($_where)->column("idCard");
  1482. $sList = array_merge($sList, (array) $idCards);
  1483. $where[] = ["active", "=", 1];
  1484. }
  1485. if ($type == ProjectState::BANKCHANGE) {
  1486. $_where = [];
  1487. $_where[] = ["checkState", "not in", [3]];
  1488. $idCards = Db::table("un_talent_bank_change")->where($_where)->column("idCard");
  1489. $sList = array_merge($sList, (array) $idCards);
  1490. }
  1491. if ($type == ProjectState::LEVELCHANGE) {
  1492. $_where = [];
  1493. $_where[] = ["checkState", "not in", [35, -1]];
  1494. $_where[] = ["isPublic", "<", 5];
  1495. $idCards = Db::table("un_talent_type_change")->where($_where)->column("idCard");
  1496. $sList = array_merge($sList, (array) $idCards);
  1497. }
  1498. $where[] = ["enterprise_id", "=", $this->user["uid"]];
  1499. $where[] = ["checkState", "=", TalentState::CERTIFICATED];
  1500. $where[] = ["isEffect", "<>", 4];
  1501. if ($sList) {
  1502. $where[] = ["card_number", "not in", $sList];
  1503. }
  1504. $result = TalentModel::where($where)->field("id,name")->select()->toArray();
  1505. return json($result);
  1506. }
  1507. public function findTalentInfoByChangeId() {
  1508. $where = [];
  1509. $id = $this->request->param('id');
  1510. $type = $this->request->param('type');
  1511. if ($type == ProjectState::QUIT) {
  1512. $info = Db::table("un_talent_quit")->where("id", $id)->find();
  1513. }
  1514. if ($type == ProjectState::LEVELCHANGE) {
  1515. $info = Db::table("un_talent_type_change")->where("id", $id)->find();
  1516. }
  1517. if ($type == ProjectState::BANKCHANGE) {
  1518. $info = Db::table("un_talent_bank_change")->where("id", $id)->find();
  1519. }
  1520. if (strlen($info["talentId"]) == 19) {
  1521. $where[] = ["enterprise_id", "=", $this->user["uid"]];
  1522. $where[] = ["card_number", "=", $info["idCard"]];
  1523. $where[] = ["delete", "=", 0];
  1524. $where[] = ["checkState", "=", TalentState::CERTIFICATED];
  1525. } else {
  1526. $where[] = ["id", "=", $info["talentId"]];
  1527. }
  1528. $result = TalentModel::where($where)->field("id,name")->select()->toArray();
  1529. return json($result);
  1530. }
  1531. public function getTalentBasicById() {
  1532. $id = $this->request["id"];
  1533. $ti = \app\common\api\VerifyApi::getTalentInfoById($id);
  1534. /* if(FengStringUtil.isNotEmpAndNull(year)){
  1535. StringBuilder sb = new StringBuilder();
  1536. List<TalentAllowancecontractDetail> contractDetailList = new ArrayList<>(); //保存上一年度的工作单位
  1537. TalentAllowanceInfo info = new TalentAllowanceInfo();
  1538. info.setType(ti.getType());
  1539. info.setYear(year);
  1540. info.setFirstInJJTime(ti.getFirstInJJTime());
  1541. ApiTalentAllowanceController.getConcatList(ti,info,year,sb,contractDetailList);
  1542. int active = AllowanceSelectUtil.validMyqy(contractDetailList,ti,info);
  1543. ti.setActive(active);
  1544. } */
  1545. return $ti;
  1546. }
  1547. /**
  1548. *
  1549. */
  1550. public function getTalentInfoFromOldLibrary() {
  1551. $responseObj = new \stdClass();
  1552. $responseObj->code = 500;
  1553. $ep = EnterpriseApi::getOne($this->user["uid"]);
  1554. $pIdCard = \StrUtil::getRequestDecodeParam($this->request, "idCard");
  1555. $eIdCard = $ep->idCard;
  1556. $where = [];
  1557. $where[] = ["e.idCard", "=", $eIdCard];
  1558. $where[] = ["ti.idCard", "=", $pIdCard];
  1559. $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();
  1560. if ($old) {
  1561. $responseObj->code = 200;
  1562. $responseObj->info = $old;
  1563. return $responseObj;
  1564. }
  1565. return $responseObj;
  1566. }
  1567. /**
  1568. * 审核列表页
  1569. */
  1570. public function examineCenter() {
  1571. $tpl = "";
  1572. switch ($this->user["type"]) {
  1573. case CommonConst::ENTERPRISE_WJ:
  1574. $tpl = "/talent/hospital/examine_center"; //卫健医院
  1575. break;
  1576. }
  1577. return view($tpl);
  1578. }
  1579. /**
  1580. * 审核列表页
  1581. */
  1582. public function examineList() {
  1583. $res = TalentApi::getHospitalExamineList($this->request);
  1584. return json($res);
  1585. }
  1586. public function examinePage() {
  1587. $id = $this->request->param("id");
  1588. $info = \app\common\api\VerifyApi::getTalentInfoById($id);
  1589. return view("/talent/hospital/view", ["row" => $info]);
  1590. }
  1591. /**
  1592. * 医院人才申报审核保存
  1593. * @return type
  1594. */
  1595. public function check() {
  1596. $request = $this->request;
  1597. $params = $request->param();
  1598. $check = $params["checkState"];
  1599. $check_msg = trim($params["checkMsg"]);
  1600. $files = $params["files"];
  1601. $fields = $params["fields"];
  1602. $id = $params["id"];
  1603. $talent_info = \app\common\api\VerifyApi::getOne($id);
  1604. if (!$talent_info) {
  1605. return json(["msg" => "数据错误"]);
  1606. }
  1607. $enterprise = EnterpriseApi::getOne($talent_info["enterprise_id"]);
  1608. $checkState = $talent_info["checkState"];
  1609. if ($this->user["isGeneral"] != 1) {
  1610. return json(["msg" => "非总院账号,无法审核"]);
  1611. }
  1612. if ($this->user["medicalCommunityId"] != $enterprise["medicalCommunityId"]) {
  1613. return json(["msg" => "不能审核其它非本医共体医院"]);
  1614. }
  1615. if (!$check) {
  1616. return json(["msg" => "请选择审核状态"]);
  1617. }
  1618. if (!$check_msg) {
  1619. return json(["msg" => "请填写审核说明"]);
  1620. }
  1621. if ($checkState == TalentState::FST_SUBMIT) {
  1622. if ($params["checkState"] == 3) {
  1623. //审核成功
  1624. $log_checkState = $checkState = TalentState::SCND_SUBMIT; //待初审
  1625. } else {
  1626. //审核驳回并记录需要修改的字段和上传文件
  1627. $checkState = TalentState::FST_SAVE; //退回材料编辑状态
  1628. $log_checkState = TalentState::BASE_REJECT; //日志记录拒绝状态
  1629. }
  1630. $log = TalentLogApi::getLastLog($id, 1);
  1631. if (!$log && !$talent_info["oldId"])
  1632. return json(["msg" => "日志数据异常,保存失败"]);
  1633. if ($log["active"] === 0) {
  1634. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  1635. } else {
  1636. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  1637. }
  1638. $data["id"] = $talent_info["id"];
  1639. $data["modify_files"] = $params["files"];
  1640. $data["modify_fields"] = $params["fields"];
  1641. TalentModel::update($data);
  1642. return json(["code" => 200, "msg" => "保存成功"]);
  1643. } else {
  1644. return json(["msg" => "不在审核范围内,保存失败"]);
  1645. }
  1646. }
  1647. /**
  1648. * 医院人才申报审核
  1649. * @return type
  1650. */
  1651. public function submitCheck() {
  1652. $id = $this->request->param("id");
  1653. $talent_info = \app\common\api\VerifyApi::getOne($id);
  1654. if (!$talent_info) {
  1655. return json(["msg" => "数据错误"]);
  1656. }
  1657. $enterprise = EnterpriseApi::getOne($talent_info["enterprise_id"]);
  1658. $checkState = $talent_info["checkState"];
  1659. if ($this->user["isGeneral"] != 1) {
  1660. return json(["msg" => "非总院账号,无法审核"]);
  1661. }
  1662. if ($this->user["medicalCommunityId"] != $enterprise["medicalCommunityId"]) {
  1663. return json(["msg" => "不能审核其它非本医共体医院"]);
  1664. }
  1665. if ($checkState == TalentState::FST_SUBMIT) {
  1666. $nowProcess = 1;
  1667. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  1668. if (!$log || $log["active"] == 1)
  1669. return json(["msg" => "请先保存审核状态,再提交审核"]);
  1670. if (in_array($log["new_state"], [TalentState::SCND_SUBMIT])) {
  1671. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  1672. }
  1673. $data["id"] = $talent_info["id"];
  1674. $data["checkState"] = $log["new_state"];
  1675. TalentModel::update($data);
  1676. TalentLogApi::setActive($log["id"], 1);
  1677. if ($log["state"] == TalentState::BASE_REJECT) {
  1678. $this->sendMsg($enterprise["id"], $log["description"]);
  1679. }
  1680. return json(["code" => 200, "msg" => "审核成功"]);
  1681. } else {
  1682. return json(["msg" => "不在审核范围内,审核失败"]);
  1683. }
  1684. }
  1685. private function sendMsg($enterprise_id, $description = "") {
  1686. $ep = EnterpriseApi::getOne($enterprise_id);
  1687. if ($ep->agentPhone) {
  1688. $smsapi = new \app\common\api\ChuanglanSmsApi();
  1689. $result = $smsapi->sendSMS($phone, $template);
  1690. $result = json_decode($result, true);
  1691. $id = getStringId();
  1692. $record_data = [
  1693. 'id' => $id,
  1694. 'userId' => $ep->id,
  1695. 'bizId' => $result["msgId"],
  1696. 'type' => 2,
  1697. 'smsType' => 2,
  1698. 'name' => $ep->name,
  1699. 'phone' => $ep->agentPhone,
  1700. 'params' => "总院审核",
  1701. 'templateCode' => "【晋江市人才服务平台】尊敬的用户,您提交的人才认定申报审核驳回,原因是:{$description},请及时登录申报系统修改并重新提交。",
  1702. 'state' => $result['code'] == 0 ? 2 : 3,
  1703. 'sendingDate' => date("Y-m-d H:i:s", time()),
  1704. 'createTime' => date("Y-m-d H:i:s", time()),
  1705. 'msg' => $result['errorMsg']
  1706. ];
  1707. \app\admin\model\MessageRecord::create($record_data);
  1708. }
  1709. }
  1710. public function validateIsCheck() {
  1711. $params = $this->request->param();
  1712. $id = $params["id"];
  1713. $talent_info = \app\common\api\VerifyApi::getTalentInfoById($id);
  1714. $enterprise = EnterpriseApi::getOne($talent_info["enterprise_id"]);
  1715. if ($talent_info) {
  1716. $checkState = $talent_info["checkState"];
  1717. if ($this->user["isGeneral"] != 1) {
  1718. return json(["msg" => "非总院账号,无法审核"]);
  1719. }
  1720. if ($this->user["medicalCommunityId"] != $enterprise["medicalCommunityId"]) {
  1721. return json(["msg" => "不能审核其它非本医共体医院"]);
  1722. }
  1723. if ($checkState != TalentState::FST_SUBMIT) {
  1724. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  1725. }
  1726. $fields = DictApi::getTalentFields_WJ();
  1727. $field_tmp = [];
  1728. if ($fields) {
  1729. foreach ($fields as $key => $field) {
  1730. $field_tmp[] = ["key" => $key, "value" => $field];
  1731. }
  1732. }
  1733. $condition = \app\common\api\TalentConditionApi::getOne($talent_info["talent_condition"]);
  1734. $where = [];
  1735. $whr = [];
  1736. $where[] = ["project", "=", 1];
  1737. $where[] = ["active", "=", 1];
  1738. $where[] = ["type", "=", $enterprise["type"]];
  1739. $where[] = ["isConditionFile", "<>", 1];
  1740. $where[] = ["delete", "=", 0];
  1741. if ($condition && $condition["bindFileTypes"]) {
  1742. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  1743. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->order("sn asc")->select();
  1744. } else {
  1745. $files = \think\facade\Db::table("new_common_filetype")->where($where)->order("sn asc")->select();
  1746. }
  1747. $talent_info["files"] = array_filter(explode(",", $talent_info["modify_files"]));
  1748. $talent_info["fields"] = array_filter(explode(",", $talent_info["modify_fields"]));
  1749. /* 保存的审核内容start */
  1750. $last_log = TalentLogApi::getLastLog($id, ProjectState::TALENT, 0, ["active", "=", 0]);
  1751. $check = ["msg" => $last_log["description"]];
  1752. if ($last_log["state"] == TalentState::BASE_VERIFY_PASS) {
  1753. $check["checkState"] = 3;
  1754. }
  1755. if ($last_log["new_state"] == TalentState::FST_SAVE && $last_log["state"] == TalentState::BASE_REJECT) {
  1756. $check["checkState"] = 2;
  1757. }
  1758. /* 保存的审核内容end */
  1759. return json(["code" => 200, "obj" => ["talentInfo" => $talent_info, "check" => $check, "fieldList" => $field_tmp, "fileList" => $files]]);
  1760. }
  1761. }
  1762. // public function mixDelete() {
  1763. // $id = $this->request->param("talentInfoId");
  1764. // $info = TalentApi::chkIsOwner($id, $this->user["uid"]);
  1765. // if (!$info) {
  1766. // return json(["msg" => "操作失败"]);
  1767. // }
  1768. // $checkState = $info["checkState"];
  1769. // if (in_array($checkState, [0, TalentState::SCND_SAVE])) {
  1770. // $data["id"] = $id;
  1771. // $data["delete"] = 1;
  1772. // TalentModel::update($data);
  1773. // return json(["msg" => "删除成功"]);
  1774. // }
  1775. // return json(["msg" => "该申报已提交审核,无法删除"]);
  1776. // }
  1777. }