IntegralVerify.php 54 KB

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