|
@@ -1,28 +1,28 @@
|
|
|
package cn.com.ctop.job.adq.data.service.impl;
|
|
package cn.com.ctop.job.adq.data.service.impl;
|
|
|
|
|
|
|
|
import cn.com.ctop.job.adq.data.entity.AdqAdvertiserList;
|
|
import cn.com.ctop.job.adq.data.entity.AdqAdvertiserList;
|
|
|
|
|
+import cn.com.ctop.job.adq.data.entity.AdqAgentAdvertiserList;
|
|
|
import cn.com.ctop.job.adq.data.mapper.AdqAdminAdvertiserListMapper;
|
|
import cn.com.ctop.job.adq.data.mapper.AdqAdminAdvertiserListMapper;
|
|
|
import cn.com.ctop.job.adq.data.service.IAdqAdminAdvertiserListService;
|
|
import cn.com.ctop.job.adq.data.service.IAdqAdminAdvertiserListService;
|
|
|
import cn.com.ctop.job.adq.data.utils.Check;
|
|
import cn.com.ctop.job.adq.data.utils.Check;
|
|
|
import cn.com.ctop.job.adq.data.utils.HttpUtils;
|
|
import cn.com.ctop.job.adq.data.utils.HttpUtils;
|
|
|
import cn.com.ctop.job.adq.utils.RandomStringGenerator;
|
|
import cn.com.ctop.job.adq.utils.RandomStringGenerator;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
+import com.alibaba.fastjson.JSONAware;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.time.Instant;
|
|
import java.time.Instant;
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
public class AdqAdminAdvertiserListServiceImpl implements IAdqAdminAdvertiserListService {
|
|
public class AdqAdminAdvertiserListServiceImpl implements IAdqAdminAdvertiserListService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private AdqAdminAdvertiserListMapper adminAdvertiserListMapper;
|
|
private AdqAdminAdvertiserListMapper adminAdvertiserListMapper;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void getAdminAdvertiserList(Long adminAdvertiserId, String accessToken, Integer cursor) {
|
|
public void getAdminAdvertiserList(Long adminAdvertiserId, String accessToken, Integer cursor) {
|
|
|
Map<String, Object> paramsMap = new HashMap<>();
|
|
Map<String, Object> paramsMap = new HashMap<>();
|
|
@@ -70,7 +70,7 @@ public class AdqAdminAdvertiserListServiceImpl implements IAdqAdminAdvertiserLis
|
|
|
}
|
|
}
|
|
|
if (!Check.isNull(addList)) {
|
|
if (!Check.isNull(addList)) {
|
|
|
adminAdvertiserListMapper.replaceAdqAccountList(addList);
|
|
adminAdvertiserListMapper.replaceAdqAccountList(addList);
|
|
|
- log.info("adq账户入库成功,业务单元ID:{},入库条数:{}",adminAdvertiserId, addList.size());
|
|
|
|
|
|
|
+ log.info("adq账户入库成功,业务单元ID:{},入库条数:{}", adminAdvertiserId, addList.size());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
JSONObject cursorPageInfo = data.getJSONObject("cursor_page_info");
|
|
JSONObject cursorPageInfo = data.getJSONObject("cursor_page_info");
|
|
@@ -90,4 +90,58 @@ public class AdqAdminAdvertiserListServiceImpl implements IAdqAdminAdvertiserLis
|
|
|
public void deleteAdvertiserListByAdminId(Long advertiserId) {
|
|
public void deleteAdvertiserListByAdminId(Long advertiserId) {
|
|
|
adminAdvertiserListMapper.deleteAdvertiserListByAdminId(advertiserId);
|
|
adminAdvertiserListMapper.deleteAdvertiserListByAdminId(advertiserId);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void getAgentInfo(Long adminAdvertiserId, Long advertiserId, String accessToken, Integer cursor) {
|
|
|
|
|
+ Map<String, Object> paramsMap = new HashMap<>();
|
|
|
|
|
+ paramsMap.put("access_token", accessToken);
|
|
|
|
|
+ long timestamp = Instant.now().getEpochSecond();
|
|
|
|
|
+ paramsMap.put("timestamp", String.valueOf(timestamp));
|
|
|
|
|
+ paramsMap.put("nonce", RandomStringGenerator.generateRandomString(32));
|
|
|
|
|
+ paramsMap.put("pagination_mode", "PAGINATION_MODE_CURSOR");
|
|
|
|
|
+ if (!Check.isNull(cursor)) {
|
|
|
|
|
+ paramsMap.put("cursor", cursor);
|
|
|
|
|
+ }
|
|
|
|
|
+ paramsMap.put("page_size", 100);
|
|
|
|
|
+ paramsMap.put("account_id", advertiserId);
|
|
|
|
|
+ JSONArray fields = new JSONArray();
|
|
|
|
|
+ fields.add("account_id");
|
|
|
|
|
+ fields.add("registration_type");
|
|
|
|
|
+ fields.add("corporation_name");
|
|
|
|
|
+ fields.add("corporation_licence");
|
|
|
|
|
+ fields.add("name");
|
|
|
|
|
+ fields.add("mdm_id");
|
|
|
|
|
+ fields.add("mdm_name");
|
|
|
|
|
+ fields.add("system_industry_id");
|
|
|
|
|
+ fields.add("customized_industry");
|
|
|
|
|
+ fields.add("agency_account_id");
|
|
|
|
|
+ paramsMap.put("fields", fields);
|
|
|
|
|
+
|
|
|
|
|
+ String s = HttpUtils.httpGet("https://api.e.qq.com/v3.0/advertiser/get", paramsMap, null);
|
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(s);
|
|
|
|
|
+ if (!Check.isNull(jsonObject)) {
|
|
|
|
|
+ Integer code = jsonObject.getInteger("code");
|
|
|
|
|
+ if (code == 0) {
|
|
|
|
|
+ JSONObject data = jsonObject.getJSONObject("data");
|
|
|
|
|
+ if (!Check.isNull(data)) {
|
|
|
|
|
+ JSONArray list = data.getJSONArray("list");
|
|
|
|
|
+ if (!Check.isNull(list)) {
|
|
|
|
|
+ JSONObject detail = list.getJSONObject(0);
|
|
|
|
|
+ if (!Check.isNull(detail)) {
|
|
|
|
|
+ AdqAgentAdvertiserList javaObject = JSONObject.toJavaObject(detail, AdqAgentAdvertiserList.class);
|
|
|
|
|
+ javaObject.setAdminAdvertiserId(adminAdvertiserId);
|
|
|
|
|
+ javaObject.setAdvertiserId(advertiserId);
|
|
|
|
|
+ adminAdvertiserListMapper.addAgent(javaObject);
|
|
|
|
|
+ log.info("账户ID:{},代理商数据更新成功", advertiserId);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<JSONObject> getAdvertiserList() {
|
|
|
|
|
+ return adminAdvertiserListMapper.getAdvertiserList();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|