고객 일별 통계

This commit is contained in:
kubo8
2022-12-22 14:03:20 +09:00
parent b20ca86875
commit 68b3b540ee
8 changed files with 504 additions and 420 deletions

View File

@@ -36,6 +36,18 @@
{
"name": "알림톡",
"colspan": 2
},
{
"name": "대체발송SMS",
"colspan": 2
},
{
"name": "대체발송LMS",
"colspan": 2
},
{
"name": "대체발송MMS",
"colspan": 2
}
],
[
@@ -83,6 +95,33 @@
{
"key": "succCntR",
"name": "성공건수"
},
{
"key": "fbSndCntS",
"name": "발송건수",
"format": "Format_00"
},
{
"key": "fbSuccCntS",
"name": "성공건수"
},
{
"key": "fbSndCntL",
"name": "발송건수",
"format": "Format_00"
},
{
"key": "fbSuccCntL",
"name": "성공건수"
},
{
"key": "fbSndCntM",
"name": "발송건수",
"format": "Format_00"
},
{
"key": "fbSuccCntM",
"name": "성공건수"
}
]
]

View File

@@ -155,13 +155,16 @@ export default {
{ header: 'LMS', childNames: ['sndCntL', 'succCntRtL'] },
{ header: 'MMS', childNames: ['sndCntM', 'succCntRtM'] },
{ header: '알림톡', childNames: ['sndCntR', 'succCntRtR'] },
{ header: '대체발송SMS', childNames: ['fbSndCntS', 'fbSuccCntRtS'] },
{ header: '대체발송LMS', childNames: ['fbSndCntL', 'fbSuccCntRtL'] },
{ header: '대체발송MMS', childNames: ['fbSndCntM', 'fbSuccCntRtM'] }
],
],
columns: [
{ name: 'sumYmd', header: '날짜', align: 'center', width: '8%' },
{ name: 'custNm', header: '고객사명', align: 'center', width: '12%' },
{ name: 'bizrno', header: '사업자번호', align: 'center', width: '8%' },
{ name: 'sumYmd', header: '날짜', align: 'center', width: '5%' },
{ name: 'custNm', header: '고객사명', align: 'center', width: '9%' },
{ name: 'bizrno', header: '사업자번호', align: 'center', width: '6%' },
{
name: 'sndCnt',
header: '발송건수',
@@ -171,7 +174,7 @@ export default {
let result = props.sndCnt.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
return result;
},
width: '7%',
width: '5%',
},
{
name: 'succCntRt',
@@ -187,7 +190,7 @@ export default {
'%)</p>'
);
},
width: '7%',
width: '5%',
},
{
name: 'sndCntS',
@@ -198,7 +201,7 @@ export default {
let result = props.sndCntS.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
return result;
},
width: '7%',
width: '5%',
},
{
name: 'succCntRtS',
@@ -214,7 +217,7 @@ export default {
'%)</p>'
);
},
width: '7%',
width: '5%',
},
{
name: 'sndCntL',
@@ -225,7 +228,7 @@ export default {
let result = props.sndCntL.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
return result;
},
width: '7%',
width: '5%',
},
{
name: 'succCntRtL',
@@ -241,7 +244,7 @@ export default {
'%)</p>'
);
},
width: '7%',
width: '5%',
},
{
name: 'sndCntM',
@@ -252,7 +255,7 @@ export default {
let result = props.sndCntM.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
return result;
},
width: '7%',
width: '5%',
},
{
name: 'succCntRtM',
@@ -268,7 +271,7 @@ export default {
'%)</p>'
);
},
width: '7%',
width: '5%',
},
{
name: 'sndCntR',
@@ -279,7 +282,7 @@ export default {
let result = props.sndCntR.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
return result;
},
width: '7%',
width: '5%',
},
{
name: 'succCntRtR',
@@ -295,7 +298,88 @@ export default {
')</p>'
);
},
width: '7%',
width: '5%',
},
{
name: 'fbSndCntS',
header: '발송건수',
align: 'center',
cls: 'td_line',
formatter: (props) => {
let result = props.fbSndCntS.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
return result;
},
width: '5%',
},
{
name: 'fbSuccCntRtS',
header: '성공건수/(%)',
align: 'center',
cls: 'td_line',
formatter: (props) => {
return (
'<p>' +
props.fbSuccCntS.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') +
'</p>\n<p>(' +
props.succFbRtS +
')</p>'
);
},
width: '5%',
},
{
name: 'fbSndCntL',
header: '발송건수',
align: 'center',
cls: 'td_line',
formatter: (props) => {
let result = props.fbSndCntL.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
return result;
},
width: '5%',
},
{
name: 'fbSuccCntRtL',
header: '성공건수/(%)',
align: 'center',
cls: 'td_line',
formatter: (props) => {
return (
'<p>' +
props.fbSuccCntL.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') +
'</p>\n<p>(' +
props.succFbRtL +
')</p>'
);
},
width: '5%',
},
{
name: 'fbSndCntM',
header: '발송건수',
align: 'center',
cls: 'td_line',
formatter: (props) => {
let result = props.fbSndCntM.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
return result;
},
width: '5%',
},
{
name: 'fbSuccCntRtL',
header: '성공건수/(%)',
align: 'center',
cls: 'td_line',
formatter: (props) => {
return (
'<p>' +
props.fbSuccCntM.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') +
'</p>\n<p>(' +
props.succFbRtM +
')</p>'
);
},
width: '5%',
},
],
noDataStr: '검색 결과가 없습니다.',

View File

