|
@@ -20,6 +20,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.xxl.job.core.context.XxlJobHelper;
|
|
import com.xxl.job.core.context.XxlJobHelper;
|
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -111,17 +112,21 @@ public class RuleKuaiShouPlanServiceImpl extends ServiceImpl<RuleDatePlanKuaisho
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void cleanRuleDataTarget(Long accountId, int page) {
|
|
|
|
|
|
+ public void cleanRuleDataTarget(Long accountId, String accessToken, int page) {
|
|
JSONObject param = new JSONObject();
|
|
JSONObject param = new JSONObject();
|
|
param.put("advertiser_id", accountId);
|
|
param.put("advertiser_id", accountId);
|
|
param.put("page_size", 500);
|
|
param.put("page_size", 500);
|
|
param.put("page", page);
|
|
param.put("page", page);
|
|
|
|
+ String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
|
+ param.put("start_date", nowDate);
|
|
|
|
+ param.put("end_date", nowDate);
|
|
|
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|
|
- headers.put("Access-Token", oauthTokenService.getTokenByAccountId(accountId).getAccessToken());
|
|
|
|
|
|
+ headers.put("Access-Token", accessToken);
|
|
headers.put("Content-Type", "application/json");
|
|
headers.put("Content-Type", "application/json");
|
|
|
|
|
|
String result = HttpUtils.kuaiShouhttpPostRequest("https://ad.e.kuaishou.com/rest/openapi/v1/ad_unit/list", param.toJSONString(), headers);
|
|
String result = HttpUtils.kuaiShouhttpPostRequest("https://ad.e.kuaishou.com/rest/openapi/v1/ad_unit/list", param.toJSONString(), headers);
|
|
|
|
+ System.err.println(result);
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
if (Check.isNull(resultJson)) {
|
|
if (Check.isNull(resultJson)) {
|
|
XxlJobHelper.log("获取定向信息接口异常,advertiserId:{}", accountId);
|
|
XxlJobHelper.log("获取定向信息接口异常,advertiserId:{}", accountId);
|
|
@@ -138,7 +143,7 @@ public class RuleKuaiShouPlanServiceImpl extends ServiceImpl<RuleDatePlanKuaisho
|
|
}
|
|
}
|
|
|
|
|
|
this.insertTarget(accountId, details);
|
|
this.insertTarget(accountId, details);
|
|
- cleanRuleDataTarget(accountId, page + 1);
|
|
|
|
|
|
+ cleanRuleDataTarget(accountId, accessToken, page + 1);
|
|
}
|
|
}
|
|
|
|
|
|
private void insertPlan(Long accountId, JSONArray details) {
|
|
private void insertPlan(Long accountId, JSONArray details) {
|
|
@@ -183,10 +188,6 @@ public class RuleKuaiShouPlanServiceImpl extends ServiceImpl<RuleDatePlanKuaisho
|
|
unit.setUnitId(unitDetail.getLong("unit_id"));
|
|
unit.setUnitId(unitDetail.getLong("unit_id"));
|
|
unit.setUnitName(unitDetail.getString("unit_name"));
|
|
unit.setUnitName(unitDetail.getString("unit_name"));
|
|
unit.setCharge(unitDetail.getBigDecimal("charge"));
|
|
unit.setCharge(unitDetail.getBigDecimal("charge"));
|
|
- unit.setDeepConversionBid(new BigDecimal(group.getDeepConversionBid()).divide(new BigDecimal("1000")));
|
|
|
|
- unit.setDeepConversionType(group.getDeepConversionType());
|
|
|
|
- unit.setOcpxActionType(group.getOcpxActionType());
|
|
|
|
- unit.setCpaBid(new BigDecimal(group.getCpaBid()).divide(new BigDecimal("1000"), 2, RoundingMode.HALF_UP));
|
|
|
|
//未知优化目标数据存空
|
|
//未知优化目标数据存空
|
|
if (group.getOcpxActionType() != 0) {
|
|
if (group.getOcpxActionType() != 0) {
|
|
unit.setConvertNum(handleConvertNum(group.getOcpxActionType(), unitDetail));
|
|
unit.setConvertNum(handleConvertNum(group.getOcpxActionType(), unitDetail));
|
|
@@ -201,7 +202,6 @@ public class RuleKuaiShouPlanServiceImpl extends ServiceImpl<RuleDatePlanKuaisho
|
|
|
|
|
|
});
|
|
});
|
|
if (!batch.isEmpty()) {
|
|
if (!batch.isEmpty()) {
|
|
- // unitKuaishouService.saveOrUpdateBatch(batch);
|
|
|
|
unitKuaishouService.replaceBatch(batch);
|
|
unitKuaishouService.replaceBatch(batch);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -261,6 +261,11 @@ public class RuleKuaiShouPlanServiceImpl extends ServiceImpl<RuleDatePlanKuaisho
|
|
|
|
|
|
Integer isOpen = unitDetail.getJSONObject("target").getJSONObject("intelli_extend").getInteger("is_open");
|
|
Integer isOpen = unitDetail.getJSONObject("target").getJSONObject("intelli_extend").getInteger("is_open");
|
|
target.setIsOpen(isOpen == null ? 0 : isOpen);
|
|
target.setIsOpen(isOpen == null ? 0 : isOpen);
|
|
|
|
+
|
|
|
|
+ target.setDeepConversionBid(new BigDecimal(unitDetail.getLong("deep_conversion_bid")).divide(new BigDecimal("1000")));
|
|
|
|
+ target.setDeepConversionType(unitDetail.getInteger("deep_conversion_bid"));
|
|
|
|
+ target.setOcpxActionType(unitDetail.getInteger("ocpx_action_type"));
|
|
|
|
+ target.setCpaBid(new BigDecimal(unitDetail.getLong("cpa_bid")).divide(new BigDecimal("1000"), 2, RoundingMode.HALF_UP));
|
|
target.setScheduleTime(unitDetail.getString("schedule_time") == null ? "" : unitDetail.getString("schedule_time"));
|
|
target.setScheduleTime(unitDetail.getString("schedule_time") == null ? "" : unitDetail.getString("schedule_time"));
|
|
target.setCreateTime(new Date());
|
|
target.setCreateTime(new Date());
|
|
target.setUpdateTime(new Date());
|
|
target.setUpdateTime(new Date());
|