|
@@ -25,10 +25,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class RuleKuaiShouPlanServiceImpl extends ServiceImpl<RuleDatePlanKuaishouMapper, RuleDatePlanKuaishou> implements IRuleKuaiShouPlanService {
|
|
public class RuleKuaiShouPlanServiceImpl extends ServiceImpl<RuleDatePlanKuaishouMapper, RuleDatePlanKuaishou> implements IRuleKuaiShouPlanService {
|
|
@@ -82,7 +79,7 @@ public class RuleKuaiShouPlanServiceImpl extends ServiceImpl<RuleDatePlanKuaisho
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void cleanRuleDataUnit(Long accountId, String startDate, String endDate, int page) {
|
|
|
|
|
|
+ public void cleanRuleDataUnit(Long accountId, String accessToken, String startDate, String endDate, 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);
|
|
@@ -91,7 +88,7 @@ public class RuleKuaiShouPlanServiceImpl extends ServiceImpl<RuleDatePlanKuaisho
|
|
param.put("end_date", endDate);
|
|
param.put("end_date", endDate);
|
|
|
|
|
|
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/report/unit_report", param.toJSONString(), headers);
|
|
String result = HttpUtils.kuaiShouhttpPostRequest("https://ad.e.kuaishou.com/rest/openapi/v1/report/unit_report", param.toJSONString(), headers);
|
|
@@ -110,7 +107,7 @@ public class RuleKuaiShouPlanServiceImpl extends ServiceImpl<RuleDatePlanKuaisho
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
this.insertUnit(accountId, details);
|
|
this.insertUnit(accountId, details);
|
|
- cleanRuleDataUnit(accountId, startDate, endDate, page + 1);
|
|
|
|
|
|
+ cleanRuleDataUnit(accountId, accessToken, startDate, endDate, page + 1);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -197,17 +194,20 @@ public class RuleKuaiShouPlanServiceImpl extends ServiceImpl<RuleDatePlanKuaisho
|
|
unit.setConvertCost(unitDetail.getBigDecimal("charge").divide(BigDecimal.valueOf(unit.getConvertNum()), 2, RoundingMode.HALF_UP));
|
|
unit.setConvertCost(unitDetail.getBigDecimal("charge").divide(BigDecimal.valueOf(unit.getConvertNum()), 2, RoundingMode.HALF_UP));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ unit.setCreateTime(new Date());
|
|
batch.add(unit);
|
|
batch.add(unit);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
});
|
|
});
|
|
if (!batch.isEmpty()) {
|
|
if (!batch.isEmpty()) {
|
|
- unitKuaishouService.saveOrUpdateBatch(batch);
|
|
|
|
|
|
+ // unitKuaishouService.saveOrUpdateBatch(batch);
|
|
|
|
+ unitKuaishouService.replaceBatch(batch);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void insertTarget(Long accountId, JSONArray details) {
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void insertTarget(Long accountId, JSONArray details) {
|
|
List<RuleDataTargetKuaishou> batch = new ArrayList<>();
|
|
List<RuleDataTargetKuaishou> batch = new ArrayList<>();
|
|
details.forEach(detail -> {
|
|
details.forEach(detail -> {
|
|
JSONObject unitDetail = (JSONObject) detail;
|
|
JSONObject unitDetail = (JSONObject) detail;
|
|
@@ -262,12 +262,14 @@ 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.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.setUpdateTime(new Date());
|
|
batch.add(target);
|
|
batch.add(target);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
if (!batch.isEmpty()) {
|
|
if (!batch.isEmpty()) {
|
|
- targetKuaishouService.saveOrUpdateBatch(batch);
|
|
|
|
|
|
+ // targetKuaishouService.saveOrUpdateBatch(batch);
|
|
|
|
+ targetKuaishouService.replaceBatch(batch);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|