|
|
@@ -702,37 +702,112 @@ public class TscOrderService {
|
|
|
}
|
|
|
|
|
|
public Collection<Order> getGoodsCpnApplyList(Collection<Order> tmtbGoodsApplyList, Collection<Order> goodsCpnAllList) {
|
|
|
- Collection<Order> goodsCpnApplyList = new ArrayList<Order>();
|
|
|
+ Collection<Order> goodsApplyCpnList = new ArrayList<Order>();
|
|
|
|
|
|
Boolean temp = true;
|
|
|
+ int cpnDcAmt = 0;
|
|
|
|
|
|
- // 쿠폰대상이 있는 상품만 정리
|
|
|
+ // 1. 쿠폰대상이 있는 상품만 정리
|
|
|
for (Order tmtbGoods : tmtbGoodsApplyList) {
|
|
|
- Collection<Order> goodsCpnList = new ArrayList<Order>();
|
|
|
-
|
|
|
- for (Order goodsCpn : goodsCpnAllList) {
|
|
|
- // 상품코드비교후 담기
|
|
|
- if ("A".equals(goodsCpn.getApplyScope()) || tmtbGoods.getGoodsCd().equals(goodsCpn.getGoodsCd())) {
|
|
|
+ List<Order> goodsCpnList = new ArrayList<Order>();
|
|
|
+
|
|
|
+ for (Order goodsCpnAll : goodsCpnAllList) {
|
|
|
+ // 2. 적용상풒 전체(A) or 상품코드 같을때 담기
|
|
|
+ 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) {
|
|
|
- goodsCpnList.add(goodsCpn);
|
|
|
+
|
|
|
+ Order goodsCpn = new Order();
|
|
|
+ goodsCpn.setCpnId(goodsCpnAll.getCpnId());
|
|
|
+ goodsCpn.setGoodsCd(tmtbGoods.getGoodsCd());
|
|
|
+ goodsCpn.setCpnNm(goodsCpnAll.getCpnNm());
|
|
|
+
|
|
|
+
|
|
|
+ // 5. 할인방식 금액, 율 판단
|
|
|
+ // 할인금액 (G240_10)
|
|
|
+ if ("G240_10".equals(goodsCpnAll.getDcWay())) {
|
|
|
+ goodsCpn.setCpnDcAmt(goodsCpnAll.getDcVal());
|
|
|
+ }
|
|
|
+ // 할인율 (G240_11)
|
|
|
+ else {
|
|
|
+ // 6. 할인율 일때 최대금액 판단으로 할인금액 등록
|
|
|
+ if (tmtbGoods.getTmtbDcAmt() > 0) {
|
|
|
+ cpnDcAmt = (tmtbGoods.getTmtbDcAmt() * goodsCpnAll.getDcVal()) / 100;
|
|
|
+ } else {
|
|
|
+ cpnDcAmt = (tmtbGoods.getCurrPrice() * goodsCpnAll.getDcVal()) / 100;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 7. 할인금액 최대값보다 작으면 적용 or getMaxDcAmt( == 0 이면 무제한
|
|
|
+ if (goodsCpnAll.getMaxDcAmt() > cpnDcAmt || goodsCpnAll.getMaxDcAmt() == 0) {
|
|
|
+ goodsCpn.setCpnDcAmt(cpnDcAmt);
|
|
|
+ } else {
|
|
|
+ goodsCpn.setCpnDcAmt(goodsCpnAll.getMaxDcAmt());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 8. 주문최소주문금액 보다 크면 쿠폰 적용
|
|
|
+ if (tmtbGoods.getCurrPrice() > goodsCpn.getBuyLimitAmt()) {
|
|
|
+ goodsCpnList.add(goodsCpn);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 쿠폰할인금액이 높은순으로 정렬 함수
|
|
|
+ goodsCpnList = getListSort(goodsCpnList);
|
|
|
+
|
|
|
tmtbGoods.setGoodsCpnList(goodsCpnList);
|
|
|
- goodsCpnApplyList.add(tmtbGoods);
|
|
|
+ goodsApplyCpnList.add(tmtbGoods);
|
|
|
}
|
|
|
|
|
|
- return goodsCpnApplyList;
|
|
|
+ return goodsApplyCpnList;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 쿠폰할인금액이 높은순으로 정렬 함수
|
|
|
+ private List<Order> getListSort(List<Order> goodsCpnList) {
|
|
|
+ int cnt = 0;
|
|
|
+ int sameCnt = 0;
|
|
|
+
|
|
|
+ List<Order> goodsCpnSortList = new ArrayList<Order>();
|
|
|
+ goodsCpnSortList.addAll(goodsCpnList);
|
|
|
+
|
|
|
+ // 1. 쿠폰할인금액 순으로 정렬
|
|
|
+ for (int i=0 ; i<goodsCpnList.size() ; i++) {
|
|
|
+ Order tempCpn1 = goodsCpnList.get(i);
|
|
|
+
|
|
|
+ cnt = 0;
|
|
|
+ sameCnt = 0;
|
|
|
+
|
|
|
+ // 2. 몇번째로 큰 할인금액 인지 판단
|
|
|
+ for (int j=0 ; j<goodsCpnList.size() ; j++) {
|
|
|
+ Order tempCpn2 = goodsCpnList.get(j);
|
|
|
+
|
|
|
+ if (tempCpn1.getCpnDcAmt() == tempCpn2.getCpnDcAmt() && i <= j) {
|
|
|
+ sameCnt++;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (tempCpn1.getCpnDcAmt() < tempCpn2.getCpnDcAmt()) {
|
|
|
+ cnt++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sameCnt > 0) {
|
|
|
+ cnt = cnt + (sameCnt - 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ goodsCpnSortList.set(cnt, tempCpn1);
|
|
|
+ }
|
|
|
+
|
|
|
+ return goodsCpnSortList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -786,14 +861,12 @@ public class TscOrderService {
|
|
|
// 1.2 즉시할인 적용가 * 주문수량(장바구니수량)
|
|
|
order.setCurrPrice(order.getCurrPrice() * order.getGoodsQty());
|
|
|
|
|
|
- log.info("order.getResDelvFeeCd() ::: {} ::: order.getGoodsCd() ::: {}", order.getResDelvFeeCd(), order.getGoodsCd());
|
|
|
-
|
|
|
// 1.3 배송정책별 상품 구분
|
|
|
- if (order.getResDelvFeeCd().equals("WMS")) {
|
|
|
+ if ("WMS".equals(order.getResDelvFeeCd())) {
|
|
|
wmsCartList.add(order);
|
|
|
wmsCnt++;
|
|
|
}
|
|
|
- else if (order.getResDelvFeeCd().equals("RES")) {
|
|
|
+ else if ("RES".equals(order.getResDelvFeeCd())) {
|
|
|
resCartList.add(order);
|
|
|
resCnt++;
|
|
|
}
|
|
|
@@ -844,7 +917,7 @@ public class TscOrderService {
|
|
|
// 1. 총알배송 가능 시간 체크
|
|
|
if (orderDao.getDailyDeliveryTimeInfo() > 0) {
|
|
|
// 2. 총알배송 가능 지역 제크
|
|
|
- if(StringUtils.isEmpty(order.getRecipZipcode())) {
|
|
|
+ if (StringUtils.isEmpty(order.getRecipZipcode())) {
|
|
|
rtn = 1;
|
|
|
} else {
|
|
|
if (orderDao.getDailyDeliveryZoneInfo(order) > 0) {
|