googleOAuthService->getGoogleAdCustomers($options); // dump($customers); foreach ($customers as $customer) { if ($customer['login_customer_id'] > 0) { Redis::send($queue, $customer,rand(5,15)); Redis::send($video_queue, $customer,rand(5,15)); } } return self::event.' send queue ok'; } public function syncDateRangeAssetRelations($options = []) { // 获取 startDate 和 endDate $startDate = $options['startDate']; $endDate = $options['endDate']; // 验证日期格式 if (!strtotime($startDate) || !strtotime($endDate)) { throw new \InvalidArgumentException('Invalid date format for startDate or endDate'); } // 将日期转换为 DateTime 对象 $startDate = new \DateTime($startDate); $endDate = new \DateTime($endDate); $queue = self::queue; $video_queue = self::video_queue; $customers = $this->googleOAuthService->getGoogleAdCustomers($options); // dump($customers); // 遍历每一天的日期 $interval = new \DateInterval('P1D'); // 1天间隔 $dateRange = new \DatePeriod($startDate, $interval, $endDate->modify('+1 day')); // 包含 endDate foreach ($dateRange as $date) { $currentDate = $date->format('Y-m-d'); // 格式化日期为 Y-m-d // 遍历每个客户 foreach ($customers as $customer) { if ($customer['login_customer_id'] > 0) { $customer['date'] = $currentDate; // 设置当前日期 Redis::send($queue, $customer, rand(10, 25)); Redis::send($video_queue, $customer, rand(10, 25)); } } } return self::event.' send queue ok'; } /** * get asset relations * @throws ApiException */ public function getAssetRelations($customer) { if ($customer['login_customer_id'] > 0) { $googleAdsAssetRelationService = new GoogleAdsAssetRelationService($customer['customer_id']); $resourceName = $googleAdsAssetRelationService->runListAssetRelations($customer['customer_id'],$customer['date']); } // return $this->successResponse(['ads_list' => $resourceName]); } /** * get asset relations * @throws ApiException */ public function getVideoAssetRelations($customer) { $googleAdsAssetRelationService = new GoogleAdsAssetRelationService($customer['customer_id']); $resourceName = $googleAdsAssetRelationService->runListVideoAssetRelations($customer['customer_id']); // return $this->successResponse(['ads_list' => $resourceName]); } // 可以加入一些公共方法 protected function successResponse($data): Response { return Json([ 'code' => 0, 'msg' => 'ok', 'data' => $data, ]); } protected function errorResponse($code, $message, $data = []): Response { return Json([ 'code' => $code, 'msg' => $message ?: 'error', 'data' => $data ]); } }