Sfoglia il codice sorgente

修改代理商报表获取逻辑

syh 4 anni fa
parent
commit
e534c5136f

+ 21 - 111
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -12,12 +12,8 @@ import cn.com.ctop.common.module.service.*;
 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.IKuaishouReportDailyAgentService;
-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.IByteDanceAdvertiserDataService;
-import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService;
 import cn.com.ctop.toutiao.modules.report.service.IReportService;
-import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.junit.Test;
@@ -31,7 +27,6 @@ import java.io.File;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -53,103 +48,18 @@ public class SampleTest {
     private IByteDanceAdvertiserDataService advertiserDataService;
     @Test
     public void loadBytedanceCreativeData() {
-        List<UserAllocation>allocations = userAllocationService.getByParams(633L,null,0);
-
-        if(null!=allocations&&!allocations.isEmpty()){
-            for (UserAllocation allocation:allocations) {
-                CtopOauthToken token = oauthTokenService.getTokenByAccountId(allocation.getAccountId());
-                advertiserDataService.getAdvertiserPlan(token, "", null, null);
-            }
-        }
-    }
-
-    @Autowired
-    private IByteDanceAdvertisePlanService advertisePlanService;
-    @Autowired
-    private IByteDanceCreativeService creativeService;
-    @Test
-    public void checkBytedanceCreativeMonitorLink() {
-        UserAllocation allocation = allocationService.getByAccountId(1655865770409997L);
-//        advertiserDataService.getAdvertiserPlan(token, "", null, null);
-        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");
-                    System.out.println(data.toJSONString());
-                    checkMonitorLink(data,plan,allocation);
-                }
-            }
-        }
-    }
-
-    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);
-        }
-    }
-
-    @Autowired
-    private ISendMessageService sendMessageService;
-    private void sendMessage(UserAllocation allocation, String errorMsg) {
-        sendMessageService.sendMessage(allocation.getUserId(),errorMsg);
+//        List<UserAllocation>allocations = userAllocationService.getByParams(633L,null,0);
+//
+//        if(null!=allocations&&!allocations.isEmpty()){
+//            for (UserAllocation allocation:allocations) {
+//                CtopOauthToken token = oauthTokenService.getTokenByAccountId(allocation.getAccountId());
+//                advertiserDataService.getAdvertiserPlan(token, "", null, null);
+//            }
+//        }
+        CtopOauthToken token = oauthTokenService.getTokenByAccountId(1667284088260616L);
+        advertiserDataService.getAdvertiserPlan(token, "", null, null);
     }
 
-
     @Autowired
     private IBindAccountLoginService bindAccountLoginService;
     @Autowired
