Talent.php 88 KB

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