option('task_ids'); $taskIdArr = null; if($task_ids) { $taskIdArr = explode(',', trim($task_ids, ',')); } DB::table('video_series_wechat_check') ->whereIn('sync_status', [1,2]) ->where('sync_task_id', '<>', '') ->where('is_enabled', 1) ->when($taskIdArr, function ($query, $taskIdArr) { return $query->whereIn('sync_task_id', $taskIdArr); })->orderBy('id') ->chunk(100, function ($items) { $now = date('Y-m-d H:i:s'); foreach ($items as $item) { $taskInfo = $this->getTask($item); if($taskInfo && 1 == $taskInfo['task_type']) { if(in_array($taskInfo['status'], [3,4])) { DB::table('video_series_wechat_check') ->where(['id' => $item->id]) ->update([ 'status' => $taskInfo['status'], 'remark' => $taskInfo['errmsg'] ?? '', 'media_id' => $taskInfo['media_id'] ?? '', 'updated_at' => $now, 'sync_task_info' => \json_encode($taskInfo), ]); } } } }); } private function getTask($syncInfo) { $appid = $syncInfo->appid ?: config('wechat.duanju.masterAppid'); $accessToken = Redis::get(AccessTokenService::getAccessTokenRedisKey($appid)); $parsedContent = HttpRequestService::simplePost(WechatURL::vod_gettask . $accessToken, [ 'task_id' => $syncInfo->sync_task_id ]); if(false === $parsedContent || (0 != $parsedContent['errcode'] ?? 0)) { return $parsedContent['task_info']; } else { myLog('GetTaskInfo')->error('拉取上传短剧任务查询失败', [ 'task_id' => $syncInfo->sync_task_id, 'appid' => $appid, 'result' => $parsedContent, ]); return []; } } }