|
@@ -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
|
}
|