ExpireVerifyChecker.php 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. $where = [];
  27. $where[] = ["active","=",1];
  28. $where[] = ["type","=", \app\common\state\ProjectState::TALENT];
  29. $batch = \app\common\model\Batch::where($where)->find();
  30. if($batch && $batch["submitEndTime"] && strtotime($batch["submitEndTime"]) < time()){
  31. //存在激活的批次,并且有设置提交截止时间,且已经超过截止时间,则检查此批次的申报是否存在尚在审批的申请(不包括通过复审的申请),全部以失败处置
  32. }
  33. $where[] = ["e.type", "=", 1];
  34. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  35. $where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
  36. $jjrc_count = Talent::alias("ti")
  37. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  38. ->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")
  39. ->where($where)->count();
  40. $where = [];
  41. $where[] = ["e.type", "=", 2];
  42. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  43. $where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
  44. $ic_count = Talent::alias("ti")
  45. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  46. ->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")
  47. ->where($where)->count();
  48. $codes = ["talentInfo_first"];
  49. $menuIds = MenuApi::getMenuIdsByCodes($codes);
  50. $where = [];
  51. $where[] = ["menuid", "in", $menuIds];
  52. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
  53. $where = [];
  54. $where[] = ["status", "=", 1];
  55. $where[] = ["roleid", "<>", 1];
  56. $regstr = ",(" . implode("|", $roleIds) . "),";
  57. $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
  58. $users = User::where($where)->whereRaw($whereRaw)->select();
  59. foreach ($users as $user) {
  60. switch ($user["type"]) {
  61. case 1:
  62. if ($jjrc_count > 0 && $user["phone"]) {
  63. queue("app\job\Messenger", ["type" => 2, "userId" => $user["id"], "name" => $user["name"], "phone" => $user["phone"], "count" => $jjrc_count]);
  64. }
  65. break;
  66. case 2:
  67. if ($ic_count > 0 && $user["phone"]) {
  68. queue("app\job\Messenger", ["type" => 2, "userId" => $user["id"], "name" => $user["name"], "phone" => $user["phone"], "count" => $ic_count]);
  69. }
  70. break;
  71. }
  72. }
  73. }
  74. }