Преглед на файлове

快手操作记录获取接口

sunzhen преди 4 години
родител
ревизия
2b45a6b870

+ 50 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouOperationReportLoadJob.java

@@ -0,0 +1,50 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import com.xxl.job.core.log.XxlJobLogger;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 快手获取操作记录定时任务
+ *
+ * @author sunzhen
+ */
+@Component
+public class KuaishouDailyAccountReportLoadJob {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService2 kuaishouInterfaceService2;
+    static ExecutorService executorService = Executors.newFixedThreadPool(3);
+
+    @XxlJob("kuaishouOperationReport")
+    public ReturnT<String> execute(String param) throws Exception {
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        Date getDate2 = DateUtils.addDay(new Date(), -2);
+        //1:查询当日数据
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        if (null == tokens || tokens.isEmpty()) {
+            XxlJobLogger.log("定时获取快手数据异常:未获取到可用的token");
+            return ReturnT.FAIL;
+        }
+        tokens.forEach(token -> executorService.submit(() ->{
+                    kuaishouInterfaceService2
+                    kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate, getDate);
+
+
+
+
+        }));
+        return ReturnT.SUCCESS;
+    }
+}

+ 7 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl2.java

@@ -30,11 +30,11 @@ public class KuaishouInterfaceServiceImpl2 implements IKuaishouInterfaceService2
         Long days = DateUtils.getDiscrepantDays(startDate, endDate);
         String start = null;
         String end = null;
-        for (int i = 0; i <= days; i++) {
-            start = DateUtils.addDay(startDate, i);
-            end = start;
-            getOperationRecordByPage(advertiserId, accessToken,1, 500, operationTarget, start, end);
-        }
+        //for (int i = 0; i <= days; i++) {
+        //    start = DateUtils.addDay(startDate, i);
+        //    end = start;
+        getOperationRecordByPage(advertiserId, accessToken,1, 500, operationTarget, startDate, endDate);
+        //}
     }
 
     private void getOperationRecordByPage(Long advertiserId, String accessToken, Integer page, Integer pageSize, Integer operationTarget, String startDate, String endDate) {
@@ -67,6 +67,7 @@ public class KuaishouInterfaceServiceImpl2 implements IKuaishouInterfaceService2
                         if (!Check.isNull(dataJson)) {
 
                             Date operationTime = dataJson.getDate("operation_time");
+                            //Date operationDate = DateUtils.parseDate()
                             Integer operationType = dataJson.getInteger("operation_type");
                             operationTarget = dataJson.getInteger("operation_target");
                             Integer roleType = dataJson.getInteger("role_type");
@@ -94,7 +95,7 @@ public class KuaishouInterfaceServiceImpl2 implements IKuaishouInterfaceService2
 
                             KuaishouOperationRecord record = new KuaishouOperationRecord();
                             record.setAccountId(advertiserId);
-                            record.setStatDate(startDate);
+                            record.setStatDate(DateUtils.formatDate(operationTime));
                             record.setOperationTime(operationTime);
                             record.setOperationType(operationType);
                             record.setRoleType(roleType);