Procházet zdrojové kódy

Merge branch 'master' into test

huangxuechao před 4 roky
rodič
revize
ef289a5745
12 změnil soubory, kde provedl 32 přidání a 49 odebrání
  1. 2 9
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/dockapi/MarketingServiceImpl.java
  2. 2 0
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/BytedanceAiVideoCreativeLog.java
  3. 3 3
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/enums/BytedanceCreativeMatTypeEnum.java
  4. 1 1
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/ByteDanceVideoInfoMapper.java
  5. 5 5
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/ByteDanceVideoInfoMapper.xml
  6. 1 1
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/IByteDanceVideoInfoService.java
  7. 11 21
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/AiBytedanceAdvertiserStrategyServiceImpl.java
  8. 2 2
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/ByteDanceVideoInfoServiceImpl.java
  9. 1 2
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/service/impl/FileInfoServiceImpl.java
  10. 0 1
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/utils/HttpUtils.java
  11. 2 2
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/utils/StringUtils.java
  12. 2 2
      jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/report/service/impl/BytedanceReportMaterialDailyServiceImpl.java

+ 2 - 9
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/dockapi/MarketingServiceImpl.java

@@ -303,8 +303,6 @@ public class MarketingServiceImpl implements MarketingService{
         return result.getJSONObject("data");
     }
 
-
-
     /**
      *
      * @description: 创建广告计划
@@ -331,9 +329,6 @@ public class MarketingServiceImpl implements MarketingService{
     }
 
 
-
-
-
     /**
      * 创建广告创意
      * @param
@@ -620,9 +615,7 @@ public class MarketingServiceImpl implements MarketingService{
         params.put("filtering", filtering);
         params.put("page", page);
         params.put("page_size", pageSize);
-        JSONObject jsonObject = HttpUtils.bytedanceGetRequest(token.getAccessToken(),
-                urlPath + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_campaign_get"),
-                params);
+        JSONObject jsonObject = HttpUtils.bytedanceGetRequest(token.getAccessToken(), urlPath + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_campaign_get"), params);
         Integer code = jsonObject.getInteger("code");
         if (null == code || !code.equals(0)) {
             log.error("获取广告组信息接口异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
@@ -630,7 +623,7 @@ public class MarketingServiceImpl implements MarketingService{
         }
         JSONArray data = jsonObject.getJSONObject("data").getJSONArray("list");
         if (null == data || data.isEmpty()) {
-            log.info("获取广告组信息为空==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
+//            log.info("获取广告组信息为空==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
             return Result.error("获取广告组信息为空");
         }
         for(int i=0;i<data.size();i++){

+ 2 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/BytedanceAiVideoCreativeLog.java

@@ -26,6 +26,7 @@ public class BytedanceAiVideoCreativeLog {
 	/**id*/
 	@TableId(type = IdType.AUTO)
 	private Long id;
+	private Long accountId;
 	/**videoCode*/
 	private String videoCode;
 	private Long campaignId;
