Procházet zdrojové kódy

미납금관리 등

marseyes před 2 roky
rodič
revize
6afec0b038

+ 41 - 39
src/main/java/com/oqpo/api/service/sttlmng/SttlStateService.java

@@ -96,46 +96,48 @@ public class SttlStateService extends CommonService {
96 96
         stlEntity.setSttlAmt(entity.getSttlReqAmt()); // 정산요청금액을 정산금액으로 지정한다.
97 97
         sttlReqMapper.updateStlMgntBaseInfo4SttlConfirm(userId, stlEntity);
98 98
 
99
-        // 매장의 계좌잔액이 있은 경우 정산지급 처리를 한다.
100
-        // 매장 계좌잔액 조회
101
-        LoanMgntBaseInfoEntity loanEntity = dsptMngMapper.selectLoanMgntBaseInfo(entity.getBrandId(), entity.getStoreId());
102
-        if (loanEntity.getAcctBal() > 0) {
103
-            // 계좌잔액이 정산요청금액 이상인 경우 정산요청금액을 지급처리하고 정산 데이터는 수납처리한다.
104
-            // 계좌잔액이 정산요청금액 미만인 경우 계좌잔액을 지급처리하고 정산 데이터는 일부 수납처리한다. (미납금 발생)
105
-            String rcptYn; // 수납완료여부
106
-            long rcptAmt = 0; // 수납금액
107
-            if (loanEntity.getAcctBal() >= entity.getSttlReqAmt()) {
108
-                rcptAmt = entity.getSttlReqAmt();
109
-                rcptYn = "Y";
110
-            } else {
111
-                rcptAmt = loanEntity.getAcctBal();
112
-                rcptYn = "N";
99
+        if ("N".equals(entity.getRcptYn())) { // 수납여부가 N인 경우
100
+            // 매장의 계좌잔액이 있은 경우 정산지급 처리를 한다.
101
+            // 매장 계좌잔액 조회
102
+            LoanMgntBaseInfoEntity loanEntity = dsptMngMapper.selectLoanMgntBaseInfo(entity.getBrandId(), entity.getStoreId());
103
+            if (loanEntity.getAcctBal() > 0) {
104
+                // 계좌잔액이 정산요청금액 이상인 경우 정산요청금액을 지급처리하고 정산 데이터는 수납처리한다.
105
+                // 계좌잔액이 정산요청금액 미만인 경우 계좌잔액을 지급처리하고 정산 데이터는 일부 수납처리한다. (미납금 발생)
106
+                String rcptYn; // 수납완료여부
107
+                long rcptAmt = 0; // 수납금액
108
+                if (loanEntity.getAcctBal() >= entity.getSttlReqAmt()) {
109
+                    rcptAmt = entity.getSttlReqAmt();
110
+                    rcptYn = "Y";
111
+                } else {
112
+                    rcptAmt = loanEntity.getAcctBal();
113
+                    rcptYn = "N";
114
+                }
115
+
116
+                // 1. 여신관리기본정보 처리
117
+                long trscBfBal = loanEntity.getAcctBal();
118
+                long trscAfBal = loanEntity.getAcctBal() - rcptAmt;
119
+                loanEntity.setAcctBal(trscAfBal); // 계좌잔액
120
+                loanEntity.setUseAmtTotal(loanEntity.getUseAmtTotal() - rcptAmt); // 사용금액합계 감소
121
+                sttlReqMapper.updateLoanMgntBaseInfo4SttlReqProc(userId, loanEntity);
122
+
123
+                // 2. 여신관리상세이력
124
+                LoanMgntDtlHstEntity hstEntity = new LoanMgntDtlHstEntity();
125
+                hstEntity.setLoanMgntUnqNo(loanEntity.getLoanMgntUnqNo());
126
+                hstEntity.setLoanRegDt(DateUtil.getCurrentDate());
127
+                hstEntity.setLoanRegTm(DateUtil.getCurrentTime());
128
+                hstEntity.setDpstPayDvsn(DpstPayDvsn.PAYMENT.getCd());
129
+                hstEntity.setMediaDvsn(MediaDvsn.SETTLMENT.getCd());
130
+                hstEntity.setPayType(PayType.STTL_PAY.getCd());
131
+                hstEntity.setTrscAmt(rcptAmt); // 거래금액
132
+                hstEntity.setTrscBfBal(trscBfBal); // 거래전잔액
133
+                hstEntity.setTrscAfBal(trscAfBal); // 거래후잔액
134
+                dsptMngMapper.insertLoanMgntDtlHst(userId, hstEntity);
135
+
136
+                // 3. 정산관리기본정보 수납처리
137
+                stlEntity.setRcptYn(rcptYn); // 수납여부
138
+                stlEntity.setRcptAmt(rcptAmt); // 수납금액
139
+                sttlReqMapper.updateStlMgntBaseInfo4Rcpt(userId, stlEntity);
113 140
             }
114
-
115
-            // 1. 여신관리기본정보 처리
116
-            long trscBfBal = loanEntity.getAcctBal();
117
-            long trscAfBal = loanEntity.getAcctBal() - rcptAmt;
118
-            loanEntity.setAcctBal(trscAfBal); // 계좌잔액
119
-            loanEntity.setUseAmtTotal(loanEntity.getUseAmtTotal() - rcptAmt); // 사용금액합계 감소
120
-            sttlReqMapper.updateLoanMgntBaseInfo4SttlReqProc(userId, loanEntity);
121
-
122
-            // 2. 여신관리상세이력
123
-            LoanMgntDtlHstEntity hstEntity = new LoanMgntDtlHstEntity();
124
-            hstEntity.setLoanMgntUnqNo(loanEntity.getLoanMgntUnqNo());
125
-            hstEntity.setLoanRegDt(DateUtil.getCurrentDate());
126
-            hstEntity.setLoanRegTm(DateUtil.getCurrentTime());
127
-            hstEntity.setDpstPayDvsn(DpstPayDvsn.PAYMENT.getCd());
128
-            hstEntity.setMediaDvsn(MediaDvsn.SETTLMENT.getCd());
129
-            hstEntity.setPayType(PayType.STTL_PAY.getCd());
130
-            hstEntity.setTrscAmt(rcptAmt); // 거래금액
131
-            hstEntity.setTrscBfBal(trscAfBal);
132
-            hstEntity.setTrscAfBal(trscBfBal);
133
-            dsptMngMapper.insertLoanMgntDtlHst(userId, hstEntity);
134
-
135
-            // 3. 정산관리기본정보 수납처리
136
-            stlEntity.setRcptYn(rcptYn); // 수납여부
137
-            stlEntity.setRcptAmt(rcptAmt); // 수납금액
138
-            sttlReqMapper.updateStlMgntBaseInfo4Rcpt(userId, stlEntity);
139 141
         }
140 142
     }
141 143
 

+ 1 - 1
src/main/resources/mybatis/sqlmaps/loanmng/UnpaidMng.xml

@@ -116,7 +116,7 @@
116 116
             stl.sttl_req_amt,           /* 정산요청금액 */
117 117
             stl.sttl_amt,               /* 정산확정금액 */
118 118
             stl.rcpt_amt,               /* 수납금액 */
119
-            (IFNULL(stl.sttl_amt, stl.sttl_req_amt) - IFNULL(stl.rcpt_amt, 0)) AS unpaid_amt,       /* 미납금액 */
119
+            (IFNULL(stl.sttl_amt, stl.sttl_req_amt) - IFNULL(stl.rcpt_amt, 0)) AS unpaid_amt,       /* 미납금액 : 정산금액 - 수납금액  */
120 120
             stl.sttl_st_cd, FN_CODE_NM('STTL_ST_CD', stl.sttl_st_cd) AS sttl_st_nm,                 /* 정산상태코드 */
121 121
             <![CDATA[
122 122
             CASE WHEN store.sttl_req_cfrm_term > 0 AND store.sttl_rcp_amt_term > 0 THEN