|
@@ -0,0 +1,124 @@
|
|
|
+package cn.com.ctop.job.bytedance.handler;
|
|
|
+
|
|
|
+import cn.com.ctop.common.module.entity.Project;
|
|
|
+import cn.com.ctop.common.module.entity.UserAllocation;
|
|
|
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
+import cn.com.ctop.common.module.service.IProjectService;
|
|
|
+import cn.com.ctop.common.module.service.ISendMessageService;
|
|
|
+import cn.com.ctop.common.module.service.IUserAllocationService;
|
|
|
+import cn.com.ctop.toutiao.modules.material.entity.ByteDanceAdvertisePlan;
|
|
|
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
|
|
|
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.xxl.job.core.biz.model.ReturnT;
|
|
|
+import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+import com.xxl.job.core.log.XxlJobLogger;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+public class BytedanceMonitoringLinksCheckJob {
|
|
|
+ @Autowired
|
|
|
+ private ICtopOauthTokenService tokenService;
|
|
|
+ @Autowired
|
|
|
+ private IUserAllocationService allocationService;
|
|
|
+ @Autowired
|
|
|
+ private IByteDanceAdvertisePlanService advertisePlanService;
|
|
|
+ @Autowired
|
|
|
+ private IByteDanceCreativeService creativeService;
|
|
|
+ @Autowired
|
|
|
+ private ISendMessageService sendMessageService;
|
|
|
+ @Autowired
|
|
|
+ private IProjectService projectService;
|
|
|
+
|
|
|
+ @XxlJob("bytedanceMonitoringLinksCheckJob")
|
|
|
+ public ReturnT<String> execute(String param) throws Exception{
|
|
|
+ List<Project> projects = projectService.listByMediaType(3,1);
|
|
|
+ if(null==projects||projects.isEmpty()){
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
+ }
|
|
|
+ for (Project project:projects) {
|
|
|
+ List<UserAllocation>allocations = allocationService.getByParams(project.getId(),null,0);
|
|
|
+ if(null==allocations||allocations.isEmpty()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for(UserAllocation allocation:allocations){
|
|
|
+ List<ByteDanceAdvertisePlan> plans = advertisePlanService.getAllPlans(allocation.getAccountId());
|
|
|
+ if(null!=plans&&!plans.isEmpty()){
|
|
|
+ for (ByteDanceAdvertisePlan plan:plans) {
|
|
|
+ Map<String, Object> creativeDetail = creativeService.getCreativeDetail(allocation.getAccountId(), plan.getId());
|
|
|
+ if(null!=creativeDetail.get("data")){
|
|
|
+ JSONObject data = (JSONObject) creativeDetail.get("data");
|
|
|
+ checkMonitorLink(data,plan,allocation);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ XxlJobLogger.log("监测链接检查完成");
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkMonitorLink(JSONObject data, ByteDanceAdvertisePlan plan, UserAllocation allocation) {
|
|
|
+ String downloadUrl = plan.getDownloadUrl();
|
|
|
+ boolean errorflag = false;
|
|
|
+ String errorMsg = "";
|
|
|
+ String token = plan.getName().split("-")[0];
|
|
|
+ String tokenInfo = "surl_token="+token;
|
|
|
+ String appType = plan.getAppType();
|
|
|
+
|
|
|
+ if(null!=downloadUrl){
|
|
|
+ if(null!=appType&&appType.equals("APP_IOS")){
|
|
|
+ if(!downloadUrl.equals("https://apps.apple.com/cn/app/id1468454200")){
|
|
|
+ errorMsg+= "应用下载链接填写异常;";
|
|
|
+ errorflag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(null!=appType&&appType.equals("APP_ANDROID")){
|
|
|
+ if(!downloadUrl.contains(token)){
|
|
|
+ errorMsg+= "应用下载链接填写异常;";
|
|
|
+ errorflag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //展示监测链接
|
|
|
+ String trackUrl = data.getString("trackUrl");
|
|
|
+ if(null!=trackUrl&&!trackUrl.trim().equals("")){
|
|
|
+ if(!trackUrl.contains(tokenInfo)){
|
|
|
+ errorMsg+= "展示监测链接填写异常;";
|
|
|
+ errorflag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //点击监测链接
|
|
|
+ String actionTrackUrl = data.getString("actionTrackUrl");
|
|
|
+ if(null!=actionTrackUrl&&!actionTrackUrl.trim().equals("")){
|
|
|
+ if(null!=appType&&appType.equals("APP_IOS")){
|
|
|
+ if(!actionTrackUrl.contains(tokenInfo)||!actionTrackUrl.contains("app_platform=ios")){
|
|
|
+ errorMsg+= "点击监测链接填写异常;";
|
|
|
+ errorflag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(null!=appType&&appType.equals("APP_ANDROID")){
|
|
|
+ if(!actionTrackUrl.contains(tokenInfo)||!actionTrackUrl.contains("tt/1967")){
|
|
|
+ errorMsg+= "点击监测链接填写异常;";
|
|
|
+ errorflag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //视频有效播放监测链接
|
|
|
+ String videoPlayEffectiveTrackUrl = data.getString("videoPlayEffectiveTrackUrl");
|
|
|
+ if(null!=videoPlayEffectiveTrackUrl&&!videoPlayEffectiveTrackUrl.trim().equals("")){
|
|
|
+ if(!actionTrackUrl.contains(tokenInfo)){
|
|
|
+ errorMsg+= "视频有效播放监测链接填写异常;";
|
|
|
+ errorflag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(errorflag){
|
|
|
+ sendMessage(allocation,"警告:账户:"+allocation.getAuthName()+"(id:"+allocation.getAccountId()+")下的广告计划:"+plan.getName()+"(id:"+plan.getId()+")"+"监测链接异常>>"+errorMsg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void sendMessage(UserAllocation allocation, String errorMsg) {
|
|
|
+ sendMessageService.sendMessage(allocation.getUserId(),errorMsg);
|
|
|
+ }
|
|
|
+}
|