IntegralVerify.php 46 KB

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