Browse Source

Google ads account

wfansh 3 months ago
parent
commit
d9963bf484

+ 10 - 9
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/marketing/googleads/service/GoogleAdsReportService.java

@@ -74,7 +74,7 @@ public class GoogleAdsReportService {
                             + TTLCacheManager.TTL_SPLITTER
                             + 60 * 5) // Redis TTL为5分钟
     public CustomerStatsVO getCustomerStats(String siteCode) {
-        GoogleAds googleAds = this.getGoogleAds(siteCode);
+        GoogleAds googleAds = this.getAdsAccount(siteCode);
         if (StringUtils.isBlank(googleAds.getCustomerId())) {
             log.info("Google Ads帐号未配置, siteCode = {}", siteCode);
             return new CustomerStatsVO(); // @Cacheable方法不允许返回null,返回CustomerStatsVO默认值
@@ -82,7 +82,7 @@ public class GoogleAdsReportService {
 
         // 1. 创建API request
         OpenAPIRequest<ReportRequestDTO> openAPIRequest =
-                this.buildAPIRequest(googleAds, null, null, 1);
+                this.buildAPIRequest(googleAds, null, null, 1); // limit值无效
 
         // 2. 请求API接口
         OpenAPIResponse<CustomerStatsDTO> openAPIResponse =
@@ -104,7 +104,7 @@ public class GoogleAdsReportService {
                             + TTLCacheManager.TTL_SPLITTER
                             + 60 * 5) // Redis TTL为5分钟
     public List<DailyStatsVO> getDailyStats(String siteCode, Date start, Date end) {
-        GoogleAds googleAds = this.getGoogleAds(siteCode);
+        GoogleAds googleAds = this.getAdsAccount(siteCode);
         if (StringUtils.isBlank(googleAds.getCustomerId())) {
             log.info("Google Ads帐号未配置, siteCode = {}", siteCode);
             return Collections.EMPTY_LIST;
@@ -113,7 +113,8 @@ public class GoogleAdsReportService {
         final int limit = 365; // 最多365天
 
         // 0. 起止日期为空时(如 全部时间),返回最近limit天数据
-        // - buildAPIRequest()方法设置无限早start,返回最早limit天数据,不符合预期
+        // - buildAPIRequest()方法设置无限早start,返回最早limit天        // -
+        // buildAPIRequest()方法设置无限早start,返回最早limit天数据,不符合预期数据,不符合预期
         if (Objects.isNull(end)) {
             end = new Date();
         }
@@ -149,7 +150,7 @@ public class GoogleAdsReportService {
                             + TTLCacheManager.TTL_SPLITTER
                             + 60 * 5) // Redis TTL为5分钟
     public List<CampaignStatsVO> getCampaignStats(String siteCode, Date start, Date end) {
-        GoogleAds googleAds = this.getGoogleAds(siteCode);
+        GoogleAds googleAds = this.getAdsAccount(siteCode);
         if (StringUtils.isBlank(googleAds.getCustomerId())) {
             log.info("Google Ads帐号未配置, siteCode = {}", siteCode);
             return Collections.EMPTY_LIST;
@@ -183,7 +184,7 @@ public class GoogleAdsReportService {
                             + TTLCacheManager.TTL_SPLITTER
                             + 60 * 5) // Redis TTL为5分钟
     public List<KeywordStatsVO> getKeywordStats(String siteCode, Date start, Date end) {
-        GoogleAds googleAds = this.getGoogleAds(siteCode);
+        GoogleAds googleAds = this.getAdsAccount(siteCode);
         if (StringUtils.isBlank(googleAds.getCustomerId())) {
             log.info("Google Ads帐号未配置, siteCode = {}", siteCode);
             return Collections.EMPTY_LIST;
@@ -217,7 +218,7 @@ public class GoogleAdsReportService {
                             + TTLCacheManager.TTL_SPLITTER
                             + 60 * 5) // Redis TTL为5分钟
     public List<PlacementStatsVO> getPlacementStats(String siteCode, Date start, Date end) {
-        GoogleAds googleAds = this.getGoogleAds(siteCode);
+        GoogleAds googleAds = this.getAdsAccount(siteCode);
         if (StringUtils.isBlank(googleAds.getCustomerId())) {
             log.info("Google Ads帐号未配置, siteCode = {}", siteCode);
             return Collections.EMPTY_LIST;
@@ -251,7 +252,7 @@ public class GoogleAdsReportService {
                             + TTLCacheManager.TTL_SPLITTER
                             + 60 * 5) // Redis TTL为5分钟
     public List<CountryStatsVO> getCountryStats(String siteCode, Date start, Date end) {
-        GoogleAds googleAds = this.getGoogleAds(siteCode);
+        GoogleAds googleAds = this.getAdsAccount(siteCode);
         if (StringUtils.isBlank(googleAds.getCustomerId())) {
             log.info("Google Ads帐号未配置, siteCode = {}", siteCode);
             return Collections.EMPTY_LIST;
@@ -283,7 +284,7 @@ public class GoogleAdsReportService {
      *
      * <p>使用AdwebRedisUtil操作 - @Cacheable注解无法嵌套使用
      */
-    private synchronized GoogleAds getGoogleAds(String siteCode) {
+    private synchronized GoogleAds getAdsAccount(String siteCode) {
         final String redisKey = String.format("%s:account:%s", "googleads", siteCode);
 
         GoogleAds googleAds = (GoogleAds) redisUtil.get(redisKey);