Selaa lähdekoodia

盯盘运营经理-运营组区分媒体

yangzian 3 vuotta sitten
vanhempi
commit
e69c70a8a2

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

@@ -64,8 +64,10 @@ public interface MaterialStareMapper {
 
     //快手-查询账户数据信息
     List<KuaiShouOperateVo> getKuaiShouOperateInfo(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("list") Set<String> operatorUserIds);
+    List<KuaiShouOperateVo> getBytedanceOperateInfo(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("list") Set<String> operatorUserIds);
 
     List<KuaiShouOperateVo> getKuaiShouOperateInfoHourly(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("list") Set<String> operatorUserIds);
+    List<KuaiShouOperateVo> getBytedanceOperateInfoHourly(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("list") Set<String> operatorUserIds);
 
     //查看 快手 有效 计划 组
     JSONObject getKuaiShouAccountBaseByUserId(@Param("list") Set<String> operatorUserIds, @Param("projectId") String projectId, @Param("accountId") String accountId, @Param("startDate") Long startDate, @Param("endDate") Long endDate);

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

@@ -487,6 +487,38 @@
     </select>
 
     <!-- 快手 快手-查询账户数据信息 -->
+    <select id="getBytedanceOperateInfo" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateVo">
+        SELECT
+        SUM( d.cost ) totalCost,
+        COUNT(DISTINCT d.account_id) accountNum,
+        COUNT(DISTINCT d.project_id) projectNum,
+        d.user_id as userId,
+        (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>
+        <if test="endDate != null and endDate != '' ">
+            and d.stat_datetime &lt;= #{endDate}
+        </if>
+        <if test='list!=null'>
+            AND d.user_id IN
+            <foreach collection="list" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY d.user_id
+        ORDER BY SUM( d.cost ) DESC
+    </select>
+
+
+    <!-- 快手 快手-查询账户数据信息 -->
     <select id="getKuaiShouOperateInfoHourly" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateVo">
         SELECT
         SUM( d.charge ) totalCost,
@@ -516,6 +548,36 @@
         GROUP BY d.user_id
         ORDER BY SUM( d.charge ) DESC
     </select>
+    <!-- 头条 -查询账户数据信息 -->
+    <select id="getBytedanceOperateInfoHourly" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateVo">
+        SELECT
+        SUM( d.cost ) totalCost,
+        COUNT(DISTINCT d.account_id) accountNum,
+        COUNT(DISTINCT d.project_id) projectNum,
+        d.user_id as userId,
+        (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>
+        <if test="endDate != null and endDate != '' ">
+            and d.stat_datetime &lt;= #{endDate}
+        </if>
+        <if test='list!=null'>
+            AND d.user_id IN
+            <foreach collection="list" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY d.user_id
+        ORDER BY SUM( d.cost ) DESC
+    </select>
 
     <!-- 快手 -查询项目数据信息 日报-->
     <select id="getKuaiShouOperateProjectInfo" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateProjectVo">

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

@@ -1313,7 +1313,14 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                 //下级员工
                 Set<String> operatorUserIds = getAffiliateId(groupVo.getUserId());
                 //有消耗的账户
-                operatorUserIds = materialStareMapper.getKuaiShouAllOperators(null,DateUtils.getDateInteger(startTime).longValue(),DateUtils.getDateInteger(endTime).longValue(),operatorUserIds);
+
+                if (mediaType.equals("1")){
+                    operatorUserIds = materialStareMapper.getBytedanceAllOperators(null,DateUtils.getDateInteger(startTime).longValue(),DateUtils.getDateInteger(endTime).longValue(),operatorUserIds);
+
+                }else {
+                    operatorUserIds = materialStareMapper.getKuaiShouAllOperators(null,DateUtils.getDateInteger(startTime).longValue(),DateUtils.getDateInteger(endTime).longValue(),operatorUserIds);
+                }
+
 
                 if (Check.isNull(operatorUserIds) || operatorUserIds.size() < 1){
                     continue;
@@ -1326,15 +1333,26 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                 //查询账户数据
                 List<KuaiShouOperateVo> listOperate= new ArrayList<>();
 
-                if (daysBetween <= 1){
+                if (mediaType.equals("1")){
+                    if (daysBetween <= 1){
+                        //时报
+                        listOperate= materialStareMapper.getBytedanceOperateInfoHourly(startDate,entDate,operatorUserIds);
+                    }else {
 
-                    //时报
-                    listOperate= materialStareMapper.getKuaiShouOperateInfoHourly(startDate,entDate,operatorUserIds);
+                        listOperate = materialStareMapper.getBytedanceOperateInfo(startDate,entDate,operatorUserIds);
+                    }
                 }else {
+                    if (daysBetween <= 1){
+                        //时报
+                        listOperate= materialStareMapper.getKuaiShouOperateInfoHourly(startDate,entDate,operatorUserIds);
+                    }else {
 
-                    listOperate = materialStareMapper.getKuaiShouOperateInfo(startDate,entDate,operatorUserIds);
+                        listOperate = materialStareMapper.getKuaiShouOperateInfo(startDate,entDate,operatorUserIds);
+                    }
                 }
 
+
+
                 //总花费
                 Double totalCost = Check.isNull(listOperate) ? 0 : listOperate.stream().mapToDouble(KuaiShouOperateVo::getTotalCost).sum();
                 groupVo.setTotalCost(new BigDecimal(totalCost).setScale(3,BigDecimal.ROUND_HALF_UP).doubleValue());
@@ -1355,8 +1373,14 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                 //平均账户消耗 总花费/账户数量
                 Double aveAccount = accountNum.intValue() == 0 ? 0 : totalCost/accountNum;
                 groupVo.setAverageAccountCost(new BigDecimal(aveAccount).setScale(3,BigDecimal.ROUND_HALF_UP).doubleValue());
+
                 //环比 = (当前 - 上阶段 ) / 上阶段
-                List<KuaiShouOperateVo> yearOnYearInfo = materialStareMapper.getKuaiShouOperateInfo(lastTimeStart,lastTimeEnd,operatorUserIds);
+                List<KuaiShouOperateVo> yearOnYearInfo = new ArrayList<>();
+                if (mediaType.equals("1")){
+                    yearOnYearInfo = materialStareMapper.getBytedanceOperateInfo(lastTimeStart,lastTimeEnd,operatorUserIds);
+                }else {
+                    yearOnYearInfo = materialStareMapper.getKuaiShouOperateInfo(lastTimeStart,lastTimeEnd,operatorUserIds);
+                }
                 String yearOnYear = "0";
                 if (!Check.isNull(yearOnYearInfo)){
                     Double lastTotalCost = Check.isNull(yearOnYearInfo) ? 0 : yearOnYearInfo.stream().mapToDouble(KuaiShouOperateVo::getTotalCost).sum();
@@ -1369,15 +1393,26 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                 //当天
                 int newUnitNumNow = 0;
                 if (startDate == nowDate || entDate == nowDate){
-                    //查询 当天有效 上新计划 上新组
-                    JSONObject newEffect = materialStareMapper.getKuaiShouAccountNowBaseByUserId(operatorUserIds,null,null,nowDate,nowDate);
+                    JSONObject newEffect = new JSONObject();
+                    if (mediaType.equals("1")){
+                        //查询 当天有效 上新计划 上新组
+                        newEffect = materialStareMapper.getBytedanceAccountBaseByUserId(operatorUserIds,null,null,nowDate,nowDate);
+                    }else {
+                        //查询 当天有效 上新计划 上新组
+                        newEffect = materialStareMapper.getKuaiShouAccountNowBaseByUserId(operatorUserIds,null,null,nowDate,nowDate);
+                    }
                     newUnitNumNow = Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum");//组
                 }
 
-                //查询 历史上新组
-                JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(operatorUserIds,null,null,startDate,entDate);
+                if (mediaType.equals("1")){
+                }else {
+                    //查询 历史上新组
+                    JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(operatorUserIds,null,null,startDate,entDate);
+                    newUnitNumNow = Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum")+newUnitNumNow;
+                }
+
                 //基建数量
-                groupVo.setUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum")+newUnitNumNow);//组
+                groupVo.setUnitNum(newUnitNumNow);//组
             }
             PageInfo<KuaiShouOperateGroupVo> pageInfo = new PageInfo<>(operationList);
             pageInfo.setTotal(operationManagerList.size());