IntegralVerify.php 40 KB

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