diff --git a/src/main/java/kr/co/uplus/ez/api/custMgt/CustMgtMapper.java b/src/main/java/kr/co/uplus/ez/api/custMgt/CustMgtMapper.java
index 3b71d1f..75c277e 100644
--- a/src/main/java/kr/co/uplus/ez/api/custMgt/CustMgtMapper.java
+++ b/src/main/java/kr/co/uplus/ez/api/custMgt/CustMgtMapper.java
@@ -3,13 +3,9 @@ package kr.co.uplus.ez.api.custMgt;
import kr.co.uplus.ez.api.custMgt.dto.*;
import kr.co.uplus.ez.common.data.ImUser;
import org.apache.ibatis.annotations.Mapper;
-
-import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
-import javax.validation.Valid;
-
@Mapper
public interface CustMgtMapper {
@@ -126,7 +122,7 @@ public interface CustMgtMapper {
String getChrgSeq();
/**충전관리 등록 */
- void insertChrgInfo(ChrgInfo chrgInfo);
+ int insertChrgInfo(ChrgInfo chrgInfo);
/**충전관리 수정 */
void updateChrg(UpdateChrgReqDto updateChrgReqDto);
/**충전관리 수정후 등록 */
@@ -134,13 +130,12 @@ public interface CustMgtMapper {
/**충전관리 삭제 */
void deleteChrg(DeleteChrgReqDto deleteChrgReqDto);
int updateChrgAmt(ChrgAmtDto chrgAmtDto);
- BigDecimal selectChargeAmt(@Valid TargetSubsInfoDto targetUserLimit);
- void insertWebMsgCli(WebMsgCliDto ezMsgDto);
- String selectNotiSeq();
- void insertNotiHst(NotiHistDto notihist);
-
-
+ SvcUserInfo selectUserInfo(String register);
+ public String selectSequence(String seqKey);
+ public String selectNotiSeq(); //알림이련seq
+ void insertWebMsgCli(WebMsgCliDto params);
+ void insertNotiHst(NotiHistDto params);
//2023-03-07 add request 부분
diff --git a/src/main/java/kr/co/uplus/ez/api/custMgt/CustMgtService.java b/src/main/java/kr/co/uplus/ez/api/custMgt/CustMgtService.java
index 448313a..63171c3 100644
--- a/src/main/java/kr/co/uplus/ez/api/custMgt/CustMgtService.java
+++ b/src/main/java/kr/co/uplus/ez/api/custMgt/CustMgtService.java
@@ -3,10 +3,11 @@ package kr.co.uplus.ez.api.custMgt;
import kr.co.uplus.ez.api.custMgt.dto.*;
import kr.co.uplus.ez.common.components.HubeasyApiComponents;
import kr.co.uplus.ez.common.data.*;
+import kr.co.uplus.ez.common.utils.CommonUtils;
+import kr.co.uplus.ez.common.utils.DateUtil;
import kr.co.uplus.ez.common.utils.DateUtils;
import kr.co.uplus.ez.common.utils.EncryptionUtil;
import kr.co.uplus.ez.common.utils.TextUtils;
-
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.mybatis.spring.SqlSessionTemplate;
@@ -121,21 +122,9 @@ public class CustMgtService {
@Value("${mail.templeteCode:E0005}")
private String templeteCode;
- /* 테이블명 */
- public static class TableName {
- public static final String EZ_MSG_NORMAL = "EZ_MSG_NORMAL"; //일반
- public static final String EZ_MSG_REAL = "EZ_MSG_REAL"; //실시간보장
- public static final String EZ_MSG_BATCH = "EZ_MSG_BATCH"; //예약
- }
-
- /* 라인유형 */
- public static class LineTpCd {
- public static final String LINE_TP_NORMAL = "normal"; //일반
- public static final String LINE_TP_REAL = "real"; //실시간보장
- public static final String LINE_TP_BATCH = "batch"; //예약
- }
-
- public static final String SND_CH_LMS = "LMS";
+ public static final String YEAR_MONTH_DAY = "yyyyMMdd";
+ public static final String WEB_REQ_ID = "WEB_REQ_ID";
+
/**
* date : 2022. 4. 25. auth : ckr desc : 청약 고객 정보 목록 조회
@@ -1103,34 +1092,31 @@ public class CustMgtService {
* @param paramMap
* @return
*/
- public InsertChrgResDto InsertChrg(@Valid InsertChrgReqDto insertChrgReqDto) {
+ @Transactional(value="db1TransactionManager")
+ public InsertChrgResDto InsertChrg(@Valid InsertChrgReqDto insertChrgReqDto){
CustMgtMapper custMgtMapper = sqlSessionMaster.getMapper(CustMgtMapper.class);
-// // 1. 사용자 유무 확인
+ int resultcnt = 0;
+
+ // 1. 사용자 유무 확인
int getUserIdCount = custMgtMapper.getUserIdCount(insertChrgReqDto.getUserId());
if (getUserIdCount < 1) {
return new InsertChrgResDto(ApiResponseCode.CM_NOT_FOUND);
}
-// // 2. 관리자 ID 존재 여부 체크.
-// SvcUserInfo svcUserInfo = custMgtMapper.selectSvcUserInfo(insertChrgReqDto.getUserId());
-//
-// if (svcUserInfo == null) {
-// return new InsertChrgResDto(ApiResponseCode.CM_NOT_FOUND);
-// }
-//
-
+
// 3. 충전 정보 등록
-
String chrgSeq = custMgtMapper.getChrgSeq();
- int userSeq = custMgtMapper.selectUserSeq(insertChrgReqDto.getUserId());
+ SvcUserInfo userInfo = custMgtMapper.selectUserInfo(insertChrgReqDto.getUserId());
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserDetails userDetails = (UserDetails) principal;
String regId = userDetails.getUsername();
+ logger.debug("insertChrgReqDto= {}", insertChrgReqDto);
+
ChrgInfo chrgInfo = new ChrgInfo();
chrgInfo.setChrgSeq(chrgSeq);
- chrgInfo.setUserSeq(userSeq);
+ chrgInfo.setUserSeq(userInfo.getUserSeq());
chrgInfo.setChrgDiv(insertChrgReqDto.getChrgDiv());
String StrYm = insertChrgReqDto.getStrtYm().replace("-", "").substring(0, 6);
chrgInfo.setStrtYm(StrYm);
@@ -1140,122 +1126,81 @@ public class CustMgtService {
chrgInfo.setRegId(regId); //로그인 ID
chrgInfo.setChgId(regId); //로그인 ID
- custMgtMapper.insertChrgInfo(chrgInfo);
+ resultcnt = custMgtMapper.insertChrgInfo(chrgInfo);
Date now = new Date();
String presentYm = DateUtils.dateToStr(now, "yyyyMM");
-
ChrgAmtDto chrgAmtDto = new ChrgAmtDto();
if (presentYm.equals(StrYm)) {
- int resultcnt = 0;
- //1. user_lmt 등록
- if ("E".equals(insertChrgReqDto.getChrgDiv())) {
+
+ if ("E".equals(insertChrgReqDto.getChrgDiv())) {
//소멸 충전금 업데이트
- chrgAmtDto.setUserSeq(userSeq);
- chrgAmtDto.setLmtYm(chrgInfo.getStrtYm());
+ chrgAmtDto.setUserSeq(userInfo.getUserSeq());
+ chrgAmtDto.setLmtYm(chrgInfo.getStrtYm());
chrgAmtDto.setExtcChrgAmt(chrgInfo.getChrgAmt());
chrgAmtDto.setCfwdChrgAmt("0");
- resultcnt = custMgtMapper.updateChrgAmt(chrgAmtDto);
+
}else if ("C".equals(insertChrgReqDto.getChrgDiv())) {
//이월 충전금 업데이트
- chrgAmtDto.setUserSeq(userSeq);
- chrgAmtDto.setLmtYm(chrgInfo.getStrtYm());
+ chrgAmtDto.setUserSeq(userInfo.getUserSeq());
+ chrgAmtDto.setLmtYm(chrgInfo.getStrtYm());
chrgAmtDto.setCfwdChrgAmt(chrgInfo.getChrgAmt());
chrgAmtDto.setExtcChrgAmt("0");
- resultcnt = custMgtMapper.updateChrgAmt(chrgAmtDto);
}
-
- //2. 문자발송
- //insert 및 update 성공시 resultCnt 0이상의 정수값이 return됨
- //update성공시
- BigDecimal chargeAmt= BigDecimal.ZERO;
- String webReqId = "";
- TargetSubsInfoDto targetUserLimit = new TargetSubsInfoDto();
- chargeAmt = custMgtMapper.selectChargeAmt(targetUserLimit);
-
- if (resultcnt>0) {
- WebMsgCliDto ezMsgDto = new WebMsgCliDto();
- ezMsgDto.setTableName(TableName.EZ_MSG_REAL);
- ezMsgDto.setTrafficType(LineTpCd.LINE_TP_REAL);
- String clientKey = generateClientKey("R", 10);
- ezMsgDto.setClientKey(clientKey);
- ezMsgDto.setReqProduct(SND_CH_LMS);
- ezMsgDto.setMsgStatus("ready");
- ezMsgDto.setCallbackNumber("15445992");
- ezMsgDto.setPhone(targetUserLimit.getHpNo()); //관리자 hp번호
- ezMsgDto.setWebReqId(webReqId);
- ezMsgDto.setOrderId("2");
-
- String msg = "[LG U+메시지허브이지]\n 충전금액 "+chargeAmt+"원이 충전되셨습니다.";
- ezMsgDto.setMsg(msg);
-
- custMgtMapper.insertWebMsgCli(ezMsgDto);
- logger.info("충전 알림 등록 : [{}]", ezMsgDto.toString());
-
- //알림 이력 insert
- NotiHistDto notihist = new NotiHistDto();
- String notiSeq = custMgtMapper.selectNotiSeq();
- notihist.setUserSeq(targetUserLimit.getUserSeq());
- notihist.setNotiSeq(notiSeq);
- notihist.setNotiMsg(msg);
- notihist.setWebReqId(webReqId);
-
- custMgtMapper.insertNotiHst(notihist);
+ if(resultcnt > 0) {
+ resultcnt = custMgtMapper.updateChrgAmt(chrgAmtDto);
+ }else {
+ logger.error("충전금 등록 오류");
}
+
+ //update성공시
+ if (resultcnt>0) {
+ String prefix = getCurrentDate(YEAR_MONTH_DAY);
+ String webReqId = "";
+
+ // 1. webReqId 채번
+ webReqId = prefix + custMgtMapper.selectSequence(WEB_REQ_ID);
+ BigDecimal chargeAmt= BigDecimal.ZERO;
+ BigDecimal zero = BigDecimal.ZERO;
+
+ //충전 금액 조회
+ chargeAmt = new BigDecimal(chrgInfo.getChrgAmt());
+ //알림문자 발송테이블 insert
+ WebMsgCliDto ezMsgDto = new WebMsgCliDto();
+ ezMsgDto.setTableName("EZ_MSG_REAL");
+ ezMsgDto.setTrafficType("real");
+ String clientKey = generateClientKey("R", 10);
+ ezMsgDto.setClientKey(clientKey);
+ ezMsgDto.setReqProduct("LMS");
+ ezMsgDto.setMsgStatus("ready");
+ ezMsgDto.setCallbackNumber("15445992");
+ ezMsgDto.setPhone(userInfo.getHpNo());
+ ezMsgDto.setWebReqId(webReqId);
+ ezMsgDto.setOrderId("2");
+
+ String msg = "[LG U+메시지허브이지]\n이번 달 이벤트 충전 금액이 충전 되었습니다.\n*충전 금액 : "+chargeAmt+"원";
+ ezMsgDto.setMsg(msg);
+
+ custMgtMapper.insertWebMsgCli(ezMsgDto);
+ logger.info("충전 알림 등록 : [{}]", ezMsgDto.toString());
+
+ //알림 이력 insert
+ NotiHistDto notihist = new NotiHistDto();
+ String notiSeq = custMgtMapper.selectNotiSeq();
+ notihist.setUserSeq(userInfo.getUserSeq());
+ notihist.setNotiSeq(notiSeq);
+ notihist.setNotiMsg(msg);
+ notihist.setWebReqId(webReqId);
+
+ custMgtMapper.insertNotiHst(notihist);
+ logger.info("충전 알림 이력 등록 : [{}]", ezMsgDto.toString());
+ }else{
+ logger.error("충전금 한도 업데이트 오류");
+ }
}
-
return new InsertChrgResDto(ApiResponseCode.SUCCESS);
}
- /**
- * clientKey 생성
- *
- * @param rsvtType
- * @return
- */
- public String generateClientKey(String lineTpCdKey, int length) {
- String prefix = getCurrentDate("yyyyMMddHHmmss") + lineTpCdKey;
- String clientKey = "";
-
- clientKey = getCommonId(prefix, length);
-
- return clientKey;
- }
- /**
- * 날짜 형식을 받아서 오늘 날짜를 해당 형식으로 반환
- *
- * @param format
- * @return
- */
- public static String getCurrentDate(String format) {
- Date date = Calendar.getInstance().getTime();
- DateFormat dateFormat = new SimpleDateFormat(format);
- return dateFormat.format(date);
- }
- /**
- * 공통ID 생성(템플릿ID, 프로젝트ID, 사용자ID 등등)
- *
- * @return
- */
- public static String getCommonId(String prefix, int len) {
- // 공통 ID 접미사
- String suffix = randomGeneration(len);
-
- // 공통 ID
- String commonId = prefix + suffix;
-
- return commonId;
- }
- /**
- * 난수 생성(매개변수로 난수길이 세팅)
- *
- * @param len
- * @return
- */
- public static String randomGeneration(int len) {
- String randomStr = RandomStringUtils.randomAlphanumeric(len);
- return randomStr;
- }
/**
* date : 2023. 3. 15.
@@ -1264,7 +1209,6 @@ public class CustMgtService {
* @param paramMap
* @return
*/
-
public UpdateChrgResDto UpdateChrg(@Valid UpdateChrgReqDto updateChrgReqDto) {
CustMgtMapper custMgtMapper = sqlSessionMaster.getMapper(CustMgtMapper.class);
@@ -1274,7 +1218,7 @@ public class CustMgtService {
// 2. 새 정보 insert
String chrgSeq = custMgtMapper.getChrgSeq();
- int userSeq = custMgtMapper.selectUserSeq(updateChrgReqDto.getUserId());
+ SvcUserInfo userInfo = custMgtMapper.selectUserInfo(updateChrgReqDto.getUserId());
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserDetails userDetails = (UserDetails) principal;
String regId = userDetails.getUsername();
@@ -1283,7 +1227,7 @@ public class CustMgtService {
ChrgInfo chrgInfo = new ChrgInfo();
chrgInfo.setChrgSeq(chrgSeq);
- chrgInfo.setUserSeq(userSeq);
+ chrgInfo.setUserSeq(userInfo.getUserSeq());
chrgInfo.setChrgDiv(updateChrgReqDto.getChrdDiv());
String StrYm = updateChrgReqDto.getStrtYm().replace("-", "").substring(0, 6);
chrgInfo.setStrtYm(StrYm);
@@ -1341,7 +1285,32 @@ public class CustMgtService {
return new UserListResDto(ApiResponseCode.SUCCESS, userListRes);
}
+ /**
+ * 날짜 형식을 받아서 오늘 날짜를 해당 형식으로 반환
+ *
+ * @param format
+ * @return
+ */
+ public String getCurrentDate(String format) {
+ Date date = Calendar.getInstance().getTime();
+ DateFormat dateFormat = new SimpleDateFormat(format);
+ return dateFormat.format(date);
+ }
+ /**
+ * clientKey 생성
+ *
+ * @param rsvtType
+ * @return
+ */
+ public String generateClientKey(String lineTpCdKey, int length) {
+ String prefix = DateUtil.getCurrentDate("yyyyMMddHHmmss") + lineTpCdKey;
+ String clientKey = "";
+
+ clientKey = CommonUtils.getCommonId(prefix, length);
+
+ return clientKey;
+ }
/* 2023-03-07 add request 부분
* date : 2023. 1. 1.
diff --git a/src/main/java/kr/co/uplus/ez/api/custMgt/dto/ChrgAmtDto.java b/src/main/java/kr/co/uplus/ez/api/custMgt/dto/ChrgAmtDto.java
index 1712c99..1293e2e 100644
--- a/src/main/java/kr/co/uplus/ez/api/custMgt/dto/ChrgAmtDto.java
+++ b/src/main/java/kr/co/uplus/ez/api/custMgt/dto/ChrgAmtDto.java
@@ -11,7 +11,7 @@ public class ChrgAmtDto implements Serializable{
/** 충전 SEQUENCE */
private String chrgSeq;
/** 유저 SEQUENCE */
- private int userSeq;
+ private String userSeq;
/** 한도년월 */
private String lmtYm;
/** 충전 시작년월 */
diff --git a/src/main/java/kr/co/uplus/ez/api/custMgt/dto/ChrgInfo.java b/src/main/java/kr/co/uplus/ez/api/custMgt/dto/ChrgInfo.java
index e8d5d06..d51f75c 100644
--- a/src/main/java/kr/co/uplus/ez/api/custMgt/dto/ChrgInfo.java
+++ b/src/main/java/kr/co/uplus/ez/api/custMgt/dto/ChrgInfo.java
@@ -11,7 +11,7 @@ public class ChrgInfo implements Serializable{
/** 충전 SEQUENCE */
private String chrgSeq;
/** 유저 SEQUENCE */
- private int userSeq;
+ private String userSeq;
/** 충전구분 */
private String chrgDiv;
/** 충전 시작년월 */
diff --git a/src/main/resources/mapper/mysql/custMgt/custMgt-mapper.xml b/src/main/resources/mapper/mysql/custMgt/custMgt-mapper.xml
index 7c9b206..a805bca 100644
--- a/src/main/resources/mapper/mysql/custMgt/custMgt-mapper.xml
+++ b/src/main/resources/mapper/mysql/custMgt/custMgt-mapper.xml
@@ -1309,133 +1309,6 @@
)
-
-
- /* extCarryOverAmtNoti.insertWebMsgCli - 메시지 원장 등록 */
- INSERT INTO
-
- hubez_send.EZ_MSG_NORMAL
-
-
- hubez_send.EZ_MSG_REAL
-
- (
- CLIENT_KEY,
- REQ_PRODUCT,
- TRAFFIC_TYPE,
- MSG_STATUS,
- REQ_DATE,
- MSG_BIZ_KEY,
- TEMPLATE_CODE,
- SEND_GROUP_KEY,
- CALLBACK_NUMBER,
- DEPT_CODE,
- MSG,
- PHONE,
- MERGE_DATA,
- TITLE,
- FILE_LIST,
- FB_PRODUCT,
- FB_TITLE,
- FB_MSG,
- FB_FILE_ID,
- RCS_MSGBASE_ID,
- RCS_HEADER,
- RCS_FOOTER,
- RCS_COPY_ALLOWED,
- RCS_EXPIRY_OPTION,
- RCS_AGENCY_ID,
- RCS_BUTTON,
- KAKAO_SENDER_KEY,
- KAKAO_TEMPLATE_KEY,
- KAKAO_BUTTON,
- KAKAO_IMAGE_WIDE_YN,
- KAKAO_IMAGE_URL,
- KAKAO_IMAGE_LINK,
- PUSH_APP_ID,
- PUSH_PROVIDER,
- PUSH_APP_USER_ID,
- WEB_REQ_ID,
- ORDER_ID
- )
- VALUES
- (
- #{clientKey},
- #{reqProduct},
- #{trafficType},
- #{msgStatus},
- DATE_ADD(NOW(), INTERVAL +8 HOUR),
- #{msgBizKey},
- #{templateCode},
- #{sendGroupKey},
- #{callbackNumber},
- #{deptCode},
- #{msg},
- #{phone},
- #{mergeData},
- '충전금액알림',
- #{fileList},
- #{fbProduct},
- #{fbTitle},
- #{fbMsg},
- #{fbFileId},
- #{rcsMsgbaseId},
- #{rcsHeader},
- #{rcsFooter},
- #{rcsCopyAllowed},
- #{rcsExpiryOption},
- #{rcsAgencyId},
- #{rcsButton},
- #{kakaoSenderKey},
- #{kakaoTemplateKey},
- #{kakaoButton},
- #{kakaoImageWideYn},
- #{kakaoImageUrl},
- #{kakaoImageLink},
- #{pushAppId},
- #{pushProvider},
- #{pushAppUserId},
- #{webReqId},
- #{orderId}
- )
-
-
-
- /* extCarryOverAmtNoti.insertNotiHst - 알림 이력 등록 */
- INSERT INTO hubez_common.EZ_NOTI_HIST
- (
- SND_YMD,
- USER_SEQ,
- NOTI_SEQ,
- NOTI_DIV,
- NOTI_MSG,
- WEB_REQ_ID,
- REG_DT
- )
- VALUES
- (
- DATE_FORMAT(NOW(), '%Y%m%d'),
- #{userSeq},
- #{notiSeq},
- '04',
- #{notiMsg},
- #{webReqId},
- NOW()
- )
-
-
UPDATE
hubez_admin.EZ_USER_LMT eul
@@ -1650,4 +1523,137 @@
ORDER BY eci.CUST_SEQ DESC
-->
+
+
+
+
+
+
+
+ /* extCarryOverAmtNoti.insertWebMsgCli - 메시지 원장 등록 */
+ INSERT INTO
+
+ hubez_send.EZ_MSG_NORMAL
+
+
+ hubez_send.EZ_MSG_REAL
+
+ (
+ CLIENT_KEY,
+ REQ_PRODUCT,
+ TRAFFIC_TYPE,
+ MSG_STATUS,
+ REQ_DATE,
+ MSG_BIZ_KEY,
+ TEMPLATE_CODE,
+ SEND_GROUP_KEY,
+ CALLBACK_NUMBER,
+ DEPT_CODE,
+ MSG,
+ PHONE,
+ MERGE_DATA,
+ TITLE,
+ FILE_LIST,
+ FB_PRODUCT,
+ FB_TITLE,
+ FB_MSG,
+ FB_FILE_ID,
+ RCS_MSGBASE_ID,
+ RCS_HEADER,
+ RCS_FOOTER,
+ RCS_COPY_ALLOWED,
+ RCS_EXPIRY_OPTION,
+ RCS_AGENCY_ID,
+ RCS_BUTTON,
+ KAKAO_SENDER_KEY,
+ KAKAO_TEMPLATE_KEY,
+ KAKAO_BUTTON,
+ KAKAO_IMAGE_WIDE_YN,
+ KAKAO_IMAGE_URL,
+ KAKAO_IMAGE_LINK,
+ PUSH_APP_ID,
+ PUSH_PROVIDER,
+ PUSH_APP_USER_ID,
+ WEB_REQ_ID,
+ ORDER_ID
+ )
+ VALUES
+ (
+ #{clientKey},
+ #{reqProduct},
+ #{trafficType},
+ #{msgStatus},
+ NOW(),
+ #{msgBizKey},
+ #{templateCode},
+ #{sendGroupKey},
+ #{callbackNumber},
+ #{deptCode},
+ #{msg},
+ #{phone},
+ #{mergeData},
+ '충전금액알림',
+ #{fileList},
+ #{fbProduct},
+ #{fbTitle},
+ #{fbMsg},
+ #{fbFileId},
+ #{rcsMsgbaseId},
+ #{rcsHeader},
+ #{rcsFooter},
+ #{rcsCopyAllowed},
+ #{rcsExpiryOption},
+ #{rcsAgencyId},
+ #{rcsButton},
+ #{kakaoSenderKey},
+ #{kakaoTemplateKey},
+ #{kakaoButton},
+ #{kakaoImageWideYn},
+ #{kakaoImageUrl},
+ #{kakaoImageLink},
+ #{pushAppId},
+ #{pushProvider},
+ #{pushAppUserId},
+ #{webReqId},
+ #{orderId}
+ )
+
+
+
+ /* extCarryOverAmtNoti.insertNotiHst - 알림 이력 등록 */
+ INSERT INTO hubez_common.EZ_NOTI_HIST
+ (
+ SND_YMD,
+ USER_SEQ,
+ NOTI_SEQ,
+ NOTI_DIV,
+ NOTI_MSG,
+ WEB_REQ_ID,
+ REG_DT
+ )
+ VALUES
+ (
+ DATE_FORMAT(NOW(), '%Y%m%d'),
+ #{userSeq},
+ #{notiSeq},
+ '04',
+ #{notiMsg},
+ #{webReqId},
+ NOW()
+ )
+