Talent.php 86 KB

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