ExpireVerifyChecker.php 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. declare (strict_types=1);
  3. namespace app\command;
  4. use think\console\Command;
  5. use think\console\Input;
  6. use think\console\input\Argument;
  7. use think\console\input\Option;
  8. use think\console\Output;
  9. use think\facade\Db;
  10. use think\facade\Log;
  11. use app\enterprise\model\Talent;
  12. use app\common\api\TalentState;
  13. use app\common\api\MenuApi;
  14. use app\admin\model\SysRelation;
  15. use app\admin\model\User;
  16. /**
  17. * 人才认定过期检测
  18. */
  19. class ExpireVerifyChecker extends Command {
  20. protected function configure() {
  21. // 指令配置
  22. $this->setName('ExpireVerifyChecker')
  23. ->setDescription('Expire Verify Checker');
  24. }
  25. protected function execute(Input $input, Output $output) {
  26. $data["id"] = 2;
  27. $data["updateTime"] = date("Y-m-d H:i:s");
  28. Db::table("new_schedule")->save($data);exit();
  29. $where = [];
  30. $where[] = ["active", "=", 1];
  31. $where[] = ["type", "=", \app\common\state\ProjectState::TALENT];
  32. $batch = \app\common\model\Batch::where($where)->find();
  33. if ($batch && $batch["submitEndTime"] && strtotime($batch["submitEndTime"]) < time()) {
  34. //存在激活的批次,并且有设置提交截止时间,且已经超过截止时间,则检查此批次的申报是否存在尚在审批的申请(不包括通过复审的申请),全部以失败处置
  35. }
  36. $where[] = ["e.type", "=", 1];
  37. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  38. $where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
  39. $jjrc_count = Talent::alias("ti")
  40. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  41. ->leftJoin("(select mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  42. ->where($where)->count();
  43. $where = [];
  44. $where[] = ["e.type", "=", 2];
  45. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  46. $where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
  47. $ic_count = Talent::alias("ti")
  48. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  49. ->leftJoin("(select mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  50. ->where($where)->count();
  51. $codes = ["talentInfo_first"];
  52. $menuIds = MenuApi::getMenuIdsByCodes($codes);
  53. $where = [];
  54. $where[] = ["menuid", "in", $menuIds];
  55. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
  56. $where = [];
  57. $where[] = ["status", "=", 1];
  58. $where[] = ["roleid", "<>", 1];
  59. $regstr = ",(" . implode("|", $roleIds) . "),";
  60. $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
  61. $users = User::where($where)->whereRaw($whereRaw)->select();
  62. foreach ($users as $user) {
  63. switch ($user["type"]) {
  64. case 1:
  65. if ($jjrc_count > 0 && $user["phone"]) {
  66. queue("app\job\Messenger", ["type" => 2, "userId" => $user["id"], "name" => $user["name"], "phone" => $user["phone"], "count" => $jjrc_count]);
  67. }
  68. break;
  69. case 2:
  70. if ($ic_count > 0 && $user["phone"]) {
  71. queue("app\job\Messenger", ["type" => 2, "userId" => $user["id"], "name" => $user["name"], "phone" => $user["phone"], "count" => $ic_count]);
  72. }
  73. break;
  74. }
  75. }
  76. }
  77. }