|
@@ -10,6 +10,7 @@ import com.oqpo.api.entity.rtnmng.RtnReqBaseInfoEntity;
|
10
|
10
|
import com.oqpo.api.entity.rtnmng.RtnReqDtlPtclEntity;
|
11
|
11
|
import com.oqpo.api.enums.SystemMessageCode;
|
12
|
12
|
import com.oqpo.api.exception.GlobalException;
|
|
13
|
+import com.oqpo.api.mapper.inoutmng.ColOdrMapper;
|
13
|
14
|
import com.oqpo.api.mapper.loanmng.LoanStateMapper;
|
14
|
15
|
import com.oqpo.api.mapper.oper.UserMngMapper;
|
15
|
16
|
import com.oqpo.api.mapper.rtnmng.RtnOdrMapper;
|
|
@@ -18,6 +19,8 @@ import com.oqpo.api.mapper.stinfo.StoreBaseInfoMapper;
|
18
|
19
|
import com.oqpo.api.mapper.stockmng.StockMngMapper;
|
19
|
20
|
import com.oqpo.api.service.CommonService;
|
20
|
21
|
import com.oqpo.api.web.dto.request.GridRequest;
|
|
22
|
+import com.oqpo.api.web.dto.request.pomng.pchOrd.CancelPchOrdDtlRequest;
|
|
23
|
+import com.oqpo.api.web.dto.request.rtnmng.CancelRtnOrdDtlRequest;
|
21
|
24
|
import com.oqpo.api.web.dto.request.rtnmng.RtnReqOrdInitRequest;
|
22
|
25
|
import com.oqpo.api.web.dto.request.rtnmng.SaveRtnOrdRequest;
|
23
|
26
|
import com.oqpo.api.web.dto.response.GridResponse;
|
|
@@ -29,6 +32,7 @@ import com.oqpo.api.web.dto.response.rtnmng.rtnOrd.RtnOrdInitInfoResponse;
|
29
|
32
|
import com.oqpo.api.web.dto.response.rtnmng.rtnOrd.RtnOrdNInitInfoResponse;
|
30
|
33
|
import com.oqpo.api.web.dto.response.rtnmng.rtnReq.RtnReqInitInfoResponse;
|
31
|
34
|
import lombok.extern.slf4j.Slf4j;
|
|
35
|
+import org.apache.ibatis.annotations.Param;
|
32
|
36
|
import org.springframework.beans.factory.annotation.Autowired;
|
33
|
37
|
import org.springframework.stereotype.Service;
|
34
|
38
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -52,6 +56,9 @@ public class RtnOdrService extends CommonService {
|
52
|
56
|
@Autowired
|
53
|
57
|
private RtnReqMapper rtnReqMapper;
|
54
|
58
|
|
|
59
|
+ @Autowired
|
|
60
|
+ private ColOdrMapper colOdrMapper;
|
|
61
|
+
|
55
|
62
|
@Autowired
|
56
|
63
|
private StoreBaseInfoMapper storeBaseInfoMapper;
|
57
|
64
|
|
|
@@ -427,47 +434,52 @@ public class RtnOdrService extends CommonService {
|
427
|
434
|
|
428
|
435
|
|
429
|
436
|
/*
|
430
|
|
- 발주 취소처리
|
431
|
|
-
|
|
437
|
+ 반품 발주 취소처리
|
|
438
|
+ */
|
432
|
439
|
@Transactional
|
433
|
|
- public void cancelPchOrdDtl(String userId, CancelPchOrdDtlRequest cancelPchOrdDtlRequest) throws Exception {
|
|
440
|
+ public void cancelRtnOrdDtl(String userId, CancelRtnOrdDtlRequest cancelRtnOrdDtlRequest) throws Exception {
|
434
|
441
|
try {
|
435
|
|
- // 품목 삭제 상태처리
|
436
|
|
- long podrAmt = 0;
|
437
|
|
- List<rtnOdrDtlPtclEntity> gridUpdateData = cancelPchOrdDtlRequest.toCodeEntities(cancelPchOrdDtlRequest.getGridUpdateData());
|
438
|
|
- List<StckMgntBaseInfoEntity> stckList = new ArrayList<StckMgntBaseInfoEntity>();
|
439
|
|
- if (gridUpdateData.size() > 0) {
|
440
|
|
- pchOrdMapper.updateCancelPodrDtl(userId, gridUpdateData) ;
|
441
|
442
|
|
442
|
|
- for (int i = 0 ; i < gridUpdateData.size() ; i++) {
|
443
|
|
- rtnOdrDtlPtclEntity delItem = gridUpdateData.get(i);
|
444
|
|
- podrAmt = podrAmt + delItem.getPodrAmt();
|
|
443
|
+ // 수거서 생성 여부 파악 (이미생성시 반품 취소 불가)
|
|
444
|
+ int ingCnt = colOdrMapper.selectColRtnIngCnt(cancelRtnOrdDtlRequest.getBrandId(), cancelRtnOrdDtlRequest.getRtnPodrUnqNo());
|
445
|
445
|
|
446
|
|
- if ("DL01".equals(cancelPchOrdDtlRequest.getDlvDvsn())) { // 본사배송이면
|
447
|
|
- StckMgntBaseInfoEntity stckEntity = new StckMgntBaseInfoEntity();
|
448
|
|
- stckEntity.setItemId(delItem.getItemId());
|
449
|
|
- stckEntity.setWaitQty(delItem.getPodrQty());
|
450
|
|
- stckList.add(stckEntity);
|
451
|
|
- }
|
452
|
|
- }
|
|
446
|
+ if (ingCnt > 0) {
|
|
447
|
+ throw new GlobalException(SystemMessageCode.ERR_INGCOLCNT);
|
453
|
448
|
}
|
454
|
449
|
|
455
|
|
- //발주취소로 인한 발주 head 상태값 변경처리 pchPodrUnqNo
|
456
|
|
- String rtnOdrStCd = selectOdrDtlStatusList(cancelPchOrdDtlRequest.getPchPodrUnqNo());
|
457
|
|
- pchOrdMapper.updateChgPodrStCd(userId, rtnOdrStCd, cancelPchOrdDtlRequest.getPchPodrUnqNo());
|
|
450
|
+ //반품요청 취소처리
|
|
451
|
+ rtnOdrMapper.updateChgRodrStCd(userId, cancelRtnOrdDtlRequest.getRtnPodrUnqNo(),"RO99");
|
|
452
|
+ rtnOdrMapper.updateChangeRodrDtlStCd(userId, cancelRtnOrdDtlRequest.getRtnPodrUnqNo(),"ROD2");
|
458
|
453
|
|
459
|
|
- // 매장 구매요청 발주일경우 사용금액 차감 처리함
|
460
|
|
- if (!"".equals(cancelPchOrdDtlRequest.getStoreId())) {
|
461
|
|
- String loanMgntUnqNo = storeBaseInfoMapper.selectStoreLoanMgntUnqNo(cancelPchOrdDtlRequest.getStoreId());
|
|
454
|
+ RtnOdrBaseInfoEntity rtnOdrInfo = rtnOdrMapper.selectRtnOdrInfo(cancelRtnOrdDtlRequest.getRtnPodrUnqNo());
|
462
|
455
|
|
463
|
|
- if (loanMgntUnqNo != null) {
|
464
|
|
- loanStateMapper.updateloanMinusPchReqUseAmt(loanMgntUnqNo, cancelPchOrdDtlRequest.getStoreId(), podrAmt);
|
465
|
|
- }
|
466
|
|
- }
|
|
456
|
+ // 반품요청건에 대한 상태에 대한 처리상태 변경 RR01
|
|
457
|
+ if ("RR01".equals(rtnOdrInfo.getRtnReqDvsn())) { // 요청반품건은 반품요청건 상태 변경처리함
|
|
458
|
+ List<RtnOdrDtlPtclEntity> rtnOrdList = rtnOdrMapper.selectROdrDtlList(cancelRtnOrdDtlRequest.getRtnPodrUnqNo());
|
|
459
|
+
|
|
460
|
+ List<RtnReqDtlPtclEntity> rtnReqDtlList = new ArrayList<RtnReqDtlPtclEntity>();
|
|
461
|
+ List<RtnReqBaseInfoEntity> rtnReqBaseList = new ArrayList<RtnReqBaseInfoEntity>();
|
|
462
|
+ String rtnReqUnqNo = "";
|
|
463
|
+ for (int i = 0 ; i < rtnOrdList.size() ;i++) {
|
|
464
|
+ RtnOdrDtlPtclEntity rtnOdrEntity = rtnOrdList.get(i);
|
|
465
|
+ RtnReqDtlPtclEntity rtnReqDtlEntity = new RtnReqDtlPtclEntity();
|
|
466
|
+ RtnReqBaseInfoEntity rtnReqBaseEntity = new RtnReqBaseInfoEntity();
|
|
467
|
+
|
|
468
|
+ rtnReqDtlEntity.setRtnReqUnqNo(rtnOdrEntity.getRtnReqUnqNo());
|
|
469
|
+ rtnReqDtlEntity.setRtnReqDtlNo(rtnOdrEntity.getRtnReqDtlNo());
|
|
470
|
+ rtnReqDtlEntity.setRtnReqDtlStCd("RRD99");
|
|
471
|
+ rtnReqDtlList.add(rtnReqDtlEntity);
|
467
|
472
|
|
468
|
|
- //출고가능수량을 복구처리
|
469
|
|
- if ("DL01".equals(cancelPchOrdDtlRequest.getDlvDvsn())) { // 본사배송이면
|
470
|
|
- stockMngMapper.updateStckPoUseQty(userId, cancelPchOrdDtlRequest.getBrandId(), cancelPchOrdDtlRequest.getShmtWhsId(), cancelPchOrdDtlRequest.getShmtLocation(), stckList );
|
|
473
|
+ if (!rtnReqUnqNo.equals(rtnOdrEntity.getRtnReqUnqNo())) {
|
|
474
|
+ rtnReqUnqNo = rtnOdrEntity.getRtnReqUnqNo();
|
|
475
|
+ rtnReqBaseEntity.setRtnReqUnqNo(rtnReqUnqNo);
|
|
476
|
+
|
|
477
|
+ String rtnReqStcd = rtnReqService.selectRtnReqDtlStatusList(rtnReqUnqNo);
|
|
478
|
+ rtnReqBaseEntity.setRtnReqStCd(rtnReqStcd);
|
|
479
|
+ rtnReqBaseList.add(rtnReqBaseEntity);
|
|
480
|
+ }
|
|
481
|
+ }
|
|
482
|
+ rtnReqMapper.updateRtnReqStCd(userId,rtnReqBaseList);
|
471
|
483
|
}
|
472
|
484
|
|
473
|
485
|
} catch (GlobalException e) {
|
|
@@ -480,40 +492,6 @@ public class RtnOdrService extends CommonService {
|
480
|
492
|
}
|
481
|
493
|
}
|
482
|
494
|
|
483
|
|
- public String selectOdrDtlStatusList(String pchReqUnqNo) throws Exception {
|
484
|
|
- //PCH_ODR_ST_CD
|
485
|
|
- String rtnOdrStCd = "";
|
486
|
|
- List<rtnOdrDtlPtclEntity> dtlEntity = pchOrdMapper.selectOdrDtlStatusList( pchReqUnqNo);
|
487
|
|
-
|
488
|
|
- int pod0 = 0 ;
|
489
|
|
- int pod1 = 0 ;
|
490
|
|
- int pod2 = 0 ;
|
491
|
|
- int pod4 = 0 ;
|
492
|
|
-
|
493
|
|
- for (int i = 0 ; i < dtlEntity.size() ; i++ ) {
|
494
|
|
- rtnOdrDtlPtclEntity entity = dtlEntity.get(i);
|
495
|
|
- if ( "POD0".equals(entity.getPodrDtlStCd())) { // 요청
|
496
|
|
- pod0 = pod0 + entity.getPodrStatusCnt() ;
|
497
|
|
- } else if ( "POD1".equals(entity.getPodrDtlStCd()) || "POD3".equals(entity.getPodrDtlStCd())) { // 접수 ,출하
|
498
|
|
- pod1 = pod1 + entity.getPodrStatusCnt() ;
|
499
|
|
- } else if ( "POD2".equals(entity.getPodrDtlStCd())) { //발주취소
|
500
|
|
- pod2 = pod2 + entity.getPodrStatusCnt() ;
|
501
|
|
- } else if ( "POD4".equals(entity.getPodrDtlStCd())) { //입고완료
|
502
|
|
- pod4 = pod4 + entity.getPodrStatusCnt() ;
|
503
|
|
- }
|
504
|
|
- }
|
505
|
|
-
|
506
|
|
- if (pod0 > 0 ) {
|
507
|
|
- rtnOdrStCd = "PO20"; //요청
|
508
|
|
- } else if ( pod0 == 0 && pod1 == 0 && pod4 == 0 ) {
|
509
|
|
- rtnOdrStCd = "PO99"; // 취소
|
510
|
|
- } else {
|
511
|
|
- rtnOdrStCd = "PO30"; // 접수
|
512
|
|
- }
|
513
|
|
-
|
514
|
|
- return rtnOdrStCd;
|
515
|
|
- }
|
516
|
|
-*/
|
517
|
495
|
/*
|
518
|
496
|
공급사 수주현황 리스트
|
519
|
497
|
|