|
@@ -12,6 +12,7 @@ import cn.com.ctop.job.kuaishou.data.utils.AlertUtils;
|
|
|
import cn.com.ctop.job.kuaishou.data.utils.Check;
|
|
import cn.com.ctop.job.kuaishou.data.utils.Check;
|
|
|
import cn.com.ctop.job.kuaishou.data.utils.DateUtils;
|
|
import cn.com.ctop.job.kuaishou.data.utils.DateUtils;
|
|
|
import cn.com.ctop.job.kuaishou.data.utils.HttpUtils;
|
|
import cn.com.ctop.job.kuaishou.data.utils.HttpUtils;
|
|
|
|
|
+import cn.com.ctop.job.kuaishou.utils.doris.sink.DorisMultiTableStreamLoadManager;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -27,6 +28,8 @@ public class KuaiShouDramaServiceImpl implements IKuaiShouDramaService {
|
|
|
private KuaiShouDramaMapper kuaiShouDramaMapper;
|
|
private KuaiShouDramaMapper kuaiShouDramaMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IKuaiShouErrorLogService errorLogService;
|
|
private IKuaiShouErrorLogService errorLogService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DorisMultiTableStreamLoadManager dorisStreamLoadManager;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void queryAdReportDetail(String accessToken, Long advertiserId, String startDate, String endDate, int page, Integer isLog, Long errId, Integer isSend) {
|
|
public void queryAdReportDetail(String accessToken, Long advertiserId, String startDate, String endDate, int page, Integer isLog, Long errId, Integer isSend) {
|
|
@@ -80,8 +83,8 @@ public class KuaiShouDramaServiceImpl implements IKuaiShouDramaService {
|
|
|
kuaiShouDramaMapper.insertAdReportDetail(addList);
|
|
kuaiShouDramaMapper.insertAdReportDetail(addList);
|
|
|
try {
|
|
try {
|
|
|
kuaiShouDramaMapper.insertAdReportDetailSD(addList);
|
|
kuaiShouDramaMapper.insertAdReportDetailSD(addList);
|
|
|
- }catch (Exception e) {
|
|
|
|
|
- log.error("insertAdReportDetailSD",e);
|
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("insertAdReportDetailSD", e);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (page < totalPage) {
|
|
if (page < totalPage) {
|
|
@@ -97,6 +100,7 @@ public class KuaiShouDramaServiceImpl implements IKuaiShouDramaService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 自投订单
|
|
|
@Override
|
|
@Override
|
|
|
public void queryOrderDetail(String accessToken, Long advertiserId, String startDate, String endDate, int page, Integer isLog, Long errId, Integer isSend) {
|
|
public void queryOrderDetail(String accessToken, Long advertiserId, String startDate, String endDate, int page, Integer isLog, Long errId, Integer isSend) {
|
|
|
String url = KuaishouLinkConstants.KS_PREFIX + KuaishouLinkConstants.DRAMA_ORDER_DETAIL;
|
|
String url = KuaishouLinkConstants.KS_PREFIX + KuaishouLinkConstants.DRAMA_ORDER_DETAIL;
|
|
@@ -153,8 +157,8 @@ public class KuaiShouDramaServiceImpl implements IKuaiShouDramaService {
|
|
|
kuaiShouDramaMapper.insertDramaOrder(addList);
|
|
kuaiShouDramaMapper.insertDramaOrder(addList);
|
|
|
try {
|
|
try {
|
|
|
kuaiShouDramaMapper.insertDramaOrderSD(addList);
|
|
kuaiShouDramaMapper.insertDramaOrderSD(addList);
|
|
|
- }catch (Exception e) {
|
|
|
|
|
- log.error("insertDramaOrderSD",e);
|
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("insertDramaOrderSD", e);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (page < totalPage) {
|
|
if (page < totalPage) {
|
|
@@ -170,6 +174,68 @@ public class KuaiShouDramaServiceImpl implements IKuaiShouDramaService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 分销第三方订单
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void querySalerOrderDetail(String accessToken, Long advertiserId, String startDate, String endDate, int page, Integer isLog, Long errId, Integer isSend) {
|
|
|
|
|
+ String url = KuaishouLinkConstants.KS_PREFIX + KuaishouLinkConstants.DRAMA_SALER_ORDER_DETAIL;
|
|
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
|
|
+ headers.put("Access-Token", accessToken);
|
|
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
|
|
+ int pageSize = 1000;
|
|
|
|
|
+ param.put("start_date", DateUtils.timeToStamp(startDate + " 00:00:00"));
|
|
|
|
|
+ param.put("end_date", DateUtils.timeToStamp(endDate + " 23:59:59"));
|
|
|
|
|
+ param.put("user_id", advertiserId);
|
|
|
|
|
+ param.put("page_size", pageSize);
|
|
|
|
|
+ param.put("page_no", page);
|
|
|
|
|
+
|
|
|
|
|
+ String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
|
|
+ if (Check.isNull(result)) {
|
|
|
|
|
+ log.error("获取快手分销短剧订单接口异常:{},accountId:{}", "返回结果为空", advertiserId);
|
|
|
|
|
+ if (isLog != null && isLog == 1) {
|
|
|
|
|
+ errorLogService.addError(advertiserId, startDate, endDate, "drama_saler_order", "daily", "返回结果为空", 2);
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
|
|
+ String message = resultJson.getString("message");
|
|
|
|
|
+ if (null == code || code != 0) {
|
|
|
|
|
+ log.error("获取快手分销短剧订单接口异常:{},accountId:{}", message, advertiserId);
|
|
|
|
|
+ if (isLog != null && isLog == 1) {
|
|
|
|
|
+ errorLogService.addError(advertiserId, startDate, endDate, "drama_saler_order", "daily", message, 2);
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONObject data = resultJson.getJSONObject("data");
|
|
|
|
|
+ int totalCount = data.getIntValue("total_count");
|
|
|
|
|
+ int totalPage = (int) Math.ceil(totalCount * 1.0 / pageSize);
|
|
|
|
|
+ JSONArray details = data.getJSONArray("core_data_list");
|
|
|
|
|
+ if (!Check.isNull(details)) {
|
|
|
|
|
+ for (int i = 0; i < details.size(); i++) {
|
|
|
|
|
+ JSONObject detailJson = details.getJSONObject(i);
|
|
|
|
|
+ detailJson.put("order_type", 2);
|
|
|
|
|
+ detailJson.put("stat_date", DateUtils.stampToIntDate(detailJson.getLong("create_time")));
|
|
|
|
|
+ detailJson.put("admin_advertiser_id", advertiserId);
|
|
|
|
|
+ detailJson.put("series_name", getSeriesName(advertiserId, detailJson.getLong("series_id"), accessToken));
|
|
|
|
|
+ }
|
|
|
|
|
+ dorisStreamLoadManager.add("media_api", "kuaishou_drama_order", details);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (page < totalPage) {
|
|
|
|
|
+ querySalerOrderDetail(accessToken, advertiserId, startDate, endDate, page + 1, isLog, errId, isSend);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.info("【{}】录入快手分销短剧订单数据完成 {} {} page: {}", advertiserId, startDate, endDate, page);
|
|
|
|
|
+ if (errId != null) {
|
|
|
|
|
+ errorLogService.deleteInfoByErrorId(errId);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isSend != null && isSend == 1) {
|
|
|
|
|
+ AlertUtils.sendMessage(advertiserId, startDate, endDate, 2, "daily", 1, "drama_saler_order");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 版权商短剧分销数据
|
|
|
@Override
|
|
@Override
|
|
|
public void querySalerCopyRightData(String accessToken, Long advertiserId, Integer seriesType, String startDate, String endDate, int page, Integer isLog, Long errId, Integer isSend) {
|
|
public void querySalerCopyRightData(String accessToken, Long advertiserId, Integer seriesType, String startDate, String endDate, int page, Integer isLog, Long errId, Integer isSend) {
|
|
|
String url = KuaishouLinkConstants.KS_PREFIX + KuaishouLinkConstants.DRAMA_SALER_COPY_RIGHT_DATA;
|
|
String url = KuaishouLinkConstants.KS_PREFIX + KuaishouLinkConstants.DRAMA_SALER_COPY_RIGHT_DATA;
|
|
@@ -222,8 +288,8 @@ public class KuaiShouDramaServiceImpl implements IKuaiShouDramaService {
|
|
|
kuaiShouDramaMapper.insertSalerCopyRightData(addList);
|
|
kuaiShouDramaMapper.insertSalerCopyRightData(addList);
|
|
|
try {
|
|
try {
|
|
|
kuaiShouDramaMapper.insertSalerCopyRightDataSD(addList);
|
|
kuaiShouDramaMapper.insertSalerCopyRightDataSD(addList);
|
|
|
- }catch (Exception e) {
|
|
|
|
|
- log.error("insertSalerCopyRightDataSD",e);
|
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("insertSalerCopyRightDataSD", e);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (page < totalPage) {
|
|
if (page < totalPage) {
|
|
@@ -239,6 +305,67 @@ public class KuaiShouDramaServiceImpl implements IKuaiShouDramaService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //分销商短剧分销数据
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void querySalerData(String accessToken, Long advertiserId, Integer seriesType, String startDate, String endDate, int page, Integer isLog, Long errId, Integer isSend) {
|
|
|
|
|
+ String url = KuaishouLinkConstants.KS_PREFIX + KuaishouLinkConstants.DRAMA_SALER_DATA;
|
|
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
|
|
+ headers.put("Access-Token", accessToken);
|
|
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
|
|
+ int pageSize = 100;
|
|
|
|
|
+ param.put("start_date", DateUtils.timeToStamp(startDate + " 00:00:00"));
|
|
|
|
|
+ param.put("end_date", DateUtils.timeToStamp(endDate + " 23:59:59"));
|
|
|
|
|
+ param.put("role_type", 2);
|
|
|
|
|
+ param.put("series_type", seriesType);
|
|
|
|
|
+ param.put("advertiser_id", advertiserId);
|
|
|
|
|
+ param.put("page_size", pageSize);
|
|
|
|
|
+ param.put("current_page", page);
|
|
|
|
|
+ String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
|
|
+ if (Check.isNull(result)) {
|
|
|
|
|
+ log.error("获取快手分销商短剧分销数据查询接口异常:{},accountId:{}", "返回结果为空", advertiserId);
|
|
|
|
|
+ if (isLog != null && isLog == 1) {
|
|
|
|
|
+ errorLogService.addError(advertiserId, startDate, endDate, "drama_saler_data", "daily", new JSONObject().fluentPut("msg", "返回结果为空").fluentPut("seriesType", seriesType).toJSONString(), 2);
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
|
|
+ String message = resultJson.getString("message");
|
|
|
|
|
+ if (null == code || code != 0) {
|
|
|
|
|
+ log.error("获取快手分销商短剧分销数据查询接口异常:{},accountId:{}", message, advertiserId);
|
|
|
|
|
+ if (isLog != null && isLog == 1 && (null == code || code != 3)) {
|
|
|
|
|
+ errorLogService.addError(advertiserId, startDate, endDate, "drama_saler_data", "daily", new JSONObject().fluentPut("msg", message).fluentPut("seriesType", seriesType).toJSONString(), 2);
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONObject data = resultJson.getJSONObject("data");
|
|
|
|
|
+ int totalCount = data.getIntValue("total_count");
|
|
|
|
|
+ int totalPage = (int) Math.ceil(totalCount * 1.0 / pageSize);
|
|
|
|
|
+ JSONArray details = data.getJSONArray("data_list");
|
|
|
|
|
+ if (!Check.isNull(details)) {
|
|
|
|
|
+ for (int i = 0; i < details.size(); i++) {
|
|
|
|
|
+ JSONObject detailJson = details.getJSONObject(i);
|
|
|
|
|
+ detailJson.put("stat_date", DateUtils.getDateInteger(detailJson.getString("report_date")));
|
|
|
|
|
+ detailJson.put("admin_advertiser_id", advertiserId);
|
|
|
|
|
+ detailJson.put("series_type", seriesType);
|
|
|
|
|
+ }
|
|
|
|
|
+ dorisStreamLoadManager.add("media_api", "kuaishou_drama_saler_data", details);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (page < totalPage) {
|
|
|
|
|
+ querySalerData(accessToken, advertiserId, seriesType, startDate, endDate, page + 1, isLog, errId, isSend);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.info("【{}】录入快手分销商短剧分销数据完成 {} {} page: {}", advertiserId, startDate, endDate, page);
|
|
|
|
|
+ if (errId != null) {
|
|
|
|
|
+ errorLogService.deleteInfoByErrorId(errId);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isSend != null && isSend == 1) {
|
|
|
|
|
+ AlertUtils.sendMessage(advertiserId, startDate, endDate, 2, "daily", 1, "drama_saler_data");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public void querySeriesInfo(String accessToken, Long advertiserId, Integer isLog, Long errId, Integer isSend) {
|
|
public void querySeriesInfo(String accessToken, Long advertiserId, Integer isLog, Long errId, Integer isSend) {
|
|
|
String url = KuaishouLinkConstants.KS_PREFIX + KuaishouLinkConstants.DRAMA_SERIES_INFO;
|
|
String url = KuaishouLinkConstants.KS_PREFIX + KuaishouLinkConstants.DRAMA_SERIES_INFO;
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|