hpk 1 vuosi sitten
vanhempi
commit
afab2b0c58

+ 1 - 1
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/controller/HistoryController.java

@@ -44,7 +44,7 @@ public class HistoryController {
                 }
 /*                kuaiShouAccountReportService.queryAccountReportDaily(token, advertiserId, startDate, endDate, 1);
                 groupReportService.queryGroupReportDaily(token, advertiserId, startDate, endDate, 1);*/
-                kuaiShouAccountReportService.queryAccountDailyFlows(token, advertiserId, startDate, endDate, 1, 1, null, 2);
+                kuaiShouAccountReportService.queryAccountDailyFlows(token, advertiserId, startDate, endDate, 1, 1, null, 2, 1);
             }
         });
         json.put("code", 200);

+ 1 - 1
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/controller/KuaiShouController.java

@@ -88,7 +88,7 @@ public class KuaiShouController {
             for (JSONObject jsonObject : jsonObjects) {
                 Long advertiserId = jsonObject.getLong("advertiser_id");
                 String accessToken = jsonObject.getString("access_token");
-                accountReportService.queryAccountDailyFlows(accessToken, advertiserId, day, day, 1, 1, null, 2);
+                accountReportService.queryAccountDailyFlows(accessToken, advertiserId, day, day, 1, 1, null, 2, 1);
 
             }
         }

+ 1 - 1
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/IKuaiShouAccountReportService.java

@@ -9,7 +9,7 @@ public interface IKuaiShouAccountReportService {
 
     void updateClAccountStatus();
 
-    void queryAccountDailyFlows(String accessToken, Long advertiserId, String startDate, String endDate, int page, Integer isLog, Long errId, Integer isSend);
+    void queryAccountDailyFlows(String accessToken, Long advertiserId, String startDate, String endDate, int page, Integer isLog, Long errId, Integer isSend, int retry);
 
     String getTokenByAdvertiserId(Long advertiserId);
 }

+ 9 - 2
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/impl/KuaiShouAccountReportServiceImpl.java

@@ -149,7 +149,7 @@ public class KuaiShouAccountReportServiceImpl implements IKuaiShouAccountReportS
     }
 
     @Override
-    public void queryAccountDailyFlows(String accessToken, Long advertiserId, String startDate, String endDate, int page, Integer isLog, Long errId, Integer isSend) {
+    public void queryAccountDailyFlows(String accessToken, Long advertiserId, String startDate, String endDate, int page, Integer isLog, Long errId, Integer isSend, int retry) {
         String url = "https://ad.e.kuaishou.com/rest/openapi/v1/advertiser/fund/daily_flows";
         Map<String, String> headers = new HashMap<>();
         headers.put("Content-Type", "application/json");
@@ -177,6 +177,13 @@ public class KuaiShouAccountReportServiceImpl implements IKuaiShouAccountReportS
         Integer code = resultJson.getInteger("code");
         String message = resultJson.getString("message");
         if (null == code || code != 0) {
+            if (retry <= 3) {
+                try {
+                    Thread.sleep(800);
+                } catch (InterruptedException ignored) {
+                }
+                queryAccountDailyFlows(accessToken, advertiserId, startDate, endDate, page,isLog, errId, isSend, retry + 1);
+            }
             log.error("获取快手广告账户流水信息异常:{},accountId:{} {}~{}", message, advertiserId,startDate,endDate);
             if (isLog != null && isLog == 1 && (null == code || code != 400002)) {
                 errorLogService.addError(advertiserId, startDate, endDate, "daily_flows", "daily", message, 2);
@@ -203,7 +210,7 @@ public class KuaiShouAccountReportServiceImpl implements IKuaiShouAccountReportS
         //    accountReportMapper.replaceKuaiShouDailyFlows(addList);
         //}
         if (page < totalPage) {
-            queryAccountDailyFlows(accessToken, advertiserId, startDate, endDate, page + 1,isLog, errId, isSend);
+            queryAccountDailyFlows(accessToken, advertiserId, startDate, endDate, page + 1,isLog, errId, isSend, 1);
         } else {
             if (errId != null) {
                 errorLogService.deleteInfoByErrorId(errId);

+ 2 - 2
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouAccountReportJob.java

@@ -120,7 +120,7 @@ public class KuaiShouAccountReportJob {
         yesAccountExecutorService.submit(new Runnable() {
             @Override
             public void run() {
-                accountReportService.queryAccountDailyFlows(accessToken, advertiserId, yesDate, yesDate, 1,1,null,2);
+                accountReportService.queryAccountDailyFlows(accessToken, advertiserId, yesDate, yesDate, 1,1,null,2, 1);
             }
         });
     }
@@ -141,7 +141,7 @@ public class KuaiShouAccountReportJob {
         yesAccountExecutorService.submit(new Runnable() {
             @Override
             public void run() {
-                accountReportService.queryAccountDailyFlows(accessToken, advertiserId, nowDate, nowDate, 1,1,null,2);
+                accountReportService.queryAccountDailyFlows(accessToken, advertiserId, nowDate, nowDate, 1,1,null,2,1);
             }
         });
     }

+ 1 - 1
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouRetryReportJob.java

@@ -110,7 +110,7 @@ public class KuaiShouRetryReportJob {
                         @Override
                         public void run() {
                             if (!Check.isNull(accessToken)) {
-                                accountReportService.queryAccountDailyFlows(accessToken, advertiserId, startDate, endDate, 1, null, id, isSend);
+                                accountReportService.queryAccountDailyFlows(accessToken, advertiserId, startDate, endDate, 1, null, id, isSend, 1);
                             }
                         }
                     });