@@ -44,6 +45,7 @@ public class BytedanceAiVideoCreativeLog {
 	private Date updateTime;
 
 	public BytedanceAiVideoCreativeLog(AiBytedanceAdvertiserStrategy strategy, Long adId, Long campaignId, ByteDanceVideoInfo video) {
+		this.accountId = strategy.getAccountId();
 		this.strategyId = strategy.getId();
 		this.adId = adId;
 		this.campaignId = campaignId;

+ 3 - 3
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/enums/BytedanceCreativeMatTypeEnum.java

@@ -6,9 +6,9 @@ public enum BytedanceCreativeMatTypeEnum {
      * 0 表示当天
      */
     BYTEDANCE_CREATIVE_MAT_TYPE_ENUM_NEW("1","上新",0L,0L),
-    BYTEDANCE_CREATIVE_MAT_TYPE_ENUM_HIGH_QUALITY("2","高质量",-14*60*24L,-1*60*24L),
-    BYTEDANCE_CREATIVE_MAT_TYPE_ENUM_MISSING("3","遗漏",-60*60*24L,-1*60*24L),
-    BYTEDANCE_CREATIVE_MAT_TYPE_ENUM_HISTORY("4","打捞",-14*60*24L,-1*60*24L);
+    BYTEDANCE_CREATIVE_MAT_TYPE_ENUM_HIGH_QUALITY("2","高质量",-4*60*24L,-1*60*24L),
+    BYTEDANCE_CREATIVE_MAT_TYPE_ENUM_MISSING("3","遗漏",-8*60*24L,-1*60*24L),
+    BYTEDANCE_CREATIVE_MAT_TYPE_ENUM_HISTORY("4","打捞",-8*60*24L,-1*60*24L);
 
     /**
      * 类型

+ 1 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/ByteDanceVideoInfoMapper.java

@@ -25,7 +25,7 @@ public interface ByteDanceVideoInfoMapper extends BaseMapper<ByteDanceVideoInfo>
      * @param videoCnt
      * @return
      */
-    List<ByteDanceVideoInfo> getNewVideoByParams(@Param(value = "accountId") Long accountId, @Param(value = "startTime")String startTime, @Param(value = "endTime")String endTime, @Param(value = "videoCnt")Long videoCnt,@Param(value = "creativeCnt")Long creativeCnt,@Param(value = "now") String now);
+    List<ByteDanceVideoInfo> getNewVideoByParams(@Param(value = "projectId") Long projectId,@Param(value = "accountId") Long accountId, @Param(value = "startTime")String startTime, @Param(value = "endTime")String endTime, @Param(value = "videoCnt")Long videoCnt,@Param(value = "creativeCnt")Long creativeCnt,@Param(value = "now") String now);
 
     List<ByteDanceVideoInfo> topMatByParams(@Param(value = "projectId")Long projectId, @Param(value = "accountId")Long accountId, @Param(value = "startTime")String startTime, @Param(value = "endTime")String endTime, @Param(value = "videoCnt")Long videoCnt,@Param(value = "now") String now);
 

+ 5 - 5
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/ByteDanceVideoInfoMapper.xml

@@ -69,11 +69,11 @@
     <select id="getNewVideoByParams"
             resultType="org.jeecg.modules.bytedance.advertise.entity.ByteDanceVideoInfo">
         select distinct video.*,
-        (select count(1) from ctop_bytedance_ai_video_creative_log l where l.video_code = video.signature and l.state_date = #{now}) as creativeNum,
+        (select count(1) from ctop_bytedance_ai_video_creative_log l where l.video_code = video.signature and l.account_id = video.account_id and l.state_date = #{now}) as creativeNum,
         (select count(1) from ctop_bytedance_creative c where c.video_id = video.vid and c.account_id = '${accountId}') as creativeCnt,
         (select count(1) from ctop_bytedance_video_slogen_info s where s.video_code = video.signature) as slogens
         from ctop_bytedance_video_info video
-        left join ctop_material_info cmi on video.signature = cmi.code
+        left join ctop_material_info cmi on video.signature = cmi.code and cmi.project_id = #{projectId}
         where account_id = #{accountId}
         and cmi.code is not null
         and cmi.offline_flag = 0
@@ -86,9 +86,9 @@
     <select id="topMatByParams" resultType="org.jeecg.modules.bytedance.advertise.entity.ByteDanceVideoInfo">
         select distinct video.*,
         a.totalCost,
-        (select count(1) from ctop_bytedance_ai_video_creative_log l where l.video_code = video.signature and l.state_date = #{now}) as creativeNum,
+        (select count(1) from ctop_bytedance_ai_video_creative_log l where l.video_code = video.signature and l.account_id = video.account_id and l.state_date = #{now}) as creativeNum,
         (select count(1) from ctop_bytedance_creative c where c.video_id = video.vid and c.account_id = '${accountId}') as creativeCnt,
-        (select count(1) from ctop_bytedance_video_slogen_info s where s.video_code = video.signature) as slogens
+        (select count(1) from ctop_bytedance_video_slogen_info s where s.video_code = video.signature ) as slogens
         from (select report.material_id, sum(cost) as totalCost
         from ctop_bytedance_report_material_daily report
         left join ctop_user_allocation cua on report.account_id = cua.account_id
@@ -114,7 +114,7 @@
     <select id="historyMatByParams" resultType="org.jeecg.modules.bytedance.advertise.entity.ByteDanceVideoInfo">
         select distinct video.*,
                a.totalCost,
-               (select count(1) from ctop_bytedance_ai_video_creative_log l where l.video_code = video.signature and l.state_date = #{now}) as creativeNum,
+               (select count(1) from ctop_bytedance_ai_video_creative_log l where l.video_code = video.signature and l.account_id = video.account_id and l.state_date = #{now}) as creativeNum,
                (select count(1) from ctop_bytedance_creative c where c.video_id = video.vid and c.account_id = '${accountId}') as creativeCnt,
                (select count(1) from ctop_bytedance_video_slogen_info s where s.video_code = video.signature) as slogens
         from (select report.material_id, sum(cost) as totalCost

+ 1 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/IByteDanceVideoInfoService.java

@@ -19,7 +19,7 @@ public interface IByteDanceVideoInfoService extends IService<ByteDanceVideoInfo>
 
     void updateMaterialType();
 
-    List<ByteDanceVideoInfo> listByParams(Long accountId, String startTime, String endTime, Long videoCnt,long creativeCnt);
+    List<ByteDanceVideoInfo> listByParams(Long projectId,Long accountId, String startTime, String endTime, Long videoCnt,long creativeCnt);
 
     List<ByteDanceVideoInfo> topMatByParams(Long projectId, Long accountId, String startTime, String endTime, Long videoCnt);
 

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

@@ -6,7 +6,6 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.base.Joiner;
-import com.google.gson.JsonObject;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.util.DateUtils;
@@ -107,21 +106,11 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
             log.info("获取{}视频素材为空=>accountId:{}",BytedanceCreativeMatTypeEnum.getNameByType(createType+""),token.getAccountId());
             return videoCnt;
         }
+        log.info("获取{}视频素材个数:{}=>accountId:{}",BytedanceCreativeMatTypeEnum.getNameByType(createType+""),videoInfos.size(),token.getAccountId());
 
         for (ByteDanceVideoInfo video:videoInfos) {
-            //1:过滤掉所有不存在于视频库的数据
-            MaterialInfo materialInfo = materialInfoService.getParams(video.getSignature(),1);
-            if(null == materialInfo){
-                continue;
-            }
-            //过滤掉所有未绑定文案的数据
-            List<BytedanceVideoSlogenInfo>slogenInfos = slogenInfoService.listByParams(video.getSignature(),1);
-            if(null == slogenInfos||slogenInfos.isEmpty()){
-                continue;
-            }
             Integer useDplinkIndex = strategy.getDpLinkIndexUsed();
             if(null==useDplinkIndex||useDplinkIndex.equals(0)){
-                Long dpIndex ;
                 AiBytedanceAdDplinkInfo adDplinkInfo = adDplinkInfoService.getlatestDpLinkInfo(strategy.getId(),strategy.getAccountId(),1);
                 if(null == adDplinkInfo){
                     adDplinkInfo = new AiBytedanceAdDplinkInfo();
@@ -148,7 +137,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 //计划名称
                 String adName = getAdName(strategy,null,video);
                 //计算本次出价
-                BigDecimal currentCpaBid = StringUtils.getRandomAdCpaBid(strategy.getAdBidCreateType(),strategy.getAdMaxBid(),strategy.getAdMinBid(),strategy.getAdStepBid(),adDplinkInfo.getAdBid());
+                BigDecimal currentCpaBid = StringUtils.getRandomAdCpaBid(strategy.getAdBidCreateType(),strategy.getAdMaxBid(),strategy.getAdMinBid(),strategy.getAdStepBid(),adDplinkInfo.getAdBid(),strategy.getAdCpaBid());
                 JSONObject adParams = getAdParams(strategy,adName,campaignId,currentCpaBid);
                 Long adId = createAdInfo(token,strategy,adParams);
                 if(null == adId){
@@ -170,6 +159,8 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                     log.info("创意创建失败:code==>{};message==>{}",code,message);
                     continue;
                 }
+                BytedanceAiVideoCreativeLog creativeLog = new BytedanceAiVideoCreativeLog(strategy,adId,campaignId,video);
+                videoCreativeLogService.saveOrUpdate(creativeLog);
                 videoCnt --;
                 if(videoCnt<=0){
                     return 0L;
@@ -207,7 +198,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 //计划名称
                 String adName = getAdName(strategy,dplinkCode,video);
                 //计算本次出价
-                BigDecimal currentCpaBid = StringUtils.getRandomAdCpaBid(strategy.getAdBidCreateType(),strategy.getAdMaxBid(),strategy.getAdMinBid(),strategy.getAdStepBid(),adDplinkInfo.getAdBid());
+                BigDecimal currentCpaBid = StringUtils.getRandomAdCpaBid(strategy.getAdBidCreateType(),strategy.getAdMaxBid(),strategy.getAdMinBid(),strategy.getAdStepBid(),adDplinkInfo.getAdBid(),strategy.getAdCpaBid());
                 adDplinkInfo.setAdBid(currentCpaBid);
                 JSONObject adParams = getAdParams(strategy,adName,campaignId,currentCpaBid);
                 Long adId = createAdInfo(token,strategy,adParams);
@@ -223,11 +214,10 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 JSONObject creativeParams = getCreativeParams(strategy,adId,video,token);
                 log.info("创意创建参数:{}",creativeParams);
                 JSONObject creativeObject =  marketingService.creativeCreate(token,adId,creativeParams);
+                log.info("创意创建返回数据:{}",creativeObject);
                 if(null!=creativeObject.getInteger("code")&&creativeObject.getInteger("code")!=0){
                     String message = creativeObject.getString("message");
                     Integer code = creativeObject.getInteger("code");
-                    //创建创意失败
-                    log.info("创意创建失败:code==>{};message==>{}",code,message);
                     continue;
                 }
                 BytedanceAiVideoCreativeLog creativeLog = new BytedanceAiVideoCreativeLog(strategy,adId,campaignId,video);
@@ -1005,13 +995,13 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
     private List<ByteDanceVideoInfo> getVideoInfoByCreateType(Long projectId,AiBytedanceAdvertiserStrategy strategy, String startTime, String endTime, Integer createType, Long videoCnt) {
         //1:上新素材 2:跑量素材 3:遗漏素材 4:打捞素材
         if(createType == 1||createType == 3){
-            return videoInfoService.listByParams(strategy.getAccountId(),startTime,endTime,videoCnt,0);
+            return videoInfoService.listByParams(projectId,strategy.getAccountId(),startTime,endTime,videoCnt,0);
         }else if(createType == 2){
             startTime = startTime.substring(0,10);
             endTime = endTime.substring(0,10);
             return videoInfoService.topMatByParams(projectId,strategy.getAccountId(),startTime,endTime,videoCnt);
         }else if(createType == 4){
-            return videoInfoService.listByParams(strategy.getAccountId(),startTime,endTime,videoCnt,20);
+            return videoInfoService.listByParams(projectId,strategy.getAccountId(),startTime,endTime,videoCnt,20);
         }
         return null;
     }
@@ -1507,12 +1497,12 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
 
     /**
      *
-     * @description:获取橙子建站站点列表
+     * 获取橙子建站站点列表
      * https://www.chengzijianzhan.com/tetris/page/XXXXXXXXXXXXX/(其中XX是建站ID,拼装后就可获得投放的URL/预览URL)
      * Android应用下载详情页 当广告计划app_type为"APP_ANDROID"时, 必填
      * @param accountId
-     * @return: org.jeecg.common.api.vo.Result
-     * @author: zianY
+     * @return org.jeecg.common.api.vo.Result
+     * @author zianY
      */
     @Override
     public Result getChengZiSite(String accountId) {

+ 2 - 2
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/ByteDanceVideoInfoServiceImpl.java

@@ -44,9 +44,9 @@ public class ByteDanceVideoInfoServiceImpl extends ServiceImpl<ByteDanceVideoInf
     }
 
     @Override
-    public List<ByteDanceVideoInfo> listByParams(Long accountId, String startTime, String endTime, Long videoCnt,long creativeCnt) {
+    public List<ByteDanceVideoInfo> listByParams(Long projectId,Long accountId, String startTime, String endTime, Long videoCnt,long creativeCnt) {
         String now = DateUtils.formatDate();
-        return videoInfoMapper.getNewVideoByParams(accountId,startTime,endTime,videoCnt,creativeCnt,now);
+        return videoInfoMapper.getNewVideoByParams(projectId,accountId,startTime,endTime,videoCnt,creativeCnt,now);
     }
 
     @Override

+ 1 - 2
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/service/impl/FileInfoServiceImpl.java

@@ -81,13 +81,12 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
         String result = null;
         for(int i=0;i<3;i++){
             JSONObject resultObject = marketingService.getSuggestImageId(token, vid);
-            log.info("获取推荐封面返回数据信息:{}",resultObject);
             if(null==resultObject||null==resultObject.getInteger("code")||0!=resultObject.getInteger("code")){
                 continue;
             }
             JSONObject data = resultObject.getJSONObject("data");
             String status = data.getString("status");
-            if(null!=status&& "SUCCESS".equals(status)){
+            if("SUCCESS".equals(status)){
                 JSONArray array  = data.getJSONArray("list");
                 JSONObject imageInfo = array.getJSONObject(0);
                 return imageInfo.getString("id");

+ 0 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/utils/HttpUtils.java

@@ -623,7 +623,6 @@ public class HttpUtils {
         String strReturn = "";
         try {
             String uri = url + "?" + mapParamsSortToStringBySeperator(params, "&");
-            System.err.println(uri);
             HttpGet httpGet = new HttpGet(uri);
             if (headers != null) {
                 Iterator<String> keyIter = headers.keySet().iterator();

+ 2 - 2
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/utils/StringUtils.java

@@ -190,11 +190,11 @@ public class StringUtils {
      * @param lastBid 上次创建计划出价
      * @author zianY
      */
-    public static BigDecimal  getRandomAdCpaBid(String type,BigDecimal maxBid,BigDecimal minBid,BigDecimal stepBid,BigDecimal lastBid){
+    public static BigDecimal  getRandomAdCpaBid(String type,BigDecimal maxBid,BigDecimal minBid,BigDecimal stepBid,BigDecimal lastBid,BigDecimal strategyCpaBid){
         BigDecimal reuslt = null;
         //固定出价
         if("FIX".equalsIgnoreCase(type)){
-            reuslt = lastBid.setScale(2,RoundingMode.DOWN);
+            reuslt = strategyCpaBid.setScale(2,RoundingMode.DOWN);
         }
         //随机出价
         if("RAND".equalsIgnoreCase(type)){

+ 2 - 2
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/report/service/impl/BytedanceReportMaterialDailyServiceImpl.java

@@ -8,7 +8,6 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.bytedance.common.utils.Check;
 import org.jeecg.modules.bytedance.report.entity.BytedanceReportMaterialDaily;
-import org.jeecg.modules.bytedance.report.entity.vo.ReportCostVo;
 import org.jeecg.modules.bytedance.report.mapper.BytedanceReportMaterialDailyMapper;
 import org.jeecg.modules.bytedance.report.service.IBytedanceReportMaterialDailyService;
 import org.springframework.context.annotation.Primary;
@@ -35,7 +34,8 @@ public class BytedanceReportMaterialDailyServiceImpl extends ServiceImpl<Bytedan
     @Resource
     private BytedanceReportMaterialDailyMapper bytedanceReportMaterialDailyMapper;
 
-    public Result getMaterialDailyReportByAccountId(String accountId, String startTime, String endTime,Integer pageNum,Integer pageSize){
+    @Override
+    public Result getMaterialDailyReportByAccountId(String accountId, String startTime, String endTime, Integer pageNum, Integer pageSize){
         PageHelper.startPage(pageNum,pageSize);
         List<Map<String, Object>> dailyReportList = bytedanceReportMaterialDailyMapper.selectMaterialDailyReportByAccountId(accountId, startTime, endTime);