Browse Source

删除废弃实体

syh 4 năm trước cách đây
mục cha
commit
34942c9cdd
16 tập tin đã thay đổi với 145 bổ sung357 xóa
  1. 21 2
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  2. 0 150
      module-common/src/main/java/cn/com/ctop/common/module/controller/RuleDataWasteCostController.java
  3. 3 17
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataCreative.java
  4. 12 31
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataPlan.java
  5. 1 24
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataTarget.java
  6. 0 50
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataWasteCost.java
  7. 0 14
      module-common/src/main/java/cn/com/ctop/common/module/mapper/RuleDataWasteCostMapper.java
  8. 0 5
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/RuleDataWasteCostMapper.xml
  9. 0 14
      module-common/src/main/java/cn/com/ctop/common/module/service/IRuleDataWasteCostService.java
  10. 0 18
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDataWasteCostServiceImpl.java
  11. 6 1
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceMonitoringLinksCheckJob.java
  12. 12 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/controller/ByteDanceCreativeController.java
  13. 8 4
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/ByteDanceAdvertisePlan.java
  14. 1 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IByteDanceCreativeService.java
  15. 6 16
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceCreativeServiceImpl.java
  16. 75 9
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ReportServiceImpl.java

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

@@ -120,9 +120,28 @@ public class SampleTest {
 
     @Test
     public void testLoadRulePlanData(){
+        Date date = new Date();
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
-        for(CtopOauthToken token :tokens){
-            reportService.getAdvertiserPlanRuleData(token,new Date(),new Date(),CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        executorService = Executors.newFixedThreadPool(10);
+        countDownLatch = new CountDownLatch(tokens.size());
+        tokens.forEach(token -> executorService.submit(()->{
+            try {
+                Long start = System.currentTimeMillis();
+                reportService.getAdvertiserPlanRuleData(token,date,date,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+                Long end = System.currentTimeMillis();
+                log.info("账户数据获取完成:accountId=>{},耗时{}毫秒",token.getAccountId(),end-start);
+            }catch (Exception e){
+                e.printStackTrace();
+            }finally {
+                countDownLatch.countDown();
+            }
+
+        }));
+
+        try {
+            countDownLatch.await();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
         }
     }
 

+ 0 - 150
module-common/src/main/java/cn/com/ctop/common/module/controller/RuleDataWasteCostController.java

@@ -1,150 +0,0 @@
-package cn.com.ctop.common.module.controller;
-
-import cn.com.ctop.common.module.entity.RuleDataWasteCost;
-import cn.com.ctop.common.module.service.IRuleDataWasteCostService;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.system.query.QueryGenerator;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.Arrays;
-
- /**
- * 规则空耗清洗数据
- * @author jeecg-boot
- * @date   2020-11-16
- * @version V1.0
- */
-@Slf4j
-@Api(tags="规则空耗清洗数据")
-@RestController
-@RequestMapping("/ctop/rule/wasteCost")
-public class RuleDataWasteCostController {
-	@Autowired
-	private IRuleDataWasteCostService ruleDataWasteCostService;
-
-	/**
-	  * 分页列表查询
-	 * @param ruleDataWasteCost
-	 * @param pageNo
-	 * @param pageSize
-	 * @param req
-	 * @return
-	 */
-	@ApiOperation(value="规则空耗清洗数据-分页列表查询", notes="规则空耗清洗数据-分页列表查询")
-	@GetMapping(value = "/list")
-	public Result<IPage<RuleDataWasteCost>> queryPageList(RuleDataWasteCost ruleDataWasteCost,
-														  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
-														  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
-														  HttpServletRequest req) {
-		Result<IPage<RuleDataWasteCost>> result = new Result<>();
-		QueryWrapper<RuleDataWasteCost> queryWrapper = QueryGenerator.initQueryWrapper(ruleDataWasteCost, req.getParameterMap());
-		Page<RuleDataWasteCost> page = new Page<RuleDataWasteCost>(pageNo, pageSize);
-		IPage<RuleDataWasteCost> pageList = ruleDataWasteCostService.page(page, queryWrapper);
-		result.setSuccess(true);
-		result.setResult(pageList);
-		return result;
-	}
-
-	/**
-	  *   添加
-	 * @param ruleDataWasteCost
-	 * @return
-	 */
-	@ApiOperation(value="规则空耗清洗数据-添加", notes="规则空耗清洗数据-添加")
-	@PostMapping(value = "/add")
-	public Result<RuleDataWasteCost> add(@RequestBody RuleDataWasteCost ruleDataWasteCost) {
-		Result<RuleDataWasteCost> result = new Result<>();
-		try {
-			ruleDataWasteCostService.save(ruleDataWasteCost);
-			result.success("添加成功!");
-		} catch (Exception e) {
-			log.error(e.getMessage(),e);
-			result.error500("操作失败");
-		}
-		return result;
-	}
-
-	/**
-	  *  编辑
-	 * @param ruleDataWasteCost
-	 * @return
-	 */
-	@ApiOperation(value="规则空耗清洗数据-编辑", notes="规则空耗清洗数据-编辑")
-	@PutMapping(value = "/edit")
-	public Result<RuleDataWasteCost> edit(@RequestBody RuleDataWasteCost ruleDataWasteCost) {
-		Result<RuleDataWasteCost> result = new Result<RuleDataWasteCost>();
-		RuleDataWasteCost ruleDataWasteCostEntity = ruleDataWasteCostService.getById(ruleDataWasteCost.getId());
-		if(ruleDataWasteCostEntity==null) {
-			result.error500("未找到对应实体");
-		}else {
-			boolean ok = ruleDataWasteCostService.updateById(ruleDataWasteCost);
-			if(ok) {
-				result.success("修改成功!");
-			}
-		}
-
-		return result;
-	}
-
-	/**
-	  *   通过id删除
-	 * @param id
-	 * @return
-	 */
-	@ApiOperation(value="规则空耗清洗数据-通过id删除", notes="规则空耗清洗数据-通过id删除")
-	@DeleteMapping(value = "/delete")
-	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
-		try {
-			ruleDataWasteCostService.removeById(id);
-		} catch (Exception e) {
-			log.error("删除失败",e.getMessage());
-			return Result.error("删除失败!");
-		}
-		return Result.ok("删除成功!");
-	}
-
-	/**
-	  *  批量删除
-	 * @param ids
-	 * @return
-	 */
-	@ApiOperation(value="规则空耗清洗数据-批量删除", notes="规则空耗清洗数据-批量删除")
-	@DeleteMapping(value = "/deleteBatch")
-	public Result<RuleDataWasteCost> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
-		Result<RuleDataWasteCost> result = new Result<>();
-		if(ids==null || "".equals(ids.trim())) {
-			result.error500("参数不识别!");
-		}else {
-			this.ruleDataWasteCostService.removeByIds(Arrays.asList(ids.split(",")));
-			result.success("删除成功!");
-		}
-		return result;
-	}
-
-	/**
-	  * 通过id查询
-	 * @param id
-	 * @return
-	 */
-	@ApiOperation(value="规则空耗清洗数据-通过id查询", notes="规则空耗清洗数据-通过id查询")
-	@GetMapping(value = "/queryById")
-	public Result<RuleDataWasteCost> queryById(@RequestParam(name="id",required=true) String id) {
-		Result<RuleDataWasteCost> result = new Result<>();
-		RuleDataWasteCost ruleDataWasteCost = ruleDataWasteCostService.getById(id);
-		if(ruleDataWasteCost==null) {
-			result.error500("未找到对应实体");
-		}else {
-			result.setResult(ruleDataWasteCost);
-			result.setSuccess(true);
-		}
-		return result;
-	}
-}

+ 3 - 17
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataCreative.java

@@ -1,14 +1,11 @@
 package cn.com.ctop.common.module.entity;
 
-import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import org.jeecgframework.poi.excel.annotation.Excel;
 
 import java.util.Date;
 
@@ -25,28 +22,17 @@ import java.util.Date;
 @ApiModel(value="ctop_rule_data_creative对象", description="规则创意清洗数据")
 public class RuleDataCreative {
 
-	@TableId(type = IdType.AUTO)
+	@TableId
 	private Long id;
 	private Long accountId;
+	private String accountName;
 	private Long planId;
 	private String planName;
 	private Long creativeId;
-	/**presentedVideo*/
-	@Excel(name = "presentedVideo", width = 15)
-    @ApiModelProperty(value = "presentedVideo")
 	private Integer presentedVideo;
-	/**creativeTitle*/
-	@Excel(name = "creativeTitle", width = 15)
-    @ApiModelProperty(value = "creativeTitle")
 	private String creativeTitle;
-	/**source*/
-	@Excel(name = "source", width = 15)
-    @ApiModelProperty(value = "source")
 	private String source;
-	/**createTime*/
-    @ApiModelProperty(value = "createTime")
+	private Integer status;
 	private Date createTime;
-	/**updateTime*/
-    @ApiModelProperty(value = "updateTime")
 	private Date updateTime;
 }

+ 12 - 31
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataPlan.java

@@ -4,11 +4,9 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import org.jeecgframework.poi.excel.annotation.Excel;
 
 import java.math.BigDecimal;
 import java.util.Date;
@@ -32,47 +30,23 @@ public class RuleDataPlan {
 	private String accountName;
 	private Long planId;
 	private String planName;
-	/**externalUrl*/
-	@Excel(name = "externalUrl", width = 15)
-    @ApiModelProperty(value = "externalUrl")
 	private String externalUrl;
-	/**downloadUrl*/
-	@Excel(name = "downloadUrl", width = 15)
-    @ApiModelProperty(value = "downloadUrl")
 	private String downloadUrl;
-	/**cost*/
-	@Excel(name = "cost", width = 15)
-    @ApiModelProperty(value = "cost")
 	private BigDecimal cost;
-	/**convert*/
-	@Excel(name = "convert", width = 15)
-    @ApiModelProperty(value = "convert")
 	private Long convertNum;
-	/**convertCost*/
-	@Excel(name = "convertCost", width = 15)
-    @ApiModelProperty(value = "convertCost")
 	private BigDecimal convertCost;
-	/**nextDayOpenRate*/
-	@Excel(name = "nextDayOpenRate", width = 15)
-    @ApiModelProperty(value = "nextDayOpenRate")
 	private BigDecimal nextDayOpenRate;
 	private BigDecimal nextDayOpenCost;
 	private Long nextDayOpen;
-	/**付费方式*/
-	@Excel(name = "付费方式", width = 15)
-    @ApiModelProperty(value = "付费方式")
 	private String pricing;
-	/**出价*/
-	@Excel(name = "出价", width = 15)
-    @ApiModelProperty(value = "出价")
 	private BigDecimal budget;
-	/**createTime*/
-    @ApiModelProperty(value = "createTime")
+	private Integer status;
 	private Date createTime;
-	/**updateTime*/
-    @ApiModelProperty(value = "updateTime")
 	private Date updateTime;
 
+	public RuleDataPlan() {
+
+	}
 	public RuleDataPlan(JSONObject data, Long accountId) {
 		Long nextDayOpen = data.getLong("attribution_next_day_open_cnt");
 		if (null != nextDayOpen) {
@@ -96,7 +70,10 @@ public class RuleDataPlan {
 		if (null != cost) {
 			this.cost = cost;
 		}
-
+		BigDecimal convertCost = data.getBigDecimal("convert_cost");
+		if (null != convertCost) {
+			this.convertCost = convertCost;
+		}
 		String adName = data.getString("ad_name");
 		if (null != adName) {
 			this.planName = adName;
@@ -107,4 +84,8 @@ public class RuleDataPlan {
 		this.createTime = new Date();
 		this.updateTime = new Date();
 	}
+
+
+
+
 }

+ 1 - 24
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataTarget.java

@@ -1,6 +1,5 @@
 package cn.com.ctop.common.module.entity;
 
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -43,10 +42,6 @@ public class RuleDataTarget {
 	@Excel(name = "inventoryType", width = 15)
     @ApiModelProperty(value = "inventoryType")
 	private String inventoryType;
-	/**sceneInventory*/
-	@Excel(name = "sceneInventory", width = 15)
-    @ApiModelProperty(value = "sceneInventory")
-	private String sceneInventory;
 	/**district*/
 	@Excel(name = "district", width = 15)
     @ApiModelProperty(value = "district")
@@ -71,27 +66,9 @@ public class RuleDataTarget {
 	@Excel(name = "hideIfConverted", width = 15)
     @ApiModelProperty(value = "hideIfConverted")
 	private String hideIfConverted;
-	/**deepBidType*/
-	@Excel(name = "deepBidType", width = 15)
-    @ApiModelProperty(value = "deepBidType")
 	private String deepBidType;
-	/**scheduleTime*/
-	@Excel(name = "scheduleTime", width = 15)
-    @ApiModelProperty(value = "scheduleTime")
 	private String scheduleTime;
-	/**createTime*/
-    @ApiModelProperty(value = "createTime")
+	private Integer status;
 	private Date createTime;
-	/**updateTime*/
-    @ApiModelProperty(value = "updateTime")
 	private Date updateTime;
-
-	public RuleDataTarget(CtopOauthToken token, Long planId, JSONObject data, String authName) {
-		this.accountId = token.getAccountId();
-		this.accountName = authName;
-		this.planId = planId;
-		this.id = planId;
-		this.createTime = new Date();
-		this.updateTime = new Date();
-	}
 }

+ 0 - 50
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataWasteCost.java

@@ -1,50 +0,0 @@
-package cn.com.ctop.common.module.entity;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-import org.jeecgframework.poi.excel.annotation.Excel;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-/**
- * 规则空耗清洗数据
- * @author jeecg-boot
- * @date   2020-11-16
- * @version V1.0
- */
-@Data
-@TableName("ctop_rule_data_waste_cost")
-@EqualsAndHashCode(callSuper = false)
-@Accessors(chain = true)
-@ApiModel(value="ctop_rule_data_waste_cost对象", description="规则空耗清洗数据")
-public class RuleDataWasteCost {
-
-	/**id*/
-	@TableId(type = IdType.AUTO)
-	private Long id;
-	private Long accountId;
-	private String accountName;
-	private Long planId;
-	private String planName;
-	/**wasteCost*/
-	@Excel(name = "wasteCost", width = 15)
-    @ApiModelProperty(value = "wasteCost")
-	private BigDecimal wasteCost;
-	/**wasteDay*/
-	@Excel(name = "wasteDay", width = 15)
-    @ApiModelProperty(value = "wasteDay")
-	private Integer wasteDay;
-	/**createTime*/
-    @ApiModelProperty(value = "createTime")
-	private Date createTime;
-	/**updateTime*/
-    @ApiModelProperty(value = "updateTime")
-	private Date updateTime;
-}

+ 0 - 14
module-common/src/main/java/cn/com/ctop/common/module/mapper/RuleDataWasteCostMapper.java

@@ -1,14 +0,0 @@
-package cn.com.ctop.common.module.mapper;
-
-import cn.com.ctop.common.module.entity.RuleDataWasteCost;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-
-/**
- * 规则空耗清洗数据
- * @author: jeecg-boot
- * @date:   2020-11-16
- * @cersion: V1.0
- */
-public interface RuleDataWasteCostMapper extends BaseMapper<RuleDataWasteCost> {
-
-}

+ 0 - 5
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/RuleDataWasteCostMapper.xml

@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="cn.com.ctop.common.module.mapper.RuleDataWasteCostMapper">
-
-</mapper>

+ 0 - 14
module-common/src/main/java/cn/com/ctop/common/module/service/IRuleDataWasteCostService.java

@@ -1,14 +0,0 @@
-package cn.com.ctop.common.module.service;
-
-import cn.com.ctop.common.module.entity.RuleDataWasteCost;
-import com.baomidou.mybatisplus.extension.service.IService;
-
-/**
- * @Description: 规则空耗清洗数据
- * @Author: jeecg-boot
- * @Date:   2020-11-16
- * @Version: V1.0
- */
-public interface IRuleDataWasteCostService extends IService<RuleDataWasteCost> {
-
-}

+ 0 - 18
module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDataWasteCostServiceImpl.java

@@ -1,18 +0,0 @@
-package cn.com.ctop.common.module.service.impl;
-
-import cn.com.ctop.common.module.entity.RuleDataWasteCost;
-import cn.com.ctop.common.module.mapper.RuleDataWasteCostMapper;
-import cn.com.ctop.common.module.service.IRuleDataWasteCostService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.stereotype.Service;
-
-/**
- * 规则空耗清洗数据
- * @author jeecg-boot
- * @date   2020-11-16
- * @version V1.0
- */
-@Service
-public class RuleDataWasteCostServiceImpl extends ServiceImpl<RuleDataWasteCostMapper, RuleDataWasteCost> implements IRuleDataWasteCostService {
-
-}

+ 6 - 1
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceMonitoringLinksCheckJob.java

@@ -1,7 +1,9 @@
 package cn.com.ctop.job.bytedance.handler;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 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;
@@ -32,6 +34,8 @@ public class BytedanceMonitoringLinksCheckJob {
     private ISendMessageService sendMessageService;
     @Autowired
     private IProjectService projectService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
 
     @XxlJob("bytedanceMonitoringLinksCheckJob")
     public ReturnT<String> execute(String param) throws Exception{
@@ -45,10 +49,11 @@ public class BytedanceMonitoringLinksCheckJob {
                 continue;
             }
             for(UserAllocation allocation:allocations){
+                CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
                 List<ByteDanceAdvertisePlan> plans = advertisePlanService.getAllPlans(allocation.getAccountId(), DateUtils.formatDate(new Date()));
                 if(null!=plans&&!plans.isEmpty()){
                     for (ByteDanceAdvertisePlan plan:plans) {
-                        Map<String, Object> creativeDetail = creativeService.getCreativeDetail(allocation.getAccountId(), plan.getId());
+                        Map<String, Object> creativeDetail = creativeService.getCreativeDetail(token, plan.getId());
                         if(null!=creativeDetail.get("data")){
                             JSONObject data = (JSONObject) creativeDetail.get("data");
                             checkMonitorLink(data,plan,allocation);

+ 12 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/controller/ByteDanceCreativeController.java

@@ -1,6 +1,8 @@
 package cn.com.ctop.toutiao.modules.material.controller;
 
 import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.common.module.utils.StringUtils;
@@ -155,9 +157,18 @@ public class ByteDanceCreativeController {
     @PostMapping("/detail")
     public Map<String,Object>creativeDetail(@RequestParam(name = "planId",required = true,defaultValue = "0") Long planId,
                                             @RequestParam(name = "accountId",required = true,defaultValue = "0") Long accountId){
-        return byteDanceCreativeService.getCreativeDetail(accountId,planId);
+        Map<String,Object>result = new HashMap<>();
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        if(null == token){
+            ResultMapUtils.setResultMap(result,StatusCode.COMMON_PARAM_ERROR);
+            return result;
+        }
+        return byteDanceCreativeService.getCreativeDetail(token,planId);
     }
 
+    @Autowired
+    ICtopOauthTokenService tokenService;
+
     /**
      * 通过id删除
      *

+ 8 - 4
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/ByteDanceAdvertisePlan.java

@@ -122,7 +122,8 @@ public class ByteDanceAdvertisePlan {
     // ocpc广告转化出价
     private BigDecimal cpaBid;
 
-    private BigDecimal deepCpaBid;  // 深度优化出价
+    // 深度优化出价
+    private BigDecimal deepCpaBid;
 
     private String deepBidType;
 
@@ -139,6 +140,8 @@ public class ByteDanceAdvertisePlan {
 
     private String convertedTimeDuration;
 
+    private String inventoryType;
+
     // audience
     private String audience;
 
@@ -216,9 +219,6 @@ public class ByteDanceAdvertisePlan {
 
     public ByteDanceAdvertisePlan(JSONObject dataObject, String accountId) {
         this.id = dataObject.getLong("id");
-        if(id == 1680967865840670L||id ==1680968574657556L||id == 1680970557193228L ){
-            System.out.println(dataObject.toJSONString());
-        }
         this.accountId = accountId;
         String name = dataObject.getString("name");
         if (null != name && !"".equals(name.trim())) {
@@ -392,6 +392,10 @@ public class ByteDanceAdvertisePlan {
         if (null != externalUrl && !"".equals(externalUrl.trim())) {
             this.externalUrl = externalUrl;
         }
+        String inventoryType = dataObject.getString("inventory_type");
+        if(null!=inventoryType&&!"".equals(inventoryType.trim())){
+            this.inventoryType  =inventoryType;
+        }
     }
 
     public ByteDanceAdvertisePlan(String advertiserId, Long adId, JSONObject params) {

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IByteDanceCreativeService.java

@@ -24,7 +24,7 @@ public interface IByteDanceCreativeService extends IService<ByteDanceCreative> {
 
     void replaceBatch(List<ByteDanceCreative> creatives);
 
-    Map<String, Object> getCreativeDetail(Long accountId, Long planId);
+    Map<String, Object> getCreativeDetail(CtopOauthToken token, Long planId);
 
     Map<String,Object> updateCreative(JSONObject data);
 

+ 6 - 16
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceCreativeServiceImpl.java

@@ -1,9 +1,7 @@
 package cn.com.ctop.toutiao.modules.material.service.impl;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.*;
 import cn.com.ctop.toutiao.modules.material.entity.ByteDanceAdvertisePlan;
 import cn.com.ctop.toutiao.modules.material.entity.ByteDanceCreative;
@@ -37,8 +35,6 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
     @Autowired
     private ByteDanceCreativeMapper creativeMapper;
     @Autowired
-    private IUserAllocationService userAllocationService;
-    @Autowired
     private IByteDanceAdvertisePlanService byteDanceAdvertisePlanService;
 
     /**
@@ -203,26 +199,20 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
      * @return
      */
     @Override
-    public Map<String, Object> getCreativeDetail(Long accountId, Long planId){
+    public Map<String, Object> getCreativeDetail(CtopOauthToken token, Long planId){
         Map<String,Object>resultMap = new HashMap<>();
-        if(null == planId||planId == 0||null == accountId||accountId == 0){
+        if(null == planId||planId == 0||null == token){
             ResultMapUtils.setResultMap(resultMap,StatusCode.COMMON_PARAM_ERROR);
             resultMap.put("data",null);
             return resultMap;
         }
-        UserAllocation allocation = userAllocationService.getByAccountId(accountId);
-        if(null == allocation||allocation.getAccountStatus()!=0){
-            ResultMapUtils.setResultMap(resultMap,StatusCode.BYTEDANCE_PLAN_DATA_NOT_EXIST);
-            resultMap.put("data",null);
-            return resultMap;
-        }
+
         ByteDanceAdvertisePlan plan = byteDanceAdvertisePlanService.getById(planId);
         if(null == plan|| "AD_STATUS_DELETE".equals(plan.getOptStatus())){
             ResultMapUtils.setResultMap(resultMap,StatusCode.BYTEDANCE_ACCOUNT_DATA_NOT_EXIST);
             resultMap.put("data",null);
             return resultMap;
         }
-        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
         // 请求地址
         String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_creative_read");
         // 请求参数
@@ -238,7 +228,7 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
         Integer code = result.getInteger("code");
         String message = result.getString("message");
         if (null ==  code) {
-            log.info("广告创意获取详情失败,accountId:{},message:{}", accountId, message);
+            log.info("广告创意获取详情失败,accountId:{},message:{}", token.getAccountId(), message);
             resultMap.put("success", false);
             resultMap.put("code", -1);
             result.put("data",null);
@@ -254,7 +244,7 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
             return resultMap;
         }
         if(code!=0){
-            log.info("广告创意获取详情失败,accountId:{},message:{}", accountId, message);
+            log.info("广告创意获取详情失败,accountId:{},message:{}", token.getAccountId(), message);
             resultMap.put("success", false);
             resultMap.put("code", -1);
             result.put("data",null);
@@ -567,7 +557,7 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
         }
         data.remove("adIds");
         data.put("adId",planIdArray.getLong(0));
-        JSONObject detail = (JSONObject) this.getCreativeDetail(accountId,planIdArray.getLong(0)).get("data");
+        JSONObject detail = (JSONObject) this.getCreativeDetail(token,planIdArray.getLong(0)).get("data");
         String modifyTime = detail.getString("modifyTime");
         data.put("modifyTime",modifyTime);
         JSONObject params = initParams(data);

+ 75 - 9
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ReportServiceImpl.java

@@ -1,13 +1,7 @@
 package cn.com.ctop.toutiao.modules.report.service.impl;
 
-import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.entity.RuleDataPlan;
-import cn.com.ctop.common.module.entity.RuleDataTarget;
-import cn.com.ctop.common.module.entity.UserAllocation;
-import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.service.IRuleDataPlanService;
-import cn.com.ctop.common.module.service.IRuleDataTargetService;
-import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.entity.*;
+import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.HttpUtils;
@@ -15,6 +9,7 @@ import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.common.module.vo.ByteDanceAdvertiserReportDTO;
 import cn.com.ctop.toutiao.modules.material.entity.ByteDanceAdvertisePlan;
 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.entity.*;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
 import cn.com.ctop.toutiao.modules.report.service.*;
@@ -198,20 +193,91 @@ public class ReportServiceImpl implements IReportService {
                 dailyReport.setDownloadUrl(plan.getDownloadUrl());
                 dailyReport.setExternalUrl(plan.getExternalUrl());
                 dailyReport.setPricing(plan.getPricing());
-                RuleDataTarget target = new RuleDataTarget(token,dailyReport.getId(),data,allocation.getAuthName());
+                RuleDataTarget target = new RuleDataTarget();
+                JSONObject audienceObject = JSONObject.parseObject(plan.getAudience());
+                target.setAccountId(token.getAccountId());
+                target.setAccountName(allocation.getAuthName());
+                target.setPlanId(dailyReport.getPlanId());
+                target.setId(dailyReport.getPlanId());
+                target.setCreateTime(new Date());
+                target.setUpdateTime(new Date());
+                if(null!=audienceObject.getString("retargeting_tags_exclude")){
+                    target.setRetargetingTagsExclude(audienceObject.getString("retargeting_tags_exclude"));
+                }
+                target.setHideIfConverted(plan.getHideIfConverted());
+                target.setHideIfExists(plan.getHideIfExists());
 
+                target.setInventoryType(plan.getInventoryType());
+                if(null!=audienceObject.getString("city")){
+                    target.setDistrict(audienceObject.getString("city"));
+                }
+                if(null!=audienceObject.getString("gender")){
+                    target.setGender(audienceObject.getString("gender"));
+                }
+                if(null!=audienceObject.getString("age")){
+                    target.setAge(audienceObject.getString("age"));
+                }
+                if(null!=audienceObject.getString("exclude_flow_package")){
+                    target.setExcludeFlowPackage(audienceObject.getString("exclude_flow_package"));
+                }
+//		this.flowPackage = audience.getString("flow_package");
+                if(null!=audienceObject.getString("platform")){
+                    target.setPlatform(audienceObject.getString("platform"));
+                }
+                target.setDeepBidType(plan.getDeepBidType());
+                target.setScheduleTime(plan.getScheduleTime());
+
+                ruleDataTargetService.saveOrUpdate(target);
+                Map<String, Object> creativeDetail = creativeService.getCreativeDetail(token, plan.getId());
+                if(null!=creativeDetail.get("data")){
+                    JSONObject detail = (JSONObject) creativeDetail.get("data");
+                    formatCreativeData(detail,allocation,dailyReport);
+                }
             }
             ruleDataPlanService.saveOrUpdate(dailyReport);
         }
         getPlanRuleDataByPage(token, conditions, page + 1);
     }
 
+    private void formatCreativeData(JSONObject detail, UserAllocation allocation, RuleDataPlan plan) {
+        //广告来源
+        String source = detail.getString("source");
+        Integer isPresentedVideo = detail.getInteger("is_presented_video");
+        JSONArray creatives = detail.getJSONArray("creatives");
+        if(null!=creatives&&!creatives.isEmpty()){
+            for(int i=0;i<creatives.size();i++){
+                JSONObject data = creatives.getJSONObject(i);
+                Long creativeId = data.getLong("creative_id");
+                if(null!=creativeId){
+                    String title = data.getString("title");
+                    RuleDataCreative dataCreative = new RuleDataCreative();
+                    dataCreative.setId(creativeId);
+                    dataCreative.setCreativeId(creativeId);
+                    dataCreative.setCreativeTitle(title);
+                    dataCreative.setPlanId(plan.getId());
+                    dataCreative.setPlanName(plan.getPlanName());
+                    dataCreative.setAccountId(allocation.getAccountId());
+                    dataCreative.setAccountName(allocation.getAuthName());
+                    dataCreative.setSource(source);
+                    dataCreative.setPresentedVideo(isPresentedVideo);
+                    dataCreative.setCreateTime(new Date());
+                    dataCreative.setUpdateTime(new Date());
+                    ruleDataCreativeService.saveOrUpdate(dataCreative);
+                }
+            }
+        }
+    }
+
+    @Autowired
+    private IByteDanceCreativeService creativeService;
     @Autowired
     private IUserAllocationService userAllocationService;
     @Autowired
     private IRuleDataPlanService ruleDataPlanService;
     @Autowired
     private IRuleDataTargetService ruleDataTargetService;
+    @Autowired
+    private IRuleDataCreativeService ruleDataCreativeService;
 
     private void getPlanReportByPage(CtopOauthToken token, ByteDanceAdvertiserReportDTO conditions, int page) {
         conditions.setPage(page);