|
|
@@ -550,176 +550,178 @@ public class TsfCartService {
|
|
|
param.setFrontGb(TsfSession.getFrontGb());
|
|
|
Collection<Order> cartGoodsList = coreOrderService.getCartGoodsList(param);
|
|
|
|
|
|
- // 장바구니 내 수량 다다익선 적용 가능 리스트 조회 (등록된 기본,적용 상품 정보 전체 조회)
|
|
|
- Collection<Order> tmtbApplyList = cartDao.selectMoreBetterApplyCartList(param);
|
|
|
+ if(param.getCustNo() > 0 ) {
|
|
|
+ // 장바구니 내 수량 다다익선 적용 가능 리스트 조회 (등록된 기본,적용 상품 정보 전체 조회)
|
|
|
+ Collection<Order> tmtbApplyList = cartDao.selectMoreBetterApplyCartList(param);
|
|
|
|
|
|
- // 장바구니 등록 다다익선 일련번호 지정
|
|
|
- List<Integer> applySq = new ArrayList<Integer>();
|
|
|
-
|
|
|
- for(Order tmtbApply : tmtbApplyList) {
|
|
|
- if(TscConstants.GoodsGb.BASE.value().equals(tmtbApply.getQtyGoodsGb()) || TscConstants.GoodsGb.BASE.value().equals(tmtbApply.getAmtGoodsGb())) {
|
|
|
- if(TscConstants.GoodsGb.BASE.value().equals(tmtbApply.getQtyGoodsGb())) {
|
|
|
- applySq.add(tmtbApply.getQtyTmtbSq());
|
|
|
- }
|
|
|
- if(TscConstants.GoodsGb.BASE.value().equals(tmtbApply.getAmtGoodsGb())) {
|
|
|
- applySq.add(tmtbApply.getAmtTmtbSq());
|
|
|
+ // 장바구니 등록 다다익선 일련번호 지정
|
|
|
+ List<Integer> applySq = new ArrayList<Integer>();
|
|
|
+
|
|
|
+ for(Order tmtbApply : tmtbApplyList) {
|
|
|
+ if(TscConstants.GoodsGb.BASE.value().equals(tmtbApply.getQtyGoodsGb()) || TscConstants.GoodsGb.BASE.value().equals(tmtbApply.getAmtGoodsGb())) {
|
|
|
+ if(TscConstants.GoodsGb.BASE.value().equals(tmtbApply.getQtyGoodsGb())) {
|
|
|
+ applySq.add(tmtbApply.getQtyTmtbSq());
|
|
|
+ }
|
|
|
+ if(TscConstants.GoodsGb.BASE.value().equals(tmtbApply.getAmtGoodsGb())) {
|
|
|
+ applySq.add(tmtbApply.getAmtTmtbSq());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- param.setTmtbSqs(applySq.stream().mapToInt(Integer::intValue).toArray());
|
|
|
-
|
|
|
- // 섹션 정보 조회 후 할인 여부 판단
|
|
|
- Collection<Order> tmtbSectionList = cartDao.selectTmtbSectionValList(applySq);
|
|
|
-
|
|
|
- for(Order applyInfo : tmtbApplyList) { // 기준 상품 및 다다익선 정보 조회
|
|
|
- // 다다익선 할인 조건 조회
|
|
|
- for(Order section : tmtbSectionList) {
|
|
|
- if(applyInfo.getQtyTmtbSq() == section.getTmtbSq()) {
|
|
|
- // 수량 적용 다다익선
|
|
|
- if (section.getSectionVal() <= applyInfo.getQtyTmtbSumQty()) { // 장바구니 수량 할인 기준 달성시
|
|
|
- if (applyInfo.getQtySectionVal() <= section.getSectionVal()) { // 기존 달성된 기준치보다 할인폭이 클 경우 기준할인 수정
|
|
|
- applyInfo.setQtySectionVal(section.getSectionVal());
|
|
|
- applyInfo.setApplyQtySectionYn("Y");
|
|
|
- applyInfo.setQtyDcWay(section.getDcWay());
|
|
|
- applyInfo.setQtyDcVal(section.getDcVal());
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (applyInfo.getQtySectionVal() < 1 && applyInfo.getQtyGoodsGb().equals(TscConstants.GoodsGb.BASE.value())) {
|
|
|
- applyInfo.setApplyQtySectionYn("N");
|
|
|
+ param.setTmtbSqs(applySq.stream().mapToInt(Integer::intValue).toArray());
|
|
|
+
|
|
|
+ // 섹션 정보 조회 후 할인 여부 판단
|
|
|
+ Collection<Order> tmtbSectionList = cartDao.selectTmtbSectionValList(applySq);
|
|
|
+
|
|
|
+ for(Order applyInfo : tmtbApplyList) { // 기준 상품 및 다다익선 정보 조회
|
|
|
+ // 다다익선 할인 조건 조회
|
|
|
+ for(Order section : tmtbSectionList) {
|
|
|
+ if(applyInfo.getQtyTmtbSq() == section.getTmtbSq()) {
|
|
|
+ // 수량 적용 다다익선
|
|
|
+ if (section.getSectionVal() <= applyInfo.getQtyTmtbSumQty()) { // 장바구니 수량 할인 기준 달성시
|
|
|
+ if (applyInfo.getQtySectionVal() <= section.getSectionVal()) { // 기존 달성된 기준치보다 할인폭이 클 경우 기준할인 수정
|
|
|
+ applyInfo.setQtySectionVal(section.getSectionVal());
|
|
|
+ applyInfo.setApplyQtySectionYn("Y");
|
|
|
+ applyInfo.setQtyDcWay(section.getDcWay());
|
|
|
+ applyInfo.setQtyDcVal(section.getDcVal());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (applyInfo.getQtySectionVal() < 1 && applyInfo.getQtyGoodsGb().equals(TscConstants.GoodsGb.BASE.value())) {
|
|
|
+ applyInfo.setApplyQtySectionYn("N");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if (applyInfo.getAmtTmtbSq() == section.getTmtbSq()) {
|
|
|
- // 금액 적용 다다익선
|
|
|
- if(section.getSectionVal() <= applyInfo.getAmtTmtbSumAmt()) { // 장바구니 수량 할인 기준 달성시
|
|
|
- if(applyInfo.getAmtSectionVal() <= section.getSectionVal()) { // 기존 달성된 기준치보다 할인폭이 클 경우 기준할인 수정
|
|
|
- applyInfo.setAmtSectionVal(section.getSectionVal());
|
|
|
- applyInfo.setApplyAmtSectionYn("Y");
|
|
|
- applyInfo.setAmtDcWay(section.getDcWay());
|
|
|
- applyInfo.setAmtDcVal(section.getDcVal());
|
|
|
- }
|
|
|
- } else {
|
|
|
- if(applyInfo.getAmtSectionVal() < 1 && applyInfo.getAmtGoodsGb().equals(TscConstants.GoodsGb.BASE.value())) {
|
|
|
- applyInfo.setApplyAmtSectionYn("N");
|
|
|
+ if (applyInfo.getAmtTmtbSq() == section.getTmtbSq()) {
|
|
|
+ // 금액 적용 다다익선
|
|
|
+ if(section.getSectionVal() <= applyInfo.getAmtTmtbSumAmt()) { // 장바구니 수량 할인 기준 달성시
|
|
|
+ if(applyInfo.getAmtSectionVal() <= section.getSectionVal()) { // 기존 달성된 기준치보다 할인폭이 클 경우 기준할인 수정
|
|
|
+ applyInfo.setAmtSectionVal(section.getSectionVal());
|
|
|
+ applyInfo.setApplyAmtSectionYn("Y");
|
|
|
+ applyInfo.setAmtDcWay(section.getDcWay());
|
|
|
+ applyInfo.setAmtDcVal(section.getDcVal());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if(applyInfo.getAmtSectionVal() < 1 && applyInfo.getAmtGoodsGb().equals(TscConstants.GoodsGb.BASE.value())) {
|
|
|
+ applyInfo.setApplyAmtSectionYn("N");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 수량 다다익선에 맞춰 정렬
|
|
|
- Collections.sort((ArrayList<Order>) tmtbApplyList, new Comparator<Order>() {
|
|
|
- @Override
|
|
|
- public int compare(Order c1, Order c2) {
|
|
|
- return c1.getQtyTmtbSq() - c2.getQtyTmtbSq();
|
|
|
- }
|
|
|
- });
|
|
|
+ // 수량 다다익선에 맞춰 정렬
|
|
|
+ Collections.sort((ArrayList<Order>) tmtbApplyList, new Comparator<Order>() {
|
|
|
+ @Override
|
|
|
+ public int compare(Order c1, Order c2) {
|
|
|
+ return c1.getQtyTmtbSq() - c2.getQtyTmtbSq();
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- // 수량 다다익선 적용 상품 할인 금액 계산
|
|
|
- int leftAmt = 0;
|
|
|
- int i = 0;
|
|
|
+ // 수량 다다익선 적용 상품 할인 금액 계산
|
|
|
+ int leftAmt = 0;
|
|
|
+ int i = 0;
|
|
|
|
|
|
- for(Order resultAmt : tmtbApplyList) {
|
|
|
- int tempAmt = 0;
|
|
|
-
|
|
|
- if("Y".equals(resultAmt.getApplyQtySectionYn()) && resultAmt.getQtyTmtbSq() > 0) {
|
|
|
- if (TscConstants.DcWay.AMT.value().equals(resultAmt.getQtyDcWay())) { // 할인 방식 금액일경우
|
|
|
- i++;
|
|
|
- tempAmt = resultAmt.getCurrPrice();
|
|
|
+ for(Order resultAmt : tmtbApplyList) {
|
|
|
+ int tempAmt = 0;
|
|
|
|
|
|
- if (i == 1) {
|
|
|
- leftAmt = resultAmt.getQtyDcVal();
|
|
|
- }
|
|
|
+ if("Y".equals(resultAmt.getApplyQtySectionYn()) && resultAmt.getQtyTmtbSq() > 0) {
|
|
|
+ if (TscConstants.DcWay.AMT.value().equals(resultAmt.getQtyDcWay())) { // 할인 방식 금액일경우
|
|
|
+ i++;
|
|
|
+ tempAmt = resultAmt.getCurrPrice();
|
|
|
|
|
|
- if (i == resultAmt.getQtyTmtbCnt()) {
|
|
|
- resultAmt.setTmtbDcAmt(tempAmt - leftAmt);
|
|
|
- resultAmt.setTmtb1DcAmt(leftAmt); // tmtb1 할인금액
|
|
|
- leftAmt = 0;
|
|
|
- i = 0;
|
|
|
- } else {
|
|
|
- double tempDcAmt = resultAmt.getQtyDcVal() * ((tempAmt) / (double)resultAmt.getQtyTmtbSumAmt());
|
|
|
- leftAmt -= (int)tempDcAmt;
|
|
|
- resultAmt.setTmtbDcAmt(tempAmt - (int)tempDcAmt);
|
|
|
-
|
|
|
- resultAmt.setTmtb1DcAmt((int)tempDcAmt); // tmtb1 할인금액
|
|
|
+ if (i == 1) {
|
|
|
+ leftAmt = resultAmt.getQtyDcVal();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (i == resultAmt.getQtyTmtbCnt()) {
|
|
|
+ resultAmt.setTmtbDcAmt(tempAmt - leftAmt);
|
|
|
+ resultAmt.setTmtb1DcAmt(leftAmt); // tmtb1 할인금액
|
|
|
+ leftAmt = 0;
|
|
|
+ i = 0;
|
|
|
+ } else {
|
|
|
+ double tempDcAmt = resultAmt.getQtyDcVal() * ((tempAmt) / (double)resultAmt.getQtyTmtbSumAmt());
|
|
|
+ leftAmt -= (int)tempDcAmt;
|
|
|
+ resultAmt.setTmtbDcAmt(tempAmt - (int)tempDcAmt);
|
|
|
+
|
|
|
+ resultAmt.setTmtb1DcAmt((int)tempDcAmt); // tmtb1 할인금액
|
|
|
+ }
|
|
|
+ } else { // 할인 방식 할인율일 경우
|
|
|
+ tempAmt = resultAmt.getCurrPrice();
|
|
|
+ tempAmt = (int) (tempAmt - (tempAmt * (resultAmt.getQtyDcVal() / 100.0)));
|
|
|
+ resultAmt.setTmtbDcAmt(tempAmt);
|
|
|
+
|
|
|
+ // 2021.04.29 다다익선할인금액수정
|
|
|
+ resultAmt.setTmtb1DcAmt((int) (resultAmt.getCurrPrice() * (resultAmt.getQtyDcVal() / 100.0))); // tmtb1 할인금액
|
|
|
}
|
|
|
- } else { // 할인 방식 할인율일 경우
|
|
|
- tempAmt = resultAmt.getCurrPrice();
|
|
|
- tempAmt = (int) (tempAmt - (tempAmt * (resultAmt.getQtyDcVal() / 100.0)));
|
|
|
- resultAmt.setTmtbDcAmt(tempAmt);
|
|
|
-
|
|
|
- // 2021.04.29 다다익선할인금액수정
|
|
|
- resultAmt.setTmtb1DcAmt((int) (resultAmt.getCurrPrice() * (resultAmt.getQtyDcVal() / 100.0))); // tmtb1 할인금액
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if (resultAmt.getTmtbDcAmt() > 0) {
|
|
|
- resultAmt.setCurrPrice(resultAmt.getTmtbDcAmt());
|
|
|
+ if (resultAmt.getTmtbDcAmt() > 0) {
|
|
|
+ resultAmt.setCurrPrice(resultAmt.getTmtbDcAmt());
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 금액 다다익선에 맞춰 정렬
|
|
|
- Collections.sort((ArrayList<Order>) tmtbApplyList, new Comparator<Order>() {
|
|
|
- @Override
|
|
|
- public int compare(Order c1, Order c2) {
|
|
|
- return c1.getAmtTmtbSq() - c2.getAmtTmtbSq();
|
|
|
- }
|
|
|
- });
|
|
|
+ // 금액 다다익선에 맞춰 정렬
|
|
|
+ Collections.sort((ArrayList<Order>) tmtbApplyList, new Comparator<Order>() {
|
|
|
+ @Override
|
|
|
+ public int compare(Order c1, Order c2) {
|
|
|
+ return c1.getAmtTmtbSq() - c2.getAmtTmtbSq();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 금액 다다익선 할인 계산
|
|
|
+ leftAmt = 0;
|
|
|
+ i = 0;
|
|
|
+ for(Order resultAmt : tmtbApplyList) {
|
|
|
+ int tempAmt = 0;
|
|
|
+
|
|
|
+ if("Y".equals(resultAmt.getApplyAmtSectionYn()) && resultAmt.getAmtTmtbSq() > 0) {
|
|
|
+ if (TscConstants.DcWay.AMT.value().equals(resultAmt.getAmtDcWay())) { // 할인 방식 금액일경우
|
|
|
+ i++;
|
|
|
+ tempAmt = resultAmt.getCurrPrice();
|
|
|
+ if (i == 1) {
|
|
|
+ leftAmt = resultAmt.getAmtDcVal();
|
|
|
+ }
|
|
|
|
|
|
- // 금액 다다익선 할인 계산
|
|
|
- leftAmt = 0;
|
|
|
- i = 0;
|
|
|
- for(Order resultAmt : tmtbApplyList) {
|
|
|
- int tempAmt = 0;
|
|
|
-
|
|
|
- if("Y".equals(resultAmt.getApplyAmtSectionYn()) && resultAmt.getAmtTmtbSq() > 0) {
|
|
|
- if (TscConstants.DcWay.AMT.value().equals(resultAmt.getAmtDcWay())) { // 할인 방식 금액일경우
|
|
|
- i++;
|
|
|
- tempAmt = resultAmt.getCurrPrice();
|
|
|
- if (i == 1) {
|
|
|
- leftAmt = resultAmt.getAmtDcVal();
|
|
|
- }
|
|
|
+ if (i == resultAmt.getAmtTmtbCnt()) {
|
|
|
+ resultAmt.setTmtbDcAmt(tempAmt - leftAmt);
|
|
|
+ resultAmt.setTmtb2DcAmt(leftAmt); // tmtb1 할인금액
|
|
|
|
|
|
- if (i == resultAmt.getAmtTmtbCnt()) {
|
|
|
- resultAmt.setTmtbDcAmt(tempAmt - leftAmt);
|
|
|
- resultAmt.setTmtb2DcAmt(leftAmt); // tmtb1 할인금액
|
|
|
-
|
|
|
- leftAmt = 0;
|
|
|
- i = 0;
|
|
|
- } else {
|
|
|
- double tempDcAmt = resultAmt.getAmtDcVal() * ((tempAmt) / (double)resultAmt.getAmtTmtbSumAmt());
|
|
|
- leftAmt -= (int)tempDcAmt;
|
|
|
- resultAmt.setTmtbDcAmt(tempAmt - (int)tempDcAmt);
|
|
|
-
|
|
|
- resultAmt.setTmtb2DcAmt((int)tempDcAmt); // tmtb1 할인금액
|
|
|
+ leftAmt = 0;
|
|
|
+ i = 0;
|
|
|
+ } else {
|
|
|
+ double tempDcAmt = resultAmt.getAmtDcVal() * ((tempAmt) / (double)resultAmt.getAmtTmtbSumAmt());
|
|
|
+ leftAmt -= (int)tempDcAmt;
|
|
|
+ resultAmt.setTmtbDcAmt(tempAmt - (int)tempDcAmt);
|
|
|
+
|
|
|
+ resultAmt.setTmtb2DcAmt((int)tempDcAmt); // tmtb1 할인금액
|
|
|
+ }
|
|
|
+ } else { // 할인 방식 할인율일 경우
|
|
|
+ tempAmt = resultAmt.getCurrPrice();
|
|
|
+ tempAmt = (int) (tempAmt - (tempAmt * (resultAmt.getAmtDcVal() / 100.0)));
|
|
|
+ resultAmt.setTmtbDcAmt(tempAmt);
|
|
|
+
|
|
|
+ // 2021.04.29 다다익선할인금액수정
|
|
|
+ resultAmt.setTmtb2DcAmt((int) (resultAmt.getCurrPrice() * (resultAmt.getAmtDcVal() / 100.0))); // tmtb2 할인금액
|
|
|
}
|
|
|
- } else { // 할인 방식 할인율일 경우
|
|
|
- tempAmt = resultAmt.getCurrPrice();
|
|
|
- tempAmt = (int) (tempAmt - (tempAmt * (resultAmt.getAmtDcVal() / 100.0)));
|
|
|
- resultAmt.setTmtbDcAmt(tempAmt);
|
|
|
-
|
|
|
- // 2021.04.29 다다익선할인금액수정
|
|
|
- resultAmt.setTmtb2DcAmt((int) (resultAmt.getCurrPrice() * (resultAmt.getAmtDcVal() / 100.0))); // tmtb2 할인금액
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 장바구니 정보에 수량 다다익선 정보 입력
|
|
|
- for (Order cart : cartGoodsList) {
|
|
|
- for (Order apply : tmtbApplyList) {
|
|
|
- if (cart.getCartSq().equals(apply.getCartSq())) {
|
|
|
- // 2021.02.24 jsh77b
|
|
|
- cart.setTmtb1DcAmt(apply.getTmtb1DcAmt());
|
|
|
- cart.setTmtb2DcAmt(apply.getTmtb2DcAmt());
|
|
|
-
|
|
|
- cart.setTmtbDcAmt(apply.getTmtbDcAmt());
|
|
|
- cart.setApplyQtySectionYn(apply.getApplyQtySectionYn());
|
|
|
- cart.setQtyTmtbNm(apply.getQtyTmtbNm());
|
|
|
- cart.setQtyTmtbSq(apply.getQtyTmtbSq());
|
|
|
- cart.setApplyAmtSectionYn(apply.getApplyAmtSectionYn());
|
|
|
- cart.setAmtTmtbNm(apply.getAmtTmtbNm());
|
|
|
- cart.setAmtTmtbSq(apply.getAmtTmtbSq());
|
|
|
+ // 장바구니 정보에 수량 다다익선 정보 입력
|
|
|
+ for (Order cart : cartGoodsList) {
|
|
|
+ for (Order apply : tmtbApplyList) {
|
|
|
+ if (cart.getCartSq().equals(apply.getCartSq())) {
|
|
|
+ // 2021.02.24 jsh77b
|
|
|
+ cart.setTmtb1DcAmt(apply.getTmtb1DcAmt());
|
|
|
+ cart.setTmtb2DcAmt(apply.getTmtb2DcAmt());
|
|
|
+
|
|
|
+ cart.setTmtbDcAmt(apply.getTmtbDcAmt());
|
|
|
+ cart.setApplyQtySectionYn(apply.getApplyQtySectionYn());
|
|
|
+ cart.setQtyTmtbNm(apply.getQtyTmtbNm());
|
|
|
+ cart.setQtyTmtbSq(apply.getQtyTmtbSq());
|
|
|
+ cart.setApplyAmtSectionYn(apply.getApplyAmtSectionYn());
|
|
|
+ cart.setAmtTmtbNm(apply.getAmtTmtbNm());
|
|
|
+ cart.setAmtTmtbSq(apply.getAmtTmtbSq());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|