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