AgentAttrsOnceByOrderJob.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * 描述.
  4. *
  5. * @author nj
  6. * @date 2021-08-02 12:21
  7. */
  8. namespace App\Jobs\Statistics;
  9. use App\Constants\PayConstant;
  10. use App\Models\Mysql\StatisticsPayModel;
  11. use App\Repositories\Statistics\StatisticsPayRepository;
  12. use Carbon\Carbon;
  13. use Illuminate\Bus\Queueable;
  14. use Illuminate\Contracts\Queue\ShouldQueue;
  15. use Illuminate\Foundation\Bus\Dispatchable;
  16. use Illuminate\Queue\InteractsWithQueue;
  17. use Illuminate\Queue\SerializesModels;
  18. use App\Models\Mysql\ChannelModel;
  19. class AgentAttrsOnceByOrderJob implements ShouldQueue
  20. {
  21. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  22. /**
  23. * 定义仓库.
  24. * @var null|StatisticsPayRepository
  25. */
  26. protected $repo = null;
  27. protected $logs = [];
  28. /**
  29. * Create a new job instance.
  30. *
  31. * @return void
  32. */
  33. public function __construct($logs = [])
  34. {
  35. $this->logs = $logs;
  36. }
  37. /**
  38. * Execute the job.
  39. *
  40. * @return void
  41. */
  42. public function handle()
  43. {
  44. if (!empty($this->logs)) {
  45. foreach ($this->logs as $log) {
  46. $this->getRepo()->updateAgentAttrsOnceByRootOrder($log['log_id'], $log['old_log']);
  47. }
  48. }
  49. }
  50. /**
  51. * 发送通知, 重新读取数据然后拼接数据,发送邮箱或者tg.
  52. */
  53. private function notify()
  54. {
  55. // Todo 发送通知, 重新读取数据然后拼接数据,发送邮箱或者tg.
  56. }
  57. /**
  58. * 获取仓库.
  59. * @return StatisticsPayRepository
  60. */
  61. private function getRepo()
  62. {
  63. if (!$this->repo instanceof StatisticsPayRepository) {
  64. $this->repo = new StatisticsPayRepository();
  65. }
  66. return $this->repo;
  67. }
  68. }