|
@@ -3,9 +3,14 @@ package org.jeecg.modules.bytedance.advertise.dockapi;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.http.HttpEntity;
|
|
|
|
+import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
|
+import org.apache.http.client.methods.HttpPost;
|
|
|
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
|
+import org.apache.http.impl.client.HttpClientBuilder;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.modules.bytedance.advertise.entity.AiBytedanceAdvertiserStrategy;
|
|
import org.jeecg.modules.bytedance.advertise.entity.AiBytedanceAdvertiserStrategy;
|
|
-import org.jeecg.modules.bytedance.advertise.entity.ByteDanceAdvertisePlan;
|
|
|
|
|
|
+import org.jeecg.modules.bytedance.advertise.vo.AdConvertQueryVo;
|
|
import org.jeecg.modules.bytedance.advertise.vo.AdGroupSearchVo;
|
|
import org.jeecg.modules.bytedance.advertise.vo.AdGroupSearchVo;
|
|
import org.jeecg.modules.bytedance.advertise.vo.ByteDanceSearchVo;
|
|
import org.jeecg.modules.bytedance.advertise.vo.ByteDanceSearchVo;
|
|
import org.jeecg.modules.bytedance.advertise.vo.PlanSearchVo;
|
|
import org.jeecg.modules.bytedance.advertise.vo.PlanSearchVo;
|
|
@@ -14,7 +19,11 @@ import org.jeecg.modules.bytedance.common.entity.CtopOauthToken;
|
|
import org.jeecg.modules.bytedance.common.utils.Check;
|
|
import org.jeecg.modules.bytedance.common.utils.Check;
|
|
import org.jeecg.modules.bytedance.common.utils.HttpUtils;
|
|
import org.jeecg.modules.bytedance.common.utils.HttpUtils;
|
|
import org.jeecg.modules.bytedance.common.utils.PropertiesUtils;
|
|
import org.jeecg.modules.bytedance.common.utils.PropertiesUtils;
|
|
-
|
|
|
|
|
|
+import org.apache.http.entity.mime.MultipartEntityBuilder;
|
|
|
|
+import java.io.BufferedReader;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.io.InputStreamReader;
|
|
|
|
+import java.net.URI;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -342,7 +351,7 @@ public class marketing {
|
|
//直达链接(点击唤起APP)
|
|
//直达链接(点击唤起APP)
|
|
params.put("open_url", strategy.getAdOpenUrl());
|
|
params.put("open_url", strategy.getAdOpenUrl());
|
|
//搜索快投功能,允许值:HAS_OPEN:启用,DISABLED:不启用
|
|
//搜索快投功能,允许值:HAS_OPEN:启用,DISABLED:不启用
|
|
- params.put("feed_delivery_search", "搜索快投");
|
|
|
|
|
|
+ //params.put("feed_delivery_search", "");
|
|
//用户定向
|
|
//用户定向
|
|
//允许值: "CITY"省市, "COUNTY"区县, "BUSINESS_DISTRICT"商圈,"NONE"不限
|
|
//允许值: "CITY"省市, "COUNTY"区县, "BUSINESS_DISTRICT"商圈,"NONE"不限
|
|
params.put("district", strategy.getAdScheduleType());
|
|
params.put("district", strategy.getAdScheduleType());
|
|
@@ -361,7 +370,7 @@ public class marketing {
|
|
//平台
|
|
//平台
|
|
//params.put("platform", byteDanceAdvertisePlan.getPlatform());
|
|
//params.put("platform", byteDanceAdvertisePlan.getPlatform());
|
|
//最低安卓版本
|
|
//最低安卓版本
|
|
- params.put("android_osv", "安卓版本");
|
|
|
|
|
|
+ params.put("android_osv", strategy.getAdAndroidOsv());
|
|
//网络
|
|
//网络
|
|
//params.put("ac", byteDanceAdvertisePlan.getAc());
|
|
//params.put("ac", byteDanceAdvertisePlan.getAc());
|
|
//过滤已安装 当推广目标为安卓应用下载时可填 0表示不限,1表示过滤,2表示定向。默认为不限
|
|
//过滤已安装 当推广目标为安卓应用下载时可填 0表示不限,1表示过滤,2表示定向。默认为不限
|
|
@@ -372,7 +381,7 @@ public class marketing {
|
|
params.put("auto_extend_enabled", strategy.getAdAutoExtendEnabled());
|
|
params.put("auto_extend_enabled", strategy.getAdAutoExtendEnabled());
|
|
//预算与出价
|
|
//预算与出价
|
|
//投放场景 允许值: 常规投放"SMART_BID_CUSTOM", 放量投放"SMART_BID_CONSERVATIVE"
|
|
//投放场景 允许值: 常规投放"SMART_BID_CUSTOM", 放量投放"SMART_BID_CONSERVATIVE"
|
|
- params.put("smart_bid_type", "投放场景");
|
|
|
|
|
|
+ params.put("smart_bid_type", strategy.getAdSmartBidType());
|
|
//预算类型 "BUDGET_MODE_DAY"日预算, "BUDGET_MODE_TOTAL"总预算
|
|
//预算类型 "BUDGET_MODE_DAY"日预算, "BUDGET_MODE_TOTAL"总预算
|
|
params.put("budget_mode", strategy.getAdBudgetMode());
|
|
params.put("budget_mode", strategy.getAdBudgetMode());
|
|
//预算 出价方式为CPC、CPM、CPV时,不少于100元;出价方式为OCPM、OCPC时,不少于300元
|
|
//预算 出价方式为CPC、CPM、CPV时,不少于100元;出价方式为OCPM、OCPC时,不少于300元
|
|
@@ -471,7 +480,6 @@ public class marketing {
|
|
* @param adId 计划ID
|
|
* @param adId 计划ID
|
|
* @return: org.jeecg.common.api.vo.Result
|
|
* @return: org.jeecg.common.api.vo.Result
|
|
* @author: zianY
|
|
* @author: zianY
|
|
- * @time: 2021/4/19 15:23
|
|
|
|
*/
|
|
*/
|
|
public static Result creativeRead(CtopOauthToken token,String advertiserId,String adId) {
|
|
public static Result creativeRead(CtopOauthToken token,String advertiserId,String adId) {
|
|
JSONObject param = new JSONObject();
|
|
JSONObject param = new JSONObject();
|
|
@@ -795,9 +803,6 @@ public class marketing {
|
|
* @author: zianY
|
|
* @author: zianY
|
|
*/
|
|
*/
|
|
public static Result updateAdvertiserPlan(CtopOauthToken token, String planId,String modifyTime,AiBytedanceAdvertiserStrategy strategy) {
|
|
public static Result updateAdvertiserPlan(CtopOauthToken token, String planId,String modifyTime,AiBytedanceAdvertiserStrategy strategy) {
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
JSONObject params = new JSONObject();
|
|
JSONObject params = new JSONObject();
|
|
//广告主ID
|
|
//广告主ID
|
|
params.put("advertiser_id", strategy.getAccountId());
|
|
params.put("advertiser_id", strategy.getAccountId());
|
|
@@ -1002,6 +1007,113 @@ public class marketing {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ * @description: 查询广告计划可用转化目标
|
|
|
|
+ *
|
|
|
|
+ * @param token
|
|
|
|
+ * @param convertQueryVo
|
|
|
|
+ * @return: org.jeecg.common.api.vo.Result
|
|
|
|
+ * @author: zianY
|
|
|
|
+ */
|
|
|
|
+ public static Result getToolConvertQuery(CtopOauthToken token,AdConvertQueryVo convertQueryVo) {
|
|
|
|
+
|
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
|
+ //广告主id
|
|
|
|
+ params.put("advertiser_id",convertQueryVo.getAdvertiserId());
|
|
|
|
+ //广告组推广目的
|
|
|
|
+ params.put("landing_type", convertQueryVo.getLandingType());
|
|
|
|
+ //投放内容
|
|
|
|
+ params.put("promotion_content", convertQueryVo.getPromotionContent());
|
|
|
|
+ //广告投放范围
|
|
|
|
+ params.put("delivery_range", convertQueryVo.getDeliveryRange() == null ? "DEFAULT" : convertQueryVo.getDeliveryRange());
|
|
|
|
+ //落地页链接
|
|
|
|
+ params.put("external_url", convertQueryVo.getExternalUrl());
|
|
|
|
+ //应用下载类型
|
|
|
|
+ params.put("app_type", convertQueryVo.getAppType());
|
|
|
|
+ //Android应用包名
|
|
|
|
+ params.put("package_name", convertQueryVo.getPackageName());
|
|
|
|
+ //iOS应用下载链接
|
|
|
|
+ params.put("itunes_url", convertQueryVo.getItunesUrl());
|
|
|
|
+ //小程序app_schema
|
|
|
|
+ params.put("app_schema", convertQueryVo.getAppSchema());
|
|
|
|
+ //附加创意类型
|
|
|
|
+ params.put("advanced_creative_type", convertQueryVo.getAdvancedCreativeType());
|
|
|
|
+ //游戏预约场景
|
|
|
|
+ params.put("marketing_scene",convertQueryVo.getMarketingScene());
|
|
|
|
+ params = Check.jsonRemoveEmpty(params);
|
|
|
|
+ JSONObject jsonObject = HttpUtils.bytedanceGetRequest(token.getAccessToken(),
|
|
|
|
+ PropertiesUtils.getValue("bytedance_config", "bytedance_v2_tools_ad_convert_query"),
|
|
|
|
+ params);
|
|
|
|
+ Integer code = jsonObject.getInteger("code");
|
|
|
|
+ String message = jsonObject.getString("message");
|
|
|
|
+ if (null == code || !code.equals(0)) {
|
|
|
|
+ log.info("查询广告计划可用转化目标接口异常==》accountId:{},message:{}", token.getAccountId(), message);
|
|
|
|
+ return Result.error(message);
|
|
|
|
+ }
|
|
|
|
+ JSONArray data = jsonObject.getJSONObject("data").getJSONArray("custom_audience_list");
|
|
|
|
+ if (null == data || data.isEmpty()) {
|
|
|
|
+ log.info("查询广告计划可用转化目标不存在==》accountId:{},message:{}", token.getAccountId(), message);
|
|
|
|
+ return Result.error("人群包信息不存在");
|
|
|
|
+ }
|
|
|
|
+ return Result.successMsg("查询广告计划可用转化目标信息获取成功",data);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 上传平台 图片
|
|
|
|
+ * @param token
|
|
|
|
+ * @param advertiserId 广告主id
|
|
|
|
+ * @param imageUrl 图片url
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public static JSONObject imageUpload(CtopOauthToken token, String advertiserId, String imageUrl) {
|
|
|
|
+ // 请求地址
|
|
|
|
+ String url = urlPath + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_file_image_ad");
|
|
|
|
+ // 构造请求
|
|
|
|
+ HttpPost httpPost = new HttpPost(url);
|
|
|
|
+ httpPost.setHeader("Access-Token", token.getAccessToken());
|
|
|
|
+ MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create();
|
|
|
|
+ // 其他参数
|
|
|
|
+ entityBuilder.addTextBody("advertiser_id", advertiserId);
|
|
|
|
+ entityBuilder.addTextBody("upload_type", BytedanceConstant.UPLOAD_TYPE_BY_URL);
|
|
|
|
+ entityBuilder.addTextBody("image_url", imageUrl);
|
|
|
|
+
|
|
|
|
+ HttpEntity entity = entityBuilder.build();
|
|
|
|
+ CloseableHttpResponse response = null;
|
|
|
|
+ CloseableHttpClient client = null;
|
|
|
|
+ try {
|
|
|
|
+ client = HttpClientBuilder.create().build();
|
|
|
|
+ httpPost.setURI(URI.create(url));
|
|
|
|
+ httpPost.setEntity(entity);
|
|
|
|
+ response = client.execute(httpPost);
|
|
|
|
+ if (response != null && response.getStatusLine().getStatusCode() == 200) {
|
|
|
|
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
|
|
+ StringBuilder buffer = new StringBuilder();
|
|
|
|
+ String line = "";
|
|
|
|
+ while ((line = bufferedReader.readLine()) != null) {
|
|
|
|
+ buffer.append(line);
|
|
|
|
+ }
|
|
|
|
+ bufferedReader.close();
|
|
|
|
+ return JSONObject.parseObject(buffer.toString());
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ } finally {
|
|
|
|
+ try {
|
|
|
|
+ if (response != null) {
|
|
|
|
+ response.close();
|
|
|
|
+ }
|
|
|
|
+ if (null != client) {
|
|
|
|
+ client.close();
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|