Browse Source

[ST24PRJ-500] [결함][BOS] 상품권 환불 이력확인 안됨

card007 4 years ago
parent
commit
fdddf224e8
1 changed files with 249 additions and 203 deletions
  1. 249 203
      src/main/java/com/style24/batch/biz/service/TsbDeliveryService.java

+ 249 - 203
src/main/java/com/style24/batch/biz/service/TsbDeliveryService.java

@@ -5,7 +5,6 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import com.style24.core.biz.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 import org.springframework.http.HttpEntity;
@@ -25,16 +24,24 @@ import com.style24.batch.biz.dao.TsbDeliveryDao;
 import com.style24.batch.support.env.TsbConstants;
 import com.style24.core.biz.dao.TscOrderChangeDao;
 import com.style24.core.biz.dao.TscOrderDao;
+import com.style24.core.biz.dao.TscPointDao;
+import com.style24.core.biz.service.TscDeliveryService;
+import com.style24.core.biz.service.TscErpService;
+import com.style24.core.biz.service.TscNaverPayService;
+import com.style24.core.biz.service.TscOrderChangeService;
+import com.style24.core.biz.service.TscOrderRefundService;
+import com.style24.core.biz.service.TscWmsService;
 import com.style24.core.biz.thirdparty.HansaeErp;
 import com.style24.core.support.env.TscConstants;
+import com.style24.core.support.env.TscConstants.OrdDtlItemStat;
 import com.style24.core.support.env.TscConstants.OrderChangeGb;
 import com.style24.core.support.env.TscConstants.OrderChangeStat;
 import com.style24.core.support.env.TscConstants.OrderDetailStat;
-import com.style24.core.support.env.TscConstants.OrdDtlItemStat;
 import com.style24.persistence.domain.Delivery;
 import com.style24.persistence.domain.Erp;
 import com.style24.persistence.domain.Order;
 import com.style24.persistence.domain.OrderChange;
+import com.style24.persistence.domain.Point;
 import com.style24.persistence.domain.WmsDelivery;
 
 import lombok.extern.slf4j.Slf4j;
