|
@@ -56,6 +56,8 @@ public class AgentManagementServiceImpl implements AgentManagementService {
|
|
|
@Resource
|
|
|
CtopAccountTransactionDayMapper ctopAccountTransactionDayMapper;
|
|
|
|
|
|
+ private String accountList = "1651537304110087;1640370875427848;73970348172";
|
|
|
+
|
|
|
/**
|
|
|
* 同步代理商下账号
|
|
|
*
|
|
@@ -70,43 +72,50 @@ public class AgentManagementServiceImpl implements AgentManagementService {
|
|
|
List<String> dataList = new ArrayList();
|
|
|
Result result = new Result();
|
|
|
try {
|
|
|
- //分页查询第一页数据
|
|
|
- JSONObject agentAccountList = selectAgentAdvertiser(1, 2000);
|
|
|
- JSONObject data = (JSONObject) agentAccountList.get("data");
|
|
|
- //dataList.addAll((List) data.get("list"));
|
|
|
- if (data.size() > 0) {
|
|
|
- JSONObject page_info = (JSONObject) data.get("page_info");
|
|
|
- int total_page = (int) page_info.get("total_page");
|
|
|
- //查询其他页数据
|
|
|
- for (int i = 0; i < total_page; i++) {
|
|
|
- JSONObject agenttList = selectAgentAdvertiser(i + 1, 2000);
|
|
|
- JSONObject agentData = (JSONObject) agenttList.get("data");
|
|
|
- List<Long> list = (List<Long>) agentData.get("list");
|
|
|
- list.stream().forEach(str -> {
|
|
|
- dataList.add(str.toString());
|
|
|
- });
|
|
|
+ if (accountList != null) {
|
|
|
+ String[] split = accountList.split(";");
|
|
|
+ for (String account : split) {
|
|
|
+ //分页查询第一页数据
|
|
|
+ JSONObject agentAccountList = selectAgentAdvertiser(1, 2000, account);
|
|
|
+ JSONObject data = (JSONObject) agentAccountList.get("data");
|
|
|
+ //dataList.addAll((List) data.get("list"));
|
|
|
+ if (data.size() > 0) {
|
|
|
+ JSONObject page_info = (JSONObject) data.get("page_info");
|
|
|
+ int total_page = (int) page_info.get("total_page");
|
|
|
+ //查询其他页数据
|
|
|
+ for (int i = 0; i < total_page; i++) {
|
|
|
+ JSONObject agenttList = selectAgentAdvertiser(i + 1, 2000, account);
|
|
|
+ JSONObject agentData = (JSONObject) agenttList.get("data");
|
|
|
+ List<Long> list = (List<Long>) agentData.get("list");
|
|
|
+ list.stream().forEach(str -> {
|
|
|
+ dataList.add(str.toString());
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ log.info("拉取" + account + "下账户数量:{}", dataList.size());
|
|
|
+ //查询数据库已存在id
|
|
|
+ List<String> accountIdList = ctopAgentAccountMapper.getAllAccountId();
|
|
|
+ if (!accountIdList.isEmpty()) {
|
|
|
+ //筛选巨量引擎剔除的用户
|
|
|
+ List<String> removeList = accountIdList.stream().filter(item -> !dataList.contains(item)).collect(toList());
|
|
|
+ //筛选巨量引擎新增的用户
|
|
|
+ List<String> addList = dataList.stream().filter(item -> !accountIdList.contains(item)).collect(toList());
|
|
|
+ //修改剔除的用户状态
|
|
|
+ if (!removeList.isEmpty()) {
|
|
|
+ ctopAgentAccountMapper.updateAccountState(removeList, 1);
|
|
|
+ }
|
|
|
+ //保存新增的用户
|
|
|
+ if (!addList.isEmpty()) {
|
|
|
+ ctopAgentAccountMapper.insertAccountData(addList, ADVERTISER_ID, df.format(new Date()));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ctopAgentAccountMapper.insertAccountData(dataList, ADVERTISER_ID, df.format(new Date()));
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
- //查询数据库已存在id
|
|
|
- List<String> accountIdList = ctopAgentAccountMapper.getAllAccountId();
|
|
|
- if (!accountIdList.isEmpty()) {
|
|
|
- //筛选巨量引擎剔除的用户
|
|
|
- List<String> removeList = accountIdList.stream().filter(item -> !dataList.contains(item)).collect(toList());
|
|
|
- //筛选巨量引擎新增的用户
|
|
|
- List<String> addList = dataList.stream().filter(item -> !accountIdList.contains(item)).collect(toList());
|
|
|
- //修改剔除的用户状态
|
|
|
- if (!removeList.isEmpty()) {
|
|
|
- ctopAgentAccountMapper.updateAccountState(removeList, 1);
|
|
|
- }
|
|
|
- //保存新增的用户
|
|
|
- if (!addList.isEmpty()) {
|
|
|
- ctopAgentAccountMapper.insertAccountData(addList, ADVERTISER_ID, df.format(new Date()));
|
|
|
}
|
|
|
- } else {
|
|
|
- ctopAgentAccountMapper.insertAccountData(dataList, ADVERTISER_ID, df.format(new Date()));
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
result.setSuccess(true);
|
|
|
result.setMessage("success");
|
|
|
return result;
|
|
@@ -409,11 +418,11 @@ public class AgentManagementServiceImpl implements AgentManagementService {
|
|
|
* @create: 2021-07-14
|
|
|
*/
|
|
|
@Override
|
|
|
- public JSONObject selectAgentAdvertiser(int pageNum, int pageSize) {
|
|
|
+ public JSONObject selectAgentAdvertiser(int pageNum, int pageSize, String account) {
|
|
|
// 请求参数
|
|
|
Map data = new HashMap() {
|
|
|
{
|
|
|
- put("advertiser_id", ADVERTISER_ID);
|
|
|
+ put("advertiser_id", account);
|
|
|
put("page", pageNum);
|
|
|
put("page_size", pageSize);
|
|
|
}
|