|
@@ -1,20 +1,26 @@
|
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.oper.UserMngEntity;
|
5
|
7
|
import com.oqpo.api.entity.rtnmng.RtnProcInfoPtclEntity;
|
6
|
8
|
import com.oqpo.api.entity.settmng.StlMgntBaseInfoEntity;
|
7
|
9
|
import com.oqpo.api.entity.settmng.StlMgntDtlPtclEntity;
|
|
10
|
+import com.oqpo.api.entity.stinfo.StoreBaseInfoEntity;
|
8
|
11
|
import com.oqpo.api.entity.stockmng.WhsProcInfoPtclEntity;
|
9
|
|
-import com.oqpo.api.enums.SttlDvsn;
|
10
|
|
-import com.oqpo.api.enums.SttlStCd;
|
|
12
|
+import com.oqpo.api.enums.*;
|
|
13
|
+import com.oqpo.api.mapper.loanmng.DsptMngMapper;
|
11
|
14
|
import com.oqpo.api.mapper.oper.UserMngMapper;
|
|
15
|
+import com.oqpo.api.mapper.stinfo.StoreBaseInfoMapper;
|
12
|
16
|
import com.oqpo.api.mapper.sttlmng.SttlReqMapper;
|
13
|
17
|
import com.oqpo.api.service.CommonService;
|
|
18
|
+import com.oqpo.api.util.DateUtil;
|
14
|
19
|
import com.oqpo.api.util.StringUtil;
|
15
|
20
|
import com.oqpo.api.web.dto.request.GridRequest;
|
16
|
21
|
import com.oqpo.api.web.dto.request.loanmng.ApproveDsptRequest;
|
17
|
22
|
import com.oqpo.api.web.dto.request.sttlmng.SttlReqData;
|
|
23
|
+import com.oqpo.api.web.dto.request.sttlmng.SttlReqProcData;
|
18
|
24
|
import com.oqpo.api.web.dto.request.sttlmng.SttlReqProcRequest;
|
19
|
25
|
import com.oqpo.api.web.dto.request.sttlmng.SttlReqRequest;
|
20
|
26
|
import com.oqpo.api.web.dto.response.GridResponse;
|
|
@@ -39,6 +45,12 @@ public class SttlReqService extends CommonService {
|
39
|
45
|
@Autowired
|
40
|
46
|
private UserMngMapper userMngMapper;
|
41
|
47
|
|
|
48
|
+ @Autowired
|
|
49
|
+ private StoreBaseInfoMapper storeBaseInfoMapper;
|
|
50
|
+
|
|
51
|
+ @Autowired
|
|
52
|
+ private DsptMngMapper dsptMngMapper;
|
|
53
|
+
|
42
|
54
|
/*
|
43
|
55
|
정산요청 그리드 리스트 조회
|
44
|
56
|
*/
|
|
@@ -189,13 +201,77 @@ public class SttlReqService extends CommonService {
|
189
|
201
|
/* 정산요청 처리 */
|
190
|
202
|
@Transactional
|
191
|
203
|
public void procSttlRequest(String userId, SttlReqProcRequest sttlReqProcRequest) throws Exception {
|
|
204
|
+ // 매장 정산타입 조회
|
|
205
|
+ StoreBaseInfoEntity storeInfo = storeBaseInfoMapper.selectStoreInfo(sttlReqProcRequest.getBrandId(), sttlReqProcRequest.getStoreId());
|
192
|
206
|
|
193
|
207
|
// 정산관리상세내역 처리
|
194
|
|
- // 정산타입에 따라
|
|
208
|
+ long sttlAmt = 0; // 정산금액
|
|
209
|
+ List<SttlReqProcData> list = sttlReqProcRequest.getSttlReqDataList();
|
|
210
|
+ for (SttlReqProcData item : list) {
|
|
211
|
+ // 정산관리상세내역 조회
|
|
212
|
+ StlMgntDtlPtclEntity dtlPtcl = sttlReqMapper.selectStlMgntDtlPtcl(sttlReqProcRequest.getSttlMgntUnqNo(), item.getSttlMgntDtlNo());
|
|
213
|
+ // 정산타입에 따라
|
|
214
|
+ if (LoanDvsn.PRE_PAYMENT.getCd().equals(storeInfo.getLoanDvsn())) {
|
|
215
|
+ // 정산금액
|
|
216
|
+ sttlAmt += dtlPtcl.getWhsColAmt();
|
|
217
|
+
|
|
218
|
+ // 1. 선불
|
|
219
|
+ // 1.1 여신관리기본정보(매장) 차감 : loan_mgnt_base_info
|
|
220
|
+ // 매장의 여신관리기본정보 조회 - 없으면 에러 처리
|
|
221
|
+ LoanMgntBaseInfoEntity loanBase = dsptMngMapper.selectLoanMgntBaseInfo(sttlReqProcRequest.getBrandId(), sttlReqProcRequest.getStoreId());
|
|
222
|
+ long trscBfBal = loanBase.getAcctBal();
|
|
223
|
+ long trscAfBal = loanBase.getAcctBal() - dtlPtcl.getWhsColAmt(); // 잔액에서 입고/수거금액 차감
|
|
224
|
+ long useAmtTotal = loanBase.getUseAmtTotal() - dtlPtcl.getWhsColAmt(); // 사용금액합계에서 입고/수거금액 차감
|
195
|
225
|
|
196
|
|
- // 정산구분에 따라 처리
|
|
226
|
+ loanBase.setAcctBal(trscBfBal);
|
|
227
|
+ loanBase.setUseAmtTotal(useAmtTotal);
|
|
228
|
+ sttlReqMapper.updateLoanMgntBaseInfo4SttlReqProc(userId, loanBase);
|
197
|
229
|
|
|
230
|
+ // 1.2 여신관리상세이력 등록 (지급/대체/정산지급)
|
|
231
|
+ // 여신관리상세이력 등록
|
|
232
|
+ LoanMgntDtlHstEntity hstEntity = new LoanMgntDtlHstEntity();
|
|
233
|
+ hstEntity.setLoanMgntUnqNo(storeInfo.getLoanMgntUnqNo());
|
|
234
|
+ hstEntity.setLoanRegDt(DateUtil.getCurrentDate());
|
|
235
|
+ hstEntity.setLoanRegTm(DateUtil.getCurrentTime());
|
|
236
|
+ hstEntity.setDpstPayDvsn(DpstPayDvsn.PAYMENT.getCd());
|
|
237
|
+ hstEntity.setMediaDvsn(MediaDvsn.SETTLMENT.getCd());
|
|
238
|
+ hstEntity.setPayType(PayType.STTL_PAY.getCd());
|
|
239
|
+ hstEntity.setTrscAmt(dtlPtcl.getWhsColAmt()); // 거래금액
|
|
240
|
+ hstEntity.setPaymAmt(dtlPtcl.getWhsColAmt()); // 지급금액
|
|
241
|
+ hstEntity.setTrscBfBal(trscBfBal);
|
|
242
|
+ hstEntity.setTrscAfBal(trscAfBal);
|
|
243
|
+ dsptMngMapper.insertLoanMgntDtlHst(userId, hstEntity);
|
|
244
|
+
|
|
245
|
+ // 1.3 정산구분에 따라 처리 (STTL_DVSN)
|
|
246
|
+ if (SttlDvsn.WHS.getCd().equals(dtlPtcl.getSttlDvsn())) { // 입고
|
|
247
|
+ // 입고처리정보내역 업데이트
|
|
248
|
+ sttlReqMapper.updateWhsProcInfoPtcl4SttlReqProc(userId, dtlPtcl);
|
|
249
|
+ } else if (SttlDvsn.RTN.getCd().equals(dtlPtcl.getSttlDvsn())) { // 수거
|
|
250
|
+ // 반품처리정보내역 업데이트
|
|
251
|
+ sttlReqMapper.updateRtnProcInfoPtcl4SttlReqProc(userId, dtlPtcl);
|
|
252
|
+ }
|
|
253
|
+ } else if (LoanDvsn.POST_PAYMENT.getCd().equals(storeInfo.getLoanDvsn())) {
|
|
254
|
+ // 2. 후불
|
|
255
|
+ // 정산상태코드만 변경하고 매장에서 정상확정시 여신처리를 한다.
|
|
256
|
+ }
|
|
257
|
+ }
|
198
|
258
|
// 정산관리기본정보 업데이트 (정산상태코드)
|
|
259
|
+ // 정산타입에 따라
|
|
260
|
+ if (LoanDvsn.PRE_PAYMENT.getCd().equals(storeInfo.getLoanDvsn())) {
|
|
261
|
+ StlMgntBaseInfoEntity baseInfo = new StlMgntBaseInfoEntity();
|
|
262
|
+ baseInfo.setSttlMgntUnqNo(sttlReqProcRequest.getSttlMgntUnqNo());
|
|
263
|
+ baseInfo.setSttlStCd(SttlStCd.STTL_CONFIRM.getCd());
|
|
264
|
+ baseInfo.setSttlDt(DateUtil.getCurrentDate());
|
|
265
|
+ baseInfo.setSttlAmt(sttlAmt);
|
|
266
|
+ sttlReqMapper.updateStlMgntBaseInfo4SttlReqProc(userId, baseInfo);
|
|
267
|
+ } else if (LoanDvsn.POST_PAYMENT.getCd().equals(storeInfo.getLoanDvsn())) {
|
|
268
|
+ StlMgntBaseInfoEntity baseInfo = new StlMgntBaseInfoEntity();
|
|
269
|
+ baseInfo.setSttlMgntUnqNo(sttlReqProcRequest.getSttlMgntUnqNo());
|
|
270
|
+ baseInfo.setSttlStCd(SttlStCd.STTL_REQ.getCd());
|
|
271
|
+ baseInfo.setSttlDt(null);
|
|
272
|
+ baseInfo.setSttlAmt(null);
|
|
273
|
+ sttlReqMapper.updateStlMgntBaseInfo4SttlReqProc(userId, baseInfo);
|
|
274
|
+ }
|
199
|
275
|
}
|
200
|
276
|
|
201
|
277
|
/* 정산요청 정보 조회 */
|