|
@@ -82,36 +82,33 @@ public class SttlStateService extends CommonService {
|
82
|
82
|
@Transactional
|
83
|
83
|
public void endSttl(String userId, SttlConfirmRequest sttlConfirmRequest) throws Exception {
|
84
|
84
|
// 정산기본정보 조회
|
85
|
|
- StlMgntBaseInfoEntity entity = sttlReqMapper.selectStlMgntBaseInfo(sttlConfirmRequest.getSttlMgntUnqNo());
|
|
85
|
+ StlMgntBaseInfoEntity stlEntity = sttlReqMapper.selectStlMgntBaseInfo(sttlConfirmRequest.getSttlMgntUnqNo());
|
86
|
86
|
|
87
|
87
|
// 정산관리기본정보 - 정산상태코드 변경
|
88
|
|
- entity.setSttlStCd(SttlStCd.STTL_CONFIRM.getCd());
|
89
|
|
- entity.setSttlDt(DateUtil.getCurrentDate());
|
90
|
|
- entity.setSttlAmt(entity.getSttlReqAmt()); // 정산요청금액을 정산금액으로 지정한다.
|
91
|
|
- sttlReqMapper.updateStlMgntBaseInfo4SttlConfirm(userId, entity);
|
|
88
|
+ stlEntity.setSttlStCd(SttlStCd.STTL_CONFIRM.getCd());
|
|
89
|
+ stlEntity.setSttlDt(DateUtil.getCurrentDate());
|
|
90
|
+ stlEntity.setSttlAmt(stlEntity.getSttlReqAmt()); // 정산요청금액을 정산금액으로 지정한다.
|
|
91
|
+ sttlReqMapper.updateStlMgntBaseInfo4SttlConfirm(userId, stlEntity);
|
92
|
92
|
|
93
|
|
- if ("N".equals(entity.getRcptYn())) { // 수납여부가 N인 경우
|
|
93
|
+ if ("N".equals(stlEntity.getRcptYn())) { // 수납여부가 N인 경우
|
94
|
94
|
// 매장의 계좌잔액이 있은 경우 정산지급 처리를 한다.
|
95
|
95
|
// 매장 계좌잔액 조회
|
96
|
|
- LoanMgntBaseInfoEntity loanEntity = dsptMngMapper.selectLoanMgntBaseInfo(entity.getBrandId(), entity.getStoreId());
|
|
96
|
+ LoanMgntBaseInfoEntity loanEntity = dsptMngMapper.selectLoanMgntBaseInfo(stlEntity.getBrandId(), stlEntity.getStoreId());
|
97
|
97
|
if (loanEntity.getAcctBal() > 0) {
|
98
|
|
- // 계좌잔액이 정산요청금액 이상인 경우 정산요청금액을 지급처리하고 정산 데이터는 수납처리한다.
|
99
|
|
- // 계좌잔액이 정산요청금액 미만인 경우 계좌잔액을 지급처리하고 정산 데이터는 일부 수납처리한다. (미납금 발생)
|
100
|
|
- String rcptYn; // 수납완료여부
|
101
|
|
- long rcptAmt = 0; // 수납금액
|
102
|
|
- if (loanEntity.getAcctBal() >= entity.getSttlReqAmt()) {
|
103
|
|
- rcptAmt = entity.getSttlReqAmt();
|
104
|
|
- rcptYn = "Y";
|
|
98
|
+ // 계좌잔액이 미납금액 이상인 경우 미납금액을 지급처리하고 정산 데이터는 수납처리한다.
|
|
99
|
+ // 계좌잔액이 미납금액 미만인 경우 계좌잔액을 지급처리하고 정산 데이터는 일부 수납처리한다. (미납금 발생)
|
|
100
|
+ long trscAmt = 0; // 수납금액
|
|
101
|
+ if (loanEntity.getAcctBal() >= stlEntity.getUnpaidAmt()) {
|
|
102
|
+ trscAmt = stlEntity.getUnpaidAmt();
|
105
|
103
|
} else {
|
106
|
|
- rcptAmt = loanEntity.getAcctBal();
|
107
|
|
- rcptYn = "N";
|
|
104
|
+ trscAmt = loanEntity.getAcctBal();
|
108
|
105
|
}
|
109
|
106
|
|
110
|
107
|
// 1. 여신관리기본정보 처리
|
111
|
108
|
long trscBfBal = loanEntity.getAcctBal();
|
112
|
|
- long trscAfBal = loanEntity.getAcctBal() - rcptAmt;
|
|
109
|
+ long trscAfBal = loanEntity.getAcctBal() - trscAmt;
|
113
|
110
|
loanEntity.setAcctBal(trscAfBal); // 계좌잔액
|
114
|
|
- loanEntity.setUseAmtTotal(loanEntity.getUseAmtTotal() - rcptAmt); // 사용금액합계 감소
|
|
111
|
+ loanEntity.setUseAmtTotal(loanEntity.getUseAmtTotal() - trscAmt); // 사용금액합계 감소
|
115
|
112
|
sttlReqMapper.updateLoanMgntBaseInfo4SttlReqProc(userId, loanEntity);
|
116
|
113
|
|
117
|
114
|
// 2. 여신관리상세이력
|
|
@@ -122,15 +119,16 @@ public class SttlStateService extends CommonService {
|
122
|
119
|
hstEntity.setDpstPayDvsn(DpstPayDvsn.PAYMENT.getCd());
|
123
|
120
|
hstEntity.setMediaDvsn(MediaDvsn.SETTLMENT.getCd());
|
124
|
121
|
hstEntity.setPayType(PayType.STTL_PAY.getCd());
|
125
|
|
- hstEntity.setTrscAmt(rcptAmt); // 거래금액
|
|
122
|
+ hstEntity.setTrscAmt(trscAmt); // 거래금액
|
126
|
123
|
hstEntity.setTrscBfBal(trscBfBal); // 거래전잔액
|
127
|
124
|
hstEntity.setTrscAfBal(trscAfBal); // 거래후잔액
|
128
|
125
|
dsptMngMapper.insertLoanMgntDtlHst(userId, hstEntity);
|
129
|
126
|
|
130
|
127
|
// 3. 정산관리기본정보 수납처리
|
131
|
|
- entity.setRcptYn(rcptYn); // 수납여부
|
132
|
|
- entity.setRcptAmt(entity.getRcptAmt() + rcptAmt); // 수납금액
|
133
|
|
- sttlReqMapper.updateStlMgntBaseInfo4Rcpt(userId, entity);
|
|
128
|
+ long rcptAmt = stlEntity.getRcptAmt() + trscAmt; // 수납금액
|
|
129
|
+ stlEntity.setRcptYn(rcptAmt >= stlEntity.getSttlReqAmt() ? "Y" : "N");
|
|
130
|
+ stlEntity.setRcptAmt(rcptAmt);
|
|
131
|
+ sttlReqMapper.updateStlMgntBaseInfo4Rcpt(userId, stlEntity);
|
134
|
132
|
}
|
135
|
133
|
}
|
136
|
134
|
}
|