@@ -220,18 +130,18 @@ public class SampleTest {
     @Test
     public void loadKuaishouAgentData() {
         kuaishouReportDailyAgentService.loginAgent();
-        for(int i=0;i<20;i++){
-            String currentDate = DateUtils.formatDate(DateUtils.addDay(new Date(),-i));
-            kuaishouReportDailyAgentService.getReport(currentDate,DateUtils.getNowDate("yyyy-MM-dd"));
-        }
-//
-//        try {
-//            for (int i = 1; i < 30; i++) {
-//                kuaishouReportDailyAgentService.getAccount(i);
-//            }
-//        } catch (Exception e) {
-//            e.printStackTrace();
+//        for(int i=0;i<20;i++){
+//            String currentDate = DateUtils.formatDate(DateUtils.addDay(new Date(),-i));
+//            kuaishouReportDailyAgentService.getReport(currentDate,DateUtils.getNowDate("yyyy-MM-dd"));
 //        }
+//
+        try {
+            for (int i = 1; i < 30; i++) {
+                kuaishouReportDailyAgentService.getAccount(i);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
     @Autowired

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaiShouDailyAgentMapper.java

@@ -23,4 +23,6 @@ public interface KuaiShouDailyAgentMapper extends BaseMapper<KuaiShouDailyAgent>
     KuaishouReportDailyAgentSum companyReportSum(@Param("startDate") String startDate, @Param("endDate") String endDate);
 
     List<KuaishouReportDailyAgent> companyReportAccountDetailList(@Param("date") String date, @Param("advertiserName") String advertiserName, @Param("isExportNullData") Integer o);
+
+    void replaceBatch(@Param(value = "list") List<KuaiShouDailyAgent> list);
 }

+ 47 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaiShouDailyAgentMapper.xml

@@ -297,5 +297,51 @@
             </if>
         </trim>
     </insert>
+    <insert id="replaceBatch">
+        replace into ctop_kuaishou_daily_agent(
+        `date`,
+        `account_id`,
+        `kid`,
+        `advertiser_name`,
+        `advertiser_create_time`,
+        `cost_campaign_count`,
+        `balance`,
+        `cost`,
+        `xianjin_cost`,
+        `fandian_cost`,
+        `kuangfan_cost`,
+        `jili_cost`,
+        `xinyong_cost`,
+        `fengmian_show_count`,
+        `fengmian_click_count`,
+        `sucai_show_count`,
+        `convert_count`,
+        `fengmian_click_rate`,
+        `convert_click_rate`
+        )
+        values
+        <foreach collection="list" item="agent" separator=",">
+            (#{agent.date},
+            #{agent.accountId},
+            #{agent.kid},
+            #{agent.advertiserName},
+            #{agent.advertiserCreateTime},
+            #{agent.costCampaignCount},
+            #{agent.balance},
+            #{agent.cost},
+            #{agent.xianjinCost},
+            #{agent.fandianCost},
+            #{agent.kuangfanCost},
+            #{agent.jiliCost},
+            #{agent.xinyongCost},
+            #{agent.fengmianShowCount},
+            #{agent.fengmianClickCount},
+            #{agent.sucaiShowCount},
+            #{agent.convertCount},
+            #{agent.fengmianClickRate},
+            #{agent.convertClickRate})
+        </foreach>
 
-</mapper>
+    </insert>
+
+</mapper>

+ 3 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAgentServiceImpl.java

@@ -54,6 +54,8 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
     @Autowired
     private KuaishouReportDailyAgentSumMapper kuaishouReportDailyAgentSumMapper;
     @Autowired
+    private KuaishouReportDailyAgentMapper kuaishouReportDailyAgentMapper;
+    @Autowired
     private KuaishouAgentAccountMapper kuaishouAgentAccountMapper;
     @Value("${jeecg.path.chrome-driver}")
     private String chromeDriver;
@@ -62,7 +64,7 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
 
     @Override
     public void replaceBatch(List<KuaiShouDailyAgent> list) {
-        for(KuaiShouDailyAgent agent:list){
+        for (KuaiShouDailyAgent agent:list) {
             kuaiShouDailyAgentMapper.insert(agent);
         }
     }
@@ -240,9 +242,6 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
     @Override
     public void getReport(String startDate, String endDate) {
         try {
-            if (!loginAgent()) {
-                return;
-            }
             String currentDate = startDate;
             Map<String, String> headerMap = new HashMap<>();
             headerMap.put("Accept", "application/json");

+ 1 - 5
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/ByteDanceVideoReportDailyController.java

@@ -124,10 +124,8 @@ public class ByteDanceVideoReportDailyController {
 	 @AutoLog(value = "头条视频按天汇总")
 	 @ApiOperation(value = "头条视频按天汇总", notes = "头条视频按天汇总")
 	 @PostMapping(value = "/bytedanceVideoInfoListDaily")
-	 public Result<PageInfo<ByteDanceVideoReportDaily>> bytedanceVideoInfoList(@RequestBody DateDTO dateDTO,
-																		   HttpServletRequest req){
+	 public Result<PageInfo<ByteDanceVideoReportDaily>> bytedanceVideoInfoList(@RequestBody DateDTO dateDTO){
 		 Result<PageInfo<ByteDanceVideoReportDaily>> result = new Result();
-
 		 Integer pageNo = dateDTO.getPageNo();
 		 Integer pageSize = dateDTO.getPageSize();
 		 if(pageNo == null){
@@ -136,9 +134,7 @@ public class ByteDanceVideoReportDailyController {
 		 if(pageSize == null){
 			 pageSize = 10;
 		 }
-
 		 PageInfo<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListDaily(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature(), dateDTO.getCost(), pageNo, pageSize, dateDTO.getProjectIds(), dateDTO.getAccountIds(), dateDTO.getSort());
-
 		 result.setResult(list);
 		 result.setSuccess(true);
 		 return result;