Browse Source

Merge branch 'master' of http://106.246.249.162:13000/orderqueen/oqpo-api

dwkim 2 years ago
parent
commit
d601126c64

+ 8 - 8
src/main/java/com/oqpo/api/entity/loanmng/LoanMgntBaseInfoEntity.java

@@ -27,21 +27,21 @@ public class LoanMgntBaseInfoEntity implements Serializable {
27 27
     @ApiModelProperty(value = "계좌번호")
28 28
     private String acctNo;
29 29
     @ApiModelProperty(value = "계좌잔액")
30
-    private long acctBal;
30
+    private Long acctBal;
31 31
     @ApiModelProperty(value = "여신구분")
32 32
     private String loanDvsn;
33 33
     @ApiModelProperty(value = "여신구분명")
34 34
     private String loanDvsnNm;
35 35
     @ApiModelProperty(value = "신용한도금액")
36
-    private long credtLimitAmt;
36
+    private Long credtLimitAmt;
37 37
     @ApiModelProperty(value = "충전한도금액")
38
-    private long chrgeLimitAmt;
38
+    private Long chrgeLimitAmt;
39 39
     @ApiModelProperty(value = "신용한도사용여부")
40 40
     private String credtLimitUseYn;
41 41
     @ApiModelProperty(value = "사용금액합계")
42
-    private long useAmtTotal;
42
+    private Long useAmtTotal;
43 43
     @ApiModelProperty(value = "가수금액합계")
44
-    private long tmpRcvAcctTotal;
44
+    private Long tmpRcvAcctTotal;
45 45
     @ApiModelProperty(value = "사용여부")
46 46
     private String useYn;
47 47
     @ApiModelProperty(value = "사용여부명")
@@ -61,11 +61,11 @@ public class LoanMgntBaseInfoEntity implements Serializable {
61 61
     @ApiModelProperty(value = "시스템변경자")
62 62
     private String sysChgNm;
63 63
     @ApiModelProperty(value = "주문사용가능금액")
64
-    private long ordUseAmt;
64
+    private Long ordUseAmt;
65 65
 
66 66
     @ApiModelProperty(value = "한도금액")
67
-    private long limitAmt;
67
+    private Long limitAmt;
68 68
     @ApiModelProperty(value = "가용한도금액")
69
-    private long posbLimitAmt;
69
+    private Long posbLimitAmt;
70 70
 
71 71
 }

+ 1 - 1
src/main/java/com/oqpo/api/entity/loanmng/LoanMgntDsptProcEntity.java

@@ -19,7 +19,7 @@ public class LoanMgntDsptProcEntity implements Serializable {
19 19
     @ApiModelProperty(value = "요청시각")
20 20
     private String reqTm;
21 21
     @ApiModelProperty(value = "입금금액")
22
-    private long dpstAmt;
22
+    private Long dpstAmt;
23 23
     @ApiModelProperty(value = "입금일자")
24 24
     private String dpstDt;
25 25
     @ApiModelProperty(value = "입금자명")

+ 5 - 5
src/main/java/com/oqpo/api/entity/loanmng/LoanMgntDtlHstEntity.java

@@ -23,15 +23,15 @@ public class LoanMgntDtlHstEntity implements Serializable {
23 23
     @ApiModelProperty(value = "입금지급구분명")
24 24
     private String dpstPayDvsnNm;
25 25
     @ApiModelProperty(value = "거래금액")
26
-    private long trscAmt;
26
+    private Long trscAmt;
27 27
     @ApiModelProperty(value = "입금금액")
28
-    private long dpstAmt;
28
+    private Long dpstAmt;
29 29
     @ApiModelProperty(value = "지급금액")
30
-    private long paymAmt;
30
+    private Long paymAmt;
31 31
     @ApiModelProperty(value = "거래전잔액")
32
-    private long trscBfBal;
32
+    private Long trscBfBal;
33 33
     @ApiModelProperty(value = "거래후잔액")
34
-    private long trscAfBal;
34
+    private Long trscAfBal;
35 35
     @ApiModelProperty(value = "매체구분")
36 36
     private String mediaDvsn;
37 37
     @ApiModelProperty(value = "매체구분명")

+ 36 - 0
src/main/java/com/oqpo/api/enums/LoanDvsn.java

@@ -0,0 +1,36 @@
1
+package com.oqpo.api.enums;
2
+
3
+import lombok.Getter;
4
+import lombok.Setter;
5
+
6
+public enum LoanDvsn {
7
+
8
+    PRE_PAYMENT("LD01", "선불(충전)"), //
9
+    POST_PAYMENT("LD02", "후불(신용)"), //
10
+    NO_STTL("LD03", "무정산"), //
11
+    ;
12
+
13
+    LoanDvsn(String cd, String nm) {
14
+        this.cd = cd;
15
+        this.name = nm;
16
+    }
17
+
18
+    @Getter
19
+    @Setter
20
+    private String cd;
21
+
22
+    @Getter
23
+    @Setter
24
+    private String name;
25
+
26
+    public static String getName(String ccd) {
27
+        LoanDvsn[] values = LoanDvsn.values();
28
+        for (LoanDvsn icd : values) {
29
+            if (icd.cd.equals(ccd)) {
30
+                return icd.name;
31
+            }
32
+        }
33
+        return ccd;
34
+    }
35
+
36
+}

+ 37 - 0
src/main/java/com/oqpo/api/enums/PayType.java

@@ -0,0 +1,37 @@
1
+package com.oqpo.api.enums;
2
+
3
+import lombok.Getter;
4
+import lombok.Setter;
5
+
6
+public enum PayType {
7
+
8
+    STTL_PAY("PT00", "정산지급"), //
9
+    CHARGE_PAYMENT("PT01", "충전결제"), //
10
+	STTL_PAYMENT("PT02", "정산결제"), //
11
+	PRE_PAYMENT("PT03", "선결제"), //
12
+    ;
13
+
14
+    PayType(String cd, String nm) {
15
+        this.cd = cd;
16
+        this.name = nm;
17
+    }
18
+
19
+    @Getter
20
+    @Setter
21
+    private String cd;
22
+
23
+    @Getter
24
+    @Setter
25
+    private String name;
26
+
27
+    public static String getName(String ccd) {
28
+        PayType[] values = PayType.values();
29
+        for (PayType icd : values) {
30
+            if (icd.cd.equals(ccd)) {
31
+                return icd.name;
32
+            }
33
+        }
34
+        return ccd;
35
+    }
36
+
37
+}

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

@@ -1,6 +1,7 @@
1 1
 package com.oqpo.api.mapper.sttlmng;
2 2
 
3 3
 
4
+import com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity;
4 5
 import com.oqpo.api.entity.rtnmng.RtnProcInfoPtclEntity;
5 6
 import com.oqpo.api.entity.settmng.StlMgntBaseInfoEntity;
6 7
 import com.oqpo.api.entity.settmng.StlMgntDtlPtclEntity;
@@ -46,4 +47,12 @@ public interface SttlReqMapper {
46 47
 
47 48
     int updateRtnProcInfoPtcl4SttlReq(@Param("userId") String userId, RtnProcInfoPtclEntity entity) throws Exception;
48 49
 
50
+    int updateLoanMgntBaseInfo4SttlReqProc(@Param("userId") String userId, LoanMgntBaseInfoEntity entity) throws Exception;
51
+
52
+    int updateWhsProcInfoPtcl4SttlReqProc(@Param("userId") String userId, StlMgntDtlPtclEntity entity) throws Exception;
53
+
54
+    int updateRtnProcInfoPtcl4SttlReqProc(@Param("userId") String userId, StlMgntDtlPtclEntity entity) throws Exception;
55
+
56
+    int updateStlMgntBaseInfo4SttlReqProc(@Param("userId") String userId, StlMgntBaseInfoEntity entity) throws Exception;
57
+
49 58
 }

+ 80 - 4
src/main/java/com/oqpo/api/service/sttlmng/SttlReqService.java

@@ -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
     /* 정산요청 정보 조회 */

+ 8 - 0
src/main/java/com/oqpo/api/web/dto/request/sttlmng/SttlReqProcRequest.java

@@ -11,6 +11,14 @@ import java.util.List;
11 11
 @Setter
12 12
 public class SttlReqProcRequest {
13 13
 
14
+    @ApiModelProperty(value = "브랜드아이디")
15
+    @NonNull
16
+    private String brandId;
17
+
18
+    @ApiModelProperty(value = "매장아이디")
19
+    @NonNull
20
+    private String storeId;
21
+
14 22
     @ApiModelProperty(value = "정산관리고유번호")
15 23
     @NonNull
16 24
     private String sttlMgntUnqNo;

+ 49 - 0
src/main/resources/mybatis/sqlmaps/sttlmng/SttlReq.xml

@@ -179,6 +179,8 @@
179 179
             A.brand_id, FN_BRAND_NM(A.brand_id) AS brand_nm,
180 180
             A.store_id, FN_STORE_NM(A.brand_id, A.store_id) AS store_nm,
181 181
             B.sttl_st_cd, FN_CODE_NM('STTL_ST_CD', B.sttl_st_cd) AS sttl_st_nm,
182
+            A.whs_mgnt_unq_no,          /* 입고관리고유번호 */
183
+            A.rtn_mgnt_unq_no,          /* 반품관리고유번호 */
182 184
             A.item_id, A.item_nm, A.unit, A.unit_amt,
183 185
             A.podr_qty, A.dlv_qty,
184 186
             A.sttl_dvsn, FN_CODE_NM('STTL_DVSN', A.sttl_dvsn) AS sttl_dvsn_nm,  /* 정산구분 */
@@ -331,4 +333,51 @@
331 333
         WHERE rtn_mgnt_unq_no = #{entity.rtnMgntUnqNo}
332 334
     </update>
333 335
 
336
+    <update id="updateLoanMgntBaseInfo4SttlReqProc" >
337
+        /* SttlReqMapper.updateLoanMgntBaseInfo4SttlReqProc */
338
+        UPDATE loan_mgnt_base_info SET
339
+            acct_bal = #{entity.acctBal},
340
+            use_amt_total = #{entity.useAmtTotal},
341
+            sys_chg_dttm = NOW(),
342
+            sys_chg_id = #{userId}
343
+        WHERE loan_mgnt_unq_no = #{entity.loanMgntUnqNo}
344
+    </update>
345
+
346
+    <update id="updateWhsProcInfoPtcl4SttlReqProc" >
347
+        /* SttlReqMapper.updateWhsProcInfoPtcl4SttlReqProc */
348
+        UPDATE whs_proc_info_ptcl SET
349
+            sttl_yn = 'Y',
350
+            sttl_mgnt_unq_no = #{entity.sttlMgntUnqNo},
351
+            sttl_mgnt_dtl_no = #{entity.sttlMgntDtlNo},
352
+            sys_chg_dttm = NOW(),
353
+            sys_chg_id = #{userId}
354
+        WHERE whs_mgnt_unq_no = #{entity.whsMgntUnqNo}
355
+    </update>
356
+
357
+    <update id="updateRtnProcInfoPtcl4SttlReqProc" >
358
+        /* SttlReqMapper.updateRtnProcInfoPtcl4SttlReqProc */
359
+        UPDATE rtn_proc_info_ptcl SET
360
+            sttl_yn = 'Y',
361
+            sttl_mgnt_unq_no = #{entity.sttlMgntUnqNo},
362
+            sttl_mgnt_dtl_no = #{entity.sttlMgntDtlNo},
363
+            sys_chg_dttm = NOW(),
364
+            sys_chg_id = #{userId}
365
+        WHERE rtn_mgnt_unq_no = #{entity.rtnMgntUnqNo}
366
+    </update>
367
+
368
+    <update id="updateStlMgntBaseInfo4SttlReqProc" >
369
+        /* SttlReqMapper.updateStlMgntBaseInfo4SttlReqProc */
370
+        UPDATE stl_mgnt_base_info SET
371
+            sttl_st_cd = #{entity.sttlStCd},
372
+            <if test="entity.sttlDt != null and entity.sttlDt != ''">
373
+            sttl_dt = #{entity.sttlDt},
374
+            </if>
375
+            <if test="entity.sttlAmt != null and entity.sttlAmt != ''">
376
+            sttl_amt = #{entity.sttlAmt},
377
+            </if>
378
+            sys_chg_dttm = NOW(),
379
+            sys_chg_id = #{userId}
380
+        WHERE sttl_mgnt_unq_no = #{entity.sttlMgntUnqNo}
381
+    </update>
382
+
334 383
 </mapper>