marseyes 2 роки тому
батько
коміт
d84fd3652a

+ 2 - 0
src/main/java/com/oqpo/api/mapper/sttlmng/SttlReqMapper.java

@@ -57,6 +57,8 @@ public interface SttlReqMapper {
57 57
 
58 58
     int updateStlMgntBaseInfo4SttlConfirm(@Param("userId") String userId, StlMgntBaseInfoEntity entity) throws Exception;
59 59
 
60
+    int updateStlMgntBaseInfo4Rcpt(@Param("userId") String userId, StlMgntBaseInfoEntity entity) throws Exception;
61
+
60 62
     int updateStlMgntBaseInfo4SttlReject(@Param("userId") String userId, StlMgntBaseInfoEntity entity) throws Exception;
61 63
 
62 64
 }

+ 61 - 6
src/main/java/com/oqpo/api/service/sttlmng/SttlStateService.java

@@ -1,8 +1,15 @@
1 1
 package com.oqpo.api.service.sttlmng;
2 2
 
3 3
 
4
+import com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity;
5
+import com.oqpo.api.entity.loanmng.LoanMgntDtlHstEntity;
4 6
 import com.oqpo.api.entity.settmng.StlMgntBaseInfoEntity;
7
+import com.oqpo.api.enums.DpstPayDvsn;
8
+import com.oqpo.api.enums.MediaDvsn;
9
+import com.oqpo.api.enums.PayType;
5 10
 import com.oqpo.api.enums.SttlStCd;
11
+import com.oqpo.api.mapper.loanmng.DsptMngMapper;
12
+import com.oqpo.api.mapper.loanmng.UnpaidMngMapper;
6 13
 import com.oqpo.api.mapper.sttlmng.SttlReqMapper;
7 14
 import com.oqpo.api.mapper.sttlmng.SttlStateMapper;
8 15
 import com.oqpo.api.service.CommonService;
@@ -29,6 +36,12 @@ public class SttlStateService extends CommonService {
29 36
     @Autowired
30 37
     private SttlReqMapper sttlReqMapper;
31 38
 
39
+    @Autowired
40
+    private DsptMngMapper dsptMngMapper;
41
+
42
+    @Autowired
43
+    private UnpaidMngMapper unpaidMngMapper;
44
+
32 45
     /*
33 46
       정산요청 그리드 리스트 조회
34 47
      */
@@ -76,12 +89,54 @@ public class SttlStateService extends CommonService {
76 89
         StlMgntBaseInfoEntity entity = sttlReqMapper.selectStlMgntBaseInfo(sttlConfirmRequest.getSttlMgntUnqNo());
77 90
 
78 91
         // 정산관리기본정보 - 정산상태코드 변경
79
-        StlMgntBaseInfoEntity infoEntity = new StlMgntBaseInfoEntity();
80
-        infoEntity.setSttlMgntUnqNo(sttlConfirmRequest.getSttlMgntUnqNo());
81
-        infoEntity.setSttlStCd(SttlStCd.STTL_CONFIRM.getCd());
82
-        infoEntity.setSttlDt(DateUtil.getCurrentDate());
83
-        infoEntity.setSttlAmt(entity.getSttlReqAmt()); // 정산요청금액을 정산금액으로 지정한다.
84
-        sttlReqMapper.updateStlMgntBaseInfo4SttlConfirm(userId, infoEntity);
92
+        StlMgntBaseInfoEntity stlEntity = new StlMgntBaseInfoEntity();
93
+        stlEntity.setSttlMgntUnqNo(sttlConfirmRequest.getSttlMgntUnqNo());
94
+        stlEntity.setSttlStCd(SttlStCd.STTL_CONFIRM.getCd());
95
+        stlEntity.setSttlDt(DateUtil.getCurrentDate());
96
+        stlEntity.setSttlAmt(entity.getSttlReqAmt()); // 정산요청금액을 정산금액으로 지정한다.
97
+        sttlReqMapper.updateStlMgntBaseInfo4SttlConfirm(userId, stlEntity);
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";
113
+            }
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
+        }
85 140
     }
86 141
 
87 142
 }

+ 1 - 1
src/main/java/com/oqpo/api/web/controller/sttlmng/SttlReqController.java

@@ -97,7 +97,7 @@ public class SttlReqController {
97 97
     })
98 98
     @ApiOperation(value = "정산 상세정보")
99 99
     @GetMapping("/info-sttl")
100
-    public ResponseEntity<SttlMngInfoResponse> infoUnpaid(@RequestParam(value = "sttlMgntUnqNo") String sttlMgntUnqNo) throws Exception {
100
+    public ResponseEntity<SttlMngInfoResponse> infoSttl(@RequestParam(value = "sttlMgntUnqNo") String sttlMgntUnqNo) throws Exception {
101 101
         return ResponseEntity.ok(sttlReqService.selectSttlReqInfo(sttlMgntUnqNo));
102 102
     }
103 103
 

+ 14 - 1
src/main/resources/mybatis/sqlmaps/sttlmng/SttlReq.xml

@@ -162,7 +162,7 @@
162 162
             DATE_FORMAT(A.sys_reg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_reg_dttm, A.sys_reg_id, FN_USER_NM(A.sys_reg_id) AS sys_reg_nm,
163 163
             DATE_FORMAT(A.sys_chg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_chg_dttm, A.sys_chg_id,
164 164
             B.loan_dvsn, FN_CODE_NM('LOAN_DVSN', B.loan_dvsn) AS loan_dvsn_nm,      /* 매장 정상구분 */
165
-            C.acct_bal                                                              /* 매장 계좌잔액 */
165
+            IFNULL(C.acct_bal, 0) AS acct_bal                                       /* 매장 계좌잔액 */
166 166
         FROM stl_mgnt_base_info A
167 167
         INNER JOIN store_base_info B ON A.brand_id = B.brand_id AND A.store_id = B.store_id
168 168
         LEFT JOIN loan_mgnt_base_info C ON B.loan_mgnt_unq_no = C.loan_mgnt_unq_no
@@ -417,4 +417,17 @@
417 417
         WHERE sttl_mgnt_unq_no = #{entity.sttlMgntUnqNo}
418 418
     </update>
419 419
 
420
+    <update id="updateStlMgntBaseInfo4Rcpt" >
421
+        /* SttlReqMapper.updateStlMgntBaseInfo4Rcpt */
422
+        UPDATE stl_mgnt_base_info SET
423
+            rcpt_yn = #{entity.rcptYn},
424
+            <if test='"Y".equals(entity.rcptYn)'>
425
+            rcpt_dt = DATE_FORMAT(NOW(),'%Y%m%d'),
426
+            </if>
427
+            rcpt_amt = #{entity.rcptAmt},
428
+            sys_chg_dttm = NOW(),
429
+            sys_chg_id = #{userId}
430
+        WHERE sttl_mgnt_unq_no = #{entity.sttlMgntUnqNo}
431
+    </update>
432
+
420 433
 </mapper>