diff --git a/db/mens-iup-query.sql b/db/mens-iup-query.sql index 9737aa7..af45ae0 100644 --- a/db/mens-iup-query.sql +++ b/db/mens-iup-query.sql @@ -75,7 +75,8 @@ SELECT * FROM tb_input_xit tix JOIN tb_input_data_xit tidx ON tix.lnk_input_id=tidx.lnk_input_id - WHERE tix.send_type='NI' + WHERE 1=1 + -- AND tix.send_type='NI' AND tix.prcs_cd='TGRG'; -- 2. bill 생성 diff --git a/src/main/java/cokr/xit/ens/modules/common/ctgy/intgrnbill/kko/service/process/KkoPayUrlService.java b/src/main/java/cokr/xit/ens/modules/common/ctgy/intgrnbill/kko/service/process/KkoPayUrlService.java index 9a7336a..e17be4c 100644 --- a/src/main/java/cokr/xit/ens/modules/common/ctgy/intgrnbill/kko/service/process/KkoPayUrlService.java +++ b/src/main/java/cokr/xit/ens/modules/common/ctgy/intgrnbill/kko/service/process/KkoPayUrlService.java @@ -91,6 +91,7 @@ public class KkoPayUrlService implements PayUrlService, S /** + * FIXME: NICE CI 결제에 적용 필요 * FIXME: Comment 카카오페이 결제 Url API * [모바일 페이지 카카오페이 결제 버튼 이벤트 시 납부(결제)정보 요청] * @Operation(summary = "납부(결제)정보 요청") diff --git a/src/main/java/cokr/xit/ens/modules/nice/mapper/INiceCiMapper.java b/src/main/java/cokr/xit/ens/modules/nice/mapper/INiceCiMapper.java new file mode 100644 index 0000000..9f2b87e --- /dev/null +++ b/src/main/java/cokr/xit/ens/modules/nice/mapper/INiceCiMapper.java @@ -0,0 +1,29 @@ +package cokr.xit.ens.modules.nice.mapper; + +import java.util.*; + +import org.apache.ibatis.annotations.*; + +import cokr.xit.ens.modules.nice.model.*; + +/** + *
+ * description :
+ * packageName : cokr.xit.ens.modules.nice.mapper
+ * fileName    : INiceMapper
+ * author      : limju
+ * date        : 2024 9월 30
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2024 9월 30   limju       최초 생성
+ *
+ * 
+ */ +@Mapper +public interface INiceCiMapper { + List selectNiceCiAcceptTgts(final NiceCiDTO.InputXit inputXit); + List selectNiceCiAcceptDatas(final NiceCiDTO.InputXit inputXit); + + int saveBill(final NiceCiDTO.BillDTO bill); +} diff --git a/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiDTO.java b/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiDTO.java new file mode 100644 index 0000000..8279eb6 --- /dev/null +++ b/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiDTO.java @@ -0,0 +1,198 @@ +package cokr.xit.ens.modules.nice.model; + +import java.time.*; +import java.util.*; + +import javax.persistence.*; + +import cokr.xit.ens.biz.iup.code.*; +import cokr.xit.ens.core.jpa.support.*; +import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.code.*; +import io.swagger.v3.oas.annotations.media.*; +import lombok.*; +import lombok.experimental.*; + +/** + *
+ * description :
+ * packageName : cokr.xit.ens.modules.nice.model
+ * fileName    : NiceCiDTO
+ * author      : limju
+ * date        : 2024 9월 30
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2024 9월 30   limju       최초 생성
+ *
+ * 
+ */ +public class NiceCiDTO { + @Schema(name = "InputXit DTO", description = "InputXit DTO") + @Data + @NoArgsConstructor + @AllArgsConstructor + @SuperBuilder + @EqualsAndHashCode(callSuper = false) + public static class InputXit { + /** + * 연계입수아이디 + */ + private Long lnkInputId; + + /** + * 기관코드 + */ + private String orgCd; + + /** + * 안내장 코드 + */ + private String jobCd; + + /** + * 입수 건수 + */ + private Long totCnt; + + /** + * 상태값 + */ + @Enumerated(EnumType.STRING) + private IupPrcsCd prcsCd; + + /** + * 에러메세지 + */ + private String errMsg; + + /** + * 발송일시분 + */ + private LocalDateTime runDt; + + /** + * 조회마감일시 + */ + private LocalDateTime expiresDt; + + /** + * 발송구분 + */ + @Enumerated(EnumType.STRING) + private IupSendTypeCd sendType; + + /** + * 접수일시 + */ + private String rcptDt; + + /** + * 결재마감일시 + */ + private LocalDateTime payExpiresDt; + + List inputDataXits = new ArrayList<>(); + + private String regId; + private LocalDateTime regDt; + private String updId; + private LocalDateTime updDt; + } + + @Schema(name = "InputDataXit DTO", description = "InputDataXit DTO") + @Data + @NoArgsConstructor + @AllArgsConstructor + @SuperBuilder + @EqualsAndHashCode(callSuper = false) + public static class InputDataXit { + private String dataId; + private Long lnkInputId; + + private String birthday; + + private String callCenterNo; + + private String carNo; + + private String gender; + + private String linkedUuid; + + private String moblphonNo; + + private String msgData; + + @Lob + private String msgDtlData; + + private String name; + + private String payStatusCd; + + private String payUrl; + + private String sid; + + private String regId; + private LocalDateTime regDt; + private String updId; + private LocalDateTime updDt; + } + + @Schema(name = "BillDTO DTO", description = "BillDTO DTO") + @Data + @NoArgsConstructor + @AllArgsConstructor + @SuperBuilder + public static class BillDTO { + private Long billId; + + private String billUid; + + private String billerUserKey; + + + /** + * 청구서 타입 + */ + @Enumerated(EnumType.STRING) + private BillSeCd billSeCd; + + private String orgCd; + + /** + * 납부결제여부 + */ + @Convert(converter = BooleanToYnConverter.class) + private Boolean paidAt; + + /** + * 지불유형 + */ + @Enumerated(EnumType.STRING) + private PaidTypeCd paidType; + + /** + * 납부(결제) 날짜 - 14자리 + */ + private String paidDt; + + /** + * 납부(결제) 취소 날짜 - 14자리 + */ + private String paidCancelDt; + + /** + * 카카오 청구서 + */ + @Lob + private String docBillKko; + + /** + * 네이버 청구서 + */ + @Lob + private String docBillNv; + } +} diff --git a/src/main/java/cokr/xit/ens/modules/nice/presentation/NiceCiController.java b/src/main/java/cokr/xit/ens/modules/nice/presentation/NiceCiController.java index 8b168e8..9e95c11 100644 --- a/src/main/java/cokr/xit/ens/modules/nice/presentation/NiceCiController.java +++ b/src/main/java/cokr/xit/ens/modules/nice/presentation/NiceCiController.java @@ -28,6 +28,13 @@ import lombok.*; @RequestMapping(value = "/nice/talk") public class NiceCiController { private final NiceCiService niceCiService; + private final NiceCiAcceptService niceCiAcceptService; + + @Operation(summary = "접수") + @PostMapping(value = "/accept", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity accept() { + return new ResponseEntity<>(niceCiAcceptService.accept(), HttpStatus.OK); + } @Operation(summary = "(대량)전송요청") @PostMapping(value = "/send/bulk", produces = MediaType.APPLICATION_JSON_VALUE) diff --git a/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiAcceptService.java b/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiAcceptService.java new file mode 100644 index 0000000..79b1d5d --- /dev/null +++ b/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiAcceptService.java @@ -0,0 +1,107 @@ +package cokr.xit.ens.modules.nice.service; + +import java.util.*; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.*; +import org.springframework.transaction.annotation.*; + +import cokr.xit.ens.biz.iup.code.*; +import cokr.xit.ens.core.aop.*; +import cokr.xit.ens.core.utils.*; +import cokr.xit.ens.modules.common.code.*; +import cokr.xit.ens.modules.common.ctgy.sys.mng.service.*; +import cokr.xit.ens.modules.nice.mapper.*; +import cokr.xit.ens.modules.nice.model.*; +import cokr.xit.ens.modules.nice.service.support.*; +import lombok.*; +import lombok.extern.slf4j.*; + +/** + *
+ * description :
+ * packageName : cokr.xit.ens.modules.nice.service
+ * fileName    : NiceCiService
+ * author      : limju
+ * date        : 2024 9월 27
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2024 9월 27   limju       최초 생성
+ *
+ * 
+ */ +@Slf4j +@Service +@RequiredArgsConstructor +public class NiceCiAcceptService { + @Value("${contract.niceCi.orgId}") + private String ORG_ID; + + @Value("${contract.niceCi.clientId}") + private String CLIENT_ID; + + private final KeySequenceService keySequenceService; + private final NiceCiApiService niceCiApiService; + + private final INiceCiMapper niceCiMapper; + + /** + *
+     * -- 1. 대상 조회
+     * SELECT *
+     *   FROM tb_input_xit tix
+     *   JOIN tb_input_data_xit tidx
+     *     ON tix.lnk_input_id=tidx.lnk_input_id
+     *  WHERE 1=1
+     *    -- AND tix.send_type='NI'
+     *    AND tix.prcs_cd='TGRG'
+     *
+     * -- 2. bill 생성
+     * -- 3. 카카오 청구서 생성
+     * -- 4. tb_input_data_xit 테이블 pay_url 에 청구서 URL UPDATE
+     * -- 5. tb_input_xit 테이블 prcs_cd='GRUC' / 실패 시 prcs_cd='TGRF'
+     * @return
+     * 
+ */ + @Transactional(propagation = Propagation.REQUIRES_NEW) + public EnsResponseVO accept(){ + NiceCiDTO.InputXit inputXit = NiceCiDTO.InputXit.builder() + .sendType(IupSendTypeCd.NI) + .prcsCd(IupPrcsCd.TGRG) + .build(); + + final List list = niceCiMapper.selectNiceCiAcceptTgts(inputXit); + + list.forEach(niceCiMapper::selectNiceCiAcceptDatas); + + final String prefixBillUid = PostSeCd.intgrnNoti.getCode() + "-" + IdGenerator.getCurrentTimeSec(); + + List bills = new ArrayList<>(); + for(NiceCiDTO.InputXit d : list){ + List inputDataXits = niceCiMapper.selectNiceCiAcceptDatas(d); + + // bill + bills.add( + NiceCiDTO.BillDTO.builder() + //.billId(keySequenceService.getKeySequence("bill_id")) + .billUid(IdGenerator.getShortUUID(prefixBillUid)) + //.billerUserKey(document.getXit_property().getBill_acpt_data().getBillerUserKey()) + //.billSeCd(document.getXit_property().getBill_acpt_data().getBillSe()) + //.orgMng(OrgMng.builder().orgCd(reqDTO.getOrg_cd()).build()) + .build() + ); + } + + bills.forEach(b -> { + b.setBillId(keySequenceService.getKeySequence("bill_id")); + niceCiMapper.saveBill(b); + }); + + return EnsResponseVO.okBuilder() + //.resultInfo(niceCiMapper.selectAcceptTgts(null)) + .build(); + } + + +} diff --git a/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiService.java b/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiService.java index 6269fd8..3ccc02a 100644 --- a/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiService.java +++ b/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiService.java @@ -6,6 +6,7 @@ import org.springframework.stereotype.*; import cokr.xit.ens.core.aop.*; import cokr.xit.ens.modules.nice.cmm.*; +import cokr.xit.ens.modules.nice.mapper.*; import cokr.xit.ens.modules.nice.model.*; import cokr.xit.ens.modules.nice.service.support.*; import lombok.*; @@ -37,6 +38,8 @@ public class NiceCiService { private final NiceCiApiService niceCiApiService; + private final INiceCiMapper niceCiMapper; + final String msg = "민자도로 관리지원센터에서 김해찬님께 발송한 미납통행료 고지서가 도착했습니다.\n" + "\n" + "민자도로 미납통행료 고지서\n" @@ -58,11 +61,6 @@ public class NiceCiService { + "\n" + "문의처 : 044-211-3377"; - public EnsResponseVO accept(){ - return null; - } - - public EnsResponseVO requestSendBulk() { NiceCiApiDTO.Request ciRequest = new NiceCiApiDTO.Request(); diff --git a/src/main/resources/mybatis-mapper/modules/iup-niceci-mapper.xml b/src/main/resources/mybatis-mapper/modules/iup-niceci-mapper.xml new file mode 100644 index 0000000..79ac4a4 --- /dev/null +++ b/src/main/resources/mybatis-mapper/modules/iup-niceci-mapper.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + /** iup-niceci-mapper|saveBill-NICE CI 청구서 생성|julim */ + INSERT INTO ens_bill ( + bill_id, + bill_uid, + bill_se_cd, +-- doc_bill_kko, +-- doc_bill_nv, + org_cd, + biller_user_key, +-- paid_at, +-- paid_cancel_dt, +-- paid_dt, +-- paid_type, + regist_dt + ) VALUES ( + #{billId}, + #{billUid}, + #{billSeCd}, + #{orgCd}, + #{billerUserKey}, + sysdate + ) ) + + +