|
@@ -1,35 +1,385 @@
|
|
|
package cn.com.ctop.toutiao.modules.material.service.impl;
|
|
|
|
|
|
+import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
+import cn.com.ctop.common.module.utils.HttpUtils;
|
|
|
+import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
|
+import cn.com.ctop.common.module.utils.StringUtils;
|
|
|
import cn.com.ctop.toutiao.modules.material.entity.ByteDanceAdvertisePlan;
|
|
|
import cn.com.ctop.toutiao.modules.material.mapper.ByteDanceAdvertisePlanMapper;
|
|
|
import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
-/**
|
|
|
- * @Description: 今日头条广告计划信息
|
|
|
- * @Author: jeecg-boot
|
|
|
- * @Date: 2019-07-22
|
|
|
- * @Version: V1.0
|
|
|
- */
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class ByteDanceAdvertisePlanServiceImpl extends ServiceImpl<ByteDanceAdvertisePlanMapper, ByteDanceAdvertisePlan> implements IByteDanceAdvertisePlanService {
|
|
|
+
|
|
|
@Autowired
|
|
|
private ByteDanceAdvertisePlanMapper byteDanceAdvertisePlanMapper;
|
|
|
|
|
|
- /**
|
|
|
- * 查询需要预警的广告计划名称
|
|
|
- *
|
|
|
- * @param accountId
|
|
|
- * @param maxBid
|
|
|
- * @return
|
|
|
- */
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getAdvertiserPlan(CtopOauthToken token, String ids, String date, String updateDate) {
|
|
|
+ getAd(token, 1, ids, date, updateDate);
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "获取广告计划信息成功");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> createAdvertiserPlan(CtopOauthToken token,String landingType, ByteDanceAdvertisePlan byteDanceAdvertisePlan) {
|
|
|
+
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ //拼接访问参数
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("Access-Token", token.getAccessToken());
|
|
|
+
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("advertiser_id",byteDanceAdvertisePlan.getAccountId());
|
|
|
+ params.put("campaign_id",byteDanceAdvertisePlan.getCampaignId());
|
|
|
+ params.put("name",byteDanceAdvertisePlan.getName());
|
|
|
+ params.put("operation",byteDanceAdvertisePlan.getOperation()==null?"enable":byteDanceAdvertisePlan.getOperation());
|
|
|
+ params.put("delivery_range",byteDanceAdvertisePlan.getDeliveryRange()==null?"DEFAULT":byteDanceAdvertisePlan.getDeliveryRange());
|
|
|
+ params.put("union_video_type",byteDanceAdvertisePlan.getUnionVideoType()==null?"ORIGINAL_VIDEO":byteDanceAdvertisePlan.getUnionVideoType());
|
|
|
+ params.put("budget_mode",byteDanceAdvertisePlan.getBudgetMode());
|
|
|
+ params.put("budget",byteDanceAdvertisePlan.getBudget());
|
|
|
+ params.put("schedule_type",byteDanceAdvertisePlan.getScheduleType());
|
|
|
+ params.put("start_time",byteDanceAdvertisePlan.getStartTime());
|
|
|
+ params.put("end_time",byteDanceAdvertisePlan.getEndTime());
|
|
|
+ //广告投放时段
|
|
|
+ //params.put("schedule_time",byteDanceAdvertisePlan.getString("scheduleTime"));
|
|
|
+ params.put("pricing",byteDanceAdvertisePlan.getPricing());
|
|
|
+ params.put("bid",byteDanceAdvertisePlan.getBid()==null?0:byteDanceAdvertisePlan.getBid());
|
|
|
+ params.put("cpa_bid",byteDanceAdvertisePlan.getCpaBid()==null?0.1:byteDanceAdvertisePlan.getCpaBid());
|
|
|
+ params.put("flow_control_mode",byteDanceAdvertisePlan.getFlowControlMode());
|
|
|
+ if(byteDanceAdvertisePlan.getPricing().equals("OCPM")){
|
|
|
+ params.put("convert_id",byteDanceAdvertisePlan.getConvertId());
|
|
|
+ }
|
|
|
+ params.put("deep_bid_type",byteDanceAdvertisePlan.getDeepBidType());
|
|
|
+ params.put("deep_cpabid",byteDanceAdvertisePlan.getDeepCpaBid());
|
|
|
+ params.put("hide_if_converted",byteDanceAdvertisePlan.getHideIfConverted());
|
|
|
+ params.put("hide_if_exists",byteDanceAdvertisePlan.getHideIfExists() == null ? 0 : byteDanceAdvertisePlan.getHideIfExists());
|
|
|
+ params.put("converted_time_duration",byteDanceAdvertisePlan.getConvertedTimeDuration());
|
|
|
+ //params.put("luban_roi_goal",byteDanceAdvertisePlan.getLubanRoiGoal()==null?0.00:byteDanceAdvertisePlan.getFloat("lubanRoiGoal"));
|
|
|
+ //params.put("roi_goal",byteDanceAdvertisePlan.getFroiGoal")==null?0.00:byteDanceAdvertisePlan.getFloat("roiGoal"));
|
|
|
+ //params.put("unique_fk",byteDanceAdvertisePlan.getUniqueFk")==null?"":byteDanceAdvertisePlan.getString("uniqueFk"));
|
|
|
+ //params.put("smart_bid_type",byteDanceAdvertisePlan.getSmartBidType")==null?"":byteDanceAdvertisePlan.getString("smartBidType"));
|
|
|
+ params.put("adjust_cpa",0);
|
|
|
+ //params.put("audience_package_id",byteDanceAdvertisePlan.getLong("audiencePackageId"));
|
|
|
+ params.put("open_url",byteDanceAdvertisePlan.getOpenUrl());
|
|
|
+ //判断推广目的
|
|
|
+ if(landingType.equals("Link")){
|
|
|
+ params.put("external_url",byteDanceAdvertisePlan.getExternalUrl());
|
|
|
+ }
|
|
|
+ if(landingType.equals("APP")){
|
|
|
+ params.put("download_type",byteDanceAdvertisePlan.getExternalUrl());
|
|
|
+
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject( HttpUtils.httpPostRequest(PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_create"), params, headers));
|
|
|
+ if (jsonObject.getInteger("code") != 0) {
|
|
|
+ log.error("广告计划创建失败==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", jsonObject.getString("message"));
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "广告组状态修改成功");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> updateAdvertiserPlan(CtopOauthToken token,String landingType, ByteDanceAdvertisePlan byteDanceAdvertisePlan) {
|
|
|
+
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+
|
|
|
+ //拼接访问参数
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("Access-Token", token.getAccessToken());
|
|
|
+
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("advertiser_id",byteDanceAdvertisePlan.getAccountId());
|
|
|
+ params.put("ad_id",byteDanceAdvertisePlan.getId());
|
|
|
+ params.put("name",byteDanceAdvertisePlan.getName());
|
|
|
+ params.put("modify_time",byteDanceAdvertisePlan.getModifyTime());
|
|
|
+ params.put("budget",byteDanceAdvertisePlan.getBudget());
|
|
|
+ params.put("schedule_type",byteDanceAdvertisePlan.getScheduleType());
|
|
|
+ params.put("start_time",byteDanceAdvertisePlan.getStartTime());
|
|
|
+ params.put("end_time",byteDanceAdvertisePlan.getEndTime());
|
|
|
+ //广告投放时段
|
|
|
+ //params.put("schedule_time",byteDanceAdvertisePlan.getString("scheduleTime"));
|
|
|
+ params.put("bid",byteDanceAdvertisePlan.getBid()==null?0:byteDanceAdvertisePlan.getBid());
|
|
|
+ params.put("cpa_bid",byteDanceAdvertisePlan.getCpaBid()==null?0.1:byteDanceAdvertisePlan.getCpaBid());
|
|
|
+ params.put("flow_control_mode",byteDanceAdvertisePlan.getFlowControlMode());
|
|
|
+ if(byteDanceAdvertisePlan.getPricing().equals("OCPM")){
|
|
|
+ params.put("convert_id",byteDanceAdvertisePlan.getConvertId());
|
|
|
+ }
|
|
|
+ params.put("deep_bid_type",byteDanceAdvertisePlan.getDeepBidType());
|
|
|
+ params.put("deep_cpabid",byteDanceAdvertisePlan.getDeepCpaBid());
|
|
|
+ params.put("hide_if_converted",byteDanceAdvertisePlan.getHideIfConverted());
|
|
|
+ params.put("hide_if_exists",byteDanceAdvertisePlan.getHideIfExists() == null ? 0 : byteDanceAdvertisePlan.getHideIfExists());
|
|
|
+ params.put("converted_time_duration",byteDanceAdvertisePlan.getConvertedTimeDuration());
|
|
|
+ //params.put("luban_roi_goal",byteDanceAdvertisePlan.getLubanRoiGoal()==null?0.00:byteDanceAdvertisePlan.getFloat("lubanRoiGoal"));
|
|
|
+ //params.put("roi_goal",byteDanceAdvertisePlan.getFroiGoal")==null?0.00:byteDanceAdvertisePlan.getFloat("roiGoal"));
|
|
|
+ //params.put("audience_package_id",byteDanceAdvertisePlan.getLong("audiencePackageId"));
|
|
|
+ params.put("open_url",byteDanceAdvertisePlan.getOpenUrl());
|
|
|
+ //判断推广目的
|
|
|
+ if(landingType.equals("Link")){
|
|
|
+ params.put("external_url",byteDanceAdvertisePlan.getExternalUrl());
|
|
|
+ }
|
|
|
+ if(landingType.equals("APP")){
|
|
|
+ params.put("download_type",byteDanceAdvertisePlan.getExternalUrl());
|
|
|
+
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject( HttpUtils.httpPostRequest(PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update"), params, headers));
|
|
|
+ if (jsonObject.getInteger("code") != 0) {
|
|
|
+ log.error("广告计划创建失败==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", jsonObject.getString("message"));
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "广告组状态修改成功");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> updateAdvertiserPlanStatus(CtopOauthToken token, String adIds, String optStatus) {
|
|
|
+ JSONArray ids = new JSONArray();
|
|
|
+ String[] getIds = adIds.split(StringUtils.COMMA);
|
|
|
+ if (getIds.length > 0) {
|
|
|
+ for (String getId : getIds) {
|
|
|
+ ids.add(Long.parseLong(getId));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //2: 根据token以及用户id获取用户信息数据
|
|
|
+ String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_status");
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("Access-Token", token.getAccessToken());
|
|
|
+
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("advertiser_id", token.getAccountId());
|
|
|
+ params.put("ad_ids", ids.toJSONString());
|
|
|
+ params.put("opt_status", optStatus);
|
|
|
+ String result = HttpUtils.httpPostRequest(url, params, headers);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
+ int code = jsonObject.getInteger("code");
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ if (code != 0) {
|
|
|
+ log.error("广告计划更新状态接口异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "广告计划更新状态接口异常");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ JSONObject data = jsonObject.getJSONObject("data");
|
|
|
+ if (null == data) {
|
|
|
+ log.info("广告计划更新状态异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", jsonObject.getString("message"));
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ JSONArray getAdIds = data.getJSONArray("ad_ids");
|
|
|
+ if (null != getAdIds && !getAdIds.isEmpty()) {
|
|
|
+ //获取广告计划信息
|
|
|
+ getAdvertiserPlan(token, adIds, null, null);
|
|
|
+ }
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "广告组状态修改成功");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, Object> updateAdvertiserPlanBudget(CtopOauthToken token, String adIds, String budgets) {
|
|
|
+ JSONArray data = new JSONArray();
|
|
|
+ String[] getadIds = adIds.split(StringUtils.COMMA);
|
|
|
+ String[] getBudgets = budgets.split(StringUtils.COMMA);
|
|
|
+ if (getadIds.length > 0) {
|
|
|
+ for (int i = 0; i < getadIds.length; i++) {
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ Long adId = Long.parseLong(getadIds[i]);
|
|
|
+ Long budget = Long.parseLong(getBudgets[i]);
|
|
|
+ object.put("ad_id", adId);
|
|
|
+ object.put("budget", budget);
|
|
|
+ data.add(object);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //2: 根据token以及用户id获取用户信息数据
|
|
|
+ String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_budget");
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("Access-Token", token.getAccessToken());
|
|
|
+
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("advertiser_id", token.getAccountId());
|
|
|
+ params.put("data", data.toJSONString());
|
|
|
+ String result = HttpUtils.httpPostRequest(url, params, headers);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ Integer code = jsonObject.getInteger("code");
|
|
|
+ if (null == code || !code.equals(0)) {
|
|
|
+ log.info("修改计划预算接口异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", jsonObject.getString("message"));
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ JSONObject getData = jsonObject.getJSONObject("data");
|
|
|
+ if (null == getData) {
|
|
|
+ log.info("修改计划预算异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", jsonObject.getString("message"));
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ JSONArray getAdIds = getData.getJSONArray("ad_ids");
|
|
|
+ if (null != getAdIds && !getAdIds.isEmpty()) {
|
|
|
+ //获取广告计划信息
|
|
|
+ getAdvertiserPlan(token, adIds, null, null);
|
|
|
+ }
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "修改计划预算成功");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> updateAdvertiserPlanBid(CtopOauthToken token, String adIds, String bids) {
|
|
|
+ String[] getadIds = adIds.split(StringUtils.COMMA);
|
|
|
+ String[] getBids = bids.split(StringUtils.COMMA);
|
|
|
+ JSONArray data = new JSONArray();
|
|
|
+ if (getadIds.length > 0) {
|
|
|
+ for (int i = 0; i < getadIds.length; i++) {
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ Long adId = Long.parseLong(getadIds[i]);
|
|
|
+ Long bid = Long.parseLong(getBids[i]);
|
|
|
+ object.put("ad_id", adId);
|
|
|
+ object.put("bid", bid);
|
|
|
+ data.add(object);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //2: 根据token以及用户id获取用户信息数据
|
|
|
+ String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_bid");
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("Access-Token", token.getAccessToken());
|
|
|
+
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("advertiser_id", token.getAccountId());
|
|
|
+ params.put("data", data.toJSONString());
|
|
|
+ String result = HttpUtils.httpPostRequest(url, params, headers);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
+ int code = jsonObject.getInteger("code");
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ if (code != 0) {
|
|
|
+ log.info("修改计划出价接口异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", jsonObject.getString("message"));
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ JSONObject getData = jsonObject.getJSONObject("data");
|
|
|
+ if (null == getData) {
|
|
|
+ log.info("修改计划出价异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", jsonObject.getString("message"));
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ JSONArray getAdIds = getData.getJSONArray("ad_ids");
|
|
|
+ if (null != getAdIds && !getAdIds.isEmpty()) {
|
|
|
+ //获取广告计划信息
|
|
|
+ getAdvertiserPlan(token, adIds, null, null);
|
|
|
+ }
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "修改计划出价成功");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getAdvertiserPlanRejectReason(CtopOauthToken token, Long advertiserId, List<Long> adIds) {
|
|
|
+
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+
|
|
|
+ String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_reject_reason");
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("Access-Token", token.getAccessToken());
|
|
|
+
|
|
|
+ JSONObject params=new JSONObject();
|
|
|
+ params.put("advertiser_id",advertiserId);
|
|
|
+ params.put("ad_ids",adIds);
|
|
|
+ String result = HttpUtils.httpPostRequest(url, params, headers);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
+ int code = jsonObject.getInteger("code");
|
|
|
+ if(code!=0){
|
|
|
+ log.info("获取计划审核建议接口异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message",jsonObject.getString("message"));
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "获取计划审核建议成功");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void getAd(CtopOauthToken token, int pageNum, String ids, String date, String updateDate) {
|
|
|
+ JSONArray getIds = new JSONArray();
|
|
|
+ if (null != ids && !"".equals(ids)) {
|
|
|
+ String[] idString = ids.split(StringUtils.COMMA);
|
|
|
+ if (idString.length > 0) {
|
|
|
+ for (String s : idString) {
|
|
|
+ Long getId = Long.parseLong(s);
|
|
|
+ getIds.add(getId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 请求地址
|
|
|
+ String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_get");
|
|
|
+ // 请求参数
|
|
|
+ Map<String, Object> filtering = new HashMap<>();
|
|
|
+ if (getIds.size() > 0) {
|
|
|
+ filtering.put("ids", getIds);
|
|
|
+ }
|
|
|
+ if (null != date && !"".equals(date)) {
|
|
|
+ filtering.put("ad_create_time", date);
|
|
|
+ }
|
|
|
+ if (null != updateDate && !"".equals(updateDate)) {
|
|
|
+ filtering.put("ad_modify_time", updateDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject param = new JSONObject();
|
|
|
+ param.put("advertiser_id", token.getAccountId());
|
|
|
+ param.put("page", pageNum);
|
|
|
+ param.put("page_size", 100);
|
|
|
+ param.put("filtering", filtering);
|
|
|
+ JSONObject resultObject = HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, param);
|
|
|
+ int code = resultObject.getInteger("code");
|
|
|
+ if (code != 0) {
|
|
|
+ log.error("获取广告计划信息接口异常==》accountId:{},message:{}", token.getAccountId(), resultObject.getString("message"));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONArray data = resultObject.getJSONObject("data").getJSONArray("list");
|
|
|
+ if (null == data || data.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (int i = 0; i < data.size(); i++) {
|
|
|
+ JSONObject dataObject = data.getJSONObject(i);
|
|
|
+ ByteDanceAdvertisePlan advertisePlan = new ByteDanceAdvertisePlan(dataObject, String.valueOf(token.getAccountId()));
|
|
|
+ BigDecimal deepCpaBid = dataObject.getBigDecimal("deep_cpabid");
|
|
|
+ if (null != deepCpaBid) {
|
|
|
+ advertisePlan.setDeepCpaBid(deepCpaBid);
|
|
|
+ }
|
|
|
+ this.saveOrUpdate(advertisePlan);
|
|
|
+ }
|
|
|
+ getAd(token, pageNum + 1, ids, date, updateDate);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<String> selectWarningGroup(Long accountId, BigDecimal maxBid) {
|
|
|
return byteDanceAdvertisePlanMapper.selectWarningGroup(accountId, maxBid);
|