Parcourir la source

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

dwkim il y a 2 ans
Parent
commit
1cc74f1fad

+ 2 - 0
src/main/java/com/oqpo/api/entity/settmng/StlMgntBaseInfoEntity.java

@@ -32,6 +32,8 @@ public class StlMgntBaseInfoEntity implements Serializable {
32 32
     private String sttlStCd;
33 33
     @ApiModelProperty(value = "정산상태명")
34 34
     private String sttlStNm;
35
+    @ApiModelProperty(value = "정산부가상태명")
36
+    private String sttlAddStNm;
35 37
     @ApiModelProperty(value = "정산요청금액")
36 38
     private Long sttlReqAmt;
37 39
     @ApiModelProperty(value = "정산일자")

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

+ 1 - 0
src/main/java/com/oqpo/api/service/loanmng/EasypayPaymentService.java

@@ -534,6 +534,7 @@ public class EasypayPaymentService extends CommonService {
534 534
         dsptMngMapper.insertLoanMgntDsptProcInfo(userId, entity);
535 535
 
536 536
         // 5. 정산관리기본정보 업데이트
537
+        easypayPaymentRequest.setR_amount(Long.parseLong(r_amount));
537 538
         unpaidMngMapper.updateStlMgntBaseInfo4Rcpt(userId, easypayPaymentRequest);
538 539
     }
539 540
 

+ 1 - 0
src/main/java/com/oqpo/api/service/loanmng/UnpaidMngService.java

@@ -48,6 +48,7 @@ public class UnpaidMngService extends CommonService {
48 48
                         .storeNm(m.getStoreNm())
49 49
                         .sttlStCd(m.getSttlStCd())
50 50
                         .sttlStNm(m.getSttlStNm())
51
+                        .sttlAddStNm(m.getSttlAddStNm())
51 52
                         .sttlReqAmt(m.getSttlReqAmt())      /* 정산요청금액 */
52 53
                         .sttlDt(m.getSttlDt())              /* 정산확정일자 */
53 54
                         .sttlAmt(m.getSttlAmt())            /* 정산확정금액 */

+ 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
 

+ 5 - 0
src/main/java/com/oqpo/api/web/dto/request/loanmng/EasypayPaymentRequest.java

@@ -1,5 +1,6 @@
1 1
 package com.oqpo.api.web.dto.request.loanmng;
2 2
 
3
+import com.fasterxml.jackson.annotation.JsonIgnore;
3 4
 import com.fasterxml.jackson.annotation.JsonProperty;
4 5
 import io.swagger.annotations.ApiModelProperty;
5 6
 import lombok.Data;
@@ -87,4 +88,8 @@ public class EasypayPaymentRequest {
87 88
     @JsonProperty("sp_sessionkey")
88 89
     private String sp_sessionkey;
89 90
 
91
+    @ApiModelProperty(value = "결제금액", required = false)
92
+    @JsonIgnore
93
+    private Long r_amount;
94
+
90 95
 }

+ 3 - 0
src/main/java/com/oqpo/api/web/dto/response/loanmng/UnpaidMngInfoResponse.java

@@ -33,6 +33,8 @@ public class UnpaidMngInfoResponse {
33 33
     private String sttlStCd;
34 34
     @ApiModelProperty(value = "정산상태명")
35 35
     private String sttlStNm;
36
+    @ApiModelProperty(value = "정산부가상태명")
37
+    private String sttlAddStNm;
36 38
     @ApiModelProperty(value = "정산요청금액")
37 39
     private Long sttlReqAmt;
38 40
     @ApiModelProperty(value = "정산일자")
@@ -76,6 +78,7 @@ public class UnpaidMngInfoResponse {
76 78
                 .storeNm(entity.getStoreNm())
77 79
                 .sttlStCd(entity.getSttlStCd())
78 80
                 .sttlStNm(entity.getSttlStNm())
81
+                .sttlAddStNm(entity.getSttlAddStNm())       /* 정산부가상태명 */
79 82
                 .sttlReqAmt(entity.getSttlReqAmt())         /* 정산요청금액 */
80 83
                 .sttlAmt(entity.getSttlAmt())               /* 정산확정금액 */
81 84
                 .unpaidAmt(entity.getUnpaidAmt())           /* 미납금액 */

+ 2 - 0
src/main/java/com/oqpo/api/web/dto/response/loanmng/UnpaidMngListResponse.java

@@ -26,6 +26,8 @@ public class UnpaidMngListResponse {
26 26
     private String storeNm;
27 27
     @ApiModelProperty(value = "정산상태코드")
28 28
     private String sttlStCd;
29
+    @ApiModelProperty(value = "정산부가상태명")
30
+    private String sttlAddStNm;
29 31
     @ApiModelProperty(value = "정산상태명")
30 32
     private String sttlStNm;
31 33
     @ApiModelProperty(value = "정산요청일자")

+ 8 - 5
src/main/resources/mybatis/sqlmaps/loanmng/UnpaidMng.xml

@@ -20,6 +20,7 @@
20 20
             stl.sttl_amt,               /* 정산확정금액 */
21 21
             stl.rcpt_amt,               /* 수납금액 */
22 22
             (IFNULL(stl.sttl_amt, stl.sttl_req_amt) - IFNULL(stl.rcpt_amt, 0)) AS unpaid_amt,       /* 미납금액 */
23
+            stl.sttl_st_cd, FN_CODE_NM('STTL_ST_CD', stl.sttl_st_cd) AS sttl_st_nm,                 /* 정산상태코드 */
23 24
             <![CDATA[
24 25
             CASE WHEN store.sttl_req_cfrm_term > 0 AND store.sttl_rcp_amt_term > 0 THEN
25 26
                     CASE WHEN stl.sttl_req_dt IS NULL THEN '정산요청전'
@@ -35,9 +36,9 @@
35 36
                 END
36 37
                 END
37 38
                 ELSE '정산대기'
38
-            END AS sttl_st_nm,         /* 상태 */
39
+            END AS sttl_add_st_nm,          /* 정산부가상태 */
39 40
             ]]>
40
-            stl.sttl_mgnt_unq_no      /* 정산관리고유번호 */
41
+            stl.sttl_mgnt_unq_no            /* 정산관리고유번호 */
41 42
         FROM store_base_info store
42 43
         INNER JOIN loan_mgnt_base_info loan
43 44
             ON store.loan_mgnt_unq_no = loan.loan_mgnt_unq_no
@@ -116,6 +117,7 @@
116 117
             stl.sttl_amt,               /* 정산확정금액 */
117 118
             stl.rcpt_amt,               /* 수납금액 */
118 119
             (IFNULL(stl.sttl_amt, stl.sttl_req_amt) - IFNULL(stl.rcpt_amt, 0)) AS unpaid_amt,       /* 미납금액 */
120
+            stl.sttl_st_cd, FN_CODE_NM('STTL_ST_CD', stl.sttl_st_cd) AS sttl_st_nm,                 /* 정산상태코드 */
119 121
             <![CDATA[
120 122
             CASE WHEN store.sttl_req_cfrm_term > 0 AND store.sttl_rcp_amt_term > 0 THEN
121 123
                     CASE WHEN stl.sttl_req_dt IS NULL THEN '정산요청전'
@@ -131,7 +133,7 @@
131 133
                 END
132 134
                 END
133 135
                 ELSE '정산대기'
134
-            END AS sttl_st_nm,         /* 상태 */
136
+            END AS sttl_add_st_nm,         /* 상태 */
135 137
             ]]>
136 138
             stl.sttl_mgnt_unq_no,      /* 정산관리고유번호 */
137 139
             stl.rcpt_yn,               /* 수납여부(후불사용) */
@@ -197,8 +199,9 @@
197 199
     <update id="updateStlMgntBaseInfo4Rcpt" >
198 200
         /* UnpaidMngMapper.updateStlMgntBaseInfo4Rcpt */
199 201
         UPDATE stl_mgnt_base_info SET
200
-            rcpt_yn = 'Y',
201
-            rcpt_dt = DATE_FORMAT(NOW(),'%Y%m%d'),
202
+            rcpt_yn = 'Y',                                                          /* 수납여부 */
203
+            rcpt_dt = DATE_FORMAT(NOW(),'%Y%m%d'),                                  /* 수납일자 */
204
+            rcpt_amt = IFNULL(rcpt_amt, 0) + #{easypayPaymentRequest.r_amount},     /* 수납금액 : 결제금액을 더한다. */
202 205
             sys_chg_dttm = NOW(),
203 206
             sys_chg_id = #{userId}
204 207
         WHERE sttl_mgnt_unq_no = #{easypayPaymentRequest.sttlMgntUnqNo}

+ 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>