Talent.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. namespace app\job;
  3. use think\queue\Job;
  4. use think\facade\Log;
  5. use think\facade\Db;
  6. use app\common\api\ChuanglanSmsApi;
  7. use app\common\model\MessageRecord;
  8. use app\common\api\TalentLogApi;
  9. use app\common\api\TalentConditionApi;
  10. use app\common\api\TalentState;
  11. use app\enterprise\model\Talent as TalentModel;
  12. /**
  13. * Description of Talent
  14. *
  15. * @author sgq
  16. */
  17. class Talent {
  18. public function fire(Job $job, $data) {
  19. if ($this->deal($data)) {
  20. $job->delete();
  21. return true;
  22. }
  23. if ($job->attempts() >= 3) {
  24. $job->delete();
  25. return false;
  26. }
  27. $job->release(10); //10秒后重试
  28. }
  29. /**
  30. * 处理业务逻辑
  31. * @param type $data
  32. * @return bool
  33. */
  34. public function deal($data): bool {
  35. switch ($data["type"]) {
  36. case 1:
  37. //部门超时驳回
  38. $mainId = $data["id"];
  39. $where[] = ["ti.id", "=", $mainId];
  40. $where[] = ["ti.checkState", "=", TalentState::FST_VERIFY_PASS];
  41. $where[] = ["ti.pass_dept_check", "=", 0];
  42. $talent_info = TalentModel::alias("ti")
  43. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  44. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  45. ->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")
  46. ->where($where)->field("ti.*,tc.companyIds,tc.companyWithFileType")->find();
  47. if ($talent_info) {
  48. $weekDay = date("w"); //0周日,6周六
  49. if ($weekDay == 6) {
  50. $delay = 2 * 24 * 3600;
  51. queue("app\job\Talent", ["type" => 1, "id" => $mainId], $delay);
  52. return true;
  53. }
  54. if (!$weekDay || $weekDay == 0) {
  55. $delay = 1 * 24 * 3600;
  56. queue("app\job\Talent", ["type" => 1, "id" => $mainId], $delay);
  57. return true;
  58. }
  59. $modify_files = array_filter(explode(",", $talent_info["modify_files"]));
  60. $companyAndTypes = [];
  61. $companyWithFileType = array_filter(explode(";", $talent_info["companyWithFileType"]));
  62. foreach ($companyWithFileType as $c) {
  63. list($companyId, $fileTypesStr) = array_filter(explode(":", $c));
  64. $companyAndTypes[$companyId] = array_filter(explode(",", $fileTypesStr));
  65. }
  66. $companyIds = array_filter(explode(",", $talent_info["companyIds"]));
  67. if ($companyIds) {
  68. if ($talent_info["re_check_companys"]) {
  69. $unpass_companyIds = array_filter(explode(",", $talent_info["re_check_companys"]));
  70. } else {
  71. //这边去除已经审核通过的单位,主要通过日志是否存在记录。
  72. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  73. $unpass_companyIds = array_diff($companyIds, (array) $pass_companyIds); //排除已经通过的单位
  74. }
  75. if (!$unpass_companyIds) {
  76. //没有未审部门
  77. return true;
  78. }
  79. //开始驳回操作
  80. $fst_dept_check_time = $talent_info["first_dept_check_time"];
  81. $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
  82. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  83. foreach ($unpass_companyIds as $companyId) {
  84. $fileTypes = $companyAndTypes[$companyId];
  85. $modify_files = array_unique((array_merge((array) $modify_files, (array) $fileTypes)));
  86. $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $companyId, $fst_dept_check_time);
  87. TalentLogApi::rewrite($dept_log["id"], [$log_checkState, $checkState], "审核超时,系统自动驳回", 1);
  88. }
  89. $log_checkState = TalentState::DEPT_VERIFY_REJECT;
  90. $data["id"] = $talent_info["id"];
  91. $data["modify_files"] = implode(",", $modify_files);
  92. $data["checkState"] = $checkState;
  93. $data["first_dept_check_time"] = null;
  94. $data["re_check_companys"] = null;
  95. TalentModel::update($data);
  96. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], "审核超时,系统自动驳回,部门审核结束", 1);
  97. }
  98. return true;
  99. }
  100. break;
  101. }
  102. return false;
  103. }
  104. }