Bläddra i källkod

投放数据-更新计划定向包

yangzian 4 år sedan
förälder
incheckning
066493c7de

+ 1 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/dockapi/MarketingService.java

@@ -45,7 +45,7 @@ public interface MarketingService {
 
     Result updPlanStatus(CtopOauthToken token, List<String> adIds, String optStatus);
 
-    Result getPlanList(CtopOauthToken token, List<PlanSearchVo> planSearchVoList, Integer pageNo, Integer pageSize);
+    Result getPlanList(CtopOauthToken token, PlanSearchVo planSearchVo, Integer pageNo, Integer pageSize);
 
     Result updateCampaignStatus(CtopOauthToken token, List<String> campaignIds, String optStatus);
 

+ 13 - 8
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/dockapi/MarketingServiceImpl.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.bytedance.advertise.dockapi;
 
+import android.widget.CheckBox;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
@@ -538,20 +539,23 @@ public class MarketingServiceImpl implements MarketingService{
      * @description: 获取广告计划
      *
      * @param token
-     * @param planSearchVoList 广告计划 入参
+     * @param
      * @return: org.jeecg.common.api.vo.Result
      * @author: zianY
      */
     @Override
-    public  Result getPlanList(CtopOauthToken token, List<PlanSearchVo> planSearchVoList, Integer pageNo, Integer pageSize) {
+    public  Result getPlanList(CtopOauthToken token, PlanSearchVo planSearchVo, Integer pageNo, Integer pageSize) {
         JSONObject params = new JSONObject();
         params.put("advertiser_id", token.getAccountId());
-        params.put("filtering", planSearchVoList);
+        params.put("filtering", planSearchVo);
         params.put("page", pageNo);
         params.put("page_size", pageSize);
-        JSONObject jsonObject = HttpUtils.bytedancePostRequest(token.getAccessToken(),
+        JSONObject jsonObject = HttpUtils.bytedanceGetRequest(token.getAccessToken(),
                 urlPath + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_get_plan"),
                 params);
+        if (Check.isNull(jsonObject)){
+            return Result.errorMsg(jsonObject.get("message").toString());
+        }
         Integer code = jsonObject.getInteger("code");
         Map<String, Object> resultMap = new HashMap<>();
         if (code != 0) {
@@ -709,7 +713,7 @@ public class MarketingServiceImpl implements MarketingService{
         //广告计划名称
         params.put("name", strategy.getAdName());
         //计划状态 默认值: "enable"开启状态 允许值: "enable"开启,"disable"关闭
-        params.put("operation", BytedanceConstant.OPERATION_ENABLE);
+        //params.put("operation", BytedanceConstant.OPERATION_ENABLE);
         // 投放范围  "DEFAULT"默认, "UNION"穿山甲
         params.put("delivery_range", strategy.getAdDeliveryRange() == null ? "DEFAULT" : strategy.getAdDeliveryRange());
         //投放形式(穿山甲视频创意类型) 当delivery_range为"UNION"时必填
@@ -743,8 +747,9 @@ public class MarketingServiceImpl implements MarketingService{
         //直达链接(点击唤起APP)
         params.put("open_url", strategy.getAdOpenUrl());
         //搜索快投功能,允许值:HAS_OPEN:启用,DISABLED:不启用
-        params.put("feed_delivery_search", "搜索快投");
+        //params.put("feed_delivery_search", "搜索快投");
         //用户定向
+        params.put("audience_package_id",strategy.getAdAudiencePackageId());
         //允许值: "CITY"省市, "COUNTY"区县, "BUSINESS_DISTRICT"商圈,"NONE"不限
         params.put("district", strategy.getAdScheduleType());
         //性别 允许值: "GENDER_FEMALE", "GENDER_MALE", "NONE"
@@ -795,10 +800,10 @@ public class MarketingServiceImpl implements MarketingService{
         Integer code = jsonObject.getInteger("code");
         if (null ==  code || !code.equals(0)) {
             log.error("广告计划修改失败==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
-            Result.error(jsonObject.getString("message"));
+            return Result.error(jsonObject.getString("message"));
         }
         //byteDanceAdvertisePlan.setId(jsonObject.getJSONObject("data").getLong("ad_id"));
-        return Result.successMsg("广告计划修改成功成功",jsonObject.getString("data"));
+        return Result.successMsg("广告计划修改成功",jsonObject.getString("data"));
     }
 
 

+ 1 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/IAiBytedanceAdvertiserStrategyService.java

@@ -69,7 +69,7 @@ public interface IAiBytedanceAdvertiserStrategyService extends IService<AiByteda
      * @param pageSize
      * @return
      */
-    Result getCampaignPlan(String accountId, List<PlanSearchVo> planSearchVoList, Integer pageNo, Integer pageSize);
+    Result getCampaignPlan(String accountId, PlanSearchVo planSearchVoList, Integer pageNo, Integer pageSize);
 
     /**
      * @description: 获取创意详细信息

+ 1 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/AiBytedanceAdvertiserStrategyServiceImpl.java

@@ -1115,7 +1115,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
      * @author zianY
      */
     @Override
-    public Result getCampaignPlan(String accountId, List<PlanSearchVo> adGroupSearchVoList, Integer pageNo, Integer pageSize) {
+    public Result getCampaignPlan(String accountId, PlanSearchVo adGroupSearchVoList, Integer pageNo, Integer pageSize) {
 
         CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
         if (null == token) {

+ 1 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/vo/PlanSearchVo.java

@@ -11,7 +11,7 @@ import java.io.Serializable;
 @Data
 public class PlanSearchVo implements Serializable {
     //按广告计划ID过滤,
-    private String ids;
+    private String[] ids;
     //按广告计划name过滤
     private String ad_name;
     //按出价方式过滤

+ 2 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/service/impl/MaterialInfoServiceImpl.java

@@ -10,6 +10,7 @@ import org.jeecg.modules.bytedance.common.service.IMaterialInfoService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.util.Arrays;
 import java.util.List;
 
@@ -24,7 +25,7 @@ import java.util.List;
 @Service
 public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, MaterialInfo> implements IMaterialInfoService {
 
-    @Autowired
+    @Resource
     private MaterialInfoMapper materialInfoMapper;
 
 

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/bytedance/advertise/controller/AiBytedanceAdvertiserStrategyController.java

@@ -274,7 +274,7 @@ public class AiBytedanceAdvertiserStrategyController {
 
 	@ApiOperation(value="头条智能投放账户配置-获取广告计划", notes="头条智能投放账户配置-获取广告计划")
 	@PostMapping(value = "/getCampaignPlanList")
-	public Result getCampaignPlanList(List<PlanSearchVo> planSearchVoList,
+	public Result getCampaignPlanList(PlanSearchVo planSearchVoList,
 								   @RequestParam("accountId") String accountId,
 								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
 								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {

+ 45 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/bytedance/advertise/controller/BytedanceReportController.java

@@ -1,10 +1,16 @@
 package org.jeecg.modules.bytedance.advertise.controller;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.JsonArray;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.beanutils.ConvertUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.bytedance.advertise.dockapi.MarketingService;
+import org.jeecg.modules.bytedance.advertise.entity.AiBytedanceAdvertiserStrategy;
+import org.jeecg.modules.bytedance.advertise.vo.PlanSearchVo;
 import org.jeecg.modules.bytedance.common.entity.CtopOauthToken;
 import org.jeecg.modules.bytedance.common.service.ICtopOauthTokenService;
 import org.jeecg.modules.bytedance.common.service.IMaterialInfoService;
@@ -144,6 +150,45 @@ public class BytedanceReportController {
 	}
 
 
+	@ApiOperation(value="投放数据-更新计划定向包", notes="投放数据-更新计划定向包")
+	@GetMapping(value = "/updateADAudiencePackage")
+	public Result updateADAudiencePackage(@RequestParam("accountId") String accountId,
+									@RequestParam("adId") String adId,
+									@RequestParam("audiencePackageId") String audiencePackageId) {
+		try {
+			//1 获取token
+			CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
+			PlanSearchVo planSearchVo = new PlanSearchVo();
+			String[] ids = adId.split(",");
+			planSearchVo.setIds(ids);
+			//2 获取广告计划
+			Result result = marketingService.getPlanList(token,planSearchVo,1,1000);
+			if (!result.isSuccess()){
+				return Result.errorMsg(result.getMessage());
+			}
+			JSONObject jsonObject =JSONObject.parseObject(result.getResult().toString());
+			JSONArray array = jsonObject.getJSONArray("list");
+			List<Map<String,Object>> dataList = JSONArray.parseObject(array.toJSONString(),List.class);
+
+			for (Map<String, Object> map : dataList) {
+				String modifyTime = map.get("modify_time").toString();
+				AiBytedanceAdvertiserStrategy strategy = new AiBytedanceAdvertiserStrategy();
+				strategy.setAccountId(Long.valueOf(accountId));
+				strategy.setAdAudiencePackageId(audiencePackageId);
+				//3 修改广告计划 中的 定向包id
+				Result resultUpd = marketingService.updateAdvertiserPlan(token,adId,modifyTime,strategy);
+				if (!resultUpd.isSuccess()){
+					return Result.errorMsg(resultUpd.getMessage());
+				}
+			}
+			return Result.successMsg("更新计划定向包", null);
+		}catch (Exception e){
+			log.error("投放数据-更新计划定向包异常",e);
+			return Result.error("请求失败,请联系开发人员!");
+		}
+	}
+
+