抖音小程序

AdService.php 703B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace App\Service;
  3. use App\Models\AdPlacement;
  4. use App\Support\DouYinApi;
  5. class AdService
  6. {
  7. public static function getAdPlacement($appId, $type) {
  8. list($list, $count) = AdPlacement::searchData([
  9. 'app_id' => $appId, 'status' => 1, 'type' => $type], 1, 1);
  10. if(0 == $count) { return '';}
  11. $adPlacementInfo = $list->first();
  12. return $adPlacementInfo->ad_placement_id ?? '';
  13. }
  14. public static function syncAdPlacement($appId) {
  15. $response = DouYinApi::syncAdPlacement($appId);
  16. if(!empty($response)) {
  17. return AdPlacement::saveData($appId, $response['ad_placement_list']);
  18. }
  19. return false;
  20. }
  21. }