IntegralVerify.php 42 KB

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