Ver Fonte

更新定向包

yangzian há 4 anos atrás
pai
commit
0c95ba64c0

+ 4 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/ByteDanceAdvertisePlan.java

@@ -153,6 +153,10 @@ public class ByteDanceAdvertisePlan {
     private BigDecimal lubanRoiGoal;
 
     private BigDecimal roiGoal;
+
+    //定向包id
+    private Integer audiencePackageId;
+
     /**
      *  受众公共参数
      */

+ 8 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/ByteDanceAdvertisePlanMapper.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.bytedance.advertise.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import io.lettuce.core.dynamic.annotation.Param;
 import org.jeecg.modules.bytedance.advertise.entity.ByteDanceAdvertisePlan;
+import org.jeecg.modules.bytedance.report.entity.BytedancePlanHourlyReport;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -20,4 +21,11 @@ public interface ByteDanceAdvertisePlanMapper extends BaseMapper<ByteDanceAdvert
     List<String> selectWarningCpaBid(@Param("accountId") Long accountId, @Param("maxCpaBid") BigDecimal maxCpaBid);
 
     int queryTodayBuiltCount(Long accountId, String date);
+
+    /**
+     * 更新广告计划 操作状态 或 定向包id
+     * @param byteDanceAdvertisePlan
+     * @return
+     */
+    Integer updateAdvertisePlan (ByteDanceAdvertisePlan byteDanceAdvertisePlan);
 }

+ 18 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/ByteDanceAdvertisePlanMapper.xml

@@ -27,4 +27,22 @@
     </select>
 
 
+
+    <!--更新广告计划 操作状态 或 定向包id-->
+    <update id="updateAdvertisePlan">
+
+        update ctop_bytedance_advertise_plan
+        <set>
+            <if test="optStatus != null">
+                opt_status = #{optStatus},
+            </if>
+            <if test="audiencePackageId != null">
+                audience_package_id = #{audiencePackageId},
+            </if>
+        </set>
+        where id = #{id}
+    </update>
+
+
+
 </mapper>

+ 3 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/IByteDanceAdvertisePlanService.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.bytedance.advertise.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.bytedance.advertise.entity.ByteDanceAdvertisePlan;
 import org.jeecg.modules.bytedance.common.entity.CtopOauthToken;
+import org.jeecg.modules.bytedance.report.entity.BytedancePlanHourlyReport;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -37,4 +38,6 @@ public interface IByteDanceAdvertisePlanService extends IService<ByteDanceAdvert
     List<ByteDanceAdvertisePlan> getAllPlans(Long accountId,String createDate);
 
     int queryToDayBuiltCount(Long accountId);
+
+    Integer updatePlanOrPackage (ByteDanceAdvertisePlan byteDanceAdvertisePlan);
 }

+ 12 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/ByteDanceAdvertisePlanServiceImpl.java

@@ -13,6 +13,7 @@ import org.jeecg.modules.bytedance.common.entity.CtopOauthToken;
 import org.jeecg.modules.bytedance.common.utils.HttpUtils;
 import org.jeecg.modules.bytedance.common.utils.PropertiesUtils;
 import org.jeecg.modules.bytedance.common.utils.StringUtils;
+import org.jeecg.modules.bytedance.report.entity.BytedancePlanHourlyReport;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -260,4 +261,15 @@ public class ByteDanceAdvertisePlanServiceImpl extends ServiceImpl<ByteDanceAdve
         return result;
     }
 
+    /**
+     * 更新广告计划 操作状态 或 定向包id
+     * @param byteDanceAdvertisePlan
+     * @return
+     */
+    @Override
+    public Integer updatePlanOrPackage (ByteDanceAdvertisePlan byteDanceAdvertisePlan){
+       return byteDanceAdvertisePlanMapper.updateAdvertisePlan(byteDanceAdvertisePlan);
+    }
+
+
 }

+ 3 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/report/entity/vo/ReportCostVo.java

@@ -50,5 +50,8 @@ public class ReportCostVo implements Serializable {
 
     private String updateTime;
 
+    //操作状态
+    private String optStatus;
+
 
 }

+ 8 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/report/service/impl/BytedanceAdvertiserHourlyReportServiceImpl.java

@@ -289,6 +289,14 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
                }
            }
            reportCostVo.setCompare(df.format(compare));
