SendTgWithdrawMegJob.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace App\Jobs;
  3. use App\Repositories\ConfigRepoistory;
  4. use GuzzleHttp\Client;
  5. use Illuminate\Bus\Queueable;
  6. use Illuminate\Contracts\Queue\ShouldQueue;
  7. use Illuminate\Foundation\Bus\Dispatchable;
  8. use Illuminate\Queue\InteractsWithQueue;
  9. use Illuminate\Queue\SerializesModels;
  10. use Modules\InnerApi\Services\CommonService;
  11. class SendTgWithdrawMegJob implements ShouldQueue
  12. {
  13. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  14. public $platform;
  15. public $uid;
  16. public $user;
  17. public $type;
  18. public $amount;
  19. public $date;
  20. /**
  21. * @param $uid
  22. * @param $user
  23. * @param $type
  24. * @param $amount
  25. * @param $date
  26. */
  27. public function __construct($uid, $user, $type, $amount, $date)
  28. {
  29. // 这里最好是普通数据,不要使用携带 IO 的对象,比如 PDO 对象
  30. $this->uid = $uid;
  31. $this->user = $user;
  32. $this->type = $type;
  33. $this->amount = $amount;
  34. $this->date = $date;
  35. }
  36. public function handle()
  37. {
  38. $configRepo = make(ConfigRepoistory::class);
  39. $tgMsgServer = $configRepo->get('tg_msg_server', 'sys');
  40. $tgApiToken = $configRepo->get('tg_api_token', 'sys');
  41. if ($tgMsgServer && $tgApiToken) {
  42. $type = '未知';
  43. if ($this->type == 1) {
  44. $type = '银行卡';
  45. } elseif ($this->type == 2) {
  46. $type = 'USDT';
  47. } elseif ($this->type == 3) {
  48. $type = '支付宝';
  49. }
  50. $commonService = new Client();
  51. $commonService->request(
  52. 'POST',
  53. $tgMsgServer . 'api/tg/send/withdraw/message',
  54. [
  55. 'json' => [
  56. 'uid' => $this->uid,
  57. 'user' => $this->user,
  58. 'type_name' => $type,
  59. 'amount' => $this->amount,
  60. 'date' => $this->date,
  61. ],
  62. 'headers' => ['AUTH-TOKEN' => $tgApiToken]
  63. ],
  64. );
  65. }
  66. }
  67. }