Bläddra i källkod

修改头条批量创意列表代码逻辑

syh 5 år sedan
förälder
incheckning
ffa390c80c

+ 3 - 5
jeecg-boot-module-system/src/main/resources/application-wps.yml

@@ -56,11 +56,8 @@ spring:
   autoconfigure:
     exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
   datasource:
-#    url: jdbc:mysql://139.186.27.96:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
-#    username: hcst
-#    password: test@20190531
-#    driver-class-name: com.mysql.jdbc.Driver
-    url: jdbc:mysql://39.106.184.70:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+    url: jdbc:mysql://139.186.27.96:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+#    url: jdbc:mysql://39.106.184.70:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
     username: hcst
     password: test@20190531
     driver-class-name: com.mysql.jdbc.Driver
@@ -99,6 +96,7 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
+#          url: jdbc:mysql://139.186.27.96:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
           url: jdbc:mysql://39.106.184.70:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
           username: hcst
           password: test@20190531

+ 17 - 38
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -6,24 +6,23 @@ import cn.com.ctop.common.module.service.IBindAccountLoginService;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.CloudVideoProcessUtil;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.crawler.modules.pangolin.entity.PangolinApp;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinAppService;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinCrawlerService;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinLoginService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceCampaignService;
 import cn.com.ctop.toutiao.modules.report.service.IReportService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
-import org.jeecg.modules.ctop.entity.KuaishouMatcostAccountMay;
-import org.jeecg.modules.ctop.service.IKuaishouMatcostAccountMayService;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
-import java.math.BigDecimal;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -123,33 +122,6 @@ public class SampleTest {
         }
     }
 
-    @Autowired
-    private IKuaishouMatcostAccountMayService matcostAccountMayService;
-    @Test
-    public void testLoadMinDate(){
-        loadData();
-    }
-
-    private void loadData(){
-        KuaishouMatcostAccountMay matcostAccountMay = matcostAccountMayService.getOne();
-        if(null!=matcostAccountMay){
-            BigDecimal cost = matcostAccountMayService.getCostByParams(matcostAccountMay);
-            if(null!=cost&&!cost.toString().trim().equals("")){
-                matcostAccountMayService.updateCostByCode(matcostAccountMay.getVideoCode(),cost);
-            }else{
-                matcostAccountMayService.updateCostByCode(matcostAccountMay.getVideoCode(),BigDecimal.ZERO);
-            }
-//            String minDate = matcostAccountMayService.getMinDate(matcostAccountMay.getVideoCode());
-//            if(null == minDate||minDate.trim().equals("")){
-//                matcostAccountMayService.updateByCode(matcostAccountMay.getVideoCode(),"-");
-//            }else{
-//                matcostAccountMayService.updateByCode(matcostAccountMay.getVideoCode(),minDate);
-//            }
-
-            loadData();
-        }
-    }
-
     @Test
     public void testPangolinData() {
         QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
@@ -160,17 +132,24 @@ public class SampleTest {
         if (list != null && !list.isEmpty()) {
             for (BindAccountLogin bindAccountLogin : list) {
                 pangolinCrawlerService.getChannelList(bindAccountLogin);
-//                pangolinCrawlerService.getActivationList(bindAccountLogin, DateUtils.getNowDate("yyyy-MM-dd"), 1);
-//                pangolinCrawlerService.getCheckList(bindAccountLogin);
-//                QueryWrapper<PangolinApp> queryWrapper1 = new QueryWrapper<>();
-//                queryWrapper1.eq("account_name", bindAccountLogin.getAccountName());
-//                List<PangolinApp> appList = pangolinAppService.list(queryWrapper1);
-//                if (appList != null && !appList.isEmpty()) {
-//                    appList.forEach(pangolinApp -> pangolinCrawlerService.getRealTimeList(bindAccountLogin, pangolinApp.getAppId()));
-//                }
+                pangolinCrawlerService.getActivationList(bindAccountLogin, DateUtils.getNowDate("yyyy-MM-dd"), 1);
+                pangolinCrawlerService.getCheckList(bindAccountLogin);
+                QueryWrapper<PangolinApp> queryWrapper1 = new QueryWrapper<>();
+                queryWrapper1.eq("account_name", bindAccountLogin.getAccountName());
+                List<PangolinApp> appList = pangolinAppService.list(queryWrapper1);
+                if (appList != null && !appList.isEmpty()) {
+                    appList.forEach(pangolinApp -> pangolinCrawlerService.getRealTimeList(bindAccountLogin, pangolinApp.getAppId()));
+                }
             }
         }
     }
+    @Autowired
+    private IByteDanceCampaignService campaignService;
+    @Test
+    public void testGetCampaign(){
+        CtopOauthToken token = oauthTokenService.getOauthTokenByAccountId("1649600126891015");
+        campaignService.getAdvertiserCampaign(token,"1672261893872756",null);
+    }
 }
 
 

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