+
+           //操作状态
+           QueryWrapper<ByteDanceAdvertisePlan> advertisePlanQueryWrapper = new QueryWrapper<>();
+           advertisePlanQueryWrapper.eq("account_id",accountId);
+           advertisePlanQueryWrapper.eq("id",reportCostVo.getAdId());
+           advertisePlanQueryWrapper.last("limit 1");
+           ByteDanceAdvertisePlan advertisePlan = byteDanceAdvertisePlanMapper.selectOne(advertisePlanQueryWrapper);
+           reportCostVo.setOptStatus(advertisePlan.getOptStatus());
        });
         PageInfo<ReportCostVo> pageInfo = new PageInfo<ReportCostVo>(reportCostVoList);
         return Result.successMsg("成功。", pageInfo);

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

@@ -393,14 +393,14 @@ public class AiBytedanceAdvertiserStrategyController {
 	@GetMapping(value = "/getAdAudiencePackage")
 	public Result getAdAudiencePackage(@RequestParam(value = "accountId",required = false) String accountId,
 									   @RequestParam(value = "landingType",required = false) String landingType,
-									   @RequestParam(value = "deliveryRange",required = false) String deliveryRange) {
+									   @RequestParam(value = "deliveryRange",required = false,defaultValue = "DEFAULT") String deliveryRange) {
 		try {
 			if (Check.isNull(accountId)){
 				return Result.errorMsg("请选择账户。");
 			}
-			if (Check.isNull(landingType)){
+			/*if (Check.isNull(landingType)){
 				return Result.errorMsg("投放内容不能为空");
-			}
+			}*/
 			return aiBytedanceAdvertiserStrategyService.getAdAudiencePackage(accountId,landingType,deliveryRange);
 		}catch (Exception e){
 			log.error("获取定向包异常",e);

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

@@ -3,6 +3,7 @@ package org.jeecg.modules.bytedance.advertise.controller;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.google.gson.JsonArray;
+import io.lettuce.core.StrAlgoArgs;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -10,6 +11,8 @@ 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.entity.ByteDanceAdvertisePlan;
+import org.jeecg.modules.bytedance.advertise.service.IByteDanceAdvertisePlanService;
 import org.jeecg.modules.bytedance.advertise.vo.PlanSearchVo;
 import org.jeecg.modules.bytedance.common.entity.CtopOauthToken;
 import org.jeecg.modules.bytedance.common.service.ICtopOauthTokenService;
@@ -58,6 +61,8 @@ public class BytedanceReportController {
 	@Autowired
 	private ICtopOauthTokenService tokenService;
 
+	@Autowired
+	private IByteDanceAdvertisePlanService byteDanceAdvertisePlanService;
 
 
 
@@ -180,6 +185,11 @@ public class BytedanceReportController {
 				if (!resultUpd.isSuccess()){
 					return Result.errorMsg(resultUpd.getMessage());
 				}
+				ByteDanceAdvertisePlan byteDanceAdvertisePlan = new ByteDanceAdvertisePlan();
+				byteDanceAdvertisePlan.setId(Long.valueOf(adId));
+				byteDanceAdvertisePlan.setAudiencePackageId(Integer.valueOf(audiencePackageId));
+				//更新 表 定向包id
+				byteDanceAdvertisePlanService.updatePlanOrPackage(byteDanceAdvertisePlan);
 			}
 			return Result.successMsg("更新计划定向包", null);
 		}catch (Exception e){
@@ -189,8 +199,6 @@ public class BytedanceReportController {
 	}
 
 
-
-
 	@ApiOperation(value="投放数据-更新计划状态", notes="投放数据-更新计划状态")
 	@GetMapping(value = "/updPlanStatus")
 	public Result updPlanStatus(@RequestParam("accountId") String accountId,
@@ -200,9 +208,19 @@ public class BytedanceReportController {
 			CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
 			List<Long> list = new ArrayList<>();
 			list.add(adId);
-			return marketingService.updPlanStatus(token,list,optStatus);
+			//api 更新计划状态
+			Result result = marketingService.updPlanStatus(token,list,optStatus);
+			if (result.isSuccess()){
+				ByteDanceAdvertisePlan byteDanceAdvertisePlan = new ByteDanceAdvertisePlan();
+				byteDanceAdvertisePlan.setId(adId);
+				byteDanceAdvertisePlan.setOptStatus(optStatus.equalsIgnoreCase("enable") ? "AD_STATUS_ENABLE" : "AD_STATUS_DISABLE");
+				//更新 表 计划状态
+				byteDanceAdvertisePlanService.updatePlanOrPackage(byteDanceAdvertisePlan);
+				return Result.successMsg(result.getMessage(), null);
+			}
+			return Result.errorMsg(result.getMessage());
 		}catch (Exception e){
-			log.error("投放数据-获取花费和环比异常",e);
+			log.error("投放数据-更新计划状态异常",e);
 			return Result.error("请求失败,请联系开发人员!");
 		}
 	}