浏览代码

반품요청현황 처리 후 구매요청 부분 로그인대상 데이타 검증 처리 로직 추가

dwkim 2 年之前
父节点
当前提交
72ad1d0e00

+ 6 - 0
src/main/java/com/oqpo/api/entity/rtnmng/RtnReqBaseInfoEntity.java

@@ -15,9 +15,13 @@ public class RtnReqBaseInfoEntity implements Serializable {
15 15
     @ApiModelProperty(value = "반품요청고유번호") private String rtnReqUnqNo;
16 16
     @ApiModelProperty(value = "매장아이디") private String storeId;
17 17
     @ApiModelProperty(value = "브랜드아이디") private String brandId;
18
+    @ApiModelProperty(value = "브랜드명") private String brandNm;
19
+    @ApiModelProperty(value = "매장아이디") private String stroeId;
20
+    @ApiModelProperty(value = "매장명") private String stroeNm;
18 21
     @ApiModelProperty(value = "반품요청일자") private String rtnReqDt;
19 22
     @ApiModelProperty(value = "반품요청시각") private String rtnReqTm;
20 23
     @ApiModelProperty(value = "반품요청상태코드") private String rtnReqStCd;
24
+    @ApiModelProperty(value = "반품요청상태명") private String rtnReqStNm;
21 25
     @ApiModelProperty(value = "반품요청담당자아이디") private String rtnReqMgrId;
22 26
     @ApiModelProperty(value = "반품요청담당자명") private String rtnReqMgrNm;
23 27
     @ApiModelProperty(value = "반품요청담당자이메일") private String rtnReqMgrEmal;
@@ -33,7 +37,9 @@ public class RtnReqBaseInfoEntity implements Serializable {
33 37
     @ApiModelProperty(value = "반품요청금액") private Long rtnReqAmt;
34 38
     @ApiModelProperty(value = "반품요청품목수") private Integer rtnReqItemQty;
35 39
     @ApiModelProperty(value = "반품창고아이디") private String rtnWhsId;
40
+    @ApiModelProperty(value = "반품창고명") private String rtnWhsNm;
36 41
     @ApiModelProperty(value = "반품LOCATION") private String rtnLocation;
42
+    @ApiModelProperty(value = "반품LOCATION명") private String rtnLocationNm;
37 43
     @ApiModelProperty(value = "시스템등록일시") private String sysRegDttm;
38 44
     @ApiModelProperty(value = "시스템등록아이디") private String sysRegId;
39 45
     @ApiModelProperty(value = "시스템변경일시") private String sysChgDttm;

+ 2 - 0
src/main/java/com/oqpo/api/entity/rtnmng/RtnReqDtlPtclEntity.java

@@ -20,12 +20,14 @@ public class RtnReqDtlPtclEntity implements Serializable {
20 20
     @ApiModelProperty(value = "반품수량") private Integer rtnQty;
21 21
     @ApiModelProperty(value = "반품금액") private Long rtnAmt;
22 22
     @ApiModelProperty(value = "반품구분") private String rtnDvsn;
23
+    @ApiModelProperty(value = "반품구분명") private String rtnDvsnNm;
23 24
     @ApiModelProperty(value = "반품사유") private String rtnRsn;
24 25
     @ApiModelProperty(value = "공급사아이디") private String spplyId;
25 26
     @ApiModelProperty(value = "단가금액") private Long unitAmt;
26 27
     @ApiModelProperty(value = "매장단가고유번호") private String storeUnitUnqNo;
27 28
     @ApiModelProperty(value = "반품예상금액") private Long rtnExpctAmt;
28 29
     @ApiModelProperty(value = "반품사유구분") private String rtnRsnDvsn;
30
+    @ApiModelProperty(value = "반품사유구분명") private String rtnRsnDvsnNm;
29 31
     @ApiModelProperty(value = "시스템등록일시") private String sysRegDttm;
30 32
     @ApiModelProperty(value = "시스템등록아이디") private String sysRegId;
31 33
     @ApiModelProperty(value = "시스템변경일시") private String sysChgDttm;

+ 2 - 0
src/main/java/com/oqpo/api/enums/SystemMessageCode.java

@@ -48,6 +48,8 @@ public enum SystemMessageCode {
48 48
     ERR_EXISTUNIT (40021, "진행중인 단가계약가 있습니다.", HttpStatus.BAD_REQUEST),
49 49
     ERR_CHGDTOPP (40022, "시작일과 종료일이 잘 못되어져 있습니다.", HttpStatus.BAD_REQUEST),
50 50
     ERR_NOTCHGDT (40023, "시작일은 변경 불가 합니다.", HttpStatus.BAD_REQUEST),
51
+    ERR_NOTBRANDBELONG (40024, "소속 브랜드 정보가 틀립니다.!", HttpStatus.BAD_REQUEST),
52
+    ERR_NOTSTOREBELONG (40024, "소속 매장 정보가 틀립니다.!", HttpStatus.BAD_REQUEST),
51 53
     ;
52 54
 
53 55
 

+ 1 - 1
src/main/java/com/oqpo/api/mapper/pomng/PchReqMapper.java

@@ -17,7 +17,7 @@ public interface PchReqMapper {
17 17
     List<PchReqBaseInfoEntity> selectPchReqGridList(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sWhsId") String sWhsId , @Param("sPchReqStCd") String sPchReqStCd , @Param("sItemNm") String sItemNm ,  GridRequest gridRequest)throws Exception;
18 18
     int selectPchReqGridCnt(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sWhsId") String sWhsId , @Param("sPchReqStCd") String sPchReqStCd , @Param("sItemNm") String sItemNm )throws Exception;
19 19
 
20
-    PchReqBaseInfoEntity selectPchReqInfo(@Param("brandId") String brandId, @Param("pchReqUnqNo") String pchReqUnqNo)throws Exception;
20
+    PchReqBaseInfoEntity selectPchReqInfo(@Param("brandId") String brandId,@Param("storeId") String storeId,  @Param("pchReqUnqNo") String pchReqUnqNo)throws Exception;
21 21
     List<PchReqDtlPtclEntity> selectPchReqDtlPtcl(@Param("brandId") String brandId, @Param("pchReqUnqNo") String pchReqUnqNo)throws Exception;
22 22
 
23 23
 

+ 6 - 0
src/main/java/com/oqpo/api/mapper/rtnmng/RtnReqMapper.java

@@ -23,6 +23,12 @@ public interface RtnReqMapper {
23 23
     int selectMaxRtnReqDtlNo(@Param("rtnReqUnqNo") String rtnReqUnqNo) throws Exception;
24 24
     RtnReqBaseInfoEntity selectSumRtnAmt(@Param("rtnReqUnqNo") String rtnReqUnqNo) throws Exception;
25 25
 
26
+    List<RtnReqBaseInfoEntity> selectRtnReqGridList(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sWhsId") String sWhsId, @Param("sRtnReqStCd") String sRtnReqStCd, @Param("sItemNm") String sItemNm, GridRequest gridRequest)throws Exception;
27
+    int selectRtnReqGridCnt(@Param("sBrandId") String sBrandId,@Param("sStoreId") String sStoreId,  @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sWhsId") String sWhsId, @Param("sRtnReqStCd") String sRtnReqStCd, @Param("sItemNm") String sItemNm)throws Exception;
28
+
29
+
30
+    RtnReqBaseInfoEntity selectRtnReqInfo(@Param("brandId") String brandId, @Param("storeId") String storeId, @Param("rtnReqUnqNo") String rtnReqUnqNo)throws Exception;
31
+    List<RtnReqDtlPtclEntity> selectRtnReqDtlList(@Param("rtnReqUnqNo") String rtnReqUnqNo)throws Exception;
26 32
 /*
27 33
     List<PchReqBaseInfoEntity> selectPchReqGridList(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sWhsId") String sWhsId, @Param("sPchReqStCd") String sPchReqStCd, @Param("sItemNm") String sItemNm, GridRequest gridRequest)throws Exception;
28 34
     int selectPchReqGridCnt(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sWhsId") String sWhsId, @Param("sPchReqStCd") String sPchReqStCd, @Param("sItemNm") String sItemNm)throws Exception;

+ 61 - 7
src/main/java/com/oqpo/api/service/pomng/PchReqService.java

@@ -92,13 +92,29 @@ public class PchReqService extends CommonService {
92 92
         int gridPage = gridRequest.getGridPage();
93 93
         int gridSize = gridRequest.getGridSize();
94 94
 
95
+
95 96
         // 로그인자 권한이 50 이면 매장 아이디 필수로 넘어와야함
96 97
         UserMngEntity uEntity = userMngMapper.selectGroupUserInfo(userId);
97 98
 
98
-        if ("50".equals(uEntity.getAuthTpCd()) && "".equals(sStoreId)) {
99
-            throw new GlobalException(SystemMessageCode.ERR_NONSTOREID);
99
+        if ("50".equals(uEntity.getAuthTpCd())) {
100
+            if ("".equals(sStoreId)) {
101
+                throw new GlobalException(SystemMessageCode.ERR_NONSTOREID);
102
+            }
103
+
104
+            if (!sBrandId.equals(uEntity.getBrandId())) {
105
+                throw new GlobalException(SystemMessageCode.ERR_NOTBRANDBELONG);
106
+            }
107
+
108
+            if (!sStoreId.equals(uEntity.getStoreId())) {
109
+                throw new GlobalException(SystemMessageCode.ERR_NOTSTOREBELONG);
110
+            }
111
+        }  else if ("40".equals(uEntity.getAuthTpCd())){
112
+            if (!sBrandId.equals(uEntity.getBrandId())) {
113
+                throw new GlobalException(SystemMessageCode.ERR_NOTBRANDBELONG);
114
+            }
100 115
         }
101 116
 
117
+
102 118
         fromDt = fromDt == null ? null : fromDt.replace(".", "");
103 119
         toDt = toDt == null ? null : toDt.replace(".", "");
104 120
 
@@ -129,19 +145,37 @@ public class PchReqService extends CommonService {
129 145
     }
130 146
 
131 147
     /* 구매요청 정보 */
132
-    public PchReqInfoResponse selectPchReqInfo(String brandId, String  pchReqUnqNo) throws Exception {
148
+    public PchReqInfoResponse selectPchReqInfo(String userId, String brandId, String  pchReqUnqNo) throws Exception {
149
+
150
+        // 로그인자 권한이 50 이면 매장 아이디 필수로 넘어와야함
151
+        String storeId = "";
152
+        UserMngEntity uEntity = userMngMapper.selectGroupUserInfo(userId);
153
+
154
+        if ("50".equals(uEntity.getAuthTpCd())) {
155
+
156
+            if (!brandId.equals(uEntity.getBrandId())) {
157
+                throw new GlobalException(SystemMessageCode.ERR_NOTBRANDBELONG);
158
+            }
159
+            storeId = uEntity.getStoreId();
133 160
 
134
-        PchReqBaseInfoEntity entity = pchReqMapper.selectPchReqInfo(brandId, pchReqUnqNo);
161
+        } else if ("40".equals(uEntity.getAuthTpCd())){
162
+            if (!brandId.equals(uEntity.getBrandId())) {
163
+                throw new GlobalException(SystemMessageCode.ERR_NOTBRANDBELONG);
164
+            }
165
+        }
166
+
167
+
168
+        PchReqBaseInfoEntity entity = pchReqMapper.selectPchReqInfo(brandId, storeId, pchReqUnqNo);
135 169
         List<PchReqDtlPtclEntity> dtlEntity = pchReqMapper.selectPchReqDtlPtcl(brandId, pchReqUnqNo);
136 170
 
137 171
         //구매요청 기본정보
138
-        UserMngEntity uEntity = userMngMapper.selectGroupUserInfo(entity.getPchReqMgrId());
172
+        UserMngEntity uiEntity = userMngMapper.selectGroupUserInfo(entity.getPchReqMgrId());
139 173
 
140 174
         LoanMgntBaseInfoEntity loanEntity = new LoanMgntBaseInfoEntity();
141
-        if ("50".equals(uEntity.getAuthTpCd())) {
175
+        if ("50".equals(uiEntity.getAuthTpCd())) {
142 176
             loanEntity = loanStateMapper.selectLoanJobDataInfo(entity.getPchReqMgrId());
143 177
         }
144
-        return PchReqInfoResponse.toDTO(entity,uEntity,loanEntity, dtlEntity );
178
+        return PchReqInfoResponse.toDTO(entity,uiEntity,loanEntity, dtlEntity );
145 179
     }
146 180
 
147 181
     /* 구매요청 저장 */
@@ -153,6 +187,26 @@ public class PchReqService extends CommonService {
153 187
             UserMngEntity uEntity = userMngMapper.selectGroupUserInfo(userId);
154 188
             String userNm = uEntity.getUserNm();
155 189
 
190
+            // 로그인자 권한이 50 이면 매장 아이디 필수로 넘어와야함
191
+
192
+            if ("50".equals(uEntity.getAuthTpCd())) {
193
+                if ("".equals(savePchReqlRequest.getStoreId())) {
194
+                    throw new GlobalException(SystemMessageCode.ERR_NONSTOREID);
195
+                }
196
+
197
+                if (!savePchReqlRequest.getBrandId().equals(uEntity.getBrandId())) {
198
+                    throw new GlobalException(SystemMessageCode.ERR_NOTBRANDBELONG);
199
+                }
200
+
201
+                if (!savePchReqlRequest.getStoreId().equals(uEntity.getStoreId())) {
202
+                    throw new GlobalException(SystemMessageCode.ERR_NOTSTOREBELONG);
203
+                }
204
+            }  else if ("40".equals(uEntity.getAuthTpCd())){
205
+                if (!savePchReqlRequest.getBrandId().equals(uEntity.getBrandId())) {
206
+                    throw new GlobalException(SystemMessageCode.ERR_NOTBRANDBELONG);
207
+                }
208
+            }
209
+
156 210
             PchReqBaseInfoEntity entity = new PchReqBaseInfoEntity();
157 211
             entity.setPchReqUnqNo(savePchReqlRequest.getPchReqUnqNo());
158 212
             entity.setBrandId(savePchReqlRequest.getBrandId());

+ 129 - 1
src/main/java/com/oqpo/api/service/rtnmng/RtnReqService.java

@@ -25,7 +25,9 @@ import com.oqpo.api.web.dto.request.pomng.pchReq.SavePchReqlRequest;
25 25
 import com.oqpo.api.web.dto.request.rtnmng.SaveRtnReqlRequest;
26 26
 import com.oqpo.api.web.dto.response.GridResponse;
27 27
 import com.oqpo.api.web.dto.response.pomng.pchReq.*;
28
+import com.oqpo.api.web.dto.response.rtnmng.rtnReq.RtnReqInfoResponse;
28 29
 import com.oqpo.api.web.dto.response.rtnmng.rtnReq.RtnReqInitInfoResponse;
30
+import com.oqpo.api.web.dto.response.rtnmng.rtnReq.RtnReqSearchListResponse;
29 31
 import lombok.extern.slf4j.Slf4j;
30 32
 import org.springframework.beans.factory.annotation.Autowired;
31 33
 import org.springframework.stereotype.Service;
@@ -66,8 +68,22 @@ public class RtnReqService extends CommonService {
66 68
             uEntity.setBrandNm(brandEntity.getBrandNm());
67 69
 
68 70
         } else if ("40".equals(uEntity.getAuthTpCd())) {  // 브랜드
69
-            // 무시
71
+            if (!pchReqInitInfoRequest.getBrandId().equals(uEntity.getBrandId())) {
72
+                throw new GlobalException(SystemMessageCode.ERR_NOTBRANDBELONG);
73
+            }
70 74
         } else if ("50".equals(uEntity.getAuthTpCd())) {  // 매장
75
+            if ("".equals(pchReqInitInfoRequest.getStoreId())) {
76
+                throw new GlobalException(SystemMessageCode.ERR_NONSTOREID);
77
+            }
78
+
79
+            if (!pchReqInitInfoRequest.getBrandId().equals(uEntity.getBrandId())) {
80
+                throw new GlobalException(SystemMessageCode.ERR_NOTBRANDBELONG);
81
+            }
82
+
83
+            if (!pchReqInitInfoRequest.getStoreId().equals(uEntity.getStoreId())) {
84
+                throw new GlobalException(SystemMessageCode.ERR_NOTSTOREBELONG);
85
+            }
86
+
71 87
             //납품창고 정보 가져오기  selectStoreWhsLocList
72 88
             whsMgntList = whsMngMapper.selectStoreWhsLocList(pchReqInitInfoRequest.getBrandId(), pchReqInitInfoRequest.getStoreId());
73 89
 
@@ -95,6 +111,25 @@ public class RtnReqService extends CommonService {
95 111
             UserMngEntity uEntity = userMngMapper.selectGroupUserInfo(userId);
96 112
             String userNm = uEntity.getUserNm();
97 113
 
114
+            if ("50".equals(uEntity.getAuthTpCd())) {
115
+                if ("".equals(saveRtnReqlRequest.getStoreId())) {
116
+                    throw new GlobalException(SystemMessageCode.ERR_NONSTOREID);
117
+                }
118
+
119
+                if (!saveRtnReqlRequest.getBrandId().equals(uEntity.getBrandId())) {
120
+                    throw new GlobalException(SystemMessageCode.ERR_NOTBRANDBELONG);
121
+                }
122
+
123
+                if (!saveRtnReqlRequest.getStoreId().equals(uEntity.getStoreId())) {
124
+                    throw new GlobalException(SystemMessageCode.ERR_NOTSTOREBELONG);
125
+                }
126
+            }  else if ("40".equals(uEntity.getAuthTpCd())){
127
+                if (!saveRtnReqlRequest.getBrandId().equals(uEntity.getBrandId())) {
128
+                    throw new GlobalException(SystemMessageCode.ERR_NOTBRANDBELONG);
129
+                }
130
+            }
131
+
132
+
98 133
             RtnReqBaseInfoEntity entity = new RtnReqBaseInfoEntity();
99 134
 
100 135
             String rtnReqUnqNo = "";
@@ -140,6 +175,12 @@ public class RtnReqService extends CommonService {
140 175
                     maxDtlNo = maxDtlNo + 10 ;
141 176
                     gridInsertData.get(i).setRtnReqUnqNo(entity.getRtnReqUnqNo());
142 177
                     gridInsertData.get(i).setRtnReqDtlNo( Integer.toString(maxDtlNo));
178
+                    if (gridInsertData.get(i).getStoreUnitUnqNo() == null || "".equals(gridInsertData.get(i).getStoreUnitUnqNo())  ) {
179
+                        gridInsertData.get(i).setUnitGubun("B");
180
+                    } else {
181
+                        gridInsertData.get(i).setUnitGubun("S");
182
+                    }
183
+
143 184
                 }
144 185
 
145 186
                 rtnReqMapper.insertRtnReqDtlPtcl(userId, gridInsertData) ;
@@ -164,4 +205,91 @@ public class RtnReqService extends CommonService {
164 205
         }
165 206
     }
166 207
 
208
+    /* 반품요청 그리드 리스트 */
209
+    public GridResponse selectRtnReqGridList(String userId, String sBrandId, String sStoreId, String fromDt, String toDt, String sWhsId, String sRtnReqStCd, String sItemNm, GridRequest gridRequest) throws Exception {
210
+        int gridPage = gridRequest.getGridPage();
211
+        int gridSize = gridRequest.getGridSize();
212
+
213
+        // 로그인자 권한이 50 이면 매장 아이디 필수로 넘어와야함
214
+        UserMngEntity uEntity = userMngMapper.selectGroupUserInfo(userId);
215
+
216
+        if ("50".equals(uEntity.getAuthTpCd())) {
217
+            if ("".equals(sStoreId)) {
218
+                throw new GlobalException(SystemMessageCode.ERR_NONSTOREID);
219
+            }
220
+
221
+            if (!sBrandId.equals(uEntity.getBrandId())) {
222
+                throw new GlobalException(SystemMessageCode.ERR_NOTBRANDBELONG);
223
+            }
224
+
225
+            if (!sStoreId.equals(uEntity.getStoreId())) {
226
+                throw new GlobalException(SystemMessageCode.ERR_NOTSTOREBELONG);
227
+            }
228
+        }  else if ("40".equals(uEntity.getAuthTpCd())){
229
+            if (!sBrandId.equals(uEntity.getBrandId())) {
230
+                throw new GlobalException(SystemMessageCode.ERR_NOTBRANDBELONG);
231
+            }
232
+        }
233
+
234
+
235
+        fromDt = fromDt == null ? null : fromDt.replace(".", "");
236
+        toDt = toDt == null ? null : toDt.replace(".", "");
237
+
238
+        int gridRecords = rtnReqMapper.selectRtnReqGridCnt( sBrandId,sStoreId,  fromDt, toDt, sWhsId,sRtnReqStCd, sItemNm );
239
+        int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
240
+        List<RtnReqBaseInfoEntity> entities = rtnReqMapper.selectRtnReqGridList( sBrandId, sStoreId, fromDt, toDt, sWhsId,sRtnReqStCd, sItemNm, gridRequest);
241
+        List<Object> gridRows = entities.stream()
242
+                .map(m -> RtnReqSearchListResponse.builder()
243
+                        .viewCd("R")
244
+                        .rtnReqUnqNo(m.getRtnReqUnqNo() == null ? "" : m.getRtnReqUnqNo())
245
+                        .brandId(m.getBrandId() == null ? "" : m.getBrandId())
246
+                        .brandNm(m.getBrandNm() == null ? "" : m.getBrandNm())
247
+                        .storeId(m.getStoreId() == null ? "" : m.getStoreId())
248
+                        .storeNm(m.getStroeNm() == null ? "" : m.getStroeNm())
249
+                        .rtnReqStCd(m.getRtnReqStCd() == null ? "" : m.getRtnReqStCd())
250
+                        .rtnReqStNm(m.getRtnReqStNm() == null ? "" : m.getRtnReqStNm())
251
+                        .rtnWhsNm(m.getRtnWhsNm() == null ? "" : m.getRtnWhsNm() + " - " + m.getRtnLocationNm())
252
+                        .rtnReqDt(m.getRtnReqDt() == null ? "" : m.getRtnReqDt())
253
+                        .rtnReqItemQty(m.getRtnReqItemQty() == null ? 0 : m.getRtnReqItemQty())
254
+                        .rtnReqAmt(m.getRtnReqAmt() == null ? 0 : m.getRtnReqAmt())
255
+                        .colReqDt(m.getColReqDt() == null ? "" : m.getColReqDt())
256
+                        .rtnReqMgrId(m.getRtnReqMgrId() == null ? "" : m.getRtnReqMgrId())
257
+                        .rtnReqMgrNm(m.getRtnReqMgrNm() == null ? "" : m.getRtnReqMgrNm())
258
+                        .rtnRjctDt(m.getRtnRjctDt() == null ? "" : m.getRtnRjctDt())
259
+                        .rtnRjctNm(m.getRtnRjctNm() == null ? "" : m.getRtnRjctNm())
260
+                        .build())
261
+                .collect(Collectors.toList());
262
+        return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
263
+    }
264
+
265
+
266
+    /* 반품요청 정보 */
267
+    public RtnReqInfoResponse selectRtnReqInfo(String userId, String brandId, String  rtnReqUnqNo) throws Exception {
268
+
269
+        String storeId = "";
270
+
271
+        // 로그인자 권한이 50 이면 매장 아이디 필수로 넘어와야함
272
+        UserMngEntity uEntity = userMngMapper.selectGroupUserInfo(userId);
273
+
274
+        if ("50".equals(uEntity.getAuthTpCd())) {
275
+
276
+            if (!brandId.equals(uEntity.getBrandId())) {
277
+                throw new GlobalException(SystemMessageCode.ERR_NOTBRANDBELONG);
278
+            }
279
+
280
+            storeId = uEntity.getStoreId();
281
+
282
+        } else if ("40".equals(uEntity.getAuthTpCd())){
283
+            if (!brandId.equals(uEntity.getBrandId())) {
284
+                throw new GlobalException(SystemMessageCode.ERR_NOTBRANDBELONG);
285
+            }
286
+        }
287
+
288
+        RtnReqBaseInfoEntity entity = rtnReqMapper.selectRtnReqInfo(brandId, storeId,  rtnReqUnqNo);
289
+        List<RtnReqDtlPtclEntity> dtlEntity = rtnReqMapper.selectRtnReqDtlList(rtnReqUnqNo);
290
+
291
+
292
+
293
+        return RtnReqInfoResponse.toDTO(entity, dtlEntity);
294
+    }
167 295
 }

+ 2 - 2
src/main/java/com/oqpo/api/web/controller/pomng/PchReqController.java

@@ -80,8 +80,8 @@ public class PchReqController {
80 80
     })
81 81
     @ApiOperation(value = "구매요청 정보")
82 82
     @GetMapping("/info-pchReq")
83
-    public ResponseEntity<PchReqInfoResponse> infoPchReq(@RequestParam(value = "brandId") String brandId, @RequestParam(value = "pchReqUnqNo") String pchReqUnqNo) throws Exception {
84
-        return ResponseEntity.ok(pchReqService.selectPchReqInfo(brandId,pchReqUnqNo));
83
+    public ResponseEntity<PchReqInfoResponse> infoPchReq(@ApiIgnore String userId, @RequestParam(value = "brandId") String brandId, @RequestParam(value = "pchReqUnqNo") String pchReqUnqNo) throws Exception {
84
+        return ResponseEntity.ok(pchReqService.selectPchReqInfo(userId, brandId,pchReqUnqNo));
85 85
     }
86 86
 
87 87
 

+ 37 - 0
src/main/java/com/oqpo/api/web/controller/rtnmng/RtnReqController.java

@@ -7,12 +7,14 @@ import com.oqpo.api.web.dto.request.pomng.pchReq.PchReqInitInfoRequest;
7 7
 import com.oqpo.api.web.dto.request.pomng.pchReq.PchReqPoTargetSearchGridRequest;
8 8
 import com.oqpo.api.web.dto.request.pomng.pchReq.PchReqSearchGridRequest;
9 9
 import com.oqpo.api.web.dto.request.pomng.pchReq.SavePchReqlRequest;
10
+import com.oqpo.api.web.dto.request.rtnmng.RtnReqSearchGridRequest;
10 11
 import com.oqpo.api.web.dto.request.rtnmng.SaveRtnReqlRequest;
11 12
 import com.oqpo.api.web.dto.response.GridResponse;
12 13
 import com.oqpo.api.web.dto.response.SaveResponse;
13 14
 import com.oqpo.api.web.dto.response.pomng.pchReq.PchReqInfoResponse;
14 15
 import com.oqpo.api.web.dto.response.pomng.pchReq.PchReqInitInfoResponse;
15 16
 import com.oqpo.api.web.dto.response.pomng.pchReq.PchReqRejectTargetResponse;
17
+import com.oqpo.api.web.dto.response.rtnmng.rtnReq.RtnReqInfoResponse;
16 18
 import com.oqpo.api.web.dto.response.rtnmng.rtnReq.RtnReqInitInfoResponse;
17 19
 import io.swagger.annotations.Api;
18 20
 import io.swagger.annotations.ApiImplicitParam;
@@ -76,4 +78,39 @@ public class RtnReqController {
76 78
 
77 79
     }
78 80
 
81
+
82
+    /**
83
+     * 설명 : 반품요청 그리드 리스트
84
+     *
85
+     * @param rtnReqSearchGridRequest
86
+     * @return
87
+     * @throws Exception
88
+     */
89
+
90
+    @ApiImplicitParams({
91
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
92
+    })
93
+    @ApiOperation(value = " 반품요청 그리드 리스트")
94
+    @PostMapping("/detail-grid-list")
95
+    public ResponseEntity<GridResponse> detailGridList(@ApiIgnore String userId,   @RequestBody @Valid RtnReqSearchGridRequest rtnReqSearchGridRequest) throws Exception {
96
+        return ResponseEntity.ok(rtnReqService.selectRtnReqGridList(userId, rtnReqSearchGridRequest.getSBrandId(), rtnReqSearchGridRequest.getSStoreId(), rtnReqSearchGridRequest.getFromDt(), rtnReqSearchGridRequest.getToDt(), rtnReqSearchGridRequest.getSWhsId(), rtnReqSearchGridRequest.getSRtnReqStCd(), rtnReqSearchGridRequest.getSItemNm(),  rtnReqSearchGridRequest.toDTO(rtnReqSearchGridRequest)));
97
+    }
98
+
99
+    /**
100
+     * 설명 : 반품요청 정보
101
+     *
102
+     * @param brandId, pchReqUnqNo
103
+     * @return
104
+     * @throws Exception
105
+     */
106
+    @ApiImplicitParams({
107
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header"),
108
+            @ApiImplicitParam(name = "brandId", value = "브랜드아이디", required = true, dataType = "String", paramType = "query"),
109
+            @ApiImplicitParam(name = "rtnReqUnqNo", value = "반품요청번호", required = true, dataType = "String", paramType = "query")
110
+    })
111
+    @ApiOperation(value = "반품요청 정보")
112
+    @GetMapping("/info-rtnReq")
113
+    public ResponseEntity<RtnReqInfoResponse> infoRtnReq(@ApiIgnore String userId, @RequestParam(value = "brandId") String brandId, @RequestParam(value = "rtnReqUnqNo") String rtnReqUnqNo) throws Exception {
114
+        return ResponseEntity.ok(rtnReqService.selectRtnReqInfo(userId, brandId,rtnReqUnqNo));
115
+    }
79 116
 }

+ 44 - 0
src/main/java/com/oqpo/api/web/dto/request/rtnmng/RtnReqSearchGridRequest.java

@@ -0,0 +1,44 @@
1
+package com.oqpo.api.web.dto.request.rtnmng;
2
+
3
+import com.oqpo.api.web.dto.request.GridRequest;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.Getter;
6
+import lombok.Setter;
7
+
8
+import javax.validation.constraints.NotBlank;
9
+
10
+
11
+@Getter
12
+@Setter
13
+public class RtnReqSearchGridRequest extends GridRequest {
14
+
15
+    @NotBlank
16
+    @ApiModelProperty(value = "브랜드아이디")
17
+    private String sBrandId;
18
+
19
+    @ApiModelProperty(value = "매장아이디")
20
+    private String sStoreId;
21
+
22
+    @NotBlank
23
+    @ApiModelProperty(value = "시작일자")
24
+    private String fromDt;
25
+
26
+    @NotBlank
27
+    @ApiModelProperty(value = "종료일자")
28
+    private String toDt;
29
+
30
+    @ApiModelProperty(value = "창고번호")
31
+    private String sWhsId;
32
+
33
+    @ApiModelProperty(value = "상태")
34
+    private String sRtnReqStCd;
35
+
36
+    @ApiModelProperty(value = "품목명")
37
+    private String sItemNm;
38
+
39
+
40
+
41
+    protected RtnReqSearchGridRequest(Integer gridSize, Integer gridPage, String sidx, String sord, Boolean pagingYn, Integer gridFirst) {
42
+        super(gridSize, gridPage, sidx, sord, pagingYn, gridFirst);
43
+    }
44
+}

+ 124 - 0
src/main/java/com/oqpo/api/web/dto/response/rtnmng/rtnReq/RtnReqInfoResponse.java

@@ -0,0 +1,124 @@
1
+package com.oqpo.api.web.dto.response.rtnmng.rtnReq;
2
+
3
+import com.fasterxml.jackson.annotation.JsonInclude;
4
+import com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity;
5
+import com.oqpo.api.entity.oper.UserMngEntity;
6
+import com.oqpo.api.entity.pomng.PchReqBaseInfoEntity;
7
+import com.oqpo.api.entity.pomng.PchReqDtlPtclEntity;
8
+import com.oqpo.api.entity.rtnmng.RtnReqBaseInfoEntity;
9
+import com.oqpo.api.entity.rtnmng.RtnReqDtlPtclEntity;
10
+import io.swagger.annotations.ApiModelProperty;
11
+import lombok.*;
12
+
13
+import java.util.List;
14
+import java.util.stream.Collectors;
15
+
16
+
17
+@Getter
18
+@Setter
19
+@Builder
20
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
21
+@JsonInclude(JsonInclude.Include.ALWAYS)
22
+public class RtnReqInfoResponse {
23
+
24
+    @ApiModelProperty(value = "반품요청고유번호") private String rtnReqUnqNo;
25
+    @ApiModelProperty(value = "브랜드아이디") private String brandId;
26
+    @ApiModelProperty(value = "브랜드명") private String brandNm;
27
+    @ApiModelProperty(value = "매장아이디") private String stroeId;
28
+    @ApiModelProperty(value = "매장명") private String stroeNm;
29
+    @ApiModelProperty(value = "반품요청일자") private String rtnReqDt;
30
+    @ApiModelProperty(value = "반품요청상태코드") private String rtnReqStCd;
31
+    @ApiModelProperty(value = "반품요청상태명") private String rtnReqStNm;
32
+    @ApiModelProperty(value = "반품요청담당자아이디") private String rtnReqMgrId;
33
+    @ApiModelProperty(value = "반품요청담당자명") private String rtnReqMgrNm;
34
+    @ApiModelProperty(value = "창고구분") private String whsDvsn;
35
+    @ApiModelProperty(value = "수거요청일자") private String colReqDt;
36
+    @ApiModelProperty(value = "비고") private String note;
37
+    @ApiModelProperty(value = "반품반려일자") private String rtnRjctDt;
38
+    @ApiModelProperty(value = "반품반려자명") private String rtnRjctNm;
39
+    @ApiModelProperty(value = "반품반려자아이디") private String rtnRjctId;
40
+    @ApiModelProperty(value = "반품반려사유") private String rtnRjctRsn;
41
+    @ApiModelProperty(value = "반품요청금액") private Long rtnReqAmt;
42
+    @ApiModelProperty(value = "반품요청품목수") private Integer rtnReqItemQty;
43
+    @ApiModelProperty(value = "반품창고아이디") private String rtnWhsId;
44
+    @ApiModelProperty(value = "반품창고명") private String rtnWhsNm;
45
+    @ApiModelProperty(value = "반품LOCATION") private String rtnLocation;
46
+    @ApiModelProperty(value = "반품LOCATION명") private String rtnLocationNm;
47
+
48
+
49
+    @ApiModelProperty(value = "반품요청 품목 정보")
50
+    private List<RtnReqInfoResponse.RtnReqDtlInfo> rtnReqDtlList;
51
+
52
+    public static RtnReqInfoResponse toDTO(RtnReqBaseInfoEntity entity, List<RtnReqDtlPtclEntity>  dtlEntityList) {
53
+        if (entity == null) return null;
54
+        return RtnReqInfoResponse.builder()
55
+                .rtnReqUnqNo(entity.getRtnReqUnqNo() == null ? "" :entity.getRtnReqUnqNo())
56
+                .brandId(entity.getBrandId() == null ? "" :entity.getBrandId())
57
+                .brandNm(entity.getBrandNm() == null ? "" :entity.getBrandNm())
58
+                .stroeId(entity.getStroeId() == null ? "" :entity.getStroeId())
59
+                .stroeNm(entity.getStroeNm() == null ? "" :entity.getStroeNm())
60
+                .rtnReqDt(entity.getRtnReqDt() == null ? "" :entity.getRtnReqDt())
61
+                .rtnReqStCd(entity.getRtnReqStCd() == null ? "" :entity.getRtnReqStCd())
62
+                .rtnReqStNm(entity.getRtnReqStNm() == null ? "" :entity.getRtnReqStNm())
63
+                .rtnReqMgrId(entity.getRtnReqMgrId() == null ? "" :entity.getRtnReqMgrId())
64
+                .rtnReqMgrNm(entity.getRtnReqMgrNm() == null ? "" :entity.getRtnReqMgrNm())
65
+                .whsDvsn(entity.getWhsDvsn() == null ? "" :entity.getWhsDvsn())
66
+                .colReqDt(entity.getColReqDt() == null ? "" :entity.getColReqDt())
67
+                .note(entity.getNote() == null ? "" :entity.getNote())
68
+                .rtnRjctDt(entity.getRtnRjctDt() == null ? "" :entity.getRtnRjctDt())
69
+                .rtnRjctNm(entity.getRtnRjctNm() == null ? "" :entity.getRtnRjctNm())
70
+                .rtnRjctId(entity.getRtnRjctId() == null ? "" :entity.getRtnRjctId())
71
+                .rtnRjctRsn(entity.getRtnRjctRsn() == null ? "" :entity.getRtnRjctRsn())
72
+                .rtnReqAmt(entity.getRtnReqAmt() == null ? 0 :entity.getRtnReqAmt())
73
+                .rtnReqItemQty(entity.getRtnReqItemQty() == null ? 0 :entity.getRtnReqItemQty())
74
+                .rtnWhsId(entity.getRtnWhsId() == null ? "" :entity.getRtnWhsId())
75
+                .rtnWhsNm(entity.getRtnWhsNm() == null ? "" :entity.getRtnWhsNm() + " - " + entity.getRtnLocationNm())
76
+                .rtnLocation(entity.getRtnLocation() == null ? "" :entity.getRtnLocation())
77
+                .rtnReqDtlList(dtlEntityList.stream()
78
+                        .map(m -> RtnReqDtlInfo.builder()
79
+                                .rtnReqUnqNo(m.getRtnReqUnqNo() == null ? "" :m.getRtnReqUnqNo())
80
+                                .rtnReqDtlNo(m.getRtnReqDtlNo() == null ? "" :m.getRtnReqDtlNo())
81
+                                .itemId(m.getItemId() == null ? "" :m.getItemId())
82
+                                .itemNm(m.getItemNm() == null ? "" :m.getItemNm())
83
+                                .unit(m.getUnit() == null ? "" :m.getUnit())
84
+                                .rtnQty(m.getRtnQty() == null ? 0 :m.getRtnQty())
85
+                                .rtnAmt(m.getRtnAmt() == null ? 0 :m.getRtnAmt())
86
+                                .rtnDvsn(m.getRtnDvsn() == null ? "" :m.getRtnDvsn())
87
+                                .rtnDvsnNm(m.getRtnDvsnNm() == null ? "" :m.getRtnDvsnNm())
88
+                                .rtnRsn(m.getRtnRsn() == null ? "" :m.getRtnRsn())
89
+                                .spplyId(m.getSpplyId() == null ? "" :m.getSpplyId())
90
+                                .unitAmt(m.getUnitAmt() == null ? 0 :m.getUnitAmt())
91
+                                .storeUnitUnqNo(m.getStoreUnitUnqNo() == null ? "" :m.getStoreUnitUnqNo())
92
+                                .rtnRsnDvsn(m.getRtnRsnDvsn() == null ? "" :m.getRtnRsnDvsn())
93
+                                .rtnRsnDvsnNm(m.getRtnRsnDvsnNm() == null ? "" :m.getRtnRsnDvsnNm())
94
+                                .brandUnitUnqNo(m.getBrandUnitUnqNo() == null ? "" :m.getBrandUnitUnqNo())
95
+                                .unitGubun(m.getUnitGubun() == null ? "" :m.getUnitGubun())
96
+                                .build())
97
+                        .collect(Collectors.toList()))
98
+                .build();
99
+    }
100
+
101
+    @Getter
102
+    @Builder
103
+    @AllArgsConstructor(access = AccessLevel.PROTECTED)
104
+    static class RtnReqDtlInfo {
105
+
106
+        @ApiModelProperty(value = "반품요청고유번호") private String rtnReqUnqNo;
107
+        @ApiModelProperty(value = "반품요청상세번호") private String rtnReqDtlNo;
108
+        @ApiModelProperty(value = "품목아이디") private String itemId;
109
+        @ApiModelProperty(value = "품목명") private String itemNm;
110
+        @ApiModelProperty(value = "단위") private String unit;
111
+        @ApiModelProperty(value = "반품수량") private Integer rtnQty;
112
+        @ApiModelProperty(value = "반품금액") private Long rtnAmt;
113
+        @ApiModelProperty(value = "반품구분") private String rtnDvsn;
114
+        @ApiModelProperty(value = "반품구분명") private String rtnDvsnNm;
115
+        @ApiModelProperty(value = "반품사유") private String rtnRsn;
116
+        @ApiModelProperty(value = "공급사아이디") private String spplyId;
117
+        @ApiModelProperty(value = "단가금액") private Long unitAmt;
118
+        @ApiModelProperty(value = "매장단가고유번호") private String storeUnitUnqNo;
119
+        @ApiModelProperty(value = "반품사유구분") private String rtnRsnDvsn;
120
+        @ApiModelProperty(value = "반품사유구분명") private String rtnRsnDvsnNm;
121
+        @ApiModelProperty(value = "브랜드단가고유번호") private String brandUnitUnqNo;
122
+        @ApiModelProperty(value = "단가구분") private String unitGubun;
123
+    }
124
+}

+ 66 - 0
src/main/java/com/oqpo/api/web/dto/response/rtnmng/rtnReq/RtnReqSearchListResponse.java

@@ -0,0 +1,66 @@
1
+package com.oqpo.api.web.dto.response.rtnmng.rtnReq;
2
+
3
+import com.fasterxml.jackson.annotation.JsonInclude;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.*;
6
+
7
+@Getter
8
+@Setter
9
+@Builder
10
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
11
+@JsonInclude(JsonInclude.Include.ALWAYS)
12
+public class RtnReqSearchListResponse {
13
+
14
+    @ApiModelProperty(value = "CRUD")
15
+    private String viewCd;
16
+
17
+    @ApiModelProperty(value = "반품요청고유번호")
18
+    private String rtnReqUnqNo;
19
+
20
+    @ApiModelProperty(value = "브랜드아이디")
21
+    private String brandId;
22
+
23
+    @ApiModelProperty(value = "브랜드명")
24
+    private String brandNm;
25
+
26
+    @ApiModelProperty(value = "매장아이디")
27
+    private String storeId;
28
+
29
+    @ApiModelProperty(value = "매장명")
30
+    private String storeNm;
31
+
32
+    @ApiModelProperty(value = "반품요청상태")
33
+    private String rtnReqStCd;
34
+
35
+    @ApiModelProperty(value = "반품요청상태명")
36
+    private String rtnReqStNm;
37
+
38
+    @ApiModelProperty(value = "납품장소")
39
+    private String rtnWhsNm;
40
+
41
+    @ApiModelProperty(value = "반품요청일")
42
+    private String rtnReqDt;
43
+
44
+    @ApiModelProperty(value = "반품요청품목수량")
45
+    private Integer rtnReqItemQty;
46
+
47
+    @ApiModelProperty(value = "반품요청합계금액")
48
+    private Long rtnReqAmt;
49
+
50
+    @ApiModelProperty(value = "수거요청일")
51
+    private String colReqDt;
52
+
53
+    @ApiModelProperty(value = "수거요청자아이디")
54
+    private String rtnReqMgrId;
55
+
56
+    @ApiModelProperty(value = "수거요청자명")
57
+    private String rtnReqMgrNm;
58
+
59
+    @ApiModelProperty(value = "반품요청반려일자")
60
+    private String rtnRjctDt;
61
+
62
+    @ApiModelProperty(value = "반품요청반려자명")
63
+    private String rtnRjctNm;
64
+
65
+
66
+}

+ 3 - 0
src/main/resources/mybatis/sqlmaps/pomng/PchReq.xml

@@ -82,6 +82,9 @@
82 82
             , nvl(pch_appr_amt,0) as pch_appr_amt, case when pch_req_total_amt = pch_appr_amt then 'Y' else 'N' end pch_appr_yn
83 83
         FROM pch_req_base_info
84 84
         WHERE brand_id = #{brandId}
85
+        <if test="storeId != null and storeId != ''">
86
+            and    store_id = #{storeId}
87
+        </if>
85 88
         and   pch_req_unq_no = #{pchReqUnqNo}
86 89
     </select>
87 90
 

+ 109 - 28
src/main/resources/mybatis/sqlmaps/rtnmng/RtnReq.xml

@@ -11,8 +11,8 @@
11 11
         , rtn_rjct_id, rtn_rjct_rsn, rtn_req_amt, rtn_req_item_qty, rtn_whs_id, rtn_location
12 12
         , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
13 13
         VALUES
14
-        (#{entity.rtnReqUnqNo}, #{entity.storeId}, #{entity.brandId}, #{entity.rtnReqDt}, #{entity.rtnReqTm}
15
-        , #{entity.rtnReqStCd}, #{entity.rtnReqMgrId}, #{entity.rtnReqMgrNm}, #{entity.rtnReqMgrTelNo}
14
+        (#{entity.rtnReqUnqNo}, #{entity.storeId}, #{entity.brandId}, case when #{entity.rtnReqStCd} = 'RR20' then  date_format(now(),'%Y%m%d') else null end , #{entity.rtnReqTm}
15
+        , #{entity.rtnReqStCd}, #{userId}, #{entity.rtnReqMgrNm}, #{entity.rtnReqMgrTelNo}
16 16
         , #{entity.whsDvsn}, #{entity.colReqDt}, #{entity.note}, #{entity.rtnRjctDt}, #{entity.rtnRjctNm}
17 17
         , #{entity.rtnRjctId}, #{entity.rtnRjctRsn}, #{entity.rtnReqAmt}, #{entity.rtnReqItemQty}, #{entity.rtnWhsId}, #{entity.rtnLocation}
18 18
         , NOW(), #{userId}, NOW(), #{userId})
@@ -21,7 +21,7 @@
21 21
 
22 22
     <update id="updateRtnReqBaseInfo">
23 23
         UPDATE rtn_req_base_info SET   /* RtnReqMapper.updateRtnReqBaseInfo */
24
-                rtn_req_dt = #{entity.rtnReqDt},
24
+                rtn_req_dt = case when #{entity.rtnReqStCd} = 'RR20' then  date_format(now(),'%Y%m%d')  else null end,
25 25
                 rtn_req_tm = #{entity.rtnReqTm},
26 26
                 rtn_req_st_cd = #{entity.rtnReqStCd},
27 27
                 whs_dvsn = #{entity.whsDvsn},
@@ -42,13 +42,13 @@
42 42
         INSERT INTO rtn_req_dtl_ptcl  /* RtnReqMapper.insertRtnReqDtlPtcl */
43 43
         (rtn_req_unq_no, rtn_req_dtl_no, item_id, item_nm, unit
44 44
         , rtn_qty, rtn_amt, rtn_dvsn, rtn_rsn
45
-        , spply_id, unit_amt, store_unit_unq_no, brand_unit_unq_no, rtn_rsn_dvsn
45
+        , spply_id, unit_amt, store_unit_unq_no, brand_unit_unq_no, rtn_rsn_dvsn, unit_gubun
46 46
         , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
47 47
         VALUES
48 48
         <foreach collection="gridInsertData" item="item" separator=",">
49 49
         (#{item.rtnReqUnqNo}, #{item.rtnReqDtlNo}, #{item.itemId}, #{item.itemNm}, #{item.unit}
50 50
         , #{item.rtnQty}, #{item.rtnAmt}, #{item.rtnDvsn}, #{item.rtnRsn}
51
-        , #{item.spplyId}, #{item.unitAmt}, #{item.storeUnitUnqNo}, #{item.brandUnitUnqNo}, #{item.rtnRsnDvsn}
51
+        , #{item.spplyId}, #{item.unitAmt}, #{item.storeUnitUnqNo}, #{item.brandUnitUnqNo}, #{item.rtnRsnDvsn}, #{unitGubun}
52 52
         , NOW(), #{userId}, NOW(), #{userId})
53 53
         </foreach>
54 54
     </insert>
@@ -89,46 +89,60 @@
89 89
             where rtn_req_unq_no = #{rtnReqUnqNo}
90 90
     </select>
91 91
 
92
-<!--
93
-    <select id="selectPchReqGridList" resultType="com.oqpo.api.entity.pomng.PchReqBaseInfoEntity">
94
-        select  /* PchReq.selectPchReqGridList */
95
-                pch_req_unq_no, brand_id, fn_brand_nm(brand_id) as brand_nm,  pch_req_nm
96
-                ,pch_req_st_cd, fn_code_nm('PCH_REQ_ST_Cd',pch_req_st_cd) as pch_req_st_nm
97
-                , pch_req_mgr_nm, date_format(dlv_req_dt,'%Y.%m.%d') as dlv_req_dt, pch_req_total_amt
98
-                ,pch_req_item_qty, date_format(pch_req_rjct_dt,'%Y.%m.%d') as pch_req_rjct_dt, pch_req_rjct_nm
99
-                ,whs_id, fn_whs_nm(brand_id, whs_id) as whs_nm
100
-                ,location, fn_whs_location_nm(brand_id, whs_id, location) as location_nm
101
-                ,date_format(pch_req_dt,'%Y.%m.%d') as pch_req_dt
102
-        from   pch_req_base_info
103
-        where  brand_id = #{sBrandId}
92
+    <select id="selectRtnReqGridList" resultType="com.oqpo.api.entity.rtnmng.RtnReqBaseInfoEntity">
93
+        select  base.brand_id, fn_brand_nm(base.brand_id) as brand_nm
94
+                ,base.store_id , fn_store_nm(base.brand_id, base.store_id) as store_nm
95
+                , base.rtn_req_unq_no
96
+                , base.rtn_req_st_cd, fn_code_nm(upper('rtn_req_st_cd'), base.rtn_req_st_cd) as rtn_req_st_nm
97
+                , base.rtn_whs_id, base.rtn_location, fn_whs_nm(base.brand_id, base.rtn_whs_id) as rtn_whs_nm
98
+                , fn_whs_location_nm(base.brand_id, base.rtn_whs_id, base.rtn_location) as rtn_location_nm
99
+                , date_format(base.rtn_req_dt, '%Y.%m.%d') as rtn_req_dt, base.rtn_req_item_qty, base.rtn_req_amt
100
+                , date_format(base.col_req_dt, '%Y.%m.%d') as col_req_dt, base.rtn_req_mgr_nm, base.rtn_req_mgr_id
101
+                , date_format(base.rtn_rjct_dt, '%Y.%m.%d') as rtn_rjct_dt, base.rtn_rjct_nm
102
+        from rtn_req_base_info base
103
+        where 1 = 1
104
+        and base.brand_id = #{sBrandId}
105
+        and base.col_req_dt between #{fromDt} and #{toDt}
104 106
         <if test="sStoreId != null and sStoreId != ''">
105
-        and    store_id = #{sStoreId}
107
+            and base.store_id = #{sStoreId}
106 108
         </if>
107
-        and    date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt}
108 109
         <if test="sWhsId != null and sWhsId != ''">
109
-            and    whs_id = #{sWhsId}
110
+        and base.rtn_whs_id = #{sWhsId}
110 111
         </if>
111
-        <if test="sPchReqStCd != null and sPchReqStCd != ''">
112
-            and    pch_req_st_cd = #{sPchReqStCd}
112
+        <if test="sRtnReqStCd != null and sRtnReqStCd != ''">
113
+        and base.rtn_req_st_cd = #{sRtnReqStCd}
113 114
         </if>
114 115
         <if test="sItemNm != null and sItemNm != ''">
115
-            and    pch_req_unq_no in ( select pch_req_unq_no from pch_req_dtl_ptcl
116
-            where date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt})
117
-            and  item_id like concat('%',#{sItemNm},'%') or item_nm like concat('%',#{sItemNm},'%')
116
+        and base.rtn_req_unq_no in (select  ptcl.rtn_req_unq_no
117
+                                    from rtn_req_base_info sbase,
118
+                                        rtn_req_dtl_ptcl  ptcl
119
+                                    where sbase.rtn_req_unq_no = ptcl.rtn_req_unq_no
120
+                                    and   sbase.brand_id = #{sBrandId}
121
+                                    and   sbase.col_req_dt between #{fromDt} and #{toDt}
122
+                                    <if test="sStoreId != null and sStoreId != ''">
123
+                                        and sbase.store_id = #{sStoreId}
124
+                                    </if>
125
+                                    <if test="sWhsId != null and sWhsId != ''">
126
+                                        and sbase.rtn_whs_id = #{sWhsId}
127
+                                    </if>
128
+                                    <if test="sRtnReqStCd != null and sRtnReqStCd != ''">
129
+                                        and sbase.rtn_req_st_cd = #{sRtnReqStCd}
130
+                                    </if>
131
+                                    and   (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%')) )
118 132
         </if>
119 133
         <choose>
120 134
             <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
121 135
                 <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
122 136
                     <if test="gridRequest.sord == 'asc'.toString()">
123
-                        order by pch_req_unq_no asc
137
+                        order by base.rtn_req_unq_no asc
124 138
                     </if>
125 139
                     <if test="gridRequest.sord == 'desc'.toString()">
126
-                        order by pch_req_unq_no desc
140
+                        order by base.rtn_req_unq_no desc
127 141
                     </if>
128 142
                 </if>
129 143
             </when>
130 144
             <otherwise>
131
-                order by pch_req_unq_no desc
145
+                order by base.rtn_req_unq_no desc
132 146
             </otherwise>
133 147
         </choose>
134 148
         <if test="gridRequest.pagingYn == true">
@@ -136,6 +150,73 @@
136 150
         </if>
137 151
     </select>
138 152
 
153
+    <select id="selectRtnReqGridCnt" resultType="int">
154
+        select count(*)
155
+        from rtn_req_base_info base
156
+        where 1 = 1
157
+        and base.brand_id = #{sBrandId}
158
+        and base.col_req_dt between #{fromDt} and #{toDt}
159
+        <if test="sStoreId != null and sStoreId != ''">
160
+            and base.store_id = #{sStoreId}
161
+        </if>
162
+        <if test="sWhsId != null and sWhsId != ''">
163
+            and base.rtn_whs_id = #{sWhsId}
164
+        </if>
165
+        <if test="sRtnReqStCd != null and sRtnReqStCd != ''">
166
+            and base.rtn_req_st_cd = #{sRtnReqStCd}
167
+        </if>
168
+        <if test="sItemNm != null and sItemNm != ''">
169
+            and base.rtn_req_unq_no in (select  ptcl.rtn_req_unq_no
170
+                                        from rtn_req_base_info sbase,
171
+                                        rtn_req_dtl_ptcl  ptcl
172
+                                        where sbase.rtn_req_unq_no = ptcl.rtn_req_unq_no
173
+                                        and   sbase.brand_id = #{sBrandId}
174
+                                        and   sbase.col_req_dt between #{fromDt} and #{toDt}
175
+                                        <if test="sStoreId != null and sStoreId != ''">
176
+                                            and sbase.store_id = #{sStoreId}
177
+                                        </if>
178
+                                        <if test="sWhsId != null and sWhsId != ''">
179
+                                            and sbase.rtn_whs_id = #{sWhsId}
180
+                                        </if>
181
+                                        <if test="sRtnReqStCd != null and sRtnReqStCd != ''">
182
+                                            and sbase.rtn_req_st_cd = #{sRtnReqStCd}
183
+                                        </if>
184
+                                        and   (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%')) )
185
+        </if>
186
+    </select>
187
+
188
+    <select id="selectRtnReqInfo" resultType="com.oqpo.api.entity.rtnmng.RtnReqBaseInfoEntity">
189
+        SELECT rtn_req_unq_no, brand_id, fn_brand_nm(brand_id) as brand_nm
190
+                , store_id, fn_store_nm(brand_id, store_id) as store_nm
191
+                , date_format(rtn_req_dt,'%Y.%m.%d') as rtn_req_dt, rtn_req_st_cd, fn_code_nm('RTN_REQ_ST_Cd',rtn_req_st_cd) as rtn_req_st_nm
192
+                , rtn_req_mgr_id, rtn_req_mgr_nm, whs_dvsn, fn_code_nm('WHS_DVSN',whs_dvsn) as whs_dvsn_nm
193
+                , date_format(col_req_dt,'%Y.%m.%d') as col_req_dt, note, date_format(rtn_rjct_dt,'%Y.%m.%d') as rtn_rjct_dt, rtn_rjct_nm, rtn_rjct_id
194
+                , rtn_rjct_rsn, rtn_req_amt, rtn_req_item_qty
195
+                , rtn_whs_id, fn_whs_nm(brand_id, rtn_whs_id) as rtn_whs_nm
196
+                , rtn_location, fn_whs_location_nm(brand_id, rtn_whs_id, rtn_location) as rtn_location_nm
197
+                , date_format(sys_reg_dttm,'%Y.%m.%d') AS sys_reg_dttm, sys_reg_id, date_format(sys_chg_dttm,'%Y.%m.%d') AS sys_chg_dttm, sys_chg_id
198
+        FROM rtn_req_base_info
199
+        WHERE 1=1
200
+        AND   brand_id = #{brandId}
201
+        <if test="storeId != null and storeId != ''">
202
+            and store_id = #{storeId}
203
+        </if>
204
+        AND   rtn_req_unq_no = #{rtnReqUnqNo}
205
+    </select>
206
+
207
+    <select id="selectRtnReqDtlList" resultType="com.oqpo.api.entity.rtnmng.RtnReqDtlPtclEntity">
208
+        SELECT rtn_req_unq_no, rtn_req_dtl_no, item_id, item_nm, unit
209
+                , rtn_qty, rtn_amt, rtn_dvsn, fn_code_nm('RTN_DVSN',rtn_dvsn) as rtn_dvsn_nm
210
+                , rtn_rsn, spply_id
211
+                , unit_amt, store_unit_unq_no, brand_unit_unq_no, rtn_rsn_dvsn, fn_code_nm('RTN_RSN_DVSN',rtn_rsn_dvsn) as rtn_rsn_dvsn_nm
212
+                , unit_gubun, fn_code_nm('UNIT_GUBUN',unit_gubun) as unit_gubun_nm
213
+        FROM rtn_req_dtl_ptcl
214
+        WHERE rtn_req_unq_no = #{rtnReqUnqNo}
215
+    </select>
216
+
217
+<!--
218
+
219
+
139 220
     <select id="selectPchReqGridCnt" resultType="int">
140 221
             select count(*) as cnt
141 222
             from   pch_req_base_info