| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace App\Jobs;
- use App\Repositories\Service\CommonService;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldBeUnique;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Bus\Dispatchable;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Queue\SerializesModels;
- use Modules\Api\Services\ConfigService;
- class SendTgMegJob implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- public $params;
- public $name;
- public $message;
- /**
- * Create a new job instance.
- *
- * @return void
- */
- public function __construct($name,$message,$params)
- {
- $this->name = $name;
- $this->params = $params;
- $this->message = $message;
- }
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle()
- {
- $configService = make(ConfigService::class);
- $tgMsgServer = $configService->getValue('tg_msg_server');
- $tgApiToken = $configService->getValue('tg_api_token');
- if ($tgMsgServer && $tgApiToken) {
- $content = json_encode($this->params,JSON_UNESCAPED_UNICODE);
- make(CommonService::class)->httpPost(
- [
- 'name' => $this->name,
- 'message' => $this->message,
- 'content'=>$content,
- 'title' => '支付中心'
- ],
- $tgMsgServer . 'api/tg/send/message',
- ['AUTH-TOKEN' => $tgApiToken]);
- }
- }
- }
|