123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- namespace App\Jobs\Video;
- use App\Service\Miniprogram\Wechat\AccessTokenService;
- use App\Service\Util\Support\Http\WechatURL;
- use App\Service\Util\Support\Trace\TraceContext;
- use App\Service\Util\Support\Http\HttpRequestService;
- use GuzzleHttp\Psr7\Utils;
- 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 Illuminate\Support\Arr;
- use Illuminate\Support\Facades\Redis;
- use Predis\Command\Traits\DB;
- class WechatCheck implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- private $info;
- /**
- * Create a new job instance.
- */
- public function __construct($info)
- {
- $this->info = $info;
- }
- /**
- * Execute the job.
- */
- public function handle(): void
- {
- myLog('wechatCheck')->info('开始处理微信提审', [
- 'info' => $this->info
- ]);
- $traceContext = TraceContext::newFromParent($this->info['traceInfo']);
- $id = $this->info['id'];
- $record = DB::table('video_wechat_check')
- ->join('videos', 'videos.id', 'video_wechat_check.video_id')
- ->where(['video_wechat_check.id' => $id,
- 'video_wechat_check.is_enabled' => 1, 'video_wechat_check.status' => 0])
- ->select('video_wechat_check.*', 'videos.name as video_name', 'videos.cover_image as video_cover_image')
- ->first();
- if(!$record) {
- myLog('WechatCheck')->info('当前状态不支持提审', [
- 'traceInfo' => $traceContext->getTraceInfo()
- ]);
- return;
- }
- $accessToken = Redis::get(AccessTokenService::getAccessTokenRedisKey($record->appid ?:
- config('wechat.duanju.masterAppid')));
- $medias = DB::table('video_series_wechat_check')
- ->where('video_id', $record->video_id)
- ->where(['sync_status' => 4, 'is_enabled' => 1])
- ->where('media_id', '<>', 0)
- ->get();
- $cover_material_id = $this->getMaterialId($record->video_cover_image, $accessToken);
- $authorized_material_id = $this->getMaterialId($record->authorized_img, $accessToken);
- $publish_license_material_id = $this->getMaterialId($record->production_license_img, $accessToken);
- $postData = [
- 'name' => $record->video_name,
- 'media_count' => $medias->count(),
- 'media_id_list' => $medias->pluck('media_id')->toArray(),
- 'producer' => $record->producer,
- 'cover_material_id' =>$cover_material_id,
- 'authorized_material_id' => $authorized_material_id,
- 'publish_license' => $record->publish_license,
- ''
- ];
- if($record->drama_id) {
- $postData['drama_id'] = $record->drama_id;
- }
- HttpRequestService::simplePost(WechatURL::vod_auditdrama . $accessToken, );
- }
- public function getMaterialId($url, $accessToken){
- $result = HttpRequestService::post(WechatURL::media_upload. $accessToken, [
- 'multipart' => [
- [
- 'name' => 'type',
- 'contents' => 'image',
- ],
- [
- 'name' => 'media',
- 'contents' => file_get_contents($url),
- 'filename' => Arr::last(explode('/', $url)),
- ]
- ]
- ]);
- return $result;
- }
- }
|