Browse Source

添加app定向,吊起链接

yumeng 4 năm trước cách đây
mục cha
commit
d876683a18

+ 8 - 4
module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java

@@ -104,6 +104,10 @@ public class KuaishouInterfaceConstant {
      * 创建广告获取应用列表(新版本)
      */
     public static final String APP_LIST_v2 = "/rest/openapi/v2/file/ad/app/list";
+    /**
+     * 获取app名称
+     */
+    public static final String APP_NAME = "/rest/openapi/v1/tool/keyword/query";
 
     /**
      * 账户日预算查询
@@ -322,19 +326,19 @@ public class KuaishouInterfaceConstant {
      * 频库-视频关联创意数查询
      */
     public static final String VIDEO_RELATE_CREATIVES = "/rest/openapi/v1/file/ad/video/relate/creatives";
-/**
+    /**
      * 查询加速探索信息接口
      */
     public static final String UNIT_EXPLORE_INFO_GET = "/rest/openapi/v1/ad_unit/explore/info/get";
-/**
+    /**
      * 广告组的加速探索预算设置
      */
     public static final String UNIT_EXPLORE_BUDGET_UPDATE = "/rest/openapi/v1/ad_unit/explore/budget/update";
-/**
+    /**
      * 暂停广告组的加速探索预算
      */
     public static final String UNIT_EXPLORE_STATUS_PAUSE = "/rest/openapi/v1/ad_unit/explore/status/pause";
-/**
+    /**
      * 查询广告组的加速探索报表接口
      */
     public static final String QUERY_SPEED_EXPLORE_REPORT = "/rest/openapi/v1/report/speed_explore";

+ 53 - 25
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java

@@ -199,6 +199,12 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 AiKuaishouUnitLevelOperationRecord unitLevelOperationRecord = new AiKuaishouUnitLevelOperationRecord();
                 BeanUtils.copyProperties(strategy, unitLevelOperationRecord);
                 unitLevelOperationRecord.setGroupName(unitName);
+                if (!Check.isNull(strategy.getCpaBid())) {
+                    unitLevelOperationRecord.setCpaBid(Integer.valueOf(strategy.getCpaBid() + ""));
+                }
+                if (!Check.isNull(strategy.getBid())) {
+                    unitLevelOperationRecord.setBid(Integer.valueOf(strategy.getBid() + ""));
+                }
                 unitLevelOperationRecord.setCreateTime(new Date());
                 unitLevelOperationRecord.setStatus(unitCode);
                 unitLevelOperationRecord.setMessage(unitMessage);
@@ -674,8 +680,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         // 拼装创建组的入参 json
         JSONObject unitParams = new JSONObject();
         Integer unitType = strategy.getUnitType();
-
-
         //创意制作方式
         unitParams.put("unit_type", unitType);
         unitParams.put("advertiser_id", token.getAccountId());
@@ -737,6 +741,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             if (!Check.isNull(appId)) {
                 unitParams.put("app_id", appId);
             }
+            // 直达链接
+            if (!Check.isNull(strategy.getSchemaUri())) {
+                unitParams.put("schema_uri", strategy.getSchemaUri());
+            }
             // 优先从系统应用商店下载
             if (null != strategy.getUseAppMarket()) {
                 unitParams.put("use_app_market", strategy.getUseAppMarket());
@@ -745,7 +753,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 unitParams.put("app_store", JSON.parseArray(strategy.getAppStore()));
             }
         } else if (campaignType == 3) { //  获取电商下单
-
             //url类型
             if (!Check.isNull(strategy.getUrlType())) {
                 unitParams.put("url_type", strategy.getUrlType());
@@ -882,17 +889,36 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         if (null != strategy.getDevicePrice() && !"".equals(strategy.getDevicePrice()) && !"[]".equals(strategy.getDevicePrice())) {
             targetJsonObject.put("device_price", JSON.parseArray(strategy.getDevicePrice()));
         }
-        if (null != strategy.getPopulation() && !"".equals(strategy.getPopulation())) {
-            JSONArray population = JSON.parseArray(strategy.getPopulation());
-            targetJsonObject.put("population", population);
-        }
+
         if (null != strategy.getFilterConvertedLevel() && strategy.getFilterConvertedLevel() != 0) {
             targetJsonObject.put("filter_converted_level", strategy.getFilterConvertedLevel());
         }
-        if (null != strategy.getExcludePopulation() && !"".equals(strategy.getExcludePopulation())) {
-            JSONArray excludePopulation = JSON.parseArray(strategy.getExcludePopulation());
-            targetJsonObject.put("exclude_population", excludePopulation);
+
+        JSONArray appInterest = JSONArray.parseArray(strategy.getAppInterest());
+        if (!Check.isNull(appInterest)) {
+            targetJsonObject.put("app_interest", appInterest);
+        }
+        // APP行为-按APP名称
+        JSONArray appIds = JSONArray.parseArray(strategy.getAppIds());
+        if (!Check.isNull(appIds)) {
+            targetJsonObject.put("app_ids", appIds);
+        }
+        // 人群包定向
+        JSONArray populationString = JSONArray.parseArray(strategy.getPopulation());
+        if (!Check.isNull(populationString)) {
+            targetJsonObject.put("population", populationString);
+        }
+        // 人群包排除
+        JSONArray excludePopulationString = JSONArray.parseArray(strategy.getExcludePopulation());
+        if (!Check.isNull(excludePopulationString)) {
+            targetJsonObject.put("exclude_population", excludePopulationString);
         }
+        // 付费人群包id
+        JSONArray paidAudienceString = JSONArray.parseArray(strategy.getPaidAudience());
+        if (!Check.isNull(paidAudienceString)) {
+            targetJsonObject.put("paid_audience", paidAudienceString);
+        }
+
         //是否开启智能扩量
         if (null != strategy.getIsOpen() && strategy.getIsOpen().equals(1)) {
             JSONObject intelliExtend = new JSONObject();
@@ -1039,30 +1065,30 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 
         }
         // APP行为-按分类
-        String appInterestString = strategy.getAppInterest();
-        if (null != appInterestString && !"".equals(appInterestString.trim())) {
-            target.put("app_interest", JSON.parseArray(appInterestString));
+        JSONArray appInterest = JSONArray.parseArray(strategy.getAppInterest());
+        if (!Check.isNull(appInterest)) {
+            target.put("app_interest", appInterest);
         }
         // APP行为-按APP名称
-        String appIdsString = strategy.getAppIds();
-        if (null != appIdsString && !"".equals(appIdsString.trim())) {
-            target.put("app_ids", JSON.parseArray(appIdsString));
+        JSONArray appIds = JSONArray.parseArray(strategy.getAppIds());
+        if (!Check.isNull(appIds)) {
+            target.put("app_ids", appIds);
         }
 
         // 人群包定向
-        String populationString = strategy.getPopulation();
-        if (null != populationString && !"".equals(populationString.trim())) {
-            target.put("population", JSON.parseArray(populationString));
+        JSONArray populationString = JSONArray.parseArray(strategy.getPopulation());
+        if (!Check.isNull(populationString)) {
+            target.put("population", populationString);
         }
         // 人群包排除
-        String excludePopulationString = strategy.getExcludePopulation();
-        if (null != excludePopulationString && !"".equals(excludePopulationString.trim())) {
-            target.put("exclude_population", JSON.parseArray(excludePopulationString));
+        JSONArray excludePopulationString = JSONArray.parseArray(strategy.getExcludePopulation());
+        if (!Check.isNull(excludePopulationString)) {
+            target.put("exclude_population", excludePopulationString);
         }
         // 付费人群包id
-        String paidAudienceString = strategy.getPaidAudience();
-        if (null != paidAudienceString && !"".equals(paidAudienceString.trim())) {
-            target.put("paid_audience", JSON.parseArray(paidAudienceString));
+        JSONArray paidAudienceString = JSONArray.parseArray(strategy.getPaidAudience());
+        if (!Check.isNull(paidAudienceString)) {
+            target.put("paid_audience", paidAudienceString);
         }
         if (Check.isNull(strategy.getBehaviorInterest())) {
             target.put("behavior_interest", JSON.parseObject(strategy.getBehaviorInterest()));
@@ -1071,6 +1097,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
     }
 
 
+
+
     private void createCreativeByImage(List<MaterialCutFrame> cutFrameList, CtopOauthToken token, JSONObject creativeParams,
                                        Long campaignId, Long unitId, KuaiShouVideoGet videoItem,
                                        int imageNumber, AiKuaishouAdvertiserStrategy strategy, String uuid, String appVersion) {

+ 35 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java

@@ -2418,4 +2418,39 @@ public class BatchController {
     }
 
 
+    /**
+     * 获取可选的深度类型
+     *
+     * @return
+     */
+    @PostMapping(value = "/getAppNames")
+    public Result<JSONArray> getAppNames(@RequestBody JSONObject requestJson) {
+        Result result = new Result<JSONArray>();
+        try {
+            Long accountId = requestJson.getLong("accountId");
+
+            CtopOauthToken token = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(token)) {
+                throw new Exception("未获取授权信息");
+            }
+            JSONArray appIds = requestJson.getJSONArray("appIds");
+
+            if (!Check.isNull(appIds)) {
+                JSONArray appNames = iKuaishouInterfaceService.getAppNames(accountId, token.getAccessToken(), appIds);
+                result.setResult(appNames);
+            } else {
+                result.setResult(new JSONArray());
+            }
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+
+    }
+
+
 }

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

@@ -468,6 +468,7 @@ public interface IKuaishouInterfaceService {
 
     void getCreativeByCreativeIds(String accessToken, Long advertiserId, JSONArray creativeIds);
 
+    JSONArray getAppNames(Long accountId, String accessToken, JSONArray appIds);
 }
 
 

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

@@ -228,6 +228,9 @@ public class BatchServiceImpl implements IBatchService {
         if (!Check.isNull(requestJson.getString("url"))) {
             unitJson.put("url", requestJson.getString("url"));
         }
+        if (!Check.isNull(requestJson.getString("schemaUri"))) {
+            unitJson.put("schema_uri", requestJson.getString("schemaUri"));
+        }
         // appId
         if (!Check.isNull(requestJson.getLong("appId"))) {
             unitJson.put("app_id", requestJson.getLong("appId"));
@@ -820,6 +823,10 @@ public class BatchServiceImpl implements IBatchService {
                 if (!Check.isNull(group.getUrl())) {
                     unitJson.put("url", group.getUrl());
                 }
+                //  吊起链接
+                if (!Check.isNull(group.getSchemaUri())) {
+                    unitJson.put("schema_uri", group.getSchemaUri());
+                }
                 // appId
                 if (!Check.isNull(group.getAppId())) {
                     unitJson.put("app_id", group.getAppId());
@@ -848,8 +855,6 @@ public class BatchServiceImpl implements IBatchService {
                     // 自定义年龄段
                     Integer ageMin = groupTarget.getAgeMin();
                     Integer ageMax = groupTarget.getAgeMax();
-
-
                     JSONObject ageJson = new JSONObject();
                     if (!Check.isNull(ageMin)) {
                         ageJson.put("min", ageMin);

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

@@ -3206,4 +3206,35 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
 
+    @Override
+    public JSONArray getAppNames(Long accountId, String accessToken, JSONArray appIds) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.APP_NAME;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", accessToken);
+        headers.put("Content-Type", " application/json");
+        JSONObject json = new JSONObject();
+        json.put("advertiser_id", accountId);
+        json.put("type", 1);
+        json.put("ids", appIds);
+        String result = HttpUtils.kuaiShouhttpPostRequest(url, json.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (!Check.isNull(resultJson)) {
+            Integer code = resultJson.getInteger("code");
+            if (code == 0) {
+                JSONObject data = resultJson.getJSONObject("data");
+                if (!Check.isNull(data)) {
+                    JSONArray keyword = data.getJSONArray("keyword");
+                    if (!Check.isNull(keyword)) {
+                        return keyword;
+
+                    }
+                }
+            }
+
+        }
+        return new JSONArray();
+
+    }
+
+
 }