FstVerifyChecker.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 FstVerifyChecker extends Command {
  20. protected function configure() {
  21. // 指令配置
  22. $this->setName('FstVerifyChecker')
  23. ->setDescription('First Verify Checker');
  24. }
  25. protected function execute(Input $input, Output $output) {
  26. $where[] = ["e.type", "=", 1];
  27. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  28. $where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
  29. $jjrc_count = Talent::alias("ti")
  30. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  31. ->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")
  32. ->where($where)->count();
  33. $where = [];
  34. $where[] = ["e.type", "=", 2];
  35. $where[] = ["ti.checkState", "=", TalentState::SCND_SUBMIT];
  36. $where[] = ["tl.state", "in", [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];
  37. $ic_count = Talent::alias("ti")
  38. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  39. ->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")
  40. ->where($where)->count();
  41. $codes = ["talentInfo_firstCheck"];
  42. $menuIds = MenuApi::getMenuIdsByCodes($codes);
  43. $where = [];
  44. $where[] = ["menuid", "in", $menuIds];
  45. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
  46. $where = [];
  47. $where[] = ["status", "=", 1];
  48. $where[] = ["roleid", "<>", 1];
  49. $regstr = ",(" . implode("|", $roleIds) . "),";
  50. $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
  51. $users = User::where($where)->whereRaw($whereRaw)->select();
  52. foreach ($users as $user) {
  53. switch ($user["type"]) {
  54. case 1:
  55. if ($jjrc_count > 0 && $user["phone"]) {
  56. queue("app\job\Messenger", ["type" => 2, "userId" => $user["id"], "name" => $user["name"], "phone" => $user["phone"], "count" => $jjrc_count]);
  57. }
  58. break;
  59. case 2:
  60. if ($ic_count > 0 && $user["phone"]) {
  61. //电路先不发短信
  62. //queue("app\job\Messenger", ["type" => 2, "userId" => $user["id"], "name" => $user["name"], "phone" => $user["phone"], "count" => $ic_count]);
  63. }
  64. break;
  65. }
  66. }
  67. }
  68. }