Browse Source

部门审核短信、复审短信配置(未加入计划表)

sugangqiang 2 years ago
parent
commit
9f7bd52ec3
4 changed files with 104 additions and 4 deletions
  1. 3 2
      app/command/DeptVerifyChecker.php
  2. 60 0
      app/command/ReVerifyChecker.php
  3. 40 2
      app/job/Messenger.php
  4. 1 0
      config/console.php

+ 3 - 2
app/command/DeptVerifyChecker.php

@@ -24,8 +24,8 @@ class DeptVerifyChecker extends Command {
 
 
     protected function configure() {
     protected function configure() {
         // 指令配置
         // 指令配置
-        $this->setName('RegisterMessenger')
-                ->setDescription('Auto send msg');
+        $this->setName('DeptVerifyChecker')
+                ->setDescription('Dept Verify Checker');
     }
     }
 
 
     protected function execute(Input $input, Output $output) {
     protected function execute(Input $input, Output $output) {
@@ -52,6 +52,7 @@ class DeptVerifyChecker extends Command {
         $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
         $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
         foreach ($jjrc_counts as $companyId => $count) {
         foreach ($jjrc_counts as $companyId => $count) {
             $where = [];
             $where = [];
+            $where[] = ["type", "=", 1];
             $where[] = ["status", "=", 1];
             $where[] = ["status", "=", 1];
             $where[] = ["roleid", "<>", 1];
             $where[] = ["roleid", "<>", 1];
             $where[] = ["companyId", "=", $companyId];
             $where[] = ["companyId", "=", $companyId];

+ 60 - 0
app/command/ReVerifyChecker.php

@@ -0,0 +1,60 @@
+<?php
+
+declare (strict_types=1);
+
+namespace app\command;
+
+use think\console\Command;
+use think\console\Input;
+use think\console\input\Argument;
+use think\console\input\Option;
+use think\console\Output;
+use think\facade\Db;
+use think\facade\Log;
+use app\common\api\TalentState;
+use app\enterprise\model\Talent;
+use app\common\api\MenuApi;
+use app\admin\model\SysRelation;
+use app\admin\model\User;
+
+/**
+ * 复审检查
+ */
+class ReVerifyChecker extends Command {
+
+    protected function configure() {
+        // 指令配置
+        $this->setName('ReVerifyChecker')
+                ->setDescription('ReVerify Checker');
+    }
+
+    protected function execute(Input $input, Output $output) {
+        $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 = ''))");
+        $where[] = ["ti.checkState", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
+        $list = Talent::alias("ti")
+                        ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
+                        ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
+                        ->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")
+                        ->where($where)->whereRaw($whereRaw)->group("e.type")->field("count(*) as count,e.type")->select()->toArray();
+        $codes = ["talentInfo_third"];
+        $menuIds = MenuApi::getMenuIdsByCodes($codes);
+        $where = [];
+        $where[] = ["menuid", "in", $menuIds];
+        $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
+        foreach ($list as $item) {
+            $where = [];
+            $where[] = ["type", "=", $item["type"]];
+            $where[] = ["status", "=", 1];
+            $where[] = ["roleid", "<>", 1];
+            $regstr = ",(" . implode("|", $roleIds) . "),";
+            $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
+            $users = User::where($where)->whereRaw($whereRaw)->select()->toArray();
+            foreach ($users as $user) {
+                if ($item["count"] > 0 && $user["phone"]) {
+                    queue("app\job\Messenger", ["type" => 4, "userId" => $user["id"], "name" => $user["name"], "phone" => $user["phone"], "count" => $item["count"]]);
+                }
+            }
+        }
+    }
+
+}

+ 40 - 2
app/job/Messenger.php

@@ -17,11 +17,9 @@ class Messenger {
 
 
     public function fire(Job $job, $data) {
     public function fire(Job $job, $data) {
         if ($this->deal($data)) {
         if ($this->deal($data)) {
-            Log::info(json_encode($data));
             $job->delete();
             $job->delete();
             return true;
             return true;
         }
         }
-        Log::error(json_encode($data));
         if ($job->attempts() >= 3) {
         if ($job->attempts() >= 3) {
             $job->delete();
             $job->delete();
             return false;
             return false;
@@ -71,6 +69,8 @@ class Messenger {
                     MessageRecord::create($record_data);
                     MessageRecord::create($record_data);
                     return true;
                     return true;
                 } catch (\think\Exception $e) {
                 } catch (\think\Exception $e) {
+                    Log::error(json_encode($data));
+                    Log::error($e->getMessage());
                     return false;
                     return false;
                 }
                 }
                 break;
                 break;
@@ -105,6 +105,44 @@ class Messenger {
                     MessageRecord::create($record_data);
                     MessageRecord::create($record_data);
                     return true;
                     return true;
                 } catch (\think\Exception $e) {
                 } catch (\think\Exception $e) {
+                    Log::error(json_encode($data));
+                    Log::error($e->getMessage());
+                    return false;
+                }
+                break;
+            case 4:
+                //通知人才申报复审人员
+                try {
+                    $userId = $data["userId"];
+                    $name = $data["name"];
+                    $phone = $data["phone"];
+                    $count = $data["count"];
+                    $template = sprintf("【晋江市人才服务平台】您的部门有%d条人才认定申报记录待复审,请及时登录审批系统处理。", $count);
+                    $smsapi = new ChuanglanSmsApi();
+                    $result = $smsapi->sendSMS($phone, $template);
+                    $result = json_decode($result, true);
+                    $id = getStringId();
+                    $record_data = [
+                        'id' => $id,
+                        'userId' => $userId,
+                        'bizId' => $result["msgId"],
+                        'type' => 1,
+                        'smsType' => 2,
+                        'name' => $name,
+                        'phone' => $phone,
+                        'params' => "复审",
+                        'templateCode' => $template,
+                        'state' => $result['code'] == 0 ? 2 : 3,
+                        'sendingDate' => date("Y-m-d H:i:s", time()),
+                        'createTime' => date("Y-m-d H:i:s", time()),
+                        'msg' => $result['errorMsg']
+                    ];
+
+                    MessageRecord::create($record_data);
+                    return true;
+                } catch (\think\Exception $e) {
+                    Log::error(json_encode($data));
+                    Log::error($e->getMessage());
                     return false;
                     return false;
                 }
                 }
                 break;
                 break;

+ 1 - 0
config/console.php

@@ -10,6 +10,7 @@ return [
         "FstVerifyChecker" => "app\command\FstVerifyChecker", //人才认定初审阶段检查
         "FstVerifyChecker" => "app\command\FstVerifyChecker", //人才认定初审阶段检查
         "RegisterMessenger" => "app\command\RegisterMessenger", //注册短信提醒后台审核
         "RegisterMessenger" => "app\command\RegisterMessenger", //注册短信提醒后台审核
         "DeptVerifyChecker" => "app\command\DeptVerifyChecker", //人才认定部门审核阶段检查
         "DeptVerifyChecker" => "app\command\DeptVerifyChecker", //人才认定部门审核阶段检查
+        "ReVerifyChecker" => "app\command\ReVerifyChecker", //人才认定复审阶段检查
         "ExpireVerifyChecker" => "app\command\ExpireVerifyChecker", //人才认定过期检查
         "ExpireVerifyChecker" => "app\command\ExpireVerifyChecker", //人才认定过期检查
     ],
     ],
 ];
 ];