KP工作檯數據漏斗

出自 qingwei personal wiki
於 2018年11月14日 (三) 09:37 由 Qingwei (對話 | 貢獻) 所做的修訂 ()
前往: 導覽搜尋

描述

aone

aone

RPC接口

接口

需求

接口

external/kpwork/overview

sql

  • terminal_type: PC, TOTAL, WS
SELECT
    stat_date,
    imps_cnt_1d_027,
    clk_cnt_1d_092,
    uv_1d_169,
    fb_cnt_1d_013,
    fst_reply_rate_1m_003,
    terminal_type
FROM
    dwp_en_dm_comp_term_catelv2_eff_d
where
    ( stat_date="2018-10-8"
      or stat_date="2018-10-9" )
    and admin_mbr_seq="14"
    and is_main_cate="Y"
    and cate_lv2_id=100010695

展現的條目

  • (投)--- 未加工(投的錢)
  • (曝)imps_cnt_1d_027  : 最近1天排除聯盟的搜索item和p4p商品曝光量
  • (訪)uv_1d_169  : 最近1天訪客數
  • (點)clk_cnt_1d_092 : 最近1天排除聯盟的搜索item和p4p商品相關點擊次數
  • (反)fb_cnt_1d_013  : 最近1天有效MC詢盤數
  • (?)fst_reply_rate_1m_003: 最近30天及時回復率

oneService

參數

  • statDate (根據statisticsType校驗,返回相應錯誤) 
  • terminalType
  • statisticsType
  • adminMemberSeq

SQL配置

  • external.kpwork.overview
select
    ${returnFields}    
from
    <if test='statisticsType == "day"'> 
        dwp_en_dm_comp_term_catelv2_eff_d
    </if>  
    <if test='statisticsType == "week"'> 
        dwp_en_dm_comp_term_catelv2_eff_w
    </if>
    <if test='statisticsType == "month"'> 
        dwp_en_dm_comp_term_catelv2_eff_m
    </if>         
where
    ( stat_date = #{statDate} 
       or stat_date = #{prevDate} )
    and admin_mbr_seq = #{adminMemberSeq}
    and terminal_type = #{terminalType}
    and is_main_cate = #{isMainCate}
    and cate_lv2_id = #{cateLv2Id}

計算前一天/周/月

import java.text.SimpleDateFormat;
import org.apache.commons.lang.time.DateUtils;


SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date statDate = new Date(sdf.parse(statDateStr).getTime());
Date prevDate = statDate;
if ("day".equalsIgnoreCase(statisticsType)) {
    prevDate = DateUtils.addDays(statDate, -1);
} else if ("week".equalsIgnoreCase(statisticsType)) {
    prevDate = DateUtils.addWeeks(statDate, -1);
} else if ("month".equalsIgnoreCase(statisticsType)) {
    prevDate = DateUtils.addMonths(statDate, -1);
}

return sdf.format(prevDate);

計算2級主營類目ID (cateLv2Id)

---!鵲橋接口即將廢棄,本函數可能會改

import com.alibaba.da.pbserver.client.dubbo.result.PBResult;
import com.alibaba.da.pbserver.client.service.PiebridgeHsfServicesLocator;
import com.alibaba.da.pbserver.server.dubbo.api.IPBHsfService;
import com.alibaba.data.alidataservice.infrastructure.util.ResultChecker;
import org.apache.commons.collections.MapUtils;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;


String PBID_GET_OVERVIEW_MAIN_INDUSTRY = "1BDE5F7A0A7D35266592C87B492946E4";
IPBHsfService pbHsfService = PiebridgeHsfServicesLocator.getPiebridgeService();

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date requestDate = new Date(sdf.parse(statDate).getTime());

Map<String, Object> params = new HashMap<>(2);
params.put("adminMemberSeq", adminMemberSeq);
params.put("statDate", requestDate);

PBResult<Map<String, Object>> mainCatePbResult = pbHsfService.queryForSingle(PBID_GET_OVERVIEW_MAIN_INDUSTRY, params);

Map<String, Object> mainCateResult = ResultChecker.checkAndReturnPbResult(mainCatePbResult);

Long industryId = -1L;
if (MapUtils.isNotEmpty(mainCateResult)) {
    industryId = (Long) mainCateResult.get("industryId");
}

return industryId;

新接口

http://oneservice.alibaba-inc.com/v2/view_service_unit.htm?spm=a1zad.8169555.0.0.616bfe14ofZa7f&logicTableId=1022295&sqlId=1001517

select
    cateLv2Id as industryId,
    isMainCate 
from
    dwpEnDmCompCatelv2FilterD 
where
    adminMbrSeq=#{adminMemberSeq} 
    and statDate=#{statDate} 
order by
    rank limit 1
  • oneness
select
    ${returnFields}
from
    dwpEnDmCompCatelv2FilterD 
where
    adminMbrSeq=#{adminMemberSeq} 
    and statDate=#{statDate} 
order by
    rank limit 1

測試

  • oneService
select
    stat_date as statDate,
    clk_cnt_1d_092 as searchClicks,
    imps_cnt_1d_027 as searchImps,
    fb_cnt_1d_013 as mcCnt,
    uv_1d_169 as visitUv,
    terminal_type as terminalType,
    fst_reply_rate_1m_003 as replyRate  
from
    dwp_en_dm_comp_term_catelv2_eff_w  
where
    (
        stat_date = '2018-11-10'          
        or stat_date = '2018-11-03'      
    )      
    and admin_mbr_seq = 14      
    and is_main_cate = 'Y'      
    and cate_lv2_id = 100010695 
order by
    stat_date desc
  • hsf
[
  "external/kpwork/overview",
  {
    "adminMemberSeq": "14",
    "statDate": "2018-11-10",
    "statisticsType": "week"
  }
]

  • oneService
select
    stat_date as statDate,
    clk_cnt_cm_092 as searchClicks,
    fb_cnt_cm_013 as mcCnt,
    imps_cnt_cm_027 as searchImps,
    uv_cm_169 as visitUv,
    terminal_type as terminalType,
    fst_reply_rate_1m_003 as replyRate 
from
    dwp_en_dm_comp_term_catelv2_eff_m 
where
    (
        stat_date = '2018-11-01' 
        or stat_date = '2018-10-01' 
    ) 
    and admin_mbr_seq = 14 
    and is_main_cate = 'Y' 
    and cate_lv2_id = 100010695
  • hsf
[
  "external/kpwork/overview",
  {
    "adminMemberSeq": "14",
    "statDate": "2018-11-01",
    "statisticsType": "month"
  }
]