Talent.php 75 KB

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