Explorar o código

Merge branch 'test'

yangzian %!s(int64=2) %!d(string=hai) anos
pai
achega
e7bbab604a

+ 33 - 2
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -1916,6 +1916,29 @@ public class DateUtils extends PropertyEditorSupport {
 
 
     /**
+     * 获取 时 list
+     *
+     * @param
+     * @return
+     */
+    public static List<String> getHoursListDifference(List<String> betweenDaysList) {
+        List<String> dateList = new ArrayList<String>(){{
+            add("00");add("01");add("02");add("03");add("04");add("05");
+            add("06");add("07");add("08");add("09");add("10");add("11");
+            add("12");add("13");add("14");add("15");add("16");add("17");
+            add("18");add("19");add("20");add("21");add("22");add("23");
+        }};
+        List<String> resultList = new ArrayList<String>();
+        betweenDaysList.forEach(day ->{
+            dateList.forEach(hour ->{
+                resultList.add((day + hour).replace("-",""));
+            });
+        });
+        return resultList;
+    }
+
+
+    /**
      * 时间 去重 排序
      *
      * @param list
@@ -2022,8 +2045,16 @@ public class DateUtils extends PropertyEditorSupport {
         //BigDecimal unitRatio = BigDecimal.valueOf((groupNum - yesNum) / yesNum).multiply(new BigDecimal(100));
         //System.out.println(unitRatio);
 
-        System.out.println(getFirstDayByMonth());
-        ;
+        //System.out.println(getFirstDayByMonth());
+
+        //System.out.println(getSubtractTime(new Date(),6));;
+
+        List<String> list = new ArrayList<String>();
+        list.add("2022-09-01");
+        list.add("2022-09-04");
+
+
+        System.out.println(getHoursListDifference(list));;
 
     }
 

+ 10 - 1
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/controller/KuaiShouOperationRecordController.java

@@ -88,13 +88,22 @@ public class KuaiShouOperationRecordController {
 
 
 
+    /**
+     *
+     * @description: 快手操作记录
+     *
+     * @param advertiserId
+     * @param unitId
+     * @param startTime
+     * @param endTime
+     * @return: org.jeecg.common.api.vo.Result<com.alibaba.fastjson.JSONObject>
+     */
     @GetMapping("/getKuaishouOperationRecordByUnit")
     public Result<JSONObject> getKuaishouOperationRecordByUnit(@RequestParam(name="advertiserId") long advertiserId,
                                                                     @RequestParam(name="unitId") long unitId,
                                                                      @RequestParam(name="startTime") String startTime,
                                                                      @RequestParam(name="endTime") String endTime) throws Exception{
 
-
         return kuaishouOperationRecordService.getKuaishouOperationRecordByUnit(advertiserId,unitId,startTime,endTime);
     }
 

+ 30 - 4
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/entity/KuaishouUnitReportHourlyPojo.java

@@ -69,35 +69,41 @@ public class KuaishouUnitReportHourlyPojo {
     /** 素材曝光数 */
     @Excel(name = "素材曝光数", width = 15)
     @ApiModelProperty(value = "素材曝光数")
-    private Long aclick;
+    private Long aClick;
     /** 行为数 */
     @Excel(name = "行为数", width = 15)
     @ApiModelProperty(value = "行为数")
-    private Long bclick;
+    private Long bClick;
     /** 封面点击率 */
     @Excel(name = "封面点击率", width = 15)
     @ApiModelProperty(value = "封面点击率")
     private java.math.BigDecimal photoClickRatio;
+    private String clickRate;
     /** 3s播放率 */
     @Excel(name = "3s播放率", width = 15)
     @ApiModelProperty(value = "3s播放率")
     private java.math.BigDecimal play3sRatio;
+    private String play3sRate;
     /** 行为率 */
     @Excel(name = "行为率", width = 15)
     @ApiModelProperty(value = "行为率")
     private java.math.BigDecimal actionRatio;
+    private String bClickRate;
     /** 平均千次曝光花费(元) */
     @Excel(name = "平均千次曝光花费(元)", width = 15)
     @ApiModelProperty(value = "平均千次曝光花费(元)")
     private java.math.BigDecimal impression1kCost;
+    private java.math.BigDecimal cpm;
     /** 平均点击单价(元) */
     @Excel(name = "平均点击单价(元)", width = 15)
     @ApiModelProperty(value = "平均点击单价(元)")
     private java.math.BigDecimal photoClickCost;
+    private java.math.BigDecimal cpc;
     /** 平均行为单价(元) */
     @Excel(name = "平均行为单价(元)", width = 15)
     @ApiModelProperty(value = "平均行为单价(元)")
     private java.math.BigDecimal actionCost;
+    private java.math.BigDecimal cpb;
     /** 分享数 */
     @Excel(name = "分享数", width = 15)
     @ApiModelProperty(value = "分享数")
@@ -138,30 +144,37 @@ public class KuaishouUnitReportHourlyPojo {
     @Excel(name = "应用下载数据-安卓下载开始数", width = 15)
     @ApiModelProperty(value = "应用下载数据-安卓下载开始数")
     private Long downloadStarted;
+    private Long downloadStart;
     /** 应用下载数据-安卓下载完成数 */
     @Excel(name = "应用下载数据-安卓下载完成数", width = 15)
     @ApiModelProperty(value = "应用下载数据-安卓下载完成数")
     private Long downloadCompleted;
+    private Long downloadFinish;
     /** 应用下载数据-激活数 */
     @Excel(name = "应用下载数据-激活数", width = 15)
     @ApiModelProperty(value = "应用下载数据-激活数")
     private Long activation;
+    private Long active;
     /** 应用下载数据-首日付费次数 */
     @Excel(name = "应用下载数据-首日付费次数", width = 15)
     @ApiModelProperty(value = "应用下载数据-首日付费次数")
     private Long eventPayFirstDay;
+    private Long firstDayPay;
     /** 应用下载数据-首日付费金额 */
     @Excel(name = "应用下载数据-首日付费金额", width = 15)
     @ApiModelProperty(value = "应用下载数据-首日付费金额")
     private java.math.BigDecimal eventPayPurchaseAmountFirstDay;
+    private java.math.BigDecimal firstDayPayAmount;
     /** 应用下载数据-首日ROI */
     @Excel(name = "应用下载数据-首日ROI", width = 15)
     @ApiModelProperty(value = "应用下载数据-首日ROI")
     private java.math.BigDecimal eventPayFirstDayRoi;
+    private java.math.BigDecimal firstDayPayROI;
     /** 应用下载数据-付费次数 */
     @Excel(name = "应用下载数据-付费次数", width = 15)
     @ApiModelProperty(value = "应用下载数据-付费次数")
     private Long eventPay;
+    private java.math.BigDecimal eventPayCost;
     /** 应用下载数据-付费金额 */
     @Excel(name = "应用下载数据-付费金额", width = 15)
     @ApiModelProperty(value = "应用下载数据-付费金额")
@@ -170,18 +183,22 @@ public class KuaishouUnitReportHourlyPojo {
     @Excel(name = "应用下载数据-ROI", width = 15)
     @ApiModelProperty(value = "应用下载数据-ROI")
     private java.math.BigDecimal eventPayRoi;
+    private java.math.BigDecimal ROI;
     /** 应用下载数据-注册数 */
     @Excel(name = "应用下载数据-注册数", width = 15)
     @ApiModelProperty(value = "应用下载数据-注册数")
     private Long eventRegister;
+    private Long register;
     /** 应用下载数据-注册成本 */
     @Excel(name = "应用下载数据-注册成本", width = 15)
     @ApiModelProperty(value = "应用下载数据-注册成本")
     private java.math.BigDecimal eventRegisterCost;
+    private java.math.BigDecimal activeRegisterCost;
     /** 应用下载数据-注册率 */
     @Excel(name = "应用下载数据-注册率", width = 15)
     @ApiModelProperty(value = "应用下载数据-注册率")
     private java.math.BigDecimal eventRegisterRatio;
+    private String activeRegisterRate;
     /** 应用下载数据-完件数 */
     @Excel(name = "应用下载数据-完件数", width = 15)
     @ApiModelProperty(value = "应用下载数据-完件数")
@@ -202,6 +219,7 @@ public class KuaishouUnitReportHourlyPojo {
     @Excel(name = "应用下载数据-授信率", width = 15)
     @ApiModelProperty(value = "应用下载数据-授信率")
     private java.math.BigDecimal eventCreditGrantAppRatio;
+    private String eventCreditGrantAppRate;
     /** 应用下载数据-付款成功数 */
     @Excel(name = "应用下载数据-付款成功数", width = 15)
     @ApiModelProperty(value = "应用下载数据-付款成功数")
@@ -218,14 +236,17 @@ public class KuaishouUnitReportHourlyPojo {
     @Excel(name = "应用下载数据-次留数(仅支持分日查询)", width = 15)
     @ApiModelProperty(value = "应用下载数据-次留数(仅支持分日查询)")
     private Long eventNextDayStay;
+    private Long nextDayOpen;
     /** 应用下载数据-次留成本(仅支持分日查询) */
     @Excel(name = "应用下载数据-次留成本(仅支持分日查询)", width = 15)
     @ApiModelProperty(value = "应用下载数据-次留成本(仅支持分日查询)")
     private java.math.BigDecimal eventNextDayStayCost;
+    private java.math.BigDecimal nextDayOpenCost;
     /** 应用下载数据-次留率(仅支持分日查询) */
     @Excel(name = "应用下载数据-次留率(仅支持分日查询)", width = 15)
     @ApiModelProperty(value = "应用下载数据-次留率(仅支持分日查询)")
     private java.math.BigDecimal eventNextDayStayRatio;
+    private String nextDayOpenRate;
     /** 落地页数据-表单提交数 */
     @Excel(name = "落地页数据-表单提交数", width = 15)
     @ApiModelProperty(value = "落地页数据-表单提交数")
@@ -234,10 +255,12 @@ public class KuaishouUnitReportHourlyPojo {
     @Excel(name = "落地页数据-表单提交单价", width = 15)
     @ApiModelProperty(value = "落地页数据-表单提交单价")
     private java.math.BigDecimal formCost;
+    private java.math.BigDecimal formCountCost;
     /** 落地页数据-表单提交点击率 */
     @Excel(name = "落地页数据-表单提交点击率", width = 15)
     @ApiModelProperty(value = "落地页数据-表单提交点击率")
     private java.math.BigDecimal formActionRatio;
+    private String formCountRate;
     /** 落地页数据-落地页完件数 */
     @Excel(name = "落地页数据-落地页完件数", width = 15)
     @ApiModelProperty(value = "落地页数据-落地页完件数")
@@ -258,6 +281,7 @@ public class KuaishouUnitReportHourlyPojo {
     @Excel(name = "落地页数据-落地页授信率", width = 15)
     @ApiModelProperty(value = "落地页数据-落地页授信率")
     private java.math.BigDecimal eventCreditGrantLandingPageRatio;
+    private String eventCreditGrantLandingPageRate;
     /** 落地页数据-有效线索数 */
     @Excel(name = "落地页数据-有效线索数", width = 15)
     @ApiModelProperty(value = "落地页数据-有效线索数")
@@ -301,7 +325,7 @@ public class KuaishouUnitReportHourlyPojo {
     /** 唤醒应用率 */
     @Excel(name = "唤醒应用率", width = 15)
     @ApiModelProperty(value = "唤醒应用率")
-    private java.math.BigDecimal eventAppInvokedRatio;
+    private String eventAppInvokedRatio;
     /** 落地页授信率 */
     @Excel(name = "落地页授信率", width = 15)
     @ApiModelProperty(value = "落地页授信率")
@@ -325,7 +349,7 @@ public class KuaishouUnitReportHourlyPojo {
     /** 新增付费人数率 */
     @Excel(name = "新增付费人数率", width = 15)
     @ApiModelProperty(value = "新增付费人数率")
-    private java.math.BigDecimal eventNewUserPayRatio;
+    private String eventNewUserPayRatio;
     /** 平均千次素材曝光花费(元) */
     @Excel(name = "平均千次素材曝光花费(元)", width = 15)
     @ApiModelProperty(value = "平均千次素材曝光花费(元)")
@@ -362,10 +386,12 @@ public class KuaishouUnitReportHourlyPojo {
     @Excel(name = "按钮点击成本", width = 15)
     @ApiModelProperty(value = "按钮点击成本")
     private java.math.BigDecimal eventButtonClickCost;
+    private java.math.BigDecimal submitCost;
     /** 按钮点击率 */
     @Excel(name = "按钮点击率", width = 15)
     @ApiModelProperty(value = "按钮点击率")
     private java.math.BigDecimal eventButtonClickRatio;
+    private String submitRate;
     /** 订单支付率 */
     @Excel(name = "订单支付率", width = 15)
     @ApiModelProperty(value = "订单支付率")

+ 11 - 1
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/KuaishouOperationRecordMapper.java

@@ -48,7 +48,17 @@ public interface KuaishouOperationRecordMapper {
      * @param endTime
      * @return
      */
-    List<JSONObject> getKuaishouOperationRecordByAdvertiserId(@Param("advertiserId") long advertiserId,@Param("objectId") long objectId,@Param("operationType") int operationType,  @Param("startTime") String startTime, @Param("endTime") String endTime);
+    List<JSONObject> getKuaishouOperationRecordByAdvertiserId(@Param("advertiserId") long advertiserId,@Param("objectId") long objectId,@Param("operationType") int operationType,  @Param("operationTime") String operationTime);
+
+    /**
+     * 查看快手 组数据信息
+     * @param accountId
+     * @param unitId
+     * @param statDate
+     * @param statHour
+     * @return
+     */
+    JSONObject getKuaishouOperationUnitReport(@Param("accountId") long accountId,@Param("unitId") long unitId, @Param("statDate") String statDate, @Param("statHour") String statHour);
 
 
 }

+ 1 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/MaterialStareMapper.java

@@ -27,6 +27,7 @@ public interface MaterialStareMapper {
 
     // 头条 同公司所有下级运营人员 有消耗的
     Set<String> getBytedanceAllOperators(@Param("companyId")String companyId,@Param("startDate")Long start, @Param("endDate")Long endDate,@Param("userIds")Set<String> userIds);
+    Set<String> getAllOperatorsByLearderId(@Param("learderId")String learderId);
     //快手-在投项目数量
     String getKuaiShouOperatorProjectNum(@Param("startDate") Long start, @Param("endDate") Long endDate, @Param("userIds") Set<String> userIds);
     //头条-在投项目数量

+ 161 - 28
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/KuaishouOperationRecordMapper.xml

@@ -6,23 +6,74 @@
 <!-- 查询快手组 时报 消耗前10 -->
     <select id="getKuaishouUnitReportHourly" resultType="org.jeecg.ctop.material.entity.KuaishouUnitReportHourlyPojo">
         SELECT
-            *,
-            charge as cost,
-            `show` as photoShow,
-            CONCAT(ROUND(download_started / bclick * 100,2) ,'%') as downloadStartRate,
-            ROUND(download_started / bclick * 100,2) as downloadStartCost,
-            CONCAT(ROUND(download_completed / download_started * 100,2) ,'%') as downloadFinishRate,
-            ROUND(charge / download_completed * 100,2) as downloadFinishCost,
-            ROUND(charge / activation * 100,2) as activeCost,
-            CONCAT(ROUND(activation / download_completed * 100,2) ,'%') as activeRate,
-            ROUND(charge / event_pay_first_day * 100,2) as firstDayPayCost
+            unit_id,
+            unit_name,
+            sum( aclick ) AS aClick,
+            sum( bclick ) AS bClick,
+            sum( charge ) AS cost,
+            sum( `show` ) AS photoShow,
+            sum( photo_click ) AS photoClick ,
+            CONCAT( ROUND( sum( photo_click ) / sum( `show` ) * 100, 2 ), '%' ) AS clickRate,
+            CONCAT( ROUND( sum( bclick ) / sum( aclick ) * 100, 2 ), '%' ) AS bClickRate,
+            ROUND( sum( charge ) / sum( `show` ) * 1000, 2 ) AS cpm,
+            ROUND( sum( charge ) / sum( photo_click ) * 1000, 2 ) AS cpc,
+            ROUND( sum( charge ) / sum( bclick ) * 1000, 2 ) AS cpb,
+            sum( download_started ) AS downloadStart,
+            CONCAT( ROUND( sum( download_started ) / sum( bclick ) * 100, 2 ), '%' ) AS downloadStartRate,
+            ROUND( sum( charge ) / sum( download_started ) * 100, 2 ) AS downloadStartCost,
+
+            CONCAT(ROUND( sum( event_pay_first_day ) / sum( activation ) * 100, 2 ), '%' ) AS eventNewUserPayRatio,
+            sum( download_completed ) AS downloadFinish,
+            CONCAT( ROUND( sum( download_completed ) / sum( download_started ) * 100, 2 ), '%' ) AS downloadFinishRate,
+
+            ROUND( sum( charge ) / sum( download_completed ) * 100, 2 ) AS downloadFinishCost,
+            sum( activation ) AS active,
+            ROUND( sum( charge ) / sum( activation ) * 100, 2 ) AS activeCost,
+            CONCAT( ROUND( sum( activation ) / sum( download_completed ) * 100, 2 ), '%' ) AS activeRate,
+            sum( event_pay_first_day ) AS firstDayPay,
+            sum( event_pay_purchase_amount_first_day ) AS firstDayPayAmount,
+            ROUND( sum( charge ) / sum( event_pay_first_day ) * 100, 2 ) AS firstDayPayCost,
+            ROUND( sum( event_pay_purchase_amount_first_day ) / sum( charge ) * 100, 2 ) AS firstDayPayROI,
+            sum( event_pay ) AS eventPay,
+            sum( event_pay_purchase_amount ) AS eventPayPurchaseAmount,
+            ROUND( sum( charge ) / sum( event_pay ) * 100, 2 ) AS eventPayCost,
+            ROUND( sum( event_pay_purchase_amount ) / sum( charge ) * 100, 2 ) AS ROI,
+            sum( event_register ) AS register,
+            ROUND( sum( charge ) / sum( event_register ) * 100, 2 ) AS activeRegisterCost,
+            CONCAT( ROUND( sum( event_register ) / sum( activation ) * 100, 2 ), '%' ) AS activeRegisterRate,
+            sum( event_next_day_stay ) AS nextDayOpen,
+            ROUND( sum( charge ) / sum( event_next_day_stay ) * 100, 2 ) AS nextDayOpenCost,
+            CONCAT(ROUND( sum( charge ) / sum( form_count ) * 100, 2 ), '%' ) AS nextDayOpenRate,
+            sum( event_jin_jian_app ) AS eventJinJianApp,
+            ROUND( sum( charge ) / sum( event_jin_jian_app ) * 100, 2 ) AS eventJinJianAppCost,
+            sum( event_credit_grant_app ) AS eventCreditGrantApp,
+            ROUND( sum( charge ) / sum( event_credit_grant_app ) * 100, 2 ) AS eventCreditGrantAppCost,
+            CONCAT( ROUND( sum( event_credit_grant_app ) / sum( event_jin_jian_app ) * 100, 2 ), '%' ) AS eventCreditGrantAppRate,
+            ROUND( sum( charge ) / sum( aclick ) * 100, 2 )  AS play3sRate,
+            sum( key_action ) AS keyAction,
+            ROUND( sum( charge ) / sum( aclick ) * 100, 2 ) AS keyActionCost,
+            sum( event_app_invoked ) AS eventAppInvoked,
+            ROUND( sum( charge ) / sum( bclick ) * 100, 2 ) AS eventAppInvokedCost,
+            CONCAT( ROUND( sum( event_app_invoked ) / sum( bclick ) * 100, 2 ), '%' ) AS eventAppInvokedRatio,
+            sum( form_count ) AS formCount,
+            CONCAT( ROUND( sum( form_cost ) / sum( bclick ) * 100, 2 ), '%' ) AS formCountRate,
+            ROUND( sum( charge ) / sum( event_jin_jian_app ) * 100, 2 ) AS formCountCost,
+            sum( event_jin_jian_landing_page ) AS eventJinJianLandingPage,
+            ROUND( sum( charge ) / sum( event_jin_jian_landing_page ) * 100, 2 ) AS eventJinJianLandingPageCost,
+            sum( event_credit_grant_landing_page ) AS eventCreditGrantLandingPage,
+            ROUND( sum( charge ) / sum( event_credit_grant_landing_page_ratio ) * 100, 2 ) AS eventCreditGrantLandingPageCost,
+            CONCAT( ROUND( sum( event_credit_grant_landing_page ) / sum( event_jin_jian_landing_page ) * 100, 2 ), '%' ) AS eventCreditGrantLandingPageRate,
+            sum( event_button_click ) AS submit,
+            ROUND( sum( charge ) / sum( event_button_click ) * 100, 2 ) AS submitCost,
+            CONCAT( ROUND( sum( event_button_click ) / sum( bclick ) * 100, 2 ), '%' ) AS submitRate
         FROM
-            media_api.`kuaishou_unit_report_hourly`
+            application.kuaishou_unit_report_hourly_dw
         WHERE
          stat_date >= #{startTime}
         AND stat_date &lt;= #{endTime}
-        AND advertiser_id = #{advertiserId}
-        ORDER BY charge DESC
+        AND account_id = #{advertiserId}
+        GROUP BY unit_id
+        ORDER BY sum( charge ) DESC
         LIMIT 10
     </select>
 
@@ -31,27 +82,110 @@
     <!-- 查询快手组 日报 消耗前10  -->
     <select id="getKuaishouUnitReportDaily" resultType="org.jeecg.ctop.material.entity.KuaishouUnitReportHourlyPojo">
         SELECT
-            *,
-               charge as cost,
-            `show` as photoShow,
-            CONCAT(ROUND(download_started / bclick * 100,2) ,'%') as downloadStartRate,
-            ROUND(download_started / bclick * 100,2) as downloadStartCost,
-            CONCAT(ROUND(download_completed / download_started * 100,2) ,'%') as downloadFinishRate,
-            ROUND(charge / download_completed * 100,2) as downloadFinishCost,
-            ROUND(charge / activation * 100,2) as activeCost,
-            CONCAT(ROUND(activation / download_completed * 100,2) ,'%') as activeRate,
-            ROUND(charge / event_pay_first_day * 100,2) as firstDayPayCost
+            unit_id,
+            unit_name,
+            sum( aclick ) AS aClick,
+            sum( bclick ) AS bClick,
+            sum( charge ) AS cost,
+            sum( `show` ) AS photoShow,
+            sum( photo_click ) AS photoClick ,
+            CONCAT( ROUND( sum( photo_click ) / sum( `show` ) * 100, 2 ), '%' ) AS clickRate,
+            CONCAT( ROUND( sum( bclick ) / sum( aclick ) * 100, 2 ), '%' ) AS bClickRate,
+            ROUND( sum( charge ) / sum( `show` ) * 1000, 2 ) AS cpm,
+            ROUND( sum( charge ) / sum( photo_click ) * 1000, 2 ) AS cpc,
+            ROUND( sum( charge ) / sum( bclick ) * 1000, 2 ) AS cpb,
+            sum( download_started ) AS downloadStart,
+            CONCAT( ROUND( sum( download_started ) / sum( bclick ) * 100, 2 ), '%' ) AS downloadStartRate,
+            ROUND( sum( charge ) / sum( download_started ) * 100, 2 ) AS downloadStartCost,
+
+            CONCAT(ROUND( sum( event_pay_first_day ) / sum( activation ) * 100, 2 ), '%' ) AS eventNewUserPayRatio,
+            sum( download_completed ) AS downloadFinish,
+            CONCAT( ROUND( sum( download_completed ) / sum( download_started ) * 100, 2 ), '%' ) AS downloadFinishRate,
+
+            ROUND( sum( charge ) / sum( download_completed ) * 100, 2 ) AS downloadFinishCost,
+            sum( activation ) AS active,
+            ROUND( sum( charge ) / sum( activation ) * 100, 2 ) AS activeCost,
+            CONCAT( ROUND( sum( activation ) / sum( download_completed ) * 100, 2 ), '%' ) AS activeRate,
+            sum( event_pay_first_day ) AS firstDayPay,
+            sum( event_pay_purchase_amount_first_day ) AS firstDayPayAmount,
+            ROUND( sum( charge ) / sum( event_pay_first_day ) * 100, 2 ) AS firstDayPayCost,
+            ROUND( sum( event_pay_purchase_amount_first_day ) / sum( charge ) * 100, 2 ) AS firstDayPayROI,
+            sum( event_pay ) AS eventPay,
+            sum( event_pay_purchase_amount ) AS eventPayPurchaseAmount,
+            ROUND( sum( charge ) / sum( event_pay ) * 100, 2 ) AS eventPayCost,
+            ROUND( sum( event_pay_purchase_amount ) / sum( charge ) * 100, 2 ) AS ROI,
+            sum( event_register ) AS register,
+            ROUND( sum( charge ) / sum( event_register ) * 100, 2 ) AS activeRegisterCost,
+            CONCAT( ROUND( sum( event_register ) / sum( activation ) * 100, 2 ), '%' ) AS activeRegisterRate,
+            sum( event_next_day_stay ) AS nextDayOpen,
+            ROUND( sum( charge ) / sum( event_next_day_stay ) * 100, 2 ) AS nextDayOpenCost,
+            CONCAT(ROUND( sum( charge ) / sum( form_count ) * 100, 2 ), '%' ) AS nextDayOpenRate,
+            sum( event_jin_jian_app ) AS eventJinJianApp,
+            ROUND( sum( charge ) / sum( event_jin_jian_app ) * 100, 2 ) AS eventJinJianAppCost,
+            sum( event_credit_grant_app ) AS eventCreditGrantApp,
+            ROUND( sum( charge ) / sum( event_credit_grant_app ) * 100, 2 ) AS eventCreditGrantAppCost,
+            CONCAT( ROUND( sum( event_credit_grant_app ) / sum( event_jin_jian_app ) * 100, 2 ), '%' ) AS eventCreditGrantAppRate,
+            ROUND( sum( charge ) / sum( aclick ) * 100, 2 )  AS play3sRate,
+            sum( key_action ) AS keyAction,
+            ROUND( sum( charge ) / sum( aclick ) * 100, 2 ) AS keyActionCost,
+            sum( event_app_invoked ) AS eventAppInvoked,
+            ROUND( sum( charge ) / sum( bclick ) * 100, 2 ) AS eventAppInvokedCost,
+            CONCAT( ROUND( sum( event_app_invoked ) / sum( bclick ) * 100, 2 ), '%' ) AS eventAppInvokedRatio,
+            sum( form_count ) AS formCount,
+            CONCAT( ROUND( sum( form_cost ) / sum( bclick ) * 100, 2 ), '%' ) AS formCountRate,
+            ROUND( sum( charge ) / sum( event_jin_jian_app ) * 100, 2 ) AS formCountCost,
+            sum( event_jin_jian_landing_page ) AS eventJinJianLandingPage,
+            ROUND( sum( charge ) / sum( event_jin_jian_landing_page ) * 100, 2 ) AS eventJinJianLandingPageCost,
+            sum( event_credit_grant_landing_page ) AS eventCreditGrantLandingPage,
+            ROUND( sum( charge ) / sum( event_credit_grant_landing_page_ratio ) * 100, 2 ) AS eventCreditGrantLandingPageCost,
+            CONCAT( ROUND( sum( event_credit_grant_landing_page ) / sum( event_jin_jian_landing_page ) * 100, 2 ), '%' ) AS eventCreditGrantLandingPageRate,
+            sum( event_button_click ) AS submit,
+            ROUND( sum( charge ) / sum( event_button_click ) * 100, 2 ) AS submitCost,
+            CONCAT( ROUND( sum( event_button_click ) / sum( bclick ) * 100, 2 ), '%' ) AS submitRate
         FROM
-            media_api.`kuaishou_unit_report_daily`
+            application.kuaishou_unit_report_daily_dw
         WHERE
             stat_date &gt;= #{startTime}
           AND stat_date &lt;= #{endTime}
-          AND advertiser_id = #{advertiserId}
-        ORDER BY charge DESC
+          AND account_id = #{advertiserId}
+        GROUP BY unit_id
+        ORDER BY sum( charge ) DESC
             LIMIT 10
     </select>
 
 
+    <!-- 查看快手 组数据信息  -->
+    <select id="getKuaishouOperationUnitReport" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        unit_id AS unitId,
+        stat_date AS statDate,
+        HOUR AS statHour,
+        charge,
+        activation,
+        ROUND( charge / activation * 100, 2 ) AS activeCost,
+        event_register AS eventRegister,
+        event_register_cost AS eventRegisterCost,
+        event_next_day_stay AS eventNextDayStay,
+        event_next_day_stay_cost AS eventNextDayStay,
+        event_pay_first_day AS eventPayIfrstDay,
+        ROUND( charge / event_pay_first_day * 100, 2 ) AS eventPayIfrstDayCost,
+        form_count AS formCount
+        FROM
+        application.kuaishou_unit_report_hourly_dw
+        WHERE
+        stat_date= #{statDate}
+        AND hour = #{statHour}
+        AND account_id = #{accountId}
+        AND unit_id = #{unitId}
+        ORDER BY
+        stat_date,HOUR
+
+
+    </select>
+
+
+
+
     <!-- 查看账户操作记录 -->
     <select id="getKuaishouOperationRecordByAdvertiserId" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
@@ -70,8 +204,7 @@
             advertiser_id = #{advertiserId}
             AND operation_type = #{operationType}
             AND object_id = #{objectId}
-            AND operation_time &gt;= #{startTime}
-            AND operation_time &lt;= #{endTime}
+          AND date_format(operation_time, '%Y%m%d%H') = #{operationTime}
 
 
     </select>

+ 14 - 22
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/MaterialStareMapper.xml

@@ -465,10 +465,8 @@
         (SELECT u.realname from `jeecg-boot`.sys_user u where u.id = d.user_id) as userName
         FROM
         application.kuaishou_account_report_daily_dw d
-        LEFT JOIN `jeecg-boot`.ctop_user_allocation u on d.account_id = u.account_id
         WHERE
         d.charge > 0
-        and u.account_status = 0
         <if test="startDate != null and startDate != '' ">
             and d.stat_date &gt;= #{startDate}
         </if>
@@ -503,10 +501,8 @@
         (SELECT u.realname from `jeecg-boot`.sys_user u where u.id = d.user_id) as userName
         FROM
         application.kuaishou_account_report_daily_dw d
-        LEFT JOIN `jeecg-boot`.ctop_user_allocation u on d.account_id = u.account_id
         WHERE
         d.charge > 0
-        and u.account_status = 0
         <if test="startDate != null and startDate != '' ">
             and d.stat_date &gt;= #{startDate}
         </if>
@@ -530,10 +526,8 @@
         (SELECT u.realname from `jeecg-boot`.sys_user u where u.id = d.user_id) as userName
         FROM
         application.bytedance_advertiser_report_hourly_dw d
-        LEFT JOIN `jeecg-boot`.ctop_user_allocation u on d.account_id = u.account_id
         WHERE
         d.cost > 0
-        and u.account_status = 0
         <if test="startDate != null and startDate != '' ">
             and d.stat_datetime &gt;= #{startDate}
         </if>
@@ -563,10 +557,8 @@
         (SELECT u.realname from `jeecg-boot`.sys_user u where u.id = d.user_id) as userName
         FROM
         application.bytedance_advertiser_report_daily_dw d
-        LEFT JOIN `jeecg-boot`.ctop_user_allocation u on d.account_id = u.account_id
         WHERE
         d.cost > 0
-        and u.account_status = 0
         <if test="startDate != null and startDate != '' ">
             and d.stat_datetime &gt;= #{startDate}
         </if>
@@ -595,10 +587,8 @@
         (SELECT u.realname from `jeecg-boot`.sys_user u where u.id = d.user_id) as userName
         FROM
         application.kuaishou_account_report_hourly_dw d
-        LEFT JOIN `jeecg-boot`.ctop_user_allocation u on d.account_id = u.account_id
         WHERE
         d.charge > 0
-        and u.account_status = 0
         <if test="startDate != null and startDate != '' ">
             and d.stat_date &gt;= #{startDate}
         </if>
@@ -625,10 +615,8 @@
         (SELECT u.realname from `jeecg-boot`.sys_user u where u.id = d.user_id) as userName
         FROM
         application.bytedance_advertiser_report_hourly_dw d
-        LEFT JOIN `jeecg-boot`.ctop_user_allocation u on d.account_id = u.account_id
         WHERE
         d.cost > 0
-        and u.account_status = 0
         <if test="startDate != null and startDate != '' ">
             and d.stat_datetime &gt;= #{startDate}
         </if>
@@ -677,10 +665,8 @@
         IFNULL(ROUND( SUM( d.charge ) / SUM( d.form_count ), 2 ),0) AS formCountPrice
         FROM
         application.kuaishou_account_report_daily_dw d
-        LEFT JOIN `jeecg-boot`.ctop_user_allocation u on d.account_id = u.account_id
         WHERE
         d.charge > 0
-        and u.account_status = 0
         <if test="startDate != null and startDate != '' ">
             and d.stat_date &gt;= #{startDate}
         </if>
@@ -712,10 +698,8 @@
         ( SELECT realname FROM `jeecg-boot`.sys_user u WHERE u.id = d.user_id ) AS userName
         FROM
         application.bytedance_advertiser_report_hourly_dw d
-        LEFT JOIN `jeecg-boot`.ctop_user_allocation u on d.account_id = u.account_id
         WHERE
         d.cost > 0
-        and u.account_status = 0
         <if test="startDate != null and startDate != '' ">
             and d.stat_datetime &gt;= #{startDate}
         </if>
@@ -742,10 +726,8 @@
         SUM( d.charge ) AS totalCost
         FROM
         application.kuaishou_account_report_hourly_dw d
-        LEFT JOIN `jeecg-boot`.ctop_user_allocation u ON d.account_id = u.account_id
         WHERE
         d.charge > 0
-        AND u.account_status = 0
         <if test="startDate != null and startDate != '' ">
             and d.stat_date &gt;= #{startDate}
         </if>
@@ -777,10 +759,8 @@
         SUM( d.cost ) AS totalCost
         FROM
         application.bytedance_advertiser_report_hourly_dw d
-        LEFT JOIN `jeecg-boot`.ctop_user_allocation u ON d.account_id = u.account_id
         WHERE
         d.cost > 0
-        AND u.account_status = 0
         <if test="startDate != null and startDate != '' ">
             and d.stat_datetime &gt;= #{startDate}
         </if>
@@ -846,10 +826,8 @@
         IFNULL(SUM(d.photo_click),0) as photoClick
         FROM
         application.kuaishou_account_report_daily_dw d
-        LEFT JOIN `jeecg-boot`.ctop_user_allocation u on d.account_id = u.account_id
         WHERE
         d.charge > 0
-        and u.account_status = 0
         <if test="startDate != null and startDate != '' ">
             and d.stat_date &gt;= #{startDate}
         </if>
@@ -1876,4 +1854,18 @@
           AND t4.media_id = #{mediaId}
     </select>
 
+
+    <!-- 所有下级运营人员 -->
+    <select id="getAllOperatorsByLearderId" resultType="java.lang.String">
+        SELECT
+            user_id
+        FROM
+            application.`app_user_manage`
+        WHERE
+            manage_id = #{learderId}
+          AND type = 1
+    </select>
+
+
+
 </mapper>

+ 1 - 1
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/KuaishouOperationRecordService.java

@@ -21,7 +21,7 @@ public interface KuaishouOperationRecordService {
     Result getKuaishouUnitChargeTopTenByAccountId(String userId,long advertiserId,String startTime,String endTime) throws NoSuchFieldException;
 
 
-    Result getKuaishouOperationRecordByUnit(long advertiserId,long unitId,String startTime,String endTime);
+    Result getKuaishouOperationRecordByUnit(long advertiserId,long unitId,String startTime,String endTime)throws Exception;
 
 
 }

+ 31 - 4
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/KuaishouOperationRecordServiceImpl.java

@@ -129,11 +129,38 @@ public class KuaishouOperationRecordServiceImpl implements KuaishouOperationReco
      * @author: zianY
      */
     @Override
-    public Result getKuaishouOperationRecordByUnit(long advertiserId,long unitId,String startTime,String endTime){
-
-        List<JSONObject> list =  kuaishouOperationRecordMapper.getKuaishouOperationRecordByAdvertiserId(advertiserId,unitId,2,startTime+" 00:00:00",endTime+" 23:59:59");
+    public Result getKuaishouOperationRecordByUnit(long advertiserId,long unitId,String startTime,String endTime) throws Exception{
+        List<JSONObject> resultList = new ArrayList<>();
+        // 获取两个日期之间 所有的 时间 年-月-日
+        List<String> betweenDaysList = DateUtils.getAllDatesOfTwoTimes(startTime,endTime);
+        // 所有时间集
+        List<String> allHoursList = DateUtils.getHoursListDifference(betweenDaysList);
+        for (String time : allHoursList) {
+            JSONObject jsonObject = new JSONObject();
+            //2022090101 -年月日 时
+            String date = time.substring(0,time.length()-2);
+            String hour = time.substring(time.length()-2);
+            //查询时报数据
+            JSONObject unit =  kuaishouOperationRecordMapper.getKuaishouOperationUnitReport(advertiserId,unitId,date,hour);
+            if (Check.isNull(unit)){
+                jsonObject.put("charge",0);
+                jsonObject.put("statDate",date);
+                jsonObject.put("statHour",hour);
+                jsonObject.put("time",time);
+                resultList.add(jsonObject);
+                continue;
+            }
 
-        return Result.successMsg("查询成功",list);
+            long uId = Long.valueOf(unit.getString("unitId"));
+            //查询操作记录
+            List<JSONObject> list =  kuaishouOperationRecordMapper.getKuaishouOperationRecordByAdvertiserId(advertiserId,uId,2,time);
+            if (!Check.isNull(list)){ list.forEach(json -> {json.put("content_log",json.getJSONArray("content_log"));});}
+            jsonObject = unit;
+            jsonObject.put("time",time);
+            jsonObject.put("operationList",list);
+            resultList.add(jsonObject);
+        }
+        return Result.successMsg("查询成功",resultList);
     }
 
 

+ 14 - 5
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/MaterialStareServiceImpl.java

@@ -1515,7 +1515,11 @@ public class MaterialStareServiceImpl implements MaterialStareService {
            List<KuaiShouOperateGroupVo> operationList = ListPageUtil.page(operationManagerList, pageSize, pageNum);
             for (KuaiShouOperateGroupVo groupVo : operationList) {
                 //下级员工
-                Set<String> operatorUserIds = getAffiliateId(groupVo.getUserId());
+                //Set<String> operatorUserIds = getAffiliateId(groupVo.getUserId());
+                //运营经理下的下级员工
+                Set<String> operatorUserIds = materialStareMapper.getAllOperatorsByLearderId(groupVo.getUserId());
+
+
                 //有消耗的账户
                 if (mediaType.equals("1")){
                     operatorUserIds = materialStareMapper.getBytedanceAllOperators(null,DateUtils.getDateInteger(startTime).longValue(),DateUtils.getDateInteger(endTime).longValue(),operatorUserIds);
@@ -1530,7 +1534,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                 }
 
                 //运营数量
-                int operationNum = Check.isNull(operatorUserIds) ? 0 : operatorUserIds.size();
+                int operationNum = Check.isNull(getAffiliateId(groupVo.getUserId())) ? 0 : getAffiliateId(groupVo.getUserId()).size();
                 groupVo.setOperationNum(operationNum);
 
                 //查询账户数据
@@ -1672,7 +1676,12 @@ public class MaterialStareServiceImpl implements MaterialStareService {
 
             for (KuaiShouOperateGroupVo groupVo : operationManagerList) {
                 //下级员工
-                Set<String> operatorUserIds = getAffiliateId(groupVo.getUserId());
+                //Set<String> operatorUserIds = getAffiliateId(groupVo.getUserId());
+
+                //运营经理下的下级员工
+                Set<String> operatorUserIds = materialStareMapper.getAllOperatorsByLearderId(groupVo.getUserId());
+
+
                 //有消耗的账户
                 if (mediaType.equals("1")){
                     operatorUserIds = materialStareMapper.getBytedanceAllOperators(null,DateUtils.getDateInteger(startTime).longValue(),DateUtils.getDateInteger(endTime).longValue(),operatorUserIds);
@@ -1686,7 +1695,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                 }
 
                 //运营数量
-                int operationNum = Check.isNull(operatorUserIds) ? 0 : operatorUserIds.size();
+                int operationNum = Check.isNull(getAffiliateId(groupVo.getUserId())) ? 0 : getAffiliateId(groupVo.getUserId()).size();
                 groupVo.setOperationNum(operationNum);
 
                 //查询账户数据
@@ -1701,7 +1710,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                         listOperate = materialStareMapper.getBytedanceOperateInfo(startDate,entDate,operatorUserIds);
                     }
                 }else {
-                    listOperate= materialStareMapper.getBytedanceOperateInfoHourly(startDate,entDate,operatorUserIds);
+                    listOperate= materialStareMapper.getKuaiShouOperateInfo(startDate,entDate,operatorUserIds);
                 }
 
                 //总花费

+ 8 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/utils/FeidNotNullUtils.java

@@ -100,6 +100,14 @@ public class FeidNotNullUtils {
         for (int j = 0; j < dateList.size(); j++) {
             Object obj = dateList.get(j);
             Map unitMap = Check.parseObj2Map(obj);
+            /**
+             * 之所以加了这三行代码 是因为 obj 中的 这三个参数 转成unitMap 后 key变成了 AClick/BClick/ROI 所以导致在根据自定义列中的fieldName获取值的时候 获取不到
+             * 别问为啥不修改下字段的命名规则 或者 前端同事修改下自定义列的字段 因为 我的同事是个老厨师了
+             */
+            unitMap.put("aClick",unitMap.get("AClick"));
+            unitMap.put("bClick",unitMap.get("BClick"));
+            unitMap.put("roi",unitMap.get("ROI"));
+
             Map<String,Object> map = new HashMap<>();
             for (int k =0;k < array.size();k++) {
                 JSONObject json = (JSONObject)array.get(k);