ReVerifyChecker.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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("(tl.state in (14,15,16)) or (tl.state=12 and ti.pass_dept_check=0) or (tl.state=10 and ti.pass_dept_check=1) or (tl.state=10 and (tc.companyIds is null or tc.companyIds = ''))");
  27. //$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 = ''))");
  28. $where[] = ["ti.checkState", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  29. $where[] = ["e.type", "=", 1]; //只对晋江人才相关部门发送短信
  30. $list = Talent::alias("ti")
  31. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  32. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  33. ->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")
  34. ->where($where)->whereRaw($whereRaw)->group("e.type")->field("count(*) as count,e.type")->select()->toArray();
  35. $codes = ["talentInfo_thirdCheck"];
  36. $menuIds = MenuApi::getMenuIdsByCodes($codes);
  37. $where = [];
  38. $where[] = ["menuid", "in", $menuIds];
  39. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
  40. foreach ($list as $item) {
  41. $where = [];
  42. $where[] = ["type", "=", $item["type"]];
  43. $where[] = ["status", "=", 1];
  44. $where[] = ["roleid", "<>", 1];
  45. $regstr = ",(" . implode("|", $roleIds) . "),";
  46. $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
  47. $users = User::where($where)->whereRaw($whereRaw)->select()->toArray();
  48. foreach ($users as $user) {
  49. if ($item["count"] > 0 && $user["phone"]) {
  50. queue("app\job\Messenger", ["type" => 4, "userId" => $user["id"], "name" => $user["name"], "phone" => $user["phone"], "count" => $item["count"]]);
  51. }
  52. }
  53. }
  54. }
  55. }