@@ -100,7 +100,6 @@ public class ByteDanceAdvertisePlanController {
                 result.error500("未知错误");
             }
         }
-
         return result;
     }
 

+ 8 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/controller/ByteDanceCampaignController.java

@@ -17,6 +17,8 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @Description: 今日头条广告组信息
@@ -62,9 +64,15 @@ public class ByteDanceCampaignController {
         if(null!=endDate&&!"".equals(endDate)){
             queryWrapper.le("campaign_create_time",endDate+" 11:59:59");
         }
+        queryWrapper.ne("status","CAMPAIGN_STATUS_DELETE");
         queryWrapper.orderByDesc("campaign_create_time");
         Page<ByteDanceCampaign> page = new Page<>(pageNo, pageSize);
         IPage<ByteDanceCampaign> pageList = byteDanceCampaignService.page(page, queryWrapper);
+        List<ByteDanceCampaign> records = pageList.getRecords();
+        if(null!=records&&!records.isEmpty()){
+            List<ByteDanceCampaign> campaigns = records.stream().map(campaign-> campaign.setCampaignStatus(campaign.getStatus().equalsIgnoreCase("CAMPAIGN_STATUS_ENABLE"))).collect(Collectors.toList());
+            pageList.setRecords(campaigns);
+        }
         result.setSuccess(true);
         result.setResult(pageList);
         return result;

+ 5 - 13
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/ByteDanceCampaign.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.toutiao.modules.material.entity;
 
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -67,16 +68,9 @@ public class ByteDanceCampaign {
     @Excel(name = "广告组时间戳,用于更新时提交,服务端判断是否基于最新信息修改", width = 15)
     @ApiModelProperty(value = "广告组时间戳,用于更新时提交,服务端判断是否基于最新信息修改")
     private String modifyTime;
-    @Excel(name = "广告组状态", width = 15)
-    @ApiModelProperty(value = "广告组状态")
+    @Dict(dicCode = "item_value", dictTable = "sys_dict_item", dicText = "item_text",extendsKey = "dict_id",extendsValue = "fbc3e2fc9e6f5cfa5f6aeddd4c3bf818")
     private String status;
     /**
-     * optStatus
-     */
-    @Excel(name = "optStatus", width = 15)
-    @ApiModelProperty(value = "optStatus")
-    private String optStatus;
-    /**
      * 广告组创建时间
      */
     @Excel(name = "广告组创建时间", width = 15)
@@ -99,6 +93,9 @@ public class ByteDanceCampaign {
     @ApiModelProperty(value = "updateTime")
     private Date updateTime;
 
+    @TableField(exist = false)
+    private Boolean campaignStatus;
+
     public ByteDanceCampaign() {
     }
 
@@ -111,7 +108,6 @@ public class ByteDanceCampaign {
         this.landingType = landingType;
         this.modifyTime = modifyTime;
         this.status = status;
-        this.optStatus = optStatus;
         this.campaignCreateTime = campaignCreateTime;
         this.campaignModifyTime = campaignModifyTime;
         this.createTime = createTime;
@@ -146,10 +142,6 @@ public class ByteDanceCampaign {
         if (null != status && !"".equals(status.trim())) {
             this.status = status;
         }
-        String optStatus = dataObject.getString("opt_status");
-        if (null != optStatus && !"".equals(optStatus.trim())) {
-            this.optStatus = optStatus;
-        }
         String campaignCreateTime = dataObject.getString("campaign_create_time");
         if (null != campaignCreateTime && !"".equals(campaignCreateTime.trim())) {
             this.campaignCreateTime = campaignCreateTime;

+ 2 - 7
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/ByteDanceCreative.java

@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.experimental.Accessors;
+import org.jeecg.common.aspect.annotation.Dict;
 import org.jeecgframework.poi.excel.annotation.Excel;
 
 import java.util.Date;
@@ -35,14 +36,9 @@ public class ByteDanceCreative {
      */
     @Excel(name = "广告计划id", width = 15)
     @ApiModelProperty(value = "广告计划id")
+    @Dict(dicCode = "id",dictTable="ctop_bytedance_advertise_plan",dicText="name")
     private Long planId;
     /**
-     * 头条平台id
-     */
-    @Excel(name = "头条平台id", width = 15)
-    @ApiModelProperty(value = "头条平台id")
-    private Long toutiaoId;
-    /**
      * 本平台广告主id
      */
     @Excel(name = "本平台广告主id", width = 15)
@@ -138,7 +134,6 @@ public class ByteDanceCreative {
     public ByteDanceCreative(JSONObject dataObject, CtopOauthToken token) {
         this.id = dataObject.getLong("creative_id");
         this.planId = dataObject.getLong("ad_id");
-        this.toutiaoId = dataObject.getLong("advertiser_id");
         this.accountId = token.getAccountId()+"";
         String title = dataObject.getString("title");
         if (null != title && !"".equals(title.trim())) {

+ 3 - 7
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceCampaignServiceImpl.java

@@ -149,6 +149,7 @@ public class ByteDanceCampaignServiceImpl extends ServiceImpl<ByteDanceCampaignM
 
         TreeMap<String, Object> params = new TreeMap<>();
         JSONObject filtering = new JSONObject();
+        filtering.put("status","CAMPAIGN_STATUS_ALL");
         if (null != ids && !"".equals(ids.trim())) {
             String[] idsArray = ids.split(StringUtils.COMMA);
             JSONArray filterIdsArray = new JSONArray();
@@ -165,9 +166,9 @@ public class ByteDanceCampaignServiceImpl extends ServiceImpl<ByteDanceCampaignM
         params.put("advertiser_id", token.getAccountId());
         params.put("page", pageNumber + "");
         String result = HttpUtils.httpGetRequest(url, headers, params);
+        System.out.println(result);
         JSONObject jsonObject = JSONObject.parseObject(result);
         Integer code = jsonObject.getInteger("code");
-
         if (null == code || !code.equals(0)) {
             log.error("获取广告组信息接口异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
             return;
@@ -177,7 +178,6 @@ public class ByteDanceCampaignServiceImpl extends ServiceImpl<ByteDanceCampaignM
             log.error("获取广告组信息不存在==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
             return;
         }
-        System.out.println(data.toJSONString());
         for (int i = 0; i < data.size(); i++) {
             JSONObject dataObject = data.getJSONObject(i);
             ByteDanceCampaign campaign = new ByteDanceCampaign(dataObject,token.getAccountId());
@@ -227,11 +227,7 @@ public class ByteDanceCampaignServiceImpl extends ServiceImpl<ByteDanceCampaignM
         if (null != getCampaignIds && !getCampaignIds.isEmpty()) {
             for (int i = 0; i < getCampaignIds.size(); i++) {
                 Long id = getCampaignIds.getLong(i);
-                ByteDanceCampaign campaign = this.getById(id);
-                if (null != campaign) {
-                    campaign.setOptStatus(optStatus);
-                }
-                this.updateById(campaign);
+                getAdvertiserCampaign(token,id+"",null);
             }
         }
         resultMap.put("code", 0);