|
@@ -17,6 +17,7 @@ import cn.com.ctop.kuaishou.modules.report.entity.*;
|
|
import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
|
|
import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
|
|
import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCampaignMapper;
|
|
import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCampaignMapper;
|
|
import cn.com.ctop.kuaishou.modules.report.service.*;
|
|
import cn.com.ctop.kuaishou.modules.report.service.*;
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -181,11 +182,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void getVideoList(CtopOauthToken token, String statDate) {
|
|
|
|
- getVideoListByPage(token, statDate, 1);
|
|
|
|
|
|
+ public void getVideoList(CtopOauthToken token, String startDate, String endDate) {
|
|
|
|
+ getVideoListByPage(token, startDate, endDate, 1);
|
|
}
|
|
}
|
|
|
|
|
|
- private void getVideoListByPage(CtopOauthToken token, String statDate, int page) {
|
|
|
|
|
|
+ private void getVideoListByPage(CtopOauthToken token, String startDate, String endDate, int page) {
|
|
try {
|
|
try {
|
|
log.info("获取视频数据,accountId:{}", token.getAccountId());
|
|
log.info("获取视频数据,accountId:{}", token.getAccountId());
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_LIST;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_LIST;
|
|
@@ -196,9 +197,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
param.put("advertiser_id", token.getAccountId());
|
|
param.put("advertiser_id", token.getAccountId());
|
|
param.put("page_size", 500);
|
|
param.put("page_size", 500);
|
|
param.put("page", page);
|
|
param.put("page", page);
|
|
- if (!Check.isNull(statDate)) {
|
|
|
|
- param.put("start_date", statDate);
|
|
|
|
- param.put("end_date", statDate);
|
|
|
|
|
|
+ if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
|
|
|
|
+ param.put("start_date", startDate);
|
|
|
|
+ param.put("end_date", endDate);
|
|
}
|
|
}
|
|
String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
@@ -223,15 +224,24 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
kuaiShouVideoGet.setId(token.getAccountId() + kuaiShouVideoGet.getPhotoId());
|
|
kuaiShouVideoGet.setId(token.getAccountId() + kuaiShouVideoGet.getPhotoId());
|
|
|
|
|
|
kuaiShouVideoGet.setAccountId(token.getAccountId());
|
|
kuaiShouVideoGet.setAccountId(token.getAccountId());
|
|
- kuaiShouVideoGet.setStatDate(DateUtils.parseDate(statDate, "yyyy-MM-dd"));
|
|
|
|
|
|
+ kuaiShouVideoGet.setStatDate(detailJson.getDate("upload_time"));
|
|
kuaiShouVideoGet.setUpdateTime(new Date());
|
|
kuaiShouVideoGet.setUpdateTime(new Date());
|
|
Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
|
|
Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
|
|
if (!Check.isNull(type)) {
|
|
if (!Check.isNull(type)) {
|
|
kuaiShouVideoGet.setMaterialType(type);
|
|
kuaiShouVideoGet.setMaterialType(type);
|
|
}
|
|
}
|
|
kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
|
|
kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
|
|
|
|
+
|
|
|
|
+ Thread thread = new Thread() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ videoGetService.getKeyFrame(token.getAccessToken(), token.getAccountId(), kuaiShouVideoGet.getSignature(), kuaiShouVideoGet.getPhotoId());
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ thread.start();
|
|
|
|
+
|
|
}
|
|
}
|
|
- getVideoListByPage(token, statDate, page + 1);
|
|
|
|
|
|
+ getVideoListByPage(token, startDate, endDate, page + 1);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
@@ -285,17 +295,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
detailJson.put("photo_comment", detailJson.getString("comment"));
|
|
detailJson.put("photo_comment", detailJson.getString("comment"));
|
|
detailJson.put("photo_like", detailJson.getString("like"));
|
|
detailJson.put("photo_like", detailJson.getString("like"));
|
|
detailJson.put("photo_show", detailJson.getString("show"));
|
|
detailJson.put("photo_show", detailJson.getString("show"));
|
|
- detailJson.remove("share");
|
|
|
|
- detailJson.remove("comment");
|
|
|
|
- detailJson.remove("like");
|
|
|
|
- detailJson.remove("show");
|
|
|
|
- detailJson.remove("adScene");
|
|
|
|
- detailJson.remove("stat_hour");
|
|
|
|
- detailJson.remove("event_valid_clues");
|
|
|
|
- detailJson.remove("event_valid_clues_cost");
|
|
|
|
- KuaishouReportDailyAccount kuaishouReportDailyAccount = JsonUtil.jsonToObj(detailJson, KuaishouReportDailyAccount.class);
|
|
|
|
- kuaishouReportDailyAccount.setAccountId(token.getAccountId());
|
|
|
|
- dailyAccountMapper.insertSelective(kuaishouReportDailyAccount);
|
|
|
|
|
|
+ var KuaishouReportDailyAccount = JSONObject.toJavaObject(detailJson, KuaishouReportDailyAccount.class);
|
|
|
|
+ KuaishouReportDailyAccount.setAccountId(token.getAccountId());
|
|
|
|
+ dailyAccountMapper.insertSelective(KuaishouReportDailyAccount);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
getAccountDailyReportByPage(token, startDate, endDate, page + 1);
|
|
getAccountDailyReportByPage(token, startDate, endDate, page + 1);
|
|
@@ -902,7 +904,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
String startDate = DateUtils.addMonth(endDateStr, -6);
|
|
String startDate = DateUtils.addMonth(endDateStr, -6);
|
|
|
|
|
|
historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), startDate, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
|
|
historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), startDate, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
|
|
-
|
|
|
|
|
|
+ getVideoList(token, null, null);
|
|
|
|
+ getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, null, null);
|
|
String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
String videoEndDate = DateUtils.addDay(nowDate, -180);
|
|
String videoEndDate = DateUtils.addDay(nowDate, -180);
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
@@ -911,7 +914,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
List<Date> dates = DateUtils.findDates(start, end);
|
|
List<Date> dates = DateUtils.findDates(start, end);
|
|
for (int i = 0; i < dates.size(); i++) {
|
|
for (int i = 0; i < dates.size(); i++) {
|
|
String formatDate = simpleDateFormat.format(dates.get(i));
|
|
String formatDate = simpleDateFormat.format(dates.get(i));
|
|
- getVideoList(token, formatDate);
|
|
|
|
getImageList(token, formatDate);
|
|
getImageList(token, formatDate);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2868,7 +2870,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
param.put("advertiser_id", accountId);
|
|
param.put("advertiser_id", accountId);
|
|
param.put("page", page);
|
|
param.put("page", page);
|
|
param.put("page_size", 200);
|
|
param.put("page_size", 200);
|
|
- if (!Check.isNull(startDate) && !Check.isNull(startDate)) {
|
|
|
|
|
|
+ if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
|
|
param.put("start_date", startDate);
|
|
param.put("start_date", startDate);
|
|
param.put("end_date", endDate);
|
|
param.put("end_date", endDate);
|
|
}
|
|
}
|
|
@@ -2891,7 +2893,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
if (!Check.isNull(jsonObject)) {
|
|
if (!Check.isNull(jsonObject)) {
|
|
KuaiShouVideoGet kuaiShouVideoGet = new KuaiShouVideoGet();
|
|
KuaiShouVideoGet kuaiShouVideoGet = new KuaiShouVideoGet();
|
|
Long photo_id = jsonObject.getLong("photo_id");
|
|
Long photo_id = jsonObject.getLong("photo_id");
|
|
- kuaiShouVideoGet.setId(accountId + photo_id + "");
|
|
|
|
|
|
+ kuaiShouVideoGet.setId(String.valueOf(accountId) + String.valueOf(photo_id));
|
|
kuaiShouVideoGet.setPhotoId(String.valueOf(photo_id));
|
|
kuaiShouVideoGet.setPhotoId(String.valueOf(photo_id));
|
|
kuaiShouVideoGet.setUrl(jsonObject.getString("watermark_url"));
|
|
kuaiShouVideoGet.setUrl(jsonObject.getString("watermark_url"));
|
|
kuaiShouVideoGet.setWidth(jsonObject.getInteger("width"));
|
|
kuaiShouVideoGet.setWidth(jsonObject.getInteger("width"));
|
|
@@ -2914,6 +2916,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
thread.start();
|
|
thread.start();
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -3116,4 +3120,73 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 下载页
|
|
|
|
+ *
|
|
|
|
+ * @param accountId
|
|
|
|
+ * @param appId
|
|
|
|
+ * @param viewComp
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public JSONArray getPageList(Long accountId, String token, Long appId, String viewComp) {
|
|
|
|
+ JSONArray returnArr = new JSONArray();
|
|
|
|
+ try {
|
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.PAGE_LIST;
|
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
|
+ headers.put("Access-Token", token);
|
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
|
+ JSONArray viewComps = new JSONArray();
|
|
|
|
+ viewComps.add(viewComp);
|
|
|
|
+ param.put("advertiser_id", accountId);
|
|
|
|
+ param.put("page_size", 500);
|
|
|
|
+ String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
|
+ JSONObject resultJson = JSON.parseObject(result);
|
|
|
|
+ if (!Check.isNull(resultJson)) {
|
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
|
+ if (code == 0) {
|
|
|
|
+ JSONObject dataJson = resultJson.getJSONObject("data");
|
|
|
|
+ if (!Check.isNull(dataJson)) {
|
|
|
|
+ JSONArray details = dataJson.getJSONArray("details");
|
|
|
|
+ if (!Check.isNull(details)) {
|
|
|
|
+ for (int i = 0; i < details.size(); i++) {
|
|
|
|
+ JSONObject jsonObject = details.getJSONObject(i);
|
|
|
|
+ if (!Check.isNull(jsonObject)) {
|
|
|
|
+ JSONArray compsArr = jsonObject.getJSONArray("comps");
|
|
|
|
+ if (!Check.isNull(compsArr)) {
|
|
|
|
+ for (int j = 0; j < compsArr.size(); j++) {
|
|
|
|
+ JSONObject compJson = compsArr.getJSONObject(j);
|
|
|
|
+ if (!Check.isNull(compJson)) {
|
|
|
|
+ Integer type = compJson.getInteger("type");
|
|
|
|
+ if (type == 7) {
|
|
|
|
+ JSONObject props = compJson.getJSONObject("props");
|
|
|
|
+ if (!Check.isNull(props)) {
|
|
|
|
+ Long returnAppId = props.getLong("appId");
|
|
|
|
+ if (returnAppId.equals(appId)) {
|
|
|
|
+ JSONObject returnJson = new JSONObject();
|
|
|
|
+ returnJson.put("siteId", jsonObject.getString("id"));
|
|
|
|
+ returnJson.put("name", jsonObject.getString("name"));
|
|
|
|
+ returnJson.put("appId", returnAppId);
|
|
|
|
+ returnArr.add(returnJson);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return returnArr;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|