|
|
@@ -769,6 +769,7 @@ public class TscOrderService {
|
|
|
|
|
|
Collection<Order> goodsCpnList = new ArrayList<Order>();
|
|
|
Collection<Order> cartCpnList = new ArrayList<Order>();
|
|
|
+ Collection<Order> cartCpnIdList = new ArrayList<Order>();
|
|
|
|
|
|
if (goodsCartCpnApplyList.size() > 0) {
|
|
|
for (Order goodsCartCpnApply : goodsCartCpnApplyList) {
|
|
|
@@ -778,21 +779,27 @@ public class TscOrderService {
|
|
|
}
|
|
|
// 장바구니쿠폰목록
|
|
|
else if ("G230_20".equals(goodsCartCpnApply.getCpnType())) {
|
|
|
- Boolean temp2 = true;
|
|
|
- for (Order cartCpn : cartCpnList) {
|
|
|
- if (cartCpn.getCpnId() == goodsCartCpnApply.getCpnId()) {
|
|
|
- temp2 = false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
// 2021.03.20 장바구니쿠폰 결제가능수단목록조회
|
|
|
order.setCpnId(goodsCartCpnApply.getCpnId());
|
|
|
String[] payTypeArr = orderDao.getCartCpnPaytypeList(order);
|
|
|
goodsCartCpnApply.setPayTypeArr(payTypeArr);
|
|
|
|
|
|
// 쿠폰시퀀스가 중복 없을때 적용
|
|
|
- if (temp2) {
|
|
|
- cartCpnList.add(goodsCartCpnApply);
|
|
|
+ cartCpnList.add(goodsCartCpnApply);
|
|
|
+
|
|
|
+ Boolean temp = true;
|
|
|
+
|
|
|
+ // 2021.09.03 중복쿠폰제거하고 장바구니쿠폰 목록만 만들기
|
|
|
+ if (cartCpnIdList.size() > 0) {
|
|
|
+ for (Order cartCpn : cartCpnIdList) {
|
|
|
+ if (goodsCartCpnApply.getCpnId().equals(cartCpn.getCpnId())) {
|
|
|
+ temp = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (temp) {
|
|
|
+ cartCpnIdList.add(goodsCartCpnApply);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -800,6 +807,7 @@ public class TscOrderService {
|
|
|
|
|
|
resultMap.set("goodsCpnList" , goodsCpnList);
|
|
|
resultMap.set("cartCpnList" , cartCpnList);
|
|
|
+ resultMap.set("cartCpnIdList" , cartCpnIdList);
|
|
|
|
|
|
return resultMap;
|
|
|
}
|
|
|
@@ -918,77 +926,84 @@ public class TscOrderService {
|
|
|
* @author jsh77b
|
|
|
* @since 2021. 02. 02
|
|
|
*/
|
|
|
- public Collection<Order> getCartCpnApplyList(Collection<Order> tmtbGoodsApplyList, Collection<Order> cartCpnAllList) {
|
|
|
+ public Collection<Order> getCartCpnApplyList(Collection<Order> tmtbGoodsApplyList, Collection<Order> cartCpnAllList
|
|
|
+ , Collection<Order> cartCpnIdList) {
|
|
|
+
|
|
|
List<Order> cartApplyCpnList = new ArrayList<Order>();
|
|
|
|
|
|
// 1. 쿠폰대상이 있는 상품만 정리
|
|
|
- for (Order cartCpn : cartCpnAllList) {
|
|
|
- int[] cartCpnCartSqArr = new int[tmtbGoodsApplyList.size()];
|
|
|
- int i = 0;
|
|
|
+
|
|
|
+ // 1. 장바구니쿠폰 ID 목록
|
|
|
+ for (Order cartCpnId : cartCpnIdList) {
|
|
|
+ Boolean temp = true;
|
|
|
int cpnDcAmt = 0;
|
|
|
int ordAmtSum = 0;
|
|
|
+ int i = 0;
|
|
|
+ int len = tmtbGoodsApplyList.size();
|
|
|
+ int[] cartCpnCartSqArr = new int[len];
|
|
|
|
|
|
- Boolean temp = true;
|
|
|
-
|
|
|
- for (Order tmtbGoods : tmtbGoodsApplyList) {
|
|
|
- if ("A".equals(cartCpn.getApplyScope()) || tmtbGoods.getGoodsCd().equals(cartCpn.getGoodsCd())) {
|
|
|
- cartCpnCartSqArr[i] = tmtbGoods.getCartSq();
|
|
|
+ // 2. 장바구니쿠폰 상품 연결 확인 목록
|
|
|
+ for (Order cartCpn : cartCpnAllList) {
|
|
|
+ // 3. 쿠폰 ID 기준으로 데이타 체크
|
|
|
+ if (cartCpnId.getCpnId().equals(cartCpn.getCpnId())) {
|
|
|
+ for (Order tmtbGoods : tmtbGoodsApplyList) {
|
|
|
+ if ("A".equals(cartCpn.getApplyScope()) || tmtbGoods.getGoodsCd().equals(cartCpn.getGoodsCd())) {
|
|
|
+ cartCpnCartSqArr[i] = tmtbGoods.getCartSq();
|
|
|
+ i++;
|
|
|
+
|
|
|
+ // 3.1최소주문금액을 체크를 위한 해당 상품 주문금액 합계
|
|
|
+ if (tmtbGoods.getTmtbDcAmt() > 0) {
|
|
|
+ ordAmtSum = ordAmtSum + tmtbGoods.getTmtbDcAmt();
|
|
|
+ } else {
|
|
|
+ ordAmtSum = ordAmtSum + ((tmtbGoods.getCurrPrice() + tmtbGoods.getOptAddPrice()) * tmtbGoods.getGoodsQty());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.2 할인율 일때 최대금액 판단으로 할인금액 등록
|
|
|
+ if ("G240_11".equals(cartCpn.getDcWay())) {
|
|
|
+ if (tmtbGoods.getTmtbDcAmt() > 0) {
|
|
|
+ cpnDcAmt = cpnDcAmt + (tmtbGoods.getTmtbDcAmt() * cartCpn.getDcVal()) / 100;
|
|
|
+ } else {
|
|
|
+ cpnDcAmt = cpnDcAmt + (((tmtbGoods.getCurrPrice() + tmtbGoods.getOptAddPrice()) * tmtbGoods.getGoodsQty()) * cartCpn.getDcVal()) / 100;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // 최소주문금액을 체크를 위한 해당 상품 주문금액 합계
|
|
|
- if (tmtbGoods.getTmtbDcAmt() > 0) {
|
|
|
- ordAmtSum = ordAmtSum + tmtbGoods.getTmtbDcAmt();
|
|
|
- } else {
|
|
|
- ordAmtSum = ordAmtSum + ((tmtbGoods.getCurrPrice() + tmtbGoods.getOptAddPrice()) * tmtbGoods.getGoodsQty());
|
|
|
+ if ("G240_10".equals(cartCpn.getDcWay())) {
|
|
|
+ cpnDcAmt = cartCpn.getDcVal();
|
|
|
}
|
|
|
|
|
|
- // TODO 장바구니 쿠폰 다다익선할인가로 할인한 금액을 합계
|
|
|
- // 6. 할인율 일때 최대금액 판단으로 할인금액 등록
|
|
|
- if ("G240_11".equals(cartCpn.getDcWay())) {
|
|
|
- if (tmtbGoods.getTmtbDcAmt() > 0) {
|
|
|
- cpnDcAmt = cpnDcAmt + (tmtbGoods.getTmtbDcAmt() * cartCpn.getDcVal()) / 100;
|
|
|
- } else {
|
|
|
- cpnDcAmt = cpnDcAmt + (((tmtbGoods.getCurrPrice() + tmtbGoods.getOptAddPrice()) * tmtbGoods.getGoodsQty()) * cartCpn.getDcVal()) / 100;
|
|
|
- }
|
|
|
+ // 7. 할인금액 최대값보다 작으면 적용 or getMaxDcAmt( == 0 이면 무제한
|
|
|
+ if (cartCpn.getMaxDcAmt() > cpnDcAmt || cartCpn.getMaxDcAmt() == 0) {
|
|
|
+ cartCpn.setCpnDcAmt(cpnDcAmt);
|
|
|
+ } else {
|
|
|
+ cartCpn.setCpnDcAmt(cartCpn.getMaxDcAmt());
|
|
|
}
|
|
|
- i++;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if ("G240_10".equals(cartCpn.getDcWay())) {
|
|
|
- cpnDcAmt = cartCpn.getDcVal();
|
|
|
- }
|
|
|
+
|
|
|
+ // 최소금액주문이상일때 쿠폰사용불가
|
|
|
+ if (cartCpn.getBuyLimitAmt() > ordAmtSum) {
|
|
|
+ cartCpn.setCartCpnCartSqArr(null);
|
|
|
+ } else {
|
|
|
+ cartCpn.setCartCpnCartSqArr(cartCpnCartSqArr);
|
|
|
|
|
|
- // 7. 할인금액 최대값보다 작으면 적용 or getMaxDcAmt( == 0 이면 무제한
|
|
|
- if (cartCpn.getMaxDcAmt() > cpnDcAmt || cartCpn.getMaxDcAmt() == 0) {
|
|
|
- cartCpn.setCpnDcAmt(cpnDcAmt);
|
|
|
- } else {
|
|
|
- cartCpn.setCpnDcAmt(cartCpn.getMaxDcAmt());
|
|
|
- }
|
|
|
-
|
|
|
- // 최소금액주문이상일때 쿠폰사용불가
|
|
|
- if (cartCpn.getBuyLimitAmt() > ordAmtSum) {
|
|
|
- cartCpn.setCartCpnCartSqArr(null);
|
|
|
- } else {
|
|
|
- cartCpn.setCartCpnCartSqArr(cartCpnCartSqArr);
|
|
|
-
|
|
|
- // 2021.05.16 중복쿠폰제거
|
|
|
- for (int j=0 ; j<cartApplyCpnList.size() ; j++) {
|
|
|
- Order cartCpn1 = cartApplyCpnList.get(j);
|
|
|
- if (cartCpn1.getCustCpnSq().equals(cartCpn.getCustCpnSq())) {
|
|
|
- temp = false;
|
|
|
+ // 2021.05.16 중복쿠폰제거
|
|
|
+ for (int j=0 ; j<cartApplyCpnList.size() ; j++) {
|
|
|
+ Order cartCpn1 = cartApplyCpnList.get(j);
|
|
|
+ if (cartCpn1.getCustCpnSq().equals(cartCpn.getCustCpnSq())) {
|
|
|
+ temp = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (temp) {
|
|
|
+ cartApplyCpnList.add(cartCpn);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- if (temp) {
|
|
|
- cartApplyCpnList.add(cartCpn);
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 쿠폰할인금액이 높은순으로 정렬 함수
|
|
|
cartApplyCpnList = getListSort(cartApplyCpnList);
|
|
|
|
|
|
- // TODO 장바구니쿠폰 최대할인 정렬
|
|
|
-
|
|
|
return cartApplyCpnList;
|
|
|
}
|
|
|
|