사용자 월별 통계 쿼리 변경

This commit is contained in:
kubo8
2022-12-22 09:10:21 +09:00
parent e34376857c
commit 7fa89eac5a
5 changed files with 255 additions and 183 deletions

View File

@@ -4,12 +4,11 @@ import kr.co.uplus.ez.api.stats.dto.*;
import kr.co.uplus.ez.common.data.ApiResponseCode; import kr.co.uplus.ez.common.data.ApiResponseCode;
import kr.co.uplus.ez.common.data.ApiResponseMessage; import kr.co.uplus.ez.common.data.ApiResponseMessage;
import kr.co.uplus.ez.common.data.Paging; import kr.co.uplus.ez.common.data.Paging;
import kr.co.uplus.ez.common.utils.DateUtils;
import org.mybatis.spring.SqlSessionTemplate; import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -145,6 +144,11 @@ public class StatsService {
StatsMapper statsMapper = sqlSessionSlave.getMapper(StatsMapper.class); StatsMapper statsMapper = sqlSessionSlave.getMapper(StatsMapper.class);
//오늘 날짜 조회인지 확인
if(DateUtils.date2strYM().equals(bsnmMonthListReqDto.getEndMon())) {
bsnmMonthListReqDto.setNowDiv("Y");
}
String nowPage = String.valueOf(bsnmMonthListReqDto.getPage()); String nowPage = String.valueOf(bsnmMonthListReqDto.getPage());
int totalCnt = statsMapper.selectCustMstatListTotalCnt(bsnmMonthListReqDto); int totalCnt = statsMapper.selectCustMstatListTotalCnt(bsnmMonthListReqDto);
@@ -189,6 +193,11 @@ public class StatsService {
public BsnmMonthListExcelResDto bsnmMonthListExcel(BsnmMonthListExcelReqDto bsnmMonthListExcelReqDto) { public BsnmMonthListExcelResDto bsnmMonthListExcel(BsnmMonthListExcelReqDto bsnmMonthListExcelReqDto) {
StatsMapper statsMapper = sqlSessionSlave.getMapper(StatsMapper.class); StatsMapper statsMapper = sqlSessionSlave.getMapper(StatsMapper.class);
//오늘 날짜 조회인지 확인
if(DateUtils.date2strYM().equals(bsnmMonthListExcelReqDto.getEndMon())) {
bsnmMonthListExcelReqDto.setNowDiv("Y");
}
List<BsnmMonthList> bsnmMonthLists = statsMapper.selectCustMstatExcelList(bsnmMonthListExcelReqDto); List<BsnmMonthList> bsnmMonthLists = statsMapper.selectCustMstatExcelList(bsnmMonthListExcelReqDto);
BsnmMonthListExcelRes bsnmMonthListExcelRes = new BsnmMonthListExcelRes(); BsnmMonthListExcelRes bsnmMonthListExcelRes = new BsnmMonthListExcelRes();

View File

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

View File

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

View File

@@ -13,6 +13,7 @@ public class DateUtils {
private static final String DF_FORMAT_STR = "yyyy-MM-dd HH:mm:ss"; private static final String DF_FORMAT_STR = "yyyy-MM-dd HH:mm:ss";
private static final String DF_YMD_FORMAT_STR = "yyyy-MM-dd"; private static final String DF_YMD_FORMAT_STR = "yyyy-MM-dd";
private static final DateTimeFormatter YMD = DateTimeFormat.forPattern("yyyyMMdd"); private static final DateTimeFormatter YMD = DateTimeFormat.forPattern("yyyyMMdd");
private static final DateTimeFormatter YM = DateTimeFormat.forPattern("yyyyMM");
private static final DateTimeFormatter YMDHMS = DateTimeFormat.forPattern("yyyyMMddHHmmss"); private static final DateTimeFormatter YMDHMS = DateTimeFormat.forPattern("yyyyMMddHHmmss");
private static final DateTimeFormatter dfFormat = DateTimeFormat.forPattern(DF_FORMAT_STR); private static final DateTimeFormatter dfFormat = DateTimeFormat.forPattern(DF_FORMAT_STR);
@@ -37,6 +38,10 @@ public class DateUtils {
return dtime2str(DateTime.now(), YMD); return dtime2str(DateTime.now(), YMD);
} }
public static String date2strYM() {
return dtime2str(DateTime.now(), YM);
}
public static String date2strYMDHMS() { public static String date2strYMDHMS() {
return dtime2str(DateTime.now(), YMDHMS); return dtime2str(DateTime.now(), YMDHMS);
} }

View File

@@ -546,107 +546,52 @@
<select id="selectCustMstatListTotalCnt" parameterType="kr.co.uplus.ez.api.stats.dto.BsnmMonthList" resultType="int"> <select id="selectCustMstatListTotalCnt" parameterType="kr.co.uplus.ez.api.stats.dto.BsnmMonthList" resultType="int">
/* stats-mapper.xml(selectCustMstatListTotalCnt) */ /* stats-mapper.xml(selectCustMstatListTotalCnt) */
SELECT SELECT
COUNT(S1.SUM_YM) AS TOTALCNT COUNT(A.SUM_YM) AS TOTALCNT
FROM FROM
( (
SELECT SELECT
SUM_YM, USER_SEQ S1.SUM_YM, 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 FROM
( (
SELECT SELECT
SUM_YM, SUM_YM, USER_SEQ,
USER_SEQ, CASE WHEN SND_CH_CD = 'SMS' THEN IFNULL(SND_CNT, 0) ELSE 0 END AS sndCntS,
SND_CH_CD, CASE WHEN SND_CH_CD = 'SMS' THEN IFNULL(SUCC_CNT, 0) ELSE 0 END AS succCntS,
IFNULL(SUM(SND_CNT), 0) AS SND_CNT, CASE WHEN SND_CH_CD = 'LMS' THEN IFNULL(SND_CNT, 0) ELSE 0 END AS sndCntL,
IFNULL(SUM(SUCC_CNT), 0) AS SUCC_CNT, CASE WHEN SND_CH_CD = 'LMS' THEN IFNULL(SUCC_CNT, 0) ELSE 0 END AS succCntL,
0 AS FBACK_CNT, CASE WHEN SND_CH_CD = 'MMS' THEN IFNULL(SND_CNT, 0) ELSE 0 END AS sndCntM,
0 AS FBACK_SUCC_CNT 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 FROM
hubez_common.EZ_CUST_MSTAT hubez_common.EZ_CUST_MSTAT
WHERE WHERE
SUM_YM BETWEEN STR_TO_DATE(CONCAT(#{startMon},'01'),'%Y%m%d') AND STR_TO_DATE(CONCAT(#{endMon},'01'),'%Y%m%d') SUM_YM BETWEEN STR_TO_DATE(CONCAT(#{startMon},'01'),'%Y%m%d') AND STR_TO_DATE(CONCAT(#{endMon},'01'),'%Y%m%d')
GROUP BY SUM_YM, USER_SEQ, SND_CH_CD AND BIZRNO != '1234567890'
UNION ALL ) S1
SELECT
SUM_YM,
USER_SEQ,
RPLCSND_CH_CD AS SND_CH_CD,
0 AS SND_CNT,
0 AS SUCC_CNT,
IFNULL(SUM(FBACK_CNT), 0) AS FBACK_CNT,
IFNULL(SUM(FBACK_SUCC_CNT), 0) AS FBACK_SUCC_CNT
FROM
hubez_common.EZ_CUST_MSTAT
WHERE
SUM_YM BETWEEN STR_TO_DATE(CONCAT(#{startMon},'01'),'%Y%m%d') AND STR_TO_DATE(CONCAT(#{endMon},'01'),'%Y%m%d')
AND RPLCSND_CH_CD IN ('SMS', 'LMS', 'MMS')
GROUP BY SUM_YM, USER_SEQ, RPLCSND_CH_CD
UNION ALL
SELECT
DATE_FORMAT(ewm.YMD, '%Y-%m-01') AS SUM_YM,
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 BETWEEN DATE_FORMAT( NOW(), '%Y-%m-01') AND 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-01') AS SUM_YM,
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 BETWEEN DATE_FORMAT( NOW(), '%Y-%m-01') AND 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 WHERE
1 = 1 1 = 1
GROUP BY SUM_YM, USER_SEQ GROUP BY S1.SUM_YM, S1.USER_SEQ
) S1, <if test='nowDiv == "Y"'>
hubez_common.EZ_SUBS_INFO S2, UNION ALL
hubez_common.EZ_CUST_INFO S3
WHERE
S1.USER_SEQ = S2.USER_SEQ
AND S2.CUST_SEQ = S3.CUST_SEQ
AND S3.BIZRNO != '1234567890'
<include refid="custMstatListCondition"/>
</select>
<select id="selectCustMstatList" parameterType="kr.co.uplus.ez.api.stats.dto.BsnmMonthList" resultType="kr.co.uplus.ez.api.stats.dto.BsnmMonthList">
/* stats-mapper.xml(selectCustMstatList) */
SELECT
DATE_FORMAT(S1.SUM_YM, '%Y-%m') AS sumYm, S3.CUST_NM AS custNm, S3.BIZRNO AS bizrno,
(S1.sndCntS + S1.sndCntL + S1.sndCntM + S1.sndCntR) AS sndCnt,
(S1.succCntS + S1.succCntL +S1.succCntM +S1.succCntR + fbSuccCntS + fbSuccCntL+ fbSuccCntM) AS succCnt,
IFNULL(ROUND(((S1.succCntS + S1.succCntL +S1.succCntM +S1.succCntR + fbSuccCntS + fbSuccCntL+ fbSuccCntM) / (S1.sndCntS + S1.sndCntL + S1.sndCntM + S1.sndCntR)) * 100, 2), 0) AS succRt,
S1.sndCntS, S1.succCntS, IFNULL(ROUND((S1.succCntS/S1.sndCntS)*100,2),0) AS succRtS,
S1.sndCntL, S1.succCntL, IFNULL(ROUND((S1.succCntL/S1.sndCntL)*100,2),0) AS succRtL,
S1.sndCntM, S1.succCntM, IFNULL(ROUND((S1.succCntM/S1.sndCntM)*100,2),0) AS succRtM,
S1.sndCntR, S1.succCntR, IFNULL(ROUND((S1.succCntR/S1.sndCntR)*100,2),0) AS succRtR,
S1.fbSndCntS, S1.fbSuccCntS, IFNULL(ROUND((S1.fbSuccCntS/S1.fbSndCntS)*100,2),0) AS succFbRtS,
S1.fbSndCntL, S1.fbSuccCntL, IFNULL(ROUND((S1.fbSuccCntL/S1.fbSndCntL)*100,2),0) AS succFbRtL,
S1.fbSndCntM, S1.fbSuccCntM, IFNULL(ROUND((S1.fbSuccCntM/S1.fbSndCntM)*100,2),0) AS succFbRtM
FROM
(
SELECT SELECT
SUM_YM, USER_SEQ, S2.SUM_YM, S2.USER_SEQ,
SUM(sndCntS) AS sndCntS, SUM(succCntS) AS succCntS, SUM(sndCntL) AS sndCntL, SUM(succCntL) AS succCntL, SUM(sndCntM) AS sndCntM, (SUM(S2.sndCntS) + SUM(S2.sndCntL) + SUM(S2.sndCntM) + SUM(S2.sndCntR)) AS sndCnt,
SUM(succCntM) AS succCntM, SUM(sndCntR) AS sndCntR, SUM(succCntR) AS succCntR, SUM(fbSndCntS) AS fbSndCntS, SUM(fbSuccCntS) AS fbSuccCntS, (SUM(S2.succCntS) + SUM(S2.succCntL) +SUM(S2.succCntM) +SUM(S2.succCntR) + SUM(fbSuccCntS) + SUM(fbSuccCntL)+ SUM(fbSuccCntM)) AS succCnt,
SUM(fbSndCntL) AS fbSndCntL, SUM(fbSuccCntL) AS fbSuccCntL, SUM(fbSndCntM) AS fbSndCntM, SUM(fbSuccCntM) AS fbSuccCntM 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 FROM
( (
SELECT SELECT
@@ -667,35 +612,6 @@
CASE WHEN SND_CH_CD = 'MMS' THEN SUM(FBACK_SUCC_CNT) ELSE 0 END AS fbSuccCntM CASE WHEN SND_CH_CD = 'MMS' THEN SUM(FBACK_SUCC_CNT) ELSE 0 END AS fbSuccCntM
FROM FROM
( (
SELECT
SUM_YM,
USER_SEQ,
SND_CH_CD,
IFNULL(SUM(SND_CNT), 0) AS SND_CNT,
IFNULL(SUM(SUCC_CNT), 0) AS SUCC_CNT,
0 AS FBACK_CNT,
0 AS FBACK_SUCC_CNT
FROM
hubez_common.EZ_CUST_MSTAT
WHERE
SUM_YM BETWEEN STR_TO_DATE(CONCAT(#{startMon},'01'),'%Y%m%d') AND STR_TO_DATE(CONCAT(#{endMon},'01'),'%Y%m%d')
GROUP BY SUM_YM, USER_SEQ, SND_CH_CD
UNION ALL
SELECT
SUM_YM,
USER_SEQ,
RPLCSND_CH_CD AS SND_CH_CD,
0 AS SND_CNT,
0 AS SUCC_CNT,
IFNULL(SUM(FBACK_CNT), 0) AS FBACK_CNT,
IFNULL(SUM(FBACK_SUCC_CNT), 0) AS FBACK_SUCC_CNT
FROM
hubez_common.EZ_CUST_MSTAT
WHERE
SUM_YM BETWEEN STR_TO_DATE(CONCAT(#{startMon},'01'),'%Y%m%d') AND STR_TO_DATE(CONCAT(#{endMon},'01'),'%Y%m%d')
AND RPLCSND_CH_CD IN ('SMS', 'LMS', 'MMS')
GROUP BY SUM_YM, USER_SEQ, RPLCSND_CH_CD
UNION ALL
SELECT SELECT
DATE_FORMAT(ewm.YMD, '%Y-%m-01') AS SUM_YM, DATE_FORMAT(ewm.YMD, '%Y-%m-01') AS SUM_YM,
esu.PRNTS_USER_SEQ AS USER_SEQ, esu.PRNTS_USER_SEQ AS USER_SEQ,
@@ -730,19 +646,146 @@
WHERE WHERE
1 = 1 1 = 1
GROUP BY SUM_YM, USER_SEQ, SND_CH_CD GROUP BY SUM_YM, USER_SEQ, SND_CH_CD
) T2 ) S2
WHERE WHERE
1 = 1 1 = 1
GROUP BY SUM_YM, USER_SEQ GROUP BY S2.SUM_YM, S2.USER_SEQ
) S1, </if>
hubez_common.EZ_SUBS_INFO S2, ) A,
hubez_common.EZ_CUST_INFO S3 hubez_common.EZ_SUBS_INFO B,
hubez_common.EZ_CUST_INFO C
WHERE WHERE
S1.USER_SEQ = S2.USER_SEQ A.USER_SEQ = B.USER_SEQ
AND S2.CUST_SEQ = S3.CUST_SEQ AND B.CUST_SEQ = C.CUST_SEQ
AND S3.BIZRNO != '1234567890' AND C.BIZRNO != '1234567890'
<include refid="custMstatListCondition"/> <include refid="custMstatListCondition"/>
ORDER BY S1.SUM_YM DESC, S3.CUST_NM </select>
<select id="selectCustMstatList" parameterType="kr.co.uplus.ez.api.stats.dto.BsnmMonthList" resultType="kr.co.uplus.ez.api.stats.dto.BsnmMonthList">
/* stats-mapper.xml(selectCustMstatList) */
SELECT
DATE_FORMAT(A.SUM_YM, '%Y-%m') AS sumYm, 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_YM, 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_YM, 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_MSTAT
WHERE
SUM_YM BETWEEN STR_TO_DATE(CONCAT(#{startMon},'01'),'%Y%m%d') AND STR_TO_DATE(CONCAT(#{endMon},'01'),'%Y%m%d')
AND BIZRNO != '1234567890'
) S1
WHERE
1 = 1
GROUP BY S1.SUM_YM, S1.USER_SEQ
<if test='nowDiv == "Y"'>
UNION ALL
SELECT
S2.SUM_YM, 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
(
SELECT
SUM_YM, 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-01') AS SUM_YM,
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 BETWEEN DATE_FORMAT( NOW(), '%Y-%m-01') AND 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-01') AS SUM_YM,
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 BETWEEN DATE_FORMAT( NOW(), '%Y-%m-01') AND 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_YM, USER_SEQ, SND_CH_CD
) S2
WHERE
1 = 1
GROUP BY S2.SUM_YM, 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"/>
ORDER BY A.SUM_YM DESC, C.CUST_NM
LIMIT #{page}, #{pagePerRows} LIMIT #{page}, #{pagePerRows}
</select> </select>
@@ -761,24 +804,60 @@
FROM FROM
( (
SELECT SELECT
DATE_FORMAT(S1.SUM_YM, '%Y-%m') AS sumYm, S3.CUST_NM AS custNm, S3.BIZRNO AS bizrno, DATE_FORMAT(A.SUM_YM, '%Y-%m') AS sumYm, C.CUST_NM AS custNm, C.BIZRNO AS bizrno,
(S1.sndCntS + S1.sndCntL + S1.sndCntM + S1.sndCntR) AS sndCnt, A.sndCnt, A.succCnt, IFNULL(ROUND((A.succCnt/A.sndCnt)*100,2), 0) AS succRt,
(S1.succCntS + S1.succCntL +S1.succCntM +S1.succCntR + fbSuccCntS + fbSuccCntL+ fbSuccCntM) AS succCnt, A.sndCntS, A.succCntS, IFNULL(ROUND((A.succCntS/A.sndCntS)*100,2), 0) AS succRtS,
IFNULL(ROUND(((S1.succCntS + S1.succCntL +S1.succCntM +S1.succCntR + fbSuccCntS + fbSuccCntL+ fbSuccCntM) / (S1.sndCntS + S1.sndCntL + S1.sndCntM + S1.sndCntR)) * 100, 2), 0) AS succRt, A.sndCntL, A.succCntL, IFNULL(ROUND((A.succCntL/A.sndCntL)*100,2), 0) AS succRtL,
S1.sndCntS, S1.succCntS, IFNULL(ROUND((S1.succCntS/S1.sndCntS)*100,2),0) AS succRtS, A.sndCntM, A.succCntM, IFNULL(ROUND((A.succCntM/A.sndCntM)*100,2), 0) AS succRtM,
S1.sndCntL, S1.succCntL, IFNULL(ROUND((S1.succCntL/S1.sndCntL)*100,2),0) AS succRtL, A.sndCntR, A.succCntR, IFNULL(ROUND((A.succCntR/A.sndCntR)*100,2), 0) AS succRtR,
S1.sndCntM, S1.succCntM, IFNULL(ROUND((S1.succCntM/S1.sndCntM)*100,2),0) AS succRtM, A.fbSndCntS, A.fbSuccCntS, IFNULL(ROUND((A.fbSuccCntS/A.fbSndCntS)*100,2), 0) AS succFbRtS,
S1.sndCntR, S1.succCntR, IFNULL(ROUND((S1.succCntR/S1.sndCntR)*100,2),0) AS succRtR, A.fbSndCntL, A.fbSuccCntL, IFNULL(ROUND((A.fbSuccCntL/A.fbSndCntL)*100,2), 0) AS succFbRtL,
S1.fbSndCntS, S1.fbSuccCntS, IFNULL(ROUND((S1.fbSuccCntS/S1.fbSndCntS)*100,2),0) AS succFbRtS, A.fbSndCntM, A.fbSuccCntM, IFNULL(ROUND((A.fbSuccCntM/A.fbSndCntM)*100,2), 0) AS succFbRtM
S1.fbSndCntL, S1.fbSuccCntL, IFNULL(ROUND((S1.fbSuccCntL/S1.fbSndCntL)*100,2),0) AS succFbRtL,
S1.fbSndCntM, S1.fbSuccCntM, IFNULL(ROUND((S1.fbSuccCntM/S1.fbSndCntM)*100,2),0) AS succFbRtM
FROM FROM
( (
SELECT SELECT
SUM_YM, USER_SEQ, S1.SUM_YM, S1.USER_SEQ,
SUM(sndCntS) AS sndCntS, SUM(succCntS) AS succCntS, SUM(sndCntL) AS sndCntL, SUM(succCntL) AS succCntL, SUM(sndCntM) AS sndCntM, (SUM(S1.sndCntS) + SUM(S1.sndCntL) + SUM(S1.sndCntM) + SUM(S1.sndCntR)) AS sndCnt,
SUM(succCntM) AS succCntM, SUM(sndCntR) AS sndCntR, SUM(succCntR) AS succCntR, SUM(fbSndCntS) AS fbSndCntS, SUM(fbSuccCntS) AS fbSuccCntS, (SUM(S1.succCntS) + SUM(S1.succCntL) +SUM(S1.succCntM) +SUM(S1.succCntR) + SUM(fbSuccCntS) + SUM(fbSuccCntL)+ SUM(fbSuccCntM)) AS succCnt,
SUM(fbSndCntL) AS fbSndCntL, SUM(fbSuccCntL) AS fbSuccCntL, SUM(fbSndCntM) AS fbSndCntM, SUM(fbSuccCntM) AS fbSuccCntM 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_YM, 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_MSTAT
WHERE
SUM_YM BETWEEN STR_TO_DATE(CONCAT(#{startMon},'01'),'%Y%m%d') AND STR_TO_DATE(CONCAT(#{endMon},'01'),'%Y%m%d')
AND BIZRNO != '1234567890'
) S1
WHERE
1 = 1
GROUP BY S1.SUM_YM, S1.USER_SEQ
<if test='nowDiv == "Y"'>
UNION ALL
SELECT
S2.SUM_YM, 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 FROM
( (
SELECT SELECT
@@ -799,35 +878,6 @@
CASE WHEN SND_CH_CD = 'MMS' THEN SUM(FBACK_SUCC_CNT) ELSE 0 END AS fbSuccCntM CASE WHEN SND_CH_CD = 'MMS' THEN SUM(FBACK_SUCC_CNT) ELSE 0 END AS fbSuccCntM
FROM FROM
( (
SELECT
SUM_YM,
USER_SEQ,
SND_CH_CD,
IFNULL(SUM(SND_CNT), 0) AS SND_CNT,
IFNULL(SUM(SUCC_CNT), 0) AS SUCC_CNT,
0 AS FBACK_CNT,
0 AS FBACK_SUCC_CNT
FROM
hubez_common.EZ_CUST_MSTAT
WHERE
SUM_YM BETWEEN STR_TO_DATE(CONCAT(#{startMon},'01'),'%Y%m%d') AND STR_TO_DATE(CONCAT(#{endMon},'01'),'%Y%m%d')
GROUP BY SUM_YM, USER_SEQ, SND_CH_CD
UNION ALL
SELECT
SUM_YM,
USER_SEQ,
RPLCSND_CH_CD AS SND_CH_CD,
0 AS SND_CNT,
0 AS SUCC_CNT,
IFNULL(SUM(FBACK_CNT), 0) AS FBACK_CNT,
IFNULL(SUM(FBACK_SUCC_CNT), 0) AS FBACK_SUCC_CNT
FROM
hubez_common.EZ_CUST_MSTAT
WHERE
SUM_YM BETWEEN STR_TO_DATE(CONCAT(#{startMon},'01'),'%Y%m%d') AND STR_TO_DATE(CONCAT(#{endMon},'01'),'%Y%m%d')
AND RPLCSND_CH_CD IN ('SMS', 'LMS', 'MMS')
GROUP BY SUM_YM, USER_SEQ, RPLCSND_CH_CD
UNION ALL
SELECT SELECT
DATE_FORMAT(ewm.YMD, '%Y-%m-01') AS SUM_YM, DATE_FORMAT(ewm.YMD, '%Y-%m-01') AS SUM_YM,
esu.PRNTS_USER_SEQ AS USER_SEQ, esu.PRNTS_USER_SEQ AS USER_SEQ,
@@ -862,17 +912,18 @@
WHERE WHERE
1 = 1 1 = 1
GROUP BY SUM_YM, USER_SEQ, SND_CH_CD GROUP BY SUM_YM, USER_SEQ, SND_CH_CD
) T2 ) S2
WHERE WHERE
1 = 1 1 = 1
GROUP BY SUM_YM, USER_SEQ GROUP BY S2.SUM_YM, S2.USER_SEQ
) S1, </if>
hubez_common.EZ_SUBS_INFO S2, ) A,
hubez_common.EZ_CUST_INFO S3 hubez_common.EZ_SUBS_INFO B,
hubez_common.EZ_CUST_INFO C
WHERE WHERE
S1.USER_SEQ = S2.USER_SEQ A.USER_SEQ = B.USER_SEQ
AND S2.CUST_SEQ = S3.CUST_SEQ AND B.CUST_SEQ = C.CUST_SEQ
AND S3.BIZRNO != '1234567890' AND C.BIZRNO != '1234567890'
<include refid="custMstatListCondition"/> <include refid="custMstatListCondition"/>
) M ) M
WHERE WHERE