|
@@ -11,6 +11,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections.ArrayStack;
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -23,28 +24,32 @@ public class KuaishouInterfaceServiceImpl2 implements IKuaishouInterfaceService2
|
|
|
@Autowired
|
|
|
private KuaishouOperationRecordMapper kuaishouOperationRecordMapper;
|
|
|
|
|
|
+ @Override
|
|
|
+ public void getOperationRecord(Long advertiserId, String accessToken, Integer operationTarget, String startDate, String endDate){
|
|
|
|
|
|
- public void getOperationRecord(){
|
|
|
-
|
|
|
-
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private void getOperationRecordByPage(Long advertiserId, String accessToken, Integer page, Integer pageSize, Integer operationTarget) {
|
|
|
+ private void getOperationRecordByPage(Long advertiserId, String accessToken, Integer page, Integer pageSize, Integer operationTarget, String startDate, String endDate) {
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.OPERATION_RECORD;
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Access-Token", accessToken);
|
|
|
headers.put("Content-Type", " application/json");
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("advertiser_id", advertiserId);
|
|
|
- //if(operationType != null){
|
|
|
- // json.put("operation_type", operationType);
|
|
|
- //}
|
|
|
- if(operationTarget != null){
|
|
|
- json.put("operation_target", operationTarget);
|
|
|
- }
|
|
|
-
|
|
|
+ json.put("operation_target", operationTarget);
|
|
|
json.put("page", page);
|
|
|
json.put("page_size", pageSize);
|
|
|
+ json.put("start_date", startDate);
|
|
|
+ json.put("end_date", endDate);
|
|
|
+
|
|
|
String result = HttpUtils.kuaiShouhttpPostRequest(url, json.toJSONString(), headers);
|
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
|
|
@@ -68,15 +73,16 @@ public class KuaishouInterfaceServiceImpl2 implements IKuaishouInterfaceService2
|
|
|
String objectId = dataJson.getString("object_id");
|
|
|
String objectName = dataJson.getString("object_name");
|
|
|
|
|
|
- if (page == 1) { //如果页数为1,删除原来的数据
|
|
|
+ if (page == 1 && i==0) { //如果页数为1,删除原来的数据
|
|
|
KuaishouOperationRecord recordDelete = new KuaishouOperationRecord();
|
|
|
+ recordDelete.setStatDate(startDate);//按天删除记录
|
|
|
recordDelete.setAccountId(advertiserId);
|
|
|
- recordDelete.setOperationTime(operationTime);
|
|
|
- recordDelete.setOperationType(operationType);
|
|
|
- recordDelete.setRoleType(roleType);
|
|
|
- recordDelete.setObjectName(objectName);
|
|
|
- recordDelete.setOperationTarget(operationTarget);
|
|
|
- recordDelete.setObjectId(objectId);
|
|
|
+ //recordDelete.setOperationTime(operationTime);
|
|
|
+ //recordDelete.setOperationType(operationType);
|
|
|
+ //recordDelete.setRoleType(roleType);
|
|
|
+ //recordDelete.setObjectName(objectName);
|
|
|
+ //recordDelete.setOperationTarget(operationTarget);
|
|
|
+ //recordDelete.setObjectId(objectId);
|
|
|
operationRecordDelete(recordDelete,operationTarget);
|
|
|
}
|
|
|
|
|
@@ -86,6 +92,7 @@ public class KuaishouInterfaceServiceImpl2 implements IKuaishouInterfaceService2
|
|
|
JSONObject log = contentLogArray.getJSONObject(j);
|
|
|
KuaishouOperationRecord record = new KuaishouOperationRecord();
|
|
|
record.setAccountId(advertiserId);
|
|
|
+ record.setStatDate(startDate);
|
|
|
record.setOperationTime(operationTime);
|
|
|
record.setOperationType(operationType);
|
|
|
record.setRoleType(roleType);
|
|
@@ -100,16 +107,22 @@ public class KuaishouInterfaceServiceImpl2 implements IKuaishouInterfaceService2
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- operationRecordInsert(recordList,operationTarget);
|
|
|
+ if(recordList !=null && recordList.size()!=0){
|
|
|
+ operationRecordInsert(recordList,operationTarget);
|
|
|
+ }
|
|
|
|
|
|
Integer totalPage = (totalCount - 1) / pageSize + 1;
|
|
|
if (page < totalPage) {
|
|
|
- getOperationRecordByPage(advertiserId, accessToken, page + 1, pageSize, operationTarget);
|
|
|
+ getOperationRecordByPage(advertiserId, accessToken, page + 1, pageSize, operationTarget, startDate, endDate);
|
|
|
}
|
|
|
+ }else{
|
|
|
+ log.error("快手操作记录接口data结果不正确,{} ~ {}, resultJson:{}", startDate, endDate, result);
|
|
|
}
|
|
|
+ }else{
|
|
|
+ log.error("快手操作记录接口code返回结果不正确,{} ~ {}, resultJson:{}", startDate, endDate, result);
|
|
|
}
|
|
|
} else {
|
|
|
- log.error("获取地域列表返回结果为空");
|
|
|
+ log.error("快手操作记录接口获取地域列表返回结果为空,{} ~ {}, resultJson:{}", startDate, endDate, result);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -148,9 +161,6 @@ public class KuaishouInterfaceServiceImpl2 implements IKuaishouInterfaceService2
|
|
|
}else if(operationTarget == 7){
|
|
|
kuaishouOperationRecordMapper.insertOperationRecordInfoPackage(recordList);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|