2 コミット 66d70fabe8 ... 40d362ebc5

作者 SHA1 メッセージ 日付
  小杜 40d362ebc5 Merge remote-tracking branch 'origin/master' 4 ヶ月 前
  小杜 91a71abe2c 首页小时ecpm报表、app渠道类型修改 4 ヶ月 前

+ 4 - 5
yt-advertise/advertise-feign/src/main/java/com/ytpm/feign/AdvertiseFeign.java

@@ -1,11 +1,7 @@
 package com.ytpm.feign;
 
 import com.ytpm.advertise.param.*;
-import com.ytpm.advertise.view.AddAppResponse;
-import com.ytpm.advertise.view.AddPlacementResponse;
-import com.ytpm.advertise.view.ComprehensiveAppReport;
-import com.ytpm.advertise.view.ComprehensiveCommonView;
-import com.ytpm.advertise.view.ComprehensiveReportView;
+import com.ytpm.advertise.view.*;
 import com.ytpm.general.Result;
 import com.ytpm.general.ResultTable;
 import io.swagger.annotations.ApiOperation;
@@ -35,6 +31,9 @@ public interface AdvertiseFeign {
     @PostMapping("/advertise/comprehensive")
     Result<ComprehensiveReportView> comprehensive(@RequestBody ComprehensiveReportParam param);
 
+    @PostMapping("/advertise/hourReport")
+    ResultTable<HourReportView> hourReport(@RequestBody HourReportParam param);
+
     @GetMapping("/delAdSource")
     Result<?> delAdSource(@RequestParam("adSourceId") Integer adSourceId);
     @PostMapping("/saveAdSource")

+ 10 - 6
yt-advertise/advertise-service/src/main/java/com/ytpm/controller/AdvertiseController.java

@@ -1,12 +1,7 @@
 package com.ytpm.controller;
 
 import com.ytpm.advertise.param.*;
-import com.ytpm.advertise.view.AddAppResponse;
-import com.ytpm.advertise.view.AddPlacementResponse;
-import com.ytpm.advertise.view.AppV1View;
-import com.ytpm.advertise.view.ComprehensiveAppReport;
-import com.ytpm.advertise.view.ComprehensiveCommonView;
-import com.ytpm.advertise.view.ComprehensiveReportView;
+import com.ytpm.advertise.view.*;
 import com.ytpm.agent.param.ChannelParam;
 import com.ytpm.general.Result;
 import com.ytpm.general.ResultTable;
@@ -130,4 +125,13 @@ public class AdvertiseController {
     public Result<ComprehensiveReportView> comprehensive(@RequestBody ComprehensiveReportParam param){
         return takuApiService.comprehensiveReport(param);
     }
+
+    /**
+     *查询分小时报表
+     */
+    @ApiOperation("查询分小时报表")
+    @PostMapping("/hourReport")
+    public ResultTable<HourReportView>  hourReport(@RequestBody HourReportParam param){
+        return takuApiService.hourReport(param);
+    }
 }

+ 1 - 1
yt-advertise/advertise-service/src/main/java/com/ytpm/service/impl/TakuApiServiceImpl.java

@@ -298,7 +298,7 @@ public class TakuApiServiceImpl implements TakuApiService {
         JSONObject object = JSONObject.parseObject(result);
         Integer count = object.getInteger("count");
         if(Objects.nonNull(count)){
-            String records = object.getString("records");
+            String records = object.getString("data");
             List<HourReportView> hourReportViews = JSONArray.parseArray(records, HourReportView.class);
             return ResultTable.resultTableOk(new PageInfo<HourReportView>(hourReportViews));
         }

+ 99 - 4
yt-agent/agent-service/src/main/java/com/ytpm/controller/AgentIndexController.java

@@ -2,12 +2,20 @@ package com.ytpm.controller;
 
 import com.ytpm.advertise.enums.AdPlatformTypeEnum;
 import com.ytpm.advertise.param.ComprehensiveReportParam;
+import com.ytpm.advertise.param.HourReportParam;
 import com.ytpm.advertise.view.ComprehensiveAppReport;
+import com.ytpm.advertise.view.HourReportView;
 import com.ytpm.agent.param.IndexResParam;
+import com.ytpm.agent.view.AgentChannelView;
+import com.ytpm.agent.view.IndexHourReportView;
+import com.ytpm.dao.ChannelMapper;
 import com.ytpm.feign.AdvertiseFeign;
 import com.ytpm.general.Result;
+import com.ytpm.general.ResultTable;
+import com.ytpm.service.impl.ChannelServiceImpl;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -18,10 +26,7 @@ import java.math.RoundingMode;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.TemporalAdjusters;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Api(tags = "首页数据统计模块")
@@ -32,6 +37,9 @@ public class AgentIndexController {
     @Resource
     private AdvertiseFeign advertiseFeign;
 
+    @Resource
+    private ChannelMapper channelMapper;
+
     /**
      * 查询广告平台收益
      */
@@ -86,7 +94,14 @@ public class AgentIndexController {
                             .map(ComprehensiveAppReport::getRevenue)
                             .filter(Objects::nonNull)
                             .reduce(BigDecimal.ZERO, BigDecimal::add);
+                    //ecpm数据
+                    BigDecimal todayEcpm = platformReports.stream()
+                            .filter(item -> todayStr.equals(item.getDate()))
+                            .filter(Objects::nonNull)
+                            .map(ComprehensiveAppReport::getEcpm)
+                            .reduce(BigDecimal.ZERO, BigDecimal::add);
                     resParam.setToday(todayRevenue.setScale(2, RoundingMode.HALF_UP).toString());
+                    resParam.setEcpmToday(todayEcpm.setScale(2, RoundingMode.HALF_UP).toString());
 
                     // 统计昨日数据
                     BigDecimal yesterdayRevenue = platformReports.stream()
@@ -96,6 +111,14 @@ public class AgentIndexController {
                             .reduce(BigDecimal.ZERO, BigDecimal::add);
                     resParam.setYesterday(yesterdayRevenue.setScale(2, RoundingMode.HALF_UP).toString());
 
+                    //昨天ecpm数据
+                    BigDecimal yesterdayEcpm = platformReports.stream()
+                            .filter(item -> yesterdayStr.equals(item.getDate()))
+                            .filter(Objects::nonNull)
+                            .map(ComprehensiveAppReport::getEcpm)
+                            .reduce(BigDecimal.ZERO, BigDecimal::add);
+                    resParam.setEcpmYesterday(yesterdayEcpm.setScale(2, RoundingMode.HALF_UP).toString());
+
                     // 统计本月数据
                     BigDecimal monthRevenue = platformReports.stream()
                             .filter(item -> {
@@ -106,7 +129,19 @@ public class AgentIndexController {
                             .map(ComprehensiveAppReport::getRevenue)
                             .filter(Objects::nonNull)
                             .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+                    BigDecimal monthEcpm = platformReports.stream()
+                            .filter(
+                                    item -> {
+                                        String date = item.getDate();
+                                        return date != null && date.compareTo(monthStartStr) >= 0
+                                                && date.compareTo(monthEndStr) <= 0;
+                                    })
+                            .filter(Objects::nonNull)
+                            .map(ComprehensiveAppReport::getEcpm)
+                            .reduce(BigDecimal.ZERO, BigDecimal::add);
                     resParam.setMonth(monthRevenue.setScale(2, RoundingMode.HALF_UP).toString());
+                    resParam.setEcpmMonth(monthEcpm.setScale(2, RoundingMode.HALF_UP).toString());
 
                     return resParam;
                 })
@@ -115,5 +150,65 @@ public class AgentIndexController {
         return Result.resultObjOk(result);
     }
 
+    /**
+     * 查询分小时报表 折线图数据
+     * 预估收益以及ecpm
+     */
+    @ApiOperation("查询分小时报表")
+    @PostMapping("/hourReport")
+    public Result<?> hourReport() {
+        HourReportParam param = new HourReportParam();
+        // 1. 准备日期参数
+        LocalDate today = LocalDate.now();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
+
+        // 今日和昨日日期
+        String todayStr = today.format(formatter);
+        Integer todayInt = Integer.valueOf(todayStr);
+        List<AgentChannelView> agentChannelViews = channelMapper.channelList();
+        ArrayList<IndexHourReportView> indexHourReportViews = new ArrayList<>();
+
+        for (AgentChannelView agentChannelView : agentChannelViews) {
+            IndexHourReportView indexHourReportView = new IndexHourReportView();
+            indexHourReportView.setChannelName(agentChannelView.getChannelName());
+
+            List<BigDecimal> hourlyData = new ArrayList<>(24);
+            for (int i = 0; i < 24; i++) {
+                hourlyData.add(BigDecimal.ZERO);
+            }
+            List<BigDecimal> ecpmData = new ArrayList<>(24);
+            for (int i = 0; i < 24; i++) {
+                ecpmData.add(BigDecimal.ZERO);
+            }
+            Integer networkId = agentChannelView.getNetworkId();
+            param.setNetwork_id_list(Collections.singletonList(networkId));
+            param.setStart_date(todayInt);
+            param.setEnd_date(todayInt);
+            param.setCurrency("CNY");
+            param.setLimit(100);
+            param.setStart(0);
+            param.setTime_zone("UTC+8");
+
+            ResultTable<HourReportView> hourReportViewResultTable = advertiseFeign.hourReport(param);
+            List<HourReportView> data = hourReportViewResultTable.getData();
+            if (!data.isEmpty()) {
+                for (HourReportView hourReport : data) {
+                    int hour = hourReport.getHour();
+                    if (hour >= 0 && hour < 24) {
+                        BigDecimal revenue = hourReport.getEstimated_revenue();
+                        hourlyData.set(hour, revenue);
+                        ecpmData.set(hour, hourReport.getEstimated_revenue_ecpm());
+                    }
+                }
+            }
+
+            indexHourReportView.setEstimatedRevenueList(hourlyData);
+            indexHourReportView.setEstimatedRevenueEcpmList(ecpmData);
+            indexHourReportViews.add(indexHourReportView);
+        }
+
+        return Result.resultObjOk(indexHourReportViews);
+    }
+
 
 }

+ 2 - 0
yt-agent/agent-service/src/main/java/com/ytpm/dao/AppMapper.java

@@ -18,6 +18,8 @@ public interface AppMapper {
      */
     YtApp selectPrimary(@Param("appId") String appId);
 
+    YtApp selectByDitchId(@Param("ditchId") Long ditchId);
+
     /**
      * 保存应用
      */

+ 11 - 0
yt-agent/agent-service/src/main/java/com/ytpm/service/impl/AgentDitchServiceImpl.java

@@ -2,10 +2,12 @@ package com.ytpm.service.impl;
 
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.ytpm.agent.model.YtApp;
 import com.ytpm.agent.model.YtDitch;
 import com.ytpm.agent.param.DitchListParam;
 import com.ytpm.agent.view.AgentDitchView;
 import com.ytpm.dao.AgentDitchMapper;
+import com.ytpm.dao.AppMapper;
 import com.ytpm.general.RepMessage;
 import com.ytpm.general.Result;
 import com.ytpm.general.ResultTable;
@@ -20,6 +22,10 @@ public class AgentDitchServiceImpl implements AgentDitchService {
     @Resource
     private AgentDitchMapper agentDitchMapper;
 
+    @Resource
+    private AppMapper appMapper;
+
+
     @Override
     public ResultTable<AgentDitchView> ditchList(DitchListParam param) {
         PageHelper.startPage(param.getPage(), param.getLimit());
@@ -37,6 +43,11 @@ public class AgentDitchServiceImpl implements AgentDitchService {
     @Override
     public Result<?> updateOne(YtDitch param) {
         agentDitchMapper.update(param);
+        //同时修改app中的渠道类型名称
+        Long ditchId = param.getDitchId();
+        YtApp ytApp = appMapper.selectByDitchId(ditchId);
+        ytApp.setDitchName(param.getDitchName());
+        appMapper.updateOne(ytApp);
         return Result.resultOk(RepMessage.MODIFY_SUCCESS);
     }
 

+ 1 - 0
yt-agent/agent-service/src/main/resources/mapper/AgentAppMapper.xml

@@ -55,6 +55,7 @@
             ya.coppa,
             ya.ccpa,
             ya.screen_orientation,
+            ya.ditch_name
             GROUP_CONCAT( acr.channel_id ) channel_id,
             GROUP_CONCAT( acr.channel_name ) channel_name,
             GROUP_CONCAT( acr.network_app_id ) network_app_id,

+ 14 - 2
yt-agent/agent-service/src/main/resources/mapper/AppMapper.xml

@@ -23,7 +23,8 @@
          coppa,
          screen_orientation,
          ccpa,
-         store_url
+         store_url,
+         ditch_id
         )
         values
         (
@@ -45,7 +46,8 @@
          #{coppa},
          #{screenOrientation},
          #{ccpa},
-         #{storeUrl}
+         #{storeUrl},
+         #{ditchId}
         )
     </insert>
     <update id="updateOne">
@@ -105,6 +107,9 @@
             <if test="qrCode != null">
                 qr_code = #{qrCode},
             </if>
+            <if test="ditchId != null">
+               ditch_id=#{ditchId}
+            </if>
 
         </set>
         where app_id = #{appId}
@@ -124,4 +129,11 @@
         from yt_app
         where user_id = #{userId}
     </select>
+
+    <select id="selectByDitchId" resultType="com.ytpm.agent.model.YtApp">
+        select
+            app_id, app_key, app_name,user_id, app_type, apk_url, qr_code, version_code, update_tips, enabled,ditch_name,ditch_id
+        from yt_app
+        where ditch_id = #{ditchId}
+    </select>
 </mapper>

+ 4 - 1
yt-agent/agent-service/src/main/resources/mapper/ChannelMapper.xml

@@ -62,13 +62,16 @@
             <if test="loginType !=null">
                 login_type = #{loginType},
             </if>
+            <if test="networkId !=null">
+                network_id=#{networkId}
+            </if>
         </set>
         where channel_id = #{channelId}
     </update>
 
     <select id="channelList" resultType="com.ytpm.agent.view.AgentChannelView">
         select
-            channel_id, channel_name, login_type, channel_account, channel_pwd, channel_status, api_key, api_secret, remark, enabled,ad_platform_type
+            channel_id, channel_name, login_type, channel_account, channel_pwd, channel_status, api_key, api_secret, remark, enabled,ad_platform_type,network_id
         from yt_channel
         where enabled = 1
     </select>

+ 9 - 0
yt-common/src/main/java/com/ytpm/agent/model/YtApp.java

@@ -96,6 +96,15 @@ public class YtApp {
      * 屏幕方向
      */
     private Integer screenOrientation;
+    /**
+     * 渠道类型id
+     */
+    private Long ditchId;
+
+    /**
+     * 渠道类型名称
+     */
+    private String ditchName;
 
 
 }

+ 2 - 0
yt-common/src/main/java/com/ytpm/agent/model/YtChannel.java

@@ -29,5 +29,7 @@ public class YtChannel {
     private Integer enabled;
     @ApiModelProperty("广告平台类型 15-穿山甲 8-腾讯广告 22-百度联盟 28-快手 29-Sigmob")
     private Integer adPlatformType;
+    @ApiModelProperty("广告平台账号id")
+    private Integer networkId;
 
 }

+ 4 - 0
yt-common/src/main/java/com/ytpm/agent/param/AppParam.java

@@ -48,4 +48,8 @@ public class AppParam {
     private String versionCode;
     @ApiModelProperty("更新提示")
     private String updateTips;
+    @ApiModelProperty("渠道类型id")
+    private Long ditchId;
+    @ApiModelProperty("渠道类型名称")
+    private String ditchName;
 }

+ 3 - 0
yt-common/src/main/java/com/ytpm/agent/param/IndexResParam.java

@@ -11,4 +11,7 @@ public class IndexResParam {
     private String today;
     private String yesterday;
     private String month;
+    private String ecpmToday;
+    private String ecpmYesterday;
+    private String ecpmMonth;
 }

+ 4 - 0
yt-common/src/main/java/com/ytpm/agent/view/AgentAppView.java

@@ -75,6 +75,10 @@ public class AgentAppView {
      * ccpa
      */
     private Integer ccpa;
+    /**
+     * 渠道类型名称
+     */
+    private String ditchName;
     /**
      * 屏幕方向
      */

+ 2 - 0
yt-common/src/main/java/com/ytpm/agent/view/AgentChannelView.java

@@ -27,4 +27,6 @@ public class AgentChannelView {
     private String remark;
     @ApiModelProperty("广告平台类型 1-穿山甲 2-腾讯广告 3-百度联盟 4-快手 5-Sigmob")
     private Integer adPlatformType;
+    @ApiModelProperty("广告平台账号ID")
+    private Integer networkId;
 }

+ 13 - 0
yt-common/src/main/java/com/ytpm/agent/view/IndexHourReportView.java

@@ -0,0 +1,13 @@
+package com.ytpm.agent.view;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+@Data
+public class IndexHourReportView {
+    private String channelName;
+    private List<BigDecimal> estimatedRevenueList;
+    private List<BigDecimal> estimatedRevenueEcpmList;
+}