ReVerifyChecker.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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\common\api\TalentState;
  12. use app\enterprise\model\Talent;
  13. use app\common\api\MenuApi;
  14. use app\admin\model\SysRelation;
  15. use app\admin\model\User;
  16. /**
  17. * 复审检查
  18. */
  19. class ReVerifyChecker extends Command {
  20. protected function configure() {
  21. // 指令配置
  22. $this->setName('ReVerifyChecker')
  23. ->setDescription('ReVerify Checker');
  24. }
  25. protected function execute(Input $input, Output $output) {
  26. $whereRaw = sprintf("(ti.checkState in (14,15,16)) or (ti.checkState=12 and ti.pass_dept_check=0) or (ti.checkState=10 and ti.pass_dept_check=1) or (ti.checkState=10 and (tc.companyIds is null or tc.companyIds = ''))");
  27. $where[] = ["ti.checkState", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  28. $list = Talent::alias("ti")
  29. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  30. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  31. ->leftJoin("(select description,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")
  32. ->where($where)->whereRaw($whereRaw)->group("e.type")->field("count(*) as count,e.type")->select()->toArray();
  33. $codes = ["talentInfo_third"];
  34. $menuIds = MenuApi::getMenuIdsByCodes($codes);
  35. $where = [];
  36. $where[] = ["menuid", "in", $menuIds];
  37. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
  38. foreach ($list as $item) {
  39. $where = [];
  40. $where[] = ["type", "=", $item["type"]];
  41. $where[] = ["status", "=", 1];
  42. $where[] = ["roleid", "<>", 1];
  43. $regstr = ",(" . implode("|", $roleIds) . "),";
  44. $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
  45. $users = User::where($where)->whereRaw($whereRaw)->select()->toArray();
  46. foreach ($users as $user) {
  47. if ($item["count"] > 0 && $user["phone"]) {
  48. queue("app\job\Messenger", ["type" => 4, "userId" => $user["id"], "name" => $user["name"], "phone" => $user["phone"], "count" => $item["count"]]);
  49. }
  50. }
  51. }
  52. }
  53. }