AgentAttrsOnceByNewUserJob.php 1.8 KB

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