Просмотр исходного кода

获取短剧 token 获取优化

zhaoxian 7 месяцев назад
Родитель
Сommit
2c1c2fb4e1

+ 3 - 1
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/mapper/CompassBindAdvertisersMapper.java

@@ -23,5 +23,7 @@ public interface CompassBindAdvertisersMapper extends BaseMapper<CompassBindAdve
 
 
     void insertRecord(@Param("accountId") Long accountId, @Param("unitId") Long unitId, @Param("alarmDetail") String text);
     void insertRecord(@Param("accountId") Long accountId, @Param("unitId") Long unitId, @Param("alarmDetail") String text);
 
 
-    void replaceBatchVideoList(@Param("videoGetList")  List<KuaishouVideoList> videoGetList);
+    void replaceBatchVideoList(@Param("videoGetList") List<KuaishouVideoList> videoGetList);
+
+    CompassBindAdvertisers getByAccountId(@Param("accountId") String accountId);
 }
 }

+ 9 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/mapper/xml/CompassBindAdvertisersMapper.xml

@@ -910,4 +910,13 @@
         </foreach>
         </foreach>
 
 
     </insert>
     </insert>
+
+    <select id="getByAccountId" resultType="cn.com.ctop.job.kuaishou.data.entity.CompassBindAdvertisers">
+        select advertiser_id,
+               advertiser_name,
+               corporation_name
+        from `media_api`.compass_bind_advertisers
+        where advertiser_id = #{accountId}
+    </select>
+
 </mapper>
 </mapper>

+ 8 - 6
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/CompassBindAdvertisersService.java

@@ -3,17 +3,19 @@ package cn.com.ctop.job.kuaishou.data.service;
 import cn.com.ctop.job.kuaishou.data.entity.CompassBindAdvertisers;
 import cn.com.ctop.job.kuaishou.data.entity.CompassBindAdvertisers;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 
- public interface CompassBindAdvertisersService extends IService<CompassBindAdvertisers> {
+public interface CompassBindAdvertisersService extends IService<CompassBindAdvertisers> {
 
 
-     void openapiGwUcV1Advertisers(Long advertiserId, String token);
+    void openapiGwUcV1Advertisers(Long advertiserId, String token);
 
 
-     void getCompassAdvertisersCampaignReportDaily(Long advertiserId, String accessToken, String startDate, String endDate, int page);
+    void getCompassAdvertisersCampaignReportDaily(Long advertiserId, String accessToken, String startDate, String endDate, int page);
 
 
-     void getCompassAdvertisersUnitReportDaily(Long advertiserId, String accessToken, String startDate, String endDate, int page);
+    void getCompassAdvertisersUnitReportDaily(Long advertiserId, String accessToken, String startDate, String endDate, int page);
 
 
-     void getCompassAdvertisersVideosReportDaily(Long advertiserId, String accessToken, String startDate, String endDate, int page);
+    void getCompassAdvertisersVideosReportDaily(Long advertiserId, String accessToken, String startDate, String endDate, int page);
 
 
-     void checkCompassAdvertisersUnit(Long advertiserId, String accessToken, String startDate, String endDate, int page);
+    void checkCompassAdvertisersUnit(Long advertiserId, String accessToken, String startDate, String endDate, int page);
 
 
     void getVideoList(Long valueOf, String token, String startDate, String endDate, int i);
     void getVideoList(Long valueOf, String token, String startDate, String endDate, int i);
+
+    CompassBindAdvertisers getByAccountId(String accountId);
 }
 }

+ 6 - 1
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/impl/CompassBindAdvertisersServiceImpl.java

@@ -87,7 +87,7 @@ public class CompassBindAdvertisersServiceImpl extends ServiceImpl<CompassBindAd
             log.error("获取快手[罗盘广告主]计划日报表异常:{},accountId:{}", message, advertiserId);
             log.error("获取快手[罗盘广告主]计划日报表异常:{},accountId:{}", message, advertiserId);
             return;
             return;
         }
         }
-        log.info("短剧返回:{}",resultJson);
+//        log.info("短剧返回:{}",resultJson);
 
 
         JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
         JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
         if (null == details || details.size() <= 0) {
         if (null == details || details.size() <= 0) {
@@ -813,4 +813,9 @@ public class CompassBindAdvertisersServiceImpl extends ServiceImpl<CompassBindAd
             log.info("短剧-视频列表数据获取完成:accountId:{}", advertiserId);
             log.info("短剧-视频列表数据获取完成:accountId:{}", advertiserId);
         }
         }
     }
     }
+
+    @Override
+    public CompassBindAdvertisers getByAccountId(String accountId) {
+        return baseMapper.getByAccountId(accountId);
+    }
 }
 }

+ 27 - 17
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/CompassBindAdvertisersJob.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.job.kuaishou.handler;
 package cn.com.ctop.job.kuaishou.handler;
 
 
+import cn.com.ctop.job.kuaishou.data.entity.CompassBindAdvertisers;
 import cn.com.ctop.job.kuaishou.data.service.CompassBindAdvertisersService;
 import cn.com.ctop.job.kuaishou.data.service.CompassBindAdvertisersService;
 import cn.com.ctop.job.kuaishou.data.service.IKuaishouVideoListService;
 import cn.com.ctop.job.kuaishou.data.service.IKuaishouVideoListService;
 import cn.com.ctop.job.kuaishou.data.service.IOauthTokenService;
 import cn.com.ctop.job.kuaishou.data.service.IOauthTokenService;
