TestJob.php 679 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace crmeb\jobs;
  3. use app\models\user\User;
  4. use crmeb\interfaces\JobInterface;
  5. use think\facade\Db;
  6. use think\queue\Job;
  7. class TestJob implements JobInterface
  8. {
  9. public function fire(Job $job, $data): void
  10. {
  11. $job->delete();
  12. if($this->doHelloJob($data))
  13. $job->delete();
  14. else {
  15. if ($job->attempts() > 3)
  16. $job->delete();
  17. }
  18. }
  19. public function doHelloJob($data)
  20. {
  21. [$order, $formId] = $data;
  22. Db::name('cache')->insert(['key'=>'test_'.rand(10,20),'result'=>json_encode($order)]);
  23. // event('OrderPaySuccess', [$order, $formId]);
  24. return true;
  25. }
  26. }