瀏覽代碼

对外代码修改

yumeng 4 年之前
父節點
當前提交
0a2f107a67

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -171,6 +171,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/ctop/kuaishou/dailyPage/**", "anon");
         filterChainDefinitionMap.put("/rest/script/*", "anon");
         filterChainDefinitionMap.put("/ctop/checkTaskList/*", "anon");
+        filterChainDefinitionMap.put("/call/*", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

+ 64 - 119
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java

@@ -272,7 +272,6 @@ public class CallbackController {
             String advertiserId = json.getString("advertiserId");
             // 媒体类型: 1 头条 2 快手
             String mediaId = json.getString("mediaId");
-
             // 广告主名称
             String advertiserName = json.getString("advertiser_name");
             //创建人
@@ -283,16 +282,12 @@ public class CallbackController {
             String projectName = json.getString("projectName");
             BigDecimal warningProportion = json.getBigDecimal("WarningProportion");
             BigDecimal warningAmount = json.getBigDecimal("WarningAmount");
-
             JSONObject data = resultObject.getJSONObject("data");
-
             if (Check.isNull(data)) {
                 returnMap.put("code", -1);
                 returnMap.put("desc", "返回信息为空");
                 return returnMap;
-
             }
-
             data.remove("advertiser_id");
             JSONArray advertiser_ids = data.getJSONArray("advertiser_ids");
             if (Check.isNull(advertiser_ids)) {
@@ -302,126 +297,76 @@ public class CallbackController {
 
             }
             data.remove("advertiser_ids");
-            StringBuilder text = new StringBuilder();
-            for (int i = 0; i < advertiser_ids.size(); i++) {
-                Long advertiser_id = advertiser_ids.getLong(i);
-                JSONObject adJson = advertiserDataService.getAdvertiserList(data.getString("access_token"), advertiser_id);
-                Integer returnCode = adJson.getInteger("code");
-                if (returnCode == 0) {
-                    JSONArray dataArr = adJson.getJSONArray("data");
-                    if (!Check.isNull(dataArr)) {
-                        for (int j = 0; j < dataArr.size(); j++) {
-                            JSONObject dataJson = dataArr.getJSONObject(j);
-                            Long advertiser_id1 = dataJson.getLong("advertiser_id");
-                            data.put("advertiser_id", advertiser_id1);
-                            CtopOauthToken token = new CtopOauthToken(advertiserId, data);
-                            ctopOauthTokenService.saveOrUpdate(token);
-                            //获取广告主信息
-                            Map<String, Object> advertiserDataMap = advertiserDataService.getAdvertiserInfo(advertiser_id1 + "", data.getString("access_token"));
-                            Boolean getSuccess = (Boolean) advertiserDataMap.get("success");
-                            if (null == getSuccess || !getSuccess) {
-                                log.info("获取广告主信息失败,accountId:{},message:{}", token.getAccountId(), (String) advertiserDataMap.get("message"));
-                                text.append("账户id:" + advertiser_id + ",暂未获取数据权限,请检查账户")
-                                        .append("<br/>");
-                                continue;
-                            }
-
-                            Long accountId = token.getAccountId();
-                            QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
-                            userAllocationQueryWrapper.eq("account_id", accountId);
-                            userAllocationQueryWrapper.eq("media_id", 1);
-                            userAllocationQueryWrapper.orderByDesc("create_time");
-                            userAllocationQueryWrapper.last("limit 1");
-                            UserAllocation checkUserAllocation = allocationMapper.selectOne(userAllocationQueryWrapper);
-                            if (!Check.isNull(checkUserAllocation)) {
-                                text.append("账户id:" + accountId + ",授权名称为:" + (String) advertiserDataMap.get("name") + ",绑定失败,失败原因:已被" + checkUserAllocation.getUserName() + "绑定。")
-                                        .append("<br/>");
-                                continue;
-                            }
-                            text.append("账户id:" + accountId + ",授权名称为:" + (String) advertiserDataMap.get("name") + ",绑定成功。").append("<br/>");
-                            String systemType = json.getString("systemType");
-                            UserAllocation userAllocation = new UserAllocation();
-                            userAllocation.setUserId(userId);
-                            userAllocation.setUserName(userName);
-                            userAllocation.setAccountId(token.getAccountId());
-                            userAllocation.setAdvertiserName(advertiserName);
-                            userAllocation.setMediaId(mediaId);
-                            userAllocation.setProjectId(projectId);
-                            userAllocation.setProjectName(projectName);
-                            userAllocation.setSystemType(systemType);
-                            userAllocation.setAuthName((String) advertiserDataMap.get("name"));
-                            userAllocation.setAdvertiserId(advertiserId);
-                            userAllocation.setWarningProportion(warningProportion);
-                            userAllocation.setWarningAmount(warningAmount);
-                            userAllocation.setCreateTime(new Date());
-                            userAllocation.setUpdateTime(new Date());
-                            int g = allocationMapper.insert(userAllocation);
-                            if (g > 0) {
-                                log.info("同步分配用户表完成,task_id:{},accountId:{}", state, token.getAccountId());
-                            }
-                            //账号绑定
-                            bindAccountAuthService.addBindAccount(token.getAccountId(), KuaishouInterfaceConstant.LOGIN_TYPE_BYTEDANCE, advertiserId);
-                            new Thread(() -> reportService.loadBytedanceHistoryData(token)).start();
-                        }
 
-                    }
-
-                } else {
-                    data.put("advertiser_id", advertiser_id);
-                    CtopOauthToken token = new CtopOauthToken(advertiserId, data);
-                    ctopOauthTokenService.saveOrUpdate(token);
-                    //获取广告主信息
-                    Map<String, Object> advertiserDataMap = advertiserDataService.getAdvertiserInfo(advertiser_id + "", data.getString("access_token"));
-                    Boolean getSuccess = (Boolean) advertiserDataMap.get("success");
-                    if (null == getSuccess || !getSuccess) {
-                        log.info("获取广告主信息失败,accountId:{},message:{}", token.getAccountId(), (String) advertiserDataMap.get("message"));
-                        text.append("账户id:" + advertiser_id + ",暂未获取数据权限,请检查账户")
-                                .append("<br/>");
-                        continue;
-                    }
+            String access_token = data.getString("access_token");
+            String refresh_token = data.getString("refresh_token");
 
-                    Long accountId = token.getAccountId();
-                    QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
-                    userAllocationQueryWrapper.eq("account_id", accountId);
-                    userAllocationQueryWrapper.eq("media_id", 1);
-                    userAllocationQueryWrapper.orderByDesc("create_time");
-                    userAllocationQueryWrapper.last("limit 1");
-                    UserAllocation checkUserAllocation = allocationMapper.selectOne(userAllocationQueryWrapper);
-                    if (!Check.isNull(checkUserAllocation)) {
-                        text.append("账户id:" + accountId + ",授权名称为:" + (String) advertiserDataMap.get("name") + ",绑定失败,失败原因:已被" + checkUserAllocation.getUserName() + "绑定。")
-                                .append("<br/>");
-                        continue;
-                    }
-                    text.append("账户id:" + accountId + ",授权名称为:" + (String) advertiserDataMap.get("name") + ",绑定成功。").append("<br/>");
-                    String systemType = json.getString("systemType");
-                    UserAllocation userAllocation = new UserAllocation();
-                    userAllocation.setUserId(userId);
-                    userAllocation.setUserName(userName);
-                    userAllocation.setAccountId(token.getAccountId());
-                    userAllocation.setAdvertiserName(advertiserName);
-                    userAllocation.setMediaId(mediaId);
-                    userAllocation.setProjectId(projectId);
-                    userAllocation.setProjectName(projectName);
-                    userAllocation.setSystemType(systemType);
-                    userAllocation.setAuthName((String) advertiserDataMap.get("name"));
-                    userAllocation.setAdvertiserId(advertiserId);
-                    userAllocation.setWarningProportion(warningProportion);
-                    userAllocation.setWarningAmount(warningAmount);
-                    userAllocation.setCreateTime(new Date());
-                    userAllocation.setUpdateTime(new Date());
-                    int g = allocationMapper.insert(userAllocation);
-                    if (g > 0) {
-                        log.info("同步分配用户表完成,task_id:{},accountId:{}", state, token.getAccountId());
+            StringBuilder text = new StringBuilder();
+            for (int i = 0; i < advertiser_ids.size(); i++) {
+                String advertiser_id = (String) advertiser_ids.get(i);
+                data.put("advertiser_id", advertiser_id);
+                CtopOauthToken token = new CtopOauthToken(advertiser_id, data);
+                ctopOauthTokenService.saveOrUpdate(token);
+                //获取广告主信息
+                Map<String, Object> advertiserDataMap = advertiserDataService.getAdvertiserInfo(advertiser_id + "", data.getString("access_token"));
+                Boolean getSuccess = (Boolean) advertiserDataMap.get("success");
+                if (null == getSuccess || !getSuccess) {
+                    log.info("获取广告主信息失败,accountId:{},message:{}", token.getAccountId(), (String) advertiserDataMap.get("message"));
+                    text.append("账户id:" + advertiser_id + ",暂未获取数据权限,请检查账户")
+                            .append("<br/>");
+                    continue;
+                }
+                Long accountId = token.getAccountId();
+                QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
+                userAllocationQueryWrapper.eq("account_id", accountId);
+                userAllocationQueryWrapper.eq("media_id", 1);
+                userAllocationQueryWrapper.orderByDesc("create_time");
+                userAllocationQueryWrapper.last("limit 1");
+                UserAllocation checkUserAllocation = allocationMapper.selectOne(userAllocationQueryWrapper);
+                if (!Check.isNull(checkUserAllocation)) {
+                    text.append("账户id:" + accountId + ",授权名称为:" + (String) advertiserDataMap.get("name") + ",绑定失败,失败原因:已被" + checkUserAllocation.getUserName() + "绑定。")
+                            .append("<br/>");
+                    continue;
+                }
+                text.append("账户id:" + accountId + ",授权名称为:" + (String) advertiserDataMap.get("name") + ",绑定成功。").append("<br/>");
+                String systemType = json.getString("systemType");
+                UserAllocation userAllocation = new UserAllocation();
+                userAllocation.setUserId(userId);
+                userAllocation.setUserName(userName);
+                userAllocation.setAccountId(token.getAccountId());
+                userAllocation.setAdvertiserName(advertiserName);
+                userAllocation.setMediaId(mediaId);
+                userAllocation.setProjectId(projectId);
+                userAllocation.setProjectName(projectName);
+                userAllocation.setSystemType(systemType);
+                userAllocation.setAuthName((String) advertiserDataMap.get("name"));
+                userAllocation.setAdvertiserId(advertiserId);
+                userAllocation.setWarningProportion(warningProportion);
+                userAllocation.setWarningAmount(warningAmount);
+                userAllocation.setCreateTime(new Date());
+                userAllocation.setUpdateTime(new Date());
+                int g = allocationMapper.insert(userAllocation);
+                if (g > 0) {
+                    log.info("同步分配用户表完成,task_id:{},accountId:{}", state, token.getAccountId());
+                }
+                //账号绑定
+                bindAccountAuthService.addBindAccount(token.getAccountId(), KuaishouInterfaceConstant.LOGIN_TYPE_BYTEDANCE, advertiserId);
+                new Thread(() -> reportService.loadBytedanceHistoryData(token)).start();
+            }
+            JSONArray jsonArray = advertiserDataService.advertiserList(access_token);
+            if (!Check.isNull(jsonArray)) {
+                for (int i = 0; i < jsonArray.size(); i++) {
+                    JSONObject dataJson = jsonArray.getJSONObject(i);
+                    if (!Check.isNull(dataJson)) {
+                        CtopOauthToken token = new CtopOauthToken();
+                        token.setAccessToken("access_token");
+                        token.setRefreshToken(refresh_token);
+                        token.setId(dataJson.getString("advertiser_id"));
+                        ctopOauthTokenService.updateById(token);
                     }
-                    //账号绑定
-                    bindAccountAuthService.addBindAccount(token.getAccountId(), KuaishouInterfaceConstant.LOGIN_TYPE_BYTEDANCE, advertiserId);
-                    new Thread(() -> reportService.loadBytedanceHistoryData(token)).start();
                 }
-
-
             }
 
-
             returnMap.put("code", 0);
             returnMap.put("desc", text.toString());
 

+ 50 - 48
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -9,13 +9,12 @@ import cn.com.ctop.common.module.entity.UReportSubscriber;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.message.handle.impl.EmailSendMsgHandle;
 import cn.com.ctop.common.module.service.*;
-import cn.com.ctop.common.module.service.impl.UReportExportRest;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.report.service.IReportService;
-import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.junit.Test;
@@ -46,29 +45,27 @@ public class SampleTest {
     private IKuaiShouDailyAgentService kuaiShouDailyAgentService;
     @Autowired
     private IReportService reportService;
+    @Autowired
+    private IByteDanceAdvertiserDataService byteDanceAdvertiserDataService;
 
     @Test
     public void loadBytedanceCreativeData() {
-        String accountIdString = "1661556811389966,1650504410207245,1652711697337351,1652711697724429,1650504410574859,1668459522250759";
-        String[] accountIds = accountIdString.split(",");
-        for(int i=0;i<accountIds.length;i++){
-            CtopOauthToken token = oauthTokenService.getTokenByAccountId(Long.parseLong(accountIds[i]));
-            reportService.getAdvertiserPlanReport(token,new Date(),new Date(),CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
-        }
+        byteDanceAdvertiserDataService.advertiserList("2093115cd521740b024a5811d361712e0b5c3303");
     }
 
     @Autowired
     private IBindAccountLoginService bindAccountLoginService;
     @Autowired
     private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
+
     @Test
-    public void loadKuaishouCookie(){
-        List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY,1);
-        if(list!=null&&!list.isEmpty()){
-            int i=0;
-            for (BindAccountLogin login:list) {
-                if(null==login.getCookie()||"".equals(login.getCookie().trim())){
-                    if(i>5){
+    public void loadKuaishouCookie() {
+        List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
+        if (list != null && !list.isEmpty()) {
+            int i = 0;
+            for (BindAccountLogin login : list) {
+                if (null == login.getCookie() || "".equals(login.getCookie().trim())) {
+                    if (i > 5) {
                         break;
                     }
                     kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login);
@@ -77,23 +74,24 @@ public class SampleTest {
             }
         }
     }
+
     static ExecutorService executorService = null;
     //线程计数器
     static CountDownLatch countDownLatch = null;
 
     @Test
-    public void deleteKuaishouComment(){
+    public void deleteKuaishouComment() {
         Long start = System.currentTimeMillis();
-        List<BindAccountLogin>loginList = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY,1);
+        List<BindAccountLogin> loginList = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
         if (loginList != null && !loginList.isEmpty()) {
             executorService = Executors.newFixedThreadPool(5);
             countDownLatch = new CountDownLatch(loginList.size());
-            loginList.forEach(login -> executorService.submit(()->{
+            loginList.forEach(login -> executorService.submit(() -> {
                 try {
-                    kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(),login);
-                }catch (Exception e){
-                    log.error(e.getMessage(),e);
-                }finally {
+                    kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(), login);
+                } catch (Exception e) {
+                    log.error(e.getMessage(), e);
+                } finally {
                     countDownLatch.countDown();
                 }
             }));
@@ -103,19 +101,21 @@ public class SampleTest {
                 e.printStackTrace();
             }
             Long end = System.currentTimeMillis();
-            log.info("快手删评论所用时长:{}毫秒",end-start);
+            log.info("快手删评论所用时长:{}毫秒", end - start);
         }
     }
+
     @Autowired
     private IUserAllocationService allocationService;
+
     @Test
     public void testLoadBytedanceData() {
-        List<UserAllocation>allocations = allocationService.getByParams(435L,null,0);
-        for (UserAllocation allocation:allocations) {
-            for(int i=2;i<10;i++){
+        List<UserAllocation> allocations = allocationService.getByParams(435L, null, 0);
+        for (UserAllocation allocation : allocations) {
+            for (int i = 2; i < 10; i++) {
                 CtopOauthToken token = oauthTokenService.getTokenByAccountId(allocation.getAccountId());
-                Date getDate = DateUtils.addDay(new Date(),-i);
-                reportService.getAdvertiserReport(token,getDate,getDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+                Date getDate = DateUtils.addDay(new Date(), -i);
+                reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
             }
         }
     }
@@ -129,10 +129,10 @@ public class SampleTest {
 //
         kuaishouReportDailyAgentService.loginAgent();
         try {
-            for(int i=1;i<30;i++){
+            for (int i = 1; i < 30; i++) {
                 kuaishouReportDailyAgentService.getAccount(i);
             }
-        }catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
         }
 //        String currentDate = D  ateUtils.formatDate(DateUtils.addDay(new Date(),-1));
@@ -144,19 +144,20 @@ public class SampleTest {
 
     @Autowired
     private ICtopCheckTaskListService checkTaskListService;
+
     @Test
-    public void checkDataStateJobTest(){
+    public void checkDataStateJobTest() {
         //查询需要检查的任务列表
-        List<CtopCheckTaskList> ctopCheckTaskList= checkTaskListService.queryExecuteList("checkDataStateJob");
-        if(ctopCheckTaskList!=null){
-            ctopCheckTaskList.forEach(it-> groovyScriptExecutor.execute(it));
+        List<CtopCheckTaskList> ctopCheckTaskList = checkTaskListService.queryExecuteList("checkDataStateJob");
+        if (ctopCheckTaskList != null) {
+            ctopCheckTaskList.forEach(it -> groovyScriptExecutor.execute(it));
         }
     }
 
     @Test
     public void loadAccountData() {
         CtopOauthToken token = oauthTokenService.getTokenByAccountId(1665922219192387L);
-        reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-09-01","yy-MM-dd"),  DateUtils.parseDate("2020-09-01","yy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+        reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-09-01", "yy-MM-dd"), DateUtils.parseDate("2020-09-01", "yy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
     }
 
     @Autowired
@@ -167,24 +168,25 @@ public class SampleTest {
     IUReportService uReportService;
 
     @Test
-    public void sendUReport(){
-        uReportService.uReportList().forEach(uReport->{
+    public void sendUReport() {
+        uReportService.uReportList().forEach(uReport -> {
             List<UReportSubscriber> uReportSubscriber = uReportService.getUReportSubscriberByFileId(uReport.getString("id"));
-            if(!uReportSubscriber.isEmpty()){
-                String title=uReport.getString("name").replace(".ureport.xml","");
-                String content="您订阅的日报在附件中请注意查收》》》";
+            if (!uReportSubscriber.isEmpty()) {
+                String title = uReport.getString("name").replace(".ureport.xml", "");
+                String content = "您订阅的日报在附件中请注意查收》》》";
                 //下载文件到本地
                 uReportExportService.exportExcel(uReport.getString("name"));
-                uReportSubscriber.forEach(sender->{
-                    emailSendMsgHandle.SendAttachment("bijiequan@c-top.com.cn",title,content,
-                            new File(System.getProperty("user.dir")+ File.separator + "uReport"+File.separator+uReport.getString("name").replace("ureport.xml","")+"xlsx"));
-                }); }
+                uReportSubscriber.forEach(sender -> {
+                    emailSendMsgHandle.SendAttachment("bijiequan@c-top.com.cn", title, content,
+                            new File(System.getProperty("user.dir") + File.separator + "uReport" + File.separator + uReport.getString("name").replace("ureport.xml", "") + "xlsx"));
+                });
+            }
         });
         //发完全部订阅,删除文件
-        File file =new File(System.getProperty("user.dir")+ File.separator + "uReport");
-        File[] files=file.listFiles();
-        if(files!=null&&files.length>0){
-            for (File f: files){
+        File file = new File(System.getProperty("user.dir") + File.separator + "uReport");
+        File[] files = file.listFiles();
+        if (files != null && files.length > 0) {
+            for (File f : files) {
                 f.delete();
             }
         }

+ 3 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IByteDanceAdvertiserDataService.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.toutiao.modules.material.service;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 
 import java.util.Map;
@@ -35,4 +36,6 @@ public interface IByteDanceAdvertiserDataService {
     void getMaterialList(CtopOauthToken token);
 
     void getImageByPage(CtopOauthToken token, String imageIds, int page);
+
+    JSONArray advertiserList(String token);
 }

+ 47 - 12
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -46,6 +46,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
             params.put("advertiser_id", accountId);
             String result = HttpUtils.httpGetRequest(url, headers, params);
             JSONObject jsonObject = JSONObject.parseObject(result);
+            System.err.println(jsonObject);
             if (Check.isNull(jsonObject)) {
                 throw new Exception("返回结果为空");
             }
@@ -82,9 +83,9 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
     }
 
     @Override
-    public Map<String, Object> getAdvertiserInfo(String accountId,String token) {
+    public Map<String, Object> getAdvertiserInfo(String accountId, String token) {
         Map<String, Object> resultMap = new HashMap<>();
-     //   CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
+        //   CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
         //2: 根据token以及用户id获取用户信息数据
         String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_advertiser_info");
         Map<String, String> headers = new HashMap<>();
@@ -97,7 +98,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         JSONObject jsonObject = JSONObject.parseObject(result);
         int code = jsonObject.getInteger("code");
 
-        if (code!=0) {
+        if (code != 0) {
             log.info("获取广告主信息接口异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
             resultMap.put("success", false);
             resultMap.put("code", -1);
@@ -122,6 +123,40 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
     }
 
 
+    @Override
+    public JSONArray advertiserList(String token) {
+        Map<String, Object> resultMap = new HashMap<>();
+        //   CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
+        //2: 根据token以及用户id获取用户信息数据
+        String url = "https://ad.oceanengine.com/open_api/oauth2/advertiser/get/";
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        TreeMap<String, Object> params = new TreeMap<>();
+        params.put("access_token", token);
+        String appId = PropertiesUtils.getValue("bytedance_config", "bytedance_appid");
+        String secret = PropertiesUtils.getValue("bytedance_config", "bytedance_secret");
+        params.put("secret", secret);
+        params.put("app_id", appId);
+        String result = HttpUtils.httpGetRequest(url, headers, params);
+        JSONObject jsonObject = JSONObject.parseObject(result);
+        log.info("返回信息:{}", jsonObject);
+        Integer code = jsonObject.getInteger("code");
+        if (code == 0) {
+            JSONObject dataJson = jsonObject.getJSONObject("data");
+            if (!Check.isNull(dataJson)) {
+                JSONArray listArr = dataJson.getJSONArray("list");
+                if (!Check.isNull(listArr)) {
+                    return listArr;
+
+                }
+            }
+
+        }
+
+        return new JSONArray();
+    }
+
+
     public void getAd(CtopOauthToken token, int pageNum, String ids, String date, String updateDate) {
         JSONArray getIds = null;
         if (null != ids && !"".equals(ids)) {
@@ -260,7 +295,6 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
     }
 
 
-
     private void getCreativeByPage(CtopOauthToken token, String date, int pageNum) {
         JSONObject resultObject = getCreative(token, date, pageNum);
         Integer code = resultObject.getInteger("code");
@@ -324,7 +358,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         String result = HttpUtils.httpPostRequest(url, params, headers);
         JSONObject jsonObject = JSONObject.parseObject(result);
         int code = jsonObject.getInteger("code");
-        if (code!=0) {
+        if (code != 0) {
             log.error("广告计划更新状态接口异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
             resultMap.put("code", -1);
             resultMap.put("message", "广告计划更新状态接口异常");
@@ -375,7 +409,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         String result = HttpUtils.httpPostRequest(url, params, headers);
         JSONObject jsonObject = JSONObject.parseObject(result);
         int code = jsonObject.getInteger("code");
-        if (code!=0) {
+        if (code != 0) {
             log.info("修改计划出价接口异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
             resultMap.put("code", -1);
             resultMap.put("message", "修改计划出价接口异常");
@@ -457,13 +491,13 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
     @Override
     public Map<String, Object> advertiserCustomAudienceSelect(String accountId) {
         Map<String, Object> resultMap = new HashMap<>();
-        if(null == accountId||accountId.trim().equals("")){
-            ResultMapUtils.setResultMap(resultMap,StatusCode.COMMON_PARAM_ERROR);
+        if (null == accountId || accountId.trim().equals("")) {
+            ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_PARAM_ERROR);
             return resultMap;
         }
         CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
-        if(null==token){
-            ResultMapUtils.setResultMap(resultMap,StatusCode.COMMON_PARAM_ERROR);
+        if (null == token) {
+            ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_PARAM_ERROR);
             return resultMap;
         }
         String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_dmp_custom_audience_select");
@@ -581,6 +615,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
 
     @Autowired
     private IBytedanceImageInfoService imageInfoService;
+
     @Override
     public void getImageByPage(CtopOauthToken token, String imageIds, int page) {
         // 请求地址
@@ -602,7 +637,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         }
 
         JSONObject resultObject = HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, param);
-        if(null==resultObject){
+        if (null == resultObject) {
             log.error("获取图片素材库接口异常==》accountId:{}", token.getAccountId());
             return;
         }
@@ -646,7 +681,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         }
 
         JSONObject resultObject = HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, param);
-        if(null==resultObject){
+        if (null == resultObject) {
             log.error("获取视频素材库接口异常==》accountId:{}", token.getAccountId());
             return;
         }