@@ -40,6 +41,23 @@ public class CompassBindAdvertisersJob {
 
 
     }
     }
 
 
+    private String getToken(String accountId) {
+        CompassBindAdvertisers advertiser = compassBindAdvertisersService.getByAccountId(accountId);
+        if (Check.isNull(advertiser)) {
+            return null;
+        }
+        String token = null;
+        String advertiserName = advertiser.getAdvertiserName();
+        if (!Check.isNull(advertiserName) && advertiserName.contains("汇创")) {
+            //汇创
+            token = tokenService.getAgentTokenByAgentId(14L);
+        } else {
+            //723 骄阳token
+            token = tokenService.getAgentTokenByAgentId(723L);
+        }
+        return token;
+    }
+
     /**
     /**
      * 获取罗盘绑定广告主今日计划日报表
      * 获取罗盘绑定广告主今日计划日报表
      */
      */
@@ -50,8 +68,7 @@ public class CompassBindAdvertisersJob {
             log.error("入参为空");
             log.error("入参为空");
             return;
             return;
         }
         }
-        //723 骄阳token
-        String token = tokenService.getAgentTokenByAgentId(723L);
+        String token = getToken(accountId);
         if (Check.isNull(token)) {
         if (Check.isNull(token)) {
             log.error("token 为空 !!!");
             log.error("token 为空 !!!");
             return;
             return;
@@ -77,8 +94,7 @@ public class CompassBindAdvertisersJob {
             log.error("入参为空");
             log.error("入参为空");
             return;
             return;
         }
         }
-        //723 骄阳token
-        String token = tokenService.getAgentTokenByAgentId(723L);
+        String token = getToken(accountId);
         if (Check.isNull(token)) {
         if (Check.isNull(token)) {
             log.error("token 为空 !!!");
             log.error("token 为空 !!!");
             return;
             return;
@@ -106,8 +122,7 @@ public class CompassBindAdvertisersJob {
             return;
             return;
         }
         }
 
 
-        //723 骄阳token
-        String token = tokenService.getAgentTokenByAgentId(723L);
+        String token = getToken(accountId);
         if (Check.isNull(token)) {
         if (Check.isNull(token)) {
             log.error("token 为空 !!!");
             log.error("token 为空 !!!");
             return;
             return;
@@ -133,8 +148,7 @@ public class CompassBindAdvertisersJob {
             log.error("入参为空");
             log.error("入参为空");
             return;
             return;
         }
         }
-        //723 骄阳token
-        String token = tokenService.getAgentTokenByAgentId(723L);
+        String token = getToken(accountId);
         if (Check.isNull(token)) {
         if (Check.isNull(token)) {
             log.error("token 为空 !!!");
             log.error("token 为空 !!!");
             return;
             return;
@@ -162,8 +176,7 @@ public class CompassBindAdvertisersJob {
             return;
             return;
         }
         }
 
 
-        //723 骄阳token
-        String token = tokenService.getAgentTokenByAgentId(723L);
+        String token = getToken(accountId);
         if (Check.isNull(token)) {
         if (Check.isNull(token)) {
             log.error("token 为空 !!!");
             log.error("token 为空 !!!");
             return;
             return;
@@ -189,8 +202,7 @@ public class CompassBindAdvertisersJob {
             log.error("入参为空");
             log.error("入参为空");
             return;
             return;
         }
         }
-        //723 骄阳token
-        String token = tokenService.getAgentTokenByAgentId(723L);
+        String token = getToken(accountId);
         if (Check.isNull(token)) {
         if (Check.isNull(token)) {
             log.error("token 为空 !!!");
             log.error("token 为空 !!!");
             return;
             return;
@@ -225,8 +237,7 @@ public class CompassBindAdvertisersJob {
             log.error("入参为空");
             log.error("入参为空");
             return;
             return;
         }
         }
-        //723 骄阳token
-        String token = tokenService.getAgentTokenByAgentId(723L);
+        String token = getToken(accountId);
         if (Check.isNull(token)) {
         if (Check.isNull(token)) {
             log.error("token 为空 !!!");
             log.error("token 为空 !!!");
             return;
             return;
@@ -253,8 +264,7 @@ public class CompassBindAdvertisersJob {
             log.error("入参为空");
             log.error("入参为空");
             return;
             return;
         }
         }
-        //723 骄阳token
-        String token = tokenService.getAgentTokenByAgentId(723L);
+        String token = getToken(accountId);
         if (Check.isNull(token)) {
         if (Check.isNull(token)) {
             log.error("token 为空 !!!");
             log.error("token 为空 !!!");
             return;
             return;
@@ -282,7 +292,7 @@ public class CompassBindAdvertisersJob {
             log.error("入参为空");
             log.error("入参为空");
             return;
             return;
         }
         }
-        String token = tokenService.getAgentTokenByAgentId(723L);
+        String token = getToken(accountId);
         if (Check.isNull(token)) {
         if (Check.isNull(token)) {
             log.error("token 为空 !!!");
             log.error("token 为空 !!!");
             return;
             return;