Bladeren bron

결제금액 유효성 체크 보완

hoone 4 jaren geleden
bovenliggende
commit
89a808b5aa

+ 132 - 41
src/main/java/com/style24/front/biz/service/TsfOrderService.java

@@ -759,13 +759,6 @@ public class TsfOrderService {
 			resultStr = "포인트 할인 금액정보가 잘못 되었습니다.";
 			return resultStr;
 		}
-		
-		/*
-		if (gfcdUseSumAmt != order.getGfcdUseSumAmt()) {
-			resultStr = "상품권 사용 금액정보가 잘못 되었습니다.";
-			return resultStr;
-		}
-		*/
 
 		if (realOrdSumAmt != order.getRealOrdSumAmt()) {
 			resultStr = "실결제 금액정보가 잘못 되었습니다.";
@@ -787,8 +780,7 @@ public class TsfOrderService {
 		int usGfcdAmt		= 0;
 
 		for (Order orderDetail : orderDetailList) {
-			
-			// TODO
+
 			// 2.1 상품 재고 확인 (상품정보유효성체크)
 			Collection<Cart> params = new ArrayList<Cart>();
 			Cart cart = new Cart();
@@ -911,12 +903,7 @@ public class TsfOrderService {
 			resultStr = "선택하신 사은품의 재고가 부족 합니다.";
 			return resultStr;
 		}
-		
-		// 7. 상품금액체크
-		
-		
-		
-		
+	
 		return resultStr;
 		
 	}
@@ -2189,7 +2176,7 @@ public class TsfOrderService {
 	 */
 	@SuppressWarnings("unchecked")
 	public String orderAmtValidationCheck(Order order) {
-		String result = "";
+		String resultStr = "SUCCESS";
 		
 		Order po = new Order();
 		
@@ -2240,7 +2227,7 @@ public class TsfOrderService {
 			}
 		}
 		
-		// 상품쿠폰, 장바구니쿠폰 적용 금액
+		// 상품쿠폰 적용 금액
 		for (Order od : tmtbGoodsApplyList) {	
 			for (Order tmtbGoods : goodsApplyCpnList) {
 				if (od.getCartSq().equals(tmtbGoods.getCartSq())) {
@@ -2253,11 +2240,103 @@ public class TsfOrderService {
 			}
 		}
 		
+		String dcWay 			= "";
+		int dcVal 				= 0;
+		int maxDcAmt 			= 0;
+		int cartCpnDcSumAmt		= 0;
+		int leftAmt				= 0;
+		int index				= 1;
+		
+		// 장바구니쿠폰 적용 금액
+		for (Order od : tmtbGoodsApplyList) {
+			for (Order cartCpn : cartCpnList) {
+				if (od.getCartCpnSq() == cartCpn.getCustCpnSq()) {
+					for (int i=0 ; i<cartCpn.getCartCpnCartSqArr().length ; i++) {
+						if (od.getCartSq().equals(cartCpn.getCartCpnCartSqArr()[i])) {
+							dcWay 		= cartCpn.getDcWay();
+							dcVal 		= cartCpn.getDcVal();
+							maxDcAmt 	= cartCpn.getMaxDcAmt();
+						}
+					}
+				}
+			}
+		}
 		
 		// 상품쿠폰, 장바구니쿠폰 적용 금액
 		int ordDcSumAmt 	= 0;
 		int ordDcAmt 		= 0;
 		
+		for (Order od : tmtbGoodsApplyList) {
+			// 주문할인금액설정
+			ordDcAmt = od.getOrdAmt() - od.getTmtb1DcAmt() - od.getTmtb2DcAmt() - od.getGoodsCpnDcAmt();
+			ordDcSumAmt = ordDcSumAmt + ordDcAmt;
+			
+			// 율할인일때 할인금액 적용
+			if ("G240_11".equals(dcWay)) {
+				for (Order cartCpn : cartCpnList) {
+					if (od.getCartCpnSq() == cartCpn.getCustCpnSq()) {
+						for (int i=0 ; i<cartCpn.getCartCpnCartSqArr().length ; i++) {
+							if (od.getCartSq().equals(cartCpn.getCartCpnCartSqArr()[i])) {								
+								int cartCpnDcAmt = (ordDcAmt * cartCpn.getDcVal()) / 100;
+								cartCpnDcSumAmt = cartCpnDcSumAmt + cartCpnDcAmt;
+								od.setCartCpnDcAmt(cartCpnDcAmt);
+							}
+						}
+					}
+				}
+			}
+		}
+		
+		// 2021.04.19 최대금액 체크
+		if (maxDcAmt > cartCpnDcSumAmt || maxDcAmt == 0) {
+			log.info("장바구니쿠폰 할인 ::: {} ", dcVal);
+		} else {
+			// 최대값 적용 일때는 금액할인 방식을 적용
+			cartCpnDcSumAmt 	= maxDcAmt;
+			dcVal				= cartCpnDcSumAmt;
+			dcWay 				= "G240_10";
+		}
+		
+		// 금액일때 할인금액 적용
+		if ("G240_10".equals(dcWay)) {
+			cartCpnDcSumAmt = dcVal;
+			leftAmt			= dcVal;
+			index 			= 1;
+			
+			for (Order cartCpn : cartCpnList) {
+				for (Order od : tmtbGoodsApplyList) {
+					// 장바구니 쿠폰 시퀀스 체크
+					if (od.getCartCpnSq() == cartCpn.getCustCpnSq()) {				
+						for (int i=0 ; i<cartCpn.getCartCpnCartSqArr().length ; i++) {
+							// 장바구니 시퀀스 체크
+							if (od.getCartSq().equals(cartCpn.getCartCpnCartSqArr()[i])) {	
+								
+								// 주문금액 - 할인금액(상품쿠폰할인금액)
+								ordDcAmt = od.getOrdAmt() - od.getTmtb1DcAmt() - od.getTmtb2DcAmt() - od.getGoodsCpnDcAmt();
+								double tempDiv1 	= (double) ordDcAmt / ordDcSumAmt;
+								double tempDiv2 	= (double) tempDiv1 * 100.0;
+								double tempDiv 		= (double) Math.round((tempDiv2) * 100.0) / 100.0;
+								
+								int cartCpnDcAmt	= 0;
+						
+								if (index == cartCpn.getCartCpnCartSqArr().length) {
+									cartCpnDcAmt 	= leftAmt;
+								} else {
+									double tempCartCpnDcAmt	= (cartCpnDcSumAmt * tempDiv) / 100;
+									cartCpnDcAmt 	= (int) tempCartCpnDcAmt;
+									leftAmt 		= leftAmt - cartCpnDcAmt;
+								}
+								
+								od.setCartCpnDcAmt(cartCpnDcAmt);
+								
+								index++;
+							}
+						}
+					}
+				}
+			}
+		}
+		
 		for (Order od : tmtbGoodsApplyList) {
 			log.info("----------------------------------------------------------------------------");
 			log.info("cartSq ::: {}"			, od.getCartSq());
@@ -2270,39 +2349,51 @@ public class TsfOrderService {
 			log.info("tmtb2DcAmt ::: {}"		, od.getTmtb2DcAmt());
 			log.info("prePntDcAmt ::: {}"		, od.getPrePntDcAmt());
 			log.info("goodsCpnDcAmt ::: {}"		, od.getGoodsCpnDcAmt());
+			log.info("cartCpnDcAmt ::: {}"		, od.getCartCpnDcAmt());
 			log.info("pntDcAmt ::: {}"			, od.getPntDcAmt());
-			log.info("gfcdUseAmt ::: {}"		, od.getGfcdUseAmt());
-			log.info("pntPrate ::: {}"			, od.getPntPrate());
-			log.info("pntMrate ::: {}"			, od.getPntMrate());
-			
-			if ("Y".equals(od.getPrePntDcAmtYn())) {
-				ordDcAmt = od.getOrdAmt() - od.getTmtb1DcAmt() - od.getTmtb2DcAmt() - od.getGoodsCpnDcAmt()  - od.getPrePntDcAmt();
-			} else {
-				ordDcAmt = od.getOrdAmt() - od.getTmtb1DcAmt() - od.getTmtb2DcAmt() - od.getGoodsCpnDcAmt();
-			}
-
-			ordDcSumAmt = ordDcSumAmt + ordDcAmt;
+			log.info("gfcdUseAmt ::: {}"		, od.getGfcdUseAmt());		
 			
-			/*
-			for (Order cartCpn : cartCpnList) {
-				if (od.getCartCpnSq() == cartCpn.getCustCpnSq()) {
-					for (int i=0 ; i<cartCpn.getCartCpnCartSqArr().length ; i++) {
-						if (od.getCartSq().equals(cartCpn.getCartCpnCartSqArr()[i])) {
-							log.info("vo.getCartSq() ::: {}", od.getCartSq());
-							log.info("cartCpn.getCpnSq() ::: {}", cartCpn.getCpnSq());
-							log.info("cartCpn.getDcWay() ::: {}", cartCpn.getDcWay());
-							log.info("cartCpn.getDcVal() ::: {}", cartCpn.getDcVal());
-							log.info("cartCpn.getMaxDcAmt() ::: {}", cartCpn.getMaxDcAmt());
-							log.info("cartCpn.getBuyLimitAmt() ::: {}", cartCpn.getBuyLimitAmt());
+			for (Order vo : orderDetailList) {
+				if (od.getCartSq().equals(vo.getCartSq())) {
+					if (od.getOrdAmt() != vo.getOrdAmt()) {
+						resultStr = "주문금액정보가 잘못 되었습니다.";
+						return resultStr;
+					}
+					
+					if (od.getTmtb1DcAmt() != vo.getTmtb1DcAmt()) {
+						resultStr = "다다익선수량 할인 금액정보가 잘못 되었습니다.";
+						return resultStr;
+					}
+					
+					if (od.getTmtb2DcAmt() != vo.getTmtb2DcAmt()) {
+						resultStr = "다다익선금액 할인 금액정보가 잘못 되었습니다.";
+						return resultStr;
+					}
+					
+					if (od.getGoodsCpnDcAmt() != vo.getGoodsCpnDcAmt()) {
+						resultStr = "상품쿠폰 할인 금액정보가 잘못 되었습니다.";
+						return resultStr;
+					}
+					
+					if (od.getCartCpnDcAmt() != vo.getCartCpnDcAmt()) {
+						resultStr = "장바구니쿠폰 할인 금액정보가 잘못 되었습니다.";
+						return resultStr;
+					}
+					
+					if ("Y".equals(od.getPrePntDcAmtYn())) {
+						if (od.getPrePntDcAmt() != vo.getPrePntDcAmt()) {
+							resultStr = "선포인트 할인 금액정보가 잘못 되었습니다.";
+							return resultStr;
 						}
 					}
 				}
 			}
-			*/
 			
 			log.info("----------------------------------------------------------------------------");	
 		}
-		return result;
+		
+		
+		return resultStr;
 	}
 
 	/**

+ 6 - 3
src/main/webapp/WEB-INF/views/mob/order/OrderFormMob.html

@@ -2267,8 +2267,8 @@ var custCpnApply = function(obj, idx, cpnType) {
 			});
 		});
 		
-		// 장바구니쿠폰 결제가능수단목록조회
-		if (obj.find("input[name='payTypeArr']").length > 0) {
+		// 장바구니쿠폰 결제가능수단목록조회 2021.10.09 장바구니쿠폰 PG 제어 보정
+		if (obj.find("input[name='payTypeArr']").length > 0 && obj.find("input[name='payTypeArr']").length < 4) {
 			$("#orderForm input[name=rdi-paynormal]").attr("disabled", true);
 			$("#orderForm input[name=rdi-paynormal]").attr("checked", false);
 			
@@ -2302,6 +2302,9 @@ var custCpnApply = function(obj, idx, cpnType) {
 			leftAmt			= dcVal;
 			index 			= 1;
 			
+			// 2021.10.10 장바구니쿠폰 길이 수정 (장바구니쿠폰 적용되지 않은 상품도 있을듯 싶음)
+			cartSqLen = obj.find("input[name='cartCpnCartSq']").length;
+			
 			// 장바구니쿠폰 해당 장바구니상품들 할인가 적용
 			obj.find("input[name='cartCpnCartSq']").each(function(){
 				var cartCpnCartSq 		= $(this).val();
@@ -2318,7 +2321,7 @@ var custCpnApply = function(obj, idx, cpnType) {
 						var goodsCpnDcAmt 	= parseInt($(this).parent().find(".goodsCpnDcAmt").text());
 						
 						var tempAmt 		= ((orgCurrPrice - cpn1DcAmt) * goodsQty) - tmtb1DcAmt - tmtb2DcAmt - goodsCpnDcAmt;
-						var tempDiv 		= (tempAmt / tempSumAmt) * 100;
+						var tempDiv 		= ((tempAmt / tempSumAmt) * 100).toFixed(2);
 						var cartCpnDcAmt	= 0;
 				
 						if (index == cartSqLen) {

+ 8 - 5
src/main/webapp/WEB-INF/views/web/order/OrderFormWeb.html

@@ -617,7 +617,7 @@ $(document).ready( function() {
 	custemerInfoSet();
 	
 	// 999. 개발화면정보설정
-	var devTemp = true;
+	var devTemp = false;
 	var arr = []
 	arr[0] = "orderInfo";
 	arr[1] = "freegiftInfo";
@@ -2077,8 +2077,8 @@ var custCpnApply = function(obj) {
 			});
 		});
 		
-		// 장바구니쿠폰 결제가능수단목록조회
-		if (obj.find("input[name='payTypeArr']").length > 0) {
+		// 장바구니쿠폰 결제가능수단목록조회 2021.10.09 장바구니쿠폰 PG 제어 보정
+		if (obj.find("input[name='payTypeArr']").length > 0 && obj.find("input[name='payTypeArr']").length < 4) {
 			$("#orderForm input[name=rdi-paynormal]").attr("disabled", true);
 			$("#orderForm input[name=rdi-paynormal]").attr("checked", false);
 			
@@ -2113,7 +2113,10 @@ var custCpnApply = function(obj) {
 		if (dcWay == "G240_10") {
 			cartCpnDcSumAmt = dcVal;
 			leftAmt			= dcVal;
-			index 			= 1;
+			index			= 1;
+			
+			// 2021.10.10 장바구니쿠폰 길이 수정 (장바구니쿠폰 적용되지 않은 상품도 있을듯 싶음)
+			cartSqLen = obj.find("input[name='cartCpnCartSq']").length;
 			
 			// 장바구니쿠폰 해당 장바구니상품들 할인가 적용
 			obj.find("input[name='cartCpnCartSq']").each(function(){
@@ -2131,7 +2134,7 @@ var custCpnApply = function(obj) {
 						var goodsCpnDcAmt 	= parseInt($(this).parent().find(".goodsCpnDcAmt").text());
 						
 						var tempAmt 		= ((orgCurrPrice - cpn1DcAmt) * goodsQty) - tmtb1DcAmt - tmtb2DcAmt - goodsCpnDcAmt;
-						var tempDiv 		= (tempAmt / tempSumAmt) * 100;
+						var tempDiv 		= ((tempAmt / tempSumAmt) * 100).toFixed(2);
 						var cartCpnDcAmt	= 0;
 				
 						if (index == cartSqLen) {