@@ -74,7 +81,7 @@ public class TsbDeliveryService {
 	private TscDeliveryService coreDeliveryService;
 
 	@Autowired
-	private TscOrderChangeService orderChangeService;	
+	private TscOrderChangeService orderChangeService;
 	
 	@Autowired
 	private TscOrderRefundService orderRefundService;
@@ -86,7 +93,10 @@ public class TsbDeliveryService {
 	private HansaeErp hansaeErp;
 	
 	@Autowired
-	private TsbWmsDeliveryService wmsDeliveryService;	
+	private TsbWmsDeliveryService wmsDeliveryService;
+
+	@Autowired
+	private TscPointDao pointDao;
 
 	/**
 	 * 총알배송 권역정보 갱신 
@@ -431,216 +441,252 @@ public class TsbDeliveryService {
 				log.info("cancelOrderRefundList {}"+cancelOrderRefundList);
 				
 				for (Order vo : cancelOrderRefundList) {
-					
-					if(dtlNo.getOrdDtlNo().equals(vo.getOrdDtlNo()))
-					{
+					if (dtlNo.getOrdDtlNo().equals(vo.getOrdDtlNo())) {
 						vo.setRegNo(TsbConstants.REG_NO);
 						vo.setUpdNo(TsbConstants.REG_NO);
 						vo.setOrdDtlStat(OrderDetailStat.PAYMENT_AFTER_CANCEL.value());
-							// 원주문 상세정보 수정
-							orderChangeDao.updateOrderDetail(vo);
-							// 원주문 상세 이력 등록
-							orderDao.createOrderDetailHst(vo);
-		
-							//vo.setOrdDtlNo(data.getOrderdtlno());
-							// 3-2-3. 주문상세단품정보 수정 및 주문상세단품이력 등록
-							// 주문상세단품정보조회
-							Collection<Order> orderDetailItemList = orderChangeDao.getOrderDetailItemForCnclRtn(vo);
-							int ordDtlOrdAmt 			= orderDetailItemList.iterator().next().getOrdAmt();
-							int ordDtlCnclRtnAmt	 	= orderDetailItemList.iterator().next().getCnclRtnAmt();
-							int ordDtlCpn1DcAmt 		= orderDetailItemList.iterator().next().getCpn1DcAmt();
-							int ordDtlTmtb1DcAmt 		= orderDetailItemList.iterator().next().getTmtb1DcAmt();
-							int ordDtlTmtb2DcAmt 		= orderDetailItemList.iterator().next().getTmtb2DcAmt();
-							int ordDtlGoodsCpnDcAmt 	= orderDetailItemList.iterator().next().getGoodsCpnDcAmt();
-							int ordDtlCartCpnDcAmt 		= orderDetailItemList.iterator().next().getCartCpnDcAmt();
-							int ordDtlPntDcAmt 			= orderDetailItemList.iterator().next().getPntDcAmt();
-							int ordDtlPrePntDcAmt 		= orderDetailItemList.iterator().next().getPrePntDcAmt();
-							int ordDtlSavePntAmt 		= orderDetailItemList.iterator().next().getSavePntAmt();
-							int ordDtlRealOrdAmt 		= orderDetailItemList.iterator().next().getRealOrdAmt();
-							int ordDtlGfcdUseAmt 		= orderDetailItemList.iterator().next().getGfcdUseAmt();
-		
-							// 주문상세단품단위 금액 등록
-							int length					= orderDetailItemList.size();
-							int index					= 1;
-							int leftOrdAmt 				= ordDtlOrdAmt;
-							int leftCnclRtnAmt			= ordDtlCnclRtnAmt;
-							int leftCpn1DcAmt 			= ordDtlCpn1DcAmt;
-							int leftTmtb1DcAmt 			= ordDtlTmtb1DcAmt;
-							int leftTmtb2DcAmt 			= ordDtlTmtb2DcAmt;
-							int leftGoodsCpnDcAmt 		= ordDtlGoodsCpnDcAmt;
-							int leftCartCpnDcAmt 		= ordDtlCartCpnDcAmt;
-							int leftPntDcAmt 			= ordDtlPntDcAmt;
-							int leftPrePntDcAmt 		= ordDtlPrePntDcAmt;
-							int leftSavePntAmt 			= ordDtlSavePntAmt;
-							int leftRealOrdAmt 			= ordDtlRealOrdAmt;
-							int leftGfcdUseAmt 			= ordDtlGfcdUseAmt;
-		
-							for (Order orderDetailItem : orderDetailItemList) {
-								double dtlOrdAmt		= orderDetailItem.getDtlOrdAmt();
-								double dtlItemOrdAmt	= orderDetailItem.getDtlItemOrdAmt();
-								double tempDivD			= (dtlItemOrdAmt / dtlOrdAmt) * 100;
-								
-								int tempDiv				= Integer.parseInt(String.valueOf(Math.round(tempDivD)));
-		
-								if (index == length) {
-									orderDetailItem.setCnclRtnAmt(leftCnclRtnAmt);
-									orderDetailItem.setCpn1DcAmt(leftCpn1DcAmt);
-									orderDetailItem.setTmtb1DcAmt(leftTmtb1DcAmt);
-									orderDetailItem.setTmtb2DcAmt(leftTmtb2DcAmt);
-									orderDetailItem.setGoodsCpnDcAmt(leftGoodsCpnDcAmt);
-									orderDetailItem.setCartCpnDcAmt(leftCartCpnDcAmt);
-									orderDetailItem.setPrePntDcAmt(leftPrePntDcAmt);
-									orderDetailItem.setPntDcAmt(leftPntDcAmt);
-									orderDetailItem.setGfcdUseAmt(leftGfcdUseAmt);
-									orderDetailItem.setRealOrdAmt(leftRealOrdAmt);
-									orderDetailItem.setSavePntAmt(leftSavePntAmt);
-									
-								} else {
-									orderDetailItem.setCnclRtnAmt((ordDtlCnclRtnAmt 		* tempDiv) / 100);
-									orderDetailItem.setCpn1DcAmt((ordDtlCpn1DcAmt 			* tempDiv) / 100);
-									orderDetailItem.setTmtb1DcAmt((ordDtlTmtb1DcAmt 		* tempDiv) / 100);
-									orderDetailItem.setTmtb2DcAmt((ordDtlTmtb2DcAmt 		* tempDiv) / 100);
-									orderDetailItem.setGoodsCpnDcAmt((ordDtlGoodsCpnDcAmt 	* tempDiv) / 100);
-									orderDetailItem.setCartCpnDcAmt((ordDtlCartCpnDcAmt 	* tempDiv) / 100);
-									orderDetailItem.setPrePntDcAmt((ordDtlPrePntDcAmt 		* tempDiv) / 100);
-									orderDetailItem.setPntDcAmt((ordDtlPntDcAmt 			* tempDiv) / 100);
-									orderDetailItem.setGfcdUseAmt((ordDtlGfcdUseAmt 		* tempDiv) / 100);
-									orderDetailItem.setRealOrdAmt((ordDtlRealOrdAmt 		* tempDiv) / 100);
-									orderDetailItem.setSavePntAmt((ordDtlSavePntAmt 		* tempDiv) / 100);
-		
-									leftCnclRtnAmt		-= ((ordDtlCnclRtnAmt 				* tempDiv) / 100);
-									leftCpn1DcAmt 		-= ((ordDtlCpn1DcAmt 				* tempDiv) / 100);
-									leftTmtb1DcAmt 		-= ((ordDtlTmtb1DcAmt 				* tempDiv) / 100);
-									leftTmtb2DcAmt 		-= ((ordDtlTmtb2DcAmt 				* tempDiv) / 100);
-									leftGoodsCpnDcAmt 	-= ((ordDtlGoodsCpnDcAmt 			* tempDiv) / 100);
-									leftCartCpnDcAmt 	-= ((ordDtlCartCpnDcAmt 			* tempDiv) / 100);
-									leftPrePntDcAmt 	-= ((ordDtlPrePntDcAmt 				* tempDiv) / 100);
-									leftPntDcAmt 		-= ((ordDtlPntDcAmt 				* tempDiv) / 100);
-									leftGfcdUseAmt 		-= ((ordDtlGfcdUseAmt 				* tempDiv) / 100);
-									leftRealOrdAmt 		-= ((ordDtlRealOrdAmt 				* tempDiv) / 100);
-									leftSavePntAmt 		-= ((ordDtlSavePntAmt 				* tempDiv) / 100);
-								}
-		
-								orderDetailItem.setRegNo(TsbConstants.REG_NO);
-								orderDetailItem.setUpdNo(TsbConstants.REG_NO);
-								orderDetailItem.setOrdDtlStat(vo.getOrdDtlStat());
+						// 원주문 상세정보 수정
+						orderChangeDao.updateOrderDetail(vo);
+						// 원주문 상세 이력 등록
+						orderDao.createOrderDetailHst(vo);
+
+						// 2021.11.19 card007 적립예정포인트 차감 후 신규 로우 생성
+						int savePntAmt = vo.getSavePntAmt();
+						if (savePntAmt > 0) {
+							vo.setOccurGb(TscConstants.PointOccurGb.EXPECT_POINT.value());
+							vo.setFirstOrdDtlNo(vo.getOrdDtlNo());
+
+							for (Order point : orderChangeDao.getCustPointHst(vo)) {
+								point.setOccurGb(TscConstants.PointOccurGb.EXPECT_POINT_CANCEL.value());
+								point.setPntUploadStat(TscConstants.PntUploadStat.APPLY_EXPECT.value());
+								point.setOccurDtlDesc("예정포인트적립취소");
+								point.setPntAmt(savePntAmt * -1);
+								point.setRegNo(TsbConstants.REG_NO);
+								point.setUpdNo(TsbConstants.REG_NO);
+
+								// 적립예정포인트 차감
+								orderChangeDao.createCustPointHstRollback(point);
+							}
+						}
+	
+						//vo.setOrdDtlNo(data.getOrderdtlno());
+						// 3-2-3. 주문상세단품정보 수정 및 주문상세단품이력 등록
+						// 주문상세단품정보조회
+						Collection<Order> orderDetailItemList = orderChangeDao.getOrderDetailItemForCnclRtn(vo);
+						int ordDtlOrdAmt 			= orderDetailItemList.iterator().next().getOrdAmt();
+						int ordDtlCnclRtnAmt	 	= orderDetailItemList.iterator().next().getCnclRtnAmt();
+						int ordDtlCpn1DcAmt 		= orderDetailItemList.iterator().next().getCpn1DcAmt();
+						int ordDtlTmtb1DcAmt 		= orderDetailItemList.iterator().next().getTmtb1DcAmt();
+						int ordDtlTmtb2DcAmt 		= orderDetailItemList.iterator().next().getTmtb2DcAmt();
+						int ordDtlGoodsCpnDcAmt 	= orderDetailItemList.iterator().next().getGoodsCpnDcAmt();
+						int ordDtlCartCpnDcAmt 		= orderDetailItemList.iterator().next().getCartCpnDcAmt();
+						int ordDtlPntDcAmt 			= orderDetailItemList.iterator().next().getPntDcAmt();
+						int ordDtlPrePntDcAmt 		= orderDetailItemList.iterator().next().getPrePntDcAmt();
+						int ordDtlSavePntAmt 		= orderDetailItemList.iterator().next().getSavePntAmt();
+						int ordDtlRealOrdAmt 		= orderDetailItemList.iterator().next().getRealOrdAmt();
+						int ordDtlGfcdUseAmt 		= orderDetailItemList.iterator().next().getGfcdUseAmt();
+	
+						// 주문상세단품단위 금액 등록
+						int length					= orderDetailItemList.size();
+						int index					= 1;
+						int leftOrdAmt 				= ordDtlOrdAmt;
+						int leftCnclRtnAmt			= ordDtlCnclRtnAmt;
+						int leftCpn1DcAmt 			= ordDtlCpn1DcAmt;
+						int leftTmtb1DcAmt 			= ordDtlTmtb1DcAmt;
+						int leftTmtb2DcAmt 			= ordDtlTmtb2DcAmt;
+						int leftGoodsCpnDcAmt 		= ordDtlGoodsCpnDcAmt;
+						int leftCartCpnDcAmt 		= ordDtlCartCpnDcAmt;
+						int leftPntDcAmt 			= ordDtlPntDcAmt;
+						int leftPrePntDcAmt 		= ordDtlPrePntDcAmt;
+						int leftSavePntAmt 			= ordDtlSavePntAmt;
+						int leftRealOrdAmt 			= ordDtlRealOrdAmt;
+						int leftGfcdUseAmt 			= ordDtlGfcdUseAmt;
+	
+						for (Order orderDetailItem : orderDetailItemList) {
+							double dtlOrdAmt		= orderDetailItem.getDtlOrdAmt();
+							double dtlItemOrdAmt	= orderDetailItem.getDtlItemOrdAmt();
+							double tempDivD			= (dtlItemOrdAmt / dtlOrdAmt) * 100;
+							
+							int tempDiv				= Integer.parseInt(String.valueOf(Math.round(tempDivD)));
+	
+							if (index == length) {
+								orderDetailItem.setCnclRtnAmt(leftCnclRtnAmt);
+								orderDetailItem.setCpn1DcAmt(leftCpn1DcAmt);
+								orderDetailItem.setTmtb1DcAmt(leftTmtb1DcAmt);
+								orderDetailItem.setTmtb2DcAmt(leftTmtb2DcAmt);
+								orderDetailItem.setGoodsCpnDcAmt(leftGoodsCpnDcAmt);
+								orderDetailItem.setCartCpnDcAmt(leftCartCpnDcAmt);
+								orderDetailItem.setPrePntDcAmt(leftPrePntDcAmt);
+								orderDetailItem.setPntDcAmt(leftPntDcAmt);
+								orderDetailItem.setGfcdUseAmt(leftGfcdUseAmt);
+								orderDetailItem.setRealOrdAmt(leftRealOrdAmt);
+								orderDetailItem.setSavePntAmt(leftSavePntAmt);
 								
-								// 2021.06.25 WMS 회수정보 수집 (교환완료) (정산구분값추가)
-								orderDetailItem.setOrdDtlStat(TscConstants.OrdDtlItemStat.SALE_RETURN_EXCHANGE_COMPLETE.value());
-								orderDetailItem.setCnclRtnQty(vo.getOrdCanChgQty());  
-								orderDetailItem.setOrdChgSq(data.getOrdChgSq());
-								orderChangeDao.createOrderDetailItemHst(orderDetailItem);
-		
-								orderChangeDao.updateOrderDetailItem(orderDetailItem);
-
-								index++;
+							} else {
+								orderDetailItem.setCnclRtnAmt((ordDtlCnclRtnAmt 		* tempDiv) / 100);
+								orderDetailItem.setCpn1DcAmt((ordDtlCpn1DcAmt 			* tempDiv) / 100);
+								orderDetailItem.setTmtb1DcAmt((ordDtlTmtb1DcAmt 		* tempDiv) / 100);
+								orderDetailItem.setTmtb2DcAmt((ordDtlTmtb2DcAmt 		* tempDiv) / 100);
+								orderDetailItem.setGoodsCpnDcAmt((ordDtlGoodsCpnDcAmt 	* tempDiv) / 100);
+								orderDetailItem.setCartCpnDcAmt((ordDtlCartCpnDcAmt 	* tempDiv) / 100);
+								orderDetailItem.setPrePntDcAmt((ordDtlPrePntDcAmt 		* tempDiv) / 100);
+								orderDetailItem.setPntDcAmt((ordDtlPntDcAmt 			* tempDiv) / 100);
+								orderDetailItem.setGfcdUseAmt((ordDtlGfcdUseAmt 		* tempDiv) / 100);
+								orderDetailItem.setRealOrdAmt((ordDtlRealOrdAmt 		* tempDiv) / 100);
+								orderDetailItem.setSavePntAmt((ordDtlSavePntAmt 		* tempDiv) / 100);
+	
+								leftCnclRtnAmt		-= ((ordDtlCnclRtnAmt 				* tempDiv) / 100);
+								leftCpn1DcAmt 		-= ((ordDtlCpn1DcAmt 				* tempDiv) / 100);
+								leftTmtb1DcAmt 		-= ((ordDtlTmtb1DcAmt 				* tempDiv) / 100);
+								leftTmtb2DcAmt 		-= ((ordDtlTmtb2DcAmt 				* tempDiv) / 100);
+								leftGoodsCpnDcAmt 	-= ((ordDtlGoodsCpnDcAmt 			* tempDiv) / 100);
+								leftCartCpnDcAmt 	-= ((ordDtlCartCpnDcAmt 			* tempDiv) / 100);
+								leftPrePntDcAmt 	-= ((ordDtlPrePntDcAmt 				* tempDiv) / 100);
+								leftPntDcAmt 		-= ((ordDtlPntDcAmt 				* tempDiv) / 100);
+								leftGfcdUseAmt 		-= ((ordDtlGfcdUseAmt 				* tempDiv) / 100);
+								leftRealOrdAmt 		-= ((ordDtlRealOrdAmt 				* tempDiv) / 100);
+								leftSavePntAmt 		-= ((ordDtlSavePntAmt 				* tempDiv) / 100);
 							}
+	
+							orderDetailItem.setRegNo(TsbConstants.REG_NO);
+							orderDetailItem.setUpdNo(TsbConstants.REG_NO);
+							orderDetailItem.setOrdDtlStat(vo.getOrdDtlStat());
 							
-							// 교환주문 상세 수정
-							vo.setOrdDtlStat(OrderDetailStat.PAYMENT_COMPLETE.value()); // 교환주문상세 결제완료
-							vo.setOrdDtlNo(dtlNo.getChgOrdDtlNo());
-							vo.setWdBfSendYn(data.getWdBfSendYn());
-							orderChangeDao.updateChgOrderDetailTemp(vo);
-							// 교환주문 상세 이력 등록 
-							orderDao.createOrderDetailHst(vo);
+							// 2021.06.25 WMS 회수정보 수집 (교환완료) (정산구분값추가)
+							orderDetailItem.setOrdDtlStat(TscConstants.OrdDtlItemStat.SALE_RETURN_EXCHANGE_COMPLETE.value());
+							orderDetailItem.setCnclRtnQty(vo.getOrdCanChgQty());  
+							orderDetailItem.setOrdChgSq(data.getOrdChgSq());
+							orderChangeDao.createOrderDetailItemHst(orderDetailItem);
+	
+							orderChangeDao.updateOrderDetailItem(orderDetailItem);
+
+							index++;
+						}
+						
+						// 교환주문 상세 수정
+						Integer exchangeOrdDtlNo = dtlNo.getChgOrdDtlNo();
+						vo.setOrdDtlStat(OrderDetailStat.PAYMENT_COMPLETE.value()); // 교환주문상세 결제완료
+						vo.setOrdDtlNo(exchangeOrdDtlNo);
+						vo.setWdBfSendYn(data.getWdBfSendYn());
+						orderChangeDao.updateChgOrderDetailTemp(vo);
+						// 교환주문 상세 이력 등록 
+						orderDao.createOrderDetailHst(vo);
+
+						// 2021.11.19 card007 적립예정포인트 차감 후 신규 로우 생성
+						if (custNo > 0 && savePntAmt > 0 && exchangeOrdDtlNo > 0) {
+							// 적립예정포인트 신규 로우 생성
+							Point point = new Point();
+							point.setCustNo(custNo);
+							point.setOccurGb(TscConstants.PointOccurGb.EXPECT_POINT.value());
+							point.setOccurDtlDesc("예정포인트적립");
+							point.setPntAmt(savePntAmt);
+							point.setCustPntSq(0);
+							point.setOrdNo(ordNo);
+							point.setOrdDtlNo(exchangeOrdDtlNo);
+							point.setReviewSq(0);
+							point.setPntUploadStat(TscConstants.PntUploadStat.APPLY_EXPECT.value());
+							point.setRegNo(TsbConstants.REG_NO);
+							point.setUpdNo(TsbConstants.REG_NO);
+							pointDao.createCustomerPointHst(point);
+						}
+						
+						// 주문상세단품정보조회
+						Collection<Order> orderDetailItemList2 = orderChangeDao.getOrderDetailItemForCnclRtn(vo);
+						int ordDtlOrdAmt2 			= orderDetailItemList2.iterator().next().getOrdAmt();
+						int ordDtlCnclRtnAmt2	 	= orderDetailItemList2.iterator().next().getCnclRtnAmt();
+						int ordDtlCpn1DcAmt2 		= orderDetailItemList2.iterator().next().getCpn1DcAmt();
+						int ordDtlTmtb1DcAmt2 		= orderDetailItemList2.iterator().next().getTmtb1DcAmt();
+						int ordDtlTmtb2DcAmt2 		= orderDetailItemList2.iterator().next().getTmtb2DcAmt();
+						int ordDtlGoodsCpnDcAmt2 	= orderDetailItemList2.iterator().next().getGoodsCpnDcAmt();
+						int ordDtlCartCpnDcAmt2 	= orderDetailItemList2.iterator().next().getCartCpnDcAmt();
+						int ordDtlPntDcAmt2 		= orderDetailItemList2.iterator().next().getPntDcAmt();
+						int ordDtlPrePntDcAmt2 		= orderDetailItemList2.iterator().next().getPrePntDcAmt();
+						int ordDtlSavePntAmt2 		= orderDetailItemList2.iterator().next().getSavePntAmt();
+						int ordDtlRealOrdAmt2 		= orderDetailItemList2.iterator().next().getRealOrdAmt();
+						int ordDtlGfcdUseAmt2 		= orderDetailItemList2.iterator().next().getGfcdUseAmt();
+	
+						// 주문상세단품단위 금액 등록
+						int length2					= orderDetailItemList2.size();
+						int index2					= 1;
+						int leftOrdAmt2 			= ordDtlOrdAmt2;
+						int leftCnclRtnAmt2			= ordDtlCnclRtnAmt2;
+						int leftCpn1DcAmt2 			= ordDtlCpn1DcAmt2;
+						int leftTmtb1DcAmt2 		= ordDtlTmtb1DcAmt2;
+						int leftTmtb2DcAmt2 		= ordDtlTmtb2DcAmt2;
+						int leftGoodsCpnDcAmt2 		= ordDtlGoodsCpnDcAmt2;
+						int leftCartCpnDcAmt2 		= ordDtlCartCpnDcAmt2;
+						int leftPntDcAmt2 			= ordDtlPntDcAmt2;
+						int leftPrePntDcAmt2 		= ordDtlPrePntDcAmt2;
+						int leftSavePntAmt2 		= ordDtlSavePntAmt2;
+						int leftRealOrdAmt2 		= ordDtlRealOrdAmt2;
+						int leftGfcdUseAmt2 		= ordDtlGfcdUseAmt2;
+	
+						for (Order orderDetailItem : orderDetailItemList2) {
+							double dtlOrdAmt		= orderDetailItem.getDtlOrdAmt();
+							double dtlItemOrdAmt	= orderDetailItem.getDtlItemOrdAmt();
+							double tempDivD			= (dtlItemOrdAmt / dtlOrdAmt) * 100;
 							
-							// 주문상세단품정보조회
-							Collection<Order> orderDetailItemList2 = orderChangeDao.getOrderDetailItemForCnclRtn(vo);
-							int ordDtlOrdAmt2 			= orderDetailItemList2.iterator().next().getOrdAmt();
-							int ordDtlCnclRtnAmt2	 	= orderDetailItemList2.iterator().next().getCnclRtnAmt();
-							int ordDtlCpn1DcAmt2 		= orderDetailItemList2.iterator().next().getCpn1DcAmt();
-							int ordDtlTmtb1DcAmt2 		= orderDetailItemList2.iterator().next().getTmtb1DcAmt();
-							int ordDtlTmtb2DcAmt2 		= orderDetailItemList2.iterator().next().getTmtb2DcAmt();
-							int ordDtlGoodsCpnDcAmt2 	= orderDetailItemList2.iterator().next().getGoodsCpnDcAmt();
-							int ordDtlCartCpnDcAmt2 	= orderDetailItemList2.iterator().next().getCartCpnDcAmt();
-							int ordDtlPntDcAmt2 		= orderDetailItemList2.iterator().next().getPntDcAmt();
-							int ordDtlPrePntDcAmt2 		= orderDetailItemList2.iterator().next().getPrePntDcAmt();
-							int ordDtlSavePntAmt2 		= orderDetailItemList2.iterator().next().getSavePntAmt();
-							int ordDtlRealOrdAmt2 		= orderDetailItemList2.iterator().next().getRealOrdAmt();
-							int ordDtlGfcdUseAmt2 		= orderDetailItemList2.iterator().next().getGfcdUseAmt();
-		
-							// 주문상세단품단위 금액 등록
-							int length2					= orderDetailItemList2.size();
-							int index2					= 1;
-							int leftOrdAmt2 			= ordDtlOrdAmt2;
-							int leftCnclRtnAmt2			= ordDtlCnclRtnAmt2;
-							int leftCpn1DcAmt2 			= ordDtlCpn1DcAmt2;
-							int leftTmtb1DcAmt2 		= ordDtlTmtb1DcAmt2;
-							int leftTmtb2DcAmt2 		= ordDtlTmtb2DcAmt2;
-							int leftGoodsCpnDcAmt2 		= ordDtlGoodsCpnDcAmt2;
-							int leftCartCpnDcAmt2 		= ordDtlCartCpnDcAmt2;
-							int leftPntDcAmt2 			= ordDtlPntDcAmt2;
-							int leftPrePntDcAmt2 		= ordDtlPrePntDcAmt2;
-							int leftSavePntAmt2 		= ordDtlSavePntAmt2;
-							int leftRealOrdAmt2 		= ordDtlRealOrdAmt2;
-							int leftGfcdUseAmt2 		= ordDtlGfcdUseAmt2;
-		
-							for (Order orderDetailItem : orderDetailItemList2) {
-								double dtlOrdAmt		= orderDetailItem.getDtlOrdAmt();
-								double dtlItemOrdAmt	= orderDetailItem.getDtlItemOrdAmt();
-								double tempDivD			= (dtlItemOrdAmt / dtlOrdAmt) * 100;
-								
-								int tempDiv				= Integer.parseInt(String.valueOf(Math.round(tempDivD)));
-		
-								if (index2 == length2) {
-									orderDetailItem.setOrdAmt(leftOrdAmt2);
-									orderDetailItem.setCnclRtnAmt(leftCnclRtnAmt2);
-									orderDetailItem.setCpn1DcAmt(leftCpn1DcAmt2);
-									orderDetailItem.setTmtb1DcAmt(leftTmtb1DcAmt2);
-									orderDetailItem.setTmtb2DcAmt(leftTmtb2DcAmt2);
-									orderDetailItem.setGoodsCpnDcAmt(leftGoodsCpnDcAmt2);
-									orderDetailItem.setCartCpnDcAmt(leftCartCpnDcAmt2);
-									orderDetailItem.setPrePntDcAmt(leftPrePntDcAmt2);
-									orderDetailItem.setPntDcAmt(leftPntDcAmt2);
-									orderDetailItem.setGfcdUseAmt(leftGfcdUseAmt2);
-									orderDetailItem.setRealOrdAmt(leftRealOrdAmt2);
-									orderDetailItem.setSavePntAmt(leftSavePntAmt2);
-									
-								} else {
-									orderDetailItem.setOrdAmt((ordDtlOrdAmt2 				* tempDiv) / 100);
-									orderDetailItem.setCnclRtnAmt((ordDtlCnclRtnAmt2 		* tempDiv) / 100);
-									orderDetailItem.setCpn1DcAmt((ordDtlCpn1DcAmt2 			* tempDiv) / 100);
-									orderDetailItem.setTmtb1DcAmt((ordDtlTmtb1DcAmt2 		* tempDiv) / 100);
-									orderDetailItem.setTmtb2DcAmt((ordDtlTmtb2DcAmt2 		* tempDiv) / 100);
-									orderDetailItem.setGoodsCpnDcAmt((ordDtlGoodsCpnDcAmt2 	* tempDiv) / 100);
-									orderDetailItem.setCartCpnDcAmt((ordDtlCartCpnDcAmt2 	* tempDiv) / 100);
-									orderDetailItem.setPrePntDcAmt((ordDtlPrePntDcAmt2 		* tempDiv) / 100);
-									orderDetailItem.setPntDcAmt((ordDtlPntDcAmt2 			* tempDiv) / 100);
-									orderDetailItem.setGfcdUseAmt((ordDtlGfcdUseAmt2 		* tempDiv) / 100);
-									orderDetailItem.setRealOrdAmt((ordDtlRealOrdAmt2 		* tempDiv) / 100);
-									orderDetailItem.setSavePntAmt((ordDtlSavePntAmt2 		* tempDiv) / 100);
-		
-									leftOrdAmt2         -= ((ordDtlOrdAmt2 					* tempDiv) / 100);
-									leftCnclRtnAmt2		-= ((ordDtlCnclRtnAmt2 				* tempDiv) / 100);
-									leftCpn1DcAmt2 		-= ((ordDtlCpn1DcAmt2 				* tempDiv) / 100);
-									leftTmtb1DcAmt2 	-= ((ordDtlTmtb1DcAmt2 				* tempDiv) / 100);
-									leftTmtb2DcAmt2 	-= ((ordDtlTmtb2DcAmt2 				* tempDiv) / 100);
-									leftGoodsCpnDcAmt2 	-= ((ordDtlGoodsCpnDcAmt2 			* tempDiv) / 100);
-									leftCartCpnDcAmt2 	-= ((ordDtlCartCpnDcAmt2 			* tempDiv) / 100);
-									leftPrePntDcAmt2 	-= ((ordDtlPrePntDcAmt2 			* tempDiv) / 100);
-									leftPntDcAmt2 		-= ((ordDtlPntDcAmt2 				* tempDiv) / 100);
-									leftGfcdUseAmt2 	-= ((ordDtlGfcdUseAmt2 				* tempDiv) / 100);
-									leftRealOrdAmt2 	-= ((ordDtlRealOrdAmt2 				* tempDiv) / 100);
-									leftSavePntAmt2 	-= ((ordDtlSavePntAmt2 				* tempDiv) / 100);
-								}
-								log.info("orderDetailItem: "+orderDetailItem.getOrdAmt());
-								orderDetailItem.setRegNo(TsbConstants.REG_NO);
-								orderDetailItem.setUpdNo(TsbConstants.REG_NO);
-								orderDetailItem.setOrdDtlStat(vo.getOrdDtlStat());
-								
-								// 2021.06.25 WMS 회수정보 수집 (교환결제완료) (정산구분값추가)
-								orderDetailItem.setOrdDtlStat(TscConstants.OrdDtlItemStat.SALE_PAYMENT_COMPLETE.value()); // G720_10  판매-결제완료
-								orderDetailItem.setCnclRtnQty(0);
-								orderDetailItem.setOrdChgSq(data.getOrdChgSq());
-								orderChangeDao.updateChgOrderDetailItemTemp(orderDetailItem);
-								orderDetailItem.setExchangeOrdDtlItemSq(orderDetailItem.getOrdDtlItemSq());
-								orderChangeDao.createOrderDetailItemHstForExchange(orderDetailItem);
+							int tempDiv				= Integer.parseInt(String.valueOf(Math.round(tempDivD)));
+	
+							if (index2 == length2) {
+								orderDetailItem.setOrdAmt(leftOrdAmt2);
+								orderDetailItem.setCnclRtnAmt(leftCnclRtnAmt2);
+								orderDetailItem.setCpn1DcAmt(leftCpn1DcAmt2);
+								orderDetailItem.setTmtb1DcAmt(leftTmtb1DcAmt2);
+								orderDetailItem.setTmtb2DcAmt(leftTmtb2DcAmt2);
+								orderDetailItem.setGoodsCpnDcAmt(leftGoodsCpnDcAmt2);
+								orderDetailItem.setCartCpnDcAmt(leftCartCpnDcAmt2);
+								orderDetailItem.setPrePntDcAmt(leftPrePntDcAmt2);
+								orderDetailItem.setPntDcAmt(leftPntDcAmt2);
+								orderDetailItem.setGfcdUseAmt(leftGfcdUseAmt2);
+								orderDetailItem.setRealOrdAmt(leftRealOrdAmt2);
+								orderDetailItem.setSavePntAmt(leftSavePntAmt2);
 								
-								index2++;
+							} else {
+								orderDetailItem.setOrdAmt((ordDtlOrdAmt2 				* tempDiv) / 100);
+								orderDetailItem.setCnclRtnAmt((ordDtlCnclRtnAmt2 		* tempDiv) / 100);
+								orderDetailItem.setCpn1DcAmt((ordDtlCpn1DcAmt2 			* tempDiv) / 100);
+								orderDetailItem.setTmtb1DcAmt((ordDtlTmtb1DcAmt2 		* tempDiv) / 100);
+								orderDetailItem.setTmtb2DcAmt((ordDtlTmtb2DcAmt2 		* tempDiv) / 100);
+								orderDetailItem.setGoodsCpnDcAmt((ordDtlGoodsCpnDcAmt2 	* tempDiv) / 100);
+								orderDetailItem.setCartCpnDcAmt((ordDtlCartCpnDcAmt2 	* tempDiv) / 100);
+								orderDetailItem.setPrePntDcAmt((ordDtlPrePntDcAmt2 		* tempDiv) / 100);
+								orderDetailItem.setPntDcAmt((ordDtlPntDcAmt2 			* tempDiv) / 100);
+								orderDetailItem.setGfcdUseAmt((ordDtlGfcdUseAmt2 		* tempDiv) / 100);
+								orderDetailItem.setRealOrdAmt((ordDtlRealOrdAmt2 		* tempDiv) / 100);
+								orderDetailItem.setSavePntAmt((ordDtlSavePntAmt2 		* tempDiv) / 100);
+	
+								leftOrdAmt2         -= ((ordDtlOrdAmt2 					* tempDiv) / 100);
+								leftCnclRtnAmt2		-= ((ordDtlCnclRtnAmt2 				* tempDiv) / 100);
+								leftCpn1DcAmt2 		-= ((ordDtlCpn1DcAmt2 				* tempDiv) / 100);
+								leftTmtb1DcAmt2 	-= ((ordDtlTmtb1DcAmt2 				* tempDiv) / 100);
+								leftTmtb2DcAmt2 	-= ((ordDtlTmtb2DcAmt2 				* tempDiv) / 100);
+								leftGoodsCpnDcAmt2 	-= ((ordDtlGoodsCpnDcAmt2 			* tempDiv) / 100);
+								leftCartCpnDcAmt2 	-= ((ordDtlCartCpnDcAmt2 			* tempDiv) / 100);
+								leftPrePntDcAmt2 	-= ((ordDtlPrePntDcAmt2 			* tempDiv) / 100);
+								leftPntDcAmt2 		-= ((ordDtlPntDcAmt2 				* tempDiv) / 100);
+								leftGfcdUseAmt2 	-= ((ordDtlGfcdUseAmt2 				* tempDiv) / 100);
+								leftRealOrdAmt2 	-= ((ordDtlRealOrdAmt2 				* tempDiv) / 100);
+								leftSavePntAmt2 	-= ((ordDtlSavePntAmt2 				* tempDiv) / 100);
 							}
+							log.info("orderDetailItem: "+orderDetailItem.getOrdAmt());
+							orderDetailItem.setRegNo(TsbConstants.REG_NO);
+							orderDetailItem.setUpdNo(TsbConstants.REG_NO);
+							orderDetailItem.setOrdDtlStat(vo.getOrdDtlStat());
+							
+							// 2021.06.25 WMS 회수정보 수집 (교환결제완료) (정산구분값추가)
+							orderDetailItem.setOrdDtlStat(TscConstants.OrdDtlItemStat.SALE_PAYMENT_COMPLETE.value()); // G720_10  판매-결제완료
+							orderDetailItem.setCnclRtnQty(0);
+							orderDetailItem.setOrdChgSq(data.getOrdChgSq());
+							orderChangeDao.updateChgOrderDetailItemTemp(orderDetailItem);
+							orderDetailItem.setExchangeOrdDtlItemSq(orderDetailItem.getOrdDtlItemSq());
+							orderChangeDao.createOrderDetailItemHstForExchange(orderDetailItem);
+							
+							index2++;
 						}
 					}
-				} 
+				}
+			} 
 
 		}