|
|
@@ -244,52 +244,10 @@ public class TsfCartService {
|
|
|
// 장바구니 상품 조회
|
|
|
Collection<Order> cartGoodsList = cartDao.getCartGoodsList(order);
|
|
|
|
|
|
- // 품절체크
|
|
|
+ // 품절 아닌 상품만 체크
|
|
|
for(Order goods : cartGoodsList) {
|
|
|
- // 상품 재고 확인
|
|
|
- GoodsStock checkParam = new GoodsStock();
|
|
|
-
|
|
|
- String stockResult = "";
|
|
|
- // 세트 상품일 경우
|
|
|
- if(TscConstants.GoodsType.SET.value().equals(goods.getGoodsType())) {
|
|
|
- Order tempItem = new Order();
|
|
|
- // 세트 구성품이 여러개일 경우
|
|
|
- if (goods.getItemCd().contains(",")) {
|
|
|
- tempItem.setItemCdArr(goods.getItemCd().split(","));
|
|
|
- tempItem.setOptCdArr(goods.getOptCd().split(","));
|
|
|
- for(int i = 0 ; i < tempItem.getItemCdArr().length ; i++) {
|
|
|
- checkParam.setGoodsCd(goods.getGoodsCd());
|
|
|
- checkParam.setItemCd(tempItem.getItemCdArr()[i]);
|
|
|
- checkParam.setOptCd(tempItem.getOptCdArr()[i]);
|
|
|
- checkParam.setGoodsQty(goods.getGoodsQty());
|
|
|
- checkParam.setGoodsType(goods.getGoodsType());
|
|
|
- stockResult = goodsService.getCheckStock(checkParam);
|
|
|
- }
|
|
|
- } else { // 세트 구성품이 하나일 경우
|
|
|
- checkParam.setGoodsCd(goods.getGoodsCd());
|
|
|
- checkParam.setItemCd(goods.getItemCd());
|
|
|
- checkParam.setOptCd(goods.getOptCd());
|
|
|
- checkParam.setGoodsQty(goods.getGoodsQty());
|
|
|
- checkParam.setGoodsType(goods.getGoodsType());
|
|
|
- stockResult = goodsService.getCheckStock(checkParam);
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 세트상품이 아닐 경우
|
|
|
- checkParam.setGoodsCd(goods.getGoodsCd());
|
|
|
- checkParam.setItemCd(goods.getItemCd());
|
|
|
- checkParam.setOptCd(goods.getOptCd());
|
|
|
- checkParam.setGoodsQty(goods.getGoodsQty());
|
|
|
- checkParam.setGoodsType(goods.getGoodsType());
|
|
|
- stockResult = goodsService.getCheckStock(checkParam);
|
|
|
- }
|
|
|
-
|
|
|
- //String stockResult = "SUCCESS";
|
|
|
-
|
|
|
- if("SUCCESS".equals(stockResult)) {
|
|
|
- goods.setSoldoutYn("N");
|
|
|
+ if("N".equals(goods.getSoldoutYn())) {
|
|
|
cartSqs.add(goods.getCartSq());
|
|
|
- } else {
|
|
|
- goods.setSoldoutYn("Y");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -311,8 +269,12 @@ public class TsfCartService {
|
|
|
cart.setAmtTmtbSq(info.getAmtTmtbSq());
|
|
|
}
|
|
|
}
|
|
|
+ if(cart.getCartSq() == 8) {
|
|
|
+ log.info("CHECK CART >> {}, {}, {}",cart.getCurrPrice(),cart.getGoodsQty(), cart.getTmtbDcAmt());
|
|
|
+ }
|
|
|
+
|
|
|
if(cart.getTmtbDcAmt() == 0) {
|
|
|
- cart.setTmtbDcAmt(cart.getCurrPrice());
|
|
|
+ cart.setTmtbDcAmt(cart.getCurrPrice() * cart.getGoodsQty());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -342,56 +304,58 @@ public class TsfCartService {
|
|
|
Collection<Order> cartGoodsList = coreOrderService.getCartGoodsList(param);
|
|
|
|
|
|
// 장바구니 내 수량 다다익선 적용 가능 리스트 조회 (등록된 기본,적용 상품 정보 전체 조회)
|
|
|
- param.setApplyGb(TscConstants.ApplyGb.QTY.value());
|
|
|
- Collection<Order> tmtbQtyApplyList = cartDao.selectMoreBetterApplyCartList(param);
|
|
|
+ Collection<Order> tmtbApplyList = cartDao.selectMoreBetterApplyCartList(param);
|
|
|
|
|
|
- // 장바구니에 담긴 상품 금액 즉시할인가를 tmtbApplyList 에 저장 (추후 계산식을 위함)
|
|
|
- for(Order cart : cartGoodsList) {
|
|
|
- for(Order apply : tmtbQtyApplyList) {
|
|
|
- if(cart.getCartSq() == apply.getCartSq()) {
|
|
|
- apply.setCurrPrice(cart.getCurrPrice() + cart.getOptAddPrice()); /* 즉시할인 적용가 */
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 장바구니 등록 수량 다다익선 일련번호 지정
|
|
|
+ // 장바구니 등록 다다익선 일련번호 지정
|
|
|
+ List<Integer> applySq = new ArrayList<Integer>();
|
|
|
List<Integer> qtyApplySq = new ArrayList<Integer>();
|
|
|
- for(Order tmtbApply : tmtbQtyApplyList) {
|
|
|
- if(TscConstants.GoodsGb.BASE.value().equals(tmtbApply.getGoodsGb())) {
|
|
|
- qtyApplySq.add(tmtbApply.getTmtbSq());
|
|
|
- }
|
|
|
- }
|
|
|
- param.setTmtbSqs(qtyApplySq.stream().mapToInt(Integer::intValue).toArray());
|
|
|
-
|
|
|
- // 장바구니 등록 다다익선 총합 금액
|
|
|
- Collection<Order> tmtbQtySumDataList = cartDao.selectApplyMoreBetterCartInfoList(param);
|
|
|
- // 기본상품 목록에 총합 데이터 등록
|
|
|
- for(Order applyInfo : tmtbQtyApplyList) {
|
|
|
- for(Order tmtbSumInfo : tmtbQtySumDataList) {
|
|
|
- if(applyInfo.getTmtbSq() == tmtbSumInfo.getTmtbSq()) {
|
|
|
- applyInfo.setTmtbSumAmt(tmtbSumInfo.getTmtbSumAmt());
|
|
|
- applyInfo.setTmtbSumQty(tmtbSumInfo.getTmtbSumQty());
|
|
|
+ List<Integer> amtApplySq = new ArrayList<Integer>();
|
|
|
+ for(Order tmtbApply : tmtbApplyList) {
|
|
|
+ if(TscConstants.GoodsGb.BASE.value().equals(tmtbApply.getQtyGoodsGb()) || TscConstants.GoodsGb.BASE.value().equals(tmtbApply.getAmtGoodsGb())) {
|
|
|
+ if(tmtbApply.getQtyTmtbSq() > 0) {
|
|
|
+ applySq.add(tmtbApply.getQtyTmtbSq());
|
|
|
+ }
|
|
|
+ if(tmtbApply.getAmtTmtbSq() > 0) {
|
|
|
+ applySq.add(tmtbApply.getAmtTmtbSq());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ param.setTmtbSqs(applySq.stream().mapToInt(Integer::intValue).toArray());
|
|
|
|
|
|
// 섹션 정보 조회 후 할인 여부 판단
|
|
|
- Collection<Order> tmtbQtySectionList = cartDao.selectTmtbSectionValList(qtyApplySq);
|
|
|
- for(Order applyInfo : tmtbQtyApplyList) { // 기준 상품 및 다다익선 정보 조회
|
|
|
- for(Order section : tmtbQtySectionList) { // 다다익선 할인 조건 조회
|
|
|
- if(applyInfo.getTmtbSq() == section.getTmtbSq()) {
|
|
|
- if(TscConstants.ApplyGb.QTY.value().equals(applyInfo.getApplyGb())) { // 수량 적용
|
|
|
- if(section.getSectionVal() <= applyInfo.getTmtbSumQty()) { // 장바구니 수량 할인 기준 달성시
|
|
|
- if(applyInfo.getSectionVal() <= section.getSectionVal()) { // 기존 달성된 기준치보다 할인폭이 클 경우 기준할인 수정
|
|
|
- applyInfo.setSectionVal(section.getSectionVal());
|
|
|
- applyInfo.setApplyQtySectionYn("Y");
|
|
|
- applyInfo.setDcWay(section.getDcWay());
|
|
|
- applyInfo.setDcVal(section.getDcVal());
|
|
|
- }
|
|
|
- } else {
|
|
|
- if(applyInfo.getSectionVal() < 1 && applyInfo.getGoodsGb().equals(TscConstants.GoodsGb.BASE.value())) {
|
|
|
- applyInfo.setApplyQtySectionYn("N");
|
|
|
- }
|
|
|
+ Collection<Order> tmtbQtySectionList = cartDao.selectTmtbSectionValList(applySq);
|
|
|
+ for(Order applyInfo : tmtbApplyList) { // 기준 상품 및 다다익선 정보 조회
|
|
|
+ // 다다익선 할인 조건 조회
|
|
|
+ for(Order section : tmtbQtySectionList) {
|
|
|
+ if(applyInfo.getQtyTmtbSq() == section.getTmtbSq()) {
|
|
|
+
|
|
|
+ // 수량 적용 다다익선
|
|
|
+ if (section.getSectionVal() <= applyInfo.getQtyTmtbSumQty()) { // 장바구니 수량 할인 기준 달성시
|
|
|
+ if (applyInfo.getSectionVal() <= section.getSectionVal()) { // 기존 달성된 기준치보다 할인폭이 클 경우 기준할인 수정
|
|
|
+ applyInfo.setSectionVal(section.getSectionVal());
|
|
|
+ applyInfo.setApplyQtySectionYn("Y");
|
|
|
+ applyInfo.setDcWay(section.getDcWay());
|
|
|
+ applyInfo.setDcVal(section.getDcVal());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (applyInfo.getSectionVal() < 1 && applyInfo.getQtyGoodsGb().equals(TscConstants.GoodsGb.BASE.value())) {
|
|
|
+ applyInfo.setApplyQtySectionYn("N");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(applyInfo.getAmtTmtbSq() == section.getTmtbSq()) {
|
|
|
+ // 금액 적용 다다익선
|
|
|
+ if(section.getSectionVal() <= applyInfo.getAmtTmtbSumAmt()) { // 장바구니 수량 할인 기준 달성시
|
|
|
+ if(applyInfo.getSectionVal() <= section.getSectionVal()) { // 기존 달성된 기준치보다 할인폭이 클 경우 기준할인 수정
|
|
|
+ applyInfo.setSectionVal(section.getSectionVal());
|
|
|
+ applyInfo.setApplyAmtSectionYn("Y");
|
|
|
+ applyInfo.setDcWay(section.getDcWay());
|
|
|
+ applyInfo.setDcVal(section.getDcVal());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if(applyInfo.getSectionVal() < 1 && applyInfo.getAmtGoodsGb().equals(TscConstants.GoodsGb.BASE.value())) {
|
|
|
+ applyInfo.setApplyAmtSectionYn("N");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -401,11 +365,11 @@ public class TsfCartService {
|
|
|
// 수량 다다익선 적용 상품 할인 금액 계산
|
|
|
int leftAmt = 0;
|
|
|
int i = 0;
|
|
|
- for(Order resultAmt : tmtbQtyApplyList) {
|
|
|
+ for(Order resultAmt : tmtbApplyList) {
|
|
|
if("Y".equals(resultAmt.getApplyQtySectionYn())) {
|
|
|
if (TscConstants.DcWay.AMT.value().equals(resultAmt.getDcWay())) { // 할인 방식 금액일경우
|
|
|
i++;
|
|
|
- int tempAmt = resultAmt.getCurrPrice() * resultAmt.getGoodsQty();
|
|
|
+ int tempAmt = resultAmt.getCurrPrice();
|
|
|
if (i == 1) {
|
|
|
leftAmt = resultAmt.getDcVal();
|
|
|
}
|
|
|
@@ -420,105 +384,23 @@ public class TsfCartService {
|
|
|
resultAmt.setTmtbDcAmt(tempAmt - (int)tempDcAmt);
|
|
|
}
|
|
|
} else { // 할인 방식 할인율일 경우
|
|
|
- int tempAmt = resultAmt.getCurrPrice() * resultAmt.getGoodsQty();
|
|
|
+ int tempAmt = resultAmt.getCurrPrice();
|
|
|
tempAmt = (int) (tempAmt - (tempAmt * (resultAmt.getDcVal() / 100.0)));
|
|
|
resultAmt.setTmtbDcAmt(tempAmt);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 장바구니 정보에 수량 다다익선 정보 입력
|
|
|
- for(Order cart : cartGoodsList) {
|
|
|
- for(Order apply : tmtbQtyApplyList) {
|
|
|
- if(cart.getCartSq() == apply.getCartSq()) {
|
|
|
- cart.setTmtbDcAmt(apply.getTmtbDcAmt());
|
|
|
- cart.setApplyQtySectionYn(apply.getApplyQtySectionYn());
|
|
|
- cart.setQtyTmtbNm(apply.getTmtbNm());
|
|
|
- cart.setQtyTmtbSq(apply.getTmtbSq());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 장바구니 내 금액 다다익선 적용 가능 리스트 조회 (등록된 기본,적용 상품 정보 전체 조회)
|
|
|
- param.setApplyGb(TscConstants.ApplyGb.AMT.value());
|
|
|
- Collection<Order> tmtbAmtApplyList = cartDao.selectMoreBetterApplyCartList(param);
|
|
|
-
|
|
|
- // 장바구니에 담긴 상품 금액 즉시할인가를 tmtbAmtApplyList 에 저장 (추후 계산식을 위함)
|
|
|
- for(Order cart : cartGoodsList) {
|
|
|
- for(Order apply : tmtbAmtApplyList) {
|
|
|
- if(cart.getCartSq() == apply.getCartSq()) {
|
|
|
- if (StringUtils.isEmpty(cart.getQtyTmtbNm())) {
|
|
|
- apply.setCurrPrice((cart.getCurrPrice() + cart.getOptAddPrice()) * cart.getGoodsQty());
|
|
|
- } else {
|
|
|
- apply.setCurrPrice(cart.getTmtbDcAmt()); /* 수량 다다익선 할인된 금액 적용 */
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 장바구니 등록 수량 다다익선 일련번호 지정
|
|
|
- List<Integer> amtApplySq = new ArrayList<Integer>();
|
|
|
- for(Order tmtbApply : tmtbAmtApplyList) {
|
|
|
- if(TscConstants.GoodsGb.BASE.value().equals(tmtbApply.getGoodsGb())) {
|
|
|
- amtApplySq.add(tmtbApply.getTmtbSq());
|
|
|
- }
|
|
|
- }
|
|
|
- param.setTmtbSqs(amtApplySq.stream().mapToInt(Integer::intValue).toArray());
|
|
|
-
|
|
|
- // 장바구니 등록 금액 다다익선 총합 금액
|
|
|
- Collection<Order> tmtbAmtSumDataList = cartDao.selectApplyMoreBetterCartInfoList(param);
|
|
|
-
|
|
|
- Map<Integer, Integer> tmtbAmtSumData = new HashMap<Integer, Integer>(); // 각 상품별 할인 금액을 다다익선별 SUM하기 위한 MAP
|
|
|
- for(Order applyInfo : tmtbAmtApplyList) {
|
|
|
- // SUM AMT는 할인된 금액으로 묶어야함.
|
|
|
- if(tmtbAmtSumData.get(applyInfo.getTmtbSq()) != null && tmtbAmtSumData.get(applyInfo.getTmtbSq()) > 0) {
|
|
|
- tmtbAmtSumData.put(applyInfo.getTmtbSq(), tmtbAmtSumData.get(applyInfo.getTmtbSq()) + applyInfo.getCurrPrice());
|
|
|
+ if(resultAmt.getTmtbDcAmt() > 0) {
|
|
|
+ resultAmt.setCurrPrice(resultAmt.getTmtbDcAmt());
|
|
|
} else {
|
|
|
- tmtbAmtSumData.put(applyInfo.getTmtbSq(), applyInfo.getCurrPrice());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 기본상품 목록에 총합 데이터 등록
|
|
|
- for(Order applyInfo : tmtbAmtApplyList) {
|
|
|
- for(Order tmtbSumInfo : tmtbAmtSumDataList) {
|
|
|
- if(applyInfo.getTmtbSq() == tmtbSumInfo.getTmtbSq()) {
|
|
|
- applyInfo.setTmtbSumQty(tmtbSumInfo.getTmtbSumQty());
|
|
|
-
|
|
|
- if(tmtbAmtSumData.get(applyInfo.getTmtbSq()) != null && tmtbAmtSumData.get(applyInfo.getTmtbSq()) > 0) {
|
|
|
- applyInfo.setTmtbSumAmt(tmtbAmtSumData.get(applyInfo.getTmtbSq()));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // 섹션 정보 조회 후 할인 여부 판단
|
|
|
- Collection<Order> tmtbAmtSectionList = cartDao.selectTmtbSectionValList(amtApplySq);
|
|
|
- for(Order applyInfo : tmtbAmtApplyList) { // 기준 상품 및 다다익선 정보 조회
|
|
|
- for(Order section : tmtbAmtSectionList) { // 다다익선 할인 조건 조회
|
|
|
- if(applyInfo.getTmtbSq() == section.getTmtbSq()) {
|
|
|
- if (TscConstants.ApplyGb.AMT.value().equals(applyInfo.getApplyGb())) {
|
|
|
- if(section.getSectionVal() <= applyInfo.getTmtbSumAmt()) { // 장바구니 수량 할인 기준 달성시
|
|
|
- if(applyInfo.getSectionVal() <= section.getSectionVal()) { // 기존 달성된 기준치보다 할인폭이 클 경우 기준할인 수정
|
|
|
- applyInfo.setSectionVal(section.getSectionVal());
|
|
|
- applyInfo.setApplyAmtSectionYn("Y");
|
|
|
- applyInfo.setDcWay(section.getDcWay());
|
|
|
- applyInfo.setDcVal(section.getDcVal());
|
|
|
- }
|
|
|
- } else {
|
|
|
- if(applyInfo.getSectionVal() < 1 && applyInfo.getGoodsGb().equals(TscConstants.GoodsGb.BASE.value())) {
|
|
|
- applyInfo.setApplyAmtSectionYn("N");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ resultAmt.setCurrPrice(resultAmt.getCurrPrice());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 금액 다다익선 할인 계산
|
|
|
leftAmt = 0;
|
|
|
i = 0;
|
|
|
- for(Order resultAmt : tmtbAmtApplyList) {
|
|
|
+ for(Order resultAmt : tmtbApplyList) {
|
|
|
if("Y".equals(resultAmt.getApplyAmtSectionYn())) {
|
|
|
if (TscConstants.DcWay.AMT.value().equals(resultAmt.getDcWay())) { // 할인 방식 금액일경우
|
|
|
i++;
|
|
|
@@ -546,11 +428,12 @@ public class TsfCartService {
|
|
|
|
|
|
// 장바구니 정보에 수량 다다익선 정보 입력
|
|
|
for(Order cart : cartGoodsList) {
|
|
|
- for(Order apply : tmtbAmtApplyList) {
|
|
|
+ for(Order apply : tmtbApplyList) {
|
|
|
if(cart.getCartSq() == apply.getCartSq()) {
|
|
|
- if(apply.getTmtbDcAmt() > 0) {
|
|
|
- cart.setTmtbDcAmt(apply.getTmtbDcAmt());
|
|
|
- }
|
|
|
+ cart.setTmtbDcAmt(apply.getTmtbDcAmt());
|
|
|
+ cart.setApplyQtySectionYn(apply.getApplyQtySectionYn());
|
|
|
+ cart.setQtyTmtbNm(apply.getQtyTmtbNm());
|
|
|
+ cart.setQtyTmtbSq(apply.getQtyTmtbSq());
|
|
|
cart.setApplyAmtSectionYn(apply.getApplyAmtSectionYn());
|
|
|
cart.setAmtTmtbNm(apply.getTmtbNm());
|
|
|
cart.setAmtTmtbSq(apply.getTmtbSq());
|