Browse Source

更新计划状态

yangzian 4 years ago
parent
commit
8d32bb3bd4

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

@@ -43,7 +43,7 @@ public interface MarketingService {
 
 
     Result updatePlanBudget(CtopOauthToken token, String advertiserId, List<Map<String, Object>> listMap);
     Result updatePlanBudget(CtopOauthToken token, String advertiserId, List<Map<String, Object>> listMap);
 
 
-    Result updPlanStatus(CtopOauthToken token, List<String> adIds, String optStatus);
+    Result updPlanStatus(CtopOauthToken token, List<Long> adIds, String optStatus);
 
 
     Result getPlanList(CtopOauthToken token, PlanSearchVo planSearchVo, Integer pageNo, Integer pageSize);
     Result getPlanList(CtopOauthToken token, PlanSearchVo planSearchVo, Integer pageNo, Integer pageSize);
 
 

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

@@ -516,7 +516,7 @@ public class MarketingServiceImpl implements MarketingService{
      * @author: zianY
      * @author: zianY
      */
      */
     @Override
     @Override
-    public  Result updPlanStatus(CtopOauthToken token, List<String> adIds, String optStatus) {
+    public  Result updPlanStatus(CtopOauthToken token, List<Long> adIds, String optStatus) {
         JSONObject params = new JSONObject();
         JSONObject params = new JSONObject();
         params.put("advertiser_id", token.getAccountId());
         params.put("advertiser_id", token.getAccountId());
         params.put("ad_ids", adIds);
         params.put("ad_ids", adIds);
@@ -525,7 +525,6 @@ public class MarketingServiceImpl implements MarketingService{
                 urlPath + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_status"),
                 urlPath + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_status"),
                 params);
                 params);
         Integer code = jsonObject.getInteger("code");
         Integer code = jsonObject.getInteger("code");
-        Map<String, Object> resultMap = new HashMap<>();
         if (code != 0) {
         if (code != 0) {
             log.error("广告计划更新状态接口异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
             log.error("广告计划更新状态接口异常==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
             return Result.error("广告计划更新状态接口异常");
             return Result.error("广告计划更新状态接口异常");

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

@@ -112,39 +112,35 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
           nowCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfoStage(accountId,startTime,endTime);
           nowCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfoStage(accountId,startTime,endTime);
           lastCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfoStage(accountId,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"));
           lastCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfoStage(accountId,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"));
         }
         }
-
-        nowMap.put("costList", nowCostList);
-        lastMap.put("costList", lastCostList);
+        //当前阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
+        nowMap.put("costList", getCostList(nowCostList));
+        //上个阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
+        lastMap.put("costList", getCostList(lastCostList));
 
 
         resultMap.put("nowMap", nowMap);
         resultMap.put("nowMap", nowMap);
         resultMap.put("lastMap", lastMap);
         resultMap.put("lastMap", lastMap);
-
         return Result.successMsg("成功。",resultMap);
         return Result.successMsg("成功。",resultMap);
     }
     }
 
 
 
 
     /**
     /**
-     * 获取 数据
+     * 获取 数据 (总)
      * @param list
      * @param list
      * @return
      * @return
      */
      */
     public Map<String,Object> getCost(List<ReportCostVo> list){
     public Map<String,Object> getCost(List<ReportCostVo> list){
         Map<String,Object> map = new HashMap<>();
         Map<String,Object> map = new HashMap<>();
-
         //花费
         //花费
         double cost = list.stream().mapToDouble(ReportCostVo::getCost).sum();
         double cost = list.stream().mapToDouble(ReportCostVo::getCost).sum();
-
         //转化成本 = 总花费 / 转化数
         //转化成本 = 总花费 / 转化数
         int converNum = list.stream().mapToInt(ReportCostVo::getConvertNum).sum();
         int converNum = list.stream().mapToInt(ReportCostVo::getConvertNum).sum();
         double conver = cost / converNum;
         double conver = cost / converNum;
         map.put("conver", String.format("%.2f", conver));
         map.put("conver", String.format("%.2f", conver));
         map.put("converNum", converNum);
         map.put("converNum", converNum);
-
         //转化率 = 转化数 / 点击数 * 100
         //转化率 = 转化数 / 点击数 * 100
         int clickNum = list.stream().mapToInt(ReportCostVo::getClick).sum();
         int clickNum = list.stream().mapToInt(ReportCostVo::getClick).sum();
         double click = Double.valueOf(converNum) /  Double.valueOf(clickNum) * 100;
         double click = Double.valueOf(converNum) /  Double.valueOf(clickNum) * 100;
         map.put("converRate", String.format("%.2f", click));
         map.put("converRate", String.format("%.2f", click));
-
         // 平均千次展显费用 = 总花费/展示数 * 1000
         // 平均千次展显费用 = 总花费/展示数 * 1000
         int showNum = list.stream().mapToInt(ReportCostVo::getShowNum).sum();
         int showNum = list.stream().mapToInt(ReportCostVo::getShowNum).sum();
         double show = (cost / showNum) * 1000 ;
         double show = (cost / showNum) * 1000 ;
@@ -152,6 +148,30 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
         return map;
         return map;
     }
     }
 
 
+    //获取 数据 (时间段)
+    public List<ReportCostVo> getCostList(List<ReportCostVo> list){
+        list.forEach(reportCostVo -> {
+            //花费
+            double cost = reportCostVo.getCost();
+            //转化成本 = 总花费 / 转化数
+            int converNum = reportCostVo.getConvertNum();
+            double conver = cost / converNum;
+            reportCostVo.setConver(String.format("%.2f", conver));
+            reportCostVo.setConvertNum(converNum);
+
+            //转化率 = 转化数 / 点击数 * 100
+            int clickNum = reportCostVo.getClick();
+            double click = Double.valueOf(converNum) /  Double.valueOf(clickNum) * 100;
+            reportCostVo.setConverRate(String.format("%.2f", click));
+
+            // 平均千次展显费用 = 总花费/展示数 * 1000
+            int showNum = reportCostVo.getShowNum();
+            double show = (cost / showNum) * 1000 ;
+            reportCostVo.setAverageShow(String.format("%.2f", show));
+        });
+        return list;
+    }
+
 
 
 
 
     /**
     /**

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

@@ -191,6 +191,25 @@ public class BytedanceReportController {
 
 
 
 
 
 
+	@ApiOperation(value="投放数据-更新计划状态", notes="投放数据-更新计划状态")
+	@GetMapping(value = "/updPlanStatus")
+	public Result updPlanStatus(@RequestParam("accountId") String accountId,
+							  @RequestParam("adId") Long adId,
+							  @RequestParam("optStatus") String optStatus) {
+		try {
+			CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
+			List<Long> list = new ArrayList<>();
+			list.add(adId);
+			return marketingService.updPlanStatus(token,list,optStatus);
+		}catch (Exception e){
+			log.error("投放数据-获取花费和环比异常",e);
+			return Result.error("请求失败,请联系开发人员!");
+		}
+	}
+
+
+
+
 	@ApiOperation(value="投放数据-素材维度展示", notes="投放数据-素材维度展示")
 	@ApiOperation(value="投放数据-素材维度展示", notes="投放数据-素材维度展示")
 	@GetMapping(value = "/selectMaterialDailyReport")
 	@GetMapping(value = "/selectMaterialDailyReport")
 	public Result selectMaterialDailyReport(@RequestParam("accountId") String accountId,
 	public Result selectMaterialDailyReport(@RequestParam("accountId") String accountId,