SignReportJob.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace App\Jobs\GrowingIO;
  3. use App\Models\User\SignModel;
  4. use App\Models\User\UserModel;
  5. use Illuminate\Bus\Queueable;
  6. use Illuminate\Queue\SerializesModels;
  7. use Illuminate\Queue\InteractsWithQueue;
  8. use Illuminate\Contracts\Queue\ShouldQueue;
  9. use Illuminate\Foundation\Bus\Dispatchable;
  10. class SignReportJob extends BaseReportJob implements ShouldQueue
  11. {
  12. use Dispatchable;
  13. use InteractsWithQueue;
  14. use Queueable;
  15. use SerializesModels;
  16. /** @var SignModel */
  17. protected $sign;
  18. protected $platform;
  19. protected $user;
  20. public function __construct($sign, $platform)
  21. {
  22. $this->sign = $sign;
  23. $this->platform = $platform;
  24. }
  25. public function doHandle()
  26. {
  27. $this->user = UserModel::find($this->sign->uid);
  28. if (!$this->user) {
  29. return;
  30. }
  31. $this->doReport(self::SIGN, $this->sign->uid, [
  32. 'type' => $this->getType(),
  33. 'gender' => $this->getGender(),
  34. ]);
  35. }
  36. protected function getGender()
  37. {
  38. switch ($this->user->gender) {
  39. case 1:
  40. return '男性';
  41. case 2:
  42. return '女性';
  43. default:
  44. return '未知';
  45. }
  46. }
  47. protected function getType()
  48. {
  49. switch ($this->platform) {
  50. case "wx":
  51. return "小程序签到";
  52. case "qq":
  53. return "小程序签到";
  54. case "ios":
  55. return "APP签到";
  56. case "android":
  57. return "APP签到";
  58. }
  59. }
  60. }