IntegralVerify.php 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use app\common\api\ChuanglanSmsApi;
  5. use app\common\api\TalentLogApi;
  6. use app\common\model\MessageRecord;
  7. use app\common\api\DictApi;
  8. use app\common\api\EnterpriseApi;
  9. use think\facade\Db;
  10. use app\admin\model\User;
  11. use app\common\api\MenuApi;
  12. use app\admin\model\SysRelation;
  13. use app\common\api\CompanyApi;
  14. use app\common\api\IntegralRecordApi;
  15. /**
  16. * Description of Talent
  17. *
  18. * @author sgq
  19. */
  20. class IntegralVerify extends AdminController {
  21. public function common_check() {
  22. $request = $this->request;
  23. $params = $request->param();
  24. $id = $params["id"];
  25. $info = IntegralRecordApi::getOne($id);
  26. return view("", ["info" => $info]);
  27. }
  28. public function cancel_verify() {
  29. $params = $this->request->param();
  30. $ids = $params["ids"];
  31. $msg = $params["msg"];
  32. if ($msg == "") {
  33. return json(["msg" => "请填写审核不通过的原因"]);
  34. }
  35. $ids_arr = array_filter(explode(",", $ids));
  36. $counts = 0;
  37. foreach ($ids_arr as $id) {
  38. $ti = VerifyApi::getOne($id);
  39. $data["id"] = $id;
  40. if ($ti["checkState"] == TalentState::FST_SUBMIT) {
  41. $data["checkState"] = TalentState::BASE_VERIFY_FAIL;
  42. TalentLogApi::write(1, $id, TalentState::BASE_VERIFY_FAIL, $msg, 1);
  43. TalentModel::update($data);
  44. $counts++;
  45. } else if ($ti["checkState"] == TalentState::SCND_SAVE) {
  46. $data["checkState"] = TalentState::FST_VERIFY_FAIL;
  47. TalentLogApi::write(1, $id, TalentState::FST_VERIFY_FAIL, $msg, 1);
  48. TalentModel::update($data);
  49. $counts++;
  50. } else {
  51. return json(["msg" => "不在审核范围"]);
  52. }
  53. }
  54. return json(["code" => 200, sprintf("%d个申请已审核失败", $counts)]);
  55. }
  56. /**
  57. * 初审
  58. * @auth {{/talentInfo/gotoIndex/1}}
  59. */
  60. public function fst_verify() {
  61. $enterprises = EnterpriseApi::getSimpleList();
  62. return view("", ["enterprises" => $enterprises]);
  63. }
  64. /**
  65. * 复审
  66. * @auth {{/talentInfo/gotoIndex/3}}
  67. */
  68. public function re_verify() {
  69. $enterprises = EnterpriseApi::getSimpleList();
  70. return view("", ["enterprises" => $enterprises]);
  71. }
  72. /**
  73. * 预备人才库
  74. * @auth {{/talentInfo/gotoIndex/4}}
  75. */
  76. public function pre_list() {
  77. if (session("user")["type"] == 1) {
  78. $message = [
  79. "typeName" => "晋江市现代产业体系人才认定", "address" => "聚才网/人才晋江微信公众号", "dep" => "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心",
  80. "phone" => "0595-85633128", "email" => "jjrc85661234@163.com"
  81. ];
  82. } else {
  83. $message = [
  84. "typeName" => "晋江市集成电路产业优秀人才认定", "address" => "福建(晋江)集成电路产业园官方网站及微信公众号", "dep" => "集成电路产业园区",
  85. "phone" => "0595-82250007、0595-82250001", "email" => "jjjcdr@163.com"
  86. ];
  87. }
  88. $enterprises = EnterpriseApi::getSimpleList();
  89. return view("", ["message" => $message, "enterprises" => $enterprises]);
  90. }
  91. public function selectNeedCheckData() {
  92. $params = $this->request->param();
  93. return json(["code" => 200, "obj" => VerifyApi::getPublicList($params)]);
  94. }
  95. /**
  96. * 预备人才库-核查征信
  97. * @auth {{/talentInfo/prepareHczx}}
  98. */
  99. public function prepareHczx() {
  100. $ids = $this->request->param("ids");
  101. $ids_arr = array_filter(explode(",", $ids));
  102. if (!$ids_arr) {
  103. $res = ["code" => 500, "msg" => "没有选择导出的名单"];
  104. echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
  105. }
  106. $where[] = ["ti.id", "in", $ids_arr];
  107. $list = TalentModel::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->field("ti.name,ti.card_type,ti.card_number,e.name as enterpriseName,e.description")->where($where)->select();
  108. if (!$list) {
  109. $res = ["code" => 500, "msg" => "没有可以导出的内容"];
  110. echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
  111. }
  112. $columns = ["序号", "姓名", "证件类型", "证件号码", "工作单位", "备注"];
  113. $rows = [];
  114. $i = 1;
  115. $card_types = DictApi::selectByParentCode("card_type");
  116. foreach ($list as $item) {
  117. $row = [
  118. $i, $item["name"], $card_types[$item["card_type"]], $item["card_number"], $item["enterpriseName"], $item["description"]
  119. ];
  120. $rows[] = $row;
  121. $i++;
  122. }
  123. $filename = "现代产业体系人才核查征信名单导出";
  124. if ($rows) {
  125. export($columns, $rows, $filename);
  126. exit();
  127. }
  128. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  129. }
  130. /**
  131. * 预备人才库-征信通过
  132. * @auth {{/talentInfo/hczxPass}}
  133. */
  134. public function hczxPass() {
  135. $params = $this->request->param();
  136. $ids = $params["ids"];
  137. $ids = array_filter(explode(",", $ids));
  138. $msg = "征信通过";
  139. $state = TalentState::ZX_PASS; //征信通过
  140. $total = count($ids);
  141. $error = 0;
  142. $success = 0;
  143. foreach ($ids as $id) {
  144. $talent_info = VerifyApi::getOne($id);
  145. if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
  146. $error++;
  147. continue;
  148. }
  149. if (VerifyApi::setPublic($id, $state, $msg)) {
  150. $success++;
  151. } else {
  152. $error++;
  153. }
  154. }
  155. return json(["code" => 200, "msg" => sprintf("核查征信完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  156. }
  157. /**
  158. * 预备人才库-征信失信
  159. * @auth {{/talentInfo/hczxReject}}
  160. */
  161. public function hczxReject() {
  162. $params = $this->request->param();
  163. $id = $params["id"];
  164. $msg = $params["outMsg"];
  165. if (!$msg)
  166. return json(["msg" => "请填写审核意见"]);
  167. $msg = "征信失信:" . $msg;
  168. $state = TalentState::ZX_FAIL; //征信不通过
  169. $talent_info = VerifyApi::getOne($id);
  170. if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
  171. return json(["msg" => "当前记录不是待核查征信状态,无法核查"]);
  172. }
  173. if (VerifyApi::setPublic($id, $state, $msg)) {
  174. return json(["code" => 200, "msg" => "已设置征信失信"]);
  175. }
  176. return json(["msg" => "设置征信失信失败"]);
  177. }
  178. /**
  179. * 预备人才库-公示预览
  180. * @auth {{/talentInfo/publicExportBefore}}
  181. */
  182. public function publicExportBefore() {
  183. $params = $this->request->param();
  184. $ids_arr = array_filter(explode(",", $params["ids"]));
  185. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
  186. if ($ids_arr) {
  187. $where[] = ["id", "in", $ids_arr];
  188. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  189. $rows = [];
  190. $i = 1;
  191. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  192. foreach ($list as $item) {
  193. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  194. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  195. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  196. $row = [
  197. $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::ZX_PASS ? "审核通过" : "审核不通过", $checkLog["description"]
  198. ];
  199. $rows[] = $row;
  200. $i++;
  201. }
  202. }
  203. if ($rows) {
  204. $filename = "现代产业体系人才公示预览导出";
  205. export($columns, $rows, $filename);
  206. exit();
  207. }
  208. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  209. }
  210. /**
  211. * 预备人才库-公示导出
  212. * @auth {{/talentInfo/publicExport}}
  213. */
  214. public function publicExport() {
  215. $params = $this->request->param();
  216. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
  217. $startTime = $params["startTime"];
  218. $endTime = $params["endTime"];
  219. if (!strtotime($startTime) || !strtotime($endTime))
  220. return json(["msg" => "时间格式错误"]);
  221. $where[] = ["checkState", "=", TalentState::ANNOUNCED];
  222. $where[] = ["publicBatch", "between", [$startTime, $endTime]];
  223. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  224. $rows = [];
  225. $i = 1;
  226. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  227. foreach ($list as $item) {
  228. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  229. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  230. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  231. $row = [
  232. $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::ANNOUNCED ? "审核通过" : "审核不通过", $checkLog["description"]
  233. ];
  234. $rows[] = $row;
  235. $i++;
  236. }
  237. if ($rows) {
  238. $filename = "现代产业体系人才公示导出";
  239. export($columns, $rows, $filename);
  240. exit();
  241. }
  242. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  243. }
  244. /**
  245. * 预备人才库-公示
  246. * @auth {{/talentInfo/preparePublic}}
  247. */
  248. public function preparePublic() {
  249. $params = $this->request->param();
  250. $ids = $params["ids"];
  251. $publicBatch = $params["batch"];
  252. if (!$publicBatch || strlen($publicBatch) != 6 || !is_numeric($publicBatch))
  253. return json(["msg" => "公示批次错误"]);
  254. $isMessage = $params["isMessage"] == 1 ? true : false;
  255. if ($isMessage && (!$params["typeName"] || !$params["address"] || !$params["publicStartTime"] || !$params["publicEndTime"] || !$params["dep"] || !$params["phone"] || !$params["email"])) {
  256. return json(["msg" => "短信参数不能为空"]);
  257. }
  258. $ids = array_filter(explode(",", $ids));
  259. $msg = "已公示";
  260. $state = TalentState::ANNOUNCED; //公示
  261. $total = count($ids);
  262. $error = 0;
  263. $success = 0;
  264. $phones = [];
  265. foreach ($ids as $id) {
  266. $talent_info = VerifyApi::getOne($id);
  267. if ($talent_info["checkState"] != TalentState::ZX_PASS) {
  268. $error++;
  269. continue;
  270. }
  271. if (VerifyApi::setPublic($id, $state, $msg, $publicBatch)) {
  272. $success++;
  273. $ep = EnterpriseApi::getOne($talent_info['enterprise_id']);
  274. $phones[] = $ep->agentPhone;
  275. } else {
  276. $error++;
  277. }
  278. }
  279. $phones = array_unique(array_filter($phones));
  280. if ($isMessage && $phones) {
  281. $sms = new \app\common\api\ChuanglanSmsApi();
  282. $tpl_content = sprintf("【晋江市人才服务平台】您好!您提交申请的%s已完成初步审核,现通过%s将审核结果予以公示,公示时间%s至%s。公示期间如有异议,请及时向%s反映。电话%s,电子邮箱%s。",
  283. $params["typeName"], $params["address"], $params["publicStartTime"], $params["publicEndTime"], $params["dep"], $params["phone"], $params["email"]);
  284. while ($phone = array_shift($phones)) {
  285. $result = $sms->sendSMS($phone, $tpl_content);
  286. $result = json_decode($result, true);
  287. $recordId = getStringId();
  288. $record_data = [
  289. 'id' => $recordId,
  290. 'bizId' => $recordId,
  291. 'type' => 2,
  292. 'smsType' => 1,
  293. 'phone' => $phone,
  294. 'params' => '公示',
  295. 'templateCode' => $tpl_content,
  296. 'state' => $result['code'] == 0 ? 2 : 3,
  297. 'sendingDate' => date("Y-m-d H:i:s", time()),
  298. 'createTime' => date("Y-m-d H:i:s", time()),
  299. 'msg' => $result['errorMsg']
  300. ];
  301. MessageRecord::create($record_data);
  302. }
  303. }
  304. return json(["code" => 200, "msg" => sprintf("公示完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  305. }
  306. /**
  307. * 预备人才库-公示再审核
  308. * @auth {{/talentInfo/prepareCheck}}
  309. */
  310. public function prepareCheck() {
  311. $params = $this->request->param();
  312. $id = $params["id"];
  313. $checkState = $params["checkState"];
  314. $msg = $params["checkMsg"];
  315. if (!$msg)
  316. return json(["msg" => "请填写审核意见"]);
  317. if ($checkState == 1) {
  318. $msg = "公示再审核通过:" . $msg;
  319. $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
  320. } else {
  321. $msg = "公示再审核不通过:" . $msg;
  322. $state = TalentState::ANNOUNCED_REVERIFY_FAIL; //公示再审核不通过
  323. }
  324. $talent_info = VerifyApi::getOne($id);
  325. if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
  326. return json(["msg" => "当前记录不是公示状态,无法审核"]);
  327. }
  328. if (VerifyApi::setPublic($id, $state, $msg)) {
  329. return json(["code" => 200, "msg" => "公示再审核完成"]);
  330. }
  331. return json(["msg" => "公示再审核失败"]);
  332. }
  333. /**
  334. * 预备人才库-公示通过(批量)
  335. * @auth {{/talentInfo/publicPass}}
  336. */
  337. public function publicPass() {
  338. $params = $this->request->param();
  339. $ids = $params["ids"];
  340. $ids = array_filter(explode(",", $ids));
  341. $msg = "公示再审核批量通过";
  342. $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
  343. $total = count($ids);
  344. $error = 0;
  345. $success = 0;
  346. foreach ($ids as $id) {
  347. $talent_info = VerifyApi::getOne($id);
  348. if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
  349. $error++;
  350. continue;
  351. }
  352. if (VerifyApi::setPublic($id, $state, $msg)) {
  353. $success++;
  354. } else {
  355. $error++;
  356. }
  357. }
  358. return json(["code" => 200, "msg" => sprintf("公示再审核完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  359. }
  360. /**
  361. * 预备人才库-公布预览
  362. * @auth {{/talentInfo/publishExportBefore}}
  363. */
  364. public function publishExportBefore() {
  365. $params = $this->request->param();
  366. $ids = $params["ids"];
  367. $ids = array_filter(explode(",", $ids));
  368. if ($ids) {
  369. $where[] = ["id", "in", $ids];
  370. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  371. $rows = [];
  372. $i = 1;
  373. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  374. foreach ($list as $item) {
  375. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  376. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  377. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  378. $row = [
  379. $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::ANNOUNCED_REVERIFY_PASS ? "审核通过" : "审核不通过", $checkLog["description"]
  380. ];
  381. $rows[] = $row;
  382. $i++;
  383. }
  384. }
  385. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
  386. $filename = "现代产业体系人才" . date("Ym") . "公布预览名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
  387. if ($rows) {
  388. export($columns, $rows, $filename);
  389. exit();
  390. }
  391. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  392. }
  393. /**
  394. * 预备人才库-公布导出
  395. * @auth {{/talentInfo/publishExport}}
  396. */
  397. public function publishExport() {
  398. $params = $this->request->param();
  399. $startTime = $params["startTime"];
  400. $endTime = $params["endTime"];
  401. if (!strtotime($startTime) || !strtotime($endTime))
  402. return json(["msg" => "时间格式错误"]);
  403. $where[] = ["checkState", "=", TalentState::PUBLISH_PASS];
  404. $where[] = ["certificateGetTime", "between", [$startTime, $endTime]];
  405. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  406. $rows = [];
  407. $i = 1;
  408. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  409. foreach ($list as $item) {
  410. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  411. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  412. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  413. $row = [
  414. $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::PUBLISH_PASS ? "审核通过" : "审核不通过", $checkLog["description"]
  415. ];
  416. $rows[] = $row;
  417. $i++;
  418. }
  419. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
  420. $filename = "现代产业体系人才" . date("Ym") . "公布名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
  421. if ($rows) {
  422. export($columns, $rows, $filename);
  423. exit();
  424. }
  425. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  426. }
  427. /**
  428. * 预备人才库-公布
  429. * @auth {{/talentInfo/publish}}
  430. */
  431. public function publish() {
  432. $params = $this->request->param();
  433. $id = $params["id"];
  434. $msg = $params["checkMsg"];
  435. $checkState = $params["checkState"];
  436. $batch = $params["batch"];
  437. if ($checkState == 1) {
  438. $state = TalentState::PUBLISH_PASS;
  439. $msg = "公布审核通过:" . $msg;
  440. } else {
  441. $state = TalentState::PUBLISH_FAIL;
  442. $msg = "公布审核不通过:" . $msg;
  443. }
  444. if (!$batch || !strtotime($batch))
  445. return json(["msg" => "公布批次时间错误"]);
  446. if (!$msg)
  447. return json(["msg" => "请填写审核意见"]);
  448. $state = TalentState::PUBLISH_PASS; //公示再审核通过
  449. $batch = $params["batch"];
  450. if (!strtotime($batch))
  451. return json(["msg" => "公布批次时间错误"]);
  452. $talent_info = VerifyApi::getOne($id);
  453. if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
  454. return json(["msg" => "当前记录不是公示再审核通过状态,无法审核"]);
  455. }
  456. if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
  457. return json(["code" => 200, "msg" => "公布审核完成"]);
  458. }
  459. return json(["msg" => "公布审核失败"]);
  460. }
  461. /**
  462. * 预备人才库-批量公布通过
  463. * @auth {{/talentInfo/preparePublish}}
  464. */
  465. public function preparePublish() {
  466. $params = $this->request->param();
  467. $ids = $params["ids"];
  468. $ids = array_filter(explode(",", $ids));
  469. $msg = "批量公布";
  470. $state = TalentState::PUBLISH_PASS; //公示再审核通过
  471. $batch = $params["batch"];
  472. if (!strtotime($batch))
  473. return json(["msg" => "公布批次时间错误"]);
  474. $total = count($ids);
  475. $error = 0;
  476. $success = 0;
  477. foreach ($ids as $id) {
  478. $talent_info = VerifyApi::getOne($id);
  479. if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
  480. $error++;
  481. continue;
  482. }
  483. if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
  484. $success++;
  485. } else {
  486. $error++;
  487. }
  488. }
  489. return json(["code" => 200, "msg" => sprintf("公布完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  490. }
  491. /**
  492. * 预备人才库-批量发放人才码
  493. * @auth {{/talentInfo/prepareCertification}}
  494. */
  495. public function prepareCertification() {
  496. $lockFile = fopen("send_certificate.lock", "a");
  497. if (flock($lockFile, LOCK_EX | LOCK_NB)) {//文件锁(独占)
  498. //查询所有待发放人才码的数据
  499. $params = $this->request->param();
  500. $ids = array_filter(explode(",", $params["ids"]));
  501. //晋江市优秀人才证书:当前年份+层次+四位递增数字
  502. //集成电路优秀人才证书:IC+当前年份+递增四位数,如IC20190001
  503. Db::startTrans();
  504. $talent_max_no = [];
  505. $user = session("user");
  506. try {
  507. $talent_list = VerifyApi::getListByIds($ids);
  508. $year = date("Y");
  509. foreach ($talent_list as $talent_info) {
  510. if ($talent_info["checkState"] != TalentState::PUBLISH_PASS) {
  511. Db::rollback();
  512. return json(["msg" => "只能对公布通过的对象发放人才码,请核查待发放人才码名单后再重新发放人才码"]);
  513. }
  514. $no_prefix = $year . $talent_info["talent_arrange"];
  515. $where[] = ["certificateNo", "like", $no_prefix . "%"];
  516. $max_no = $talent_max_no[$talent_info["talent_arrange"]] ?: Db::table("new_talent_info")->where($where)->max("certificateNo");
  517. if (!$max_no) {
  518. $max_no = $no_prefix . "0001";
  519. } else {
  520. $new_no = intval(substr($max_no, 5)) + 1;
  521. $max_no = $no_prefix . str_pad($new_no, 4, "0", STR_PAD_LEFT);
  522. }
  523. //更新证书编号
  524. $data["id"] = $talent_info["id"];
  525. $data["certificateNo"] = $max_no;
  526. $data["checkState"] = TalentState::CERTIFICATED;
  527. $data["isPublic"] = 5;
  528. Db::table("new_talent_info")->update($data);
  529. //写入日志
  530. $log["last_state"] = TalentState::PUBLISH_PASS;
  531. $log["id"] = getStringId();
  532. $log["state"] = $log["new_state"] = TalentState::CERTIFICATED;
  533. $log["type"] = 1;
  534. $log["mainId"] = $talent_info["id"];
  535. $log["companyId"] = $user["companyId"];
  536. $log["active"] = 1;
  537. $log["description"] = "人才码为:" . $max_no;
  538. $log["createUser"] = sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]);
  539. $log["createTime"] = date("Y-m-d H:i:s");
  540. Db::table("new_talent_checklog")->insert($log);
  541. $talent_max_no[$talent_info["talent_arrange"]] = $max_no;
  542. }
  543. Db::commit();
  544. return json(["code" => 200, "msg" => "发放人才码成功"]);
  545. } catch (\Exception $e) {
  546. Db::rollback();
  547. return json(["msg" => "发放人才码失败:" . $e->getMessage()]);
  548. }
  549. flock($lockFile, LOCK_UN);
  550. } else {
  551. return json(["msg" => "同一时间只能有一个管理员进行发放人才码操作"]);
  552. }
  553. }
  554. /**
  555. * 预备人才库-撤销公布
  556. * @auth {{/talentInfo/prepareCanclePublish}}
  557. */
  558. public function pre_cancel_publish() {
  559. }
  560. /**
  561. * 初审-提交未保存
  562. * @param \think\Request $request
  563. * @param type $talent_info
  564. * @return type json
  565. */
  566. private function fstCheck(\think\Request $request, $talent_info) {
  567. $params = $request->param();
  568. if ($params["checkState"] == 3) {
  569. //审核成功,并取消设置越过部门并审
  570. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  571. $data["pass_dept_check"] = 0;
  572. if ($talent_info["isImport"] && $talent_info["isMatchZhiren"]) {
  573. $data["pass_dept_check"] = 1;
  574. }
  575. } else if ($params["checkState"] == 4) {
  576. if ($talent_info["highProcess"] < 4)
  577. return json(["msg" => "只有曾经通过部门并审,初审时才可以选择直接跳过部门并审阶段"]);
  578. //审核成功,并设置越过部门并审。附加条件:最高进度曾经通过部门并审4(包含部门并审)
  579. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  580. $data["pass_dept_check"] = $talent_info["highProcess"] >= 4 ? 1 : 0;
  581. } else if ($params["checkState"] == 5) {
  582. //选择重审部门
  583. if ($talent_info["highProcess"] < 4)
  584. return json(["msg" => "只有曾经通过部门并审,初审时才可以选择再次审核的部门"]);
  585. if (!$params["companys"])
  586. return json(["msg" => "请选择需要再次审核的部门"]);
  587. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  588. $companyIds = array_filter(explode(",", $condition["companyIds"])); //该条件下需要审核的所有单位
  589. $re_check_companys = array_filter(explode(",", $talent_info["re_check_companys"]));
  590. foreach ($re_check_companys as $reCompanyId) {
  591. if (!in_array($reCompanyId, $companyIds)) {
  592. return json(["msg" => "错误的部门"]);
  593. }
  594. }
  595. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  596. $data["pass_dept_check"] = 0;
  597. } else {
  598. //审核驳回并记录需要修改的字段和上传文件
  599. $checkState = TalentState::SCND_SAVE; //退回材料编辑状态
  600. $log_checkState = TalentState::FST_VERIFY_REJECT; //日志记录拒绝状态
  601. }
  602. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  603. if (!$log)
  604. return json(["msg" => "日志数据异常,保存失败"]);
  605. if ($log["active"] == 0) {
  606. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  607. } else {
  608. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  609. }
  610. $data["id"] = $talent_info["id"];
  611. $data["modify_files"] = $params["files"];
  612. $data["modify_fields"] = $params["fields"];
  613. $data["re_check_companys"] = $params["companys"];
  614. TalentModel::update($data);
  615. return json(["code" => 200, "msg" => "保存成功"]);
  616. }
  617. /**
  618. * 初审-提交审核
  619. * @param type $talent_info
  620. * @return type json
  621. */
  622. private function fstSubmitCheck($talent_info) {
  623. $nowProcess = 3;
  624. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  625. if (!$log || $log["active"] == 1)
  626. return json(["msg" => "请先保存审核状态,再提交审核"]);
  627. if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  628. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  629. }
  630. $userIds = [];
  631. if ($log["new_state"] == TalentState::FST_VERIFY_PASS && $talent_info["pass_dept_check"] == 0) {
  632. $data["first_dept_check_time"] = date("Y-m-d H:i:s");
  633. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  634. $companyIds = array_filter(explode(",", $condition["companyIds"])); //该条件下需要审核的所有单位
  635. if ($talent_info["re_check_companys"]) {
  636. $unpass_companyIds = array_filter(explode(",", $talent_info["re_check_companys"]));
  637. } else {
  638. //这边去除已经审核通过的单位,主要通过日志是否存在记录。
  639. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  640. $unpass_companyIds = array_diff($companyIds, (array) $pass_companyIds); //排除已经通过的单位
  641. if (!$unpass_companyIds) {
  642. $data["pass_dept_check"] = 1; //部门已经全部审核过了,跳过部门审核
  643. }
  644. }
  645. if ($unpass_companyIds) {
  646. sort($unpass_companyIds);
  647. TalentLogApi::writeDeptLogs($talent_info["id"], $unpass_companyIds, TalentState::FST_VERIFY_PASS);
  648. //初审通过发送短信通知并审部门
  649. $privs = ["/admin/talent/dept_check"];
  650. $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
  651. $where[] = ["menuid", "in", $menuIds];
  652. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
  653. $where = [];
  654. $where[] = ["status", "=", 1];
  655. $where[] = ["companyId", "in", $unpass_companyIds];
  656. $where[] = ["roleid", "in", $roleIds];
  657. $where[] = ["roleid", "<>", 1];
  658. $userIds = User::where($where)->column("id");
  659. }
  660. }
  661. $data["id"] = $talent_info["id"];
  662. $data["checkState"] = $log["new_state"];
  663. TalentModel::update($data);
  664. TalentLogApi::setActive($log["id"], 1);
  665. $this->sendMsgByState($talent_info, $log["new_state"], $userIds);
  666. return json(["code" => 200, "msg" => "审核成功"]);
  667. }
  668. /**
  669. * 复审-提交未保存
  670. * @param \think\Request $request
  671. * @param type $talent_info
  672. * @param type json
  673. */
  674. private function reCheck(\think\Request $request, $talent_info) {
  675. $params = $request->param();
  676. if ($params["checkState"] == 3) {
  677. //审核成功
  678. $log_checkState = $checkState = TalentState::REVERIFY_PASS; //复核成功
  679. } else if ($params["checkState"] == 2) {
  680. //审核驳回并记录需要修改的字段和上传文件
  681. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  682. $log_checkState = TalentState::REVERIFY_REJECT; //日志记录拒绝状态
  683. } else {
  684. $log_checkState = $checkState = TalentState::REVERIFY_FAIL; //审核失败
  685. }
  686. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  687. if (!$log)
  688. return json(["msg" => "日志数据异常,保存失败"]);
  689. if ($log["active"] == 0) {
  690. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  691. } else {
  692. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  693. }
  694. $data["id"] = $talent_info["id"];
  695. $data["modify_files"] = $params["files"];
  696. $data["modify_fields"] = $params["fields"];
  697. TalentModel::update($data);
  698. return json(["code" => 200, "msg" => "保存成功"]);
  699. }
  700. /**
  701. * 复审-提交审核
  702. * @param type $talent_info
  703. * @return type json
  704. */
  705. private function reSubmitCheck($talent_info) {
  706. return $this->commonSubmitCheck($talent_info, 5);
  707. }
  708. private function commonSubmitCheck($talent_info, $nowProcess) {
  709. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  710. if (!$log || $log["active"] == 1)
  711. return json(["msg" => "请先保存审核状态,再提交审核"]);
  712. if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  713. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  714. }
  715. $data["id"] = $talent_info["id"];
  716. $data["checkState"] = $log["new_state"];
  717. TalentModel::update($data);
  718. TalentLogApi::setActive($log["id"], 1);
  719. $userIds = [];
  720. if (in_array($data["checkState"], [TalentState::REVERIFY_PASS, TalentState::REVERIFY_REJECT])) {
  721. //复核成功需要发送短信给征信部门,复核的其它状态发送通知给用户,调用此方法的还有基础审核的每个状态都要发送通知给用户
  722. //从征信审核权限,逆推征信部门
  723. if ($data["checkState"] == TalentState::REVERIFY_PASS) {
  724. $privs = ["/admin/talent/hczxReject", "/admin/talent/hczxPass"];
  725. } else {
  726. $privs = ["admin/talent/fst_check"];
  727. }
  728. $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
  729. $where = [];
  730. $where[] = ["menuid", "in", $menuIds];
  731. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
  732. $where = [];
  733. $where[] = ["status", "=", 1];
  734. $where[] = ["roleid", "in", $roleIds];
  735. $where[] = ["roleid", "<>", 1];
  736. $userIds = User::where($where)->column("id");
  737. }
  738. $this->sendMsgByState($talent_info, $data["checkState"], $userIds);
  739. return json(["code" => 200, "msg" => "审核成功"]);
  740. }
  741. private function sendMsgByState($talent_info, $state, $userIds = []) {
  742. $phones = [];
  743. $template = "";
  744. $type = 0;
  745. $processName = "";
  746. $userId = 0;
  747. $name = null;
  748. switch ($state) {
  749. case TalentState::BASE_VERIFY_PASS://基础信息审核通过发送短信通知用户
  750. $type = 2;
  751. $processName = "基础信息审核";
  752. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核通过,请及时登录申报系统并进行人才认定的信息申报填写。";
  753. break;
  754. case TalentState::BASE_REJECT://基础信息审核驳回发送短信通知用户
  755. $type = 2;
  756. $processName = "基础信息审核";
  757. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核驳回,原因是:{$log['description']},请及时登录申报系统修改并重新提交。";
  758. break;
  759. case TalentState::BASE_VERIFY_FAIL://基础信息审核不通过发送短信通知用户
  760. $type = 2;
  761. $processName = "基础信息审核";
  762. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核不通过,原因是:{$log['description']}。";
  763. break;
  764. case TalentState::FST_VERIFY_PASS://初审通过发送短信通知并审部门
  765. $type = 1;
  766. $processName = "初级审核";
  767. $template = "【晋江市人才服务平台】您的部门有新的人才认定申报需要审批,请及时登录审批系统处理。";
  768. break;
  769. case TalentState::FST_VERIFY_REJECT; //初审驳回发送短信通知用户
  770. $type = 2;
  771. $processName = "初级审核";
  772. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才认定申报审核驳回,原因是:{$log['description']},请及时登录申报系统修改并重新提交。";
  773. break;
  774. case TalentState::FST_VERIFY_FAIL://初审不通过发送短信通知用户
  775. $type = 2;
  776. $processName = "初级审核";
  777. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才认定申报审核不通过,原因是:{$log['description']}。";
  778. break;
  779. case TalentState::DEPT_VERIFY_REJECT://并审驳回发送短信通知初审部门
  780. $type = 1;
  781. $processName = "部门并审";
  782. $template = "【晋江市人才服务平台】有人才认定申报在并审阶段被驳回,原因是:{$log['description']},请及时登录审批系统处理。";
  783. break;
  784. case TalentState::REVERIFY_PASS://复核通过发短信通知征信部门
  785. $type = 1;
  786. $processName = "复审";
  787. $template = "【晋江市人才服务平台】有新的人才认定申报通过复审进入征信阶段,请及时登录审批系统处理。";
  788. break;
  789. case TalentState::REVERIFY_REJECT://复核驳回发短信通知初审部门
  790. $type = 1;
  791. $processName = "复审";
  792. $template = "【晋江市人才服务平台】有人才认定申报在复审阶段被驳回,原因是:{$log['description']},请及时登录审批系统处理。";
  793. break;
  794. }
  795. if ($type == 1) {
  796. $where = [];
  797. $where[] = ["id", "in", $userIds];
  798. $phones = User::where($where)->column("phone");
  799. $phones = array_unique(array_filter($phones));
  800. }
  801. if ($type == 2) {
  802. $ep = EnterpriseApi::getOne($talent_info['enterprise_id']);
  803. $phones[] = $ep->agentPhone;
  804. $userId = $ep->id;
  805. $name = $ep->name;
  806. }
  807. if ($phones && $template) {
  808. while ($phone = array_shift($phones)) {
  809. $smsapi = new ChuanglanSmsApi();
  810. $result = $smsapi->sendSMS($phone, $template);
  811. $result = json_decode($result, true);
  812. $id = getStringId();
  813. $record_data = [
  814. 'id' => $id,
  815. 'userId' => $userId,
  816. 'bizId' => $id,
  817. 'type' => $type,
  818. 'smsType' => 2,
  819. 'name' => $name,
  820. 'phone' => $phone,
  821. 'params' => $processName,
  822. 'templateCode' => $template,
  823. 'state' => $result['code'] == 0 ? 2 : 3,
  824. 'sendingDate' => date("Y-m-d H:i:s", time()),
  825. 'createTime' => date("Y-m-d H:i:s", time()),
  826. 'msg' => $result['errorMsg']
  827. ];
  828. MessageRecord::create($record_data);
  829. }
  830. }
  831. }
  832. public function check() {
  833. //公共调度方法
  834. $request = $this->request;
  835. $params = $request->param();
  836. $check = $params["checkState"];
  837. $check_msg = trim($params["checkMsg"]);
  838. $files = $params["files"];
  839. $fields = $params["fields"];
  840. $id = $params["id"];
  841. $talent_info = VerifyApi::getOne($id);
  842. $checkState = $talent_info["checkState"];
  843. if (!$talent_info) {
  844. return json(["msg" => "数据错误"]);
  845. }
  846. if (!$check) {
  847. return json(["msg" => "请选择审核状态"]);
  848. }
  849. if (!$check_msg) {
  850. return json(["msg" => "请填写审核说明"]);
  851. }
  852. if ($checkState == TalentState::FST_SUBMIT) {
  853. return $this->baseCheck($request, $talent_info);
  854. } else if ($checkState == TalentState::BASE_VERIFY_PASS) {
  855. return $this->baseReCheck($request, $talent_info);
  856. } else if ($checkState == TalentState::SCND_SUBMIT) {
  857. return $this->fstCheck($request, $talent_info);
  858. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  859. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  860. $companys = array_filter(explode(",", $condition["companyIds"]));
  861. if ($companys && $talent_info["pass_dept_check"] != 1) {
  862. if (!in_array($this->user["companyId"], $companys))
  863. return json(["msg" => "你的部门不在并审部门列表"]);
  864. return $this->deptCheck($request, $talent_info, $companys);
  865. } else {
  866. return $this->reCheck($request, $talent_info);
  867. }
  868. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  869. return $this->reCheck($request, $talent_info);
  870. } else {
  871. return json(["msg" => "不在审核范围内,保存失败"]);
  872. }
  873. }
  874. public function submitCheck() {
  875. //公共调度方法
  876. $id = $this->request->param("id");
  877. $talent_info = VerifyApi::getOne($id);
  878. $checkState = $talent_info["checkState"];
  879. if (!$talent_info) {
  880. return json(["msg" => "数据错误"]);
  881. }
  882. if ($checkState == TalentState::FST_SUBMIT) {
  883. return $this->baseSubmitCheck($talent_info);
  884. } else if ($checkState == TalentState::BASE_VERIFY_PASS) {
  885. return $this->baseReSubmitCheck($talent_info);
  886. } else if ($checkState == TalentState::SCND_SUBMIT) {
  887. return $this->fstSubmitCheck($talent_info);
  888. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  889. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  890. $companys = array_filter(explode(",", $condition["companyIds"]));
  891. if ($companys && $talent_info["pass_dept_check"] != 1) {
  892. if (!in_array($this->user["companyId"], $companys))
  893. return json(["msg" => "你的部门不在并审部门列表"]);
  894. return $this->deptSubmitCheck($talent_info, $companys);
  895. } else {
  896. return $this->reSubmitCheck($talent_info);
  897. }
  898. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  899. return $this->reSubmitCheck($talent_info);
  900. } else {
  901. return json(["msg" => "不在审核范围内,审核失败"]);
  902. }
  903. }
  904. public function validateIsCheck() {
  905. $params = $this->request->param();
  906. $id = $params["id"];
  907. $talent_info = VerifyApi::getOne($id);
  908. $fstLog = TalentLogApi::getFstLog($id, 1);
  909. $isMix = false;
  910. if (in_array($fstLog["state"], [TalentState::SCND_SAVE, TalentState::SCND_SUBMIT])) {
  911. //初次提交是待初审状态,则为新的混合基础信息和人才认证信息的申报
  912. $isMix = true;
  913. }
  914. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  915. if ($talent_info) {
  916. $checkState = $talent_info["checkState"];
  917. // 0正在填写 1保存未提交 2已提交未审核 3已审核 4驳回 5基审复核通过 6基审复核驳回 7基审复核失败 8保存补充材料未提交 9提交补充材料进入初审 10初审通过 11初审驳回 12部门审核通过 13部门审核驳回 14复核通过 15复核驳回 16复核失败
  918. $process = 0;
  919. if (in_array($checkState, [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_PASS, TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS])) {
  920. switch ($checkState) {
  921. case TalentState::FST_SUBMIT:
  922. $fields = DictApi::getTalentFields(1, $talent_info["isImport"]);
  923. $field_tmp = [];
  924. foreach ($fields as $key => $field) {
  925. $field_tmp[] = ["key" => $key, "value" => $field];
  926. }
  927. $where[] = ["project", "=", 1];
  928. $where[] = ["step", "=", 1];
  929. $where[] = ["active", "=", 1];
  930. $where[] = ["type", "=", $enterprise["type"]];
  931. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  932. /* foreach ($files as $key => $file) {
  933. $options = array_filter(explode(",", $file["option"]));
  934. if ($options) {
  935. switch ($file["rel"]) {
  936. case "talent_type":
  937. $allow_tags = array_filter(explode(",", $file["enterprise_tag"]));
  938. if ($allow_tags && !in_array($enterprise["enterpriseTag"], $allow_tags)) {
  939. unset($files[$key]);
  940. break;
  941. }
  942. if (!in_array($talent_info["talent_type"], $options)) {
  943. unset($files[$key]);
  944. break;
  945. }
  946. break;
  947. case "birthday":
  948. $birthYear = substr($talent_info["birthday"], 0, 4);
  949. $currentYear = date("Y");
  950. $age = $currentYear - $birthYear;
  951. if ($age < $options[0]) {
  952. unset($files[$key]);
  953. break;
  954. }
  955. break;
  956. }
  957. }
  958. } */
  959. $process = 1;
  960. break;
  961. case TalentState::BASE_VERIFY_PASS:
  962. $fields = DictApi::getTalentFields(1, $talent_info["isImport"]);
  963. $field_tmp = [];
  964. foreach ($fields as $key => $field) {
  965. $field_tmp[] = ["key" => $key, "value" => $field];
  966. }
  967. $where[] = ["project", "=", 1];
  968. $where[] = ["step", "=", 1];
  969. $where[] = ["active", "=", 1];
  970. $where[] = ["type", "=", $enterprise["type"]];
  971. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  972. $process = 2;
  973. break;
  974. case TalentState::SCND_SUBMIT:
  975. $fields = DictApi::getTalentFields(2, $talent_info["isImport"]);
  976. $process = 3;
  977. break;
  978. case TalentState::FST_VERIFY_PASS:
  979. $tc = TalentConditionApi::getOne($talent_info["talent_condition"]);
  980. if ($tc["companyIds"] && $talent_info["pass_dept_check"] != 1) {
  981. $process = 4;
  982. $fields = DictApi::getTalentFields(3, $talent_info["isImport"]);
  983. } else {
  984. $process = 5;
  985. $fields = DictApi::getTalentFields(2, $talent_info["isImport"]);
  986. }
  987. break;
  988. case TalentState::DEPT_VERIFY_PASS:
  989. $process = 5;
  990. $fields = DictApi::getTalentFields(2, $talent_info["isImport"]);
  991. break;
  992. }
  993. if ($isMix && $process != 4) {
  994. if ($enterprise["type"] == 2) {
  995. $fields = DictApi::getTalentFields_IC();
  996. } else {
  997. $fields = DictApi::getTalentFields(4, $talent_info["isImport"]);
  998. }
  999. }
  1000. if ($checkState != TalentState::FST_SUBMIT) {
  1001. //$fields = DictApi::getTalentFields(2);
  1002. $field_tmp = [];
  1003. if ($fields) {
  1004. foreach ($fields as $key => $field) {
  1005. $field_tmp[] = ["key" => $key, "value" => $field];
  1006. }
  1007. }
  1008. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  1009. $companys = array_filter(explode(",", $condition["companyIds"]));
  1010. $_companys = [];
  1011. foreach ($companys as $companyId) {
  1012. $company = CompanyApi::getOne($companyId);
  1013. $_companys[] = $company;
  1014. }
  1015. if ($process == 4 && $enterprise["type"] == 1) {
  1016. $where = [];
  1017. $where[] = ["delete", "=", 0];
  1018. $cwfts = explode(";", $condition["companyWithFileType"]);
  1019. foreach ($cwfts as $cwft) {
  1020. $_company_setting = explode(":", $cwft);
  1021. if ($_company_setting[0] == $this->user["companyId"]) {
  1022. $where[] = ["id", "in", explode(",", $_company_setting[1])];
  1023. break;
  1024. }
  1025. }
  1026. if ($where) {
  1027. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  1028. } else {
  1029. $files = [];
  1030. }
  1031. } else {
  1032. $where = [];
  1033. $whr = [];
  1034. if (!$isMix) {
  1035. $where[] = ["step", "=", 2];
  1036. }
  1037. $where[] = ["project", "=", 1];
  1038. $where[] = ["active", "=", 1];
  1039. $where[] = ["type", "=", $enterprise["type"]];
  1040. $where[] = ["isConditionFile", "<>", 1];
  1041. $where[] = ["delete", "=", 0];
  1042. if ($condition && $condition["bindFileTypes"]) {
  1043. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  1044. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->select();
  1045. } else {
  1046. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  1047. }
  1048. }
  1049. }
  1050. $talent_info["files"] = array_filter(explode(",", $talent_info["modify_files"]));
  1051. $talent_info["fields"] = array_filter(explode(",", $talent_info["modify_fields"]));
  1052. return json(["code" => 200, "obj" => ["process" => $process, "talentInfo" => $talent_info, "fieldList" => $field_tmp, "fileList" => $files, "companys" => $_companys]]);
  1053. } else {
  1054. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  1055. }
  1056. }
  1057. }
  1058. public function findFieldsAndFiles() {
  1059. }
  1060. public function fstVerifyListExport() {
  1061. $this->commonExport(3);
  1062. }
  1063. public function reVerifyListExport() {
  1064. $this->commonExport(5);
  1065. }
  1066. public function preListExport() {
  1067. $this->commonExport(6);
  1068. }
  1069. private function commonExport($process) {
  1070. $params = $this->request->param();
  1071. $fields = $params["export"];
  1072. if (!$fields)
  1073. return json(["msg" => "请选择要导出的数据"]);
  1074. $names = DictApi::getTalentFields(4);
  1075. $names["industryFieldNew"] = "产业领域";
  1076. $names["enterpriseName"] = "单位名称";
  1077. $names["enterpriseTag"] = "单位标签";
  1078. $names["street"] = "所属镇街";
  1079. $names["checkState"] = "审核状态";
  1080. $names["checkMsg"] = "审核意见";
  1081. $list = VerifyApi::getExportDatas($process, $fields);
  1082. foreach ($fields as $field) {
  1083. $columns[] = $names[$field];
  1084. }
  1085. $datas = [];
  1086. for ($i = 0; $i < count($list); $i++) {
  1087. $data = [];
  1088. for ($n = 0; $n < count($fields); $n++) {
  1089. $data[] = $list[$i][$fields[$n]];
  1090. }
  1091. $datas[] = $data;
  1092. }
  1093. if ($datas) {
  1094. export($columns, $datas);
  1095. exit();
  1096. }
  1097. echo "<script>parent.layer.alert('没有可以导出的数据');window.history.go(-1);</script>";
  1098. }
  1099. public function getPhones() {
  1100. $list = VerifyApi::getListByProcess($this->request->param("process"));
  1101. $result = [];
  1102. if ($list) {
  1103. foreach ($list as $item) {
  1104. if ($item["phone"] && $item["name"]) {
  1105. $result[] = sprintf("%s:%s", $item["name"], $item["phone"]);
  1106. }
  1107. }
  1108. }
  1109. return json(["code" => 200, "obj" => implode(";", $result)]);
  1110. }
  1111. public function getEnterprisePhones() {
  1112. $list = VerifyApi::getListByProcess($this->request->param("process"));
  1113. $result = [];
  1114. if ($list) {
  1115. foreach ($list as $item) {
  1116. if ($item["agentName"] && $item["agentPhone"]) {
  1117. $result[] = sprintf("%s:%s", $item["agentName"], $item["agentPhone"]);
  1118. }
  1119. }
  1120. }
  1121. return json(["code" => 200, "obj" => implode(";", $result)]);
  1122. }
  1123. }