@@ -217,6 +217,12 @@ public class StatsService {
StatsMapper statsMapper = sqlSessionSlave.getMapper(StatsMapper.class);
String nowPage = String.valueOf(bsnmDayListReqDto.getPage());
//오늘 날짜 조회인지 확인
if(DateUtils.date2strYMD().equals(bsnmDayListReqDto.getEndDay())) {
bsnmDayListReqDto.setNowDiv("Y");
}
int totalCnt = statsMapper.selectCustDstatListTotalCnt(bsnmDayListReqDto);
if (totalCnt == 0) {
@@ -261,6 +267,11 @@ public class StatsService {
StatsMapper statsMapper = sqlSessionSlave.getMapper(StatsMapper.class);
//오늘 날짜 조회인지 확인
if(DateUtils.date2strYMD().equals(bsnmDayListExcelReqDto.getEndDay())) {
bsnmDayListExcelReqDto.setNowDiv("Y");
}
List<BsnmDayList> bsnmDayLists = statsMapper.selectCustDstatExcelList(bsnmDayListExcelReqDto);
BsnmDayListExcelRes bsnmDayListExcelRes = new BsnmDayListExcelRes();

View File

@@ -45,4 +45,23 @@ public class BsnmDayList implements Serializable {
private String succCntR;
@ApiModelProperty(example = "알림톡 성공율", name = "알림톡 성공율", dataType = "String")
private String succRtR;
@ApiModelProperty(example = "대체발송SMS 발송건수", name = "대체발송SMS 발송건수", dataType = "String")
private String fbSndCntS;
@ApiModelProperty(example = "대체발송SMS 성공건수", name = "대체발송SMS 성공건수", dataType = "String")
private String fbSuccCntS;
@ApiModelProperty(example = "대체발송SMS 성공율", name = "대체발송SMS 성공율", dataType = "String")
private String succFbRtS;
@ApiModelProperty(example = "대체발송LMS 발송건수", name = "대체발송LMS 발송건수", dataType = "String")
private String fbSndCntL;
@ApiModelProperty(example = "대체발송LMS 성공건수", name = "대체발송LMS 성공건수", dataType = "String")
private String fbSuccCntL;
@ApiModelProperty(example = "대체발송LMS 성공율", name = "대체발송LMS 성공율", dataType = "String")
private String succFbRtL;
@ApiModelProperty(example = "대체발송MMS 발송건수", name = "대체발송MMS 발송건수", dataType = "String")
private String fbSndCntM;
@ApiModelProperty(example = "대체발송MMS 성공건수", name = "대체발송MMS 성공건수", dataType = "String")
private String fbSuccCntM;
@ApiModelProperty(example = "대체발송MMS 성공율", name = "대체발송MMS 성공율", dataType = "String")
private String succFbRtM;
}

View File

@@ -24,4 +24,8 @@ public class BsnmDayListExcelReqDto implements Serializable {
@ApiModelProperty(example = "사업자등록번호", name = "사업자등록번호", dataType = "String")
private String bizrno;
@NotNull
@ApiModelProperty(example = "당일 조회 여부", name = "당일 조회 여부", dataType = "String")
private String nowDiv = "N";
}

View File

@@ -32,4 +32,8 @@ public class BsnmDayListReqDto implements Serializable {
@ApiModelProperty(example = "현재 페이지", name = "현재 페이지", dataType = "int")
private int page;
@NotNull
@ApiModelProperty(example = "당일 조회 여부", name = "당일 조회 여부", dataType = "String")
private String nowDiv = "N";
}

View File

@@ -8,9 +8,9 @@ spring:
pool-name: hikari-cp
maximum-pool-size: 30
minimum-idle: 5
connection-timeout: 5000
connection-timeout: 1800000
connection-init-sql: SELECT 1
validation-timeout: 2000
validation-timeout: 600000
idle-timeout: 600000
max-lifetime: 1800000
datasource-db2:
@@ -22,9 +22,9 @@ spring:
pool-name: hikari-cp
maximum-pool-size: 30
minimum-idle: 5
connection-timeout: 5000
connection-timeout: 1800000
connection-init-sql: SELECT 1
validation-timeout: 2000
validation-timeout: 600000
idle-timeout: 600000
max-lifetime: 1800000

View File

@@ -934,421 +934,344 @@
<select id="selectCustDstatListTotalCnt" parameterType="kr.co.uplus.ez.api.stats.dto.BsnmDayListReqDto" resultType="int">
/* stats-mapper.xml(selectCustDstatListTotalCnt) */
SELECT
COUNT(*) AS TOTALCNT
COUNT(SUM_YMD) AS TOTALCNT
FROM
(
<!-- 추가분 시작 -->
SELECT
DATE_FORMAT(ewm.REG_DT , '%Y-%m-%d') AS SUM_YMD
,ewm.USER_SEQ
,(SELECT CUST_NM FROM hubez_common.EZ_CUST_INFO ci WHERE ci.CUST_SEQ = esu.CUST_SEQ) as CUST_NM
,(SELECT BIZRNO FROM hubez_common.EZ_CUST_INFO ci WHERE ci.CUST_SEQ = esu.CUST_SEQ) as BIZRNO
S1.SUM_YMD, S1.USER_SEQ
FROM
hubez_common.EZ_WEB_MSG ewm
INNER JOIN hubez_common.EZ_SVC_USER esu ON ewm.USER_SEQ = esu.USER_SEQ
WHERE
1 = 1
AND DATE_FORMAT( #{endDay}, '%Y-%m-%d') = DATE_FORMAT( NOW(), '%Y-%m-%d')
AND DATE_FORMAT( ewm.REG_DT, '%Y-%m-%d') = DATE_FORMAT( NOW(), '%Y-%m-%d')
GROUP BY DATE_FORMAT(ewm.REG_DT, '%Y-%m-%d') , ewm.USER_SEQ
UNION ALL
<!-- 추가분 끝 -->
(
SELECT
SUM_YMD
,USER_SEQ
,CUST_NM
,BIZRNO
SUM_YMD, USER_SEQ
FROM
hubez_common.EZ_CUST_DSTAT
WHERE 1=1
AND SUM_YMD BETWEEN DATE_FORMAT(#{startDay},'%Y%m%d') AND DATE_FORMAT(#{endDay},'%Y%m%d')
GROUP BY SUM_YMD, USER_SEQ
) A
WHERE 1=1
<if test="custNm != null and custNm != ''">
AND CUST_NM LIKE CONCAT('%',#{custNm},'%')
</if>
<if test="bizrno != null and bizrno != ''">
AND BIZRNO LIKE CONCAT('%',#{bizrno},'%')
WHERE
SUM_YMD BETWEEN DATE_FORMAT(#{startDay},'%Y%m%d') AND DATE_FORMAT(#{endDay},'%Y%m%d')
AND BIZRNO != '1234567890'
) S1
WHERE
1 = 1
GROUP BY S1.SUM_YMD, S1.USER_SEQ
<if test='nowDiv == "Y"'>
UNION ALL
SELECT
S2.SUM_YMD, S2.USER_SEQ
FROM
(
SELECT
SUM_YMD, USER_SEQ
FROM
(
SELECT
DATE_FORMAT(ewm.YMD, '%Y-%m-%d') AS SUM_YMD,
esu.PRNTS_USER_SEQ AS USER_SEQ,
REPLACE (ewm.CH_STR ,'KKO_NOTI', 'ALIMTALK') AS SND_CH_CD
FROM
hubez_common.EZ_WEB_MSG ewm INNER JOIN
hubez_common.EZ_SVC_USER esu ON ewm.USER_SEQ = esu.USER_SEQ
WHERE
ewm.YMD = DATE_FORMAT( NOW(), '%Y-%m-%d')
GROUP BY ewm.YMD, esu.PRNTS_USER_SEQ, ewm.CH_STR
UNION ALL
SELECT
DATE_FORMAT(ewm.YMD, '%Y-%m-%d') AS SUM_YMD,
esu.PRNTS_USER_SEQ AS USER_SEQ,
FB_CH_STR AS SND_CH_CD
FROM
hubez_common.EZ_WEB_MSG ewm INNER JOIN
hubez_common.EZ_SVC_USER esu ON ewm.USER_SEQ = esu.USER_SEQ
WHERE
ewm.YMD = DATE_FORMAT( NOW(), '%Y-%m-%d')
AND (FB_SUCC_CNT > 0 OR FB_FAIL_CNT > 0)
GROUP BY ewm.YMD, esu.PRNTS_USER_SEQ, ewm.FB_CH_STR
) T1
WHERE
1 = 1
GROUP BY SUM_YMD, USER_SEQ, SND_CH_CD
) S2
WHERE
1 = 1
GROUP BY S2.SUM_YMD, S2.USER_SEQ
</if>
) A,
hubez_common.EZ_SUBS_INFO B,
hubez_common.EZ_CUST_INFO C
WHERE
A.USER_SEQ = B.USER_SEQ
AND B.CUST_SEQ = C.CUST_SEQ
AND C.BIZRNO != '1234567890'
<include refid="custMstatListCondition"/>
</select>
<select id="selectCustDstatList" parameterType="kr.co.uplus.ez.api.stats.dto.BsnmDayListReqDto" resultType="kr.co.uplus.ez.api.stats.dto.BsnmDayList">
/* stats-mapper.xml(selectCustDstatList) */
select DATE_FORMAT(t1.SUM_YMD, '%Y-%m-%d') AS SUM_YMD
, t1.CUST_NM AS CUST_NM
, t1.BIZRNO AS BIZRNO
, SUM(t2.sndCntS + t2.sndCntL + t2.sndCntM + t2.sndCntR) AS SND_CNT
, SUM(t2.succCntS + t2.succCntL + t2.succCntM + t2.succCntR) AS SUCC_CNT
, IFNULL(TRUNCATE(SUM(t2.succCntS + t2.succCntL + t2.succCntM + t2.succCntR) / SUM(t2.sndCntS + t2.sndCntL + t2.sndCntM + t2.sndCntR) * 100, 2),0) as SUCC_RT
, SUM(t2.sndCntS) as SND_CNT_S
, SUM(t2.succCntS) as SUCC_CNT_S
, IFNULL(TRUNCATE((SUM(t2.succCntS) / SUM(t2.sndCntS)) * 100, 2), 0) as SUCC_RT_S
, SUM(t2.sndCntL) as SND_CNT_L
, SUM(t2.succCntL) as SUCC_CNT_L
, IFNULL(TRUNCATE((SUM(t2.succCntL) / SUM(t2.sndCntL)) * 100, 2), 0) as SUCC_RT_L
, SUM(t2.sndCntM) as SND_CNT_M
, SUM(t2.succCntM) as SUCC_CNT_M
, IFNULL(TRUNCATE((SUM(t2.succCntM) / SUM(t2.sndCntM)) * 100, 2), 0) as SUCC_RT_M
, SUM(t2.sndCntR) as SND_CNT_R
, SUM(t2.succCntR) as SUCC_CNT_R
, IFNULL(TRUNCATE((SUM(t2.succCntR) / SUM(t2.sndCntR)) * 100, 2), 0) as SUCC_RT_R
from (
<!-- 추가분 (시작) -->
SELECT
DATE_FORMAT(ewm.REG_DT , '%Y-%m-%d') AS SUM_YMD
,ewm.USER_SEQ
,(SELECT BIZRNO FROM hubez_common.EZ_CUST_INFO ci WHERE ci.CUST_SEQ = esu.CUST_SEQ) as BIZRNO
,(SELECT CUST_NM FROM hubez_common.EZ_CUST_INFO ci WHERE ci.CUST_SEQ = esu.CUST_SEQ) as CUST_NM
DATE_FORMAT(A.SUM_YMD, '%Y-%m-%d') AS sumYmd, C.CUST_NM AS custNm, C.BIZRNO AS bizrno,
A.sndCnt, A.succCnt, IFNULL(ROUND((A.succCnt/A.sndCnt)*100,2),0) AS succRt,
A.sndCntS, A.succCntS, IFNULL(ROUND((A.succCntS/A.sndCntS)*100,2),0) AS succRtS,
A.sndCntL, A.succCntL, IFNULL(ROUND((A.succCntL/A.sndCntL)*100,2),0) AS succRtL,
A.sndCntM, A.succCntM, IFNULL(ROUND((A.succCntM/A.sndCntM)*100,2),0) AS succRtM,
A.sndCntR, A.succCntR, IFNULL(ROUND((A.succCntR/A.sndCntR)*100,2),0) AS succRtR,
A.fbSndCntS, A.fbSuccCntS, IFNULL(ROUND((A.fbSuccCntS/A.fbSndCntS)*100,2),0) AS succFbRtS,
A.fbSndCntL, A.fbSuccCntL, IFNULL(ROUND((A.fbSuccCntL/A.fbSndCntL)*100,2),0) AS succFbRtL,
A.fbSndCntM, A.fbSuccCntM, IFNULL(ROUND((A.fbSuccCntM/A.fbSndCntM)*100,2),0) AS succFbRtM
FROM
hubez_common.EZ_WEB_MSG ewm
INNER JOIN hubez_common.EZ_SVC_USER esu ON ewm.USER_SEQ = esu.USER_SEQ
(
SELECT
S1.SUM_YMD, S1.USER_SEQ,
(SUM(S1.sndCntS) + SUM(S1.sndCntL) + SUM(S1.sndCntM) + SUM(S1.sndCntR)) AS sndCnt,
(SUM(S1.succCntS) + SUM(S1.succCntL) +SUM(S1.succCntM) +SUM(S1.succCntR) + SUM(fbSuccCntS) + SUM(fbSuccCntL)+ SUM(fbSuccCntM)) AS succCnt,
SUM(S1.sndCntS) AS sndCntS, SUM(S1.succCntS) AS succCntS, SUM(S1.sndCntL) AS sndCntL, SUM(S1.succCntL) AS succCntL, SUM(S1.sndCntM) AS sndCntM,
SUM(S1.succCntM) AS succCntM, SUM(S1.sndCntR) AS sndCntR, SUM(S1.succCntR) AS succCntR, SUM(S1.fbSndCntS) AS fbSndCntS, SUM(S1.fbSuccCntS) AS fbSuccCntS,
SUM(S1.fbSndCntL) AS fbSndCntL, SUM(S1.fbSuccCntL) AS fbSuccCntL, SUM(S1.fbSndCntM) AS fbSndCntM, SUM(S1.fbSuccCntM) AS fbSuccCntM
FROM
(
SELECT
SUM_YMD, USER_SEQ,
CASE WHEN SND_CH_CD = 'SMS' THEN IFNULL(SND_CNT, 0) ELSE 0 END AS sndCntS,
CASE WHEN SND_CH_CD = 'SMS' THEN IFNULL(SUCC_CNT, 0) ELSE 0 END AS succCntS,
CASE WHEN SND_CH_CD = 'LMS' THEN IFNULL(SND_CNT, 0) ELSE 0 END AS sndCntL,
CASE WHEN SND_CH_CD = 'LMS' THEN IFNULL(SUCC_CNT, 0) ELSE 0 END AS succCntL,
CASE WHEN SND_CH_CD = 'MMS' THEN IFNULL(SND_CNT, 0) ELSE 0 END AS sndCntM,
CASE WHEN SND_CH_CD = 'MMS' THEN IFNULL(SUCC_CNT, 0) ELSE 0 END AS succCntM,
CASE WHEN SND_CH_CD = 'ALIMTALK' THEN IFNULL(SND_CNT, 0) ELSE 0 END AS sndCntR,
CASE WHEN SND_CH_CD = 'ALIMTALK' THEN IFNULL(SUCC_CNT, 0) ELSE 0 END AS succCntR,
CASE WHEN RPLCSND_CH_CD = 'SMS' THEN IFNULL(FBACK_CNT, 0) ELSE 0 END AS fbSndCntS,
CASE WHEN RPLCSND_CH_CD = 'SMS' THEN IFNULL(FBACK_SUCC_CNT, 0) ELSE 0 END AS fbSuccCntS,
CASE WHEN RPLCSND_CH_CD = 'LMS' THEN IFNULL(FBACK_CNT, 0) ELSE 0 END AS fbSndCntL,
CASE WHEN RPLCSND_CH_CD = 'LMS' THEN IFNULL(FBACK_SUCC_CNT, 0) ELSE 0 END AS fbSuccCntL,
CASE WHEN RPLCSND_CH_CD = 'MMS' THEN IFNULL(FBACK_CNT, 0) ELSE 0 END AS fbSndCntM,
CASE WHEN RPLCSND_CH_CD = 'MMS' THEN IFNULL(FBACK_SUCC_CNT, 0) ELSE 0 END AS fbSuccCntM
FROM
hubez_common.EZ_CUST_DSTAT
WHERE
SUM_YMD BETWEEN DATE_FORMAT(#{startDay},'%Y%m%d') AND DATE_FORMAT(#{endDay},'%Y%m%d')
AND BIZRNO != '1234567890'
) S1
WHERE
1 = 1
AND DATE_FORMAT( #{endDay}, '%Y-%m-%d') = DATE_FORMAT( NOW(), '%Y-%m-%d')
AND DATE_FORMAT( ewm.REG_DT, '%Y-%m-%d') = DATE_FORMAT( NOW(), '%Y-%m-%d')
GROUP BY DATE_FORMAT(ewm.REG_DT, '%Y-%m-%d') , ewm.USER_SEQ
GROUP BY S1.SUM_YMD, S1.USER_SEQ
<if test='nowDiv == "Y"'>
UNION ALL
<!-- 추가분 (끝) -->
select SUM_YMD
, USER_SEQ
, BIZRNO
, CUST_NM
from (
select ecm.SUM_YMD
, ecm.USER_SEQ
, ecm.BIZRNO
, ecm.CUST_NM
from hubez_common.EZ_CUST_DSTAT ecm
where 1=1
AND SUM_YMD BETWEEN DATE_FORMAT(#{startDay},'%Y%m%d') AND DATE_FORMAT(#{endDay},'%Y%m%d')
<include refid="custDstatListCondition"/>
group by ecm.SUM_YMD, ecm.USER_SEQ
ORDER BY ecm.SUM_YMD DESC, ecm.USER_SEQ
) list
LIMIT #{page}, #{pagePerRows}
) t1 inner join (
select SUM_YMD
, USER_SEQ
, sum(smsSndCnt) AS sndCntS
, sum(smsSuccCnt) AS succCntS
, sum(smsSuccRt) AS succRtS
, sum(lmsSndCnt) AS sndCntL
, sum(lmsSuccCnt) AS succCntL
, sum(lmsSuccRt) AS succRtL
, sum(mmsSndCnt) AS sndCntM
, sum(mmsSuccCnt) AS succCntM
, sum(mmsSuccRt) AS succRtM
, sum(alimtSndCnt) AS sndCntR
, sum(alimtSuccCnt) AS succCntR
, sum(alimtSuccRt) AS succRtR
from (
select SUM_YMD
, USER_SEQ
, case when sndChCd = 'SMS' then SUM(SND_CNT) + SUM(FBACK_CNT)
else 0
end as smsSndCnt
, case when sndChCd = 'SMS' then SUM(SUCC_CNT) + SUM(FBACK_SUCC_CNT)
else 0
end as smsSuccCnt
, case when sndChCd = 'SMS' then TRUNCATE((SUM(SUCC_CNT) + SUM(FBACK_SUCC_CNT)) / (SUM(SND_CNT) + SUM(FBACK_CNT)) * 100, 2)
else 0
end as smsSuccRt
, case when sndChCd = 'LMS' then SUM(SND_CNT) + SUM(FBACK_CNT)
else 0
end as lmsSndCnt
, case when sndChCd = 'LMS' then SUM(SUCC_CNT) + SUM(FBACK_SUCC_CNT)
else 0
end as lmsSuccCnt
, case when sndChCd = 'LMS' then TRUNCATE((SUM(SUCC_CNT) + SUM(FBACK_SUCC_CNT)) / (SUM(SND_CNT) + SUM(FBACK_CNT)) * 100, 2)
else 0
end as lmsSuccRt
, case when sndChCd = 'MMS' then SUM(SND_CNT) + SUM(FBACK_CNT)
else 0
end as mmsSndCnt
, case when sndChCd = 'MMS' then SUM(SUCC_CNT) + SUM(FBACK_SUCC_CNT)
else 0
end as mmsSuccCnt
, case when sndChCd = 'MMS' then TRUNCATE((SUM(SUCC_CNT) + SUM(FBACK_SUCC_CNT)) / (SUM(SND_CNT) + SUM(FBACK_CNT)) * 100, 2)
else 0
end as mmsSuccRt
, case when sndChCd = 'ALIMTALK' then SUM(SND_CNT) + SUM(FBACK_CNT)
else 0
end as alimtSndCnt
, case when sndChCd = 'ALIMTALK' then SUM(SUCC_CNT) + SUM(FBACK_SUCC_CNT)
else 0
end as alimtSuccCnt
, case when sndChCd = 'ALIMTALK' then TRUNCATE((SUM(SUCC_CNT) + SUM(FBACK_SUCC_CNT)) / (SUM(SND_CNT) + SUM(FBACK_CNT)) * 100, 2)
else 0
end as alimtSuccRt
from (
<!-- 추가분 (시작) -->
SELECT
DATE_FORMAT(ewm.REG_DT , '%Y-%m-%d') AS SUM_YMD
,ewm.USER_SEQ
,REPLACE (ewm.CH_STR ,'KKO_NOTI', 'ALIMTALK') AS sndChCd
,SUM(IFNULL(ewm.SEND_CNT, 0)) AS SND_CNT
,SUM(IFNULL(ewm.SUCC_CNT, 0)) AS SUCC_CNT
,SUM(IFNULL(ewm.FAIL_CNT, 0)) AS FAIL_CNT
,SUM(IFNULL(ewm.FB_SUCC_CNT , 0)) + SUM(IFNULL(ewm.FB_FAIL_CNT, 0)) AS FBACK_CNT
,SUM(IFNULL(ewm.FB_SUCC_CNT, 0)) AS FBACK_SUCC_CNT
,SUM(IFNULL(ewm.FB_FAIL_CNT, 0)) AS FBACK_FAIL_CNT
S2.SUM_YMD, S2.USER_SEQ,
(SUM(S2.sndCntS) + SUM(S2.sndCntL) + SUM(S2.sndCntM) + SUM(S2.sndCntR)) AS sndCnt,
(SUM(S2.succCntS) + SUM(S2.succCntL) +SUM(S2.succCntM) +SUM(S2.succCntR) + SUM(fbSuccCntS) + SUM(fbSuccCntL)+ SUM(fbSuccCntM)) AS succCnt,
SUM(S2.sndCntS) AS sndCntS, SUM(S2.succCntS) AS succCntS, SUM(S2.sndCntL) AS sndCntL, SUM(S2.succCntL) AS succCntL, SUM(S2.sndCntM) AS sndCntM,
SUM(S2.succCntM) AS succCntM, SUM(S2.sndCntR) AS sndCntR, SUM(S2.succCntR) AS succCntR, SUM(S2.fbSndCntS) AS fbSndCntS, SUM(S2.fbSuccCntS) AS fbSuccCntS,
SUM(S2.fbSndCntL) AS fbSndCntL, SUM(S2.fbSuccCntL) AS fbSuccCntL, SUM(S2.fbSndCntM) AS fbSndCntM, SUM(S2.fbSuccCntM) AS fbSuccCntM
FROM
hubez_common.EZ_WEB_MSG ewm
(
SELECT
SUM_YMD, USER_SEQ,
CASE WHEN SND_CH_CD = 'SMS' THEN SUM(SND_CNT) ELSE 0 END AS sndCntS,
CASE WHEN SND_CH_CD = 'SMS' THEN SUM(SUCC_CNT) ELSE 0 END AS succCntS,
CASE WHEN SND_CH_CD = 'LMS' THEN SUM(SND_CNT) ELSE 0 END AS sndCntL,
CASE WHEN SND_CH_CD = 'LMS' THEN SUM(SUCC_CNT) ELSE 0 END AS succCntL,
CASE WHEN SND_CH_CD = 'MMS' THEN SUM(SND_CNT) ELSE 0 END AS sndCntM,
CASE WHEN SND_CH_CD = 'MMS' THEN SUM(SUCC_CNT) ELSE 0 END AS succCntM,
CASE WHEN SND_CH_CD = 'ALIMTALK' THEN SUM(SND_CNT) ELSE 0 END AS sndCntR,
CASE WHEN SND_CH_CD = 'ALIMTALK' THEN SUM(SUCC_CNT) ELSE 0 END AS succCntR,
CASE WHEN SND_CH_CD = 'SMS' THEN SUM(FBACK_CNT) ELSE 0 END AS fbSndCntS,
CASE WHEN SND_CH_CD = 'SMS' THEN SUM(FBACK_SUCC_CNT) ELSE 0 END AS fbSuccCntS,
CASE WHEN SND_CH_CD = 'LMS' THEN SUM(FBACK_CNT) ELSE 0 END AS fbSndCntL,
CASE WHEN SND_CH_CD = 'LMS' THEN SUM(FBACK_SUCC_CNT) ELSE 0 END AS fbSuccCntL,
CASE WHEN SND_CH_CD = 'MMS' THEN SUM(FBACK_CNT) ELSE 0 END AS fbSndCntM,
CASE WHEN SND_CH_CD = 'MMS' THEN SUM(FBACK_SUCC_CNT) ELSE 0 END AS fbSuccCntM
FROM
(
SELECT
DATE_FORMAT(ewm.YMD, '%Y-%m-%d') AS SUM_YMD,
esu.PRNTS_USER_SEQ AS USER_SEQ,
REPLACE (ewm.CH_STR ,'KKO_NOTI', 'ALIMTALK') AS SND_CH_CD,
SUM(IFNULL(ewm.SEND_CNT, 0)) AS SND_CNT,
SUM(IFNULL(ewm.SUCC_CNT, 0)) AS SUCC_CNT,
0 AS FBACK_CNT,
0 AS FBACK_SUCC_CNT
FROM
hubez_common.EZ_WEB_MSG ewm INNER JOIN
hubez_common.EZ_SVC_USER esu ON ewm.USER_SEQ = esu.USER_SEQ
WHERE
ewm.YMD = DATE_FORMAT( NOW(), '%Y-%m-%d')
GROUP BY ewm.YMD, esu.PRNTS_USER_SEQ, ewm.CH_STR
UNION ALL
SELECT
DATE_FORMAT(ewm.YMD, '%Y-%m-%d') AS SUM_YMD,
esu.PRNTS_USER_SEQ AS USER_SEQ,
FB_CH_STR AS SND_CH_CD,
0 AS SND_CNT,
0 AS SUCC_CNT,
SUM(IFNULL(ewm.FB_SUCC_CNT + ewm.FB_FAIL_CNT, 0)) AS FBACK_CNT,
SUM(IFNULL(ewm.FB_SUCC_CNT, 0)) AS FBACK_SUCC_CNT
FROM
hubez_common.EZ_WEB_MSG ewm INNER JOIN
hubez_common.EZ_SVC_USER esu ON ewm.USER_SEQ = esu.USER_SEQ
WHERE
ewm.YMD = DATE_FORMAT( NOW(), '%Y-%m-%d')
AND (FB_SUCC_CNT > 0 OR FB_FAIL_CNT > 0)
GROUP BY ewm.YMD, esu.PRNTS_USER_SEQ, ewm.FB_CH_STR
) T1
WHERE
1 = 1
AND DATE_FORMAT( #{endDay}, '%Y-%m-%d') = DATE_FORMAT( NOW(), '%Y-%m-%d')
AND DATE_FORMAT( ewm.REG_DT, '%Y-%m-%d') = DATE_FORMAT( NOW(), '%Y-%m-%d')
GROUP BY
DATE_FORMAT(ewm.REG_DT, '%Y-%m-%d'), ewm.USER_SEQ , ewm.CH_STR
UNION ALL
<!-- 추가분 (끝) -->
select ecm.SUM_YMD, ecm.USER_SEQ, SND_CH_CD as sndChCd
, ifnull(sum(SND_CNT) , 0) as SND_CNT
, ifnull(sum(SUCC_CNT) , 0) as SUCC_CNT
, ifnull(sum(FAIL_CNT) , 0) as FAIL_CNT
, 0 as FBACK_CNT
, 0 as FBACK_SUCC_CNT
, 0 as FBACK_FAIL_CNT
from hubez_common.EZ_CUST_DSTAT ecm
inner join (
select SUM_YMD
, USER_SEQ
from (
select ecm.SUM_YMD
, ecm.USER_SEQ
from hubez_common.EZ_CUST_DSTAT ecm
where 1=1
AND SUM_YMD BETWEEN DATE_FORMAT(#{startDay},'%Y%m%d') AND DATE_FORMAT(#{endDay},'%Y%m%d')
<include refid="custDstatListCondition"/>
group by ecm.SUM_YMD , ecm.USER_SEQ
ORDER BY ecm.SUM_YMD DESC , ecm.USER_SEQ
) list
LIMIT #{page}, #{pagePerRows}
) list
on list.SUM_YMD = ecm.SUM_YMD and list.USER_SEQ = ecm.USER_SEQ
where ecm.SUM_YMD BETWEEN DATE_FORMAT(#{startDay},'%Y%m%d') AND DATE_FORMAT(#{endDay},'%Y%m%d')
group by ecm.SUM_YMD , ecm.USER_SEQ, SND_CH_CD
union all
select ecm.SUM_YMD, ecm.USER_SEQ, ecm.RPLCSND_CH_CD as sndChCd
, 0 as SND_CNT
, 0 as SUCC_CNT
, 0 as FAIL_CNT
, ifnull(sum(FBACK_CNT) , 0) as FBACK_CNT
, ifnull(sum(FBACK_SUCC_CNT) , 0) as FBACK_SUCC_CNT
, ifnull(sum(FBACK_FAIL_CNT) , 0) as FBACK_FAIL_CNT
from hubez_common.EZ_CUST_DSTAT ecm
inner join (
select SUM_YMD
, USER_SEQ
from (
select ecm.SUM_YMD
, ecm.USER_SEQ
from hubez_common.EZ_CUST_DSTAT ecm
where 1=1
AND SUM_YMD BETWEEN DATE_FORMAT(#{startDay},'%Y%m%d') AND DATE_FORMAT(#{endDay},'%Y%m%d')
<include refid="custDstatListCondition"/>
group by ecm.SUM_YMD , ecm.USER_SEQ
ORDER BY ecm.SUM_YMD DESC, ecm.USER_SEQ
) list
LIMIT #{page}, #{pagePerRows}
) list
on list.SUM_YMD = ecm.SUM_YMD and list.USER_SEQ = ecm.USER_SEQ
where ecm.SUM_YMD BETWEEN DATE_FORMAT(#{startDay},'%Y%m%d') AND DATE_FORMAT(#{endDay},'%Y%m%d')
and RPLCSND_CH_CD in ('SMS', 'LMS', 'MMS', 'ALIMTALK')
group by ecm.SUM_YMD, ecm.USER_SEQ, ecm.RPLCSND_CH_CD
) t1 group by SUM_YMD, USER_SEQ, sndChCd order by null
) t2 group by SUM_YMD, USER_SEQ order by null
) t2 on t2.SUM_YMD = t1.SUM_YMD and t2.USER_SEQ = t1.USER_SEQ
WHERE 1=1
GROUP BY SUM_YMD, USER_SEQ, SND_CH_CD
) S2
WHERE
1 = 1
GROUP BY S2.SUM_YMD, S2.USER_SEQ
</if>
) A,
hubez_common.EZ_SUBS_INFO B,
hubez_common.EZ_CUST_INFO C
WHERE
A.USER_SEQ = B.USER_SEQ
AND B.CUST_SEQ = C.CUST_SEQ
AND C.BIZRNO != '1234567890'
<include refid="custMstatListCondition"/>
GROUP BY t1.BIZRNO, t1.SUM_YMD
order by SUM_YMD DESC, t1.USER_SEQ
ORDER BY A.SUM_YMD DESC, C.CUST_NM
LIMIT #{page}, #{pagePerRows}
</select>
<select id="selectCustDstatExcelList" parameterType="kr.co.uplus.ez.api.stats.dto.BsnmDayListExcelReqDto" resultType="kr.co.uplus.ez.api.stats.dto.BsnmDayList">
/* stats-mapper.xml(selectCustDstatExcelList) */
select DATE_FORMAT(t1.SUM_YMD, '%Y-%m-%d') AS SUM_YMD
, t1.CUST_NM AS CUST_NM
, t1.BIZRNO AS BIZRNO
, SUM(t2.sndCntS + t2.sndCntL + t2.sndCntM + t2.sndCntR) AS SND_CNT
, CONCAT(SUM(t2.succCntS + t2.succCntL + t2.succCntM + t2.succCntR),'(',(TRUNCATE(SUM(t2.succCntS + t2.succCntL + t2.succCntM + t2.succCntR) / SUM(t2.sndCntS + t2.sndCntL + t2.sndCntM + t2.sndCntR) * 100, 2)) , '%)') AS SUCC_CNT
, SUM(t2.sndCntS) as SND_CNT_S
, CONCAT(SUM(t2.succCntS), '(', IFNULL(TRUNCATE((SUM(t2.succCntS) / SUM(t2.sndCntS)) * 100, 2), 0), '%)') as SUCC_CNT_S
, SUM(t2.sndCntL) as SND_CNT_L
, CONCAT(SUM(t2.succCntL), '(', IFNULL(TRUNCATE((SUM(t2.succCntL) / SUM(t2.sndCntL)) * 100, 2), 0) , '%)') as SUCC_CNT_L
, SUM(t2.sndCntM) as SND_CNT_M
, CONCAT(SUM(t2.succCntM), '(', IFNULL(TRUNCATE((SUM(t2.succCntM) / SUM(t2.sndCntM)) * 100, 2), 0), '%)') as SUCC_CNT_M
, SUM(t2.sndCntR) as SND_CNT_R
, CONCAT(SUM(t2.succCntR), '(', IFNULL(TRUNCATE((SUM(t2.succCntR) / SUM(t2.sndCntR)) * 100, 2), 0), '%)') as SUCC_CNT_R
from (
<!-- 추가분 (시작) -->
SELECT
DATE_FORMAT(ewm.REG_DT , '%Y-%m-%d') AS SUM_YMD
,ewm.USER_SEQ
,(SELECT BIZRNO FROM hubez_common.EZ_CUST_INFO ci WHERE ci.CUST_SEQ = esu.CUST_SEQ) as BIZRNO
,(SELECT CUST_NM FROM hubez_common.EZ_CUST_INFO ci WHERE ci.CUST_SEQ = esu.CUST_SEQ) as CUST_NM
sumYmd, custNm, bizrno,
sndCnt, CONCAT(succCnt,'(',succRt,'%)') AS succCnt,
sndCntS, CONCAT(succCntS,'(',succRtS,'%)') AS succCntS,
sndCntL, CONCAT(succCntL,'(',succRtL,'%)') AS succCntL,
sndCntM, CONCAT(succCntM,'(',succRtM,'%)') AS succCntM,
sndCntR, CONCAT(succCntR,'(',succRtR,'%)') AS succCntR,
fbSndCntS, CONCAT(fbSuccCntS,'(',succFbRtS,'%)') AS fbSuccCntS,
fbSndCntL, CONCAT(fbSuccCntL,'(',succFbRtL,'%)') AS fbSuccCntL,
fbSndCntM, CONCAT(fbSuccCntM,'(',succFbRtM,'%)') AS fbSuccCntM
FROM
hubez_common.EZ_WEB_MSG ewm
INNER JOIN hubez_common.EZ_SVC_USER esu ON ewm.USER_SEQ = esu.USER_SEQ
(
SELECT
DATE_FORMAT(A.SUM_YMD, '%Y-%m-%d') AS sumYmd, C.CUST_NM AS custNm, C.BIZRNO AS bizrno,
A.sndCnt, A.succCnt, IFNULL(ROUND((A.succCnt/A.sndCnt)*100,2),0) AS succRt,
A.sndCntS, A.succCntS, IFNULL(ROUND((A.succCntS/A.sndCntS)*100,2),0) AS succRtS,
A.sndCntL, A.succCntL, IFNULL(ROUND((A.succCntL/A.sndCntL)*100,2),0) AS succRtL,
A.sndCntM, A.succCntM, IFNULL(ROUND((A.succCntM/A.sndCntM)*100,2),0) AS succRtM,
A.sndCntR, A.succCntR, IFNULL(ROUND((A.succCntR/A.sndCntR)*100,2),0) AS succRtR,
A.fbSndCntS, A.fbSuccCntS, IFNULL(ROUND((A.fbSuccCntS/A.fbSndCntS)*100,2),0) AS succFbRtS,
A.fbSndCntL, A.fbSuccCntL, IFNULL(ROUND((A.fbSuccCntL/A.fbSndCntL)*100,2),0) AS succFbRtL,
A.fbSndCntM, A.fbSuccCntM, IFNULL(ROUND((A.fbSuccCntM/A.fbSndCntM)*100,2),0) AS succFbRtM
FROM
(
SELECT
S1.SUM_YMD, S1.USER_SEQ,
(SUM(S1.sndCntS) + SUM(S1.sndCntL) + SUM(S1.sndCntM) + SUM(S1.sndCntR)) AS sndCnt,
(SUM(S1.succCntS) + SUM(S1.succCntL) +SUM(S1.succCntM) +SUM(S1.succCntR) + SUM(fbSuccCntS) + SUM(fbSuccCntL)+ SUM(fbSuccCntM)) AS succCnt,
SUM(S1.sndCntS) AS sndCntS, SUM(S1.succCntS) AS succCntS, SUM(S1.sndCntL) AS sndCntL, SUM(S1.succCntL) AS succCntL, SUM(S1.sndCntM) AS sndCntM,
SUM(S1.succCntM) AS succCntM, SUM(S1.sndCntR) AS sndCntR, SUM(S1.succCntR) AS succCntR, SUM(S1.fbSndCntS) AS fbSndCntS, SUM(S1.fbSuccCntS) AS fbSuccCntS,
SUM(S1.fbSndCntL) AS fbSndCntL, SUM(S1.fbSuccCntL) AS fbSuccCntL, SUM(S1.fbSndCntM) AS fbSndCntM, SUM(S1.fbSuccCntM) AS fbSuccCntM
FROM
(
SELECT
SUM_YMD, USER_SEQ,
CASE WHEN SND_CH_CD = 'SMS' THEN IFNULL(SND_CNT, 0) ELSE 0 END AS sndCntS,
CASE WHEN SND_CH_CD = 'SMS' THEN IFNULL(SUCC_CNT, 0) ELSE 0 END AS succCntS,
CASE WHEN SND_CH_CD = 'LMS' THEN IFNULL(SND_CNT, 0) ELSE 0 END AS sndCntL,
CASE WHEN SND_CH_CD = 'LMS' THEN IFNULL(SUCC_CNT, 0) ELSE 0 END AS succCntL,
CASE WHEN SND_CH_CD = 'MMS' THEN IFNULL(SND_CNT, 0) ELSE 0 END AS sndCntM,
CASE WHEN SND_CH_CD = 'MMS' THEN IFNULL(SUCC_CNT, 0) ELSE 0 END AS succCntM,
CASE WHEN SND_CH_CD = 'ALIMTALK' THEN IFNULL(SND_CNT, 0) ELSE 0 END AS sndCntR,
CASE WHEN SND_CH_CD = 'ALIMTALK' THEN IFNULL(SUCC_CNT, 0) ELSE 0 END AS succCntR,
CASE WHEN RPLCSND_CH_CD = 'SMS' THEN IFNULL(FBACK_CNT, 0) ELSE 0 END AS fbSndCntS,
CASE WHEN RPLCSND_CH_CD = 'SMS' THEN IFNULL(FBACK_SUCC_CNT, 0) ELSE 0 END AS fbSuccCntS,
CASE WHEN RPLCSND_CH_CD = 'LMS' THEN IFNULL(FBACK_CNT, 0) ELSE 0 END AS fbSndCntL,
CASE WHEN RPLCSND_CH_CD = 'LMS' THEN IFNULL(FBACK_SUCC_CNT, 0) ELSE 0 END AS fbSuccCntL,
CASE WHEN RPLCSND_CH_CD = 'MMS' THEN IFNULL(FBACK_CNT, 0) ELSE 0 END AS fbSndCntM,
CASE WHEN RPLCSND_CH_CD = 'MMS' THEN IFNULL(FBACK_SUCC_CNT, 0) ELSE 0 END AS fbSuccCntM
FROM
hubez_common.EZ_CUST_DSTAT
WHERE
SUM_YMD BETWEEN DATE_FORMAT(#{startDay},'%Y%m%d') AND DATE_FORMAT(#{endDay},'%Y%m%d')
AND BIZRNO != '1234567890'
) S1
WHERE
1 = 1
AND DATE_FORMAT( #{endDay}, '%Y-%m-%d') = DATE_FORMAT( NOW(), '%Y-%m-%d')
AND DATE_FORMAT( ewm.REG_DT, '%Y-%m-%d') = DATE_FORMAT( NOW(), '%Y-%m-%d')
GROUP BY DATE_FORMAT(ewm.REG_DT, '%Y-%m-%d') , ewm.USER_SEQ
GROUP BY S1.SUM_YMD, S1.USER_SEQ
<if test='nowDiv == "Y"'>
UNION ALL
<!-- 추가분 (끝) -->
select SUM_YMD
, USER_SEQ
, BIZRNO
, CUST_NM
from (
select ecm.SUM_YMD
, ecm.USER_SEQ
, ecm.BIZRNO
, ecm.CUST_NM
from hubez_common.EZ_CUST_DSTAT ecm
where 1=1
AND SUM_YMD BETWEEN DATE_FORMAT(#{startDay},'%Y%m%d') AND DATE_FORMAT(#{endDay},'%Y%m%d')
<include refid="custDstatListCondition"/>
group by ecm.SUM_YMD , ecm.USER_SEQ
ORDER BY ecm.SUM_YMD DESC, ecm.USER_SEQ
) list
) t1 inner join (
select SUM_YMD
, USER_SEQ
, sum(smsSndCnt) AS sndCntS
, sum(smsSuccCnt) AS succCntS
, sum(smsSuccRt) AS succRtS
, sum(lmsSndCnt) AS sndCntL
, sum(lmsSuccCnt) AS succCntL
, sum(lmsSuccRt) AS succRtL
, sum(mmsSndCnt) AS sndCntM
, sum(mmsSuccCnt) AS succCntM
, sum(mmsSuccRt) AS succRtM
, sum(alimtSndCnt) AS sndCntR
, sum(alimtSuccCnt) AS succCntR
, sum(alimtSuccRt) AS succRtR
from (
select SUM_YMD
, USER_SEQ
, case when sndChCd = 'SMS' then SUM(SND_CNT) + SUM(FBACK_CNT)
else 0
end as smsSndCnt
, case when sndChCd = 'SMS' then SUM(SUCC_CNT) + SUM(FBACK_SUCC_CNT)
else 0
end as smsSuccCnt
, case when sndChCd = 'SMS' then TRUNCATE((SUM(SUCC_CNT) + SUM(FBACK_SUCC_CNT)) / (SUM(SND_CNT) + SUM(FBACK_CNT)) * 100, 2)
else 0
end as smsSuccRt
, case when sndChCd = 'LMS' then SUM(SND_CNT) + SUM(FBACK_CNT)
else 0
end as lmsSndCnt
, case when sndChCd = 'LMS' then SUM(SUCC_CNT) + SUM(FBACK_SUCC_CNT)
else 0
end as lmsSuccCnt
, case when sndChCd = 'LMS' then TRUNCATE((SUM(SUCC_CNT) + SUM(FBACK_SUCC_CNT)) / (SUM(SND_CNT) + SUM(FBACK_CNT)) * 100, 2)
else 0
end as lmsSuccRt
, case when sndChCd = 'MMS' then SUM(SND_CNT) + SUM(FBACK_CNT)
else 0
end as mmsSndCnt
, case when sndChCd = 'MMS' then SUM(SUCC_CNT) + SUM(FBACK_SUCC_CNT)
else 0
end as mmsSuccCnt
, case when sndChCd = 'MMS' then TRUNCATE((SUM(SUCC_CNT) + SUM(FBACK_SUCC_CNT)) / (SUM(SND_CNT) + SUM(FBACK_CNT)) * 100, 2)
else 0
end as mmsSuccRt
, case when sndChCd = 'ALIMTALK' then SUM(SND_CNT) + SUM(FBACK_CNT)
else 0
end as alimtSndCnt
, case when sndChCd = 'ALIMTALK' then SUM(SUCC_CNT) + SUM(FBACK_SUCC_CNT)
else 0
end as alimtSuccCnt
, case when sndChCd = 'ALIMTALK' then TRUNCATE((SUM(SUCC_CNT) + SUM(FBACK_SUCC_CNT)) / (SUM(SND_CNT) + SUM(FBACK_CNT)) * 100, 2)
else 0
end as alimtSuccRt
from (
<!-- 추가분 (시작) -->
SELECT
DATE_FORMAT(ewm.REG_DT , '%Y-%m-%d') AS SUM_YMD
,ewm.USER_SEQ
,REPLACE (ewm.CH_STR ,'KKO_NOTI', 'ALIMTALK') AS sndChCd
,SUM(IFNULL(ewm.SEND_CNT, 0)) AS SND_CNT
,SUM(IFNULL(ewm.SUCC_CNT, 0)) AS SUCC_CNT
,SUM(IFNULL(ewm.FAIL_CNT, 0)) AS FAIL_CNT
,SUM(IFNULL(ewm.FB_SUCC_CNT , 0)) + SUM(IFNULL(ewm.FB_FAIL_CNT, 0)) AS FBACK_CNT
,SUM(IFNULL(ewm.FB_SUCC_CNT, 0)) AS FBACK_SUCC_CNT
,SUM(IFNULL(ewm.FB_FAIL_CNT, 0)) AS FBACK_FAIL_CNT
S2.SUM_YMD, S2.USER_SEQ,
(SUM(S2.sndCntS) + SUM(S2.sndCntL) + SUM(S2.sndCntM) + SUM(S2.sndCntR)) AS sndCnt,
(SUM(S2.succCntS) + SUM(S2.succCntL) +SUM(S2.succCntM) +SUM(S2.succCntR) + SUM(fbSuccCntS) + SUM(fbSuccCntL)+ SUM(fbSuccCntM)) AS succCnt,
SUM(S2.sndCntS) AS sndCntS, SUM(S2.succCntS) AS succCntS, SUM(S2.sndCntL) AS sndCntL, SUM(S2.succCntL) AS succCntL, SUM(S2.sndCntM) AS sndCntM,
SUM(S2.succCntM) AS succCntM, SUM(S2.sndCntR) AS sndCntR, SUM(S2.succCntR) AS succCntR, SUM(S2.fbSndCntS) AS fbSndCntS, SUM(S2.fbSuccCntS) AS fbSuccCntS,
SUM(S2.fbSndCntL) AS fbSndCntL, SUM(S2.fbSuccCntL) AS fbSuccCntL, SUM(S2.fbSndCntM) AS fbSndCntM, SUM(S2.fbSuccCntM) AS fbSuccCntM
FROM
hubez_common.EZ_WEB_MSG ewm
(
SELECT
SUM_YMD, USER_SEQ,
CASE WHEN SND_CH_CD = 'SMS' THEN SUM(SND_CNT) ELSE 0 END AS sndCntS,
CASE WHEN SND_CH_CD = 'SMS' THEN SUM(SUCC_CNT) ELSE 0 END AS succCntS,
CASE WHEN SND_CH_CD = 'LMS' THEN SUM(SND_CNT) ELSE 0 END AS sndCntL,
CASE WHEN SND_CH_CD = 'LMS' THEN SUM(SUCC_CNT) ELSE 0 END AS succCntL,
CASE WHEN SND_CH_CD = 'MMS' THEN SUM(SND_CNT) ELSE 0 END AS sndCntM,
CASE WHEN SND_CH_CD = 'MMS' THEN SUM(SUCC_CNT) ELSE 0 END AS succCntM,
CASE WHEN SND_CH_CD = 'ALIMTALK' THEN SUM(SND_CNT) ELSE 0 END AS sndCntR,
CASE WHEN SND_CH_CD = 'ALIMTALK' THEN SUM(SUCC_CNT) ELSE 0 END AS succCntR,
CASE WHEN SND_CH_CD = 'SMS' THEN SUM(FBACK_CNT) ELSE 0 END AS fbSndCntS,
CASE WHEN SND_CH_CD = 'SMS' THEN SUM(FBACK_SUCC_CNT) ELSE 0 END AS fbSuccCntS,
CASE WHEN SND_CH_CD = 'LMS' THEN SUM(FBACK_CNT) ELSE 0 END AS fbSndCntL,
CASE WHEN SND_CH_CD = 'LMS' THEN SUM(FBACK_SUCC_CNT) ELSE 0 END AS fbSuccCntL,
CASE WHEN SND_CH_CD = 'MMS' THEN SUM(FBACK_CNT) ELSE 0 END AS fbSndCntM,
CASE WHEN SND_CH_CD = 'MMS' THEN SUM(FBACK_SUCC_CNT) ELSE 0 END AS fbSuccCntM
FROM
(
SELECT
DATE_FORMAT(ewm.YMD, '%Y-%m-%d') AS SUM_YMD,
esu.PRNTS_USER_SEQ AS USER_SEQ,
REPLACE (ewm.CH_STR ,'KKO_NOTI', 'ALIMTALK') AS SND_CH_CD,
SUM(IFNULL(ewm.SEND_CNT, 0)) AS SND_CNT,
SUM(IFNULL(ewm.SUCC_CNT, 0)) AS SUCC_CNT,
0 AS FBACK_CNT,
0 AS FBACK_SUCC_CNT
FROM
hubez_common.EZ_WEB_MSG ewm INNER JOIN
hubez_common.EZ_SVC_USER esu ON ewm.USER_SEQ = esu.USER_SEQ
WHERE
ewm.YMD = DATE_FORMAT( NOW(), '%Y-%m-%d')
GROUP BY ewm.YMD, esu.PRNTS_USER_SEQ, ewm.CH_STR
UNION ALL
SELECT
DATE_FORMAT(ewm.YMD, '%Y-%m-%d') AS SUM_YMD,
esu.PRNTS_USER_SEQ AS USER_SEQ,
FB_CH_STR AS SND_CH_CD,
0 AS SND_CNT,
0 AS SUCC_CNT,
SUM(IFNULL(ewm.FB_SUCC_CNT + ewm.FB_FAIL_CNT, 0)) AS FBACK_CNT,
SUM(IFNULL(ewm.FB_SUCC_CNT, 0)) AS FBACK_SUCC_CNT
FROM
hubez_common.EZ_WEB_MSG ewm INNER JOIN
hubez_common.EZ_SVC_USER esu ON ewm.USER_SEQ = esu.USER_SEQ
WHERE
ewm.YMD = DATE_FORMAT( NOW(), '%Y-%m-%d')
AND (FB_SUCC_CNT > 0 OR FB_FAIL_CNT > 0)
GROUP BY ewm.YMD, esu.PRNTS_USER_SEQ, ewm.FB_CH_STR
) T1
WHERE
1 = 1
AND DATE_FORMAT( #{endDay}, '%Y-%m-%d') = DATE_FORMAT( NOW(), '%Y-%m-%d')
AND DATE_FORMAT( ewm.REG_DT, '%Y-%m-%d') = DATE_FORMAT( NOW(), '%Y-%m-%d')
GROUP BY
DATE_FORMAT(ewm.REG_DT, '%Y-%m-%d'), ewm.USER_SEQ , ewm.CH_STR
UNION ALL
<!-- 추가분 (끝) -->
select ecm.SUM_YMD, ecm.USER_SEQ, SND_CH_CD as sndChCd
, ifnull(sum(SND_CNT) , 0) as SND_CNT
, ifnull(sum(SUCC_CNT) , 0) as SUCC_CNT
, ifnull(sum(FAIL_CNT) , 0) as FAIL_CNT
, 0 as FBACK_CNT
, 0 as FBACK_SUCC_CNT
, 0 as FBACK_FAIL_CNT
from hubez_common.EZ_CUST_DSTAT ecm
inner join (
select SUM_YMD
, USER_SEQ
from (
select ecm.SUM_YMD
, ecm.USER_SEQ
from hubez_common.EZ_CUST_DSTAT ecm
where 1=1
AND SUM_YMD BETWEEN DATE_FORMAT(#{startDay},'%Y%m%d') AND DATE_FORMAT(#{endDay},'%Y%m%d')
<include refid="custDstatListCondition"/>
group by ecm.SUM_YMD , ecm.USER_SEQ
ORDER BY ecm.SUM_YMD DESC , ecm.USER_SEQ
) list
) list
on list.SUM_YMD = ecm.SUM_YMD and list.USER_SEQ = ecm.USER_SEQ
where ecm.SUM_YMD BETWEEN DATE_FORMAT(#{startDay},'%Y%m%d') AND DATE_FORMAT(#{endDay},'%Y%m%d')
group by ecm.SUM_YMD , ecm.USER_SEQ, SND_CH_CD
union all
select ecm.SUM_YMD, ecm.USER_SEQ, ecm.RPLCSND_CH_CD as sndChCd
, 0 as SND_CNT
, 0 as SUCC_CNT
, 0 as FAIL_CNT
, ifnull(sum(FBACK_CNT) , 0) as FBACK_CNT
, ifnull(sum(FBACK_SUCC_CNT) , 0) as FBACK_SUCC_CNT
, ifnull(sum(FBACK_FAIL_CNT) , 0) as FBACK_FAIL_CNT
from hubez_common.EZ_CUST_DSTAT ecm
inner join (
select SUM_YMD
, USER_SEQ
from (
select ecm.SUM_YMD
, ecm.USER_SEQ
from hubez_common.EZ_CUST_DSTAT ecm
where 1=1
AND SUM_YMD BETWEEN DATE_FORMAT(#{startDay},'%Y%m%d') AND DATE_FORMAT(#{endDay},'%Y%m%d')
<include refid="custDstatListCondition"/>
group by ecm.SUM_YMD , ecm.USER_SEQ
ORDER BY ecm.SUM_YMD DESC, ecm.USER_SEQ
) list
) list
on list.SUM_YMD = ecm.SUM_YMD and list.USER_SEQ = ecm.USER_SEQ
where ecm.SUM_YMD BETWEEN DATE_FORMAT(#{startDay},'%Y%m%d') AND DATE_FORMAT(#{endDay},'%Y%m%d')
and RPLCSND_CH_CD in ('SMS', 'LMS', 'MMS', 'ALIMTALK')
group by ecm.SUM_YMD, ecm.USER_SEQ, ecm.RPLCSND_CH_CD
) t1 group by SUM_YMD, USER_SEQ, sndChCd order by null
) t2 group by SUM_YMD, USER_SEQ order by null
) t2 on t2.SUM_YMD = t1.SUM_YMD and t2.USER_SEQ = t1.USER_SEQ
WHERE 1=1
GROUP BY SUM_YMD, USER_SEQ, SND_CH_CD
) S2
WHERE
1 = 1
GROUP BY S2.SUM_YMD, S2.USER_SEQ
</if>
) A,
hubez_common.EZ_SUBS_INFO B,
hubez_common.EZ_CUST_INFO C
WHERE
A.USER_SEQ = B.USER_SEQ
AND B.CUST_SEQ = C.CUST_SEQ
AND C.BIZRNO != '1234567890'
<include refid="custMstatListCondition"/>
GROUP BY t1.BIZRNO, t1.SUM_YMD
order by SUM_YMD DESC, t1.USER_SEQ
ORDER BY A.SUM_YMD DESC, C.CUST_NM
) M
WHERE
1 = 1
ORDER BY M.sumYmd DESC, M.custNm
</select>
<sql id="custMstatListCondition">