浏览代码

Merge remote-tracking branch 'origin/master'

yumeng 2 年之前
父节点
当前提交
100f85ccd5

+ 8 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/controller/KuaishouPromoterController.java

@@ -203,5 +203,12 @@ public class KuaishouPromoterController extends BaseController {
         return result;
     }
 
-
+    /**
+     * 获取达人公海视频销售
+     */
+    @GetMapping("/getGongHaiVideoSales")
+    @ApiOperation(value = "获取达人公海视频销售")
+    public Result getGongHaiVideoSales(@ApiParam("达人ID") @RequestParam(value = "promoterId", required = false) Long promoterId) {
+        return kuaishouPromoterService.getGongHaiVideoSales(promoterId);
+    }
 }

+ 2 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/entity/KuaishouPromoter.java

@@ -156,7 +156,7 @@ public class KuaishouPromoter {
     public KuaishouPromoter() {
     }
 
-    public KuaishouPromoter(Long id, String promoterNickName, String province, String promoterUrl, String fansNumber, String avgVideoSales, String videoSales, String totalSale) {
+    public KuaishouPromoter(Long id, String promoterNickName, String province, String promoterUrl, String fansNumber, String avgVideoSales, String videoSales, String totalSale,Long promoterId) {
         this.id = id;
         this.promoterNickName = promoterNickName;
         this.province = province;
@@ -165,5 +165,6 @@ public class KuaishouPromoter {
         this.avgVideoSales = avgVideoSales;
         this.videoSales = videoSales;
         this.totalSale = totalSale;
+        this.promoterId = promoterId;
     }
 }

+ 2 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/IKuaishouPromoterService.java

@@ -71,4 +71,6 @@ public interface IKuaishouPromoterService {
     Result updatePromoterLabel(JSONObject result);
 
     void updateFollowUpRecords(JSONObject result);
+
+    Result getGongHaiVideoSales(Long promoterId);
 }

+ 23 - 4
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouPromoterServiceImpl.java

@@ -123,6 +123,10 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
     public List<JSONObject> selectKuaishouPromoterList2(Long promoterId, String promoterNickName, String status, String parameter, String orderBy) {
         if (Check.isNull(parameter)) {
             parameter = "promoterId";
+        } else if ("avgVideoSales".equals(parameter)) {
+            parameter = "SUBSTRING_INDEX(avgVideoSales,'-',-1)+0";
+        } else if ("videoSales".equals(parameter)) {
+            parameter = "SUBSTRING_INDEX(videoSales,'-',-1)+0";
         }
         if (Check.isNull(orderBy)) {
             orderBy = "desc";
@@ -160,7 +164,6 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
                 Long startTime = System.currentTimeMillis();
                 String content = HttpUtil.httpGetRequest(internalIpPath + "kuaiShou/promoter/getPromoterInfo?promoterId=" + promoter.getPromoterId());
                 result = JSONObject.parseObject(content);
-                log.info("获取达人详情数据,用时:{}s", (System.currentTimeMillis() - startTime) / 1000);
                 data.put("promoterInfo", promoter);
                 data.put("result", result);
                 //跟进记录
@@ -245,7 +248,6 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
             Long startTime = System.currentTimeMillis();
             String content = HttpUtil.httpPostRequest(startIpPath + "promoterInfo/getPromoterId", param, null);
             JSONObject result = JSONObject.parseObject(content);
-            log.info("更新达人信息,用时:{}s,返回结果:{}", (System.currentTimeMillis() - startTime) / 1000, result);
             if (Check.isNotNull(result) && Check.isNotNull(result.getString("promoterNickName"))) {
                 KuaishouPromoter kuaishouPromoter = new KuaishouPromoter(
                         id,
@@ -255,9 +257,12 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
                         result.getString("fanNum"),
                         result.getString("avgVideoSales"),
                         result.getString("videoSales"),
-                        result.getString("totalSale")
+                        result.getString("totalSale"),
+                        promoterId
                 );
-                kuaishouPromoterMapper.updateKuaishouPromoter(kuaishouPromoter);
+                kuaishouPromoterMapper.updateKuaishouPromoterByPromoterId(kuaishouPromoter);
+            } else {
+                log.error("更新达人失败,达人ID:{}         【返回结果】:{}", promoterId, result);
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -293,6 +298,20 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
     }
 
     @Override
+    public Result getGongHaiVideoSales(Long promoterId) {
+        Map<String, Object> param = new HashMap<>();
+        param.put("promoterId", promoterId);
+        String url = startIpPath + "promoterInfo/updatePromoter";
+        String content = HttpUtil.httpPostRequest(url, param, null);
+        if ("0".equals(content)) {
+            return Result.success();
+        } else {
+            log.error("查询达人公海销售额失败,达人ID:{}\nurl:{}", promoterId, url);
+            return Result.error("失败");
+        }
+    }
+
+    @Override
     public Result updatePromoterLabel(JSONObject result) {
         Long promoterId = result.getLong("promoterId");
         Long userId = result.getLong("userId");

+ 2 - 0
ruixuan-live/src/main/java/com/ruixuan/jinniu/mapper/KuaishouAccountMapper.java

@@ -72,4 +72,6 @@ public interface KuaishouAccountMapper {
     void insertRecord(JSONObject o);
 
     List<JSONObject> getAccountNameByProjectId(@Param("projectId") Long projectId);
+
+    int deleteKuaishouAccountByProjectId(@Param("projectId") Long projectId);
 }

+ 3 - 0
ruixuan-live/src/main/java/com/ruixuan/jinniu/service/IKuaishouAccountService.java

@@ -34,6 +34,7 @@ public interface IKuaishouAccountService {
     public List<KuaishouAccount> selectKuaishouAccountList(KuaishouAccount kuaishouAccount);
 
     List<KuaishouAccount> getAccountByProjectId(Long projectId);
+
     /**
      * 新增账户
      *
@@ -63,4 +64,6 @@ public interface IKuaishouAccountService {
     Result<Object> edit(KuaishouAccount kuaishouAccount);
 
     List<JSONObject> getAccountNameByProjectId(Long projectId);
+
+    int deleteKuaishouAccountByProjectId(Long id);
 }

+ 5 - 0
ruixuan-live/src/main/java/com/ruixuan/jinniu/service/impl/KuaishouAccountServiceImpl.java

@@ -176,6 +176,11 @@ public class KuaishouAccountServiceImpl implements IKuaishouAccountService {
         return kuaishouAccountMapper.getAccountNameByProjectId(projectId);
     }
 
+    @Override
+    public int deleteKuaishouAccountByProjectId(Long id) {
+        return kuaishouAccountMapper.deleteKuaishouAccountByProjectId(id);
+    }
+
     private void insertAccountRecord(KuaishouAccount account, Long userId, int type) {
         JSONObject o = new JSONObject();
         o.put("accountId", account.getAccountId());

+ 3 - 0
ruixuan-live/src/main/java/com/ruixuan/jinniu/service/impl/KuaishouProjectMemberServiceImpl.java

@@ -99,6 +99,9 @@ public class KuaishouProjectMemberServiceImpl implements IKuaishouProjectMemberS
     public Result<Object> addProjectUsers(JSONObject o) {
         Long projectId = o.getLong("projectId");
         JSONArray userIds = o.getJSONArray("userIds");
+        if (Check.isNull(projectId) || Check.isNull(userIds)) {
+            return Result.error("缺少参数!");
+        }
         String projectName = o.getString("projectName");
         if (Check.isNull(projectName)) {
             KuaishouProject project = projectMapper.selectKuaishouProjectById(projectId);

+ 12 - 5
ruixuan-live/src/main/java/com/ruixuan/jinniu/service/impl/KuaishouProjectServiceImpl.java

@@ -61,7 +61,7 @@ public class KuaishouProjectServiceImpl implements IKuaishouProjectService {
         Long userId = kuaishouProject.getUserId();
         String roleKey = sysUserService.getRoleKeyByUserId(userId);
         List<Long> userList;
-        if ("admin".equals(roleKey)) {
+        if ("admin".equals(roleKey) || "directorOperations".equals(roleKey)) {
             //查看所有
             userList = null;
         } else if ("electricPin".equals(roleKey) || "facePin".equals(roleKey)) {
@@ -75,7 +75,7 @@ public class KuaishouProjectServiceImpl implements IKuaishouProjectService {
         } else if ("operations".equals(roleKey) || "operator".equals(roleKey)) {
             //运营 运营专员
             kuaishouProject.setOperatorIdList(Arrays.asList(userId));
-        } else if ("operationsManager".equals(roleKey) || "directorOperations".equals(roleKey)) {
+        } else if ("operationsManager".equals(roleKey)) {
             //运营经理、运营总监
             Long deptId = deptService.getDeptIdByUserId(userId);
             userList = deptService.getDeptUserListByDeptId(deptId);
@@ -109,8 +109,12 @@ public class KuaishouProjectServiceImpl implements IKuaishouProjectService {
         mem.put("projectId", kuaishouProject.getId());
         mem.put("projectName", kuaishouProject.getProjectName());
         Set<Long> ses = new HashSet<>();
-        ses.add(kuaishouProject.getSaleId());
-        ses.add(kuaishouProject.getOperatorId());
+        if (Check.isNotNull(kuaishouProject.getSaleId())) {
+            ses.add(kuaishouProject.getSaleId());
+        }
+        if (Check.isNotNull(kuaishouProject.getOperatorId())) {
+            ses.add(kuaishouProject.getOperatorId());
+        }
         if (Check.isNotNull(kuaishouProject.getDesignResponsibleId())) {
             ses.add(kuaishouProject.getDesignResponsibleId());
         }
@@ -151,7 +155,9 @@ public class KuaishouProjectServiceImpl implements IKuaishouProjectService {
      */
     @Override
     public int deleteKuaishouProjectById(Long id) {
-        return projectMapper.deleteKuaishouProjectById(id);
+        projectMapper.deleteKuaishouProjectById(id);
+        return kuaishouAccountService.deleteKuaishouAccountByProjectId(id);
+
     }
 
     @Override
@@ -172,6 +178,7 @@ public class KuaishouProjectServiceImpl implements IKuaishouProjectService {
         } else {
             kuaishouProject.setOperatorIdList(Arrays.asList(kuaishouProject.getUserId()));
         }
+        PageUtils.startPage();
         return projectMapper.getMyProjects(kuaishouProject);
     }
 

+ 30 - 5
ruixuan-live/src/main/java/com/ruixuan/report/service/impl/KuaishouLiveAccountReportServiceImpl.java

@@ -99,10 +99,10 @@ public class KuaishouLiveAccountReportServiceImpl implements IKuaishouLiveAccoun
 
         String type = map.get("type").toString();
         if ("hourly".equals(type)) {
-            PageUtils.startPage();
+//            PageUtils.startPage();
             return mapper.getProjectCostListByHourly(map);
         } else {
-            PageUtils.startPage();
+//            PageUtils.startPage();
             return mapper.getProjectCostListByDaily(map);
         }
     }
@@ -166,7 +166,7 @@ public class KuaishouLiveAccountReportServiceImpl implements IKuaishouLiveAccoun
         if (Check.isNotNull(yesCostTotal) && new BigDecimal(yesCostTotal).compareTo(new BigDecimal("0")) > 0) {
             DecimalFormat decimalFormat = new DecimalFormat("0.00%");
             Double yearOnYearD = (costTotal - yesCostTotal) / yesCostTotal;
-            all.put("roi", new BigDecimal(yearOnYearD).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue());
+            all.put("roi", new BigDecimal(yearOnYearD).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
         } else {
             all.put("roi", "0.0");
         }
@@ -328,11 +328,36 @@ public class KuaishouLiveAccountReportServiceImpl implements IKuaishouLiveAccoun
         String type = map.get("type").toString();
         String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.getKuaishouAccountReport());
         map.put("filedAll", filedAll);
+        List<JSONObject> list = null;
         if ("hourly".equals(type)) {
-            return mapper.getAccountDataReportByHourly(map);
+            list = mapper.getAccountDataReportByHourly(map);
         } else {
-            return mapper.getAccountDataReportByDaily(map);
+            list = mapper.getAccountDataReportByDaily(map);
         }
+        BigDecimal ten = new BigDecimal("10");
+        // 花费、成本、GMV以及相关字段 除以 10
+        list.forEach(data -> {
+            data.put("costTotal", data.getBigDecimal("costTotal").divide(ten));
+            data.put("adShow1kCost", data.getBigDecimal("adShow1kCost").divide(ten));
+            data.put("actionbarClickCost", data.getBigDecimal("actionbarClickCost").divide(ten));
+            data.put("conversionCostEsp", data.getBigDecimal("conversionCostEsp").divide(ten));
+            data.put("gmv", data.getBigDecimal("gmv").divide(ten));
+            data.put("t0Gmv", data.getBigDecimal("t0Gmv").divide(ten));
+            data.put("t1Gmv", data.getBigDecimal("t1Gmv").divide(ten));
+            data.put("t7Gmv", data.getBigDecimal("t7Gmv").divide(ten));
+            data.put("t15Gmv", data.getBigDecimal("t15Gmv").divide(ten));
+            data.put("t30Gmv", data.getBigDecimal("t30Gmv").divide(ten));
+            data.put("t0OrderCntCost", data.getBigDecimal("t0OrderCntCost").divide(ten));
+            data.put("reservationCost", data.getBigDecimal("reservationCost").divide(ten));
+            data.put("liveAudienceCost", data.getBigDecimal("liveAudienceCost").divide(ten));
+            data.put("fansT0Gmv", data.getBigDecimal("fansT0Gmv").divide(ten));
+            data.put("fansT1Gmv", data.getBigDecimal("fansT1Gmv").divide(ten));
+            data.put("fansT7Gmv", data.getBigDecimal("fansT7Gmv").divide(ten));
+            data.put("fansT15Gmv", data.getBigDecimal("fansT15Gmv").divide(ten));
+            data.put("fansT30Gmv", data.getBigDecimal("fansT30Gmv").divide(ten));
+            data.put("fansT1Gmv", data.getBigDecimal("fansT1Gmv").divide(ten));
+        });
+        return list;
     }
 
     @Override

+ 1 - 5
ruixuan-live/src/main/java/com/ruixuan/report/utils/AccountReportConstants.java

@@ -167,7 +167,7 @@ public class AccountReportConstants {
             "    \"comment\": \"30日累计GMV\"\n" +
             "  },\n" +
             "  \"roi\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(t1.conversion_num) != 0 THEN CONCAT(CAST(ROUND((sum(t1.cost_total) / sum(t1.conversion_num)) * 100,2) AS CHAR) ,'%') ELSE '0.00%' END AS roi \",\n" +
+            "    \"filed\": \"CASE WHEN sum(t1.cost_total) != 0 THEN ROUND((sum(t1.gmv) / sum(t1.cost_total)),2) ELSE '0.00' END AS roi \",\n" +
             "    \"comment\": \"ROI\"\n" +
             "  },\n" +
             "  \"paiedOrder\": {\n" +
@@ -278,10 +278,6 @@ public class AccountReportConstants {
             "    \"filed\": \"IFNULL(sum(t1.fans_t30_gmv),0) as fansT30Gmv \",\n" +
             "    \"comment\": \"涨粉30日GMV\"\n" +
             "  },\n" +
-            "  \"fansT1Gmv\": {\n" +
-            "    \"filed\": \"IFNULL(sum(t1.fans_t1_gmv),0) as fansT1Gmv \",\n" +
-            "    \"comment\": \"涨粉次日GMV\"\n" +
-            "  },\n" +
             "  \"fansT0Roi\": {\n" +
             "    \"filed\": \"CASE WHEN sum(t1.cost_total) != 0 THEN CONCAT(CAST(ROUND((sum(t1.fans_t0_gmv) / sum(t1.cost_total)) * 100,2) AS CHAR) ,'%') ELSE '0.00%' END AS fansT0Roi \",\n" +
             "    \"comment\": \"涨粉当日ROI\"\n" +

+ 9 - 5
ruixuan-live/src/main/resources/mapper/isc/KuaishouPromoterMapper.xml

@@ -108,7 +108,9 @@
         IF(t0.fans is null,t2.fans_number,t0.fans) AS 'fansNumber',
         t1.30day_gmv AS 'monthDayGmv',
         t1.30day_order_num AS 'monthDayOrderNum',
-        t1.valid_amount AS 'validAmount'
+        t1.valid_amount AS 'validAmount',
+        IF(t0.videoSales is null,t2.video_sales,t0.videoSales) AS 'videoSales',
+        IF(t0.avgVideoSales is null,t2.avg_video_sales,t0.avgVideoSales) AS 'avgVideoSales'
         FROM
         promoter_info t0
         LEFT JOIN promoter_oerder_amount t1 ON t1.promoter_id = t0.promoter_id
@@ -118,11 +120,12 @@
         group_concat( user_name ) AS 'userName',
         fans_number, promoter_url,
         commission_requirement,
-        promoter_nick_name
+        promoter_nick_name,
+        avg_video_sales,
+        video_sales
         FROM kuaishou_promoter
         GROUP BY promoter_id
-        ) t2 ON t1.promoter_id =
-        t2.promoter_id
+        ) t2 ON t1.promoter_id = t2.promoter_id
         <where>
             <if test="promoterId != null ">
                 and t1.promoter_id = #{promoterId}
@@ -147,7 +150,8 @@
 
     <select id="getFailInfo" resultMap="KuaishouPromoterResult">
         <include refid="selectKuaishouPromoterVo"/>
-        where promoter_nick_name = '' or promoter_nick_name is null
+        where (promoter_nick_name = '' or promoter_nick_name is null)
+        AND state =1
     </select>
 
     <select id="getBoundPromoterRoleKey" resultType="com.alibaba.fastjson.JSONObject">

+ 7 - 5
ruixuan-live/src/main/resources/mapper/jinniu/KuaishouAccountMapper.xml

@@ -212,6 +212,12 @@
         where id = #{id}
     </delete>
 
+    <delete id="deleteKuaishouAccountByProjectId" parameterType="Long">
+        delete
+        from kuaishou_account
+        where project_id = #{projectId}
+    </delete>
+
     <select id="selectUnboundAccountList" resultType="com.alibaba.fastjson.JSONObject">
         SELECT *
         FROM (
@@ -238,7 +244,6 @@
             <if test="ksId != null and ksId != '' ">
                 AND t1.user_id = #{ksId}
             </if>
-            ORDER BY account_create_time DESC
             )
             union all
             (SELECT
@@ -263,7 +268,6 @@
                     AND ks_id = #{ksId}
                 </if>
             </where>
-            ORDER BY account_create_time DESC
             )
         </if>
         <if test="status == 2 ">
@@ -289,7 +293,6 @@
             <if test="ksId != null and ksId != '' ">
                 AND t1.user_id = #{ksId}
             </if>
-            ORDER BY account_create_time DESC
         </if>
         <if test="status == 1">
             SELECT
@@ -314,9 +317,8 @@
                     AND ks_id = #{ksId}
                 </if>
             </where>
-            ORDER BY account_create_time DESC
         </if>
-        ) t
+        ) t  ORDER BY accountCreateTime DESC
     </select>
 
     <insert id="insertRecord">

+ 26 - 20
ruixuan-live/src/main/resources/mapper/report/KuaishouLiveAccountReportMapper.xml

@@ -73,7 +73,7 @@
         t2.operator_id as 'operatorId',
         t2.operator_name as 'operatorName',
         SUM(cost_total) as 'costTotal',
-        IFNULL(ROUND(SUM(t1.t0_gmv) / SUM(cost_total), 2), 0) as 'roi'
+        IFNULL(ROUND(SUM(t1.gmv) / SUM(cost_total), 2), 0) as 'roi'
         FROM kuaishou_live_account_report_hourly_dw t1
         LEFT JOIN `kuaishou_project` t2 ON t1.project_id = t2.id
         WHERE report_date = #{today}
@@ -86,13 +86,14 @@
             </foreach>
         </if>
         GROUP BY t1.project_id
+        HAVING SUM(cost_total)>0
         ) t1
         LEFT JOIN
         (
         SELECT
         t1.project_id as 'projectId',
         SUM(cost_total) as 'costTotal',
-        IFNULL(ROUND(SUM(t1.t0_gmv) / SUM(cost_total), 2), 0) as 'roi'
+        IFNULL(ROUND(SUM(t1.gmv) / SUM(cost_total), 2), 0) as 'roi'
         FROM kuaishou_live_account_report_hourly_dw t1
         WHERE report_date = #{yesterday}
         AND hour &lt;= #{hour}
@@ -119,7 +120,7 @@
         t2.operator_id as 'operatorId',
         t2.operator_name as 'operatorName',
         SUM(cost_total) as 'costTotal',
-        IFNULL(ROUND(SUM(t1.t0_gmv) / SUM(cost_total), 2), 0) as 'roi'
+        IFNULL(ROUND(SUM(t1.gmv) / SUM(cost_total), 2), 0) as 'roi'
         FROM kuaishou_live_account_report_daily_dw t1
         LEFT JOIN `kuaishou_project` t2 ON t1.project_id = t2.id
         WHERE report_date >= #{startDate}
@@ -132,13 +133,14 @@
             </foreach>
         </if>
         GROUP BY t1.project_id
+        HAVING SUM(cost_total)>0
         ) t1
         LEFT JOIN
         (
         SELECT
         project_id as 'projectId',
         SUM(cost_total) as 'costTotal',
-        IFNULL(ROUND(SUM(t0_gmv) / SUM(cost_total), 2), 0) as 'roi'
+        IFNULL(ROUND(SUM(gmv) / SUM(cost_total), 2), 0) as 'roi'
         FROM kuaishou_live_account_report_daily_dw
         WHERE report_date >=#{lastStart}
         AND report_date &lt;=#{lastEnd}
@@ -243,13 +245,14 @@
         t2.operator_id AS 'userId',
         t2.operator_name AS 'userName',
         SUM(cost_total) AS 'costTotal',
-        count( DISTINCT CASE WHEN t1.cost_total > 0 THEN t1.account_id ELSE 0 END ) AS 'accountNum',
-        count( DISTINCT CASE WHEN t1.cost_total > 0 THEN t1.project_id ELSE 0 END ) AS 'projectNum'
+        count( DISTINCT t1.account_id ) AS 'accountNum',
+        count( DISTINCT t1.project_id) AS 'projectNum'
         FROM
         kuaishou_live_account_report_hourly_dw t1
         LEFT JOIN kuaishou_account t2 ON t1.account_id = t2.account_id
         WHERE report_date = #{today}
         AND hour &lt;= #{hour}
+        AND t1.cost_total >0
         AND t2.account_type = 1
         <if test="userList != null and userList.size() > 0 ">
             AND t1.user_id IN
@@ -291,13 +294,14 @@
         t2.operator_id AS 'userId',
         t2.operator_name AS 'userName',
         SUM(cost_total) AS 'costTotal',
-        count( DISTINCT CASE WHEN t1.cost_total > 0 THEN t1.account_id ELSE 0 END ) AS 'accountNum',
-        count( DISTINCT CASE WHEN t1.cost_total > 0 THEN t1.project_id ELSE 0 END ) AS 'projectNum'
+        count( DISTINCT t1.account_id ) AS 'accountNum',
+        count( DISTINCT t1.project_id) AS 'projectNum'
         FROM
         kuaishou_live_account_report_daily_dw t1
         LEFT JOIN kuaishou_account t2 ON t1.account_id = t2.account_id
         WHERE report_date >= #{startDate}
         AND report_date &lt;= #{endDate}
+        AND t1.cost_total >0
         AND t2.account_type = 1
         <if test="userList != null and userList.size() > 0 ">
             AND user_id IN
@@ -339,14 +343,15 @@
         SELECT
         '汇总' AS 'userName',
         SUM(cost_total) AS 'costTotal',
-        count( DISTINCT CASE WHEN t1.cost_total > 0 THEN t1.account_id ELSE 0 END ) AS 'accountNum',
-        count( DISTINCT CASE WHEN t1.cost_total > 0 THEN t1.project_id ELSE 0 END ) AS 'projectNum'
+        count( DISTINCT t1.account_id ) AS 'accountNum',
+        count( DISTINCT t1.project_id) AS 'projectNum'
         FROM
         kuaishou_live_account_report_hourly_dw t1
         LEFT JOIN kuaishou_account t2 ON t1.account_id = t2.account_id
         WHERE report_date = #{today}
         AND hour &lt;= #{hour}
         AND t2.account_type = 1
+        AND t1.cost_total >0
         <if test="userList != null and userList.size() > 0 ">
             AND t1.user_id IN
             <foreach collection="userList" item="userId" open="(" separator="," close=")">
@@ -380,14 +385,15 @@
         SELECT
         '汇总' AS 'userName',
         SUM(cost_total) AS 'costTotal',
-        count( DISTINCT CASE WHEN t1.cost_total > 0 THEN t1.account_id ELSE 0 END ) AS 'accountNum',
-        count( DISTINCT CASE WHEN t1.cost_total > 0 THEN t1.project_id ELSE 0 END ) AS 'projectNum'
+        count( DISTINCT t1.account_id ) AS 'accountNum',
+        count( DISTINCT t1.project_id) AS 'projectNum'
         FROM
         kuaishou_live_account_report_daily_dw t1
         LEFT JOIN kuaishou_account t2 ON t1.account_id = t2.account_id
         WHERE report_date >= #{startDate}
         AND report_date &lt;= #{endDate}
         AND t2.account_type = 1
+        AND t1.cost_total >0
         <if test="userList != null and userList.size() > 0 ">
             AND user_id IN
             <foreach collection="userList" item="userId" open="(" separator="," close=")">
@@ -468,8 +474,8 @@
         (
         SELECT
         IFNULL(SUM(cost_total),0)AS'costTotal',
-        IFNULL(SUM(t0_gmv),0)AS't0Gmv',
-        IFNULL(SUM(t0_gmv)/SUM(cost_total),0)AS't0Roi',
+        IFNULL(SUM(gmv),0)AS't0Gmv',
+        IFNULL(SUM(gmv)/SUM(cost_total),0)AS't0Roi',
         IFNULL(SUM(cost_total)/SUM(standard_live_played_started),0)AS'viewCost',
         IFNULL(SUM(merchant_reco_fans),0)AS'upFans',
         IFNULL(SUM(cost_total)/SUM(t0_order_cnt),0)AS'orderCost'
@@ -489,8 +495,8 @@
         (
         SELECT
         IFNULL(SUM(cost_total),0)AS'costTotal',
-        IFNULL(SUM(t0_gmv),0)AS't0Gmv',
-        IFNULL(SUM(t0_gmv)/SUM(cost_total),0)AS't0Roi',
+        IFNULL(SUM(gmv),0)AS't0Gmv',
+        IFNULL(SUM(gmv)/SUM(cost_total),0)AS't0Roi',
         IFNULL(SUM(cost_total)/SUM(standard_live_played_started),0)AS'viewCost',
         IFNULL(SUM(merchant_reco_fans),0)AS'upFans',
         IFNULL(SUM(cost_total)/SUM(t0_order_cnt),0)AS'orderCost'
@@ -525,8 +531,8 @@
         (
         SELECT
         IFNULL(SUM(cost_total),0)AS'costTotal',
-        IFNULL(SUM(t0_gmv),0)AS't0Gmv',
-        IFNULL(SUM(t0_gmv)/SUM(cost_total),0)AS't0Roi',
+        IFNULL(SUM(gmv),0)AS't0Gmv',
+        IFNULL(SUM(gmv)/SUM(cost_total),0)AS't0Roi',
         IFNULL(SUM(cost_total)/SUM(standard_live_played_started),0)AS'viewCost',
         IFNULL(SUM(merchant_reco_fans),0)AS'upFans',
         IFNULL(SUM(cost_total)/SUM(t0_order_cnt),0)AS'orderCost'
@@ -546,8 +552,8 @@
         (
         SELECT
         IFNULL(SUM(cost_total),0)AS'costTotal',
-        IFNULL(SUM(t0_gmv),0)AS't0Gmv',
-        IFNULL(SUM(t0_gmv)/SUM(cost_total),0)AS't0Roi',
+        IFNULL(SUM(gmv),0)AS't0Gmv',
+        IFNULL(SUM(gmv)/SUM(cost_total),0)AS't0Roi',
         IFNULL(SUM(cost_total)/SUM(standard_live_played_started),0)AS'viewCost',
         IFNULL(SUM(merchant_reco_fans),0)AS'upFans',
         IFNULL(SUM(cost_total)/SUM(t0_order_cnt),0)AS'orderCost'