ソースを参照

自动投放创建时校验监测链接

yangzian 3 年 前
コミット
2a09659563

+ 3 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/IMonitorBytedanceService.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.bytedance.advertise.service;
 
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.bytedance.advertise.vo.MonitorBytedanceAdVo;
+import org.jeecg.modules.bytedance.common.entity.CtopOauthToken;
 
 import java.util.Set;
 
@@ -21,4 +22,6 @@ public interface IMonitorBytedanceService{
     Result updAccountActionTrackUrl(MonitorBytedanceAdVo monitorBytedanceAdVo);
 
     Result selectAccountActionTrackUrlList(String accountId, String warningFlag, Set<String> operatorUserIds, Integer pageNum, Integer pageSize);
+
+    void trackUrlContrast(CtopOauthToken token,String accountId,String converId,String planId);
 }

+ 10 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/AiBytedanceAdvertiserStrategyServiceImpl.java

@@ -80,6 +80,9 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
     @Autowired
     IAiBytedanceAutocreateLogService iBytedanceAutocreateLogService;
 
+    @Autowired
+    IMonitorBytedanceService monitorBytedanceService;
+
     @Override
     public Long createCreative(CtopOauthToken token, AiBytedanceAdvertiserStrategy strategy, Integer createType, Long videoCnt, String openUrl) throws ParseException {
         UserAllocation userAllocation = userAllocationService.getByAccountId(strategy.getAccountId());
@@ -193,6 +196,9 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 adDplinkInfo.setImageMode(creativeImageMode);
                 adDplinkInfoService.save(adDplinkInfo);
 
+                monitorBytedanceService.trackUrlContrast(token,String.valueOf(strategy.getAccountId()),String.valueOf(strategy.getAdConvertId()),String.valueOf(adId));
+                log.info("账户id:{};==========不使用dp链接=======校验第三方监测链接==============>{};message==>{}",strategy.getAccountId());
+
                 BytedanceAiVideoCreativeLog creativeLog = new BytedanceAiVideoCreativeLog(strategy,adId,campaignId,video);
                 videoCreativeLogService.saveOrUpdate(creativeLog);
                 videoCnt --;
@@ -274,6 +280,10 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 adDplinkInfo.setStrategyId(strategy.getId());
                 adDplinkInfo.setImageMode(creativeImageMode);
                 adDplinkInfoService.save(adDplinkInfo);
+
+                monitorBytedanceService.trackUrlContrast(token,String.valueOf(strategy.getAccountId()),String.valueOf(strategy.getAdConvertId()),String.valueOf(adId));
+                log.info("账户id:{};==========使用dp链接=======校验第三方监测链接==============>{};message==>{}",strategy.getAccountId());
+
                 BytedanceAiVideoCreativeLog creativeLog = new BytedanceAiVideoCreativeLog(strategy,adId,campaignId,video);
                 videoCreativeLogService.saveOrUpdate(creativeLog);
                 videoCnt --;

+ 39 - 22
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/MonitorBytedanceServiceImpl.java

@@ -150,28 +150,7 @@ public class MonitorBytedanceServiceImpl implements IMonitorBytedanceService {
         //查询 配置的点击监测链接
         List<MonitorBytedanceAdVo> accountList = monitorBytedanceActionTrackUrlMapper.getAccountActionTrackUrl(accountId,"1",null);
         for (MonitorBytedanceAdVo accountInfo : accountList) {
-            /*
-            //1:校验 账户自动投放配置中 监测链接
-            //查询账户配置中的 转化id
-            List<MonitorBytedanceAdVo> converId = monitorBytedanceActionTrackUrlMapper.getBytedancStrategyAcctionId(accountInfo.getAccountId());
-            if (!Check.isNull(converId)){
-                // 账户id  和 转化id 查询 第三方监测链接
-                Result resultConvert = aiBytedanceAdvertiserStrategyService.readToolConvertInfo(converId.get(0).getAccountId(),converId.get(0).getConvertId());
-                if (!resultConvert.isSuccess()){
-                    return  Result.errorMsg(resultConvert.getMessage());
-                }
-                JSONObject jsonObject = (JSONObject) JSONObject.toJSON(resultConvert.getResult());
-                String action_track_url = jsonObject.getString("action_track_url");
-                //自动投放账户配置中的链接 != 监测链接配置
-                if (!StringUtils.equals(action_track_url,accountInfo.getActionTrackUrl())){
-                    //发送预警消息
-                    sendEnterpriseWeiXinMessage(accountInfo);
-                    log.info("accountId:=={}==目标转化id:{}=====第三方点击监测链接与自动投放配置不一致,已发送企业微信通知============",accountInfo.getAccountId(),converId.get(0).getConvertId());
-                    continue;
-                }
-            }
-*/
-            //2:校验 拉取后台计划 监测链接
+            //校验 拉取后台计划 监测链接
             //根据账户 查询头条计划中的 点击监测链接
             List<MonitorBytedanceAdVo> actionTrackUrlList = monitorBytedanceActionTrackUrlMapper.getBytedancPlanActionTrackUrl(Long.valueOf(accountInfo.getAccountId()));
             if (!Check.isNull(actionTrackUrlList)){
@@ -210,4 +189,42 @@ public class MonitorBytedanceServiceImpl implements IMonitorBytedanceService {
 
 
 
+    /**
+     *
+     * @description: 自动投放中 账户自动创建时 校验第三方监测链接
+     *
+     * @param token
+     * @param accountId 账户id
+     * @param converId 转化目标id
+     * @param planId 计划id
+     * @return: void
+     * @author: zianY
+     * @time: 2022/1/13
+     */
+    public void trackUrlContrast(CtopOauthToken token,String accountId,String converId,String planId){
+        //校验 账户自动投放配置中 监测链接
+        //查询 链接配置
+        List<MonitorBytedanceAdVo> monitorBytedanceAdVos = monitorBytedanceActionTrackUrlMapper.getAccountActionTrackUrl(String.valueOf(accountId),"1",null);
+        if (!Check.isNull(monitorBytedanceAdVos)){
+            MonitorBytedanceAdVo bytedanceAdVo = monitorBytedanceAdVos.get(0);
+            // 账户id  和 转化id 查询 第三方监测链接
+            Result resultConvert = aiBytedanceAdvertiserStrategyService.readToolConvertInfo(accountId,converId);
+            if (resultConvert.isSuccess()){
+                JSONObject jsonObject = (JSONObject) JSONObject.toJSON(resultConvert.getResult());
+                String action_track_url = jsonObject.getString("action_track_url");
+                //自动投放账户配置中的链接 != 监测链接配置
+                if (!StringUtils.equals(action_track_url,bytedanceAdVo.getActionTrackUrl())){
+                    //关停计划
+                    marketingServiceImpl.updPlanStatus(token, Arrays.asList(Long.valueOf(planId)),"disable");
+                    //发送预警消息
+                    sendEnterpriseWeiXinMessage(bytedanceAdVo);
+                    log.info("accountId:=={}==目标转化id:{}=====自动投创建====第三方点击监测链接与自动投放配置不一致,已发送企业微信通知============",bytedanceAdVo.getAccountId(),bytedanceAdVo.getConvertId());
+                }
+            }
+            log.info("accountId:=={}==目标转化id:{}=====第三方点击监测链接获取失败",accountId,converId);
+        }
+        log.info("accountId:=={}==目标转化id为空。",accountId);
+    }
+
+
 }