jsh77b 5 anos atrás
pai
commit
1103344ecf

+ 30 - 24
src/main/java/com/style24/core/biz/service/TscOrderService.java

@@ -710,41 +710,47 @@ public class TscOrderService {
 		// 1. 쿠폰대상이 있는 상품만 정리
 		for (Order tmtbGoods : tmtbGoodsApplyList) {
 			List<Order> goodsCpnList = new ArrayList<Order>();
-			
-			for (Order goodsCpn : goodsCpnAllList) {
-				
+
+			for (Order goodsCpnAll : goodsCpnAllList) {
 				// 2. 적용상풒 전체(A) or 상품코드 같을때 담기
-				if ("A".equals(goodsCpn.getApplyScope()) || tmtbGoods.getGoodsCd().equals(goodsCpn.getGoodsCd())) {
+				if ("A".equals(goodsCpnAll.getApplyScope()) || tmtbGoods.getGoodsCd().equals(goodsCpnAll.getGoodsCd())) {
 					temp = true;
 					
 					// 3. 상품쿠폰목록에 담긴 상풐은 제외
 					for (Order goodsCpnApply : goodsCpnList) {
-						if (tmtbGoods.getGoodsCd().equals(goodsCpnApply.getGoodsCd())) {
+						if (goodsCpnAll.getCpnId() == goodsCpnApply.getCpnId()) {
 							temp = false;
 						}
 					}
 					
 					// 4. 상품쿠폰목록에 담기 가능 상품 담기
 					if (temp) {
+						
+						Order goodsCpn = new Order();
+						goodsCpn.setCpnId(goodsCpnAll.getCpnId());
+						goodsCpn.setGoodsCd(tmtbGoods.getGoodsCd());
+						goodsCpn.setCpnNm(goodsCpnAll.getCpnNm());
+						
+						
 						// 5. 할인방식 금액, 율 판단 
 						// 할인금액 (G240_10)
-						if ("G240_10".equals(goodsCpn.getDcWay())) {
-							goodsCpn.setCpnDcAmt(goodsCpn.getDcVal());
+						if ("G240_10".equals(goodsCpnAll.getDcWay())) {
+							goodsCpn.setCpnDcAmt(goodsCpnAll.getDcVal());
 						}
 						// 할인율 (G240_11)
 						else {
 							// 6. 할인율 일때 최대금액 판단으로 할인금액 등록
 							if (tmtbGoods.getTmtbDcAmt() > 0) {
-								cpnDcAmt = (tmtbGoods.getTmtbDcAmt() * goodsCpn.getDcVal()) / 100;
+								cpnDcAmt = (tmtbGoods.getTmtbDcAmt() * goodsCpnAll.getDcVal()) / 100;
 							} else {
-								cpnDcAmt = (tmtbGoods.getCurrPrice() * goodsCpn.getDcVal()) / 100;
+								cpnDcAmt = (tmtbGoods.getCurrPrice() * goodsCpnAll.getDcVal()) / 100;
 							}
 							
 							// 7. 할인금액 최대값보다 작으면 적용 or getMaxDcAmt( == 0 이면 무제한
-							if (goodsCpn.getMaxDcAmt() > cpnDcAmt || goodsCpn.getMaxDcAmt() == 0) {
+							if (goodsCpnAll.getMaxDcAmt() > cpnDcAmt || goodsCpnAll.getMaxDcAmt() == 0) {
 								goodsCpn.setCpnDcAmt(cpnDcAmt);
 							} else {
-								goodsCpn.setCpnDcAmt(goodsCpn.getMaxDcAmt());
+								goodsCpn.setCpnDcAmt(goodsCpnAll.getMaxDcAmt());
 							}
 						}
 						
@@ -757,9 +763,9 @@ public class TscOrderService {
 			}
 			
 			// 쿠폰할인금액이 높은순으로 정렬 함수 
-			List<Order> goodsCpnSortList = getListSort(goodsCpnList);
+			goodsCpnList = getListSort(goodsCpnList);
 			
-			tmtbGoods.setGoodsCpnList(goodsCpnSortList);
+			tmtbGoods.setGoodsCpnList(goodsCpnList);
 			goodsApplyCpnList.add(tmtbGoods);
 		}
 		
@@ -768,37 +774,37 @@ public class TscOrderService {
 	
 	// 쿠폰할인금액이 높은순으로 정렬 함수
 	private List<Order> getListSort(List<Order> goodsCpnList) {
-		List<Order> goodsCpnSortList = new ArrayList<Order>();
+		int cnt 			= 0;
+		int sameCnt 		= 0;
 		
-		Order tempOrder1 = null;
-		Order tempOrder2 = null;
-		int cnt 	= 0;
-		int sameCnt = 0;
+		List<Order> goodsCpnSortList = new ArrayList<Order>();
+		goodsCpnSortList.addAll(goodsCpnList);
 		
 		// 1. 쿠폰할인금액 순으로 정렬
 		for (int i=0 ; i<goodsCpnList.size() ; i++) {
-			tempOrder1 = goodsCpnList.get(i);
+			Order tempCpn1 = goodsCpnList.get(i);
+			
 			cnt 	= 0;
 			sameCnt = 0;
 			
 			// 2. 몇번째로 큰 할인금액 인지 판단
 			for (int j=0 ; j<goodsCpnList.size() ; j++) {
-				tempOrder2 = goodsCpnList.get(j);
+				Order tempCpn2 = goodsCpnList.get(j);
 				
-				if (tempOrder1.getCpnDcAmt() == tempOrder2.getCpnDcAmt() && i <= j) {
+				if (tempCpn1.getCpnDcAmt() == tempCpn2.getCpnDcAmt() && i <= j) {
 					sameCnt++;
 				}
 				
-				if (tempOrder1.getCpnDcAmt() > tempOrder2.getCpnDcAmt()) {
+				if (tempCpn1.getCpnDcAmt() < tempCpn2.getCpnDcAmt()) {
 					cnt++;
 				}
 			}
 			
 			if (sameCnt > 0) {
-				cnt = cnt + (sameCnt -1);
+				cnt = cnt + (sameCnt - 1);
 			}
 			
-			goodsCpnSortList.add(cnt, tempOrder1);
+			goodsCpnSortList.set(cnt, tempCpn1);
 		}
 		
 		return goodsCpnSortList;

+ 7 - 5
src/main/java/com/style24/persistence/mybatis/shop/TscOrder.xml

@@ -1983,11 +1983,13 @@
 						AND    CR2.CPN_TARGET = 'G260_13' -- 공급업체
 						AND    CR2.DEL_YN = 'N'
 					) X
-					LEFT  OUTER JOIN TB_COUPON_REFVAL CR
-					ON    X.CPN_ID = CR.CPN_ID
-					AND   X.GOODS_CD = CR.REF_VAL 
-					AND   CR.CPN_TARGET = 'G260_14' -- 제외상품
-					AND   CR.DEL_YN = 'N'
+					LEFT   OUTER JOIN TB_COUPON_REFVAL CR
+					ON     X.CPN_ID = CR.CPN_ID
+					AND    X.GOODS_CD = CR.REF_VAL 
+					AND    CR.CPN_TARGET = 'G260_14' -- 제외상품
+					AND    CR.DEL_YN = 'N'
+					WHERE  1=1
+					AND    CR.REF_VAL IS NULL
 			) Z
 			ON     Z.CPN_ID = CP.CPN_ID
 			WHERE  1=1