浏览代码

替换监测链接

yumeng 4 年之前
父节点
当前提交
4eadf73ecb

+ 102 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java

@@ -5,6 +5,8 @@ import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
 import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.*;
 import cn.com.ctop.common.module.vo.ResFileDTO;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
@@ -13,6 +15,7 @@ import cn.com.ctop.toutiao.modules.report.service.IBytedancePlanDailyReportServi
 import cn.com.ctop.toutiao.modules.report.service.IBytedancePlanHourlyReportService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
 import cn.com.ctop.toutiao.modules.report.service.IReportService;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
@@ -68,12 +71,110 @@ public class TestController {
     private IMaterialImageInfoService iMaterialImageInfoService;
     @Autowired
     private IBytedanceReportService bytedanceReportService;
+    @Autowired
+    private IKuaiShouCreativeService creativeService;
+    @Autowired
+    private IBatchService batchService;
     static ExecutorService executorService = Executors.newFixedThreadPool(15);
     static ExecutorService videoService = Executors.newFixedThreadPool(5);
     static ExecutorService suzhaoService = Executors.newFixedThreadPool(5);
 
 
 
+
+    @GetMapping(value = "/campaignList")
+    public void campaignList() {
+        List<Long> list = new ArrayList();
+        list.add(6828954L);
+
+
+        for (int i = 0; i < list.size(); i++) {
+            Long accountId = list.get(i);
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            kuaishouInterfaceService.getCampaignList(oauthToken, null, null);
+        }
+
+    }
+
+
+    @GetMapping(value = "/creativeList")
+    public void creativeList() {
+        List<Long> list = new ArrayList();
+        list.add(6828954L);
+        for (int i = 0; i < list.size(); i++) {
+            Long accountId = list.get(i);
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            QueryWrapper<KuaiShouCampaign> campaignQueryWrapper = new QueryWrapper<>();
+            campaignQueryWrapper.eq("account_id", accountId);
+
+            List<KuaiShouCampaign> list1 = campaignService.list(campaignQueryWrapper);
+            for (KuaiShouCampaign campaign : list1) {
+                kuaishouInterfaceService.getAsyncCreativeListV2(oauthToken.getAccountId(), oauthToken.getAccessToken(), campaign.getCampaignId());
+               /* try {
+                 //   Thread.sleep(1000L);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }*/
+            }
+
+
+        }
+
+    }
+
+
+    @GetMapping(value = "/updateCreative")
+    public void updateCreative() {
+        List<Long> list = new ArrayList();
+        list.add(6828954L);
+        for (int i = 0; i < list.size(); i++) {
+            Long accountId = list.get(i);
+
+
+
+            JSONObject json = new JSONObject();
+            String clickTrackUrl = null;
+            if (accountId == 6828954L) {
+                clickTrackUrl = "https://uri6.com/tkio/yQ7VZva?imei=__IMEI2__&androidid=__ANDROIDID2__&oaid=__OAID__&mac=__MAC__&ip=__IP__&ry_adcreative_id=__CID__&ry_adplan_id=__DID__&ry_adplan_name=__DNAME__&ry_adgroup_id=__AID__&callback=__CALLBACK__&kscsite=__CSITE__&noredirect=true";
+            }
+            json.put("clickTrackUrl", clickTrackUrl);
+
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            QueryWrapper<KuaiShouCreative> creativeQueryWrapper = new QueryWrapper<>();
+            creativeQueryWrapper.eq("account_id", accountId);
+           /* if (accountId == 3727345L) {
+                creativeQueryWrapper.eq("click_track_url", "https://vdd.qq.com/aid/kuaishou_click_detail?app=tenvideo&imeimd5=__IMEI2__&idfamd5=__IDFA2__&androidid=__ANDROIDID2__&callback_url=__CALLBACK__&campaign_id=__DID__&adgroup_id=__AID__&creative_id=__CID__&account_id=3727345&timestamp=__TS__");
+            } else if (accountId == 6004204L) {
+                creativeQueryWrapper.eq("click_track_url", "https://vdd.qq.com/aid/kuaishou_click_detail?app=tenvideo&imeimd5=__IMEI2__&idfamd5=__IDFA2__&androidid=__ANDROIDID2__&callback_url=__CALLBACK__&campaign_id=__DID__&adgroup_id=__AID__&creative_id=__CID__&account_id=6004204&timestamp=__TS__");
+            } else if (accountId == 6399167L) {
+                creativeQueryWrapper.eq("click_track_url", "https://vdd.qq.com/aid/kuaishou_click_detail?app=tenvideo&imeimd5=__IMEI2__&idfamd5=__IDFA2__&androidid=__ANDROIDID2__&callback_url=__CALLBACK__&campaign_id=__DID__&adgroup_id=__AID__&creative_id=__CID__&account_id=6399167&timestamp=__TS__");
+            }*/
+
+
+            List<KuaiShouCreative> list1 = creativeService.list(creativeQueryWrapper);
+            for (KuaiShouCreative creative : list1) {
+                executorService.submit(new Runnable() {
+                    @Override
+                    public void run() {
+                        try {
+                            json.put("creativeId", creative.getCreativeId());
+                            batchService.updateCreative(json, oauthToken);
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+                });
+
+
+            }
+
+
+        }
+
+
+    }
+
+
     @GetMapping(value = "/getCut")
     public void getCut() {
         QueryWrapper<MaterialInfo> materialInfoQueryWrapper = new QueryWrapper<>();
@@ -111,11 +212,6 @@ public class TestController {
     }
 
 
-
-
-
-
-
     @GetMapping(value = "/t")
     public String test() {
         Result<String> result = new Result<>();
@@ -819,7 +915,6 @@ public class TestController {
     }
 
 
-
     @GetMapping(value = "/getAppList")
     public void getAppList() throws JobExecutionException {
         try {
@@ -835,7 +930,7 @@ public class TestController {
 
             tokens.forEach(token -> {
 
-                kuaishouInterfaceService.getAppList(token.getAccountId(),token.getAccessToken());
+                kuaishouInterfaceService.getAppList(token.getAccountId(), token.getAccessToken());
                 //suzhaoService.submit(new Runnable() {
                 //    @Override
                 //    public void run() {

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java

@@ -19,6 +19,8 @@ import java.util.Map;
  * 2019年11月12日11:08:52
  */
 public interface IKuaishouInterfaceService {
+     void getAsyncCreativeListV2(Long accountId, String accessToken, Long campaignId);
+
 
     /**
      * 计划日报

+ 7 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java

@@ -642,6 +642,12 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {
+                    log.info("修改成功,accountId:{},creativeId:{}", creativeJson.getLong("advertiser_id"), creativeJson.getLong("creative_id"));
+                } else {
+                    log.info("修改失败,accountId:{},creativeId:{},原因:{}", creativeJson.getLong("advertiser_id"), creativeJson.getLong("creative_id"), resultJson.getString("message"));
+
+                }
+                /*if (code == 0) {
                     JSONObject data = resultJson.getJSONObject("data");
                     if (!Check.isNull(data)) {
 
@@ -662,7 +668,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                 } else {
                     returnJson.put("code", -1);
                     returnJson.put("message", resultJson.getString("message"));
-                }
+                }*/
             }
         } catch (Exception e) {
             e.printStackTrace();

+ 118 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -136,6 +136,124 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     private IKuaiShouAdvertiserBaseInfoService KuaiShouAdvertiserBaseInfoService;
 
 
+
+    @Override
+    public void getAsyncCreativeListV2(Long accountId, String accessToken, Long campaignId) {
+
+
+        try {
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Content-Type", " application/json");
+            headers.put("Access-Token", accessToken);
+            JSONObject param = new JSONObject();
+            param.put("advertiser_id", accountId);
+            param.put("page_size", 200);
+            param.put("campaign_id", campaignId);
+
+           /* Map<String, Object> deleteMap = new HashMap<>();
+            deleteMap.put("account_id", accountId);
+            deleteMap.put("campaign_id", campaignId);
+            creativeService.removeByMap(deleteMap);*/
+
+
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (Check.isNull(resultJson)) {
+                log.error("获取广告创意返回结果为空,advertiserId:{}", accountId);
+                return;
+            }
+            Integer code = resultJson.getInteger("code");
+            String message = resultJson.getString("message");
+            if (null == code || code != 0) {
+                log.error("获取广告创意返回结果异常,advertiserId:{},message:{}", accountId, message);
+                return;
+            }
+            JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+            if (null == details || details.size() <= 0) {
+                return;
+            }
+            List<KuaiShouCreative> creatives = new ArrayList<>();
+            for (int i = 0; i < details.size(); i++) {
+                JSONObject detailJson = JSONObject.parseObject(details.get(i).toString());
+                if (!Check.isNull(detailJson)) {
+                    KuaiShouCreative creative = new KuaiShouCreative();
+                    creative.setId("" + accountId + detailJson.getLong("creative_id"));
+                    creative.setAccountId(accountId);
+                    creative.setCampaignId(detailJson.getLong("campaign_id"));
+                    creative.setUnitId(detailJson.getLong("unit_id"));
+                    creative.setCreativeId(detailJson.getLong("creative_id"));
+                    creative.setCreativeName(detailJson.getString("creative_name"));
+                    creative.setCreativeMaterialType(detailJson.getInteger("creative_material_type"));
+                    if (!Check.isNull(detailJson.getJSONArray("material_url"))) {
+                        creative.setMaterialUrl(detailJson.getJSONArray("material_url").toJSONString());
+                    }
+
+                    if (!Check.isNull(detailJson.getJSONArray("image_tokens"))) {
+                        creative.setImageTokens(detailJson.getJSONArray("image_tokens").toJSONString());
+                    }
+                    creative.setStatus(detailJson.getInteger("status"));
+                    creative.setPutStatus(detailJson.getInteger("put_status"));
+                    creative.setCreateChannel(detailJson.getInteger("create_channel"));
+                    creative.setReviewDetail(detailJson.getString("review_detail"));
+                    creative.setCoverUrl(detailJson.getString("cover_url"));
+                    creative.setImageToken(detailJson.getString("image_token"));
+                    creative.setCoverWidth(detailJson.getString("cover_width"));
+                    creative.setCoverHeight(detailJson.getString("cover_height"));
+                    creative.setOverlayBgUrl(detailJson.getString("overlay_bg_url"));
+                    creative.setOverlayBgImageToken(detailJson.getString("overlay_bg_image_token"));
+                    creative.setStickerTitle(detailJson.getString("sticker_title"));
+                    creative.setOverlayType(detailJson.getString("overlay_type"));
+                    creative.setClickTrackUrl(detailJson.getString("click_track_url"));
+                    creative.setImpressionUrl(detailJson.getString("impression_url"));
+                    creative.setAdPhotoPlayedT3sUrl(detailJson.getString("ad_photo_played_t3s_url"));
+                    creative.setCreativeCreateTime(detailJson.getDate("create_time"));
+                    creative.setCreativeUpdateTime(detailJson.getDate("update_time"));
+                    creative.setFirstFrameType(detailJson.getInteger("first_frame_type"));
+                    creative.setShortSlogan(detailJson.getString("short_slogan"));
+                    JSONObject displayInfoJson = detailJson.getJSONObject("display_info");
+                    if (!Check.isNull(displayInfoJson)) {
+                        creative.setDescription(displayInfoJson.getString("description"));
+                        creative.setActionBarText(displayInfoJson.getString("action_bar_text"));
+                    }
+                    creative.setCreateTime(new Date());
+                    creative.setUpdateTime(new Date());
+                    creative.setSiteId(detailJson.getLong("site_id"));
+                    creative.setPhotoId(detailJson.getString("photo_id"));
+                    if (detailJson.getLong("photo_id") == 0) {
+                        JSONArray photoIds = new JSONArray();
+                        JSONObject programmed_creative_material = detailJson.getJSONObject("programmed_creative_material");
+                        if (!Check.isNull(programmed_creative_material)) {
+                            creative.setProgrammedCreativeMaterial(programmed_creative_material.toJSONString());
+                            JSONArray materials = programmed_creative_material.getJSONArray("materials");
+                            if (!Check.isNull(materials)) {
+                                for (int j = 0; j < materials.size(); j++) {
+                                    JSONObject materialJson = materials.getJSONObject(j);
+                                    if (!Check.isNull(materialJson)) {
+                                        Long photo_id = materialJson.getLong("photo_id");
+                                        photoIds.add(String.valueOf(photo_id));
+                                    }
+                                }
+                                creative.setPhotoIds(photoIds.toJSONString());
+                            }
+                        }
+                    }
+                    creatives.add(creative);
+                }
+
+            }
+            creativeService.replaceBatch(creatives);
+
+
+        } catch (Exception e) {
+            e.printStackTrace();
+
+        }
+
+
+    }
+
+
     @Override
     public void getAdvertiserReportHourly(CtopOauthToken token, Date startDate, Date endDate) {
         getAdvertiserReportHourlyByPage(token, startDate, endDate, 1);