ソースを参照

반품관련 처리 프로세스 수정

dwkim 2 年 前
コミット
b5e6d6873c

+ 1 - 0
src/main/java/com/oqpo/api/enums/MediaDvsn.java

@@ -10,6 +10,7 @@ public enum MediaDvsn {
10 10
     CARD("CARD", "카드"), //
11 11
     SETTLMENT("STTL", "대체"), //
12 12
     VERTUAL("VRTL", "가상"), //
13
+    RTNC("RTNC", "반품"), //
13 14
     ;
14 15
 
15 16
     MediaDvsn(String cd, String nm) {

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

@@ -9,6 +9,7 @@ public enum PayType {
9 9
     CHARGE_PAYMENT("PT01", "충전결제"), //
10 10
 	STTL_PAYMENT("PT02", "정산결제"), //
11 11
 	PRE_PAYMENT("PT03", "선결제"), //
12
+    RTN_PAYMENT("PT04", "반품지급"), //
12 13
     ;
13 14
 
14 15
     PayType(String cd, String nm) {

+ 8 - 5
src/main/java/com/oqpo/api/mapper/loanmng/LoanStateMapper.java

@@ -28,14 +28,17 @@ public interface LoanStateMapper {
28 28
                               @Param("fromDt") String fromDt, @Param("toDt") String toDt) throws Exception;
29 29
 
30 30
 
31
-    LoanMgntBaseInfoEntity selectLoanJobDataInfo(@Param("storeId") String storeId) ;
31
+    LoanMgntBaseInfoEntity selectLoanJobDataInfo(@Param("storeId") String storeId)  throws Exception;
32 32
 
33
-    int updateloanPchReqUseAmt(@Param("loanMgntUnqNo") String loanMgntUnqNo, @Param("storeId") String storeId, @Param("ordPchReqAmt") long ordPchReqAmt);
34
-    int updateloanMinusPchReqUseAmt(@Param("loanMgntUnqNo") String loanMgntUnqNo, @Param("storeId") String storeId, @Param("ordPchReqAmt") long ordPchReqAmt);
33
+    int updateloanPchReqUseAmt(@Param("loanMgntUnqNo") String loanMgntUnqNo, @Param("storeId") String storeId, @Param("ordPchReqAmt") long ordPchReqAmt) throws Exception;
34
+    int updateloanMinusPchReqUseAmt(@Param("loanMgntUnqNo") String loanMgntUnqNo, @Param("storeId") String storeId, @Param("ordPchReqAmt") long ordPchReqAmt) throws Exception;
35 35
 
36
-    int updateloanMinusInstProc(@Param("loanMgntUnqNo") String loanMgntUnqNo, @Param("storeId") String storeId, @Param("useAmtTotal") long useAmtTotal);
36
+    int updateloanMinusInstProc(@Param("loanMgntUnqNo") String loanMgntUnqNo, @Param("storeId") String storeId, @Param("useAmtTotal") long useAmtTotal) throws Exception;
37 37
 
38
-    int updateListLoanMinusProc(@Param("userId") String userId, List<LoanMgntBaseInfoEntity> gridUpdateData );
38
+    int updateListLoanMinusProc(@Param("userId") String userId, List<LoanMgntBaseInfoEntity> gridUpdateData ) throws Exception;
39 39
 
40
+    int updateloanRtnacctBalAmt(@Param("userId") String userId, LoanMgntBaseInfoEntity entity) throws Exception;
41
+
42
+    LoanMgntBaseInfoEntity selectLoanRtnDataInfo(@Param("storeId") String storeId)  throws Exception;
40 43
 
41 44
 }

+ 49 - 3
src/main/java/com/oqpo/api/service/inoutmng/ColOdrService.java

@@ -3,6 +3,7 @@ package com.oqpo.api.service.inoutmng;
3 3
 
4 4
 import com.oqpo.api.entity.inoutmng.*;
5 5
 import com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity;
6
+import com.oqpo.api.entity.loanmng.LoanMgntDtlHstEntity;
6 7
 import com.oqpo.api.entity.oper.FileEntity;
7 8
 import com.oqpo.api.entity.oper.UserMngEntity;
8 9
 import com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity;
@@ -16,13 +17,12 @@ import com.oqpo.api.entity.stinfo.StoreBaseInfoEntity;
16 17
 import com.oqpo.api.entity.stockmng.StckMgntBaseInfoEntity;
17 18
 import com.oqpo.api.entity.stockmng.StckMgntDtlHistEntity;
18 19
 import com.oqpo.api.entity.stockmng.WhsProcInfoPtclEntity;
19
-import com.oqpo.api.enums.ChgDvsn;
20
-import com.oqpo.api.enums.InOutCd;
21
-import com.oqpo.api.enums.SystemMessageCode;
20
+import com.oqpo.api.enums.*;
22 21
 import com.oqpo.api.exception.GlobalException;
23 22
 import com.oqpo.api.mapper.FileMapper;
24 23
 import com.oqpo.api.mapper.inoutmng.ColOdrMapper;
25 24
 import com.oqpo.api.mapper.inoutmng.ShmtOdrMapper;
25
+import com.oqpo.api.mapper.loanmng.DsptMngMapper;
26 26
 import com.oqpo.api.mapper.loanmng.LoanStateMapper;
27 27
 import com.oqpo.api.mapper.oper.UserMngMapper;
28 28
 import com.oqpo.api.mapper.pomng.PchOrdMapper;
@@ -34,6 +34,7 @@ import com.oqpo.api.mapper.stockmng.StockMngMapper;
34 34
 import com.oqpo.api.service.CommonService;
35 35
 import com.oqpo.api.service.pomng.PchOrdService;
36 36
 import com.oqpo.api.service.rtnmng.RtnOdrService;
37
+import com.oqpo.api.util.DateUtil;
37 38
 import com.oqpo.api.web.dto.request.GridRequest;
38 39
 import com.oqpo.api.web.dto.request.inoutmng.*;
39 40
 import com.oqpo.api.web.dto.response.GridResponse;
@@ -78,6 +79,11 @@ public class ColOdrService extends CommonService {
78 79
     @Autowired
79 80
     private UserMngMapper userMngMapper;
80 81
 
82
+    @Autowired
83
+    private LoanStateMapper loanStateMapper;
84
+
85
+    @Autowired
86
+    private DsptMngMapper dsptMngMapper;
81 87
 
82 88
 
83 89
     /*
@@ -806,6 +812,9 @@ public class ColOdrService extends CommonService {
806 812
                 StoreBaseInfoEntity whsUseInfo = storeBaseInfoMapper.selectStoreLoanInfo(uEntity.getBrandId(), uEntity.getStoreId());
807 813
                 storeWhsUseYn = whsUseInfo.getWhsUseYn();
808 814
 
815
+                // 여신금액 합
816
+                long acctbalAmt = 0 ;
817
+
809 818
                 List<RtnProcInfoPtclEntity> rtnProcInfoPtclList = new ArrayList<RtnProcInfoPtclEntity>();
810 819
                 List<StckMgntBaseInfoEntity> stckMgntBaseInfoList = new ArrayList<StckMgntBaseInfoEntity>();
811 820
                 List<StckMgntDtlHistEntity> stckMgntDtlHistList= new ArrayList<StckMgntDtlHistEntity>();
@@ -817,6 +826,15 @@ public class ColOdrService extends CommonService {
817 826
                 // 반품처리를 위한 관련정보를 가져온다
818 827
                 List<PickInfoMgntEntity> targetList = colOdrMapper.selectColRtnInstProcList(saveRtnStockProcRequest.getBrandId(), saveRtnStockProcRequest.getRtnWhsId(), searchList);
819 828
 
829
+                //String loanMgntUnqNo = "";
830
+                LoanMgntBaseInfoEntity loanInfo = null ;
831
+                long loanAmt = 0 ; // 여신차감할 금액 (사용금액 - 여신차감금액,   잔액금액 - 여신차감금액)
832
+                if (!"".toString().equals(saveRtnStockProcRequest.getStoreId())) {
833
+                    loanInfo = loanStateMapper.selectLoanRtnDataInfo(saveRtnStockProcRequest.getStoreId());
834
+                }
835
+
836
+
837
+
820 838
                 for (int i = 0; i < gridInsertData.size(); i++) {
821 839
                     RtnProcInfoPtclEntity requestData = gridInsertData.get(i);
822 840
 
@@ -933,6 +951,9 @@ public class ColOdrService extends CommonService {
933 951
                                 stckW1Hist.setRelationNo(rtnMgntUnqNo);  //======================================
934 952
                                 stckMgntDtlHistList.add(stckW1Hist);
935 953
 
954
+                                //반품 금액 계산
955
+                                acctbalAmt = acctbalAmt +  (targetData.getPickDtlInfo().getUnitAmt() * requestData.getColQty()) ;
956
+
936 957
                             } else if (targetData.getColDvsn().equals("C002") && requestData.getColQty() > 0) {
937 958
                                 //  공급사 수거일경우 - 본사창고 재고 차감 처리
938 959
                                 // 1. 참감처리 , 2. 반품처리테이블 생성, 3. 수거서 업데이타, 4, 반품발주건 업데이트
@@ -1030,6 +1051,31 @@ public class ColOdrService extends CommonService {
1030 1051
                     List<PickInfoMgntEntity>  pickInfoList = colOdrMapper.selectColPickStList(userId, pickInfoMgntList);
1031 1052
                     colOdrMapper.updateChgStckPickStCd(userId, pickInfoList);
1032 1053
                 }
1054
+
1055
+                //수거 반품 금액 매장에 정산처리함 acctbalAmt
1056
+                if (loanInfo != null && !"".toString().equals(saveRtnStockProcRequest.getStoreId())) {
1057
+
1058
+                    if ("LD01".equals(loanInfo.getLoanDvsn()) || "LD02".equals(loanInfo.getLoanDvsn())) {
1059
+                        LoanMgntBaseInfoEntity loanEntity = new LoanMgntBaseInfoEntity();
1060
+                        loanEntity.setLoanMgntUnqNo(loanInfo.getLoanMgntUnqNo());
1061
+                        loanEntity.setStoreId(saveRtnStockProcRequest.getStoreId());
1062
+                        loanEntity.setAcctBal(acctbalAmt);
1063
+                        loanStateMapper.updateloanRtnacctBalAmt(userId, loanEntity);
1064
+
1065
+                        LoanMgntDtlHstEntity hstEntity = new LoanMgntDtlHstEntity();
1066
+                        hstEntity.setLoanMgntUnqNo(loanInfo.getLoanMgntUnqNo());
1067
+                        hstEntity.setLoanRegDt(DateUtil.getCurrentDate());
1068
+                        hstEntity.setLoanRegTm(DateUtil.getCurrentTime());
1069
+                        hstEntity.setDpstPayDvsn(DpstPayDvsn.DEPOSIT.getCd());
1070
+                        hstEntity.setMediaDvsn(MediaDvsn.RTNC.getCd());
1071
+                        hstEntity.setPayType(PayType.RTN_PAYMENT.getCd());
1072
+
1073
+                        hstEntity.setTrscAmt(acctbalAmt); // 거래금액
1074
+                        hstEntity.setTrscBfBal(loanInfo.getAcctBal());
1075
+                        hstEntity.setTrscAfBal(loanInfo.getAcctBal() + acctbalAmt);
1076
+                        dsptMngMapper.insertLoanMgntDtlHst(userId, hstEntity);
1077
+                    }
1078
+                }
1033 1079
             }
1034 1080
 
1035 1081
         } catch (GlobalException e) {

+ 1 - 1
src/main/java/com/oqpo/api/service/inoutmng/ShmtOdrService.java

@@ -182,7 +182,7 @@ public class ShmtOdrService extends CommonService {
182 182
                         }
183 183
 
184 184
                         if (reqEntity.getShmtQty() < entity.getPchOdrDtlInfo().getPodrQty()) {
185
-                            // 출고수량보다 발주수량클경우 구매금액을 차감 처리.
185
+                            // 출고수량보다 발주수량클경우 구매금액을 차감 처리. selectStoreLoanMgntUnqNo
186 186
                             String loanMgntUnqNo = storeBaseInfoMapper.selectStoreLoanMgntUnqNo(entity.getStoreId());
187 187
 
188 188
                             if (loanList.size() > 0) {

+ 17 - 0
src/main/resources/mybatis/sqlmaps/loanmng/LoanState.xml

@@ -184,4 +184,21 @@
184 184
             and   store_id = #{item.storeId}
185 185
         </foreach>
186 186
     </update>
187
+
188
+    <update id="updateloanRtnacctBalAmt">
189
+        update /* updateloanRtnacctBalAmt */ loan_mgnt_base_info
190
+        set   sys_chg_dttm = now()
191
+             ,sys_chg_id = #{userId}
192
+             ,acct_bal = acct_bal + #{entity.acctBal}
193
+        where loan_mgnt_unq_no = #{entity.loanMgntUnqNo}
194
+        and   store_id = #{entity.storeId}
195
+    </update>
196
+
197
+
198
+    <select id="selectLoanRtnDataInfo" resultType="com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity">
199
+        select loan_mgnt_unq_no, store_id, loan_dvsn, acct_bal
200
+        from   loan_mgnt_base_info
201
+        where  store_id = #{storeId}
202
+        and    use_yn = 'Y'
203
+    </select>
187 204
 </mapper>