|
@@ -1,5 +1,7 @@
|
|
|
package cn.com.ctop.toutiao.service.impl;
|
|
|
|
|
|
+import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
import cn.com.ctop.common.module.utils.HttpUtils;
|
|
|
import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
|
import cn.com.ctop.common.module.utils.ResultMapUtils;
|
|
@@ -11,8 +13,6 @@ import cn.com.ctop.toutiao.service.IByteDanceAdvertiserDataService;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
-import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -632,6 +632,42 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
//根据adId获取公告计划信息
|
|
|
ByteDanceAdvertisePlan advertisePlan = advertisePlanService.getById(adId);
|
|
|
data.put("modify_time", advertisePlan.getModifyTime());
|
|
|
+ Integer deliveryType = requestJson.getInteger("deviceType");
|
|
|
+ if (null != deliveryType && deliveryType == 2) {
|
|
|
+ //穿山甲
|
|
|
+ //精选流量包类型
|
|
|
+ String superiorPopularityType = template.getSuperiorPopularityType();
|
|
|
+ if (null != superiorPopularityType && "ZDY".equals(superiorPopularityType)) {
|
|
|
+ JSONArray flowPackage = requestJson.getJSONArray("flowPackage");
|
|
|
+ if (null != flowPackage && flowPackage.size() > 0) {
|
|
|
+ JSONArray getFlowPackage = new JSONArray();
|
|
|
+ for (int i = 0; i < flowPackage.size(); i++) {
|
|
|
+ String flowPackageString = flowPackage.getString(i);
|
|
|
+ getFlowPackage.add(Long.parseLong(flowPackageString));
|
|
|
+ }
|
|
|
+ data.put("flow_package", getFlowPackage);
|
|
|
+ }
|
|
|
+ JSONArray excludeFlowPackage = requestJson.getJSONArray("excludeFlowPackage");
|
|
|
+ if (null != excludeFlowPackage && excludeFlowPackage.size() > 0) {
|
|
|
+ JSONArray getExcludeFlowPackage = new JSONArray();
|
|
|
+ for (int i = 0; i < excludeFlowPackage.size(); i++) {
|
|
|
+ String excludeFlowPackageString = excludeFlowPackage.getString(i);
|
|
|
+ getExcludeFlowPackage.add(Long.parseLong(excludeFlowPackageString));
|
|
|
+ }
|
|
|
+ data.put("exclude_flow_package", getExcludeFlowPackage);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ data.put("superior_popularity_type", superiorPopularityType);
|
|
|
+ }
|
|
|
+ //设备类型
|
|
|
+ String deviceType = template.getDeviceType();
|
|
|
+ if (null != deviceType && !"".equals(deviceType) && !"NONE".equals(deviceType)) {
|
|
|
+ JSONArray typeArray = new JSONArray();
|
|
|
+ typeArray.add(deviceType);
|
|
|
+ data.put("device_type", typeArray);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
JSONArray retargetingTagsExclude = requestJson.getJSONArray("retargetingTagsExclude");
|
|
|
JSONArray retargetingTagsInclude = requestJson.getJSONArray("retargetingTagsInclude");
|
|
|
if (null != retargetingTagsExclude && retargetingTagsExclude.size() > 0) {
|
|
@@ -805,6 +841,54 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取流量包数据接口
|
|
|
+ *
|
|
|
+ * @param accountId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> flowPackageGet(String accountId) {
|
|
|
+ JSONObject jsonObject = flowPackageGetJSONObject(accountId);
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ Integer code = jsonObject.getInteger("code");
|
|
|
+ String message = jsonObject.getString("message");
|
|
|
+ result.put("code", code);
|
|
|
+ result.put("message", message);
|
|
|
+ if (null == code || code != 0) {
|
|
|
+ result.put("success", false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ JSONArray packageList = jsonObject.getJSONObject("data").getJSONArray("list");
|
|
|
+ if (null != packageList && packageList.size() > 0) {
|
|
|
+ JSONArray packageArray = new JSONArray();
|
|
|
+ for (int i = 0; i < packageList.size(); i++) {
|
|
|
+ JSONObject packageObject = packageList.getJSONObject(i);
|
|
|
+ packageObject.remove("rit");
|
|
|
+ String status = packageObject.getString("status");
|
|
|
+ if (null != status && status.equals("FLOW_PACKAGE_ENABLE")) {
|
|
|
+ packageArray.add(packageObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.put("data", packageArray);
|
|
|
+ }
|
|
|
+ result.put("success", true);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public JSONObject flowPackageGetJSONObject(String accountId) {
|
|
|
+ CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
|
|
|
+ // 请求地址
|
|
|
+ String url = "https://ad.toutiao.com/open_api/2/tools/union/flow_package/get/";
|
|
|
+ // 请求参数
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("advertiser_id", token.getAccountId());
|
|
|
+ params.put("page", 1);
|
|
|
+ params.put("page_size", 100);
|
|
|
+ JSONObject resultObject = HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, params);
|
|
|
+ return resultObject;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private void getAdvertiserCreativeByPageNumber(String accountId, Integer pageNumber, String ids) {
|
|
|
CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
|